diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2021-07-29 20:15:26 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2021-07-29 20:15:26 +0000 |
| commit | 344a3780b2e33f6ca763666c380202b18aab72a3 (patch) | |
| tree | f0b203ee6eb71d7fdd792373e3c81eb18d6934dd /lldb/source/Target/StackFrame.cpp | |
| parent | b60736ec1405bb0a8dd40989f67ef4c93da068ab (diff) | |
vendor/llvm-project/llvmorg-13-init-16847-g88e66fa60ae5vendor/llvm-project/llvmorg-12.0.1-rc2-0-ge7dac564cd0evendor/llvm-project/llvmorg-12.0.1-0-gfed41342a82f
Diffstat (limited to 'lldb/source/Target/StackFrame.cpp')
| -rw-r--r-- | lldb/source/Target/StackFrame.cpp | 87 |
1 files changed, 34 insertions, 53 deletions
diff --git a/lldb/source/Target/StackFrame.cpp b/lldb/source/Target/StackFrame.cpp index 131581567d73..cba51d266c5b 100644 --- a/lldb/source/Target/StackFrame.cpp +++ b/lldb/source/Target/StackFrame.cpp @@ -213,6 +213,35 @@ const Address &StackFrame::GetFrameCodeAddress() { return m_frame_code_addr; } +// This can't be rewritten into a call to +// RegisterContext::GetPCForSymbolication because this +// StackFrame may have been constructed with a special pc, +// e.g. tail-call artificial frames. +Address StackFrame::GetFrameCodeAddressForSymbolication() { + Address lookup_addr(GetFrameCodeAddress()); + if (!lookup_addr.IsValid()) + return lookup_addr; + if (m_behaves_like_zeroth_frame) + return lookup_addr; + + addr_t offset = lookup_addr.GetOffset(); + if (offset > 0) { + lookup_addr.SetOffset(offset - 1); + } else { + // lookup_addr is the start of a section. We need do the math on the + // actual load address and re-compute the section. We're working with + // a 'noreturn' function at the end of a section. + TargetSP target_sp = CalculateTarget(); + if (target_sp) { + addr_t addr_minus_one = lookup_addr.GetOpcodeLoadAddress( + target_sp.get(), AddressClass::eCode) - + 1; + lookup_addr.SetOpcodeLoadAddress(addr_minus_one, target_sp.get()); + } + } + return lookup_addr; +} + bool StackFrame::ChangePC(addr_t pc) { std::lock_guard<std::recursive_mutex> guard(m_mutex); // We can't change the pc value of a history stack frame - it is immutable. @@ -288,30 +317,7 @@ StackFrame::GetSymbolContext(SymbolContextItem resolve_scope) { // If this is not frame zero, then we need to subtract 1 from the PC value // when doing address lookups since the PC will be on the instruction // following the function call instruction... - - Address lookup_addr(GetFrameCodeAddress()); - if (!m_behaves_like_zeroth_frame && lookup_addr.IsValid()) { - addr_t offset = lookup_addr.GetOffset(); - if (offset > 0) { - lookup_addr.SetOffset(offset - 1); - - } else { - // lookup_addr is the start of a section. We need do the math on the - // actual load address and re-compute the section. We're working with - // a 'noreturn' function at the end of a section. - ThreadSP thread_sp(GetThread()); - if (thread_sp) { - TargetSP target_sp(thread_sp->CalculateTarget()); - if (target_sp) { - addr_t addr_minus_one = - lookup_addr.GetLoadAddress(target_sp.get()) - 1; - lookup_addr.SetLoadAddress(addr_minus_one, target_sp.get()); - } else { - lookup_addr.SetOffset(offset - 1); - } - } - } - } + Address lookup_addr(GetFrameCodeAddressForSymbolication()); if (m_sc.module_sp) { // We have something in our stack frame symbol context, lets check if we @@ -1160,31 +1166,6 @@ StackFrame::GetValueObjectForFrameVariable(const VariableSP &variable_sp, return valobj_sp; } -ValueObjectSP StackFrame::TrackGlobalVariable(const VariableSP &variable_sp, - DynamicValueType use_dynamic) { - std::lock_guard<std::recursive_mutex> guard(m_mutex); - if (IsHistorical()) - return ValueObjectSP(); - - // Check to make sure we aren't already tracking this variable? - ValueObjectSP valobj_sp( - GetValueObjectForFrameVariable(variable_sp, use_dynamic)); - if (!valobj_sp) { - // We aren't already tracking this global - VariableList *var_list = GetVariableList(true); - // If this frame has no variables, create a new list - if (var_list == nullptr) - m_variable_list_sp = std::make_shared<VariableList>(); - - // Add the global/static variable to this frame - m_variable_list_sp->AddVariable(variable_sp); - - // Now make a value object for it so we can track its changes - valobj_sp = GetValueObjectForFrameVariable(variable_sp, use_dynamic); - } - return valobj_sp; -} - bool StackFrame::IsInlined() { if (m_sc.block == nullptr) GetSymbolContext(eSymbolContextBlock); @@ -1313,11 +1294,11 @@ lldb::ValueObjectSP StackFrame::GuessValueForAddress(lldb::addr_t addr) { const char *plugin_name = nullptr; const char *flavor = nullptr; - const bool prefer_file_cache = false; + const bool force_live_memory = true; DisassemblerSP disassembler_sp = Disassembler::DisassembleRange(target_arch, plugin_name, flavor, - *target_sp, pc_range, prefer_file_cache); + *target_sp, pc_range, force_live_memory); if (!disassembler_sp || !disassembler_sp->GetInstructionList().GetSize()) { return ValueObjectSP(); @@ -1693,10 +1674,10 @@ lldb::ValueObjectSP StackFrame::GuessValueForRegisterAndOffset(ConstString reg, const char *plugin_name = nullptr; const char *flavor = nullptr; - const bool prefer_file_cache = false; + const bool force_live_memory = true; DisassemblerSP disassembler_sp = Disassembler::DisassembleRange(target_arch, plugin_name, flavor, - *target_sp, pc_range, prefer_file_cache); + *target_sp, pc_range, force_live_memory); if (!disassembler_sp || !disassembler_sp->GetInstructionList().GetSize()) { return ValueObjectSP(); |
