Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* non-contiguous files break dwarf2 init-file recognition
@ 2002-12-11 14:27 Alexandre Oliva
  2002-12-11 14:41 ` Elena Zannoni
  0 siblings, 1 reply; 3+ messages in thread
From: Alexandre Oliva @ 2002-12-11 14:27 UTC (permalink / raw)
  To: gdb-patches

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

If an object file contains functions in CODE sections that are mapped
to different segments, or just non-contiguous memory areas, and the
entry point of the program happens to be in between such areas, we may
end up picking the wrong comp_unit as init file.  This patch fixes it
(as long as the code of the init file itself is contiguous, this
should be fine, otherwise the whole thing has to be redesigned).  Ok
to install?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: gdb-non-contig-comp-unit.patch --]
[-- Type: text/x-patch, Size: 1901 bytes --]

Index: gdb/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	* dwarf2read.c (read_file_scope): Handle non-contiguous
	comp_units, testing entry_point for every subprogram.

Index: gdb/dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.78
diff -u -p -r1.78 dwarf2read.c
--- gdb/dwarf2read.c 11 Dec 2002 20:55:37 -0000 1.78
+++ gdb/dwarf2read.c 11 Dec 2002 21:42:29 -0000
@@ -1710,9 +1710,15 @@ read_file_scope (struct die_info *die, s
   struct die_info *child_die;
   bfd *abfd = objfile->obfd;
   struct line_header *line_header = 0;
+  CORE_ADDR entry_point = objfile->ei.entry_point - baseaddr;
+  int init_file = 0;
 
   if (!dwarf2_get_pc_bounds (die, &lowpc, &highpc, objfile))
     {
+      if (entry_point >= lowpc && entry_point < highpc
+	  && lowpc != ((CORE_ADDR) -1))
+	init_file = 1;
+      
       if (die->has_children)
 	{
 	  child_die = die->next;
@@ -1724,6 +1730,17 @@ read_file_scope (struct die_info *die, s
 
 		  if (dwarf2_get_pc_bounds (child_die, &low, &high, objfile))
 		    {
+		      /* We want to do this test per subprogram, so
+			 that, if the comp_unit is not contiguous
+			 (e.g., it has code in several sections that
+			 are not mapped to a single segment, such that
+			 there is code from other comp_units
+			 interspersed with code from this one), we
+			 don't get false positives.  */
+		      if (entry_point >= low && entry_point < high
+			  && lowpc != ((CORE_ADDR) -1))
+			init_file = 1;
+
 		      lowpc = min (lowpc, low);
 		      highpc = max (highpc, high);
 		    }
@@ -1760,8 +1777,7 @@ read_file_scope (struct die_info *die, s
 	}
     }
 
-  if (objfile->ei.entry_point >= lowpc &&
-      objfile->ei.entry_point < highpc)
+  if (init_file)
     {
       objfile->ei.entry_file_lowpc = lowpc;
       objfile->ei.entry_file_highpc = highpc;

[-- Attachment #3: Type: text/plain, Size: 289 bytes --]


-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                 aoliva@{redhat.com, gcc.gnu.org}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist                Professional serial bug killer

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: non-contiguous files break dwarf2 init-file recognition
  2002-12-11 14:27 non-contiguous files break dwarf2 init-file recognition Alexandre Oliva
@ 2002-12-11 14:41 ` Elena Zannoni
  2002-12-11 20:36   ` Alexandre Oliva
  0 siblings, 1 reply; 3+ messages in thread
From: Elena Zannoni @ 2002-12-11 14:41 UTC (permalink / raw)
  To: Alexandre Oliva; +Cc: gdb-patches

Alexandre Oliva writes:
 > If an object file contains functions in CODE sections that are mapped
 > to different segments, or just non-contiguous memory areas, and the
 > entry point of the program happens to be in between such areas, we may
 > end up picking the wrong comp_unit as init file.  This patch fixes it
 > (as long as the code of the init file itself is contiguous, this
 > should be fine, otherwise the whole thing has to be redesigned).  Ok
 > to install?
 > 

How odd.  I am just looking at an old patch that was dealing with
DW_AT_ranges, from rth:
http://sources.redhat.com/ml/gdb-patches/2001-12/msg00616.html I am
trying tointegrate that at the moment because the lexical blocks are
broken. (see gdb gnats pr 833). Would that patch help you here?
Probably not.

Elena


 > Index: gdb/ChangeLog
 > from  Alexandre Oliva  <aoliva@redhat.com>
 > 
 > 	* dwarf2read.c (read_file_scope): Handle non-contiguous
 > 	comp_units, testing entry_point for every subprogram.
 > 
 > Index: gdb/dwarf2read.c
 > ===================================================================
 > RCS file: /cvs/src/src/gdb/dwarf2read.c,v
 > retrieving revision 1.78
 > diff -u -p -r1.78 dwarf2read.c
 > --- gdb/dwarf2read.c 11 Dec 2002 20:55:37 -0000 1.78
 > +++ gdb/dwarf2read.c 11 Dec 2002 21:42:29 -0000
 > @@ -1710,9 +1710,15 @@ read_file_scope (struct die_info *die, s
 >    struct die_info *child_die;
 >    bfd *abfd = objfile->obfd;
 >    struct line_header *line_header = 0;
 > +  CORE_ADDR entry_point = objfile->ei.entry_point - baseaddr;
 > +  int init_file = 0;
 >  
 >    if (!dwarf2_get_pc_bounds (die, &lowpc, &highpc, objfile))
 >      {
 > +      if (entry_point >= lowpc && entry_point < highpc
 > +	  && lowpc != ((CORE_ADDR) -1))
 > +	init_file = 1;
 > +      
 >        if (die->has_children)
 >  	{
 >  	  child_die = die->next;
 > @@ -1724,6 +1730,17 @@ read_file_scope (struct die_info *die, s
 >  
 >  		  if (dwarf2_get_pc_bounds (child_die, &low, &high, objfile))
 >  		    {
 > +		      /* We want to do this test per subprogram, so
 > +			 that, if the comp_unit is not contiguous
 > +			 (e.g., it has code in several sections that
 > +			 are not mapped to a single segment, such that
 > +			 there is code from other comp_units
 > +			 interspersed with code from this one), we
 > +			 don't get false positives.  */
 > +		      if (entry_point >= low && entry_point < high
 > +			  && lowpc != ((CORE_ADDR) -1))
 > +			init_file = 1;
 > +
 >  		      lowpc = min (lowpc, low);
 >  		      highpc = max (highpc, high);
 >  		    }
 > @@ -1760,8 +1777,7 @@ read_file_scope (struct die_info *die, s
 >  	}
 >      }
 >  
 > -  if (objfile->ei.entry_point >= lowpc &&
 > -      objfile->ei.entry_point < highpc)
 > +  if (init_file)
 >      {
 >        objfile->ei.entry_file_lowpc = lowpc;
 >        objfile->ei.entry_file_highpc = highpc;
 > 
 > -- 
 > Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
 > Red Hat GCC Developer                 aoliva@{redhat.com, gcc.gnu.org}
 > CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
 > Free Software Evangelist                Professional serial bug killer


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: non-contiguous files break dwarf2 init-file recognition
  2002-12-11 14:41 ` Elena Zannoni
