This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] libdw: fix offset for sig8 lookup in dwarf_formref_die


Hi Jason, Hi Josh,

On Wed, 2015-01-14 at 09:59 -0800, Josh Stone wrote:
> On 01/14/2015 08:47 AM, Mark Wielaard wrote:
> > On Wed, 2015-01-14 at 09:26 -0500, Jason P. Leasure wrote:
> >> -      offset = cu->type_offset;
> >> +      offset = cu->start + cu->type_offset;
> > 
> > Thanks, I believe this is correct. I am surprised we didn't encounter
> > this earlier. Do you happen to have a testcase for it?
> 
> It's a regression from commit 9202665816763, before which cu->start was
> used with the offset everywhere.
> 
> I can see this in my dwarvish tool with Jason's example source.  You
> just need a ref_sig8 that's not in the first type_unit, cu->start > 0.
> So here, struct A has a ref_sig8 to struct B in the second type_unit.
> 
> In the bad case I see "signature  ref_sig8  [30] 0", where those last
> two bits are supposed to be the offset and tag.
> 
> I see "signature  ref_sig8  [72] structure_type" with 0.160, or with
> master and this patch, and it expands the tree of attributes from there.
> 
> Of course you won't want a GUI for tests, but it should be easy to craft
> this one directly.

Aha. So this is my bug, I broke it. Sorry about that :{
So I added a ChangeLog entry and pushed Jason's patch. Then tweaked the
typeiter2 testcase a little to show the name and offset of the type DIE
found to show the regression and added that to master too as attached.

Thanks,

Mark
From 47efc3bef9f39a0494f9957b2e5f7da33482865b Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mjw@redhat.com>
Date: Wed, 14 Jan 2015 21:38:16 +0100
Subject: [PATCH] tests: Add testfile-debug-types test case.

Test for regression fixed in commit 7c713822:
"libdw: fix offset for sig8 lookup in dwarf_formref_die"

Signed-off-by: Mark Wielaard <mjw@redhat.com>
---
 tests/ChangeLog                |   7 +++++++
 tests/Makefile.am              |   5 +++--
 tests/run-typeiter.sh          |  14 +++++++++++---
 tests/testfile-debug-types.bz2 | Bin 0 -> 3024 bytes
 tests/typeiter2.c              |   6 ++++--
 5 files changed, 25 insertions(+), 7 deletions(-)
 create mode 100755 tests/testfile-debug-types.bz2

diff --git a/tests/ChangeLog b/tests/ChangeLog
index 6dd553b..365d98d 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,10 @@
+2015-01-14  Mark Wielaard  <mjw@redhat.com>
+
+	* testfile-debug-types.bz2: New testfile.
+	* Makefile.am (EXTRA_DIST): Add testfile-debug-types.bz2.
+	* typeiter2.c (main): Print both name and offset of found form DIE.
+	* run-typeiter.s: Adjust output and add testfile-debug-types.
+
 2014-12-26  Mark Wielaard  <mjw@redhat.com>
 
 	* run-test-archive64.sh: Add nm test.
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 303f783..14adebd 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,6 +1,6 @@
 ## Process this file with automake to create Makefile.in
 ##
-## Copyright (C) 1996-2014 Red Hat, Inc.
+## Copyright (C) 1996-2015 Red Hat, Inc.
 ## This file is part of elfutils.
 ##
 ## This file is free software; you can redistribute it and/or modify
@@ -280,7 +280,8 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh \
 	     linkmap-cut.bz2 linkmap-cut.core.bz2 \
 	     run-aggregate-size.sh testfile-sizes1.o.bz2 testfile-sizes2.o.bz2 \
 	     testfile-sizes3.o.bz2 \
-	     run-readelf-A.sh testfileppc32attrs.o.bz2
+	     run-readelf-A.sh testfileppc32attrs.o.bz2 \
+	     testfile-debug-types.bz2
 
 if USE_VALGRIND
 valgrind_cmd='valgrind -q --error-exitcode=1 --run-libc-freeres=no'
diff --git a/tests/run-typeiter.sh b/tests/run-typeiter.sh
index 605ee2a..2687bab 100755
--- a/tests/run-typeiter.sh
+++ b/tests/run-typeiter.sh
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 2012 Red Hat, Inc.
+# Copyright (C) 2012, 2015 Red Hat, Inc.
 # This file is part of elfutils.
 #
 # This file is free software; you can redistribute it and/or modify
@@ -41,14 +41,22 @@
 #
 # g++ -gdwarf-4 -g -fdebug-types-section
 
-testfiles testfile59
+# echo 'struct A{ struct B {} x;};A a; A::B b;int main(){return 0;}' \
+#  | g++ -x c++  -g -fdebug-types-section -o testfile-debug-types -
+
+testfiles testfile59 testfile-debug-types
 
 testrun_compare ${abs_builddir}/typeiter testfile59 <<\EOF
 ok
 EOF
 
 testrun_compare ${abs_builddir}/typeiter2 testfile59 <<\EOF
-ok
+ok s1 [25]
+EOF
+
+testrun_compare ${abs_builddir}/typeiter2 testfile-debug-types <<\EOF
+ok A [68]
+ok B [38]
 EOF
 
 exit 0
diff --git a/tests/testfile-debug-types.bz2 b/tests/testfile-debug-types.bz2
new file mode 100755
index 0000000000000000000000000000000000000000..a41f4938cee6ad6994f716b592b9d1d09e64cdbd
GIT binary patch
literal 3024
zcmV;>3orCST4*^jL0KkKS?tm1f&dEmfB*mg|Ns8~|NsB@|NsC0|NZZ8%>P?-(OCb)
zde7H>fB)bL4rph<Gjlg-d1&p=G`#my-g@d3Q{Kk#(IZnTey5>N8m1G`q-4S{gF{Uk
zXlNQV$&fVDKn(*;GyrL)fB<MT2dSr|$)Gd<27^rv28@FcG$I-S2AUXxB=perO_cQ1
z%>?xsHlP{?hKHyCG}BEzK+&d68Z>F4rbdH68UO}>0004?!~;apC#mRCY3c@=Hc<Ug
zG&BGJ00003KmY&@001-q000009-uS;000d#L?B9espzNar9V>unNKM6#GarTJxv~=
z<qVrq>SzrB0QEgUG|&Uo000dQ8UO*HXaE2J(dr;*XaEfj0BB?~0MU@h28{+lV1Q%|
zGyn!hhJa`Q4FDPdXaE7A05k>(6co@Y=+F{-BAA2PlP9T@CYn7#kTf&^8V^X&9;P5P
z0gwOyGH3t*2dDrv0000Kvo=^r+&ij1xUfCr4pB&>cNAqKG=rj14U8&g9wCA<3Lo#{
zg#jdj7##!yTNZW&%3~@D>FArQmamsyS<srmP6UnO3PA#0?`k{W7|C@kVyI$R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3rpx|ORd75AAuo68Ms-{>`HFfZVaka+>n6jawjg+;|?ZxLBqALT$p6eu7p
z7_d|=n9FEhXBPc3vqP~sh2ZcvOIQse4a$Ve(g~6=y=J?7Om(E8bx@$7cA`SN7Pz-1
z7?4XXa!m6s?EIM6noD*W*Ij_+=qc2MH&0w98YBUK5QBopZjdC~t5-mQo1?YtKU(xX
SJ4}gx@pmLsg$WML9*7{vGDm;_

literal 0
HcmV?d00001

diff --git a/tests/typeiter2.c b/tests/typeiter2.c
index 6ddfa38..35b6a12 100644
--- a/tests/typeiter2.c
+++ b/tests/typeiter2.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2012, 2013 Red Hat, Inc.
+/* Copyright (C) 2012, 2013, 2015 Red Hat, Inc.
    This file is part of elfutils.
 
    This file is free software; you can redistribute it and/or modify
@@ -23,6 +23,7 @@
 #include <stdio.h>
 #include <unistd.h>
 #include <dwarf.h>
+#include <inttypes.h>
 
 int
 main (int argc, char *argv[])
@@ -71,7 +72,8 @@ main (int argc, char *argv[])
 		      if (form == NULL)
 			printf ("fail\n");
 		      else
-			printf ("ok\n");
+			printf ("ok %s [%" PRIx64 "]\n",
+				dwarf_diename (form), dwarf_dieoffset (form));
 		    }
 
 		  if (dwarf_siblingof (iter, &iter_mem) != 0)
-- 
1.8.3.1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]