]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
dwarflint: Check that CU DIE has stmt_list if children have decl_file
authorPetr Machata <pmachata@redhat.com>
Wed, 9 Mar 2011 20:33:31 +0000 (21:33 +0100)
committerPetr Machata <pmachata@redhat.com>
Wed, 9 Mar 2011 20:33:31 +0000 (21:33 +0100)
- Mark's test case attached

dwarflint/check_debug_info.cc
dwarflint/tests/empty-1.bz2 [new file with mode: 0644]
dwarflint/tests/run-bad.sh

index 7d7b293c57102f0c277b388c99e1150be0ca0362..c05e438a544a6ddfec2156a60e3264785e3abc0f 100644 (file)
@@ -1234,9 +1234,13 @@ check_debug_info_refs::check_debug_info_refs (checkstack &stack,
   for (std::vector<cu>::iterator it = _m_info->cus.begin ();
        it != _m_info->cus.end (); ++it)
     {
-      if (it->stmt_list.addr != (uint64_t)-1
-         && (_m_line == NULL
-             || !_m_line->has_line_table (it->stmt_list.addr)))
+      if (it->stmt_list.addr == (uint64_t)-1)
+       for (size_t i = 0; i < it->decl_file_refs.size; ++i)
+         wr_error (it->decl_file_refs.refs[i].who)
+           << "references .debug_line table, but CU DIE lacks DW_AT_stmt_list."
+           << std::endl;
+      else if (_m_line == NULL
+              || !_m_line->has_line_table (it->stmt_list.addr))
        wr_error (it->stmt_list.who)
          << "unresolved reference to .debug_line table "
          << pri::hex (it->stmt_list.addr) << '.' << std::endl;
diff --git a/dwarflint/tests/empty-1.bz2 b/dwarflint/tests/empty-1.bz2
new file mode 100644 (file)
index 0000000..25a7ada
Binary files /dev/null and b/dwarflint/tests/empty-1.bz2 differ
index 39fbdb5f4285e6dd72aa4e7de75523a0e216624f..a59b74ad75a489dc32277e5fb6db43e99132e476 100755 (executable)
@@ -27,7 +27,8 @@
 
 srcdir=$srcdir/tests
 
-testfiles hello.bad-1 hello.bad-3 garbage-1 garbage-2 garbage-3 garbage-4 \
+testfiles hello.bad-1 hello.bad-3 empty-1 \
+    garbage-1 garbage-2 garbage-3 garbage-4 \
     garbage-5 garbage-6 garbage-7 garbage-8
 
 testrun_compare ./dwarflint hello.bad-1 <<EOF
@@ -42,6 +43,12 @@ error: .debug_info: DIE 0xa4: toplevel DIE chain contains more than one DIE.
 error: .debug_info: DIE 0xab: toplevel DIE chain contains more than one DIE.
 EOF
 
+testrun_compare ./dwarflint empty-1 <<EOF
+warning: .debug_line: table 0: the file #1 \`empty.c' is not used.
+error: .debug_line: table 0: sequence of opcodes not terminated with DW_LNE_end_sequence.
+error: .debug_info: DIE 0x29 (abbr. attribute 0x13): references .debug_line table, but CU DIE lacks DW_AT_stmt_list.
+EOF
+
 testrun_compare ./dwarflint garbage-1 <<EOF
 error: Broken ELF: offset out of range.
 error: .debug_abbrev: data not found.