public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Generate DW_AT_ranges for non-contiguous code
@ 2006-07-31 23:22 Sterling Augustine
  2006-08-07 10:55 ` Nick Clifton
  2006-10-10 11:30 ` Andreas Schwab
  0 siblings, 2 replies; 14+ messages in thread
From: Sterling Augustine @ 2006-07-31 23:22 UTC (permalink / raw)
  To: binutils

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

Let's try this again...

This enclosed (fixed) patch adds support for DW_AT_ranges when assembly 
code is noncontiguous. See: 
http://sourceware.org/ml/gdb/2006-05/msg00015.html for a discussion of 
the problem this is addressing.

I believe Tensilica's copyright assignment is already on file.

One issue here is that this particular usage of DW_AT_ranges is dwarf 3,
and gas emits 2 for the dwarf version number. Don't know the right thing
to do there. Bumping the version number for this seems extreme.

Let me know any issues...

Sterling Augustine
Member of Technical Staff
Tensilica, Inc.

gas/

2006-07-31  Sterling Augustine  <sterling@tensilica.com>

     * dwarf2dbg.c (out_debug_info): Add new parameter ranges_seg
     and emit DW_AT_ranges when code in compilation unit is not
     contiguous.
     (out_debug_abbrev): Emit DW_AT_ranges abbreviation if code in
     is not contiguous.
     (dwarf2_finish): Create and pass ranges_seg to out_debug_info.
     (out_debug_ranges): New function to emit .debug_ranges section
     when code is not contiguous.




