<rdar://problem/13265297>
StackFrame assumes m_sc is additive, but m_sc can lose its target. So now the SymbolContext::Clear() method takes a bool that indicates if the target should be cleared. Modified all existing code to properly set the bool argument.
git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@175953 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/API/SBSymbolContext.cpp b/source/API/SBSymbolContext.cpp
index a310d25..780364c 100644
--- a/source/API/SBSymbolContext.cpp
+++ b/source/API/SBSymbolContext.cpp
@@ -72,7 +72,7 @@
else
{
if (m_opaque_ap.get())
- m_opaque_ap->Clear();
+ m_opaque_ap->Clear(true);
}
}
diff --git a/source/Commands/CommandObjectSource.cpp b/source/Commands/CommandObjectSource.cpp
index 0beaadf..d7daa49 100644
--- a/source/Commands/CommandObjectSource.cpp
+++ b/source/Commands/CommandObjectSource.cpp
@@ -482,7 +482,7 @@
ModuleSP module_sp (module_list.GetModuleAtIndex(i));
if (module_sp && module_sp->ResolveFileAddress(m_options.address, so_addr))
{
- sc.Clear();
+ sc.Clear(true);
if (module_sp->ResolveSymbolContextForAddress (so_addr, eSymbolContextEverything, sc) & eSymbolContextLineEntry)
sc_list.Append(sc);
}
@@ -505,7 +505,7 @@
ModuleSP module_sp (so_addr.GetModule());
if (module_sp)
{
- sc.Clear();
+ sc.Clear(true);
if (module_sp->ResolveSymbolContextForAddress (so_addr, eSymbolContextEverything, sc) & eSymbolContextLineEntry)
{
sc_list.Append(sc);
diff --git a/source/Core/Address.cpp b/source/Core/Address.cpp
index 5c9ed1a..66093bc 100644
--- a/source/Core/Address.cpp
+++ b/source/Core/Address.cpp
@@ -762,7 +762,7 @@
uint32_t
Address::CalculateSymbolContext (SymbolContext *sc, uint32_t resolve_scope) const
{
- sc->Clear();
+ sc->Clear(false);
// Absolute addresses don't have enough information to reconstruct even their target.
SectionSP section_sp (GetSection());
diff --git a/source/Core/Disassembler.cpp b/source/Core/Disassembler.cpp
index 0d29e01..b74238c 100644
--- a/source/Core/Disassembler.cpp
+++ b/source/Core/Disassembler.cpp
@@ -445,7 +445,7 @@
}
else
{
- sc.Clear();
+ sc.Clear(true);
}
}
diff --git a/source/Core/Module.cpp b/source/Core/Module.cpp
index 9490d2e..953a81b 100644
--- a/source/Core/Module.cpp
+++ b/source/Core/Module.cpp
@@ -442,8 +442,8 @@
Mutex::Locker locker (m_mutex);
uint32_t resolved_flags = 0;
- // Clear the result symbol context in case we don't find anything
- sc.Clear();
+ // Clear the result symbol context in case we don't find anything, but don't clear the target
+ sc.Clear(false);
// Get the section from the section/offset address.
SectionSP section_sp (so_addr.GetSection());
diff --git a/source/Expression/ClangExpressionDeclMap.cpp b/source/Expression/ClangExpressionDeclMap.cpp
index 9851a46..db1ef16 100644
--- a/source/Expression/ClangExpressionDeclMap.cpp
+++ b/source/Expression/ClangExpressionDeclMap.cpp
@@ -86,12 +86,12 @@
m_parser_vars->m_sym_ctx = exe_ctx.GetThreadPtr()->GetStackFrameAtIndex(0)->GetSymbolContext(lldb::eSymbolContextEverything);
else if (exe_ctx.GetProcessPtr())
{
- m_parser_vars->m_sym_ctx.Clear();
+ m_parser_vars->m_sym_ctx.Clear(true);
m_parser_vars->m_sym_ctx.target_sp = exe_ctx.GetTargetSP();
}
else if (target)
{
- m_parser_vars->m_sym_ctx.Clear();
+ m_parser_vars->m_sym_ctx.Clear(true);
m_parser_vars->m_sym_ctx.target_sp = exe_ctx.GetTargetSP();
}
diff --git a/source/Plugins/Process/Utility/RegisterContextLLDB.cpp b/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
index cb691c5..6b52a62 100644
--- a/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
@@ -60,7 +60,7 @@
m_registers(),
m_parent_unwind (unwind_lldb)
{
- m_sym_ctx.Clear();
+ m_sym_ctx.Clear(false);
m_sym_ctx_valid = false;
if (IsFrameZero ())
@@ -409,7 +409,7 @@
{
Address temporary_pc(m_current_pc);
temporary_pc.SetOffset(m_current_pc.GetOffset() - 1);
- m_sym_ctx.Clear();
+ m_sym_ctx.Clear(false);
m_sym_ctx_valid = false;
if ((pc_module_sp->ResolveSymbolContextForAddress (temporary_pc, eSymbolContextFunction| eSymbolContextSymbol, m_sym_ctx) & eSymbolContextSymbol) == eSymbolContextSymbol)
{
diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index d7e5db1..95e049c 100644
--- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -2564,7 +2564,7 @@
bool
SymbolFileDWARF::GetFunction (DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry* func_die, SymbolContext& sc)
{
- sc.Clear();
+ sc.Clear(false);
// Check if the symbol vendor already knows about this compile unit?
sc.comp_unit = GetCompUnitForDWARFCompUnit(dwarf_cu, UINT32_MAX);
diff --git a/source/Symbol/SymbolContext.cpp b/source/Symbol/SymbolContext.cpp
index b3d9748..b4b777b 100644
--- a/source/Symbol/SymbolContext.cpp
+++ b/source/Symbol/SymbolContext.cpp
@@ -108,9 +108,10 @@
}
void
-SymbolContext::Clear()
+SymbolContext::Clear(bool clear_target)
{
- target_sp.reset();
+ if (clear_target)
+ target_sp.reset();
module_sp.reset();
comp_unit = NULL;
function = NULL;
@@ -453,7 +454,7 @@
SymbolContext &next_frame_sc,
Address &next_frame_pc) const
{
- next_frame_sc.Clear();
+ next_frame_sc.Clear(false);
next_frame_pc.Clear();
if (block)
diff --git a/source/Symbol/Variable.cpp b/source/Symbol/Variable.cpp
index 8172875..309e392 100644
--- a/source/Symbol/Variable.cpp
+++ b/source/Symbol/Variable.cpp
@@ -203,7 +203,7 @@
if (m_owner_scope)
m_owner_scope->CalculateSymbolContext(sc);
else
- sc->Clear();
+ sc->Clear(false);
}
bool
diff --git a/source/Target/StackFrame.cpp b/source/Target/StackFrame.cpp
index 2cc46ef..98249a4 100644
--- a/source/Target/StackFrame.cpp
+++ b/source/Target/StackFrame.cpp
@@ -250,7 +250,7 @@
StackFrame::ChangePC (addr_t pc)
{
m_frame_code_addr.SetRawAddress(pc);
- m_sc.Clear();
+ m_sc.Clear(false);
m_flags.Reset(0);
ThreadSP thread_sp (GetThread());
if (thread_sp)