Skip to content

[lldb] Remove (deprecated) Function::GetAddressRange #132923

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions lldb/include/lldb/Symbol/Function.h
Original file line number Diff line number Diff line change
Expand Up @@ -445,9 +445,6 @@ class Function : public UserID, public SymbolContextScope {

Function *CalculateSymbolContextFunction() override;

/// DEPRECATED: Use GetAddressRanges instead.
const AddressRange &GetAddressRange() { return m_range; }

AddressRanges GetAddressRanges() { return m_block.GetRanges(); }

/// Return the address of the function (its entry point). This address is also
Expand Down Expand Up @@ -658,11 +655,6 @@ class Function : public UserID, public SymbolContextScope {
/// All lexical blocks contained in this function.
Block m_block;

/// The function address range that covers the widest range needed to contain
/// all blocks. DEPRECATED: do not use this field in new code as the range may
/// include addresses belonging to other functions.
AddressRange m_range;

/// The address (entry point) of the function.
Address m_address;

Expand Down
28 changes: 3 additions & 25 deletions lldb/source/Symbol/Function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,33 +254,13 @@ Function *IndirectCallEdge::GetCallee(ModuleList &images,

/// @}

AddressRange CollapseRanges(llvm::ArrayRef<AddressRange> ranges) {
if (ranges.empty())
return AddressRange();
if (ranges.size() == 1)
return ranges[0];

Address lowest_addr = ranges[0].GetBaseAddress();
addr_t highest_addr = lowest_addr.GetFileAddress() + ranges[0].GetByteSize();
for (const AddressRange &range : ranges.drop_front()) {
Address range_begin = range.GetBaseAddress();
addr_t range_end = range_begin.GetFileAddress() + range.GetByteSize();
if (range_begin.GetFileAddress() < lowest_addr.GetFileAddress())
lowest_addr = range_begin;
if (range_end > highest_addr)
highest_addr = range_end;
}
return AddressRange(lowest_addr, highest_addr - lowest_addr.GetFileAddress());
}

//
Function::Function(CompileUnit *comp_unit, lldb::user_id_t func_uid,
lldb::user_id_t type_uid, const Mangled &mangled, Type *type,
Address address, AddressRanges ranges)
: UserID(func_uid), m_comp_unit(comp_unit), m_type_uid(type_uid),
m_type(type), m_mangled(mangled), m_block(*this, func_uid),
m_range(CollapseRanges(ranges)), m_address(std::move(address)),
m_prologue_byte_size(0) {
m_address(std::move(address)), m_prologue_byte_size(0) {
assert(comp_unit != nullptr);
lldb::addr_t base_file_addr = m_address.GetFileAddress();
for (const AddressRange &range : ranges)
Expand Down Expand Up @@ -464,8 +444,7 @@ void Function::Dump(Stream *s, bool show_context) const {
s->EOL();
// Dump the root object
if (m_block.BlockInfoHasBeenParsed())
m_block.Dump(s, m_range.GetBaseAddress().GetFileAddress(), INT_MAX,
show_context);
m_block.Dump(s, m_address.GetFileAddress(), INT_MAX, show_context);
}

void Function::CalculateSymbolContext(SymbolContext *sc) {
Expand All @@ -474,8 +453,7 @@ void Function::CalculateSymbolContext(SymbolContext *sc) {
}

ModuleSP Function::CalculateSymbolContextModule() {
SectionSP section_sp(m_range.GetBaseAddress().GetSection());
if (section_sp)
if (SectionSP section_sp = m_address.GetSection())
return section_sp->GetModule();

return this->GetCompileUnit()->GetModule();
Expand Down