]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
libdw: dwarf_getsrclines don't set end_sequence when there are no lines.
authorMark Wielaard <mjw@redhat.com>
Fri, 3 May 2013 09:28:49 +0000 (11:28 +0200)
committerMark Wielaard <mjw@redhat.com>
Sun, 5 May 2013 20:15:13 +0000 (22:15 +0200)
Some CUs might only have a file list, but no actual source lines in their
statement list. Only set end_sequence at the end of the source lines list
if there are actually lines.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
libdw/ChangeLog
libdw/dwarf_getsrclines.c
tests/ChangeLog
tests/Makefile.am
tests/run-get-lines.sh
tests/testfilenolines.bz2 [new file with mode: 0755]

index ef9b3acdd8379803f761a23f14ceb6e0a505c881..59b6c63af90a0caf0fd8f5f79f4631a4dee8ff8c 100644 (file)
@@ -1,3 +1,8 @@
+2013-05-03  Mark Wielaard  <mjw@redhat.com>
+
+       * dwarf_getsrclines.c (dwarf_getsrclines): Only set end_sequence
+       when nlinelist > 0.
+
 2013-04-28  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
        * libdw.map (ELFUTILS_0.156): New.
index 5a58b783188aa620b0fbd8d90d466034cf3cce93..fa4dd18c03b3256188c5c26b9f47fd39dc9fb0b5 100644 (file)
@@ -715,7 +715,8 @@ dwarf_getsrclines (Dwarf_Die *cudie, Dwarf_Lines **lines, size_t *nlines)
       /* Make sure the highest address for the CU is marked as end_sequence.
         This is required by the DWARF spec, but some compilers forget and
         dwfl_module_getsrc depends on it.  */
-      cu->lines->info[nlinelist - 1].end_sequence = 1;
+      if (nlinelist > 0)
+       cu->lines->info[nlinelist - 1].end_sequence = 1;
 
       /* Success.  */
       res = 0;
index 4003851f58ffee75d15831e86c03d712e9f90ab2..6df580a7f89eb3ae924100384206282d82648689 100644 (file)
@@ -1,3 +1,9 @@
+2013-05-03  Mark Wielaard  <mjw@redhat.com>
+
+       * testfilenolines.bz2: New test file.
+       * Makefile.am (EXTRA_DIST): Add testfilenolines.bz2.
+       * run-get-lines.sh: Run testrun_compare on testfilenolines.
+
 2013-04-30  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
        * dwfl-report-elf-align.c: Use false add_p_vaddr for dwfl_report_elf.
index 4b57703597a8dc8023286826e97b6d5779fdb788..6327edbb1d8059e127452839a4904bfc26cc1533 100644 (file)
@@ -198,7 +198,8 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh \
             testfile69.core.bz2 testfile69.so.bz2 \
             testfile70.core.bz2 testfile70.exec.bz2 \
             run-dwfllines.sh run-dwfl-report-elf-align.sh \
-            testfile-dwfl-report-elf-align-shlib.so.bz2
+            testfile-dwfl-report-elf-align-shlib.so.bz2 \
+            testfilenolines
 
 if USE_VALGRIND
 valgrind_cmd='valgrind -q --trace-children=yes --error-exitcode=1 --run-libc-freeres=no'
index 5a220cab7bb57c175571846b64992b337bf6e59f..fb48c77d99355e2587dea22742d1235d4dff2b1b 100755 (executable)
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 1999, 2000, 2002, 2004, 2005 Red Hat, Inc.
+# Copyright (C) 1999, 2000, 2002, 2004, 2005, 2013 Red Hat, Inc.
 # This file is part of elfutils.
 # Written by Ulrich Drepper <drepper@redhat.com>, 1999.
 #
@@ -18,7 +18,7 @@
 
 . $srcdir/test-subr.sh
 
-testfiles testfile testfile2
+testfiles testfile testfile2 testfilenolines
 
 testrun_compare ${abs_builddir}/get-lines testfile testfile2 <<\EOF
 cuhl = 11, o = 0, asz = 4, osz = 4, ncu = 191
@@ -61,4 +61,31 @@ cuhl = 11, o = 267, asz = 4, osz = 4, ncu = 2680
 10000514: /shoggoth/drepper/m.c:8:0: is_stmt:yes, end_seq:yes, bb:no, prologue:no, epilogue:no
 EOF
 
+# - lines.c
+# int ft;
+#
+# int
+# main (int argc, char **argv)
+# {
+#   return ft - 42;
+# }
+#
+# - nolines.c
+# int ft = 42;
+#
+# gcc -g -c lines.c
+# gcc -g -c nolines.c
+# gcc -g -o testfilenolines lines.o nolines.o
+
+testrun_compare ${abs_builddir}/get-lines testfilenolines <<\EOF
+cuhl = 11, o = 0, asz = 8, osz = 4, ncu = 169
+ 4 lines
+400474: /home/mark/src/tests/lines.c:5:0: is_stmt:yes, end_seq:no, bb:no, prologue:no, epilogue:no
+40047f: /home/mark/src/tests/lines.c:6:0: is_stmt:yes, end_seq:no, bb:no, prologue:no, epilogue:no
+400488: /home/mark/src/tests/lines.c:7:0: is_stmt:yes, end_seq:no, bb:no, prologue:no, epilogue:no
+40048a: /home/mark/src/tests/lines.c:7:0: is_stmt:yes, end_seq:yes, bb:no, prologue:no, epilogue:no
+cuhl = 11, o = 125, asz = 8, osz = 4, ncu = 243
+ 0 lines
+EOF
+
 exit 0
diff --git a/tests/testfilenolines.bz2 b/tests/testfilenolines.bz2
new file mode 100755 (executable)
index 0000000..23cd722
Binary files /dev/null and b/tests/testfilenolines.bz2 differ