aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectTarget.cpp
diff options
context:
space:
mode:
authorPavel Labath <pavel@labath.sk>2025-02-06 09:12:44 +0100
committerGitHub <noreply@github.com>2025-02-06 09:12:44 +0100
commitfeb5a77d700f46d6638f073d411cbe0d8a924fdf (patch)
tree97b297f0356d04019e48601a09af11a787467625 /lldb/source/Commands/CommandObjectTarget.cpp
parent6e402f5121e87e82fa686046c867ef67d4b4b851 (diff)
downloadllvm-feb5a77d700f46d6638f073d411cbe0d8a924fdf.zip
llvm-feb5a77d700f46d6638f073d411cbe0d8a924fdf.tar.gz
llvm-feb5a77d700f46d6638f073d411cbe0d8a924fdf.tar.bz2
[lldb] Add SymbolContext::GetFunctionOrSymbolAddress (#123340)
Many uses of SC::GetAddressRange were not interested in the range, but in the address of the function/symbol contained inside the symbol context. They were getting that by calling the GetBaseAddress on the returned range, which worked well enough so far, but isn't compatible with discontinuous functions, whose address (entry point) may not be the lowest address in the range. To resolve this problem, this PR creates a new function whose purpose is return the address of the function or symbol inside the symbol context. It also changes all of the callers of GetAddressRange which do not actually care about the range to call this function instead.
Diffstat (limited to 'lldb/source/Commands/CommandObjectTarget.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectTarget.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp
index d8265e4..d0092c2 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -1621,12 +1621,15 @@ static void DumpSymbolContextList(
if (!first_module)
strm.EOL();
- AddressRange range;
-
- sc.GetAddressRange(eSymbolContextEverything, 0, true, range);
+ Address addr;
+ if (sc.line_entry.IsValid())
+ addr = sc.line_entry.range.GetBaseAddress();
+ else if (sc.block && sc.block->GetContainingInlinedBlock())
+ sc.block->GetContainingInlinedBlock()->GetStartAddress(addr);
+ else
+ addr = sc.GetFunctionOrSymbolAddress();
- DumpAddress(exe_scope, range.GetBaseAddress(), verbose, all_ranges, strm,
- settings);
+ DumpAddress(exe_scope, addr, verbose, all_ranges, strm, settings);
first_module = false;
}
strm.IndentLess();
@@ -3570,16 +3573,13 @@ protected:
continue;
if (!sc.module_sp || sc.module_sp->GetObjectFile() == nullptr)
continue;
- AddressRange range;
- if (!sc.GetAddressRange(eSymbolContextFunction | eSymbolContextSymbol, 0,
- false, range))
- continue;
- if (!range.GetBaseAddress().IsValid())
+ Address addr = sc.GetFunctionOrSymbolAddress();
+ if (!addr.IsValid())
continue;
ConstString funcname(sc.GetFunctionName());
if (funcname.IsEmpty())
continue;
- addr_t start_addr = range.GetBaseAddress().GetLoadAddress(target);
+ addr_t start_addr = addr.GetLoadAddress(target);
if (abi)
start_addr = abi->FixCodeAddress(start_addr);