Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PDB] Support PDB-backed expressions evaluation
Summary: This patch contains several small fixes, which makes it possible to evaluate expressions on Windows using information from PDB. The changes are: - several sanitize checks; - make IRExecutionUnit::MemoryManager::getSymbolAddress to not return a magic value on a failure, because callers wait 0 in this case; - entry point required to be a file address, not RVA, in the ObjectFilePECOFF; - do not crash on a debuggee second chance exception - it may be an expression evaluation crash; - create parameter declarations for functions in AST to make it possible to call debugee functions from expressions; - relax name searching rules for variables, functions, namespaces and types. Now it works just like in the DWARF plugin; - fix endless recursion in SymbolFilePDB::ParseCompileUnitFunctionForPDBFunc. Reviewers: zturner, asmith, stella.stamenova Reviewed By: stella.stamenova, asmith Tags: #lldb Differential Revision: https://reviews.llvm.org/D53759 llvm-svn: 347962
- Loading branch information
Aleksandr Urakov
committed
Nov 30, 2018
1 parent
b1d0148
commit e0366d1
Showing
12 changed files
with
135 additions
and
34 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
namespace N0 { | ||
namespace N1 { | ||
|
||
char *buf0 = nullptr; | ||
char buf1[] = {0, 1, 2, 3, 4, 5, 6, 7}; | ||
|
||
char sum(char *buf, int size) { | ||
char result = 0; | ||
for (int i = 0; i < size; i++) | ||
result += buf[i]; | ||
return result; | ||
} | ||
|
||
} // namespace N1 | ||
} // namespace N0 | ||
|
||
int main() { | ||
char result = N0::N1::sum(N0::N1::buf1, sizeof(N0::N1::buf1)); | ||
return 0; | ||
} |
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,7 @@ | ||
breakpoint set --file ExpressionsTest.cpp --line 19 | ||
run | ||
print result | ||
print N0::N1::sum(N0::N1::buf1, sizeof(N0::N1::buf1)) | ||
print N1::sum(N1::buf1, sizeof(N1::buf1)) | ||
print sum(buf1, sizeof(buf1)) | ||
print sum(buf1, 1000000000) |
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 @@ | ||
print sum(buf0, 1) |
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,2 @@ | ||
print sum(buf0, result - 28) | ||
print sum(buf1 + 3, 3) |
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,36 @@ | ||
REQUIRES: system-windows, msvc | ||
RUN: %msvc_cl /Zi /GS- /c %S/Inputs/ExpressionsTest.cpp /Fo%t.obj | ||
RUN: %msvc_link /debug:full /nodefaultlib /entry:main %t.obj /out:%t.exe | ||
RUN: %lldb -b -s %S/Inputs/ExpressionsTest0.script -s %S/Inputs/ExpressionsTest1.script -s %S/Inputs/ExpressionsTest2.script -- %t.exe 2>&1 | FileCheck %s | ||
|
||
// Check the variable value through `print` | ||
CHECK: (lldb) print result | ||
CHECK: (char) $0 = '\x1c' | ||
|
||
// Call the function just like in the code | ||
CHECK: (lldb) print N0::N1::sum(N0::N1::buf1, sizeof(N0::N1::buf1)) | ||
CHECK: (char) $1 = '\x1c' | ||
|
||
// Try the relaxed namespaces search | ||
CHECK: (lldb) print N1::sum(N1::buf1, sizeof(N1::buf1)) | ||
CHECK: (char) $2 = '\x1c' | ||
|
||
// Try the relaxed variables and functions search | ||
CHECK: (lldb) print sum(buf1, sizeof(buf1)) | ||
CHECK: (char) $3 = '\x1c' | ||
|
||
// Make a crash during expression calculation | ||
CHECK: (lldb) print sum(buf1, 1000000000) | ||
CHECK: The process has been returned to the state before expression evaluation. | ||
|
||
// Make one more crash | ||
CHECK: (lldb) print sum(buf0, 1) | ||
CHECK: The process has been returned to the state before expression evaluation. | ||
|
||
// Check if the process state was restored succesfully | ||
CHECK: (lldb) print sum(buf0, result - 28) | ||
CHECK: (char) $4 = '\0' | ||
|
||
// Call the function with arbitrary parameters | ||
CHECK: (lldb) print sum(buf1 + 3, 3) | ||
CHECK: (char) $5 = '\f' |
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
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
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
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