@ 2002-12-11 20:36   ` Alexandre Oliva
  0 siblings, 0 replies; 3+ messages in thread
From: Alexandre Oliva @ 2002-12-11 20:36 UTC (permalink / raw)
  To: Elena Zannoni; +Cc: gdb-patches

On Dec 11, 2002, Elena Zannoni <ezannoni@redhat.com> wrote:

> http://sources.redhat.com/ml/gdb-patches/2001-12/msg00616.html
> Would that patch help you here?
> Probably not.

Definitely not.  The case at hand has debugging info for a function
whose oddly-named section was explicitly discarded by a linker script,
but whose lowpc was not at the beginning of the section, so, even
though the section address ended up as zero, it wasn't zero for lowpc
of the function, so the lowpc==0 test in dwarf2_get_pc_bounds() didn't
pass and the debugging info for the function was not discarded.

Then, since the comp_unit had code in .text too, the final
lowpc/highpc region contained all code from zero to the end of the
.text code in the comp_unit, and the program entry point happened to
be in between, so we thought that comp_unit was the entry_file, and
the excessively-inclusive region ended up being used to tell whether
a stack trace had got to the top of the stack.

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                 aoliva@{redhat.com, gcc.gnu.org}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist                Professional serial bug killer


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-12-12  1:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-11 14:27 non-contiguous files break dwarf2 init-file recognition Alexandre Oliva
2002-12-11 14:41 ` Elena Zannoni
2002-12-11 20:36   ` Alexandre Oliva

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox