From 22cfe6f39d432bd095e9a3638033f2bb99f83c8e Mon Sep 17 00:00:00 2001 From: Sergei Barannikov Date: Fri, 27 Mar 2026 20:22:48 +0300 Subject: [PATCH] [lldb] Make single-argument Address constructor explicit (NFC) (#189035) This is to highlight places where we (probably unintentionally) construct an `Address` object from an already resolved address, making it unresolved again. See the changes in `DynamicLoaderDarwin.cpp` for a quick example. Also, use this constructor instead of `Address(lldb::addr_t file_addr, const SectionList *section_list)` when `section_list` is `nullptr`. --- lldb/include/lldb/Breakpoint/BreakpointLocation.h | 8 ++++---- lldb/include/lldb/Core/Address.h | 2 +- lldb/source/Breakpoint/BreakpointLocation.cpp | 8 ++------ lldb/source/Commands/CommandObjectMemory.cpp | 6 +++--- lldb/source/Commands/CommandObjectTarget.cpp | 7 ++++--- lldb/source/Core/Address.cpp | 2 +- lldb/source/DataFormatters/FormattersHelpers.cpp | 2 +- lldb/source/DataFormatters/StringPrinter.cpp | 3 +-- lldb/source/Expression/DWARFExpression.cpp | 8 ++++---- lldb/source/Plugins/ABI/Mips/ABISysV_mips.cpp | 2 +- lldb/source/Plugins/ABI/Mips/ABISysV_mips64.cpp | 2 +- lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc.cpp | 2 +- lldb/source/Plugins/ABI/SystemZ/ABISysV_s390x.cpp | 2 +- lldb/source/Plugins/ABI/X86/ABISysV_i386.cpp | 4 ++-- lldb/source/Plugins/ABI/X86/ABISysV_x86_64.cpp | 2 +- lldb/source/Plugins/ABI/X86/ABIWindows_x86_64.cpp | 2 +- .../Plugins/Architecture/Mips/ArchitectureMips.cpp | 2 +- .../FreeBSD-Kernel/DynamicLoaderFreeBSDKernel.cpp | 2 -- .../Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp | 2 +- .../MacOSX-DYLD/DynamicLoaderDarwin.cpp | 3 ++- .../InstrumentationRuntimeMainThreadChecker.cpp | 2 +- lldb/source/Plugins/Language/ObjC/CFBasicHash.cpp | 4 ++-- lldb/source/Plugins/Language/ObjC/CFBasicHash.h | 2 +- lldb/source/Plugins/Language/ObjC/NSString.cpp | 14 +++++++------- .../CPlusPlus/ItaniumABIRuntime.cpp | 2 +- .../Plugins/ObjectFile/ELF/ObjectFileELF.cpp | 10 ++++++---- .../Plugins/SymbolFile/CTF/SymbolFileCTF.cpp | 3 ++- .../SymbolFile/NativePDB/SymbolFileNativePDB.cpp | 2 +- lldb/source/Symbol/SymbolContext.cpp | 2 +- lldb/source/Target/StackFrame.cpp | 4 ++-- lldb/source/Target/Target.cpp | 2 +- .../source/ValueObject/ValueObjectDynamicValue.cpp | 2 +- 32 files changed, 59 insertions(+), 61 deletions(-) diff --git a/lldb/include/lldb/Breakpoint/BreakpointLocation.h b/lldb/include/lldb/Breakpoint/BreakpointLocation.h index c44ff471b8c4..d7eef1966bb3 100644 --- a/lldb/include/lldb/Breakpoint/BreakpointLocation.h +++ b/lldb/include/lldb/Breakpoint/BreakpointLocation.h @@ -406,9 +406,9 @@ public: private: // Data members: - bool m_should_resolve_indirect_functions; - bool m_is_reexported; - bool m_is_indirect; + bool m_should_resolve_indirect_functions = false; + bool m_is_reexported = false; + bool m_is_indirect = false; ///< The address defining this location. Address m_address; ///< The breakpoint that produced this object. @@ -424,7 +424,7 @@ private: /// by multiple processes. std::mutex m_condition_mutex; ///< For testing whether the condition source code changed. - size_t m_condition_hash; + size_t m_condition_hash = 0; ///< Breakpoint location ID. lldb::break_id_t m_loc_id; ///< Number of times this breakpoint location has been hit. diff --git a/lldb/include/lldb/Core/Address.h b/lldb/include/lldb/Core/Address.h index 85b2ab7bb3cf..71078bb44e57 100644 --- a/lldb/include/lldb/Core/Address.h +++ b/lldb/include/lldb/Core/Address.h @@ -160,7 +160,7 @@ public: /// A list of sections, one of which may contain the \a file_addr. Address(lldb::addr_t file_addr, const SectionList *section_list); - Address(lldb::addr_t abs_addr); + explicit Address(lldb::addr_t abs_addr); /// Assignment operator. /// diff --git a/lldb/source/Breakpoint/BreakpointLocation.cpp b/lldb/source/Breakpoint/BreakpointLocation.cpp index 1ec60b8fa32e..4bc6fff70c89 100644 --- a/lldb/source/Breakpoint/BreakpointLocation.cpp +++ b/lldb/source/Breakpoint/BreakpointLocation.cpp @@ -34,9 +34,7 @@ using namespace lldb_private; BreakpointLocation::BreakpointLocation(break_id_t loc_id, Breakpoint &owner, const Address &addr, lldb::tid_t tid, bool check_for_resolver) - : m_should_resolve_indirect_functions(false), m_is_reexported(false), - m_is_indirect(false), m_address(addr), m_owner(owner), - m_condition_hash(0), m_loc_id(loc_id), m_hit_counter() { + : m_address(addr), m_owner(owner), m_loc_id(loc_id) { if (check_for_resolver) { const Symbol *symbol = m_address.CalculateSymbolContextSymbol(); if (symbol && symbol->IsIndirect()) { @@ -48,9 +46,7 @@ BreakpointLocation::BreakpointLocation(break_id_t loc_id, Breakpoint &owner, } BreakpointLocation::BreakpointLocation(break_id_t loc_id, Breakpoint &owner) - : m_should_resolve_indirect_functions(false), m_is_reexported(false), - m_is_indirect(false), m_address(LLDB_INVALID_ADDRESS), m_owner(owner), - m_condition_hash(0), m_loc_id(loc_id), m_hit_counter() { + : m_owner(owner), m_loc_id(loc_id) { SetThreadIDInternal(LLDB_INVALID_THREAD_ID); } diff --git a/lldb/source/Commands/CommandObjectMemory.cpp b/lldb/source/Commands/CommandObjectMemory.cpp index 3b416028ee41..21ee0f21b8e0 100644 --- a/lldb/source/Commands/CommandObjectMemory.cpp +++ b/lldb/source/Commands/CommandObjectMemory.cpp @@ -655,7 +655,7 @@ protected: return; } - Address address(addr, nullptr); + Address address(addr); bytes_read = target->ReadMemory(address, data_sp->GetBytes(), data_sp->GetByteSize(), error, true); if (bytes_read == 0) { @@ -703,8 +703,8 @@ protected: std::string buffer; buffer.resize(item_byte_size + 1, 0); Status error; - size_t read = target->ReadCStringFromMemory(data_addr, &buffer[0], - item_byte_size + 1, error); + size_t read = target->ReadCStringFromMemory( + Address(data_addr), &buffer[0], item_byte_size + 1, error); if (error.Fail()) { result.AppendErrorWithFormat( "failed to read memory from 0x%" PRIx64 ".\n", addr); diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp index ea68d5b600a0..dccb7256b1cb 100644 --- a/lldb/source/Commands/CommandObjectTarget.cpp +++ b/lldb/source/Commands/CommandObjectTarget.cpp @@ -3632,9 +3632,10 @@ protected: UnwindTable &uw_table = sc.module_sp->GetUnwindTable(); FuncUnwindersSP func_unwinders_sp = m_options.m_cached - ? uw_table.GetFuncUnwindersContainingAddress(start_addr, sc) - : uw_table.GetUncachedFuncUnwindersContainingAddress(start_addr, - sc); + ? uw_table.GetFuncUnwindersContainingAddress(Address(start_addr), + sc) + : uw_table.GetUncachedFuncUnwindersContainingAddress( + Address(start_addr), sc); if (!func_unwinders_sp) continue; diff --git a/lldb/source/Core/Address.cpp b/lldb/source/Core/Address.cpp index f19d22b3c0d6..dd550028c5f7 100644 --- a/lldb/source/Core/Address.cpp +++ b/lldb/source/Core/Address.cpp @@ -748,7 +748,7 @@ bool Address::Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, DumpAddressRange(s->AsRawOstream(), range->GetRangeBase(), range->GetRangeEnd(), addr_size); s->PutCString(", location = "); - var_sp->DumpLocations(s, all_ranges ? LLDB_INVALID_ADDRESS : *this); + var_sp->DumpLocations(s, all_ranges ? Address() : *this); s->PutCString(", decl = "); var_sp->GetDeclaration().DumpStopContext(s, false); s->EOL(); diff --git a/lldb/source/DataFormatters/FormattersHelpers.cpp b/lldb/source/DataFormatters/FormattersHelpers.cpp index 9b1ee8e7f6bc..ce65de05547e 100644 --- a/lldb/source/DataFormatters/FormattersHelpers.cpp +++ b/lldb/source/DataFormatters/FormattersHelpers.cpp @@ -125,7 +125,7 @@ lldb_private::formatters::GetArrayAddressOrPointerValue(ValueObject &valobj) { data_addr.type == eAddressTypeFile) return Address(data_addr.address, valobj.GetModule()->GetSectionList()); - return data_addr.address; + return Address(data_addr.address); } void lldb_private::formatters::DumpCxxSmartPtrPointerSummary( diff --git a/lldb/source/DataFormatters/StringPrinter.cpp b/lldb/source/DataFormatters/StringPrinter.cpp index 257178425017..60cb0fc5d687 100644 --- a/lldb/source/DataFormatters/StringPrinter.cpp +++ b/lldb/source/DataFormatters/StringPrinter.cpp @@ -404,8 +404,7 @@ static bool ReadEncodedBufferAndDumpToStream( if (!options.GetStream()) return false; - if (options.GetLocation() == 0 || - options.GetLocation() == LLDB_INVALID_ADDRESS) + if (options.GetLocation() == Address(0) || options.GetLocation() == Address()) return false; lldb::TargetSP target_sp = options.GetTargetSP(); diff --git a/lldb/source/Expression/DWARFExpression.cpp b/lldb/source/Expression/DWARFExpression.cpp index c23471a2c121..7f59fe827cf2 100644 --- a/lldb/source/Expression/DWARFExpression.cpp +++ b/lldb/source/Expression/DWARFExpression.cpp @@ -1899,10 +1899,10 @@ llvm::Expected DWARFExpression::Evaluate( case Value::ValueType::LoadAddress: { if (target) { if (curr_piece.ResizeData(piece_byte_size) == piece_byte_size) { - if (target->ReadMemory(addr, curr_piece.GetBuffer().GetBytes(), - piece_byte_size, error, - /*force_live_memory=*/false) != - piece_byte_size) { + if (target->ReadMemory( + Address(addr), curr_piece.GetBuffer().GetBytes(), + piece_byte_size, error, + /*force_live_memory=*/false) != piece_byte_size) { const char *addr_type = (curr_piece_source_value_type == Value::ValueType::LoadAddress) ? "load" diff --git a/lldb/source/Plugins/ABI/Mips/ABISysV_mips.cpp b/lldb/source/Plugins/ABI/Mips/ABISysV_mips.cpp index 338d5c152f61..dd99d47bb28c 100644 --- a/lldb/source/Plugins/ABI/Mips/ABISysV_mips.cpp +++ b/lldb/source/Plugins/ABI/Mips/ABISysV_mips.cpp @@ -847,7 +847,7 @@ ValueObjectSP ABISysV_mips::GetReturnValueObjectImpl( reg_ctx->GetRegisterInfoByName("r2", 0), 0); // We have got the address. Create a memory object out of it return_valobj_sp = ValueObjectMemory::Create( - &thread, "", Address(mem_address, nullptr), return_compiler_type); + &thread, "", Address(mem_address), return_compiler_type); return return_valobj_sp; } else if (return_compiler_type.IsRealFloatingPointType()) { if (IsSoftFloat(fp_flag)) { diff --git a/lldb/source/Plugins/ABI/Mips/ABISysV_mips64.cpp b/lldb/source/Plugins/ABI/Mips/ABISysV_mips64.cpp index 2cd49478878e..328ddad97524 100644 --- a/lldb/source/Plugins/ABI/Mips/ABISysV_mips64.cpp +++ b/lldb/source/Plugins/ABI/Mips/ABISysV_mips64.cpp @@ -1121,7 +1121,7 @@ ValueObjectSP ABISysV_mips64::GetReturnValueObjectImpl( // We have got the address. Create a memory object out of it return_valobj_sp = ValueObjectMemory::Create( - &thread, "", Address(mem_address, nullptr), return_compiler_type); + &thread, "", Address(mem_address), return_compiler_type); } return return_valobj_sp; } diff --git a/lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc.cpp b/lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc.cpp index fea5174e8fbb..bdfc9c7e0806 100644 --- a/lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc.cpp +++ b/lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc.cpp @@ -843,7 +843,7 @@ ValueObjectSP ABISysV_ppc::GetReturnValueObjectImpl( (uint64_t)thread.GetRegisterContext()->ReadRegisterAsUnsigned(r3_id, 0); return_valobj_sp = ValueObjectMemory::Create( - &thread, "", Address(storage_addr, nullptr), return_compiler_type); + &thread, "", Address(storage_addr), return_compiler_type); } } diff --git a/lldb/source/Plugins/ABI/SystemZ/ABISysV_s390x.cpp b/lldb/source/Plugins/ABI/SystemZ/ABISysV_s390x.cpp index 063ca39c5647..f1abe9434537 100644 --- a/lldb/source/Plugins/ABI/SystemZ/ABISysV_s390x.cpp +++ b/lldb/source/Plugins/ABI/SystemZ/ABISysV_s390x.cpp @@ -605,7 +605,7 @@ ValueObjectSP ABISysV_s390x::GetReturnValueObjectImpl( lldb::addr_t storage_addr = (uint64_t)thread.GetRegisterContext()->ReadRegisterAsUnsigned(r2_id, 0); return_valobj_sp = ValueObjectMemory::Create( - &thread, "", Address(storage_addr, nullptr), return_compiler_type); + &thread, "", Address(storage_addr), return_compiler_type); } return return_valobj_sp; diff --git a/lldb/source/Plugins/ABI/X86/ABISysV_i386.cpp b/lldb/source/Plugins/ABI/X86/ABISysV_i386.cpp index 3e31e10c78f9..b7304e826746 100644 --- a/lldb/source/Plugins/ABI/X86/ABISysV_i386.cpp +++ b/lldb/source/Plugins/ABI/X86/ABISysV_i386.cpp @@ -505,7 +505,7 @@ ValueObjectSP ABISysV_i386::GetReturnValueObjectSimple( thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & 0xffffffff); return_valobj_sp = ValueObjectMemory::Create( - &thread, "", Address(storage_addr, nullptr), return_compiler_type); + &thread, "", Address(storage_addr), return_compiler_type); } } else // Neither 'Integral' nor 'Floating Point' { @@ -614,7 +614,7 @@ ValueObjectSP ABISysV_i386::GetReturnValueObjectImpl( thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & 0xffffffff); return_valobj_sp = ValueObjectMemory::Create( - &thread, "", Address(storage_addr, nullptr), return_compiler_type); + &thread, "", Address(storage_addr), return_compiler_type); } return return_valobj_sp; diff --git a/lldb/source/Plugins/ABI/X86/ABISysV_x86_64.cpp b/lldb/source/Plugins/ABI/X86/ABISysV_x86_64.cpp index 1d184d64f5a4..c033c0edadc8 100644 --- a/lldb/source/Plugins/ABI/X86/ABISysV_x86_64.cpp +++ b/lldb/source/Plugins/ABI/X86/ABISysV_x86_64.cpp @@ -841,7 +841,7 @@ ValueObjectSP ABISysV_x86_64::GetReturnValueObjectImpl( (uint64_t)thread.GetRegisterContext()->ReadRegisterAsUnsigned(rax_id, 0); return_valobj_sp = ValueObjectMemory::Create( - &thread, "", Address(storage_addr, nullptr), return_compiler_type); + &thread, "", Address(storage_addr), return_compiler_type); } } diff --git a/lldb/source/Plugins/ABI/X86/ABIWindows_x86_64.cpp b/lldb/source/Plugins/ABI/X86/ABIWindows_x86_64.cpp index 620a247be547..079b22a30760 100644 --- a/lldb/source/Plugins/ABI/X86/ABIWindows_x86_64.cpp +++ b/lldb/source/Plugins/ABI/X86/ABIWindows_x86_64.cpp @@ -724,7 +724,7 @@ ValueObjectSP ABIWindows_x86_64::GetReturnValueObjectImpl( (uint64_t)thread.GetRegisterContext()->ReadRegisterAsUnsigned(rax_id, 0); return_valobj_sp = ValueObjectMemory::Create( - &thread, "", Address(storage_addr, nullptr), return_compiler_type); + &thread, "", Address(storage_addr), return_compiler_type); } return return_valobj_sp; } diff --git a/lldb/source/Plugins/Architecture/Mips/ArchitectureMips.cpp b/lldb/source/Plugins/Architecture/Mips/ArchitectureMips.cpp index 3748be0533ad..bb838558269f 100644 --- a/lldb/source/Plugins/Architecture/Mips/ArchitectureMips.cpp +++ b/lldb/source/Plugins/Architecture/Mips/ArchitectureMips.cpp @@ -113,7 +113,7 @@ lldb::addr_t ArchitectureMips::GetBreakableLoadAddress(lldb::addr_t addr, if (current_offset == 0) return addr; - auto insn = GetInstructionAtAddress(target, current_offset, addr); + auto insn = GetInstructionAtAddress(target, Address(current_offset), addr); if (nullptr == insn || !insn->HasDelaySlot()) return addr; diff --git a/lldb/source/Plugins/DynamicLoader/FreeBSD-Kernel/DynamicLoaderFreeBSDKernel.cpp b/lldb/source/Plugins/DynamicLoader/FreeBSD-Kernel/DynamicLoaderFreeBSDKernel.cpp index a0b3a4d85c4e..00b1de6aee36 100644 --- a/lldb/source/Plugins/DynamicLoader/FreeBSD-Kernel/DynamicLoaderFreeBSDKernel.cpp +++ b/lldb/source/Plugins/DynamicLoader/FreeBSD-Kernel/DynamicLoaderFreeBSDKernel.cpp @@ -255,8 +255,6 @@ void DynamicLoaderFreeBSDKernel::DebuggerInit( DynamicLoaderFreeBSDKernel::DynamicLoaderFreeBSDKernel(Process *process, addr_t kernel_address) : DynamicLoader(process), m_process(process), - m_linker_file_list_struct_addr(LLDB_INVALID_ADDRESS), - m_linker_file_head_addr(LLDB_INVALID_ADDRESS), m_kernel_load_address(kernel_address), m_mutex() { process->SetCanRunCode(false); } diff --git a/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp b/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp index 2d010db96070..dc0e70a471ac 100644 --- a/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp +++ b/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp @@ -289,7 +289,7 @@ bool DynamicLoaderHexagonDYLD::SetRendezvousBreakpoint() { // Make sure our breakpoint is at the right address. assert(target.GetBreakpointByID(m_dyld_bid) - ->FindLocationByAddress(break_addr) + ->FindLocationByAddress(Address(break_addr)) ->GetBreakpoint() .GetID() == m_dyld_bid); diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp index 474d908810e0..afa0ef28a381 100644 --- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp +++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp @@ -1037,7 +1037,8 @@ DynamicLoaderDarwin::GetStepThroughTrampolinePlan(Thread &thread, current_symbol->GetName().GetCString(), actual_symbol->GetName().GetCString(), target_addr.GetLoadAddress(target_sp.get())); - addresses.push_back(target_addr.GetLoadAddress(target_sp.get())); + addresses.push_back( + Address(target_addr.GetLoadAddress(target_sp.get()))); } } } diff --git a/lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.cpp b/lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.cpp index b89a6aa17691..3b63ca219302 100644 --- a/lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.cpp +++ b/lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.cpp @@ -103,7 +103,7 @@ InstrumentationRuntimeMainThreadChecker::RetrieveReportData( std::string apiName; Status read_error; - target.ReadCStringFromMemory(apiname_ptr, apiName, read_error); + target.ReadCStringFromMemory(Address(apiname_ptr), apiName, read_error); if (read_error.Fail()) return StructuredData::ObjectSP(); diff --git a/lldb/source/Plugins/Language/ObjC/CFBasicHash.cpp b/lldb/source/Plugins/Language/ObjC/CFBasicHash.cpp index 42cda0146f2e..e434c68c7749 100644 --- a/lldb/source/Plugins/Language/ObjC/CFBasicHash.cpp +++ b/lldb/source/Plugins/Language/ObjC/CFBasicHash.cpp @@ -6,7 +6,7 @@ using namespace lldb; using namespace lldb_private; bool CFBasicHash::IsValid() const { - if (m_address != LLDB_INVALID_ADDRESS) { + if (m_address != Address()) { if (m_ptr_size == 4 && m_ht_32) return true; else if (m_ptr_size == 8 && m_ht_64) @@ -21,7 +21,7 @@ bool CFBasicHash::Update(addr_t addr, ExecutionContextRef exe_ctx_rf) { if (addr == LLDB_INVALID_ADDRESS || !addr) return false; - m_address = addr; + m_address = Address(addr); m_exe_ctx_ref = exe_ctx_rf; m_ptr_size = m_exe_ctx_ref.GetTargetSP()->GetArchitecture().GetAddressByteSize(); diff --git a/lldb/source/Plugins/Language/ObjC/CFBasicHash.h b/lldb/source/Plugins/Language/ObjC/CFBasicHash.h index f850c50342a3..a85a618094d4 100644 --- a/lldb/source/Plugins/Language/ObjC/CFBasicHash.h +++ b/lldb/source/Plugins/Language/ObjC/CFBasicHash.h @@ -62,7 +62,7 @@ private: uint32_t m_ptr_size = UINT32_MAX; lldb::ByteOrder m_byte_order = lldb::eByteOrderInvalid; - Address m_address = LLDB_INVALID_ADDRESS; + Address m_address; std::unique_ptr<__CFBasicHash> m_ht_32 = nullptr; std::unique_ptr<__CFBasicHash> m_ht_64 = nullptr; ExecutionContextRef m_exe_ctx_ref; diff --git a/lldb/source/Plugins/Language/ObjC/NSString.cpp b/lldb/source/Plugins/Language/ObjC/NSString.cpp index 2626b9a3f7b8..b7cc0062a9e6 100644 --- a/lldb/source/Plugins/Language/ObjC/NSString.cpp +++ b/lldb/source/Plugins/Language/ObjC/NSString.cpp @@ -145,7 +145,7 @@ bool lldb_private::formatters::NSStringSummaryProvider( if (error.Fail()) return false; if (has_explicit_length && is_unicode) { - options.SetLocation(location); + options.SetLocation(Address(location)); options.SetTargetSP(valobj.GetTargetSP()); options.SetStream(&stream); options.SetQuote('"'); @@ -158,7 +158,7 @@ bool lldb_private::formatters::NSStringSummaryProvider( return StringPrinter::ReadStringAndDumpToStream< StringPrinter::StringElementType::UTF16>(options); } else { - options.SetLocation(location + 1); + options.SetLocation(Address(location + 1)); options.SetTargetSP(valobj.GetTargetSP()); options.SetStream(&stream); options.SetSourceSize(explicit_length); @@ -174,7 +174,7 @@ bool lldb_private::formatters::NSStringSummaryProvider( !is_path_store && !is_mutable) { uint64_t location = 3 * ptr_size + valobj_addr; - options.SetLocation(location); + options.SetLocation(Address(location)); options.SetTargetSP(valobj.GetTargetSP()); options.SetStream(&stream); options.SetQuote('"'); @@ -196,7 +196,7 @@ bool lldb_private::formatters::NSStringSummaryProvider( if (error.Fail()) return false; } - options.SetLocation(location); + options.SetLocation(Address(location)); options.SetTargetSP(valobj.GetTargetSP()); options.SetStream(&stream); options.SetQuote('"'); @@ -222,7 +222,7 @@ bool lldb_private::formatters::NSStringSummaryProvider( explicit_length = length_valobj_sp->GetValueAsUnsigned(0) >> 20; lldb::addr_t location = valobj.GetValueAsUnsigned(0) + ptr_size + 4; - options.SetLocation(location); + options.SetLocation(Address(location)); options.SetTargetSP(valobj.GetTargetSP()); options.SetStream(&stream); options.SetQuote('"'); @@ -245,7 +245,7 @@ bool lldb_private::formatters::NSStringSummaryProvider( has_explicit_length = !(error.Fail() || explicit_length == 0); location++; } - options.SetLocation(location); + options.SetLocation(Address(location)); options.SetTargetSP(valobj.GetTargetSP()); options.SetStream(&stream); options.SetSourceSize(explicit_length); @@ -268,7 +268,7 @@ bool lldb_private::formatters::NSStringSummaryProvider( if (has_explicit_length && !has_null) explicit_length++; // account for the fact that there is no NULL and we // need to have one added - options.SetLocation(location); + options.SetLocation(Address(location)); options.SetTargetSP(valobj.GetTargetSP()); options.SetStream(&stream); options.SetSourceSize(explicit_length); diff --git a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABIRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABIRuntime.cpp index 797abd8b0aa1..9a76d94b4e7c 100644 --- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABIRuntime.cpp +++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABIRuntime.cpp @@ -307,7 +307,7 @@ bool ItaniumABIRuntime::GetDynamicTypeAndAddress( return false; Status error; const int64_t offset_to_top = target.ReadSignedIntegerFromMemory( - offset_to_top_location, addr_byte_size, INT64_MIN, error); + Address(offset_to_top_location), addr_byte_size, INT64_MIN, error); if (offset_to_top == INT64_MIN) return false; diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp index 565a12c4ff85..b1994f5e9463 100644 --- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -978,7 +978,8 @@ Address ObjectFileELF::GetImageInfoAddress(Target *target) { if (symbol.d_tag == DT_MIPS_RLD_MAP) { // DT_MIPS_RLD_MAP tag stores an absolute address of the debug pointer. Address addr; - if (target->ReadPointerFromMemory(d_load_addr, error, addr, true)) + if (target->ReadPointerFromMemory(Address(d_load_addr), error, addr, + true)) return addr; } if (symbol.d_tag == DT_MIPS_RLD_MAP_REL) { @@ -986,7 +987,8 @@ Address ObjectFileELF::GetImageInfoAddress(Target *target) { // relative to the address of the tag. uint64_t rel_offset; rel_offset = target->ReadUnsignedIntegerFromMemory( - d_load_addr, GetAddressByteSize(), UINT64_MAX, error, true); + Address(d_load_addr), GetAddressByteSize(), UINT64_MAX, error, + true); if (error.Success() && rel_offset != UINT64_MAX) { Address addr; addr_t debug_ptr_address = @@ -1025,7 +1027,7 @@ Address ObjectFileELF::GetBaseAddress() { if (header.sh_flags & SHF_ALLOC) return Address(GetSectionList()->FindSectionByID(SectionIndex(I)), 0); } - return LLDB_INVALID_ADDRESS; + return Address(); } for (const auto &EnumPHdr : llvm::enumerate(ProgramHeaders())) { @@ -1036,7 +1038,7 @@ Address ObjectFileELF::GetBaseAddress() { return Address( GetSectionList()->FindSectionByID(SegmentID(EnumPHdr.index())), 0); } - return LLDB_INVALID_ADDRESS; + return Address(); } size_t ObjectFileELF::ParseDependentModules() { diff --git a/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp b/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp index 2f6235ea5e76..09251e2f57e1 100644 --- a/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp +++ b/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp @@ -959,7 +959,8 @@ uint32_t SymbolFileCTF::ResolveSymbolContext(const Address &so_addr, // Resolve variables. if (resolve_scope & eSymbolContextVariable) { for (VariableSP variable_sp : m_variables) { - if (variable_sp->LocationIsValidForAddress(so_addr.GetFileAddress())) { + if (variable_sp->LocationIsValidForAddress( + Address(so_addr.GetFileAddress()))) { sc.variable = variable_sp.get(); break; } diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp index 1f225c4c70e2..3518a919c67d 100644 --- a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp +++ b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp @@ -1826,7 +1826,7 @@ void SymbolFileNativePDB::ParseInlineSite(PdbCompilandSymId id, S_INLINESITE) { // Its parent is another inline site, lookup parent site's range vector // for callsite line. - ParseInlineSite(parent_id, func_base); + ParseInlineSite(parent_id, Address(func_base)); std::shared_ptr parent_site = m_inline_sites[toOpaqueUid(parent_id)]; FileSpec &parent_decl_file = diff --git a/lldb/source/Symbol/SymbolContext.cpp b/lldb/source/Symbol/SymbolContext.cpp index 61991429c2a8..0d66a383075f 100644 --- a/lldb/source/Symbol/SymbolContext.cpp +++ b/lldb/source/Symbol/SymbolContext.cpp @@ -1113,7 +1113,7 @@ bool SymbolContextSpecifier::AddressMatches(lldb::addr_t addr) { if (m_type & eAddressRangeSpecified) { } else { - Address match_address(addr, nullptr); + Address match_address(addr); SymbolContext sc; m_target_sp->GetImages().ResolveSymbolContextForAddress( match_address, eSymbolContextEverything, sc); diff --git a/lldb/source/Target/StackFrame.cpp b/lldb/source/Target/StackFrame.cpp index 9fb26176e43c..d3403403ee5e 100644 --- a/lldb/source/Target/StackFrame.cpp +++ b/lldb/source/Target/StackFrame.cpp @@ -65,7 +65,7 @@ StackFrame::StackFrame(const ThreadSP &thread_sp, user_id_t frame_idx, : m_thread_wp(thread_sp), m_frame_index(frame_idx), m_concrete_frame_index(unwind_frame_index), m_reg_context_sp(), m_id(pc, cfa, nullptr, thread_sp->GetProcess().get()), - m_frame_code_addr(pc), m_sc(), m_flags(), m_frame_base(), + m_frame_code_addr(Address(pc)), m_sc(), m_flags(), m_frame_base(), m_frame_base_error(), m_cfa_is_valid(cfa_is_valid), m_stack_frame_kind(kind), m_artificial(artificial), m_behaves_like_zeroth_frame(behaves_like_zeroth_frame), @@ -93,7 +93,7 @@ StackFrame::StackFrame(const ThreadSP &thread_sp, user_id_t frame_idx, m_concrete_frame_index(unwind_frame_index), m_reg_context_sp(reg_context_sp), m_id(pc, cfa, nullptr, thread_sp->GetProcess().get()), - m_frame_code_addr(pc), m_sc(), m_flags(), m_frame_base(), + m_frame_code_addr(Address(pc)), m_sc(), m_flags(), m_frame_base(), m_frame_base_error(), m_cfa_is_valid(true), m_stack_frame_kind(StackFrame::Kind::Regular), m_artificial(false), m_behaves_like_zeroth_frame(behaves_like_zeroth_frame), diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index 126a2b57ed4b..250d3f337a7b 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -582,7 +582,7 @@ Target::CreateAddressInModuleBreakpoint(lldb::addr_t file_addr, bool internal, std::make_shared( shared_from_this()); BreakpointResolverSP resolver_sp = - std::make_shared(nullptr, file_addr, + std::make_shared(nullptr, Address(file_addr), file_spec); return CreateBreakpoint(filter_sp, resolver_sp, internal, request_hardware, false); diff --git a/lldb/source/ValueObject/ValueObjectDynamicValue.cpp b/lldb/source/ValueObject/ValueObjectDynamicValue.cpp index 4c2cf0738d05..cc16869b38f0 100644 --- a/lldb/source/ValueObject/ValueObjectDynamicValue.cpp +++ b/lldb/source/ValueObject/ValueObjectDynamicValue.cpp @@ -255,7 +255,7 @@ bool ValueObjectDynamicValue::UpdateValue() { } m_value.GetScalar() = (uint64_t)local_buffer.data(); - m_address = LLDB_INVALID_ADDRESS; + m_address = Address(); } else { // Otherwise we have a legitimate address on the target. Point to the load // address.