Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Joel Brobecker <brobecker@adacore.com>
Cc: gdb-patches@sourceware.org
Subject: [commit] [patch] Fix CU relative vs. absolute offsets  [Re: RFC: problem with DW_OP_GNU_deref_type and dwarf's get_base_type callback]
Date: Thu, 08 Mar 2012 19:40:00 -0000	[thread overview]
Message-ID: <20120308193952.GA31141@host2.jankratochvil.net> (raw)
In-Reply-To: <20120307194655.GS2853@adacore.com>

On Wed, 07 Mar 2012 20:46:55 +0100, Joel Brobecker wrote:
> FWIW: I didn't see any regression with our testsuite and GCC 4.7.

Checked it in, with a new testcase for one part of it.

The part
-      if (type_sig->type_offset != die->offset)
+      if (type_sig->per_cu.offset + type_sig->type_offset
+         != die->offset)

comes from:
	Re: [1/4] RFC: skip DIEs which only declare an enum
	http://sourceware.org/ml/gdb-patches/2011-07/msg00428.html
and while it has no new testcase:
(1) after changing it the debug output clearly shows it is right:
    type_sig->type_offset=0x25 != die->offset=0x82e
    type_sig->type_offset=0x3c != die->offset=0x7ce
    ->
    type_sig->type_offset=0x821 != die->offset=0x82e
    type_sig->type_offset=0x7d4 != die->offset=0x7ce
(2) it is also shown in the [patch 2/2] enforcing
    proper .debug_*-section vs.  CU relative offset types.

For the dwarf2_fetch_die_location_block part it was even easy to write
a testcase showing now FAIL->PASS.


Thanks,
Jan


http://sourceware.org/ml/gdb-cvs/2012-03/msg00134.html

--- src/gdb/ChangeLog	2012/03/08 19:08:09	1.13979
+++ src/gdb/ChangeLog	2012/03/08 19:37:04	1.13980
@@ -1,5 +1,15 @@
 2012-03-08  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
+	Fix CU relative vs. absolute DIE offsets.
+	* dwarf2loc.h (dwarf2_fetch_die_location_block): Rename parameter
+	offset to offset_in_cu.
+	* dwarf2read.c (process_enumeration_scope): Add CU offset to
+	TYPE_OFFSET.
+	(dwarf2_fetch_die_location_block): Rename parameter offset to
+	offset_in_cu.  New variable offset, add CU offset to OFFSET_IN_CU.
+
+2012-03-08  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
 	* libunwind-frame.c: Rename to ...
 	* ia64-libunwind-tdep.c: ... here.
 	* libunwind-frame.h: Rename to ...
--- src/gdb/testsuite/ChangeLog	2012/03/08 07:42:50	1.3127
+++ src/gdb/testsuite/ChangeLog	2012/03/08 19:37:07	1.3128
@@ -1,5 +1,11 @@
 2012-03-08  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
+	Fix CU relative vs. absolute DIE offsets.
+	* gdb.dwarf2/dw2-op-call.S: New compilation unit preceding the existing
+	one.
+
+2012-03-08  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
 	Fix false FAIL on distros with relro linkage as default.
 	* gdb.reverse/solib-precsave.exp: Try to compile the test using
 	-Wl,-z,norelro first.
--- src/gdb/dwarf2loc.h	2012/01/05 21:53:14	1.29
+++ src/gdb/dwarf2loc.h	2012/03/08 19:37:07	1.30
@@ -61,7 +61,7 @@
    CORE_ADDR pc);
 
 struct dwarf2_locexpr_baton dwarf2_fetch_die_location_block
-  (unsigned int offset, struct dwarf2_per_cu_data *per_cu,
+  (unsigned int offset_in_cu, struct dwarf2_per_cu_data *per_cu,
    CORE_ADDR (*get_frame_pc) (void *baton),
    void *baton);
 
--- src/gdb/dwarf2read.c	2012/03/06 23:41:50	1.619
+++ src/gdb/dwarf2read.c	2012/03/08 19:37:07	1.620
@@ -8031,7 +8031,8 @@
 	= lookup_signatured_type_at_offset (dwarf2_per_objfile->objfile,
 					    cu->per_cu->debug_types_section,
 					    cu->per_cu->offset);
-      if (type_sig->type_offset != die->offset)
+      if (type_sig->per_cu.offset + type_sig->type_offset
+	  != die->offset)
 	return;
     }
 