[-- Attachment #2: discont.patch --]
[-- Type: text/plain, Size: 4539 bytes --]

--- binutils-060728/gas/dwarf2dbg.c	2006-06-07 04:27:57.000000000 -0700
+++ updated/gas/dwarf2dbg.c	2006-07-31 11:11:58.584415000 -0700
@@ -201,8 +201,9 @@ static void process_entries (segT, struc
 static void out_file_list (void);
 static void out_debug_line (segT);
 static void out_debug_aranges (segT, segT);
+static void out_debug_ranges (segT);
 static void out_debug_abbrev (segT);
-static void out_debug_info (segT, segT, segT);
+static void out_debug_info (segT, segT, segT, segT);
 \f
 #ifndef TC_DWARF2_EMIT_OFFSET
 # define TC_DWARF2_EMIT_OFFSET  generic_dwarf2_emit_offset
@@ -1293,6 +1294,54 @@ out_debug_line (segT line_seg)
 /* Emit data for .debug_aranges.  */
 
 static void
+out_debug_ranges (segT ranges_seg)
+{
+  unsigned int addr_size = sizeof_address;
+  struct line_seg *s;
+  expressionS expr;
+  unsigned int i;
+
+  subseg_set (ranges_seg, 0);
+
+  /* Base Address Entry.  */
+  for (i = 0; i < addr_size; i++) 
+      out_byte (0xff);
+  for (i = 0; i < addr_size; i++) 
+      out_byte (0);
+
+  /* Range List Entry.  */
+  for (s = all_segs; s; s = s->next)
+    {
+      fragS *frag;
+      symbolS *beg, *end;
+
+      frag = first_frag_for_seg (s->seg);
+      beg = symbol_temp_new (s->seg, 0, frag);
+      s->text_start = beg;
+
+      frag = last_frag_for_seg (s->seg);
+      end = symbol_temp_new (s->seg, get_frag_fix (frag, s->seg), frag);
+      s->text_end = end;
+
+      expr.X_op = O_symbol;
+      expr.X_add_symbol = beg;
+      expr.X_add_number = 0;
+      emit_expr (&expr, addr_size);
+
+      expr.X_op = O_symbol;
+      expr.X_add_symbol = end;
+      expr.X_add_number = 0;
+      emit_expr (&expr, addr_size);
+    }
+
+  /* End of Range Entry.   */
+  for (i = 0; i < addr_size; i++) 
+      out_byte (0);
+  for (i = 0; i < addr_size; i++) 
+      out_byte (0);
+}
+
+static void
 out_debug_aranges (segT aranges_seg, segT info_seg)
 {
   unsigned int addr_size = sizeof_address;
@@ -1382,6 +1431,13 @@ out_debug_abbrev (segT abbrev_seg)
       out_abbrev (DW_AT_low_pc, DW_FORM_addr);
       out_abbrev (DW_AT_high_pc, DW_FORM_addr);
     }
+  else
+    {
+      if (DWARF2_FORMAT () == dwarf2_format_32bit)
+	out_abbrev (DW_AT_ranges, DW_FORM_data4);
+      else
+	out_abbrev (DW_AT_ranges, DW_FORM_data8);
+    }
   out_abbrev (DW_AT_name, DW_FORM_string);
   out_abbrev (DW_AT_comp_dir, DW_FORM_string);
   out_abbrev (DW_AT_producer, DW_FORM_string);
@@ -1395,7 +1451,7 @@ out_debug_abbrev (segT abbrev_seg)
 /* Emit a description of this compilation unit for .debug_info.  */
 
 static void
-out_debug_info (segT info_seg, segT abbrev_seg, segT line_seg)
+out_debug_info (segT info_seg, segT abbrev_seg, segT line_seg, segT ranges_seg)
 {
   char producer[128];
   char *comp_dir;
@@ -1458,8 +1514,7 @@ out_debug_info (segT info_seg, segT abbr
   /* ??? sizeof_offset */
   TC_DWARF2_EMIT_OFFSET (section_symbol (line_seg), 4);
 
-  /* These two attributes may only be emitted if all of the code is
-     contiguous.  Multiple sections are not that.  */
+  /* These two attributes are emitted if all of the code is contiguous.  */
   if (all_segs->next == NULL)
     {
       /* DW_AT_low_pc */
@@ -1474,6 +1529,16 @@ out_debug_info (segT info_seg, segT abbr
       expr.X_add_number = 0;
       emit_expr (&expr, sizeof_address);
     }
+  else
+    {
+      /* This attributes is emitted if the code is disjoint.  */
+      
+      /* DW_AT_ranges */
+      expr.X_op = O_symbol;
+      expr.X_add_symbol = section_symbol (ranges_seg);
+      expr.X_add_number = 0;
+      emit_expr (&expr, sizeof_address);
+    }
 
   /* DW_AT_name.  We don't have the actual file name that was present
      on the command line, so assume files[1] is the main input file.
@@ -1564,6 +1629,7 @@ dwarf2_finish (void)
     {
       segT abbrev_seg;
       segT aranges_seg;
+      segT ranges_seg;
 
       assert (all_segs);
       
@@ -1580,8 +1646,19 @@ dwarf2_finish (void)
 
       record_alignment (aranges_seg, ffs (2 * sizeof_address) - 1);
 
+      if (all_segs->next == NULL)
+	ranges_seg = NULL;
+      else
+	{
+	  ranges_seg = subseg_new (".debug_ranges", 0);
+	  bfd_set_section_flags (stdoutput, ranges_seg, 
+				 SEC_READONLY | SEC_DEBUGGING);
+	  record_alignment (ranges_seg, ffs (2 * sizeof_address) - 1);
+	  out_debug_ranges (ranges_seg);
+	}
+
       out_debug_aranges (aranges_seg, info_seg);
       out_debug_abbrev (abbrev_seg);
-      out_debug_info (info_seg, abbrev_seg, line_seg);
+      out_debug_info (info_seg, abbrev_seg, line_seg, ranges_seg);
     }
 }

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

* Re: Generate DW_AT_ranges for non-contiguous code
  2006-07-31 23:22 Generate DW_AT_ranges for non-contiguous code Sterling Augustine
@ 2006-08-07 10:55 ` Nick Clifton
  2006-08-07 13:30   ` Daniel Jacobowitz
  2006-10-10 11:30 ` Andreas Schwab
  1 sibling, 1 reply; 14+ messages in thread
From: Nick Clifton @ 2006-08-07 10:55 UTC (permalink / raw)
  To: Sterling Augustine; +Cc: binutils

Hi Sterling,

> This enclosed (fixed) patch adds support for DW_AT_ranges when assembly 
> code is noncontiguous. See: 
> http://sourceware.org/ml/gdb/2006-05/msg00015.html for a discussion of 
> the problem this is addressing.

Does it really ?  I tried using a patched set of sources and I found 
that GDB was still unable to report the file or line number of either 
'main' or 'foo' when they were in different sections.

> I believe Tensilica's copyright assignment is already on file.

It is.

> One issue here is that this particular usage of DW_AT_ranges is dwarf 3,
> and gas emits 2 for the dwarf version number. Don't know the right thing
> to do there. Bumping the version number for this seems extreme.

Hmm, have you tried bumping the version number and seeing how it affects 
GDB ?  I am thinking that maybe it is the right thing to do, although it 
may be necessary to add another GAS command line switch to disable the 
generation of DWARF3 specific debug info for environments with debuggers 
that cannot handle it.

Cheers
   Nick

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

* Re: Generate DW_AT_ranges for non-contiguous code
  2006-08-07 10:55 ` Nick Clifton
@ 2006-08-07 13:30   ` Daniel Jacobowitz
  2006-08-07 14:08     ` Nick Clifton
  2006-08-07 14:08     ` Nick Clifton
  0 siblings, 2 replies; 14+ messages in thread
From: Daniel Jacobowitz @ 2006-08-07 13:30 UTC (permalink / raw)
  To: Nick Clifton; +Cc: Sterling Augustine, binutils

On Mon, Aug 07, 2006 at 11:54:51AM +0100, Nick Clifton wrote:
> >One issue here is that this particular usage of DW_AT_ranges is dwarf 3,
> >and gas emits 2 for the dwarf version number. Don't know the right thing
> >to do there. Bumping the version number for this seems extreme.
> 
> Hmm, have you tried bumping the version number and seeing how it affects 
> GDB ?  I am thinking that maybe it is the right thing to do, although it 
> may be necessary to add another GAS command line switch to disable the 
> generation of DWARF3 specific debug info for environments with debuggers 
> that cannot handle it.

Sterling is actually correct; you shouldn't bump the version number for
this.  Every major revision of the DWARF standard which includes a
version number bump also includes some incompatible format changes
(i.e. a situation where you need to know which version it is, in order
to parse it correctly).  From .debug_info version 2 to .debug_info
version 3 there were only tiny changes; one was the size of an address
versus the size indicated in the dwarf header, and another was the use
of a LEB128 versus a byte.

If you are only adding new attributes or tags from dwarf3, version 2
consumers will generally handle it correctly.

-- 
Daniel Jacobowitz
CodeSourcery

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

* Re: Generate DW_AT_ranges for non-contiguous code
  2006-08-07 13:30   ` Daniel Jacobowitz
@ 2006-08-07 14:08     ` Nick Clifton
  2006-08-07 14:08     ` Nick Clifton
  1 sibling, 0 replies; 14+ messages in thread
From: Nick Clifton @ 2006-08-07 14:08 UTC (permalink / raw)
  To: Nick Clifton, Sterling Augustine, binutils

Hi Daniel,

>>> One issue here is that this particular usage of DW_AT_ranges is dwarf 3,
>>> and gas emits 2 for the dwarf version number. Don't know the right thing
>>> to do there. Bumping the version number for this seems extreme.
>> Hmm, have you tried bumping the version number and seeing how it affects 
>> GDB ?  I am thinking that maybe it is the right thing to do, although it 
>> may be necessary to add another GAS command line switch to disable the 
>> generation of DWARF3 specific debug info for environments with debuggers 
>> that cannot handle it.
> 
> Sterling is actually correct; you shouldn't bump the version number for
> this.  Every major revision of the DWARF standard which includes a
> version number bump also includes some incompatible format changes
> (i.e. a situation where you need to know which version it is, in order
> to parse it correctly).  From .debug_info version 2 to .debug_info
> version 3 there were only tiny changes; one was the size of an address
> versus the size indicated in the dwarf header, and another was the use
> of a LEB128 versus a byte.
> 
> If you are only adding new attributes or tags from dwarf3, version 2
> consumers will generally handle it correctly.

Ok thanks - in which case the patch looks good, but I would like 
Sterling to confirm that it actually fixes the problem since it did not 
appear to do so for me.

Cheers
   Nick


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

* Re: Generate DW_AT_ranges for non-contiguous code
  2006-08-07 13:30   ` Daniel Jacobowitz
  2006-08-07 14:08     ` Nick Clifton
@ 2006-08-07 14:08     ` Nick Clifton
  2006-08-07 20:30       ` Sterling Augustine
  1 sibling, 1 reply; 14+ messages in thread
From: Nick Clifton @ 2006-08-07 14:08 UTC (permalink / raw)
  To: Nick Clifton, Sterling Augustine, binutils

Hi Daniel,

>>> One issue here is that this particular usage of DW_AT_ranges is dwarf 3,
>>> and gas emits 2 for the dwarf version number. Don't know the right thing
>>> to do there. Bumping the version number for this seems extreme.
>> Hmm, have you tried bumping the version number and seeing how it affects 
>> GDB ?  I am thinking that maybe it is the right thing to do, although it 
>> may be necessary to add another GAS command line switch to disable the 
>> generation of DWARF3 specific debug info for environments with debuggers 
>> that cannot handle it.
> 
> Sterling is actually correct; you shouldn't bump the version number for
> this.  Every major revision of the DWARF standard which includes a
> version number bump also includes some incompatible format changes
> (i.e. a situation where you need to know which version it is, in order
> to parse it correctly).  From .debug_info version 2 to .debug_info
> version 3 there were only tiny changes; one was the size of an address
> versus the size indicated in the dwarf header, and another was the use
> of a LEB128 versus a byte.
> 
> If you are only adding new attributes or tags from dwarf3, version 2
> consumers will generally handle it correctly.

Ok thanks - in which case the patch looks good, but I would like 
Sterling to confirm that it actually fixes the problem since it did not 
appear to do so for me.

Cheers
   Nick


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

* Re: Generate DW_AT_ranges for non-contiguous code
  2006-08-07 14:08     ` Nick Clifton
@ 2006-08-07 20:30       ` Sterling Augustine
  2006-08-07 21:46         ` Daniel Jacobowitz
  0 siblings, 1 reply; 14+ messages in thread
From: Sterling Augustine @ 2006-08-07 20:30 UTC (permalink / raw)
  To: Nick Clifton; +Cc: binutils

Nick Clifton wrote:
> Ok thanks - in which case the patch looks good, but I would like 
> Sterling to confirm that it actually fixes the problem since it did not 
> appear to do so for me.

I believe that the debugging information is correct. However gdb's 
support of DW_AT_ranges is immature. At least as far as I can tell.

gdb/dwarf2read.c:read_partial_die--which handles low_pc and high_pc 
attributes in the normal case--ignores the ranges attribute completely. 
This is one location in gdb that will have to be fixed.

Also bfd/dwarf2.c:scan_unit_for_symbols also only supports aranges 
inside functions, but not inside compilation units. This is another 
place that gdb will need to be fixed for full support.

I'm probably missing others.

In any event, I believe that this is the correct first step to a 
solution, rather than the complete solution.

Thanks,

Sterling

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

* Re: Generate DW_AT_ranges for non-contiguous code
  2006-08-07 20:30       ` Sterling Augustine
@ 2006-08-07 21:46         ` Daniel Jacobowitz
  2006-08-07 22:00           ` Sterling Augustine
  0 siblings, 1 reply; 14+ messages in thread
From: Daniel Jacobowitz @ 2006-08-07 21:46 UTC (permalink / raw)
  To: Sterling Augustine; +Cc: Nick Clifton, binutils

On Mon, Aug 07, 2006 at 01:30:33PM -0700, Sterling Augustine wrote:
> Nick Clifton wrote:
> >Ok thanks - in which case the patch looks good, but I would like 
> >Sterling to confirm that it actually fixes the problem since it did not 
> >appear to do so for me.
> 
> I believe that the debugging information is correct. However gdb's 
> support of DW_AT_ranges is immature. At least as far as I can tell.
> 
> gdb/dwarf2read.c:read_partial_die--which handles low_pc and high_pc 
> attributes in the normal case--ignores the ranges attribute completely. 
> This is one location in gdb that will have to be fixed.
> 
> Also bfd/dwarf2.c:scan_unit_for_symbols also only supports aranges 
> inside functions, but not inside compilation units. This is another 
> place that gdb will need to be fixed for full support.
> 
> I'm probably missing others.
> 
> In any event, I believe that this is the correct first step to a 
> solution, rather than the complete solution.

You are probably correct.

I posted a patch to the GDB list recently which handled DW_AT_ranges
for lexical blocks better - not perfect, but pretty good.  The same
approach could be used to handle compilation units.

So in the mean time, I recommend that you verify by hand that the
debugging information is better than before, rather than relying on
GDB.

-- 
Daniel Jacobowitz
CodeSourcery

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

* Re: Generate DW_AT_ranges for non-contiguous code
  2006-08-07 21:46         ` Daniel Jacobowitz
@ 2006-08-07 22:00           ` Sterling Augustine
  2006-08-08  8:29             ` Nick Clifton
  0 siblings, 1 reply; 14+ messages in thread
From: Sterling Augustine @ 2006-08-07 22:00 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: Nick Clifton, binutils

Daniel Jacobowitz wrote:
> So in the mean time, I recommend that you verify by hand that the
> debugging information is better than before, rather than relying on
> GDB.

readelf --debug-dump shows what looks to me like correct debug info. At 
least as far as I can tell.




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

* Re: Generate DW_AT_ranges for non-contiguous code
  2006-08-07 22:00           ` Sterling Augustine
@ 2006-08-08  8:29             ` Nick Clifton
  0 siblings, 0 replies; 14+ messages in thread
From: Nick Clifton @ 2006-08-08  8:29 UTC (permalink / raw)
  To: Sterling Augustine; +Cc: Daniel Jacobowitz, binutils

Hi Sterling,

>> So in the mean time, I recommend that you verify by hand that the
>> debugging information is better than before, rather than relying on
>> GDB.
> 
> readelf --debug-dump shows what looks to me like correct debug info. At 
> least as far as I can tell.

Great - in which case I have applied your patch to the sources.

Cheers
   Nick


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

* Re: Generate DW_AT_ranges for non-contiguous code
  2006-07-31 23:22 Generate DW_AT_ranges for non-contiguous code Sterling Augustine
  2006-08-07 10:55 ` Nick Clifton
@ 2006-10-10 11:30 ` Andreas Schwab
  2006-10-10 20:58   ` Sterling Augustine
  1 sibling, 1 reply; 14+ messages in thread
From: Andreas Schwab @ 2006-10-10 11:30 UTC (permalink / raw)
  To: Sterling Augustine; +Cc: binutils

Sterling Augustine <sterling@tensilica.com> writes:

> @@ -1382,6 +1431,13 @@ out_debug_abbrev (segT abbrev_seg)
>        out_abbrev (DW_AT_low_pc, DW_FORM_addr);
>        out_abbrev (DW_AT_high_pc, DW_FORM_addr);
>      }
> +  else
> +    {
> +      if (DWARF2_FORMAT () == dwarf2_format_32bit)
> +	out_abbrev (DW_AT_ranges, DW_FORM_data4);
> +      else
> +	out_abbrev (DW_AT_ranges, DW_FORM_data8);
> +    }

Here you use DW_FORM_data4.

> @@ -1474,6 +1529,16 @@ out_debug_info (segT info_seg, segT abbr
>        expr.X_add_number = 0;
>        emit_expr (&expr, sizeof_address);
>      }
> +  else
> +    {
> +      /* This attributes is emitted if the code is disjoint.  */
> +      
> +      /* DW_AT_ranges */
> +      expr.X_op = O_symbol;
> +      expr.X_add_symbol = section_symbol (ranges_seg);
> +      expr.X_add_number = 0;
> +      emit_expr (&expr, sizeof_address);

And here you use sizeof_address.  That ain't gonna work.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

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

* Re: Generate DW_AT_ranges for non-contiguous code
  2006-10-10 11:30 ` Andreas Schwab
@ 2006-10-10 20:58   ` Sterling Augustine
  2006-10-14  9:43     ` Nick Clifton
  0 siblings, 1 reply; 14+ messages in thread
From: Sterling Augustine @ 2006-10-10 20:58 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: binutils

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

Andreas Schwab wrote:
> [...] That ain't gonna work.

Thanks for the catch. Enclosed is a patch which should fix.

Sterling

[-- Attachment #2: ranges_patch --]
[-- Type: text/plain, Size: 796 bytes --]

Index: dwarf2dbg.c
===================================================================
RCS file: /cvs/src/src/gas/dwarf2dbg.c,v
retrieving revision 1.87
diff -d -u -r1.87 dwarf2dbg.c
--- dwarf2dbg.c	8 Aug 2006 19:09:33 -0000	1.87
+++ dwarf2dbg.c	10 Oct 2006 16:48:30 -0000
@@ -1591,13 +1591,10 @@
     }
   else
     {
-      /* This attributes is emitted if the code is disjoint.  */
+      /* This attribute is emitted if the code is disjoint.  */
       
       /* DW_AT_ranges */
-      expr.X_op = O_symbol;
-      expr.X_add_symbol = section_symbol (ranges_seg);
-      expr.X_add_number = 0;
-      emit_expr (&expr, sizeof_address);
+      TC_DWARF2_EMIT_OFFSET (section_symbol (ranges_seg), sizeof_offset);
     }
 
   /* DW_AT_name.  We don't have the actual file name that was present

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

* Re: Generate DW_AT_ranges for non-contiguous code
  2006-10-10 20:58   ` Sterling Augustine
@ 2006-10-14  9:43     ` Nick Clifton
  0 siblings, 0 replies; 14+ messages in thread
From: Nick Clifton @ 2006-10-14  9:43 UTC (permalink / raw)
  To: Sterling Augustine; +Cc: Andreas Schwab, binutils

Hi Sterling,

> Thanks for the catch. Enclosed is a patch which should fix.

>        /* DW_AT_ranges */
> -      expr.X_op = O_symbol;
> -      expr.X_add_symbol = section_symbol (ranges_seg);
> -      expr.X_add_number = 0;
> -      emit_expr (&expr, sizeof_address);
> +      TC_DWARF2_EMIT_OFFSET (section_symbol (ranges_seg), sizeof_offset);
>      }

Approved and applied with this ChangeLog entry.

Cheers
   Nick

gas/ChangeLog
2006-10-13  Sterling Augstine  <sterling@tensilica.com>

	* dwarf2dbg.c (out_debug_info): Use TC_DWARF2_EMIT_OFFSET to emit
	a disjoint DW_AT range.


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

* re: Generate DW_AT_ranges for non-contiguous code
@ 2006-07-28 22:06 Sterling Augustine
  0 siblings, 0 replies; 14+ messages in thread
From: Sterling Augustine @ 2006-07-28 22:06 UTC (permalink / raw)
  To: binutils

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

I need to withdraw this patch. The attribute should point into the 
debug.ranges section, rather than the .debug.aranges section.

Sterling Augustine
Member of Technical Staff
Tensilica, Inc.



[-- Attachment #2: discont.patch --]
[-- Type: text/plain, Size: 2440 bytes --]

--- binutils-060728/gas/dwarf2dbg.c	2006-06-07 04:27:57.000000000 -0700
+++ updated/gas/dwarf2dbg.c	2006-07-28 13:35:43.229267000 -0700
@@ -202,7 +202,7 @@ static void out_file_list (void);
 static void out_debug_line (segT);
 static void out_debug_aranges (segT, segT);
 static void out_debug_abbrev (segT);
-static void out_debug_info (segT, segT, segT);
+static void out_debug_info (segT, segT, segT, segT);
 \f
 #ifndef TC_DWARF2_EMIT_OFFSET
 # define TC_DWARF2_EMIT_OFFSET  generic_dwarf2_emit_offset
@@ -1382,6 +1382,9 @@ out_debug_abbrev (segT abbrev_seg)
       out_abbrev (DW_AT_low_pc, DW_FORM_addr);
       out_abbrev (DW_AT_high_pc, DW_FORM_addr);
     }
+  else
+    out_abbrev (DW_AT_ranges, DW_FORM_addr);
+
   out_abbrev (DW_AT_name, DW_FORM_string);
   out_abbrev (DW_AT_comp_dir, DW_FORM_string);
   out_abbrev (DW_AT_producer, DW_FORM_string);
@@ -1395,7 +1398,7 @@ out_debug_abbrev (segT abbrev_seg)
 /* Emit a description of this compilation unit for .debug_info.  */
 
 static void
-out_debug_info (segT info_seg, segT abbrev_seg, segT line_seg)
+out_debug_info (segT info_seg, segT abbrev_seg, segT line_seg, segT aranges_seg)
 {
   char producer[128];
   char *comp_dir;
@@ -1458,8 +1461,7 @@ out_debug_info (segT info_seg, segT abbr
   /* ??? sizeof_offset */
   TC_DWARF2_EMIT_OFFSET (section_symbol (line_seg), 4);
 
-  /* These two attributes may only be emitted if all of the code is
-     contiguous.  Multiple sections are not that.  */
+  /* These two attributes are emitted if all of the code is contiguous.  */
   if (all_segs->next == NULL)
     {
       /* DW_AT_low_pc */
@@ -1474,6 +1476,16 @@ out_debug_info (segT info_seg, segT abbr
       expr.X_add_number = 0;
       emit_expr (&expr, sizeof_address);
     }
+  else
+    {
+      /* Use a range attribute for non-contiguous code.  */
+      
+      /* DW_AT_ranges */
+      expr.X_op = O_symbol;
+      expr.X_add_symbol = section_symbol (aranges_seg);
+      expr.X_add_number = 0;
+      emit_expr (&expr, sizeof_address);
+    }
 
   /* DW_AT_name.  We don't have the actual file name that was present
      on the command line, so assume files[1] is the main input file.
@@ -1582,6 +1594,6 @@ dwarf2_finish (void)
 
       out_debug_aranges (aranges_seg, info_seg);
       out_debug_abbrev (abbrev_seg);
-      out_debug_info (info_seg, abbrev_seg, line_seg);
+      out_debug_info (info_seg, abbrev_seg, line_seg, aranges_seg);
     }
 }




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

* Generate DW_AT_ranges for non-contiguous code
@ 2006-07-28 21:12 Sterling Augustine
  0 siblings, 0 replies; 14+ messages in thread
From: Sterling Augustine @ 2006-07-28 21:12 UTC (permalink / raw)
  To: binutils

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

This enclosed patch adds support for DW_AT_ranges when assembly code is
noncontiguous. See: http://sourceware.org/ml/gdb/2006-05/msg00015.html
for a discussion of the problem this is addressing.

I believe Tensilica's copyright assignment is already on file.

One issue here is that this particular usage of DW_AT_ranges is dwarf 3,
and gas emits 2 for the dwarf version number. Don't know the right thing 
to do there. Bumping the version number for this seems extreme.

Let me know any issues...

Sterling Augustine
Member of Technical Staff
Tensilica, Inc.

gas/

2006-07-28  Sterling Augustine  <sterling@tensilica.com>

	* dwarf2dbg.c (out_debug_info): Add new parameter aranges_seg
	and emit DW_AT_ranges when code in compilation unit is not
	contiguous.
	(out_debug_abbrev): Emit DW_AT_ranges abbreviation if code in
	is not contiguous.
	(dwarf2_finish): Pass aranges_seg to out_debug_info.




[-- Attachment #2: discont.patch --]
[-- Type: text/plain, Size: 2439 bytes --]

--- binutils-060728/gas/dwarf2dbg.c	2006-06-07 04:27:57.000000000 -0700
+++ updated/gas/dwarf2dbg.c	2006-07-28 13:35:43.229267000 -0700
@@ -202,7 +202,7 @@ static void out_file_list (void);
 static void out_debug_line (segT);
 static void out_debug_aranges (segT, segT);
 static void out_debug_abbrev (segT);
-static void out_debug_info (segT, segT, segT);
+static void out_debug_info (segT, segT, segT, segT);
 \f
 #ifndef TC_DWARF2_EMIT_OFFSET
 # define TC_DWARF2_EMIT_OFFSET  generic_dwarf2_emit_offset
@@ -1382,6 +1382,9 @@ out_debug_abbrev (segT abbrev_seg)
       out_abbrev (DW_AT_low_pc, DW_FORM_addr);
       out_abbrev (DW_AT_high_pc, DW_FORM_addr);
     }
+  else
+    out_abbrev (DW_AT_ranges, DW_FORM_addr);
+
   out_abbrev (DW_AT_name, DW_FORM_string);
   out_abbrev (DW_AT_comp_dir, DW_FORM_string);
   out_abbrev (DW_AT_producer, DW_FORM_string);
@@ -1395,7 +1398,7 @@ out_debug_abbrev (segT abbrev_seg)
 /* Emit a description of this compilation unit for .debug_info.  */
 
 static void
-out_debug_info (segT info_seg, segT abbrev_seg, segT line_seg)
+out_debug_info (segT info_seg, segT abbrev_seg, segT line_seg, segT aranges_seg)
 {
   char producer[128];
   char *comp_dir;
@@ -1458,8 +1461,7 @@ out_debug_info (segT info_seg, segT abbr
   /* ??? sizeof_offset */
   TC_DWARF2_EMIT_OFFSET (section_symbol (line_seg), 4);
 
-  /* These two attributes may only be emitted if all of the code is
-     contiguous.  Multiple sections are not that.  */
+  /* These two attributes are emitted if all of the code is contiguous.  */
   if (all_segs->next == NULL)
     {
       /* DW_AT_low_pc */
@@ -1474,6 +1476,16 @@ out_debug_info (segT info_seg, segT abbr
       expr.X_add_number = 0;
       emit_expr (&expr, sizeof_address);
     }
+  else
+    {
+      /* Use a range attribute for non-contiguous code.  */
+      
+      /* DW_AT_ranges */
+      expr.X_op = O_symbol;
+      expr.X_add_symbol = section_symbol (aranges_seg);
+      expr.X_add_number = 0;
+      emit_expr (&expr, sizeof_address);
+    }
 
   /* DW_AT_name.  We don't have the actual file name that was present
      on the command line, so assume files[1] is the main input file.
@@ -1582,6 +1594,6 @@ dwarf2_finish (void)
 
       out_debug_aranges (aranges_seg, info_seg);
       out_debug_abbrev (abbrev_seg);
-      out_debug_info (info_seg, abbrev_seg, line_seg);
+      out_debug_info (info_seg, abbrev_seg, line_seg, aranges_seg);
     }
 }



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

end of thread, other threads:[~2006-10-13 11:37 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-07-31 23:22 Generate DW_AT_ranges for non-contiguous code Sterling Augustine
2006-08-07 10:55 ` Nick Clifton
2006-08-07 13:30   ` Daniel Jacobowitz
2006-08-07 14:08     ` Nick Clifton
2006-08-07 14:08     ` Nick Clifton
2006-08-07 20:30       ` Sterling Augustine
2006-08-07 21:46         ` Daniel Jacobowitz
2006-08-07 22:00           ` Sterling Augustine
2006-08-08  8:29             ` Nick Clifton
2006-10-10 11:30 ` Andreas Schwab
2006-10-10 20:58   ` Sterling Augustine
2006-10-14  9:43     ` Nick Clifton
  -- strict thread matches above, loose matches on Subject: below --
2006-07-28 22:06 Sterling Augustine
2006-07-28 21:12 Sterling Augustine

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).