summaryrefslogtreecommitdiffstats
path: root/debuginfo-tests/dexter-tests
diff options
context:
space:
mode:
Diffstat (limited to 'debuginfo-tests/dexter-tests')
-rw-r--r--debuginfo-tests/dexter-tests/aggregate-indirect-arg.cpp43
-rw-r--r--debuginfo-tests/dexter-tests/asan-deque.cpp47
-rw-r--r--debuginfo-tests/dexter-tests/asan.c28
-rw-r--r--debuginfo-tests/dexter-tests/ctor.cpp35
-rw-r--r--debuginfo-tests/dexter-tests/dbg-arg.c58
-rw-r--r--debuginfo-tests/dexter-tests/global-constant.cpp30
-rw-r--r--debuginfo-tests/dexter-tests/hello.c13
-rw-r--r--debuginfo-tests/dexter-tests/inline-line-gap.cpp47
-rw-r--r--debuginfo-tests/dexter-tests/nrvo-string.cpp55
-rw-r--r--debuginfo-tests/dexter-tests/nrvo.cpp40
-rw-r--r--debuginfo-tests/dexter-tests/realigned-frame.cpp39
-rw-r--r--debuginfo-tests/dexter-tests/stack-var.c16
-rw-r--r--debuginfo-tests/dexter-tests/vla.c22
13 files changed, 473 insertions, 0 deletions
diff --git a/debuginfo-tests/dexter-tests/aggregate-indirect-arg.cpp b/debuginfo-tests/dexter-tests/aggregate-indirect-arg.cpp
new file mode 100644
index 00000000000..4c495c9dee3
--- /dev/null
+++ b/debuginfo-tests/dexter-tests/aggregate-indirect-arg.cpp
@@ -0,0 +1,43 @@
+// REQUIRES: system-linux, lldb
+//
+// RUN: %dexter --fail-lt 1.0 -w \
+// RUN: --builder 'clang' --debugger 'lldb' --cflags "-O0 -g" \
+// RUN: --ldflags="-lstdc++" -- %s
+// Radar 8945514
+
+class SVal {
+public:
+ ~SVal() {}
+ const void* Data;
+ unsigned Kind;
+};
+
+void bar(SVal &v) {}
+class A {
+public:
+ void foo(SVal v) { bar(v); } // DexLabel('foo')
+};
+
+int main() {
+ SVal v;
+ v.Data = 0;
+ v.Kind = 2142;
+ A a;
+ a.foo(v);
+ return 0;
+}
+
+/*
+DexExpectProgramState({
+ 'frames': [
+ {
+ 'location': { 'lineno': 'foo' },
+ 'watches': {
+ 'v.Data == 0': 'true',
+ 'v.Kind': '2142'
+ }
+ }
+ ]
+})
+*/
+
diff --git a/debuginfo-tests/dexter-tests/asan-deque.cpp b/debuginfo-tests/dexter-tests/asan-deque.cpp
new file mode 100644
index 00000000000..50fe1675048
--- /dev/null
+++ b/debuginfo-tests/dexter-tests/asan-deque.cpp
@@ -0,0 +1,47 @@
+// REQUIRES: !asan, system-linux, lldb
+// Zorg configures the ASAN stage2 bots to not build the asan
+// compiler-rt. Only run this test on non-asanified configurations.
+// UNSUPPORTED: apple-lldb-pre-1000
+
+// XFAIL: lldb
+// lldb-8, even outside of dexter, will sometimes trigger an asan fault in
+// the debugged process and generally freak out.
+
+// RUN: %dexter --fail-lt 1.0 -w \
+// RUN: --builder 'clang' --debugger 'lldb' \
+// RUN: --cflags "-O1 -glldb -fsanitize=address -arch x86_64" \
+// RUN: --ldflags="-fsanitize=address" -- %s
+#include <deque>
+
+struct A {
+ int a;
+ A(int a) : a(a) {}
+ A() : a(0) {}
+};
+
+using deq_t = std::deque<A>;
+
+template class std::deque<A>;
+
+static void __attribute__((noinline, optnone)) escape(deq_t &deq) {
+ static volatile deq_t *sink;
+ sink = &deq;
+}
+
+int main() {
+ deq_t deq;
+ deq.push_back(1234);
+ deq.push_back(56789);
+ escape(deq); // DexLabel('first')
+ while (!deq.empty()) {
+ auto record = deq.front();
+ deq.pop_front();
+ escape(deq); // DexLabel('second')
+ }
+}
+
+// DexExpectWatchValue('deq[0].a', '1234', on_line='first')
+// DexExpectWatchValue('deq[1].a', '56789', on_line='first')
+
+// DexExpectWatchValue('deq[0].a', '56789', '0', on_line='second')
+
diff --git a/debuginfo-tests/dexter-tests/asan.c b/debuginfo-tests/dexter-tests/asan.c
new file mode 100644
index 00000000000..c7d5263efd3
--- /dev/null
+++ b/debuginfo-tests/dexter-tests/asan.c
@@ -0,0 +1,28 @@
+// REQUIRES: !asan, system-linux, lldb
+// Zorg configures the ASAN stage2 bots to not build the asan
+// compiler-rt. Only run this test on non-asanified configurations.
+//
+// RUN: %dexter --fail-lt 1.0 -w \
+// RUN: --builder 'clang-c' --debugger 'lldb' \
+// RUN: --cflags "--driver-mode=gcc -O0 -glldb -fblocks -arch x86_64 \
+// RUN: -fsanitize=address" --ldflags="-fsanitize=address" -- %s
+
+struct S {
+ int a[8];
+};
+
+int f(struct S s, unsigned i) {
+ return s.a[i]; // DexLabel('asan')
+}
+
+int main(int argc, const char **argv) {
+ struct S s = {{0, 1, 2, 3, 4, 5, 6, 7}};
+ if (f(s, 4) == 4)
+ return f(s, 0);
+ return 0;
+}
+
+// DexExpectWatchValue('s.a[0]', '0', on_line='asan')
+// DexExpectWatchValue('s.a[1]', '1', on_line='asan')
+// DexExpectWatchValue('s.a[7]', '7', on_line='asan')
+
diff --git a/debuginfo-tests/dexter-tests/ctor.cpp b/debuginfo-tests/dexter-tests/ctor.cpp
new file mode 100644
index 00000000000..77195d7d79e
--- /dev/null
+++ b/debuginfo-tests/dexter-tests/ctor.cpp
@@ -0,0 +1,35 @@
+// REQUIRES: system-linux, lldb
+//
+// RUN: %dexter --fail-lt 1.0 -w \
+// RUN: --builder 'clang' --debugger 'lldb' --cflags "-O0 -glldb" -- %s
+
+class A {
+public:
+ A() : zero(0), data(42) { // DexLabel('ctor_start')
+ }
+private:
+ int zero;
+ int data;
+};
+
+int main() {
+ A a;
+ return 0;
+}
+
+
+/*
+DexExpectProgramState({
+ 'frames': [
+ {
+ 'location': {
+ 'lineno': 'ctor_start'
+ },
+ 'watches': {
+ '*this': {'is_irretrievable': False}
+ }
+ }
+ ]
+})
+*/
+
diff --git a/debuginfo-tests/dexter-tests/dbg-arg.c b/debuginfo-tests/dexter-tests/dbg-arg.c
new file mode 100644
index 00000000000..7d0ef7b6b70
--- /dev/null
+++ b/debuginfo-tests/dexter-tests/dbg-arg.c
@@ -0,0 +1,58 @@
+// REQUIRES: system-linux, lldb
+//
+// This test case checks debug info during register moves for an argument.
+// RUN: %dexter --fail-lt 1.0 -w \
+// RUN: --builder clang-c --debugger 'lldb' \
+// RUN: --cflags "-m64 -mllvm -fast-isel=false -g" -- %s
+//
+// Radar 8412415
+
+struct _mtx
+{
+ long unsigned int ptr;
+ int waiters;
+ struct {
+ int tag;
+ int pad;
+ } mtxi;
+};
+
+
+int foobar(struct _mtx *mutex) {
+ int r = 1;
+ int l = 0; // DexLabel('l_assign')
+ int j = 0;
+ do {
+ if (mutex->waiters) {
+ r = 2;
+ }
+ j = bar(r, l);
+ ++l;
+ } while (l < j);
+ return r + j;
+}
+
+int bar(int i, int j) {
+ return i + j;
+}
+
+int main() {
+ struct _mtx m;
+ m.waiters = 0;
+ return foobar(&m);
+}
+
+
+/*
+DexExpectProgramState({
+ 'frames': [
+ {
+ 'location': { 'lineno': 'l_assign' },
+ 'watches': {
+ '*mutex': { 'is_irretrievable': False }
+ }
+ }
+ ]
+})
+*/
+
diff --git a/debuginfo-tests/dexter-tests/global-constant.cpp b/debuginfo-tests/dexter-tests/global-constant.cpp
new file mode 100644
index 00000000000..faad72a85ed
--- /dev/null
+++ b/debuginfo-tests/dexter-tests/global-constant.cpp
@@ -0,0 +1,30 @@
+// REQUIRES: system-windows
+//
+// RUN: %dexter --fail-lt 1.0 -w --builder 'clang-cl_vs2015' \
+// RUN: --debugger 'dbgeng' --cflags '/Z7 /Zi' --ldflags '/Z7 /Zi' -- %s
+
+// Check that global constants have debug info.
+
+const float TestPi = 3.14;
+struct S {
+ static const char TestCharA = 'a';
+};
+enum TestEnum : int {
+ ENUM_POS = 2147000000,
+ ENUM_NEG = -2147000000,
+};
+void useConst(int) {}
+int main() {
+ useConst(TestPi);
+ useConst(S::TestCharA);
+ useConst(ENUM_NEG); // DexLabel('stop')
+ return 0;
+}
+
+// DexExpectWatchValue('TestPi', 3.140000104904175, on_line='stop')
+// DexExpectWatchValue('S::TestCharA', 97, on_line='stop')
+// DexExpectWatchValue('ENUM_NEG', -2147000000, on_line='stop')
+/* DexExpectProgramState({'frames': [{
+ 'location': {'lineno' : 'stop'},
+ 'watches': {'ENUM_POS' : {'is_irretrievable': True}}
+}]}) */
diff --git a/debuginfo-tests/dexter-tests/hello.c b/debuginfo-tests/dexter-tests/hello.c
new file mode 100644
index 00000000000..bd94646aae6
--- /dev/null
+++ b/debuginfo-tests/dexter-tests/hello.c
@@ -0,0 +1,13 @@
+// REQUIRES: system-windows
+//
+// RUN: %dexter --fail-lt 1.0 -w --builder 'clang-cl_vs2015' \
+// RUN: --debugger 'dbgeng' --cflags '/Z7 /Zi' --ldflags '/Z7 /Zi' -- %s
+
+#include <stdio.h>
+int main() {
+ printf("hello world\n");
+ int x = 42;
+ __debugbreak(); // DexLabel('stop')
+}
+
+// DexExpectWatchValue('x', 42, on_line='stop')
diff --git a/debuginfo-tests/dexter-tests/inline-line-gap.cpp b/debuginfo-tests/dexter-tests/inline-line-gap.cpp
new file mode 100644
index 00000000000..211ab06ae64
--- /dev/null
+++ b/debuginfo-tests/dexter-tests/inline-line-gap.cpp
@@ -0,0 +1,47 @@
+// REQUIRES: system-windows
+//
+// RUN: %dexter --fail-lt 1.0 -w --builder 'clang-cl_vs2015' \
+// RUN: --debugger 'dbgeng' --cflags '/Od /Z7 /Zi' \
+// RUN: --ldflags '/Od /Z7 /Zi' -- %s
+//
+// RUN: %dexter --fail-lt 1.0 -w --builder 'clang-cl_vs2015' \
+// RUN: --debugger 'dbgeng' --cflags '/O2 /Z7 /Zi' \
+// RUN: --ldflags '/O2 /Z7 /Zi' -- %s
+
+// This code is structured to have an early exit with an epilogue in the middle
+// of the function, which creates a gap between the beginning of the inlined
+// code region and the end. Previously, this confused cdb.
+
+volatile bool shutting_down_ = true;
+volatile bool tearing_down_ = true;
+
+void __attribute__((optnone)) setCrashString(const char *) {}
+void __attribute__((optnone)) doTailCall() {}
+extern "C" void __declspec(noreturn) abort();
+
+void __forceinline inlineCrashFrame() {
+ if (shutting_down_ || tearing_down_) {
+ setCrashString("crashing");
+ // MSVC lays out calls to abort out of line, gets the layout we want.
+ abort(); // DexLabel('stop')
+ }
+}
+
+void __declspec(noinline) callerOfInlineCrashFrame(bool is_keeping_alive) {
+ if (is_keeping_alive)
+ inlineCrashFrame();
+ else
+ doTailCall();
+}
+
+int __attribute__((optnone)) main() {
+ callerOfInlineCrashFrame(true);
+}
+
+/*
+DexExpectProgramState({'frames':[
+ {'function': 'inlineCrashFrame', 'location':{'lineno' : 'stop'} },
+ {'function': 'callerOfInlineCrashFrame'},
+ {'function': 'main'}
+]})
+*/
diff --git a/debuginfo-tests/dexter-tests/nrvo-string.cpp b/debuginfo-tests/dexter-tests/nrvo-string.cpp
new file mode 100644
index 00000000000..79561dc6e2f
--- /dev/null
+++ b/debuginfo-tests/dexter-tests/nrvo-string.cpp
@@ -0,0 +1,55 @@
+// Purpose:
+// This ensures that DW_OP_deref is inserted when necessary, such as when
+// NRVO of a string object occurs in C++.
+//
+// REQUIRES: !asan, system-linux, lldb
+// Zorg configures the ASAN stage2 bots to not build the asan
+// compiler-rt. Only run this test on non-asanified configurations.
+//
+// RUN: %dexter --fail-lt 1.0 -w \
+// RUN: --builder 'clang' --debugger 'lldb' \
+// RUN: --cflags "-O0 -glldb -fno-exceptions" -- %s
+//
+// RUN: %dexter --fail-lt 1.0 -w \
+// RUN: --builder 'clang' --debugger 'lldb' \
+// RUN: --cflags "-O1 -glldb -fno-exceptions" -- %s
+//
+// PR34513
+volatile int sideeffect = 0;
+void __attribute__((noinline)) stop() { sideeffect++; }
+
+struct string {
+ string() {}
+ string(int i) : i(i) {}
+ ~string() {}
+ int i = 0;
+};
+string get_string() {
+ string unused;
+ string output = 3;
+ stop(); // DexLabel('string-nrvo')
+ return output;
+}
+void some_function(int) {}
+struct string2 {
+ string2() = default;
+ string2(string2 &&other) { i = other.i; }
+ int i;
+};
+string2 get_string2() {
+ string2 output;
+ output.i = 5;
+ some_function(output.i);
+ // Test that the debugger can get the value of output after another
+ // function is called.
+ stop(); // DexLabel('string2-nrvo')
+ return output;
+}
+int main() {
+ get_string();
+ get_string2();
+}
+
+// DexExpectWatchValue('output.i', 3, on_line='string-nrvo')
+// DexExpectWatchValue('output.i', 5, on_line='string2-nrvo')
+
diff --git a/debuginfo-tests/dexter-tests/nrvo.cpp b/debuginfo-tests/dexter-tests/nrvo.cpp
new file mode 100644
index 00000000000..9ce0197766a
--- /dev/null
+++ b/debuginfo-tests/dexter-tests/nrvo.cpp
@@ -0,0 +1,40 @@
+// This ensures that DW_OP_deref is inserted when necessary, such as when NRVO
+// of a string object occurs in C++.
+//
+// REQUIRES: system-windows
+//
+// RUN: %dexter --fail-lt 1.0 -w --builder 'clang-cl_vs2015' \
+// RUN: --debugger 'dbgeng' --cflags '/Z7 /Zi' --ldflags '/Z7 /Zi' -- %s
+
+struct string {
+ string() {}
+ string(int i) : i(i) {}
+ ~string() {}
+ int i = 0;
+};
+string get_string() {
+ string unused;
+ string result = 3;
+ return result; // DexLabel('readresult1')
+}
+void some_function(int) {}
+struct string2 {
+ string2() = default;
+ string2(string2 &&other) { i = other.i; }
+ int i;
+};
+string2 get_string2() {
+ string2 result;
+ result.i = 5;
+ some_function(result.i);
+ // Test that the debugger can get the value of result after another
+ // function is called.
+ return result; // DexLabel('readresult2')
+}
+int main() {
+ get_string();
+ get_string2();
+}
+
+// DexExpectWatchValue('result.i', 3, on_line='readresult1')
+// DexExpectWatchValue('result.i', 5, on_line='readresult2')
diff --git a/debuginfo-tests/dexter-tests/realigned-frame.cpp b/debuginfo-tests/dexter-tests/realigned-frame.cpp
new file mode 100644
index 00000000000..3d3c086cd17
--- /dev/null
+++ b/debuginfo-tests/dexter-tests/realigned-frame.cpp
@@ -0,0 +1,39 @@
+// REQUIRES: system-windows
+//
+// RUN: %dexter --fail-lt 1.0 -w --builder 'clang-cl_vs2015' \
+// RUN: --debugger 'dbgeng' --cflags '/Z7 /Zi' --ldflags '/Z7 /Zi' -- %s
+
+// From https://llvm.org/pr38857, where we had issues with stack realignment.
+
+struct Foo {
+ int x = 42;
+ int __declspec(noinline) foo();
+ void __declspec(noinline) bar(int *a, int *b, double *c);
+};
+int Foo::foo() {
+ int a = 1;
+ int b = 2;
+ double __declspec(align(32)) force_alignment = 0.42;
+ bar(&a, &b, &force_alignment); // DexLabel('in_foo')
+ x += (int)force_alignment;
+ return x;
+}
+void Foo::bar(int *a, int *b, double *c) {
+ *c += *a + *b; // DexLabel('in_bar')
+}
+int main() {
+ Foo o;
+ o.foo();
+}
+/*
+DexExpectProgramState({'frames':[
+ {'function': 'Foo::bar', 'location' : {'lineno' : 'in_bar'} },
+ {'function': 'Foo::foo',
+ 'watches' : {
+ 'a' : '1',
+ 'b' : '2',
+ 'force_alignment' : '0.42'
+ }
+ }
+]})
+*/
diff --git a/debuginfo-tests/dexter-tests/stack-var.c b/debuginfo-tests/dexter-tests/stack-var.c
new file mode 100644
index 00000000000..15321b0ab14
--- /dev/null
+++ b/debuginfo-tests/dexter-tests/stack-var.c
@@ -0,0 +1,16 @@
+// REQUIRES: system-linux, lldb
+//
+// RUN: %dexter --fail-lt 1.0 -w \
+// RUN: --builder clang-c --debugger 'lldb' --cflags "-O -glldb" -- %s
+
+void __attribute__((noinline, optnone)) bar(int *test) {}
+int main() {
+ int test;
+ test = 23;
+ bar(&test); // DexLabel('before_bar')
+ return test; // DexLabel('after_bar')
+}
+
+// DexExpectWatchValue('test', '23', on_line='before_bar')
+// DexExpectWatchValue('test', '23', on_line='after_bar')
+
diff --git a/debuginfo-tests/dexter-tests/vla.c b/debuginfo-tests/dexter-tests/vla.c
new file mode 100644
index 00000000000..a06bf3c8170
--- /dev/null
+++ b/debuginfo-tests/dexter-tests/vla.c
@@ -0,0 +1,22 @@
+// This test case verifies the debug location for variable-length arrays.
+// REQUIRES: system-linux, lldb
+//
+// RUN: %dexter --fail-lt 1.0 -w \
+// RUN: --builder clang-c --debugger 'lldb' --cflags "-O0 -glldb" -- %s
+
+void init_vla(int size) {
+ int i;
+ int vla[size];
+ for (i = 0; i < size; i++)
+ vla[i] = size-i;
+ vla[0] = size; // DexLabel('end_init')
+}
+
+int main(int argc, const char **argv) {
+ init_vla(23);
+ return 0;
+}
+
+// DexExpectWatchValue('vla[0]', '23', on_line='end_init')
+// DexExpectWatchValue('vla[1]', '22', on_line='end_init')
+
OpenPOWER on IntegriCloud