diff --git a/llvm/include/llvm/DebugInfo/GSYM/LookupResult.h b/llvm/include/llvm/DebugInfo/GSYM/LookupResult.h --- a/llvm/include/llvm/DebugInfo/GSYM/LookupResult.h +++ b/llvm/include/llvm/DebugInfo/GSYM/LookupResult.h @@ -24,11 +24,13 @@ StringRef Dir; ///< Line entry source file directory path. StringRef Base; ///< Line entry source file basename. uint32_t Line = 0; ///< Source file line number. + uint32_t Offset = 0; ///< Byte size offset within the named function. }; inline bool operator==(const SourceLocation &LHS, const SourceLocation &RHS) { return LHS.Name == RHS.Name && LHS.Dir == RHS.Dir && - LHS.Base == RHS.Base && LHS.Line == RHS.Line; + LHS.Base == RHS.Base && LHS.Line == RHS.Line && + LHS.Offset == RHS.Offset; } raw_ostream &operator<<(raw_ostream &OS, const SourceLocation &R); diff --git a/llvm/lib/DebugInfo/GSYM/FunctionInfo.cpp b/llvm/lib/DebugInfo/GSYM/FunctionInfo.cpp --- a/llvm/lib/DebugInfo/GSYM/FunctionInfo.cpp +++ b/llvm/lib/DebugInfo/GSYM/FunctionInfo.cpp @@ -223,6 +223,7 @@ // location as best we can and return. SourceLocation SrcLoc; SrcLoc.Name = LR.FuncName; + SrcLoc.Offset = Addr - FuncAddr; LR.Locations.push_back(SrcLoc); return LR; } @@ -235,6 +236,7 @@ SourceLocation SrcLoc; SrcLoc.Name = LR.FuncName; + SrcLoc.Offset = Addr - FuncAddr; SrcLoc.Dir = GR.getString(LineEntryFile->Dir); SrcLoc.Base = GR.getString(LineEntryFile->Base); SrcLoc.Line = LineEntry->Line; diff --git a/llvm/lib/DebugInfo/GSYM/InlineInfo.cpp b/llvm/lib/DebugInfo/GSYM/InlineInfo.cpp --- a/llvm/lib/DebugInfo/GSYM/InlineInfo.cpp +++ b/llvm/lib/DebugInfo/GSYM/InlineInfo.cpp @@ -145,10 +145,12 @@ if (CallFile->Dir || CallFile->Base) { SourceLocation SrcLoc; SrcLoc.Name = SrcLocs.back().Name; + SrcLoc.Offset = SrcLocs.back().Offset; SrcLoc.Dir = GR.getString(CallFile->Dir); SrcLoc.Base = GR.getString(CallFile->Base); SrcLoc.Line = Inline.CallLine; SrcLocs.back().Name = GR.getString(Inline.Name); + SrcLocs.back().Offset = Addr - Inline.Ranges[0].Start; SrcLocs.push_back(SrcLoc); } return true; diff --git a/llvm/unittests/DebugInfo/GSYM/GSYMTest.cpp b/llvm/unittests/DebugInfo/GSYM/GSYMTest.cpp --- a/llvm/unittests/DebugInfo/GSYM/GSYMTest.cpp +++ b/llvm/unittests/DebugInfo/GSYM/GSYMTest.cpp @@ -1362,45 +1362,45 @@ LR = GR->lookup(0x100F); ASSERT_THAT_EXPECTED(LR, Succeeded()); EXPECT_THAT(LR->Locations, - testing::ElementsAre(SourceLocation{"main", "/tmp", "main.c", 5})); + testing::ElementsAre(SourceLocation{"main", "/tmp", "main.c", 5, 15})); LR = GR->lookup(0x1010); ASSERT_THAT_EXPECTED(LR, Succeeded()); EXPECT_THAT(LR->Locations, testing::ElementsAre(SourceLocation{"inline1", "/tmp", "foo.h", 10}, - SourceLocation{"main", "/tmp", "main.c", 6})); + SourceLocation{"main", "/tmp", "main.c", 6, 16})); LR = GR->lookup(0x1012); ASSERT_THAT_EXPECTED(LR, Succeeded()); EXPECT_THAT(LR->Locations, testing::ElementsAre(SourceLocation{"inline2", "/tmp", "foo.h", 20}, - SourceLocation{"inline1", "/tmp", "foo.h", 33}, - SourceLocation{"main", "/tmp", "main.c", 6})); + SourceLocation{"inline1", "/tmp", "foo.h", 33, 2}, + SourceLocation{"main", "/tmp", "main.c", 6, 18})); LR = GR->lookup(0x1014); ASSERT_THAT_EXPECTED(LR, Succeeded()); EXPECT_THAT(LR->Locations, - testing::ElementsAre(SourceLocation{"inline1", "/tmp", "foo.h", 11}, - SourceLocation{"main", "/tmp", "main.c", 6})); + testing::ElementsAre(SourceLocation{"inline1", "/tmp", "foo.h", 11, 4}, + SourceLocation{"main", "/tmp", "main.c", 6, 20})); LR = GR->lookup(0x1016); ASSERT_THAT_EXPECTED(LR, Succeeded()); EXPECT_THAT(LR->Locations, testing::ElementsAre(SourceLocation{"inline3", "/tmp", "foo.h", 30}, - SourceLocation{"inline1", "/tmp", "foo.h", 35}, - SourceLocation{"main", "/tmp", "main.c", 6})); + SourceLocation{"inline1", "/tmp", "foo.h", 35, 6}, + SourceLocation{"main", "/tmp", "main.c", 6, 22})); LR = GR->lookup(0x1018); ASSERT_THAT_EXPECTED(LR, Succeeded()); EXPECT_THAT(LR->Locations, - testing::ElementsAre(SourceLocation{"inline1", "/tmp", "foo.h", 12}, - SourceLocation{"main", "/tmp", "main.c", 6})); + testing::ElementsAre(SourceLocation{"inline1", "/tmp", "foo.h", 12, 8}, + SourceLocation{"main", "/tmp", "main.c", 6, 24})); LR = GR->lookup(0x1020); ASSERT_THAT_EXPECTED(LR, Succeeded()); EXPECT_THAT(LR->Locations, - testing::ElementsAre(SourceLocation{"main", "/tmp", "main.c", 8})); + testing::ElementsAre(SourceLocation{"main", "/tmp", "main.c", 8, 32})); } @@ -1968,32 +1968,32 @@ LR = GR->lookup(0x1100-1); ASSERT_THAT_EXPECTED(LR, Succeeded()); EXPECT_THAT(LR->Locations, - testing::ElementsAre(SourceLocation{"main", "/tmp", "main.c", 10})); + testing::ElementsAre(SourceLocation{"main", "/tmp", "main.c", 10, 255})); LR = GR->lookup(0x1100); ASSERT_THAT_EXPECTED(LR, Succeeded()); EXPECT_THAT(LR->Locations, testing::ElementsAre(SourceLocation{"inline1", "/tmp", "inline.h", 20}, - SourceLocation{"main", "/tmp", "main.c", 10})); + SourceLocation{"main", "/tmp", "main.c", 10, 256})); LR = GR->lookup(0x1180-1); ASSERT_THAT_EXPECTED(LR, Succeeded()); EXPECT_THAT(LR->Locations, - testing::ElementsAre(SourceLocation{"inline1", "/tmp", "inline.h", 20}, - SourceLocation{"main", "/tmp", "main.c", 10})); + testing::ElementsAre(SourceLocation{"inline1", "/tmp", "inline.h", 20, 127}, + SourceLocation{"main", "/tmp", "main.c", 10, 383})); LR = GR->lookup(0x1180); ASSERT_THAT_EXPECTED(LR, Succeeded()); EXPECT_THAT(LR->Locations, - testing::ElementsAre(SourceLocation{"inline1", "/tmp", "inline.h", 21}, - SourceLocation{"main", "/tmp", "main.c", 10})); + testing::ElementsAre(SourceLocation{"inline1", "/tmp", "inline.h", 21, 128}, + SourceLocation{"main", "/tmp", "main.c", 10, 384})); LR = GR->lookup(0x1200-1); ASSERT_THAT_EXPECTED(LR, Succeeded()); EXPECT_THAT(LR->Locations, - testing::ElementsAre(SourceLocation{"inline1", "/tmp", "inline.h", 21}, - SourceLocation{"main", "/tmp", "main.c", 10})); + testing::ElementsAre(SourceLocation{"inline1", "/tmp", "inline.h", 21, 255}, + SourceLocation{"main", "/tmp", "main.c", 10, 511})); LR = GR->lookup(0x1200); ASSERT_THAT_EXPECTED(LR, Succeeded()); EXPECT_THAT(LR->Locations, - testing::ElementsAre(SourceLocation{"main", "/tmp", "main.c", 11})); + testing::ElementsAre(SourceLocation{"main", "/tmp", "main.c", 11, 512})); }