]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
libdwfl: dwfl_module_getsrc should never match end_sequence line.
authorMark Wielaard <mjw@redhat.com>
Sat, 27 Dec 2014 15:16:29 +0000 (16:16 +0100)
committerMark Wielaard <mjw@redhat.com>
Fri, 16 Jan 2015 08:01:57 +0000 (09:01 +0100)
The line with end_sequence set has an address outside the current line
sequence. An end_sequence line has no other useful information except
marking the address as out of range.

Two tests, addrscopes and funcscopes, depended on matching the end_sequence
line. But that was because they included the high_pc address in the scope.
However the high_pc attributes has as address the first location past the
range associated with a given DIE. Adjust the tests to use high_pc - 1 as
end of the scope.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
libdwfl/ChangeLog
libdwfl/dwfl_module_getsrc.c
tests/ChangeLog
tests/addrscopes.c
tests/funcscopes.c
tests/run-addrscopes.sh
tests/run-funcscopes.sh

index 4dda62af3bd46b40365412774c37dfc7fc520644..5a97578172bca96e81b6b2b18b227b25068fd7e5 100644 (file)
@@ -1,3 +1,8 @@
+2014-12-27  Mark Wielaard  <mjw@redhat.com>
+
+       * dwfl_module_getsrc.c (dwfl_module_getsrc): Never match a line that
+       has end_sequence set.
+
 2015-01-04  Mark Wielaard  <mjw@redhat.com>
 
        * cu.c (intern_cu): Store result and return directly when finding
index f6d883903b84a360621b44d5aee8af00e1572457..f7e340bc687bd9b3de6e432508bb02880803cb89 100644 (file)
@@ -64,11 +64,11 @@ dwfl_module_getsrc (Dwfl_Module *mod, Dwarf_Addr addr)
                l = idx;
            }
 
-         /* The last line which is less than or equal to addr is what we want,
-            except with an end_sequence which can only be strictly equal.  */
+         /* The last line which is less than or equal to addr is what
+            we want, unless it is the end_sequence which is after the
+            current line sequence.  */
          Dwarf_Line *line = &lines->info[l];
-         if (line->addr == addr
-             || (! line->end_sequence && line->addr < addr))
+         if (! line->end_sequence && line->addr <= addr)
            return &cu->lines->idx[l];
        }
 
index c05e807933f34b36d721178e9f8d1b70bb60c26a..b81e83c1a22cf4e461e6852693483461e0e25a33 100644 (file)
@@ -1,3 +1,10 @@
+2014-12-27  Mark Wielaard  <mjw@redhat.com>
+
+       * addrscopes.c (handle_address): Last address in scope is highpc - 1.
+       * funcscopes.c (handle_function): Likewise.
+       * run-addrscopes.sh: Adjust last address in scope.
+       * run-funcscopes.sh: Likewise.
+
 2015-01-07  Mark Wielaard  <mjw@redhat.com>
 
        * run-addrcfi.sh: Add test for ppc32 eh_frame_hdr address search.
