Skip to content

Commit f78c236

Browse files
committed
Import Dexter to debuginfo-tests
Dexter (Debug Experience Tester) is a test-driver for our debug info integration tests, reading a set of debug experience expectations and comparing them with the actual behaviour of a program under a debugger. More about Dexter can be found in the RFC: http://lists.llvm.org/pipermail/llvm-dev/2019-October/135773.html and the phab review in D68708. Not all the debuginfo tests have been transformed into Dexter tests, and we look forwards to doing that incrementally. This commit mostly aims to flush out buildbots that are running debuginfo-tests but don't have python 3 installed, possibly green-dragon and some windows bots.
1 parent efacf2c commit f78c236

File tree

166 files changed

+9920
-313
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

166 files changed

+9920
-313
lines changed

debuginfo-tests/CMakeLists.txt

Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,47 @@ set(DEBUGINFO_TEST_DEPS
1313
not
1414
)
1515

16-
configure_lit_site_cfg(
17-
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
18-
${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
19-
MAIN_CONFIG
20-
${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py
21-
)
16+
# Wipe, uh, previous results
17+
unset(PYTHONINTERP_FOUND CACHE)
18+
unset(PYTHON_EXECUTABLE CACHE)
19+
unset(PYTHON_LIBRARY CACHE)
20+
unset(PYTHON_DLL CACHE)
21+
unset(PYTHON_INCLUDE_DIR CACHE)
22+
unset(PYTHON_VERSION_STRING CACHE)
23+
unset(PYTHON_VERSION_MAJOR CACHE)
24+
unset(PYTHON_VERSION_MINOR CACHE)
25+
unset(PYTHON_VERSION_PATCH CACHE)
26+
unset(PYTHONLIBS_VERSION_STRING CACHE)
2227

23-
add_lit_testsuite(check-debuginfo "Running debug info integration tests"
24-
${CMAKE_CURRENT_BINARY_DIR}
25-
DEPENDS ${DEBUGINFO_TEST_DEPS}
26-
)
27-
set_target_properties(check-debuginfo PROPERTIES FOLDER "Debug info tests")
28+
# Try to find python3. If it doesn't exist, dexter tests can't run.
29+
find_package(PythonInterp "3")
30+
if (NOT DEFINED PYTHON_EXECUTABLE)
31+
message(FATAL_ERROR "Cannot run debuginfo-tests without python")
32+
elseif(PYTHON_VERSION_MAJOR LESS 3)
33+
message(FATAL_ERROR "Cannot run debuginfo-tests without python 3")
34+
else()
35+
configure_lit_site_cfg(
36+
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
37+
${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
38+
MAIN_CONFIG
39+
${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py
40+
)
41+
42+
add_lit_testsuite(check-debuginfo "Running debug info integration tests"
43+
${CMAKE_CURRENT_BINARY_DIR}
44+
DEPENDS ${DEBUGINFO_TEST_DEPS}
45+
)
46+
set_target_properties(check-debuginfo PROPERTIES FOLDER "Debug info tests")
47+
endif()
48+
49+
# Prevent the rest of llvm observing our secret python3-ness
50+
unset(PYTHONINTERP_FOUND CACHE)
51+
unset(PYTHON_EXECUTABLE CACHE)
52+
unset(PYTHON_LIBRARY CACHE)
53+
unset(PYTHON_DLL CACHE)
54+
unset(PYTHON_INCLUDE_DIR CACHE)
55+
unset(PYTHON_VERSION_STRING CACHE)
56+
unset(PYTHON_VERSION_MAJOR CACHE)
57+
unset(PYTHON_VERSION_MINOR CACHE)
58+
unset(PYTHON_VERSION_PATCH CACHE)
59+
unset(PYTHONLIBS_VERSION_STRING CACHE)

debuginfo-tests/README.txt

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
-*- rst -*-
22
This is a collection of tests to check debugging information generated by
33
compiler. This test suite can be checked out inside clang/test folder. This
4-
will enable 'make test' for clang to pick up these tests. Typically, test
5-
cases included here includes debugger commands and intended debugger output
6-
as comments in source file using DEBUGGER: and CHECK: as prefixes respectively.
4+
will enable 'make test' for clang to pick up these tests.
5+
6+
Some tests (in the 'llgdb-tests' directory) are written with debugger
7+
commands and checks for the intended debugger output in the source file,
8+
using DEBUGGER: and CHECK: as prefixes respectively.
79

810
For example::
911

@@ -17,3 +19,25 @@ For example::
1719

1820
is a testcase where the debugger is asked to break at function 'f1' and
1921
print value of argument 'i'. The expected value of 'i' is 42 in this case.
22+
23+
Other tests are written for use with the 'Dexter' tool (in the 'dexter-tests'
24+
and 'dexter' directories respectively). These use a domain specific language
25+
in comments to describe the intended debugger experience in a more abstract
26+
way than debugger commands. This allows for testing integration across
27+
multiple debuggers from one input language.
28+
29+
For example::
30+
31+
void __attribute__((noinline, optnone)) bar(int *test) {}
32+
int main() {
33+
int test;
34+
test = 23;
35+
bar(&test); // DexLabel('before_bar')
36+
return test; // DexLabel('after_bar')
37+
}
38+
39+
// DexExpectWatchValue('test', '23', on_line='before_bar')
40+
// DexExpectWatchValue('test', '23', on_line='after_bar')
41+
42+
Labels two lines with the names 'before_bar' and 'after_bar', and records that
43+
the 'test' variable is expected to have the value 23 on both of them.

debuginfo-tests/aggregate-indirect-arg.cpp

Lines changed: 0 additions & 32 deletions
This file was deleted.

debuginfo-tests/ctor.cpp

Lines changed: 0 additions & 25 deletions
This file was deleted.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// REQUIRES: system-linux, lldb
2+
//
3+
// RUN: %dexter --fail-lt 1.0 -w \
4+
// RUN: --builder 'clang' --debugger 'lldb' --cflags "-O0 -g" \
5+
// RUN: --ldflags="-lstdc++" -- %s
6+
// Radar 8945514
7+
8+
class SVal {
9+
public:
10+
~SVal() {}
11+
const void* Data;
12+
unsigned Kind;
13+
};
14+
15+
void bar(SVal &v) {}
16+
class A {
17+
public:
18+
void foo(SVal v) { bar(v); } // DexLabel('foo')
19+
};
20+
21+
int main() {
22+
SVal v;
23+
v.Data = 0;
24+
v.Kind = 2142;
25+
A a;
26+
a.foo(v);
27+
return 0;
28+
}
29+
30+
/*
31+
DexExpectProgramState({
32+
'frames': [
33+
{
34+
'location': { 'lineno': 'foo' },
35+
'watches': {
36+
'v.Data == 0': 'true',
37+
'v.Kind': '2142'
38+
}
39+
}
40+
]
41+
})
42+
*/
43+
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// REQUIRES: !asan, system-linux, lldb
2+
// Zorg configures the ASAN stage2 bots to not build the asan
3+
// compiler-rt. Only run this test on non-asanified configurations.
4+
// UNSUPPORTED: apple-lldb-pre-1000
5+
6+
// XFAIL: lldb
7+
// lldb-8, even outside of dexter, will sometimes trigger an asan fault in
8+
// the debugged process and generally freak out.
9+
10+
// RUN: %dexter --fail-lt 1.0 -w \
11+
// RUN: --builder 'clang' --debugger 'lldb' \
12+
// RUN: --cflags "-O1 -glldb -fsanitize=address -arch x86_64" \
13+
// RUN: --ldflags="-fsanitize=address" -- %s
14+
#include <deque>
15+
16+
struct A {
17+
int a;
18+
A(int a) : a(a) {}
19+
A() : a(0) {}
20+
};
21+
22+
using deq_t = std::deque<A>;
23+
24+
template class std::deque<A>;
25+
26+
static void __attribute__((noinline, optnone)) escape(deq_t &deq) {
27+
static volatile deq_t *sink;
28+
sink = &deq;
29+
}
30+
31+
int main() {
32+
deq_t deq;
33+
deq.push_back(1234);
34+
deq.push_back(56789);
35+
escape(deq); // DexLabel('first')
36+
while (!deq.empty()) {
37+
auto record = deq.front();
38+
deq.pop_front();
39+
escape(deq); // DexLabel('second')
40+
}
41+
}
42+
43+
// DexExpectWatchValue('deq[0].a', '1234', on_line='first')
44+
// DexExpectWatchValue('deq[1].a', '56789', on_line='first')
45+
46+
// DexExpectWatchValue('deq[0].a', '56789', '0', on_line='second')
47+
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// REQUIRES: !asan, system-linux, lldb
2+
// Zorg configures the ASAN stage2 bots to not build the asan
3+
// compiler-rt. Only run this test on non-asanified configurations.
4+
//
5+
// RUN: %dexter --fail-lt 1.0 -w \
6+
// RUN: --builder 'clang-c' --debugger 'lldb' \
7+
// RUN: --cflags "--driver-mode=gcc -O0 -glldb -fblocks -arch x86_64 \
8+
// RUN: -fsanitize=address" --ldflags="-fsanitize=address" -- %s
9+
10+
struct S {
11+
int a[8];
12+
};
13+
14+
int f(struct S s, unsigned i) {
15+
return s.a[i]; // DexLabel('asan')
16+
}
17+
18+
int main(int argc, const char **argv) {
19+
struct S s = {{0, 1, 2, 3, 4, 5, 6, 7}};
20+
if (f(s, 4) == 4)
21+
return f(s, 0);
22+
return 0;
23+
}
24+
25+
// DexExpectWatchValue('s.a[0]', '0', on_line='asan')
26+
// DexExpectWatchValue('s.a[1]', '1', on_line='asan')
27+
// DexExpectWatchValue('s.a[7]', '7', on_line='asan')
28+
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// REQUIRES: system-linux, lldb
2+
//
3+
// RUN: %dexter --fail-lt 1.0 -w \
4+
// RUN: --builder 'clang' --debugger 'lldb' --cflags "-O0 -glldb" -- %s
5+
6+
class A {
7+
public:
8+
A() : zero(0), data(42) { // DexLabel('ctor_start')
9+
}
10+
private:
11+
int zero;
12+
int data;
13+
};
14+
15+
int main() {
16+
A a;
17+
return 0;
18+
}
19+
20+
21+
/*
22+
DexExpectProgramState({
23+
'frames': [
24+
{
25+
'location': {
26+
'lineno': 'ctor_start'
27+
},
28+
'watches': {
29+
'*this': {'is_irretrievable': False}
30+
}
31+
}
32+
]
33+
})
34+
*/
35+
Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
// This test case checks debug info during register moves for an argument.
2-
// RUN: %clang %target_itanium_abi_host_triple -m64 -mllvm -fast-isel=false %s -c -o %t.o -g
3-
// RUN: %clang %target_itanium_abi_host_triple -m64 %t.o -o %t.out
4-
// RUN: %test_debuginfo %s %t.out
1+
// REQUIRES: system-linux, lldb
52
//
6-
// DEBUGGER: break 26
7-
// DEBUGGER: r
8-
// DEBUGGER: print mutex
9-
// CHECK: ={{.* 0x[0-9A-Fa-f]+}}
3+
// This test case checks debug info during register moves for an argument.
4+
// RUN: %dexter --fail-lt 1.0 -w \
5+
// RUN: --builder clang-c --debugger 'lldb' \
6+
// RUN: --cflags "-m64 -mllvm -fast-isel=false -g" -- %s
107
//
118
// Radar 8412415
129

@@ -23,7 +20,7 @@ struct _mtx
2320

2421
int foobar(struct _mtx *mutex) {
2522
int r = 1;
26-
int l = 0;
23+
int l = 0; // DexLabel('l_assign')
2724
int j = 0;
2825
do {
2926
if (mutex->waiters) {
@@ -44,3 +41,18 @@ int main() {
4441
m.waiters = 0;
4542
return foobar(&m);
4643
}
44+
45+
46+
/*
47+
DexExpectProgramState({
48+
'frames': [
49+
{
50+
'location': { 'lineno': 'l_assign' },
51+
'watches': {
52+
'*mutex': { 'is_irretrievable': False }
53+
}
54+
}
55+
]
56+
})
57+
*/
58+
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// REQUIRES: system-windows
2+
//
3+
// RUN: %dexter --fail-lt 1.0 -w --builder 'clang-cl_vs2015' \
4+
// RUN: --debugger 'dbgeng' --cflags '/Z7 /Zi' --ldflags '/Z7 /Zi' -- %s
5+
6+
// Check that global constants have debug info.
7+
8+
const float TestPi = 3.14;
9+
struct S {
10+
static const char TestCharA = 'a';
11+
};
12+
enum TestEnum : int {
13+
ENUM_POS = 2147000000,
14+
ENUM_NEG = -2147000000,
15+
};
16+
void useConst(int) {}
17+
int main() {
18+
useConst(TestPi);
19+
useConst(S::TestCharA);
20+
useConst(ENUM_NEG); // DexLabel('stop')
21+
return 0;
22+
}
23+
24+
// DexExpectWatchValue('TestPi', 3.140000104904175, on_line='stop')
25+
// DexExpectWatchValue('S::TestCharA', 97, on_line='stop')
26+
// DexExpectWatchValue('ENUM_NEG', -2147000000, on_line='stop')
27+
/* DexExpectProgramState({'frames': [{
28+
'location': {'lineno' : 'stop'},
29+
'watches': {'ENUM_POS' : {'is_irretrievable': True}}
30+
}]}) */

0 commit comments

Comments
 (0)