diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2022-07-03 14:10:23 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2022-07-03 14:10:23 +0000 |
| commit | 145449b1e420787bb99721a429341fa6be3adfb6 (patch) | |
| tree | 1d56ae694a6de602e348dd80165cf881a36600ed /lldb/source/Symbol/Variable.cpp | |
| parent | ecbca9f5fb7d7613d2b94982c4825eb0d33d6842 (diff) | |
Vendor import of llvm-project main llvmorg-15-init-15358-g53dc0f107877.vendor/llvm-project/llvmorg-15-init-15358-g53dc0f107877
Diffstat (limited to 'lldb/source/Symbol/Variable.cpp')
| -rw-r--r-- | lldb/source/Symbol/Variable.cpp | 67 |
1 files changed, 27 insertions, 40 deletions
diff --git a/lldb/source/Symbol/Variable.cpp b/lldb/source/Symbol/Variable.cpp index 89682fc39141..b92c86654496 100644 --- a/lldb/source/Symbol/Variable.cpp +++ b/lldb/source/Symbol/Variable.cpp @@ -147,23 +147,13 @@ void Variable::Dump(Stream *s, bool show_context) const { if (m_location.IsValid()) { s->PutCString(", location = "); - lldb::addr_t loclist_base_addr = LLDB_INVALID_ADDRESS; - if (m_location.IsLocationList()) { - SymbolContext variable_sc; - m_owner_scope->CalculateSymbolContext(&variable_sc); - if (variable_sc.function) - loclist_base_addr = variable_sc.function->GetAddressRange() - .GetBaseAddress() - .GetFileAddress(); - } ABISP abi; if (m_owner_scope) { ModuleSP module_sp(m_owner_scope->CalculateSymbolContextModule()); if (module_sp) abi = ABI::FindPlugin(ProcessSP(), module_sp->GetArchitecture()); } - m_location.GetDescription(s, lldb::eDescriptionLevelBrief, - loclist_base_addr, abi.get()); + m_location.GetDescription(s, lldb::eDescriptionLevelBrief, abi.get()); } if (m_external) @@ -253,6 +243,14 @@ bool Variable::LocationIsValidForAddress(const Address &address) { // Be sure to resolve the address to section offset prior to calling this // function. if (address.IsSectionOffset()) { + // We need to check if the address is valid for both scope range and value + // range. + // Empty scope range means block range. + bool valid_in_scope_range = + GetScopeRange().IsEmpty() || GetScopeRange().FindEntryThatContains( + address.GetFileAddress()) != nullptr; + if (!valid_in_scope_range) + return false; SymbolContext sc; CalculateSymbolContext(&sc); if (sc.module_sp == address.GetModule()) { @@ -445,36 +443,25 @@ Status Variable::GetValuesForVariableExpressionPath( return error; } -bool Variable::DumpLocationForAddress(Stream *s, const Address &address) { - // Be sure to resolve the address to section offset prior to calling this - // function. - if (address.IsSectionOffset()) { - SymbolContext sc; - CalculateSymbolContext(&sc); - if (sc.module_sp == address.GetModule()) { - ABISP abi; - if (m_owner_scope) { - ModuleSP module_sp(m_owner_scope->CalculateSymbolContextModule()); - if (module_sp) - abi = ABI::FindPlugin(ProcessSP(), module_sp->GetArchitecture()); - } +bool Variable::DumpLocations(Stream *s, const Address &address) { + SymbolContext sc; + CalculateSymbolContext(&sc); + ABISP abi; + if (m_owner_scope) { + ModuleSP module_sp(m_owner_scope->CalculateSymbolContextModule()); + if (module_sp) + abi = ABI::FindPlugin(ProcessSP(), module_sp->GetArchitecture()); + } - const addr_t file_addr = address.GetFileAddress(); - if (sc.function) { - if (sc.function->GetAddressRange().ContainsFileAddress(address)) { - addr_t loclist_base_file_addr = - sc.function->GetAddressRange().GetBaseAddress().GetFileAddress(); - if (loclist_base_file_addr == LLDB_INVALID_ADDRESS) - return false; - return m_location.DumpLocationForAddress(s, eDescriptionLevelBrief, - loclist_base_file_addr, - file_addr, abi.get()); - } - } - return m_location.DumpLocationForAddress(s, eDescriptionLevelBrief, - LLDB_INVALID_ADDRESS, file_addr, - abi.get()); - } + const addr_t file_addr = address.GetFileAddress(); + if (sc.function) { + addr_t loclist_base_file_addr = + sc.function->GetAddressRange().GetBaseAddress().GetFileAddress(); + if (loclist_base_file_addr == LLDB_INVALID_ADDRESS) + return false; + return m_location.DumpLocations(s, eDescriptionLevelBrief, + loclist_base_file_addr, file_addr, + abi.get()); } return false; } |
