]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
libdw/
authorRoland McGrath <roland@redhat.com>
Thu, 18 Aug 2005 22:01:57 +0000 (22:01 +0000)
committerRoland McGrath <roland@redhat.com>
Thu, 18 Aug 2005 22:01:57 +0000 (22:01 +0000)
2005-08-18  Roland McGrath  <roland@redhat.com>

* dwarf_getscopes.c (dwarf_getscopes): Include the CU itself as
outermost scope in the results.

tests/
2005-08-18  Roland McGrath  <roland@redhat.com>

* run-addrscopes.sh: New file.
* testfile22.bz2: New data file.
* Makefile.am (TESTS, EXTRA_DIST): Add them.

libdw/ChangeLog
libdw/dwarf_getscopes.c
tests/ChangeLog
tests/Makefile.am
tests/run-addrscopes.sh [new file with mode: 0755]
tests/testfile22.bz2 [new file with mode: 0644]

index 17b8b3e5d74a59f302df2c4cc86c9d5217a9ffe6..de716d43f5087bc7d4a385c50ce830e35ebe7170 100644 (file)
@@ -1,3 +1,8 @@
+2005-08-18  Roland McGrath  <roland@redhat.com>
+
+       * dwarf_getscopes.c (dwarf_getscopes): Include the CU itself as
+       outermost scope in the results.
+
 2005-08-15  Roland McGrath  <roland@redhat.com>
 
        * dwarf_func_inline.c: New file.
index 21d6f20a6322454f17b7d86e68b98262802f9a20..7863036b24d1befd562c7d0f88821ea2ac98465d 100644 (file)
@@ -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.  */
     {
index a1803bc9d99dcb60ce22054d8236ea649cf018c9..b5b6e18f625d637c3890e2e7aa08a67fd5aa8220 100644 (file)
@@ -1,5 +1,9 @@
 2005-08-18  Roland McGrath  <roland@redhat.com>
 
+       * 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.
index a462f82c9a9ce03d5739f2205a949201ca9a3a0f..a8ae760b54af801936459b4a343eae7383fdc1c9 100644 (file)
@@ -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 (executable)
index 0000000..901d02e
--- /dev/null
@@ -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 (file)
index 0000000..8c26270
Binary files /dev/null and b/tests/testfile22.bz2 differ