Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PDB support of function-level linking and splitted functions
Summary: The patch adds support of splitted functions (when MSVC is used with PGO) and function-level linking feature. SymbolFilePDB::ParseCompileUnitLineTable function relies on fact that ranges of compiled source files in the binary are continuous and don't intersect each other. The function creates LineSequence for each file and inserts it into LineTable, and implementation of last one relies on continuity of the sequence. But it's not always true when function-level linking enabled, e.g. in added input test file test-pdb-function-level-linking.exe there is xstring's std__basic_string_char_std__char_traits_char__std__allocator_char_____max_size (.00454820) between test-pdb-function-level-linking.cpp's foo (.00454770) and main (.004548F0). To fix the problem this patch renews the sequence on each address gap. Reviewers: asmith, zturner Reviewed By: asmith Subscribers: mgorny, lldb-commits Differential Revision: https://reviews.llvm.org/D47708 llvm-svn: 334030
- Loading branch information
Showing
9 changed files
with
107 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
lldb/unittests/SymbolFile/PDB/Inputs/test-pdb-function-level-linking.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Compile with "cl /c /ZI /sdl /EHsc /MTd /permissive- | ||
// test-pdb-function-level-linking.cpp" | ||
// Link with "link /debug:full test-pdb-function-level-linking.obj" | ||
|
||
#include <memory> | ||
#include <string> | ||
|
||
std::string foo() | ||
{ | ||
return "Hello!"; | ||
} | ||
|
||
int main() | ||
{ | ||
auto x = foo(); | ||
return 0; | ||
} |
Empty file.
Empty file.
27 changes: 27 additions & 0 deletions
27
lldb/unittests/SymbolFile/PDB/Inputs/test-pdb-splitted-function.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Compile with "cl /c /Zi /GL /O2 /EHsc /MTd test-pdb-splitted-function.cpp" | ||
// Link with "link /debug:full /LTCG /GENPROFILE | ||
// test-pdb-splitted-function.obj" | ||
// Run several times | ||
// Link with "link /debug:full /LTCG /USEPROFILE | ||
// test-pdb-splitted-function.obj" | ||
|
||
#include <cmath> | ||
#include <iostream> | ||
|
||
int main() | ||
{ | ||
auto b = false; | ||
for (auto i = 1; i <= 1024; i++) | ||
{ | ||
if (b) | ||
{ | ||
std::cout << "Unreachable code" << std::endl; | ||
auto x = std::sin(i); | ||
return x; | ||
} | ||
|
||
b = (i % 2 + (i - 1) % 2) != 1; | ||
} | ||
|
||
return 0; | ||
} |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters