From: Roland McGrath Date: Thu, 18 Aug 2005 22:01:57 +0000 (+0000) Subject: libdw/ X-Git-Tag: elfutils-0.120~106 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f5fda7d93acc0c9b0da0173fee746ced8034d8d0;p=thirdparty%2Felfutils.git 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. --- 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 000000000..8c262709d Binary files /dev/null and b/tests/testfile22.bz2 differ