index fca61d33d825647e0fed86019d3808945b3d5ce7..2285d2ca90c730305c6a869847890106db04a8e8 100644 (file)
@@ -1,5 +1,5 @@
 /* Test program for dwarf_getscopes.
-   Copyright (C) 2005 Red Hat, Inc.
+   Copyright (C) 2005, 2014 Red Hat, Inc.
    This file is part of elfutils.
 
    This file is free software; you can redistribute it and/or modify
@@ -125,10 +125,10 @@ handle_address (GElf_Addr pc, Dwfl *dwfl)
              lowpc += cubias;
              highpc += cubias;
              Dwfl_Line *loline = dwfl_getsrc (dwfl, lowpc);
-             Dwfl_Line *hiline = dwfl_getsrc (dwfl, highpc);
+             Dwfl_Line *hiline = dwfl_getsrc (dwfl, highpc - 1);
              paddr (": ", lowpc, loline);
              if (highpc != lowpc)
-               paddr (" .. ", lowpc, hiline == loline ? NULL : hiline);
+               paddr (" .. ", highpc - 1, hiline == loline ? NULL : hiline);
            }
          puts ("");
 
index 720ff3b98ede30ebe10a2d711e49d8aa82533b4b..55cb4facde8b61dc54cebd34871809806afc1a95 100644 (file)
@@ -1,5 +1,5 @@
 /* Test program for dwarf_getscopes.
-   Copyright (C) 2005 Red Hat, Inc.
+   Copyright (C) 2005, 2014 Red Hat, Inc.
    This file is part of elfutils.
 
    This file is free software; you can redistribute it and/or modify
@@ -153,10 +153,10 @@ handle_function (Dwarf_Die *funcdie, void *arg)
              lowpc += a->dwbias;
              highpc += a->dwbias;
              Dwfl_Line *loline = dwfl_getsrc (a->dwfl, lowpc);
-             Dwfl_Line *hiline = dwfl_getsrc (a->dwfl, highpc);
+             Dwfl_Line *hiline = dwfl_getsrc (a->dwfl, highpc - 1);
              paddr (": ", lowpc, loline);
              if (highpc != lowpc)
-               paddr (" .. ", lowpc, hiline == loline ? NULL : hiline);
+               paddr (" .. ", highpc - 1, hiline == loline ? NULL : hiline);
            }
          puts ("");
 
index 4f5c9d7fc6b51ee7b7ca7f8612ea0f73d9d78528..8f1bf0e3652ea578bff73a92457e94187922046e 100755 (executable)
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 2005 Red Hat, Inc.
+# Copyright (C) 2005, 2014 Red Hat, Inc.
 # This file is part of elfutils.
 #
 # This file is free software; you can redistribute it and/or modify
@@ -21,9 +21,9 @@ testfiles testfile22
 
 testrun_compare ${abs_builddir}/addrscopes -e testfile22 0x8048353 <<\EOF
 0x8048353:
-    tests/foo.c (0x11): 0x8048348 (tests/foo.c:5) .. 0x804837e (tests/foo.c:16)
+    tests/foo.c (0x11): 0x8048348 (tests/foo.c:5) .. 0x804837c (tests/foo.c:16)
         global                        [    be]
-        function (0x2e): 0x8048348 (tests/foo.c:5) .. 0x804835b (tests/foo.c:14)
+        function (0x2e): 0x8048348 (tests/foo.c:5) .. 0x8048359 (tests/foo.c:11)
             local                         [    8f]
 EOF
 
@@ -32,8 +32,8 @@ test_cleanup
 testfiles testfile24
 testrun_compare ${abs_builddir}/addrscopes -e testfile24 0x804834e <<\EOF
 0x804834e:
-    inline-test.c (0x11): 0x8048348 (/home/roland/build/stock-elfutils/inline-test.c:7) .. 0x8048364 (/home/roland/build/stock-elfutils/inline-test.c:16)
-        add (0x1d): 0x804834e (/home/roland/build/stock-elfutils/inline-test.c:3) .. 0x8048350 (/home/roland/build/stock-elfutils/inline-test.c:9)
+    inline-test.c (0x11): 0x8048348 (/home/roland/build/stock-elfutils/inline-test.c:7) .. 0x8048360 (/home/roland/build/stock-elfutils/inline-test.c:16)
+        add (0x1d): 0x804834e (/home/roland/build/stock-elfutils/inline-test.c:3) .. 0x804834f
             y                             [    9d]
             x                             [    a2]
             x (abstract)
index d236f5c3b0b8be5352a17ef720459df6b7604dd4..367729a702e02a2f5d41fcbbcbcfe31f35d595a9 100755 (executable)
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 2005 Red Hat, Inc.
+# Copyright (C) 2005, 2014 Red Hat, Inc.
 # This file is part of elfutils.
 #
 # This file is free software; you can redistribute it and/or modify
@@ -21,8 +21,8 @@ testfiles testfile25
 
 testrun_compare ${abs_builddir}/funcscopes -e testfile25 incr <<\EOF
 testfile25: 0x8048000 .. 0x8049528
-    inline-test.c (0x11): 0x8048348 (/home/roland/build/stock-elfutils/inline-test.c:7) .. 0x804834f (/home/roland/build/stock-elfutils/inline-test.c:9)
-        incr (0x2e): 0x8048348 (/home/roland/build/stock-elfutils/inline-test.c:7) .. 0x804834f (/home/roland/build/stock-elfutils/inline-test.c:9)
+    inline-test.c (0x11): 0x8048348 (/home/roland/build/stock-elfutils/inline-test.c:7) .. 0x804834e (/home/roland/build/stock-elfutils/inline-test.c:9)
+        incr (0x2e): 0x8048348 (/home/roland/build/stock-elfutils/inline-test.c:7) .. 0x804834e (/home/roland/build/stock-elfutils/inline-test.c:9)
             x                             [    66]
 EOF