https://github.com/jimingham updated 
https://github.com/llvm/llvm-project/pull/89324

>From b6021cf31e4c607dc4d541b4dd3b028e93050767 Mon Sep 17 00:00:00 2001
From: Jim Ingham <jing...@apple.com>
Date: Thu, 18 Apr 2024 15:02:37 -0700
Subject: [PATCH 1/3] Check for null oso SymbolFile in
 SymbolFileDwarfDebugMap::ResolveSymbolContext.

The couple other places that use the oso module's SymbolFile, they check that
it's non-null, so this is just an oversight in ResolveSymbolContext.

I didn't add a test for this (but did add a log message for the error case)
because I can't see how this would actually happen.  The .o file had to have
valid enough DWARF that the linker's parser could handle it or it would not be
in the debug map.  If you delete the .o file, we just leave that entry out of
the debug map.  If you strip it or otherwise mess with it, we'll notice the
changed mod time and refuse to read it...

This was based on a report from the field, and we don't have access to the
project.  But if the logging tells me how this happened I can come back and add 
a test with
that example.
---
 .../SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp  | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
index 1de585832e3216..d6560e399e4fc4 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
@@ -848,9 +848,18 @@ SymbolFileDWARFDebugMap::ResolveSymbolContext(const 
Address &exe_so_addr,
                 debug_map_entry->data.GetOSOFileAddress();
             Address oso_so_addr;
             if (oso_module->ResolveFileAddress(oso_file_addr, oso_so_addr)) {
-              resolved_flags |=
-                  oso_module->GetSymbolFile()->ResolveSymbolContext(
-                      oso_so_addr, resolve_scope, sc);
+              SymbolFile *sym_file = oso_module->GetSymbolFile();
+              if (sym_file) {
+                resolved_flags |= sym_file->ResolveSymbolContext(oso_so_addr, 
+                    resolve_scope, sc);
+              } else {
+                ObjectFile *obj_file = GetObjectFile();
+                LLDB_LOG(GetLog(DWARFLog::DebugMap),
+                         "Failed to get symfile for OSO: {0} in module: {1}", 
+                         oso_module->GetFileSpec(), 
+                         obj_file ? obj_file->GetFileSpec() : 
+                             FileSpec("unknown"));
+              }
             }
           }
         }

>From 50e5143db27ce5f00008b0d9c77f485883f0c1eb Mon Sep 17 00:00:00 2001
From: Jim Ingham <jing...@apple.com>
Date: Thu, 18 Apr 2024 16:07:52 -0700
Subject: [PATCH 2/3] Move sym_file definition inside "if ()".

---
 .../Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp       | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
index d6560e399e4fc4..4089697f0bbc11 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
@@ -848,8 +848,7 @@ SymbolFileDWARFDebugMap::ResolveSymbolContext(const Address 
&exe_so_addr,
                 debug_map_entry->data.GetOSOFileAddress();
             Address oso_so_addr;
             if (oso_module->ResolveFileAddress(oso_file_addr, oso_so_addr)) {
-              SymbolFile *sym_file = oso_module->GetSymbolFile();
-              if (sym_file) {
+              if (SymbolFile *sym_file = oso_module->GetSymbolFile()) {
                 resolved_flags |= sym_file->ResolveSymbolContext(oso_so_addr, 
                     resolve_scope, sc);
               } else {

>From a13fc0de7e5412d29add4bcb57ab55614e92108a Mon Sep 17 00:00:00 2001
From: Jim Ingham <jing...@apple.com>
Date: Thu, 18 Apr 2024 16:14:10 -0700
Subject: [PATCH 3/3] Bow

---
 .../SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp     | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
index 4089697f0bbc11..f066f13d51c5d1 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
@@ -849,15 +849,15 @@ SymbolFileDWARFDebugMap::ResolveSymbolContext(const 
Address &exe_so_addr,
             Address oso_so_addr;
             if (oso_module->ResolveFileAddress(oso_file_addr, oso_so_addr)) {
               if (SymbolFile *sym_file = oso_module->GetSymbolFile()) {
-                resolved_flags |= sym_file->ResolveSymbolContext(oso_so_addr, 
-                    resolve_scope, sc);
+                resolved_flags |= sym_file->ResolveSymbolContext(
+                    oso_so_addr, resolve_scope, sc);
               } else {
                 ObjectFile *obj_file = GetObjectFile();
                 LLDB_LOG(GetLog(DWARFLog::DebugMap),
-                         "Failed to get symfile for OSO: {0} in module: {1}", 
-                         oso_module->GetFileSpec(), 
-                         obj_file ? obj_file->GetFileSpec() : 
-                             FileSpec("unknown"));
+                         "Failed to get symfile for OSO: {0} in module: {1}",
+                         oso_module->GetFileSpec(),
+                         obj_file ? obj_file->GetFileSpec()
+                                  : FileSpec("unknown"));
               }
             }
           }

_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to