Skip to content

Commit

Permalink
Reapply "Import Dexter to debuginfo-tests""
Browse files Browse the repository at this point in the history
This reverts commit cb935f3.

Discussion in D68708 advises that green dragon is being briskly
refurbished, and it's good to have this patch up testing it.
  • Loading branch information
jmorse committed Oct 31, 2019
1 parent 34f3c0f commit 984fad2
Show file tree
Hide file tree
Showing 166 changed files with 9,920 additions and 313 deletions.
54 changes: 43 additions & 11 deletions debuginfo-tests/CMakeLists.txt
Expand Up @@ -13,15 +13,47 @@ set(DEBUGINFO_TEST_DEPS
not
)

configure_lit_site_cfg(
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
MAIN_CONFIG
${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py
)
# Wipe, uh, previous results
unset(PYTHONINTERP_FOUND CACHE)
unset(PYTHON_EXECUTABLE CACHE)
unset(PYTHON_LIBRARY CACHE)
unset(PYTHON_DLL CACHE)
unset(PYTHON_INCLUDE_DIR CACHE)
unset(PYTHON_VERSION_STRING CACHE)
unset(PYTHON_VERSION_MAJOR CACHE)
unset(PYTHON_VERSION_MINOR CACHE)
unset(PYTHON_VERSION_PATCH CACHE)
unset(PYTHONLIBS_VERSION_STRING CACHE)

add_lit_testsuite(check-debuginfo "Running debug info integration tests"
${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${DEBUGINFO_TEST_DEPS}
)
set_target_properties(check-debuginfo PROPERTIES FOLDER "Debug info tests")
# Try to find python3. If it doesn't exist, dexter tests can't run.
find_package(PythonInterp "3")
if (NOT DEFINED PYTHON_EXECUTABLE)
message(FATAL_ERROR "Cannot run debuginfo-tests without python")
elseif(PYTHON_VERSION_MAJOR LESS 3)
message(FATAL_ERROR "Cannot run debuginfo-tests without python 3")
else()
configure_lit_site_cfg(
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
MAIN_CONFIG
${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py
)

add_lit_testsuite(check-debuginfo "Running debug info integration tests"
${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${DEBUGINFO_TEST_DEPS}
)
set_target_properties(check-debuginfo PROPERTIES FOLDER "Debug info tests")
endif()

# Prevent the rest of llvm observing our secret python3-ness
unset(PYTHONINTERP_FOUND CACHE)
unset(PYTHON_EXECUTABLE CACHE)
unset(PYTHON_LIBRARY CACHE)
unset(PYTHON_DLL CACHE)
unset(PYTHON_INCLUDE_DIR CACHE)
unset(PYTHON_VERSION_STRING CACHE)
unset(PYTHON_VERSION_MAJOR CACHE)
unset(PYTHON_VERSION_MINOR CACHE)
unset(PYTHON_VERSION_PATCH CACHE)
unset(PYTHONLIBS_VERSION_STRING CACHE)
30 changes: 27 additions & 3 deletions debuginfo-tests/README.txt
@@ -1,9 +1,11 @@
-*- rst -*-
This is a collection of tests to check debugging information generated by
compiler. This test suite can be checked out inside clang/test folder. This
will enable 'make test' for clang to pick up these tests. Typically, test
cases included here includes debugger commands and intended debugger output
as comments in source file using DEBUGGER: and CHECK: as prefixes respectively.
will enable 'make test' for clang to pick up these tests.

Some tests (in the 'llgdb-tests' directory) are written with debugger
commands and checks for the intended debugger output in the source file,
using DEBUGGER: and CHECK: as prefixes respectively.

For example::

Expand All @@ -17,3 +19,25 @@ For example::

is a testcase where the debugger is asked to break at function 'f1' and
print value of argument 'i'. The expected value of 'i' is 42 in this case.

Other tests are written for use with the 'Dexter' tool (in the 'dexter-tests'
and 'dexter' directories respectively). These use a domain specific language
in comments to describe the intended debugger experience in a more abstract
way than debugger commands. This allows for testing integration across
multiple debuggers from one input language.

For example::

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')

Labels two lines with the names 'before_bar' and 'after_bar', and records that
the 'test' variable is expected to have the value 23 on both of them.
32 changes: 0 additions & 32 deletions debuginfo-tests/aggregate-indirect-arg.cpp

This file was deleted.

25 changes: 0 additions & 25 deletions debuginfo-tests/ctor.cpp

This file was deleted.

43 changes: 43 additions & 0 deletions 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'
}
}
]
})
*/

47 changes: 47 additions & 0 deletions 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')

28 changes: 28 additions & 0 deletions 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')

35 changes: 35 additions & 0 deletions 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}
}
}
]
})
*/

@@ -1,12 +1,9 @@
// This test case checks debug info during register moves for an argument.
// RUN: %clang %target_itanium_abi_host_triple -m64 -mllvm -fast-isel=false %s -c -o %t.o -g
// RUN: %clang %target_itanium_abi_host_triple -m64 %t.o -o %t.out
// RUN: %test_debuginfo %s %t.out
// REQUIRES: system-linux, lldb
//
// DEBUGGER: break 26
// DEBUGGER: r
// DEBUGGER: print mutex
// CHECK: ={{.* 0x[0-9A-Fa-f]+}}
// 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

Expand All @@ -23,7 +20,7 @@ struct _mtx

int foobar(struct _mtx *mutex) {
int r = 1;
int l = 0;
int l = 0; // DexLabel('l_assign')
int j = 0;
do {
if (mutex->waiters) {
Expand All @@ -44,3 +41,18 @@ int main() {
m.waiters = 0;
return foobar(&m);
}


/*
DexExpectProgramState({
'frames': [
{
'location': { 'lineno': 'l_assign' },
'watches': {
'*mutex': { 'is_irretrievable': False }
}
}
]
})
*/

30 changes: 30 additions & 0 deletions 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}}
}]}) */

0 comments on commit 984fad2

Please sign in to comment.