https://github.com/satyajanga updated https://github.com/llvm/llvm-project/pull/217932
>From 9bcc4d7455196fea6f030854b70be14ba3eb3360 Mon Sep 17 00:00:00 2001 From: satya janga <[email protected]> Date: Fri, 21 Aug 2026 13:55:59 -0700 Subject: [PATCH 1/2] [lldb] Prefer readers with detailed debug information Rank symbol-file readers that provide line tables, blocks, local variables, or types ahead of readers that provide only information obtainable from an object symbol table. Preserve the existing ability-mask ordering within each category. --- lldb/include/lldb/Symbol/SymbolFile.h | 7 +++++-- lldb/source/Symbol/SymbolFile.cpp | 13 +++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/lldb/include/lldb/Symbol/SymbolFile.h b/lldb/include/lldb/Symbol/SymbolFile.h index ae6504c016d7b..0ec2e10cfeaa0 100644 --- a/lldb/include/lldb/Symbol/SymbolFile.h +++ b/lldb/include/lldb/Symbol/SymbolFile.h @@ -95,8 +95,11 @@ class SymbolFile : public PluginInterface { /// trying to figure out which symbol file plug-in will get used /// for a given object file. The plug-in that responds with the /// best mix of "SymbolFile::Abilities" bits set, will get chosen to - /// be the symbol file parser. This allows each plug-in to check for - /// sections that contain data a symbol file plug-in would need. For + /// be the symbol file parser. Plug-ins that provide detailed debug + /// information such as line tables, blocks, local variables, or types are + /// preferred over plug-ins that provide only information obtainable from an + /// object file's symbol table. This allows each plug-in to check for sections + /// that contain data a symbol file plug-in would need. For /// example the DWARF plug-in requires DWARF sections in a file that /// contain debug information. If the DWARF plug-in doesn't find /// these sections, it won't respond with many ability bits set, and diff --git a/lldb/source/Symbol/SymbolFile.cpp b/lldb/source/Symbol/SymbolFile.cpp index 0ef139b1d453a..5b1b2094bca1d 100644 --- a/lldb/source/Symbol/SymbolFile.cpp +++ b/lldb/source/Symbol/SymbolFile.cpp @@ -23,6 +23,7 @@ #include "lldb/lldb-private.h" #include <future> +#include <utility> using namespace lldb_private; using namespace lldb; @@ -30,6 +31,13 @@ using namespace lldb; char SymbolFile::ID; char SymbolFileCommon::ID; +static std::pair<bool, uint32_t> GetSymbolFileRank(uint32_t abilities) { + constexpr uint32_t detailed_info = + SymbolFile::LineTables | SymbolFile::Blocks | SymbolFile::LocalVariables | + SymbolFile::VariableTypes; + return {static_cast<bool>(abilities & detailed_info), abilities}; +} + void SymbolFile::PreloadSymbols() { // No-op for most implementations. } @@ -65,9 +73,10 @@ SymbolFile *SymbolFile::FindPlugin(ObjectFileSP objfile_sp) { if (curr_symfile_up) { const uint32_t sym_file_abilities = curr_symfile_up->GetAbilities(); - if (sym_file_abilities > best_symfile_abilities) { + if (GetSymbolFileRank(sym_file_abilities) > + GetSymbolFileRank(best_symfile_abilities)) { best_symfile_abilities = sym_file_abilities; - best_symfile_up.reset(curr_symfile_up.release()); + best_symfile_up = std::move(curr_symfile_up); // If any symbol file parser has all of the abilities, then we should // just stop looking. if ((kAllAbilities & sym_file_abilities) == kAllAbilities) >From 1d834b58b7189fe1b0c1677bd088ed56fd7b06dc Mon Sep 17 00:00:00 2001 From: satya janga <[email protected]> Date: Fri, 21 Aug 2026 13:56:04 -0700 Subject: [PATCH 2/2] [lldb][DWARF] Support standalone line tables Parse valid .debug_line contributions when .debug_info is absent and create LLDB CompileUnit objects without synthesizing DWARFUnit objects. Build support files, line tables, and address ranges directly from the parsed contributions. Add an SBAPI regression test for a DWARF v2 line-only object and focused coverage for malformed and padded line tables. --- .../SymbolFile/DWARF/SymbolFileDWARF.cpp | 231 +++++++++++++++--- .../SymbolFile/DWARF/SymbolFileDWARF.h | 6 + .../TestStandaloneDebugLine.py | 63 +++++ .../standalone-debug-line/main.s | 14 ++ .../DWARF/x86/standalone-debug-line.s | 160 ++++++++++++ 5 files changed, 442 insertions(+), 32 deletions(-) create mode 100644 lldb/test/API/python_api/symbol-context/standalone-debug-line/TestStandaloneDebugLine.py create mode 100644 lldb/test/API/python_api/symbol-context/standalone-debug-line/main.s create mode 100644 lldb/test/Shell/SymbolFile/DWARF/x86/standalone-debug-line.s diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index 81cd4444161f7..8efeed27bcf86 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -308,6 +308,68 @@ static void ParseSupportFilesFromPrologue( } } +struct lldb_private::plugin::dwarf::StandaloneDWARFLineTableInfo { + std::vector<llvm::DWARFDebugLine::LineTable> line_tables; + llvm::once_flag aranges_once_flag; + DWARFDebugAranges aranges; + + const llvm::DWARFDebugLine::LineTable *GetLineTable(uint32_t cu_idx) const; + + const DWARFDebugAranges &GetAranges(lldb::addr_t first_code_address); +}; + +static std::unique_ptr<LineTable> +ConvertLineTable(CompileUnit &comp_unit, + const llvm::DWARFDebugLine::LineTable &line_table, + lldb::addr_t first_code_address) { + // FIXME: Rather than parsing the whole line table and then copying it over + // into LLDB, we should explore using a callback to populate the line table + // while we parse to reduce memory usage. + std::vector<LineTable::Sequence> sequences; + // The Sequences view contains only valid line sequences. Don't iterate over + // the Rows directly. + for (const llvm::DWARFDebugLine::Sequence &seq : line_table.Sequences) { + // Ignore line sequences that do not start after the first code address. + // All addresses generated in a sequence are incremental so we only need + // to check the first one of the sequence. + if (seq.LowPC < first_code_address) + continue; + LineTable::Sequence sequence; + for (unsigned idx = seq.FirstRowIndex; idx < seq.LastRowIndex; ++idx) { + const llvm::DWARFDebugLine::Row &row = line_table.Rows[idx]; + LineTable::AppendLineEntryToSequence( + sequence, row.Address.Address, row.Line, row.Column, row.File, + row.IsStmt, row.BasicBlock, row.PrologueEnd, row.EpilogueBegin, + row.EndSequence); + } + sequences.push_back(std::move(sequence)); + } + + return std::make_unique<LineTable>(&comp_unit, std::move(sequences)); +} + +const llvm::DWARFDebugLine::LineTable * +StandaloneDWARFLineTableInfo::GetLineTable(uint32_t cu_idx) const { + if (cu_idx >= line_tables.size()) + return nullptr; + return &line_tables[cu_idx]; +} + +const DWARFDebugAranges & +StandaloneDWARFLineTableInfo::GetAranges(lldb::addr_t first_code_address) { + llvm::call_once(aranges_once_flag, [&] { + for (uint32_t cu_idx = 0; cu_idx < line_tables.size(); ++cu_idx) { + for (const llvm::DWARFDebugLine::Sequence &seq : + line_tables[cu_idx].Sequences) { + if (seq.isValid() && seq.LowPC >= first_code_address) + aranges.AppendRange(cu_idx, seq.LowPC, seq.HighPC); + } + } + aranges.Sort(/*minimize=*/true); + }); + return aranges; +} + void SymbolFileDWARF::Initialize() { LogChannelDWARF::Initialize(); PluginManager::RegisterPlugin(GetPluginNameStatic(), @@ -628,6 +690,11 @@ uint32_t SymbolFileDWARF::CalculateAbilities() { if (section) section_list = §ion->GetChildren(); + section = + section_list->FindSectionByType(eSectionTypeDWARFDebugLine, true).get(); + if (section) + debug_line_file_size = section->GetFileSize(); + section = section_list->FindSectionByType(eSectionTypeDWARFDebugInfo, true).get(); if (section != nullptr) { @@ -651,11 +718,6 @@ uint32_t SymbolFileDWARF::CalculateAbilities() { return 0; } - section = - section_list->FindSectionByType(eSectionTypeDWARFDebugLine, true) - .get(); - if (section) - debug_line_file_size = section->GetFileSize(); } else { llvm::StringRef symfile_dir = m_objfile_sp->GetFileSpec().GetDirectory(); if (symfile_dir.contains_insensitive(".dsym")) { @@ -688,8 +750,13 @@ uint32_t SymbolFileDWARF::CalculateAbilities() { abilities |= CompileUnits | Functions | Blocks | GlobalVariables | LocalVariables | VariableTypes; - if (debug_line_file_size > 0) + if (debug_line_file_size > 0 && (abilities & CompileUnits)) abilities |= LineTables; + else if (debug_line_file_size > 0 && + !GetStandaloneLineTableInfo().line_tables.empty()) + // A standalone line table still supplies enough information to create + // compile units, even though there are no DIEs backing them. + abilities |= CompileUnits | LineTables; } return abilities; } @@ -741,9 +808,59 @@ DWARFDebugInfo &SymbolFileDWARF::DebugInfo() { return *m_info; } +StandaloneDWARFLineTableInfo &SymbolFileDWARF::GetStandaloneLineTableInfo() { + llvm::call_once(m_standalone_line_table_once_flag, [&] { + auto info = std::make_unique<StandaloneDWARFLineTableInfo>(); + + // A DWARFUnit implies the presence of .debug_info. Standalone line tables + // deliberately bypass DWARFUnit creation and directly synthesize LLDB + // compile units instead. + if (m_context.getOrLoadDebugInfoData().GetByteSize() != 0) { + m_standalone_line_table_info = std::move(info); + return; + } + + llvm::DWARFDataExtractor line_data = + m_context.getOrLoadLineData().GetAsLLVMDWARF(); + if (line_data.getData().empty()) { + m_standalone_line_table_info = std::move(info); + return; + } + + llvm::DWARFContext &context = m_context.GetAsLLVM(); + llvm::DWARFDebugLine::SectionParser parser(line_data, context, + context.normal_units()); + Log *log = GetLog(DWARFLog::DebugInfo); + while (!parser.done()) { + bool valid = true; + auto recoverable = [&](llvm::Error error) { + LLDB_LOG_ERROR(log, std::move(error), + "SymbolFileDWARF failed to parse standalone line " + "table: {0}"); + }; + auto unrecoverable = [&](llvm::Error error) { + valid = false; + LLDB_LOG_ERROR(log, std::move(error), + "SymbolFileDWARF failed to parse standalone line " + "table: {0}"); + }; + llvm::DWARFDebugLine::LineTable line_table = + parser.parseNext(recoverable, unrecoverable); + if (valid && SupportedVersion(line_table.Prologue.getVersion()) && + !line_table.Prologue.FileNames.empty()) + info->line_tables.push_back(std::move(line_table)); + } + m_standalone_line_table_info = std::move(info); + }); + return *m_standalone_line_table_info; +} + DWARFCompileUnit *SymbolFileDWARF::GetDWARFCompileUnit(CompileUnit *comp_unit) { if (!comp_unit) return nullptr; + if (m_standalone_line_table_info && + comp_unit->GetUserData() == m_standalone_line_table_info.get()) + return nullptr; // The compile unit ID is the index of the DWARF unit. DWARFUnit *dwarf_cu = DebugInfo().GetUnitAtIndex(comp_unit->GetID()); @@ -888,6 +1005,12 @@ std::optional<uint32_t> SymbolFileDWARF::GetDWARFUnitIndex(uint32_t cu_idx) { } uint32_t SymbolFileDWARF::CalculateNumCompileUnits() { + if (!GetDebugMapSymfile()) { + StandaloneDWARFLineTableInfo &standalone = GetStandaloneLineTableInfo(); + if (!standalone.line_tables.empty()) + return standalone.line_tables.size(); + } + BuildCuTranslationTable(); return m_lldb_cu_to_dwarf_unit.empty() ? DebugInfo().GetNumUnits() : m_lldb_cu_to_dwarf_unit.size(); @@ -895,6 +1018,33 @@ uint32_t SymbolFileDWARF::CalculateNumCompileUnits() { CompUnitSP SymbolFileDWARF::ParseCompileUnitAtIndex(uint32_t cu_idx) { ASSERT_MODULE_LOCK(this); + StandaloneDWARFLineTableInfo &info = GetStandaloneLineTableInfo(); + const llvm::DWARFDebugLine::LineTable *line_table = + GetDebugMapSymfile() ? nullptr : info.GetLineTable(cu_idx); + if (line_table) { + SupportFileList support_files; + ParseSupportFilesFromPrologue(support_files, m_objfile_sp->GetModule(), + line_table->Prologue, + m_objfile_sp->GetFileSpec().GetPathStyle()); + + // DWARF v5 guarantees that file index zero names the primary source file. + // Earlier versions are one-based and have no explicit primary-file field; + // use the first file in the table as the best available fallback. + const size_t primary_file_idx = + line_table->Prologue.getVersion() < 5 ? 1 : 0; + SupportFileNSP primary_file = + support_files.GetSupportFileAtIndex(primary_file_idx); + + ModuleSP module_sp = m_objfile_sp->GetModule(); + if (!module_sp) + return {}; + CompUnitSP cu_sp = std::make_shared<CompileUnit>( + module_sp, m_standalone_line_table_info.get(), primary_file, cu_idx, + eLanguageTypeUnknown, eLazyBoolNo, std::move(support_files)); + SetCompileUnitAtIndex(cu_idx, cu_sp); + return cu_sp; + } + if (std::optional<uint32_t> dwarf_idx = GetDWARFUnitIndex(cu_idx)) { if (auto *dwarf_cu = llvm::cast_or_null<DWARFCompileUnit>( DebugInfo().GetUnitAtIndex(*dwarf_idx))) @@ -1239,6 +1389,20 @@ bool SymbolFileDWARF::ParseLineTable(CompileUnit &comp_unit) { if (comp_unit.GetLineTable() != nullptr) return true; + if (m_standalone_line_table_info && + comp_unit.GetUserData() == m_standalone_line_table_info.get()) { + const llvm::DWARFDebugLine::LineTable *line_table = + m_standalone_line_table_info->GetLineTable(comp_unit.GetID()); + if (!line_table) + return false; + if (m_first_code_address == LLDB_INVALID_ADDRESS) + InitializeFirstCodeAddress(); + comp_unit.SetLineTable( + ConvertLineTable(comp_unit, *line_table, m_first_code_address) + .release()); + return true; + } + DWARFUnit *dwarf_cu = GetDWARFCompileUnit(&comp_unit); if (!dwarf_cu) return false; @@ -1255,32 +1419,8 @@ bool SymbolFileDWARF::ParseLineTable(CompileUnit &comp_unit) { if (!line_table) return false; - // FIXME: Rather than parsing the whole line table and then copying it over - // into LLDB, we should explore using a callback to populate the line table - // while we parse to reduce memory usage. - std::vector<LineTable::Sequence> sequences; - // The Sequences view contains only valid line sequences. Don't iterate over - // the Rows directly. - for (const llvm::DWARFDebugLine::Sequence &seq : line_table->Sequences) { - // Ignore line sequences that do not start after the first code address. - // All addresses generated in a sequence are incremental so we only need - // to check the first one of the sequence. Check the comment at the - // m_first_code_address declaration for more details on this. - if (seq.LowPC < m_first_code_address) - continue; - LineTable::Sequence sequence; - for (unsigned idx = seq.FirstRowIndex; idx < seq.LastRowIndex; ++idx) { - const llvm::DWARFDebugLine::Row &row = line_table->Rows[idx]; - LineTable::AppendLineEntryToSequence( - sequence, row.Address.Address, row.Line, row.Column, row.File, - row.IsStmt, row.BasicBlock, row.PrologueEnd, row.EpilogueBegin, - row.EndSequence); - } - sequences.push_back(std::move(sequence)); - } - std::unique_ptr<LineTable> line_table_up = - std::make_unique<LineTable>(&comp_unit, std::move(sequences)); + ConvertLineTable(comp_unit, *line_table, m_first_code_address); if (SymbolFileDWARFDebugMap *debug_map_symfile = GetDebugMapSymfile()) { // We have an object file that has a line table with addresses that are not @@ -2151,6 +2291,33 @@ uint32_t SymbolFileDWARF::ResolveSymbolContext(const Address &so_addr, eSymbolContextLineEntry | eSymbolContextVariable)) { lldb::addr_t file_vm_addr = so_addr.GetFileAddress(); + StandaloneDWARFLineTableInfo &standalone = GetStandaloneLineTableInfo(); + if (!GetDebugMapSymfile() && !standalone.line_tables.empty()) { + if (m_first_code_address == LLDB_INVALID_ADDRESS) + InitializeFirstCodeAddress(); + const DWARFDebugAranges &aranges = + standalone.GetAranges(m_first_code_address); + const dw_offset_t cu_idx = aranges.FindAddress(file_vm_addr); + if (cu_idx == DW_INVALID_OFFSET) + return 0; + + CompUnitSP cu_sp = GetCompileUnitAtIndex(cu_idx); + sc.comp_unit = cu_sp.get(); + if (!sc.comp_unit) + return 0; + resolved |= eSymbolContextCompUnit; + + if (resolve_scope & eSymbolContextLineEntry) { + if (LineTable *line_table = sc.comp_unit->GetLineTable()) { + Address exe_so_addr(so_addr); + if (FixupAddress(exe_so_addr) && + line_table->FindLineEntryByAddress(exe_so_addr, sc.line_entry)) + resolved |= eSymbolContextLineEntry; + } + } + return resolved; + } + DWARFDebugInfo &debug_info = DebugInfo(); const DWARFDebugAranges &aranges = debug_info.GetCompileUnitAranges(); const dw_offset_t cu_offset = aranges.FindAddress(file_vm_addr); @@ -2251,7 +2418,7 @@ uint32_t SymbolFileDWARF::ResolveSymbolContext( if (resolve_scope & eSymbolContextCompUnit) { for (uint32_t cu_idx = 0, num_cus = GetNumCompileUnits(); cu_idx < num_cus; ++cu_idx) { - CompileUnit *dc_cu = ParseCompileUnitAtIndex(cu_idx).get(); + CompileUnit *dc_cu = GetCompileUnitAtIndex(cu_idx).get(); if (!dc_cu) continue; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h index 9879fc4fe922c..a1f539e0fd890 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h @@ -60,6 +60,7 @@ class DWARFTypeUnit; class SymbolFileDWARFDebugMap; class SymbolFileDWARFDwo; class SymbolFileDWARFDwp; +struct StandaloneDWARFLineTableInfo; #define DIE_IS_BEING_PARSED ((lldb_private::Type *)1) @@ -516,6 +517,8 @@ class SymbolFileDWARF : public SymbolFileCommon { void BuildCuTranslationTable(); std::optional<uint32_t> GetDWARFUnitIndex(uint32_t cu_idx); + StandaloneDWARFLineTableInfo &GetStandaloneLineTableInfo(); + void FindDwpSymbolFile(); const SupportFileList *GetTypeUnitSupportFiles(DWARFTypeUnit &tu); @@ -538,6 +541,9 @@ class SymbolFileDWARF : public SymbolFileCommon { llvm::once_flag m_info_once_flag; std::unique_ptr<DWARFDebugInfo> m_info; + llvm::once_flag m_standalone_line_table_once_flag; + std::unique_ptr<StandaloneDWARFLineTableInfo> m_standalone_line_table_info; + std::unique_ptr<llvm::DWARFDebugAbbrev> m_abbr; std::unique_ptr<GlobalVariableMap> m_global_aranges_up; diff --git a/lldb/test/API/python_api/symbol-context/standalone-debug-line/TestStandaloneDebugLine.py b/lldb/test/API/python_api/symbol-context/standalone-debug-line/TestStandaloneDebugLine.py new file mode 100644 index 0000000000000..13d6db338b019 --- /dev/null +++ b/lldb/test/API/python_api/symbol-context/standalone-debug-line/TestStandaloneDebugLine.py @@ -0,0 +1,63 @@ +import os + +import lldb +from lldbsuite.test import configuration +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * + + +class StandaloneDebugLineTestCase(TestBase): + NO_DEBUG_INFO_TESTCASE = True + + @skipUnlessPlatform(["linux"]) + @skipIfLLVMTargetMissing("X86") + def test(self): + object_path = self.getBuildArtifact("line.o") + self.runBuildCommand( + [ + os.path.join(configuration.llvm_tools_dir, "llvm-mc"), + "-triple=x86_64-pc-linux", + "-filetype=obj", + "-dwarf-version=2", + self.getSourcePath("main.s"), + "-o", + object_path, + ] + ) + + target = self.createTestTarget(object_path) + + # The regular symbol table advertises functions, while the standalone + # line table must make SymbolFileDWARF the preferred reader. + module = target.GetModuleAtIndex(0) + self.assertTrue(module.FindSection(".debug_line").IsValid()) + self.assertFalse(module.FindSection(".debug_info").IsValid()) + self.assertFalse(module.FindSection(".debug_abbrev").IsValid()) + self.assertTrue(module.FindSection(".symtab").IsValid()) + self.assertEqual(module.GetNumCompileUnits(), 1) + + # An address must resolve to its symbol, synthetic compile unit, and + # line entry. It must not manufacture a DWARF function. + symbol = module.FindSymbol("foo", lldb.eSymbolTypeCode) + self.assertTrue(symbol.IsValid()) + + address = symbol.GetStartAddress() + self.assertTrue(address.IsValid()) + self.assertEqual(address.GetSymbol().GetName(), "foo") + self.assertFalse(address.GetFunction().IsValid()) + + compile_unit = address.GetCompileUnit() + self.assertTrue(compile_unit.IsValid()) + self.assertEqual(compile_unit.GetFileSpec().GetFilename(), "standalone.c") + + line_entry = address.GetLineEntry() + self.assertTrue(line_entry.IsValid()) + self.assertEqual(line_entry.GetFileSpec().GetFilename(), "standalone.c") + self.assertEqual(line_entry.GetLine(), 42) + self.assertEqual(line_entry.GetColumn(), 7) + + # Source-to-address lookup must use the same standalone line table. + breakpoint = target.BreakpointCreateByLocation("standalone.c", 42) + self.assertEqual(breakpoint.GetNumLocations(), 1) + breakpoint_address = breakpoint.GetLocationAtIndex(0).GetAddress() + self.assertEqual(breakpoint_address, address) diff --git a/lldb/test/API/python_api/symbol-context/standalone-debug-line/main.s b/lldb/test/API/python_api/symbol-context/standalone-debug-line/main.s new file mode 100644 index 0000000000000..e35bbabdbf7be --- /dev/null +++ b/lldb/test/API/python_api/symbol-context/standalone-debug-line/main.s @@ -0,0 +1,14 @@ +# This file deliberately has a line table and symbols, but no debug-info DIEs. + .file 1 "/tmp/standalone.c" + + .text + .globl foo + .type foo,@function +foo: + .loc 1 42 7 + nop + .loc 1 43 3 + nop + retq +.Lfoo_end: + .size foo, .Lfoo_end-foo diff --git a/lldb/test/Shell/SymbolFile/DWARF/x86/standalone-debug-line.s b/lldb/test/Shell/SymbolFile/DWARF/x86/standalone-debug-line.s new file mode 100644 index 0000000000000..798d7d33193e1 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/x86/standalone-debug-line.s @@ -0,0 +1,160 @@ +# Test malformed and unusual standalone DWARF line tables. The ordinary +# address and source lookup behavior is covered by the SBAPI test in +# lldb/test/API/python_api/symbol-context/standalone-debug-line. + +# REQUIRES: lld +# UNSUPPORTED: system-windows + +# RUN: llvm-mc -triple=x86_64-pc-linux -filetype=obj -dwarf-version=2 \ +# RUN: %s -o %t.good.o +# RUN: llvm-mc -triple=x86_64-pc-linux -filetype=obj \ +# RUN: --defsym MALFORMED_BODY=1 %s -o %t.bad-body.o +# RUN: ld.lld -e bad_body -Ttext=0x201000 %t.bad-body.o -o %t.bad-body +# RUN: %lldb %t.bad-body -b -o "image dump symfile" \ +# RUN: -o "image lookup -a 0x201000 -v" | \ +# RUN: FileCheck %s --check-prefix=BAD-BODY +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux \ +# RUN: %S/debug-types-line-tables.s -o %t.types.o +# RUN: llvm-objcopy --remove-section=.debug_info %t.types.o %t.types +# RUN: lldb-test symbols %t.types | FileCheck %s --check-prefix=TYPES +# RUN: llvm-mc -triple=x86_64-pc-linux -filetype=obj --defsym INFO_ONLY=1 \ +# RUN: %s -o %t.info.o +# RUN: ld.lld -e foo -Ttext=0x201000 %t.good.o %t.info.o -o %t.info +# RUN: %lldb %t.info -b -o "image dump symfile" \ +# RUN: -o "image lookup -a 0x201000 -v" | \ +# RUN: FileCheck %s --check-prefix=INFO +# RUN: llvm-mc -triple=x86_64-pc-linux -filetype=obj --defsym RECOVERABLE=1 \ +# RUN: %s -o %t.recoverable.o +# RUN: ld.lld -e recoverable -Ttext=0x201000 %t.recoverable.o \ +# RUN: -o %t.recoverable +# RUN: %lldb %t.recoverable -b -o "image dump symfile" \ +# RUN: -o "image lookup -a 0x201000 -v" | \ +# RUN: FileCheck %s --check-prefix=RECOVERABLE + + .ifdef INFO_ONLY + .section .debug_info,"",@progbits + .byte 0 + .else + .ifdef MALFORMED_BODY + .text + .globl bad_body + .type bad_body,@function +bad_body: + nop + retq +.Lbad_body_end: + .size bad_body, .Lbad_body_end-bad_body + + .section .debug_line,"",@progbits +.Lbad_body_start: + .long .Lbad_body_end_table-.Lbad_body_version +.Lbad_body_version: + .short 2 + .long .Lbad_body_header_end-.Lbad_body_header +.Lbad_body_header: + .byte 1 + .byte 1 + .byte -5 + .byte 14 + .byte 13 + .byte 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1 + .asciz "/tmp" + .byte 0 + .asciz "bad-body.c" + .uleb128 1 + .uleb128 0 + .uleb128 0 + .byte 0 +.Lbad_body_header_end: + .byte 0, 9, 2 + .quad bad_body + .byte 3 + .sleb128 6 + .byte 1 + .byte 2 + .uleb128 2 + .byte 0, 1, 1 + .byte 3 +.Lbad_body_end_table: + .else + .ifdef RECOVERABLE + .text + .globl recoverable + .type recoverable,@function +recoverable: + nop + retq +.Lrecoverable_func_end: + .size recoverable, .Lrecoverable_func_end-recoverable + + .section .debug_line,"",@progbits +.Lrecoverable_start: + .long .Lrecoverable_end-.Lrecoverable_version +.Lrecoverable_version: + .short 2 + .long .Lrecoverable_header_end-.Lrecoverable_header +.Lrecoverable_header: + .byte 1 + .byte 1 + .byte -5 + .byte 14 + .byte 13 + .byte 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1 + .asciz "/tmp" + .byte 0 + .asciz "recoverable.c" + .uleb128 1 + .uleb128 0 + .uleb128 0 + .byte 0 + # CUDA line tables can contain padding at the end of the prologue. + .byte 0, 0, 0, 0 +.Lrecoverable_header_end: + .byte 0, 9, 2 + .quad recoverable + .byte 3 + .sleb128 6 + .byte 5 + .uleb128 5 + .byte 1 + .byte 2 + .uleb128 2 + .byte 0, 1, 1 +.Lrecoverable_end: + .else + .file 1 "/tmp/standalone-one.c" + + .text + .p2align 4 + .globl foo + .type foo,@function +foo: + .loc 1 42 7 + nop + .loc 1 43 3 + nop + retq +.Lfunc_end: + .size foo, .Lfunc_end-foo + .endif + .endif + .endif + +# BAD-BODY: SymbolFile symtab +# BAD-BODY-LABEL: (lldb) image lookup -a 0x201000 -v +# BAD-BODY-NOT: CompileUnit: +# BAD-BODY: Symbol: {{.*}}name="bad_body" + +# TYPES: Compile units: +# TYPES: CompileUnit{{.*}}file = '/tmp/b.cc' + +# INFO: SymbolFile symtab +# INFO-LABEL: (lldb) image lookup -a 0x201000 -v +# INFO-NOT: CompileUnit: +# INFO: Symbol: {{.*}}name="foo" + +# RECOVERABLE: SymbolFile dwarf +# RECOVERABLE-LABEL: (lldb) image lookup -a 0x201000 -v +# RECOVERABLE: CompileUnit: {{.*}}file = "/tmp/recoverable.c" +# RECOVERABLE: LineEntry: {{.*}}/tmp/recoverable.c:7:5 +# RECOVERABLE: Symbol: {{.*}}name="recoverable" _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
