Skip to content

Commit

Permalink
Ignore DIEs in the skeleton unit in a DWO scenario
Browse files Browse the repository at this point in the history
Summary:
r362103 exposed a bug, where we could read incorrect data if a skeleton
unit contained more than the single unit DIE. Clang emits these kinds of
units with -fsplit-dwarf-inlining (which is also the default).

Changing lldb to handle these DIEs is nontrivial, as we'd have to change
the UID encoding logic to be able to reference these DIEs, and fix up
various places which are assuming that all DIEs come from the separate
compile unit.

However, it turns out this is not necessary, as the DWO unit contains
all the information that the skeleton unit does. So, this patch just
skips parsing the extra DIEs if we have successfully found the DWO file.
This enforces the invariant that the rest of the code is already
operating under.

This patch fixes a couple of existing tests, but I've also included a
simpler test which does not depend on execution of binaries, and would
have helped us in catching this sooner.

Reviewers: clayborg, JDevlieghere, aprantl

Subscribers: probinson, dblaikie, lldb-commits

Differential Revision: https://reviews.llvm.org/D62852

llvm-svn: 362586
  • Loading branch information
labath committed Jun 5, 2019
1 parent 9d8d0f6 commit da7f033
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lldb/lit/SymbolFile/DWARF/split-dwarf-inlining.cpp
@@ -0,0 +1,8 @@
// RUN: %clangxx -target x86_64-pc-linux -gsplit-dwarf -fsplit-dwarf-inlining \
// RUN: -c %s -o %t
// RUN: %lldb %t -o "breakpoint set -n foo" -b | FileCheck %s

// CHECK: Breakpoint 1: 2 locations

__attribute__((always_inline)) int foo(int x) { return x; }
int bar(int x) { return foo(x); }
11 changes: 11 additions & 0 deletions lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
Expand Up @@ -183,6 +183,17 @@ void DWARFUnit::ExtractDIEsRWLocked() {

if (!m_first_die)
AddUnitDIE(m_die_array.front());

// With -fsplit-dwarf-inlining, clang will emit non-empty skeleton compile
// units. We are not able to access these DIE *and* the dwo file
// simultaneously. We also don't need to do that as the dwo file will
// contain a superset of information. So, we don't even attempt to parse
// any remaining DIEs.
if (m_dwo_symbol_file) {
m_die_array.front().SetHasChildren(false);
break;
}

} else {
if (null_die) {
if (prev_die_had_children) {
Expand Down

0 comments on commit da7f033

Please sign in to comment.