[llvm] [dsymutil] Fix spurious warnings in MachODebugMapParser (PR #78794)

via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 19 14:07:46 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-debuginfo

Author: Jonas Devlieghere (JDevlieghere)

<details>
<summary>Changes</summary>

When the MachODebugMapParser encounters an object file that cannot be found on disk, it currently leaves the parser in an incoherent state, resulting in spurious warnings that can in turn slow down dsymutil.

rdar://117515153

---
Full diff: https://github.com/llvm/llvm-project/pull/78794.diff


4 Files Affected:

- (added) llvm/test/tools/dsymutil/ARM/missing-object-warning.test (+5) 
- (added) llvm/test/tools/dsymutil/Inputs/private/tmp/missing/foo.o () 
- (added) llvm/test/tools/dsymutil/Inputs/private/tmp/missing/foobar.out () 
- (modified) llvm/tools/dsymutil/MachODebugMapParser.cpp (+2-3) 


``````````diff
diff --git a/llvm/test/tools/dsymutil/ARM/missing-object-warning.test b/llvm/test/tools/dsymutil/ARM/missing-object-warning.test
new file mode 100644
index 00000000000000..62b3ecb31888b1
--- /dev/null
+++ b/llvm/test/tools/dsymutil/ARM/missing-object-warning.test
@@ -0,0 +1,5 @@
+RUN: dsymutil -oso-prepend-path %p/../Inputs --dump-debug-map %p/../Inputs/private/tmp/missing/foobar.out 2>&1 | FileCheck %s
+
+CHECK: bar.o unable to open object file
+CHECK-NOT: could not find object file symbol for symbol _bar
+CHECK-NOT: could not find object file symbol for symbol _main
diff --git a/llvm/test/tools/dsymutil/Inputs/private/tmp/missing/foo.o b/llvm/test/tools/dsymutil/Inputs/private/tmp/missing/foo.o
new file mode 100644
index 00000000000000..333b39c45b1452
Binary files /dev/null and b/llvm/test/tools/dsymutil/Inputs/private/tmp/missing/foo.o differ
diff --git a/llvm/test/tools/dsymutil/Inputs/private/tmp/missing/foobar.out b/llvm/test/tools/dsymutil/Inputs/private/tmp/missing/foobar.out
new file mode 100755
index 00000000000000..2574c85b992924
Binary files /dev/null and b/llvm/test/tools/dsymutil/Inputs/private/tmp/missing/foobar.out differ
diff --git a/llvm/tools/dsymutil/MachODebugMapParser.cpp b/llvm/tools/dsymutil/MachODebugMapParser.cpp
index 524a6795c360e9..6a9f25681cdd1c 100644
--- a/llvm/tools/dsymutil/MachODebugMapParser.cpp
+++ b/llvm/tools/dsymutil/MachODebugMapParser.cpp
@@ -186,6 +186,8 @@ void MachODebugMapParser::addCommonSymbols() {
 /// everything up to add symbols to the new one.
 void MachODebugMapParser::switchToNewDebugMapObject(
     StringRef Filename, sys::TimePoint<std::chrono::seconds> Timestamp) {
+  addCommonSymbols();
+  resetParserState();
 
   SmallString<80> Path(PathPrefix);
   sys::path::append(Path, Filename);
@@ -206,9 +208,6 @@ void MachODebugMapParser::switchToNewDebugMapObject(
     return;
   }
 
-  addCommonSymbols();
-  resetParserState();
-
   CurrentDebugMapObject =
       &Result->addDebugMapObject(Path, Timestamp, MachO::N_OSO);
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/78794


More information about the llvm-commits mailing list