summaryrefslogtreecommitdiffstats
path: root/lldb/lit/SymbolFile
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/lit/SymbolFile')
-rw-r--r--lldb/lit/SymbolFile/PDB/Inputs/ExpressionsTest.cpp20
-rw-r--r--lldb/lit/SymbolFile/PDB/Inputs/ExpressionsTest0.script7
-rw-r--r--lldb/lit/SymbolFile/PDB/Inputs/ExpressionsTest1.script1
-rw-r--r--lldb/lit/SymbolFile/PDB/Inputs/ExpressionsTest2.script2
-rw-r--r--lldb/lit/SymbolFile/PDB/expressions.test36
5 files changed, 66 insertions, 0 deletions
diff --git a/lldb/lit/SymbolFile/PDB/Inputs/ExpressionsTest.cpp b/lldb/lit/SymbolFile/PDB/Inputs/ExpressionsTest.cpp
new file mode 100644
index 00000000000..3785cd3c64c
--- /dev/null
+++ b/lldb/lit/SymbolFile/PDB/Inputs/ExpressionsTest.cpp
@@ -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;
+}
diff --git a/lldb/lit/SymbolFile/PDB/Inputs/ExpressionsTest0.script b/lldb/lit/SymbolFile/PDB/Inputs/ExpressionsTest0.script
new file mode 100644
index 00000000000..d31a2abb68a
--- /dev/null
+++ b/lldb/lit/SymbolFile/PDB/Inputs/ExpressionsTest0.script
@@ -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)
diff --git a/lldb/lit/SymbolFile/PDB/Inputs/ExpressionsTest1.script b/lldb/lit/SymbolFile/PDB/Inputs/ExpressionsTest1.script
new file mode 100644
index 00000000000..dac887faa5b
--- /dev/null
+++ b/lldb/lit/SymbolFile/PDB/Inputs/ExpressionsTest1.script
@@ -0,0 +1 @@
+print sum(buf0, 1)
diff --git a/lldb/lit/SymbolFile/PDB/Inputs/ExpressionsTest2.script b/lldb/lit/SymbolFile/PDB/Inputs/ExpressionsTest2.script
new file mode 100644
index 00000000000..b19240baf99
--- /dev/null
+++ b/lldb/lit/SymbolFile/PDB/Inputs/ExpressionsTest2.script
@@ -0,0 +1,2 @@
+print sum(buf0, result - 28)
+print sum(buf1 + 3, 3)
diff --git a/lldb/lit/SymbolFile/PDB/expressions.test b/lldb/lit/SymbolFile/PDB/expressions.test
new file mode 100644
index 00000000000..76cb334e1ae
--- /dev/null
+++ b/lldb/lit/SymbolFile/PDB/expressions.test
@@ -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'
OpenPOWER on IntegriCloud