public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [patch] dwarf display: false (location list) in DWARF-4
@ 2011-07-27 12:30 Jan Kratochvil
  2011-07-27 18:15 ` Jakub Jelinek
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Kratochvil @ 2011-07-27 12:30 UTC (permalink / raw)
  To: binutils

Hi,

echo 'struct s { char a[1<<24]; int b; } s;'|gcc -gdwarf-4 -o 1.o -c -x c -;readelf -wia 1.o

 <2><34>: Abbrev Number: 4 (DW_TAG_member)
    <35>   DW_AT_name        : b
    <37>   DW_AT_decl_file   : 1
    <38>   DW_AT_decl_line   : 1
    <39>   DW_AT_type        : <0x55>
    <3d>   DW_AT_data_member_location: 0x1000000        (location list)
+
   4      DW_TAG_member    [no children]
    DW_AT_name         DW_FORM_string
    DW_AT_decl_file    DW_FORM_data1
    DW_AT_decl_line    DW_FORM_data1
    DW_AT_type         DW_FORM_ref4
    DW_AT_data_member_location DW_FORM_data4

But that is wrong, DWARF-4 has DW_FORM_sec_offset for `(location list)',
0x1000000 is normal data (DW_FORM_data4) in DWARF-4.  There should be just:

    <3d>   DW_AT_data_member_location: 0x1000000

No regressions on {x86_64,i686}-fedora16pre-linux-gnu.  I haven't found the
string "location list" anywhere in the testsuites so I hope I did not break any
other targets' testsuites.


Thanks,
Jan


binutils/
2011-07-27  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* dwarf.c (read_and_display_attr_value): Recognize DW_FORM_data4 and
	DW_FORM_data8 as location list pointers only for DWARF < 4.

--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -1485,8 +1485,8 @@ read_and_display_attr_value (unsigned long attribute,
 	case DW_AT_GNU_call_site_data_value:
 	case DW_AT_GNU_call_site_target:
 	case DW_AT_GNU_call_site_target_clobbered:
-    	  if (form == DW_FORM_data4
-	      || form == DW_FORM_data8
+    	  if ((dwarf_version < 4
+	       && (form == DW_FORM_data4 || form == DW_FORM_data8))
 	      || form == DW_FORM_sec_offset)
 	    {
 	      /* Process location list.  */
@@ -1516,8 +1516,8 @@ read_and_display_attr_value (unsigned long attribute,
 	  break;
 
 	case DW_AT_ranges:
-	  if (form == DW_FORM_data4
-	      || form == DW_FORM_data8
+    	  if ((dwarf_version < 4
+	       && (form == DW_FORM_data4 || form == DW_FORM_data8))
 	      || form == DW_FORM_sec_offset)
 	    {
 	      /* Process range list.  */
@@ -1734,8 +1734,8 @@ read_and_display_attr_value (unsigned long attribute,
     case DW_AT_GNU_call_site_data_value:
     case DW_AT_GNU_call_site_target:
     case DW_AT_GNU_call_site_target_clobbered:
-      if (form == DW_FORM_data4
-	  || form == DW_FORM_data8
+      if ((dwarf_version < 4
+           && (form == DW_FORM_data4 || form == DW_FORM_data8))
 	  || form == DW_FORM_sec_offset)
 	printf (_("(location list)"));
       /* Fall through.  */

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

* Re: [patch] dwarf display: false (location list) in DWARF-4
  2011-07-27 12:30 [patch] dwarf display: false (location list) in DWARF-4 Jan Kratochvil
@ 2011-07-27 18:15 ` Jakub Jelinek
  2011-07-27 18:28   ` Jan Kratochvil
  0 siblings, 1 reply; 3+ messages in thread
From: Jakub Jelinek @ 2011-07-27 18:15 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: binutils

On Wed, Jul 27, 2011 at 12:06:05PM +0200, Jan Kratochvil wrote:
>     <3d>   DW_AT_data_member_location: 0x1000000        (location list)
> 
> But that is wrong, DWARF-4 has DW_FORM_sec_offset for `(location list)',
> 0x1000000 is normal data (DW_FORM_data4) in DWARF-4.  There should be just:
> 
>     <3d>   DW_AT_data_member_location: 0x1000000

> 2011-07-27  Jan Kratochvil  <jan.kratochvil@redhat.com>
> 
> 	* dwarf.c (read_and_display_attr_value): Recognize DW_FORM_data4 and
> 	DW_FORM_data8 as location list pointers only for DWARF < 4.

Ok for trunk.

This BTW shows a gcc bug for -gdwarf-3 - the DWARF3 standard
explicitly disallows DW_FORM_data4 and DW_FORM_data8 from constant class if
the attribute has also some *ptr class (from the DWARF3 list it seems that
only DW_AT_data_member_location is affected.  In DWARF2 that wasn't a
problem, as DWARF2 didn't allow a constant for DW_AT_data_member_location.
And in DWARF4 also DW_AT_start_scope allows a constant and *ptr, but there
it should already be using DW_FORM_sec_offset for the *ptr...

	Jakub

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

* Re: [patch] dwarf display: false (location list) in DWARF-4
  2011-07-27 18:15 ` Jakub Jelinek
@ 2011-07-27 18:28   ` Jan Kratochvil
  0 siblings, 0 replies; 3+ messages in thread
From: Jan Kratochvil @ 2011-07-27 18:28 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: binutils

On Wed, 27 Jul 2011 18:28:54 +0200, Jakub Jelinek wrote:
> On Wed, Jul 27, 2011 at 12:06:05PM +0200, Jan Kratochvil wrote:
> > 2011-07-27  Jan Kratochvil  <jan.kratochvil@redhat.com>
> > 
> > 	* dwarf.c (read_and_display_attr_value): Recognize DW_FORM_data4 and
> > 	DW_FORM_data8 as location list pointers only for DWARF < 4.
> 
> Ok for trunk.

Checked in:
	http://sourceware.org/ml/binutils-cvs/2011-07/msg00141.html


> This BTW shows a gcc bug for -gdwarf-3 - the DWARF3 standard
> explicitly disallows DW_FORM_data4 and DW_FORM_data8 from constant class if
> the attribute has also some *ptr class (from the DWARF3 list it seems that
> only DW_AT_data_member_location is affected.

OK, true.  GDB (handle_data_member_location, Tom Tromey) parses it in a GCC
compatible way FYI, always preferring the constant class.


Thanks,
Jan

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

end of thread, other threads:[~2011-07-27 16:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-27 12:30 [patch] dwarf display: false (location list) in DWARF-4 Jan Kratochvil
2011-07-27 18:15 ` Jakub Jelinek
2011-07-27 18:28   ` Jan Kratochvil

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