summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/include/lldb/Core/Module.h7
-rw-r--r--lldb/lit/SymbolFile/Inputs/target-symbols-add-unwind.c1
-rw-r--r--lldb/lit/SymbolFile/target-symbols-add-unwind.test26
-rw-r--r--lldb/source/Core/Module.cpp10
-rw-r--r--lldb/source/Symbol/UnwindTable.cpp2
5 files changed, 42 insertions, 4 deletions
diff --git a/lldb/include/lldb/Core/Module.h b/lldb/include/lldb/Core/Module.h
index f59e38d907a..19c6bdad330 100644
--- a/lldb/include/lldb/Core/Module.h
+++ b/lldb/include/lldb/Core/Module.h
@@ -706,7 +706,7 @@ public:
/// Returns the unwind table for this module. If this object has no
/// associated object file, an empty UnwindTable is returned.
//------------------------------------------------------------------
- UnwindTable &GetUnwindTable() { return m_unwind_table; }
+ UnwindTable &GetUnwindTable();
llvm::VersionTuple GetVersion();
@@ -1105,8 +1105,9 @@ protected:
lldb::ObjectFileSP m_objfile_sp; ///< A shared pointer to the object file
///parser for this module as it may or may
///not be shared with the SymbolFile
- UnwindTable m_unwind_table{*this}; ///< Table of FuncUnwinders objects created
- /// for this Module's functions
+ llvm::Optional<UnwindTable> m_unwind_table; ///< Table of FuncUnwinders
+ /// objects created for this
+ /// Module's functions
lldb::SymbolVendorUP
m_symfile_up; ///< A pointer to the symbol vendor for this module.
std::vector<lldb::SymbolVendorUP>
diff --git a/lldb/lit/SymbolFile/Inputs/target-symbols-add-unwind.c b/lldb/lit/SymbolFile/Inputs/target-symbols-add-unwind.c
new file mode 100644
index 00000000000..aa04da7bef4
--- /dev/null
+++ b/lldb/lit/SymbolFile/Inputs/target-symbols-add-unwind.c
@@ -0,0 +1 @@
+void _start() {}
diff --git a/lldb/lit/SymbolFile/target-symbols-add-unwind.test b/lldb/lit/SymbolFile/target-symbols-add-unwind.test
new file mode 100644
index 00000000000..322669c4925
--- /dev/null
+++ b/lldb/lit/SymbolFile/target-symbols-add-unwind.test
@@ -0,0 +1,26 @@
+# TODO: When it's possible to run "image show-unwind" without a running
+# process, we can remove the unsupported line below, and hard-code an ELF
+# triple in the test.
+# UNSUPPORTED: system-windows, system-darwin
+
+# RUN: cd %T
+# RUN: %clang %S/Inputs/target-symbols-add-unwind.c -nostdlib -g \
+# RUN: -fno-unwind-tables -o target-symbols-add-unwind.debug
+# RUN: llvm-objcopy --strip-debug target-symbols-add-unwind.debug \
+# RUN: target-symbols-add-unwind.stripped
+# RUN: %lldb target-symbols-add-unwind.stripped -s %s -o quit | FileCheck %s
+
+process launch --stop-at-entry
+image show-unwind -n _start
+# CHECK-LABEL: image show-unwind -n _start
+# CHECK-NOT: debug_frame UnwindPlan:
+
+target symbols add -s target-symbols-add-unwind.stripped target-symbols-add-unwind.debug
+# CHECK-LABEL: target symbols add
+# CHECK: symbol file {{.*}} has been added to {{.*}}
+
+image show-unwind -n _start
+# CHECK-LABEL: image show-unwind -n _start
+# CHECK: debug_frame UnwindPlan:
+# CHECK-NEXT: This UnwindPlan originally sourced from DWARF CFI
+# CHECK-NEXT: This UnwindPlan is sourced from the compiler: yes.
diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp
index 262e15dbcc7..e9d9c5e7c5a 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -1300,6 +1300,12 @@ void Module::SectionFileAddressesChanged() {
sym_vendor->SectionFileAddressesChanged();
}
+UnwindTable &Module::GetUnwindTable() {
+ if (!m_unwind_table)
+ m_unwind_table.emplace(*this);
+ return *m_unwind_table;
+}
+
SectionList *Module::GetUnifiedSectionList() {
if (!m_sections_up)
m_sections_up = llvm::make_unique<SectionList>();
@@ -1446,6 +1452,10 @@ void Module::SetSymbolFileFileSpec(const FileSpec &file) {
// one
obj_file->ClearSymtab();
+ // Clear the unwind table too, as that may also be affected by the
+ // symbol file information.
+ m_unwind_table.reset();
+
// The symbol file might be a directory bundle ("/tmp/a.out.dSYM")
// instead of a full path to the symbol file within the bundle
// ("/tmp/a.out.dSYM/Contents/Resources/DWARF/a.out"). So we need to
diff --git a/lldb/source/Symbol/UnwindTable.cpp b/lldb/source/Symbol/UnwindTable.cpp
index dde31fb2450..4b87f697fc0 100644
--- a/lldb/source/Symbol/UnwindTable.cpp
+++ b/lldb/source/Symbol/UnwindTable.cpp
@@ -46,7 +46,7 @@ void UnwindTable::Initialize() {
if (!object_file)
return;
- SectionList *sl = object_file->GetSectionList();
+ SectionList *sl = m_module.GetSectionList();
if (!sl)
return;
OpenPOWER on IntegriCloud