Skip to content

Commit 456ca4a

Browse files
committed
[llvm-gsymutil] Don't warn about duplicate debug info for merged functions
1 parent 4564ac9 commit 456ca4a

File tree

4 files changed

+26
-13
lines changed

4 files changed

+26
-13
lines changed

llvm/include/llvm/DebugInfo/GSYM/GsymCreator.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ class GsymCreator {
147147
bool IsSegment = false;
148148
bool Finalized = false;
149149
bool Quiet;
150-
150+
// Specifies weather the input might contain merged functions
151+
bool InputHasMergedFunctions;
151152

152153
/// Get the first function start address.
153154
///
@@ -292,7 +293,12 @@ class GsymCreator {
292293
}
293294

294295
public:
295-
GsymCreator(bool Quiet = false);
296+
/// Construct a GsymCreator object.
297+
///
298+
/// \param Quiet Whether to suppress warning messages
299+
/// \param InputHasMergedFunctions Weather the input might contain merged
300+
/// functions - functions with identical address ranges.
301+
GsymCreator(bool Quiet = false, bool InputHasMergedFunctions = false);
296302

297303
/// Save a GSYM file to a stand alone file.
298304
///

llvm/lib/DebugInfo/GSYM/GsymCreator.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@
2121
using namespace llvm;
2222
using namespace gsym;
2323

24-
GsymCreator::GsymCreator(bool Quiet)
25-
: StrTab(StringTableBuilder::ELF), Quiet(Quiet) {
24+
GsymCreator::GsymCreator(bool Quiet, bool InputHasMergedFunctions)
25+
: StrTab(StringTableBuilder::ELF), Quiet(Quiet),
26+
InputHasMergedFunctions(InputHasMergedFunctions) {
2627
insertFile(StringRef());
2728
}
2829

@@ -315,12 +316,16 @@ llvm::Error GsymCreator::finalize(OutputAggregator &Out) {
315316
std::swap(Prev, Curr);
316317
}
317318
} else {
318-
Out.Report("Overlapping function ranges", [&](raw_ostream &OS) {
319-
// print warnings about overlaps
320-
OS << "warning: function ranges overlap:\n"
321-
<< Prev << "\n"
322-
<< Curr << "\n";
323-
});
319+
// Equal ranges are invalid only in the case where merged functions
320+
// are not expected.
321+
if (!InputHasMergedFunctions) {
322+
Out.Report("Overlapping function ranges", [&](raw_ostream &OS) {
323+
// print warnings about overlaps
324+
OS << "warning: function ranges overlap:\n"
325+
<< Prev << "\n"
326+
<< Curr << "\n";
327+
});
328+
}
324329
FinalizedFuncs.emplace_back(std::move(Curr));
325330
}
326331
} else {

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
# RUN: yaml2obj %s -o %t.dSYM
22

33
## Verify that we don't keep merged functions by default
4-
# RUN: llvm-gsymutil --num-threads=1 --convert %t.dSYM --out-file=%t.default.gSYM
4+
# RUN: llvm-gsymutil --num-threads=1 --convert %t.dSYM --out-file=%t.default.gSYM | FileCheck --check-prefix=CHECK-GSYM-CREATE-NOMERGE %s
55
# RUN: llvm-gsymutil --verify --verbose %t.default.gSYM | FileCheck --check-prefix=CHECK-GSYM-DEFAULT %s
66

77
## Verify that we keep merged functions when specyfing --merged-functions
8-
# RUN: llvm-gsymutil --num-threads=1 --convert %t.dSYM --out-file=%t.keep.gSYM --merged-functions
8+
# RUN: llvm-gsymutil --num-threads=1 --convert %t.dSYM --out-file=%t.keep.gSYM --merged-functions | FileCheck --check-prefix=CHECK-GSYM-CREATE-MERGE %s
99
# RUN: llvm-gsymutil --verify --verbose %t.keep.gSYM | FileCheck --check-prefix=CHECK-GSYM-KEEP %s
1010

1111
## Note: For identical functions, the dSYM / gSYM cannot be counted on to be deterministic.
1212
## So we can only match the general structure, not exact function names / offsets
1313

14+
# CHECK-GSYM-CREATE-NOMERGE: warning: same address range contains different debug info.
15+
# CHECK-GSYM-CREATE-MERGE-NOT: warning: same address range contains different debug info.
1416

1517
# CHECK-GSYM-DEFAULT-NOT: Merged FunctionInfos
1618
# CHECK-GSYM-DEFAULT: FunctionInfo @ 0x{{[0-9a-fA-F]+}}: [0x{{[0-9a-fA-F]+}} - 0x{{[0-9a-fA-F]+}}) "my_func_03"

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ static llvm::Error handleObjectFile(ObjectFile &Obj, const std::string &OutFile,
349349
auto ThreadCount =
350350
NumThreads > 0 ? NumThreads : std::thread::hardware_concurrency();
351351

352-
GsymCreator Gsym(Quiet);
352+
GsymCreator Gsym(Quiet, UseMergedFunctions);
353353

354354
// See if we can figure out the base address for a given object file, and if
355355
// we can, then set the base address to use to this value. This will ease

0 commit comments

Comments
 (0)