https://github.com/satyajanga created https://github.com/llvm/llvm-project/pull/218030
## Summary - rank symbol-file readers that provide detailed debug information ahead of readers that expose only information obtainable from an object symbol table - preserve the existing ability-mask ordering within each category - avoid format names, registration-order dependencies, and fabricated ability bits ## Rationale `SymbolFile::FindPlugin` currently compares ability masks numerically. As a result, a reader providing compile units and line tables (`0x3`) can lose to a basic symbol-table reader providing functions (`0x4`). Line tables, lexical blocks, local variables, and types contain information that the object symbol table cannot recover, while raw symbols remain available through the object file. ## Testing - built `lldb` - `SymbolTests` (125/125 passed) - exercised end-to-end by the stacked standalone-DWARF change in #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] [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) _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
