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

Jonas Devlieghere via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 19 14:08:21 PST 2024


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

>From f182d5e23882a9a629b13b767cbd6566885d0dc3 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere <jonas at devlieghere.com>
Date: Fri, 19 Jan 2024 13:49:27 -0800
Subject: [PATCH] [dsymutil] Fix spurious warnings in MachODebugMapParser

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.

This fixes #78411.

rdar://117515153
---
 .../dsymutil/ARM/missing-object-warning.test    |   5 +++++
 .../dsymutil/Inputs/private/tmp/missing/foo.o   | Bin 0 -> 1792 bytes
 .../Inputs/private/tmp/missing/foobar.out       | Bin 0 -> 17336 bytes
 llvm/tools/dsymutil/MachODebugMapParser.cpp     |   5 ++---
 4 files changed, 7 insertions(+), 3 deletions(-)
 create mode 100644 llvm/test/tools/dsymutil/ARM/missing-object-warning.test
 create mode 100644 llvm/test/tools/dsymutil/Inputs/private/tmp/missing/foo.o
 create mode 100755 llvm/test/tools/dsymutil/Inputs/private/tmp/missing/foobar.out

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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WlExDdqEuXh-ofvHt_cj6&K_E43eLfT!Q?|JV-e7AJ<iNd

literal 0
HcmV?d00001

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 0000000000000000000000000000000000000000..2574c85b9929240784035fb4b3ffddcb99ba061c
GIT binary patch
literal 17336
zcmeI4U1%It6vyv=R9X at nsnN#z(RnCRC1k~x+KT8VbTP%y#x~Yfglm$WwL`PJ?e0X|
zBql4hq7;#e;)@RvDW$<EYQ^+H8mQVAQKR*fB2iS5hl-^(rGa$)|7Y)znbZ&PQO<#L
z&zy7So_p`_&g+ at aX3t!zRVtz&QRr3BDLm{~7M_&44%!OUy1n_{)WfN*TNn+CH#r=-
z%wwG?sMZ~+bVoSt%}<77%J_>ArgCo-tzCPMTYawj;d&kSR1ec;UZL;L^+It~HYv|&
z-J5^H$!D~a&lV6_xW8dj?@=>}eyE;_`(~b3+osL;r8aKz&zdxlVLdT+ELL^NAjom8
zQf1x+Ijo0SWBm2-c^}+E1N2$=T(hAC&#*Pnb|~c<qj6Zi^Iv2sCRtE?BP!8bDkgfI
zu0&>UPX<2adMNkN-q!Q#?saP(e0{}hA3eYQ{X at 4SW<jfGLY4SZ at 7X(U&9?Zh$a&|3
zrL4yJSSJI%LE*YQKXW{DB-4z~Au_)g>}T8Fl56LhTAHvgrwcDZZicdcIjPiQ*jtQG
zUX&Z5%nyTGLl8WZB0 at k22mv7=1cZPP5CTF#2nYcoAOwVf5D)@FKnMr{As_^VfDjM@
zLO=)z0U;m+gn$qb0zyCt2mv7=1cZPP5CTF#2nYcoAOwVf5D)@FKnMr{As_^VfDjM@
zLO=-oZwOebymdULzfKxkIiV)z`lCnY_Njx%Ppljp-nVk>#~O8Urc!xjvQ8bNor<ZE
z$-3k*bSu})^|u_soP(^v*5n%unV at AaG<(~VuvGS?Q<B~|Kd|4r7M;`ePzrjUS&|Oh
z!acDt-e#16U^}#FPiHtR5nbIEE5+35K at 6uj{5*)tI=4gHd+hFB*Va4i&Wv4DOS(FX
z>dI`PpqAx2oxECJEq7{gG264fH8X*Q*}v`gm@|)l_>g}m{48dT{61nc&#6rq{QiIT
zrLPM3%&&rai^0<0ydWQ3{{iHK>vu2k9r#@T%?0Z}f_q@?YoT1<_Zj=E^@DltpZ)KA
z*D~{c-=BXM;uQMae=r~1Kd+ at O!VdTO{nX)oe?9V{@AI;Z at 7J^NCxpu{QS%ZtFHw7!
zm~eBu5;><-a`KNQ6yi<YDzU5RJl^Trp&U~M6$&ZT`n%Ve;@=pQn*E`694Fw{!Xs1a
z5ySB!F%^yTOXg8|J!vK(_&-3)uod-wSx}Aq^XUI7B7#kN3-`L}so9&pXmpnUGFf?O
zx>)Y(I^P=q_VXn#4!k=)x~{)%^xWvs8}FnGA5Uk;<KIk7?2K+nFRBb29q8Nt{RanH
zpKCn)Z~5u;Tz~VYe~cZtyWV};O+2Z;dg<hapRV}wt(ikFe{%lq(;M$_TDSjtY3=>V
dlYQT9IQw2CJCu6i_%n^Aqbr6!yn5z0^(R~|BuD at N

literal 0
HcmV?d00001

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);
 



More information about the llvm-commits mailing list