# test_exec_root: The root path where tests should be run.
config.test_exec_root = config.debuginfo_tests_obj_root
+tools = [
+ ToolSubst('%test_debuginfo', command=os.path.join(
+ config.debuginfo_tests_src_root, 'test_debuginfo.pl')),
+]
+
+def get_required_attr(config, attr_name):
+ attr_value = getattr(config, attr_name, None)
+ if attr_value == None:
+ lit_config.fatal(
+ "No attribute %r in test configuration! You may need to run "
+ "tests from your build directory or add this attribute "
+ "to lit.site.cfg " % attr_name)
+ return attr_value
+
+# If this is an MSVC environment, the tests at the root of the tree are
+# unsupported. The local win_cdb test suite, however, is supported.
+is_msvc = get_required_attr(config, "is_msvc")
+if is_msvc:
+ # FIXME: We should add some llvm lit utility code to find the Windows SDK
+ # and set up the environment appopriately.
+ win_sdk = 'C:/Program Files (x86)/Windows Kits/10/'
+ arch = 'x64'
+ config.unsupported = True
+ llvm_config.with_system_environment(['LIB', 'LIBPATH', 'INCLUDE'])
+ # Clear _NT_SYMBOL_PATH to prevent cdb from attempting to load symbols from
+ # the network.
+ llvm_config.with_environment('_NT_SYMBOL_PATH', '')
+ tools.append(ToolSubst('%cdb', '"%s"' % os.path.join(win_sdk, 'Debuggers',
+ arch, 'cdb.exe')))
+
llvm_config.use_default_substitutions()
# clang_src_dir is not used by these tests, but is required by
tool_dirs = [config.llvm_tools_dir]
-tools = [
- ToolSubst('%test_debuginfo', command=os.path.join(
- config.debuginfo_tests_src_root, 'test_debuginfo.pl')),
-]
-
llvm_config.add_tool_substitutions(tools, tool_dirs)
lit.util.usePlatformSdkOnDarwin(config, lit_config)
--- /dev/null
+These are debug info integration tests similar to the ones in the parent
+directory, except that these are designed to test compatibility between clang,
+lld, and cdb, the command line debugger that ships as part of the Microsoft
+Windows SDK. The debugger command language that cdb uses is very different from
+gdb and LLDB, so it's useful to be able to write some tests directly in the cdb
+command language.
--- /dev/null
+// RUN: %clang_cl %s -o %t.exe -fuse-ld=lld -Z7
+// RUN: grep DE[B]UGGER: %s | sed -e 's/.*DE[B]UGGER: //' > %t.script
+// RUN: %cdb -cf %t.script %t.exe | FileCheck %s --check-prefixes=DEBUGGER,CHECK
+
+// 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);
+ // DEBUGGER: g
+ // DEBUGGER: .frame 1
+ // DEBUGGER: dv
+ // CHECK: a = 0n1
+ // CHECK: b = 0n2
+ // CHECK: force_alignment = 0.41999{{.*}}
+ // DEBUGGER: q
+ x += (int)force_alignment;
+ return x;
+}
+void Foo::bar(int *a, int *b, double *c) {
+ __debugbreak();
+ *c += *a + *b;
+}
+int main() {
+ Foo o;
+ o.foo();
+}