Skip to content

Commit 3f1a391

Browse files
authored
[llvm-gsymutil] Fix broken tests (#121837)
Recently #120991 broke a couple of tests. Also `macho-merged-funcs-dwarf.yaml` was already flaky due to some non-determinism issues. Fixing the previous code to not break tests and modifying `macho-merged-funcs-dwarf.yaml` to fix the non-determinism (which will be resolved later).
1 parent be21bd9 commit 3f1a391

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

llvm/test/tools/llvm-gsymutil/ARM_AArch64/macho-merged-funcs-dwarf.yaml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,15 @@
6767
## Test the lookup functionality for merged functions:
6868
# RUN: llvm-gsymutil --verify %t.keep.gSYM --address 0x248 --merged-functions | FileCheck --check-prefix=CHECK-MERGED-LOOKUP %s
6969
# RUN: llvm-gsymutil --verify %t.keep.gSYM --address 0x248 | FileCheck --check-prefix=CHECK-NORMAL-LOOKUP %s
70-
70+
71+
#### TODO: Fix non-determinism leading that is currently worked around with `{{[1-3]}}` below.
72+
7173
# CHECK-MERGED-LOOKUP: Found 3 functions at address 0x0000000000000248:
72-
# CHECK-MERGED-LOOKUP-NEXT: 0x0000000000000248: my_func_02 @ /tmp/test_gsym_yaml/out/file_02.cpp:5
73-
# CHECK-MERGED-LOOKUP-NEXT-NEXT: 0x0000000000000248: my_func_01 @ /tmp/test_gsym_yaml/out/file_01.cpp:5
74-
# CHECK-MERGED-LOOKUP-NEXT-NEXT: 0x0000000000000248: my_func_03 @ /tmp/test_gsym_yaml/out/file_03.cpp:5
74+
# CHECK-MERGED-LOOKUP-NEXT: 0x0000000000000248: my_func_0{{[1-3]}} @ /tmp/test_gsym_yaml/out/file_0{{[1-3]}}.cpp:5
75+
# CHECK-MERGED-LOOKUP-NEXT-NEXT: 0x0000000000000248: my_func_0{{[1-3]}} @ /tmp/test_gsym_yaml/out/file_0{{[1-3]}}.cpp:5
76+
# CHECK-MERGED-LOOKUP-NEXT-NEXT: 0x0000000000000248: my_func_0{{[1-3]}} @ /tmp/test_gsym_yaml/out/file_0{{[1-3]}}.cpp:5
7577

76-
# CHECK-NORMAL-LOOKUP: 0x0000000000000248: my_func_01 @ /tmp/test_gsym_yaml/out/file_01.cpp:5
78+
# CHECK-NORMAL-LOOKUP: 0x0000000000000248: my_func_0{{[1-3]}} @ /tmp/test_gsym_yaml/out/file_0{{[1-3]}}.cpp:5
7779

7880

7981
--- !mach-o

llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -508,11 +508,6 @@ static llvm::Error convertFileToGSYM(OutputAggregator &Out) {
508508
}
509509

510510
static void doLookup(GsymReader &Gsym, uint64_t Addr, raw_ostream &OS) {
511-
auto logError = [Addr, &OS](Error E) {
512-
OS << HEX64(Addr) << ": ";
513-
logAllUnhandledErrors(std::move(E), OS, "error: ");
514-
};
515-
516511
if (UseMergedFunctions) {
517512
if (auto Results = Gsym.lookupAll(Addr)) {
518513
OS << "Found " << Results->size() << " functions at address "
@@ -526,20 +521,23 @@ static void doLookup(GsymReader &Gsym, uint64_t Addr, raw_ostream &OS) {
526521
}
527522
} else { /* UseMergedFunctions == false */
528523
if (auto Result = Gsym.lookup(Addr)) {
524+
// If verbose is enabled dump the full function info for the address.
525+
if (Verbose) {
526+
if (auto FI = Gsym.getFunctionInfo(Addr)) {
527+
OS << "FunctionInfo for " << HEX64(Addr) << ":\n";
528+
Gsym.dump(OS, *FI);
529+
OS << "\nLookupResult for " << HEX64(Addr) << ":\n";
530+
}
531+
}
529532
OS << Result.get();
530533
} else {
531-
logError(Result.takeError());
532-
return;
533-
}
534-
}
535-
536-
if (Verbose) {
537-
if (auto FI = Gsym.getFunctionInfo(Addr)) {
538-
OS << "FunctionInfo for " << HEX64(Addr) << ":\n";
539-
Gsym.dump(OS, *FI);
540-
OS << "\nLookupResult for " << HEX64(Addr) << ":\n";
534+
if (Verbose)
535+
OS << "\nLookupResult for " << HEX64(Addr) << ":\n";
536+
OS << HEX64(Addr) << ": ";
537+
logAllUnhandledErrors(Result.takeError(), OS, "error: ");
541538
}
542-
OS << "\n";
539+
if (Verbose)
540+
OS << "\n";
543541
}
544542
}
545543

0 commit comments

Comments
 (0)