llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-lldb Author: Med Ismail Bennani (medismailben) <details> <summary>Changes</summary> --- Patch is 37.34 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/158811.diff 26 Files Affected: - (modified) lldb/include/lldb/Breakpoint/BreakpointLocation.h (+2-1) - (modified) lldb/include/lldb/Core/Address.h (+1-1) - (modified) lldb/include/lldb/Symbol/LineEntry.h (+17-3) - (modified) lldb/include/lldb/lldb-forward.h (+1-1) - (modified) lldb/source/API/SBLineEntry.cpp (+5-5) - (modified) lldb/source/API/SBThread.cpp (+9-4) - (modified) lldb/source/Breakpoint/BreakpointResolver.cpp (+16-6) - (modified) lldb/source/Commands/CommandObjectDisassemble.cpp (+2-2) - (modified) lldb/source/Commands/CommandObjectSource.cpp (+4-2) - (modified) lldb/source/Commands/CommandObjectTarget.cpp (+2-2) - (modified) lldb/source/Commands/CommandObjectThread.cpp (+2-2) - (modified) lldb/source/Core/AddressResolverFileLine.cpp (+2-2) - (modified) lldb/source/Core/FormatEntity.cpp (+8-7) - (modified) lldb/source/DataFormatters/TypeSummary.cpp (+2-2) - (modified) lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp (+1-1) - (modified) lldb/source/Symbol/CompileUnit.cpp (+10-6) - (modified) lldb/source/Symbol/Function.cpp (+9-8) - (modified) lldb/source/Symbol/LineEntry.cpp (+37-18) - (modified) lldb/source/Symbol/LineTable.cpp (+8-7) - (modified) lldb/source/Symbol/Symbol.cpp (+4-3) - (modified) lldb/source/Symbol/SymbolContext.cpp (+20-8) - (modified) lldb/source/Target/ThreadPlanShouldStopHere.cpp (+1-1) - (modified) lldb/source/Target/ThreadPlanStepOverRange.cpp (+2-2) - (modified) lldb/source/Target/ThreadPlanStepRange.cpp (+8-4) - (modified) lldb/tools/lldb-test/lldb-test.cpp (+8-3) - (modified) lldb/unittests/Symbol/LineTableTest.cpp (+8-3) ``````````diff diff --git a/lldb/include/lldb/Breakpoint/BreakpointLocation.h b/lldb/include/lldb/Breakpoint/BreakpointLocation.h index ab2e5e170559d..6a8d9ccfc8bc7 100644 --- a/lldb/include/lldb/Breakpoint/BreakpointLocation.h +++ b/lldb/include/lldb/Breakpoint/BreakpointLocation.h @@ -279,7 +279,8 @@ class BreakpointLocation /// The line entry must have the same start address as the address for this /// location. bool SetPreferredLineEntry(const LineEntry &line_entry) { - if (m_address == line_entry.range.GetBaseAddress()) { + if (line_entry.HasValidRange() && + m_address == line_entry.GetRange().GetBaseAddress()) { m_preferred_line_entry = line_entry; return true; } diff --git a/lldb/include/lldb/Core/Address.h b/lldb/include/lldb/Core/Address.h index 85b2ab7bb3cfe..a16cb55680a68 100644 --- a/lldb/include/lldb/Core/Address.h +++ b/lldb/include/lldb/Core/Address.h @@ -30,7 +30,7 @@ class Stream; class Symbol; class SymbolContext; class Target; -struct LineEntry; +class LineEntry; /// \class Address Address.h "lldb/Core/Address.h" /// A section + offset based address class. diff --git a/lldb/include/lldb/Symbol/LineEntry.h b/lldb/include/lldb/Symbol/LineEntry.h index 8da59cf0bd24a..755729a2a1442 100644 --- a/lldb/include/lldb/Symbol/LineEntry.h +++ b/lldb/include/lldb/Symbol/LineEntry.h @@ -13,12 +13,14 @@ #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/SupportFile.h" #include "lldb/lldb-private.h" +#include <optional> namespace lldb_private { /// \class LineEntry LineEntry.h "lldb/Symbol/LineEntry.h" /// A line table entry class. -struct LineEntry { +class LineEntry { +public: /// Default constructor. /// /// Initialize all member variables to invalid values. @@ -133,9 +135,21 @@ struct LineEntry { /// Helper to access the file. const FileSpec &GetFile() const { return file_sp->GetSpecOnly(); } - /// The section offset address range for this line entry. - AddressRange range; + /// Get the address range for this line entry. + /// \return The address range if valid, otherwise an invalid AddressRange. + const AddressRange &GetRange() const; + /// Check if this line entry has a valid address range. + bool HasValidRange() const; + + /// Set the address range for this line entry. + void SetRange(const AddressRange &range); + +private: + /// The section offset address range for this line entry (optional). + std::optional<AddressRange> m_range; + +public: /// The source file, possibly mapped by the target.source-map setting. lldb::SupportFileSP file_sp; diff --git a/lldb/include/lldb/lldb-forward.h b/lldb/include/lldb/lldb-forward.h index af5656b3dcad1..1dedfd0d644f7 100644 --- a/lldb/include/lldb/lldb-forward.h +++ b/lldb/include/lldb/lldb-forward.h @@ -306,7 +306,7 @@ class WatchpointResource; class WatchpointResourceCollection; class WatchpointSetOptions; struct CompilerContext; -struct LineEntry; +class LineEntry; struct PropertyDefinition; struct ScriptSummaryFormat; struct StatisticsOptions; diff --git a/lldb/source/API/SBLineEntry.cpp b/lldb/source/API/SBLineEntry.cpp index 0f4936f32a074..78ff488e8927f 100644 --- a/lldb/source/API/SBLineEntry.cpp +++ b/lldb/source/API/SBLineEntry.cpp @@ -50,8 +50,8 @@ SBAddress SBLineEntry::GetStartAddress() const { LLDB_INSTRUMENT_VA(this); SBAddress sb_address; - if (m_opaque_up) - sb_address.SetAddress(m_opaque_up->range.GetBaseAddress()); + if (m_opaque_up && m_opaque_up->HasValidRange()) + sb_address.SetAddress(m_opaque_up->GetRange().GetBaseAddress()); return sb_address; } @@ -60,9 +60,9 @@ SBAddress SBLineEntry::GetEndAddress() const { LLDB_INSTRUMENT_VA(this); SBAddress sb_address; - if (m_opaque_up) { - sb_address.SetAddress(m_opaque_up->range.GetBaseAddress()); - sb_address.OffsetAddress(m_opaque_up->range.GetByteSize()); + if (m_opaque_up && m_opaque_up->HasValidRange()) { + sb_address.SetAddress(m_opaque_up->GetRange().GetBaseAddress()); + sb_address.OffsetAddress(m_opaque_up->GetRange().GetByteSize()); } return sb_address; } diff --git a/lldb/source/API/SBThread.cpp b/lldb/source/API/SBThread.cpp index 4e4aa48bc9a2e..da240a84db48c 100644 --- a/lldb/source/API/SBThread.cpp +++ b/lldb/source/API/SBThread.cpp @@ -515,9 +515,14 @@ void SBThread::StepInto(const char *target_name, uint32_t end_line, if (frame_sp && frame_sp->HasDebugInformation()) { SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything)); AddressRange range; - if (end_line == LLDB_INVALID_LINE_NUMBER) - range = sc.line_entry.range; - else { + if (end_line == LLDB_INVALID_LINE_NUMBER) { + if (sc.line_entry.HasValidRange()) + range = sc.line_entry.GetRange(); + else { + error = Status::FromErrorString("No valid range for line entry"); + return; + } + } else { llvm::Error err = sc.GetAddressRangeFromHereToEndLine(end_line, range); if (err) { error = Status::FromErrorString(llvm::toString(std::move(err)).c_str()); @@ -787,7 +792,7 @@ SBError SBThread::StepOverUntil(lldb::SBFrame &sb_frame, eSymbolContextLineEntry, sc_list); for (const SymbolContext &sc : sc_list) { addr_t step_addr = - sc.line_entry.range.GetBaseAddress().GetLoadAddress(target); + sc.line_entry.GetRange().GetBaseAddress().GetLoadAddress(target); if (step_addr != LLDB_INVALID_ADDRESS) { AddressRange unused_range; if (frame_sc.function->GetRangeContainingLoadAddress(step_addr, *target, diff --git a/lldb/source/Breakpoint/BreakpointResolver.cpp b/lldb/source/Breakpoint/BreakpointResolver.cpp index 4ac40501a5df5..a91805156a63c 100644 --- a/lldb/source/Breakpoint/BreakpointResolver.cpp +++ b/lldb/source/Breakpoint/BreakpointResolver.cpp @@ -273,11 +273,19 @@ void BreakpointResolver::SetSCMatchesByLine( } // Sort by file address. - llvm::sort(worklist_begin, worklist_end, - [](const SymbolContext &a, const SymbolContext &b) { - return a.line_entry.range.GetBaseAddress().GetFileAddress() < - b.line_entry.range.GetBaseAddress().GetFileAddress(); - }); + llvm::sort( + worklist_begin, worklist_end, + [](const SymbolContext &a, const SymbolContext &b) { + auto a_addr = + a.line_entry.HasValidRange() + ? a.line_entry.GetRange().GetBaseAddress().GetFileAddress() + : LLDB_INVALID_ADDRESS; + auto b_addr = + b.line_entry.HasValidRange() + ? b.line_entry.GetRange().GetBaseAddress().GetFileAddress() + : LLDB_INVALID_ADDRESS; + return a_addr < b_addr; + }); // Go through and see if there are line table entries that are // contiguous, and if so keep only the first of the contiguous range. @@ -307,7 +315,9 @@ void BreakpointResolver::AddLocation(SearchFilter &filter, bool skip_prologue, llvm::StringRef log_ident) { Log *log = GetLog(LLDBLog::Breakpoints); - Address line_start = sc.line_entry.range.GetBaseAddress(); + Address line_start = sc.line_entry.HasValidRange() + ? sc.line_entry.GetRange().GetBaseAddress() + : Address(); if (!line_start.IsValid()) { LLDB_LOGF(log, "error: Unable to set breakpoint %s at file address " diff --git a/lldb/source/Commands/CommandObjectDisassemble.cpp b/lldb/source/Commands/CommandObjectDisassemble.cpp index c0553d2c6c8b2..5c32e985c78b8 100644 --- a/lldb/source/Commands/CommandObjectDisassemble.cpp +++ b/lldb/source/Commands/CommandObjectDisassemble.cpp @@ -356,8 +356,8 @@ CommandObjectDisassemble::GetCurrentLineRanges() { LineEntry pc_line_entry( frame->GetSymbolContext(eSymbolContextLineEntry).line_entry); - if (pc_line_entry.IsValid()) - return std::vector<AddressRange>{pc_line_entry.range}; + if (pc_line_entry.IsValid() && pc_line_entry.HasValidRange()) + return std::vector<AddressRange>{pc_line_entry.GetRange()}; // No line entry, so just disassemble around the current pc m_options.show_mixed = false; diff --git a/lldb/source/Commands/CommandObjectSource.cpp b/lldb/source/Commands/CommandObjectSource.cpp index 0b4599b16ef0d..fe38aa82ae5c0 100644 --- a/lldb/source/Commands/CommandObjectSource.cpp +++ b/lldb/source/Commands/CommandObjectSource.cpp @@ -1032,9 +1032,11 @@ class CommandObjectSourceList : public CommandObjectParsed { bool show_inlined_frames = true; const bool show_function_arguments = true; const bool show_function_name = true; + Address addr = sc.line_entry.HasValidRange() + ? sc.line_entry.GetRange().GetBaseAddress() + : Address(); sc.DumpStopContext(&result.GetOutputStream(), - m_exe_ctx.GetBestExecutionContextScope(), - sc.line_entry.range.GetBaseAddress(), + m_exe_ctx.GetBestExecutionContextScope(), addr, show_fullpaths, show_module, show_inlined_frames, show_function_arguments, show_function_name); result.GetOutputStream().EOL(); diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp index 0f96fa92a731d..43a6211a18a33 100644 --- a/lldb/source/Commands/CommandObjectTarget.cpp +++ b/lldb/source/Commands/CommandObjectTarget.cpp @@ -1628,8 +1628,8 @@ static void DumpSymbolContextList( strm.EOL(); Address addr; - if (sc.line_entry.IsValid()) - addr = sc.line_entry.range.GetBaseAddress(); + if (sc.line_entry.IsValid() && sc.line_entry.HasValidRange()) + addr = sc.line_entry.GetRange().GetBaseAddress(); else if (sc.block && sc.block->GetContainingInlinedBlock()) sc.block->GetContainingInlinedBlock()->GetStartAddress(addr); else diff --git a/lldb/source/Commands/CommandObjectThread.cpp b/lldb/source/Commands/CommandObjectThread.cpp index bbec714642ec9..9c9573cba9529 100644 --- a/lldb/source/Commands/CommandObjectThread.cpp +++ b/lldb/source/Commands/CommandObjectThread.cpp @@ -519,7 +519,7 @@ class CommandObjectThreadStepWithTypeAndScope : public CommandObjectParsed { block_range.GetByteSize() - pc_offset_in_block; range = AddressRange(pc_address, range_length); } else { - range = sc.line_entry.range; + range = sc.line_entry.GetRange(); } new_plan_sp = thread->QueueThreadPlanForStepInRange( @@ -999,7 +999,7 @@ class CommandObjectThreadUntil : public CommandObjectParsed { while (idx < end_func_idx) { if (line_idx_ranges.FindEntryIndexThatContains(idx) != UINT32_MAX) { addr_t address = - line_entry.range.GetBaseAddress().GetLoadAddress(target); + line_entry.GetRange().GetBaseAddress().GetLoadAddress(target); if (address != LLDB_INVALID_ADDRESS) address_list.push_back(address); } diff --git a/lldb/source/Core/AddressResolverFileLine.cpp b/lldb/source/Core/AddressResolverFileLine.cpp index 6ab3b8fcee154..be2f3aa4bebbe 100644 --- a/lldb/source/Core/AddressResolverFileLine.cpp +++ b/lldb/source/Core/AddressResolverFileLine.cpp @@ -46,8 +46,8 @@ AddressResolverFileLine::SearchCallback(SearchFilter &filter, cu->ResolveSymbolContext(m_src_location_spec, eSymbolContextEverything, sc_list); for (const SymbolContext &sc : sc_list) { - Address line_start = sc.line_entry.range.GetBaseAddress(); - addr_t byte_size = sc.line_entry.range.GetByteSize(); + Address line_start = sc.line_entry.GetRange().GetBaseAddress(); + addr_t byte_size = sc.line_entry.GetRange().GetByteSize(); if (line_start.IsValid()) { AddressRange new_range(line_start, byte_size); m_address_ranges.push_back(new_range); diff --git a/lldb/source/Core/FormatEntity.cpp b/lldb/source/Core/FormatEntity.cpp index 491f5c6320d97..2548dfd1620fd 100644 --- a/lldb/source/Core/FormatEntity.cpp +++ b/lldb/source/Core/FormatEntity.cpp @@ -1918,10 +1918,11 @@ bool FormatEntity::Format(const Entry &entry, Stream &s, return false; case Entry::Type::FunctionLineOffset: - if (sc) - return (DumpAddressOffsetFromFunction( - s, sc, exe_ctx, sc->line_entry.range.GetBaseAddress(), false, false, - false)); + if (sc) { + Address line_addr = sc->line_entry.GetRange().GetBaseAddress(); + return (DumpAddressOffsetFromFunction(s, sc, exe_ctx, line_addr, false, + false, false)); + } return false; case Entry::Type::FunctionPCOffset: @@ -1986,11 +1987,11 @@ bool FormatEntity::Format(const Entry &entry, Stream &s, case Entry::Type::LineEntryStartAddress: case Entry::Type::LineEntryEndAddress: - if (sc && sc->line_entry.range.GetBaseAddress().IsValid()) { - Address addr = sc->line_entry.range.GetBaseAddress(); + if (sc && sc->line_entry.HasValidRange()) { + Address addr = sc->line_entry.GetRange().GetBaseAddress(); if (entry.type == Entry::Type::LineEntryEndAddress) - addr.Slide(sc->line_entry.range.GetByteSize()); + addr.Slide(sc->line_entry.GetRange().GetByteSize()); if (DumpAddressAndContent(s, sc, exe_ctx, addr, false)) return true; } diff --git a/lldb/source/DataFormatters/TypeSummary.cpp b/lldb/source/DataFormatters/TypeSummary.cpp index 6aa290698cd12..489d6c43f5092 100644 --- a/lldb/source/DataFormatters/TypeSummary.cpp +++ b/lldb/source/DataFormatters/TypeSummary.cpp @@ -105,8 +105,8 @@ bool StringSummaryFormat::FormatObject(ValueObject *valobj, std::string &retval, retval = std::string(s.GetString()); return true; } else { - if (FormatEntity::Format(m_format, s, &sc, &exe_ctx, - &sc.line_entry.range.GetBaseAddress(), valobj, + Address temp_addr = sc.line_entry.GetRange().GetBaseAddress(); + if (FormatEntity::Format(m_format, s, &sc, &exe_ctx, &temp_addr, valobj, false, false)) { retval.assign(std::string(s.GetString())); return true; diff --git a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp index 0e2ca1784e7e9..58d0c7f309784 100644 --- a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp +++ b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp @@ -947,7 +947,7 @@ uint32_t SymbolFilePDB::ResolveSymbolContext( continue; auto file_vm_addr = - sc.line_entry.range.GetBaseAddress().GetFileAddress(); + sc.line_entry.GetRange().GetBaseAddress().GetFileAddress(); if (file_vm_addr == LLDB_INVALID_ADDRESS || file_vm_addr == 0) continue; diff --git a/lldb/source/Symbol/CompileUnit.cpp b/lldb/source/Symbol/CompileUnit.cpp index 166f111ef6220..64e4e29d99c6b 100644 --- a/lldb/source/Symbol/CompileUnit.cpp +++ b/lldb/source/Symbol/CompileUnit.cpp @@ -335,7 +335,7 @@ void CompileUnit::ResolveSymbolContext( // line entry will be the in function that contained the line that might // be a CallSite, and we can just iterate over that function to find any // inline records, and dig up their call sites. - Address start_addr = line_entry.range.GetBaseAddress(); + Address start_addr = line_entry.GetRange().GetBaseAddress(); Function *function = start_addr.CalculateSymbolContextFunction(); // Record the size of the list to see if we added to it: size_t old_sc_list_size = sc_list.GetSize(); @@ -390,8 +390,9 @@ void CompileUnit::ResolveSymbolContext( *src_location_spec.GetColumn() == call_site_line.column)) matches_spec = true; } - if (matches_spec && - sibling_block->GetRangeAtIndex(0, call_site_line.range)) { + AddressRange range; + if (matches_spec && sibling_block->GetRangeAtIndex(0, range)) { + call_site_line.SetRange(range); SymbolContext call_site_sc(sc.target_sp, sc.module_sp, sc.comp_unit, sc.function, sc.block, &call_site_line, sc.symbol); @@ -446,8 +447,9 @@ void CompileUnit::ResolveSymbolContext( if (resolve_scope == eSymbolContextLineEntry) { sc_list.Append(sc); } else { - line_entry.range.GetBaseAddress().CalculateSymbolContext(&resolved_sc, - resolve_scope); + if (line_entry.HasValidRange()) + line_entry.GetRange().GetBaseAddress().CalculateSymbolContext( + &resolved_sc, resolve_scope); // Sometimes debug info is bad and isn't able to resolve the line entry's // address back to the same compile unit and/or line entry. If the compile // unit changed, then revert back to just the compile unit and line entry. @@ -474,7 +476,9 @@ void CompileUnit::ResolveSymbolContext( "unable to resolve a line table file address {0:x16} back " "to a compile unit, please file a bug and attach the address " "and file.", - line_entry.range.GetBaseAddress().GetFileAddress()); + line_entry.HasValidRange() + ? line_entry.GetRange().GetBaseAddress().GetFileAddress() + : 0); } sc_list.Append(sc); } diff --git a/lldb/source/Symbol/Function.cpp b/lldb/source/Symbol/Function.cpp index 6114eccd935ee..39e85a10665d0 100644 --- a/lldb/source/Symbol/Function.cpp +++ b/lldb/source/Symbol/Function.cpp @@ -593,7 +593,7 @@ uint32_t Function::GetPrologueByteSize() { if (first_line_entry.is_prologue_end) { prologue_end_file_addr = - first_line_entry.range.GetBaseAddress().GetFileAddress(); + first_line_entry.GetRange().GetBaseAddress().GetFileAddress(); prologue_end_line_idx = first_line_entry_idx; } else { // Check the first few instructions and look for one that has @@ -605,7 +605,7 @@ uint32_t Function::GetPrologueByteSize() { if (line_table->GetLineEntryAtIndex(idx, line_entry)) { if (line_entry.is_prologue_end) { prologue_end_file_addr = - line_entry.range.GetBaseAddress().GetFileAddress(); + line_entry.GetRange().GetBaseAddress().GetFileAddress(); prologue_end_line_idx = idx; break; } @@ -625,7 +625,7 @@ uint32_t Function::GetPrologueByteSize() { if (line_table->GetLineEntryAtIndex(idx, line_entry)) { if (line_entry.line != first_line_entry.line) { prologue_end_file_addr = - line_entry.range.GetBaseAddress().GetFileAddress(); + line_entry.GetRange().GetBaseAddress().GetFileAddress(); prologue_end_line_idx = idx; break; } @@ -634,8 +634,8 @@ uint32_t Function::GetPrologueByteSize() { if (prologue_end_file_addr == LLDB_INVALID_ADDRESS) { prologue_end_file_addr = - first_line_entry.range.GetBaseAddress().GetFileAddress() + - first_line_entry.range.GetByteSize(); + first_line_entry.GetRange().GetBaseAddress().GetFileAddress() + + first_line_entry.GetRange().GetByteSize(); prologue_end_line_idx = first_line_entry_idx; } } @@ -659,7 +659,7 @@ uint32_t Function::GetPrologueByteSize() { if (line_entry.line != 0) break; } - if (line_entry.range.GetBaseAddress().GetFileAddress() >= + if (line_entry.GetRange().GetBaseAddress().GetFileAddress() >= range_end_file_addr) break; @@ -670,8 +670,9 @@ uint32_t Function::GetPrologueByteSize() { LineEntry first_non_zero_entry; if (line_table->GetLineEntryAtIndex(first_non_zero_line, ... [truncated] `````````` </details> https://github.com/llvm/llvm-project/pull/158811 _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
