From 72310355ff64de112fcdd9e39297ddf377c9257e Mon Sep 17 00:00:00 2001 From: Greg Clayton Date: Sat, 23 Feb 2013 04:12:47 +0000 Subject: [PATCH] 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. llvm-svn: 175953 --- lldb/include/lldb/Symbol/SymbolContext.h | 2 +- lldb/source/API/SBSymbolContext.cpp | 2 +- lldb/source/Commands/CommandObjectSource.cpp | 4 ++-- lldb/source/Core/Address.cpp | 2 +- lldb/source/Core/Disassembler.cpp | 2 +- lldb/source/Core/Module.cpp | 4 ++-- lldb/source/Expression/ClangExpressionDeclMap.cpp | 4 ++-- lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp | 4 ++-- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp | 2 +- lldb/source/Symbol/SymbolContext.cpp | 7 ++++--- lldb/source/Symbol/Variable.cpp | 2 +- lldb/source/Target/StackFrame.cpp | 2 +- 12 files changed, 19 insertions(+), 18 deletions(-) diff --git a/lldb/include/lldb/Symbol/SymbolContext.h b/lldb/include/lldb/Symbol/SymbolContext.h index f6c05b0..719fac1 100644 --- a/lldb/include/lldb/Symbol/SymbolContext.h +++ b/lldb/include/lldb/Symbol/SymbolContext.h @@ -131,7 +131,7 @@ public: /// to their default state. //------------------------------------------------------------------ void - Clear (); + Clear (bool clear_target); //------------------------------------------------------------------ /// Dump a description of this object to a Stream. diff --git a/lldb/source/API/SBSymbolContext.cpp b/lldb/source/API/SBSymbolContext.cpp index a310d25..780364c 100644 --- a/lldb/source/API/SBSymbolContext.cpp +++ b/lldb/source/API/SBSymbolContext.cpp @@ -72,7 +72,7 @@ SBSymbolContext::SetSymbolContext (const SymbolContext *sc_ptr) else { if (m_opaque_ap.get()) - m_opaque_ap->Clear(); + m_opaque_ap->Clear(true); } } diff --git a/lldb/source/Commands/CommandObjectSource.cpp b/lldb/source/Commands/CommandObjectSource.cpp index 0beaadf..d7daa49 100644 --- a/lldb/source/Commands/CommandObjectSource.cpp +++ b/lldb/source/Commands/CommandObjectSource.cpp @@ -482,7 +482,7 @@ protected: 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 @@ protected: 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/lldb/source/Core/Address.cpp b/lldb/source/Core/Address.cpp index 5c9ed1a..66093bc 100644 --- a/lldb/source/Core/Address.cpp +++ b/lldb/source/Core/Address.cpp @@ -762,7 +762,7 @@ Address::Dump (Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, Dum 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/lldb/source/Core/Disassembler.cpp b/lldb/source/Core/Disassembler.cpp index 0d29e01..b74238c 100644 --- a/lldb/source/Core/Disassembler.cpp +++ b/lldb/source/Core/Disassembler.cpp @@ -445,7 +445,7 @@ Disassembler::PrintInstructions } else { - sc.Clear(); + sc.Clear(true); } } diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp index 9490d2e..953a81b 100644 --- a/lldb/source/Core/Module.cpp +++ b/lldb/source/Core/Module.cpp @@ -442,8 +442,8 @@ Module::ResolveSymbolContextForAddress (const Address& so_addr, uint32_t resolve 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/lldb/source/Expression/ClangExpressionDeclMap.cpp b/lldb/source/Expression/ClangExpressionDeclMap.cpp index 9851a46..db1ef16 100644 --- a/lldb/source/Expression/ClangExpressionDeclMap.cpp +++ b/lldb/source/Expression/ClangExpressionDeclMap.cpp @@ -86,12 +86,12 @@ ClangExpressionDeclMap::WillParse(ExecutionContext &exe_ctx) 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/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp index cb691c5..6b52a62 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp +++ b/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp @@ -60,7 +60,7 @@ RegisterContextLLDB::RegisterContextLLDB 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 @@ RegisterContextLLDB::InitializeNonZerothFrame() { 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/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index d7e5db1..95e049c 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -2564,7 +2564,7 @@ SymbolFileDWARF::GetCompUnitForDWARFCompUnit (DWARFCompileUnit* dwarf_cu, uint32 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/lldb/source/Symbol/SymbolContext.cpp b/lldb/source/Symbol/SymbolContext.cpp index b3d9748..b4b777b 100644 --- a/lldb/source/Symbol/SymbolContext.cpp +++ b/lldb/source/Symbol/SymbolContext.cpp @@ -108,9 +108,10 @@ SymbolContext::operator= (const SymbolContext& rhs) } 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::GetParentOfInlinedScope (const Address &curr_frame_pc, 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/lldb/source/Symbol/Variable.cpp b/lldb/source/Symbol/Variable.cpp index 8172875..309e392 100644 --- a/lldb/source/Symbol/Variable.cpp +++ b/lldb/source/Symbol/Variable.cpp @@ -203,7 +203,7 @@ Variable::CalculateSymbolContext (SymbolContext *sc) if (m_owner_scope) m_owner_scope->CalculateSymbolContext(sc); else - sc->Clear(); + sc->Clear(false); } bool diff --git a/lldb/source/Target/StackFrame.cpp b/lldb/source/Target/StackFrame.cpp index 2cc46ef..98249a4 100644 --- a/lldb/source/Target/StackFrame.cpp +++ b/lldb/source/Target/StackFrame.cpp @@ -250,7 +250,7 @@ void 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) -- 2.7.4