[PATCH] D105068: Fix a case where multiple symbols with zero size would cause duplicate entries in gsym files.
Greg Clayton via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 28 18:26:43 PDT 2021
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGab546ead3bf7: Fix a case where multiple symbols with zero size would cause duplicate entries… (authored by clayborg).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D105068/new/
https://reviews.llvm.org/D105068
Files:
llvm/lib/DebugInfo/GSYM/GsymCreator.cpp
llvm/unittests/DebugInfo/GSYM/GSYMTest.cpp
Index: llvm/unittests/DebugInfo/GSYM/GSYMTest.cpp
===================================================================
--- llvm/unittests/DebugInfo/GSYM/GSYMTest.cpp
+++ llvm/unittests/DebugInfo/GSYM/GSYMTest.cpp
@@ -2518,3 +2518,27 @@
StringRef MethodName = GR->getString(ExpFI->Name);
EXPECT_EQ(MethodName, "main");
}
+
+TEST(GSYMTest, TestGsymCreatorMultipleSymbolsWithNoSize) {
+ // Multiple symbols at the same address with zero size were being emitted
+ // instead of being combined into a single entry. This function tests to make
+ // sure we only get one symbol.
+ uint8_t UUID[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16};
+ GsymCreator GC;
+ GC.setUUID(UUID);
+ constexpr uint64_t BaseAddr = 0x1000;
+ constexpr uint8_t AddrOffSize = 1;
+ const uint32_t Func1Name = GC.insertString("foo");
+ const uint32_t Func2Name = GC.insertString("bar");
+ GC.addFunctionInfo(FunctionInfo(BaseAddr, 0, Func1Name));
+ GC.addFunctionInfo(FunctionInfo(BaseAddr, 0, Func2Name));
+ Error Err = GC.finalize(llvm::nulls());
+ ASSERT_FALSE(Err);
+ TestEncodeDecode(GC, llvm::support::little, GSYM_VERSION, AddrOffSize,
+ BaseAddr,
+ 1, // NumAddresses
+ ArrayRef<uint8_t>(UUID));
+ TestEncodeDecode(GC, llvm::support::big, GSYM_VERSION, AddrOffSize, BaseAddr,
+ 1, // NumAddresses
+ ArrayRef<uint8_t>(UUID));
+}
Index: llvm/lib/DebugInfo/GSYM/GsymCreator.cpp
===================================================================
--- llvm/lib/DebugInfo/GSYM/GsymCreator.cpp
+++ llvm/lib/DebugInfo/GSYM/GsymCreator.cpp
@@ -224,9 +224,13 @@
Funcs.erase(
removeIfBinary(Funcs.begin(), Funcs.end(),
[&](const auto &Prev, const auto &Curr) {
- if (Prev.Range.intersects(Curr.Range)) {
- // Overlapping address ranges.
- if (Prev.Range == Curr.Range) {
+ // Empty ranges won't intersect, but we still need to
+ // catch the case where we have multiple symbols at the
+ // same address and coalesce them.
+ const bool ranges_equal = Prev.Range == Curr.Range;
+ if (ranges_equal || Prev.Range.intersects(Curr.Range)) {
+ // Overlapping ranges or empty identical ranges.
+ if (ranges_equal) {
// Same address range. Check if one is from debug
// info and the other is from a symbol table. If
// so, then keep the one with debug info. Our
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105068.355081.patch
Type: text/x-patch
Size: 2688 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210629/0abb4563/attachment.bin>
More information about the llvm-commits
mailing list