From f5fda7d93acc0c9b0da0173fee746ced8034d8d0 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Thu, 18 Aug 2005 22:01:57 +0000 Subject: [PATCH] libdw/ 2005-08-18 Roland McGrath * dwarf_getscopes.c (dwarf_getscopes): Include the CU itself as outermost scope in the results. tests/ 2005-08-18 Roland McGrath * run-addrscopes.sh: New file. * testfile22.bz2: New data file. * Makefile.am (TESTS, EXTRA_DIST): Add them. --- libdw/ChangeLog | 5 +++++ libdw/dwarf_getscopes.c | 17 +++++++++++++---- tests/ChangeLog | 4 ++++ tests/Makefile.am | 7 +++++-- tests/run-addrscopes.sh | 31 +++++++++++++++++++++++++++++++ tests/testfile22.bz2 | Bin 0 -> 2555 bytes 6 files changed, 58 insertions(+), 6 deletions(-) create mode 100755 tests/run-addrscopes.sh create mode 100644 tests/testfile22.bz2 diff --git a/libdw/ChangeLog b/libdw/ChangeLog index 17b8b3e5d..de716d43f 100644 --- a/libdw/ChangeLog +++ b/libdw/ChangeLog @@ -1,3 +1,8 @@ +2005-08-18 Roland McGrath + + * dwarf_getscopes.c (dwarf_getscopes): Include the CU itself as + outermost scope in the results. + 2005-08-15 Roland McGrath * dwarf_func_inline.c: New file. diff --git a/libdw/dwarf_getscopes.c b/libdw/dwarf_getscopes.c index 21d6f20a6..7863036b2 100644 --- a/libdw/dwarf_getscopes.c +++ b/libdw/dwarf_getscopes.c @@ -297,9 +297,14 @@ dwarf_getscopes (Dwarf_Die *cudie, Dwarf_Addr pc, Dwarf_Die **scopes) if (cudie == NULL) return -1; - int n = find_pc (1, cudie, pc, scopes); - if (likely (n >= -1)) - /* We have an error or a final result. */ + int n = find_pc (2, cudie, pc, scopes); + if (likely (n >= 0)) + { + /* We have a final result. Now store the outermost scope, the CU. */ + (*scopes)[n++] = *cudie; + return n; + } + if (n == -1) return n; /* We have the scopes out to one that is a concrete instance of an @@ -320,7 +325,11 @@ dwarf_getscopes (Dwarf_Die *cudie, Dwarf_Addr pc, Dwarf_Die **scopes) int result = find_die (0, cudie, origin, scopes, n); if (likely (result > 0)) - return n + result - 1; + { + n = n + result - 1; + (*scopes)[n++] = *cudie; + return n; + } if (result == 0) /* No match, shouldn't happen. */ { diff --git a/tests/ChangeLog b/tests/ChangeLog index a1803bc9d..b5b6e18f6 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,5 +1,9 @@ 2005-08-18 Roland McGrath + * run-addrscopes.sh: New file. + * testfile22.bz2: New data file. + * Makefile.am (TESTS, EXTRA_DIST): Add them. + * addrscopes.c: New file. * Makefile.am (noinst_PROGRAMS): Add it. (addrscopes_LDADD): New variable. diff --git a/tests/Makefile.am b/tests/Makefile.am index a462f82c9..a8ae760b5 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -45,7 +45,8 @@ TESTS = run-arextract.sh run-arsymtest.sh newfile test-nlist \ run-strip-test3.sh run-strip-test4.sh run-strip-test5.sh \ run-strip-test6.sh run-ecp-test.sh run-ecp-test2.sh \ run-elflint-test.sh run-elflint-self.sh run-ranlib-test.sh \ - run-ranlib-test2.sh run-ranlib-test3.sh run-ranlib-test4.sh + run-ranlib-test2.sh run-ranlib-test3.sh run-ranlib-test4.sh \ + run-addrscopes.sh # run-show-ciefde.sh EXTRA_DIST = run-arextract.sh run-arsymtest.sh \ @@ -61,12 +62,14 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh \ run-strip-test4.sh run-strip-test5.sh run-strip-test6.sh \ run-elflint-self.sh run-ranlib-test.sh run-ranlib-test2.sh \ run-ranlib-test3.sh run-ranlib-test4.sh \ + run-addrscopes.sh \ testfile15.bz2 testfile15.debug.bz2 \ testfile16.bz2 testfile16.debug.bz2 \ testfile17.bz2 testfile17.debug.bz2 \ testfile18.bz2 testfile19.bz2 testfile19.index.bz2 \ testfile20.bz2 testfile20.index.bz2 \ - testfile21.bz2 testfile21.index.bz2 + testfile21.bz2 testfile21.index.bz2 \ + testfile22.bz2 if MUDFLAP static_build=yes diff --git a/tests/run-addrscopes.sh b/tests/run-addrscopes.sh new file mode 100755 index 000000000..901d02e12 --- /dev/null +++ b/tests/run-addrscopes.sh @@ -0,0 +1,31 @@ +#! /bin/sh +# Copyright (C) 2005 Red Hat, Inc. +# +# This program is Open Source software; you can redistribute it and/or +# modify it under the terms of the Open Software License version 1.0 as +# published by the Open Source Initiative. +# +# You should have received a copy of the Open Software License along +# with this program; if not, you may obtain a copy of the Open Software +# License version 1.0 from http://www.opensource.org/licenses/osl.php or +# by writing the Open Source Initiative c/o Lawrence Rosen, Esq., +# 3001 King Ranch Road, Ukiah, CA 95482. +set -e + +# Don't fail if we cannot decompress the file. +bunzip2 -c $srcdir/testfile22.bz2 > testfile22 2>/dev/null || exit 0 + +LD_LIBRARY_PATH=../libdw:../libebl:../libelf${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH \ + ./addrscopes -e testfile22 0x8048353 >& addrscopes-test.out || : + +diff -Bbu addrscopes-test.out - <<\EOF +0x8048353: + tests/foo.c (0x11): 0x8048348 (tests/foo.c:5) .. 0x804837e (tests/foo.c:16) + global [ be] + function (0x2e): 0x8048348 (tests/foo.c:5) .. 0x804835b (tests/foo.c:14) + local [ 8f] +EOF + +rm -f testfile22 addrscopes-test.out + +exit 0 diff --git a/tests/testfile22.bz2 b/tests/testfile22.bz2 new file mode 100644 index 0000000000000000000000000000000000000000..8c262709d7f2a29d8eaef6a368f67f4d0047f87e GIT binary patch literal 2555 zc-jH`2?X{+T4*^jL0KkKS^l_|4FCxG|NsC0|Ns8?|NsC0|L?#5|Ns8_&iHPWr&;~? zb;4(FZ%yC`^7q=i;0EsQI~lgxy3XS|F;sl^uCUWcO%iFT>Uy53;txuCo|>KlG{{Dt zr>TT`ntB>WGHEc-07sMnWWbskGy$ac%Ut$Z796JZju;3#6O=?i+H@els$JEfGr$lI1jv|> z$x>8^ zN@fv307dh4`2Dg0Z5A%p=N^8Rxe#I8puf`I!UGB7Fs{%Ifqye9lRnn>k!j0OVzN0W zVVXLey?Dl96eMNgL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