Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Paul Pluzhnikov <ppluzhnikov@google.com>
To: gdb-patches ml <gdb-patches@sourceware.org>
Cc: Christian Thalinger <Christian.Thalinger@sun.com>
Subject: [patch] Fix Darwin breakage
Date: Fri, 14 Aug 2009 16:32:00 -0000	[thread overview]
Message-ID: <8ac60eac0908140922m57367e9dn464783d8ff625474@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 705 bytes --]

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.

[-- Attachment #2: gdb-macho-20090814.txt --]
[-- Type: text/plain, Size: 2834 bytes --]

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).  */
 

             reply	other threads:[~2009-08-14 16:22 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-14 16:32 Paul Pluzhnikov [this message]
2009-08-14 17:56 ` Paul Pluzhnikov
2009-08-14 19:09   ` Tom Tromey
2009-08-14 18:32 ` Tom Tromey
2009-08-14 19:15   ` Paul Pluzhnikov
2009-08-18 12:24 ` Christian Thalinger
2009-08-18 16:17   ` Paul Pluzhnikov
2009-08-20 17:01     ` Christian Thalinger
2009-08-20 17:09       ` Paul Pluzhnikov
2009-08-20 17:16         ` Christian Thalinger
2009-08-21 11:30         ` Christian Thalinger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8ac60eac0908140922m57367e9dn464783d8ff625474@mail.gmail.com \
    --to=ppluzhnikov@google.com \
    --cc=Christian.Thalinger@sun.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox