From feb5a77d700f46d6638f073d411cbe0d8a924fdf Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Thu, 6 Feb 2025 09:12:44 +0100 Subject: [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. --- lldb/source/Commands/CommandObjectTarget.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'lldb/source/Commands/CommandObjectTarget.cpp') 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); -- cgit v1.1