https://github.com/satyajanga updated 
https://github.com/llvm/llvm-project/pull/218030

>From f66518acc5633ebf4bb30449e48352fc1c783e61 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 +++++--
 .../Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp    |  2 +-
 lldb/source/Symbol/SymbolFile.cpp                   | 13 +++++++++++--
 3 files changed, 17 insertions(+), 5 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/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 81cd4444161f7..cdef694510ca8 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -688,7 +688,7 @@ 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;
   }
   return abilities;
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

Reply via email to