[patch] Fix Darwin breakage

Paul Pluzhnikov ppluzhnikov@google.com
Fri Aug 14 16:32:00 GMT 2009


Greetings,

This patch:
  http://sourceware.org/ml/gdb-patches/2009-07/msg00417.html
caused Darwin/MacOSX to stop working with assertion:
  objfiles.c:793: internal-error: qsort_cmp: Assertion
`obj_section_endaddr (sect1) <= sect2_addr' failed.

Turns out this worked only "by accident" before.

Here is a proposed fix. Tested by running "./gdb ./gdb", setting
breakpoints, etc.
(I don't have dejagnu setup on MacOS yet).

Thanks,
-- 
Paul Pluzhnikov

2009-08-14  Paul Pluzhnikov  <ppluzhnikov@google.com>

        * objfiles.h (OBJF_NOT_MAPPED): New macro.
        * objfiles.c (update_section_map): Ignore unmapped objfiles.
        * machoread.c (macho_oso_symfile): Set OBJF_NOT_MAPPED for oso files.
-------------- next part --------------
Index: machoread.c
===================================================================
RCS file: /cvs/src/src/gdb/machoread.c,v
retrieving revision 1.5
diff -p -u -r1.5 machoread.c
--- machoread.c	19 Jun 2009 14:30:30 -0000	1.5
+++ machoread.c	14 Aug 2009 16:08:50 -0000
@@ -406,7 +406,7 @@ macho_oso_symfile (struct objfile *main_
 	      bfd_close (member_bfd);
 	    }
 	    else
-	      symbol_file_add_from_bfd (member_bfd, 0, addrs, 0);
+	      symbol_file_add_from_bfd (member_bfd, 0, addrs, OBJF_NOT_MAPPED);
 	}
       else
 	{
@@ -429,7 +429,7 @@ macho_oso_symfile (struct objfile *main_
 	      continue;
 	    }
   
-	  symbol_file_add_from_bfd (abfd, 0, addrs, 0);
+	  symbol_file_add_from_bfd (abfd, 0, addrs, OBJF_NOT_MAPPED);
 	}
       xfree (oso->symbols);
       xfree (oso->offsets);
@@ -592,7 +592,7 @@ macho_symfile_read (struct objfile *objf
 	  oso_vector = NULL;
 
 	  /* Now recurse: read dwarf from dsym.  */
-	  symbol_file_add_from_bfd (dsym_bfd, 0, NULL, 0);
+	  symbol_file_add_from_bfd (dsym_bfd, 0, NULL, OBJF_NOT_MAPPED);
       
 	  /* Don't try to read dwarf2 from main file or shared libraries.  */
 	  return;
Index: objfiles.c
===================================================================
RCS file: /cvs/src/src/gdb/objfiles.c,v
retrieving revision 1.91
diff -p -u -r1.91 objfiles.c
--- objfiles.c	10 Aug 2009 22:09:22 -0000	1.91
+++ objfiles.c	14 Aug 2009 16:08:50 -0000
@@ -840,16 +840,20 @@ update_section_map (struct obj_section *
     & SEC_THREAD_LOCAL) == 0)
 
   map_size = 0;
-  ALL_OBJSECTIONS (objfile, s)
-    if (insert_p (objfile, s))
-      map_size += 1;
+  ALL_OBJFILES (objfile)	
+    if ((objfile->flags & OBJF_NOT_MAPPED) == 0)
+      ALL_OBJFILE_OSECTIONS (objfile, s)
+	if (insert_p (objfile, s))
+	  map_size += 1;
 
   map = xmalloc (map_size * sizeof (*map));
 
   i = 0;
-  ALL_OBJSECTIONS (objfile, s)
-    if (insert_p (objfile, s))
-      map[i++] = s;
+  ALL_OBJFILES (objfile)	
+    if ((objfile->flags & OBJF_NOT_MAPPED) == 0)
+      ALL_OBJFILE_OSECTIONS (objfile, s)
+	if (insert_p (objfile, s))
+	  map[i++] = s;
 
 #undef insert_p
 
Index: objfiles.h
===================================================================
RCS file: /cvs/src/src/gdb/objfiles.h,v
retrieving revision 1.61
diff -p -u -r1.61 objfiles.h
--- objfiles.h	4 Aug 2009 18:46:05 -0000	1.61
+++ objfiles.h	14 Aug 2009 16:08:50 -0000
@@ -414,6 +414,12 @@ struct objfile
 
 #define OBJF_USERLOADED	(1 << 3)	/* User loaded */
 
+/* This objfile is not mapped into the process address space. We only have it
+   for its debug bits.  One example is MACH-O ("other source") object
+   files.  */
+
+#define OBJF_NOT_MAPPED (1 << 4)        /* Not mapped */
+
 /* The object file that the main symbol table was loaded from (e.g. the
    argument to the "symbol-file" or "file" command).  */
 


More information about the Gdb-patches mailing list