@@ -14202,11 +14203,12 @@
    dwarf2_locexpr_baton->data has lifetime of PER_CU->OBJFILE.  */
 
 struct dwarf2_locexpr_baton
-dwarf2_fetch_die_location_block (unsigned int offset,
+dwarf2_fetch_die_location_block (unsigned int offset_in_cu,
 				 struct dwarf2_per_cu_data *per_cu,
 				 CORE_ADDR (*get_frame_pc) (void *baton),
 				 void *baton)
 {
+  unsigned int offset = per_cu->offset + offset_in_cu;
   struct dwarf2_cu *cu;
   struct die_info *die;
   struct attribute *attr;
--- src/gdb/testsuite/gdb.dwarf2/dw2-op-call.S	2012/01/04 08:17:51	1.5
+++ src/gdb/testsuite/gdb.dwarf2/dw2-op-call.S	2012/03/08 19:37:08	1.6
@@ -23,6 +23,23 @@
 array3:	.2byte	3
 
 	.section .debug_info
+.Lcu0_begin:
+	/* CU header */
+	.4byte	.Lcu0_end - .Lcu0_start		/* Length of Compilation Unit */
+.Lcu0_start:
+	.2byte	2				/* DWARF Version */
+	.4byte	.Labbrev1_begin			/* Offset into abbrev section */
+	.byte	4				/* Pointer size */
+
+	/* CU die */
+	.uleb128 1				/* Abbrev: DW_TAG_compile_unit */
+	.ascii	"file0.txt\0"			/* DW_AT_name */
+	.ascii	"GNU C 3.3.3\0"			/* DW_AT_producer */
+	.byte	2				/* DW_LANG_C (C) */
+
+	.byte	0				/* End of children of CU */
+.Lcu0_end:
+
 .Lcu1_begin:
 	/* CU header */
 	.4byte	.Lcu1_end - .Lcu1_start		/* Length of Compilation Unit */


      reply	other threads:[~2012-03-08 19:40 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-05 22:34 RFC: problem with DW_OP_GNU_deref_type and dwarf's get_base_type callback Joel Brobecker
2012-03-06 20:25 ` Tom Tromey
2012-03-06 23:46   ` Joel Brobecker
2012-03-07 17:10 ` [patch] Fix CU relative vs. absolute offsets [Re: RFC: problem with DW_OP_GNU_deref_type and dwarf's get_base_type callback] Jan Kratochvil
2012-03-07 17:13   ` [patch 2/2] typedef-checking for " Jan Kratochvil
2012-03-07 18:58     ` Doug Evans
2012-03-07 19:10       ` Jan Kratochvil
2012-03-07 19:29         ` Jan Kratochvil
2012-03-08 21:54       ` Tom Tromey
2012-03-08 21:56         ` Doug Evans
2012-03-07 19:07     ` Joel Brobecker
2012-03-07 19:16       ` Jan Kratochvil
2012-03-08 21:53     ` Tom Tromey
2012-03-09 19:40       ` cu_offset vs. sect_offset field names bikeshedding [Re: [patch 2/2] typedef-checking for CU relative vs. absolute offsets] Jan Kratochvil
2012-03-09 19:52         ` Joel Brobecker
2012-03-19 20:02           ` [commit] [patch 2/2] typedef-checking for CU relative vs. absolute offsets Jan Kratochvil
2012-03-09 19:56         ` cu_offset vs. sect_offset field names bikeshedding [Re: [patch 2/2] typedef-checking for CU relative vs. absolute offsets] Tom Tromey
2012-03-07 18:57   ` [patch] Fix CU relative vs. absolute offsets [Re: RFC: problem with DW_OP_GNU_deref_type and dwarf's get_base_type callback] Joel Brobecker
2012-03-07 19:47     ` Joel Brobecker
2012-03-08 19:40       ` Jan Kratochvil [this message]

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=20120308193952.GA31141@host2.jankratochvil.net \
    --to=jan.kratochvil@redhat.com \
    --cc=brobecker@adacore.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