Fix some issues with LLDB's lit configuration files.

Recently I tried to port LLDB's lit configuration files over to use a
on the surface, but broke some cases that weren't broken before and also
exposed some additional problems with the old approach that we were just
getting lucky with.

When we set up a lit environment, the goal is to make it as hermetic as
possible. We should not be relying on PATH and enabling the use of
arbitrary shell commands. Instead, only whitelisted commands should be
allowed. These are, generally speaking, the lit builtins such as echo,
cd, etc, as well as anything for which substitutions have been
explicitly set up for. These substitutions should map to the build
output directory, but in some cases it's useful to be able to override
this (for example to point to an installed tools directory).

This is, of course, how it's supposed to work. What was actually
happening is that we were bringing in PATH and LD_LIBRARY_PATH and then
just running the given run line as a shell command. This led to problems
such as finding the wrong version of clang-cl on PATH since it wasn't
even a substitution, and flakiness / non-determinism since the
environment the tests were running in would change per-machine. On the
other hand, it also made other things possible. For example, we had some
tests that were explicitly running cl.exe and link.exe instead of
clang-cl and lld-link and the only reason it worked at all is because it
was finding them on PATH. Unfortunately we can't entirely get rid of
these tests, because they support a few things in debug info that
clang-cl and lld-link don't (notably, the LF_UDT_MOD_SRC_LINE record
which makes some of the tests fail.

The high level changes introduced in this patch are:

1. Removal of functionality - The lit test suite no longer respects
   LLDB_TEST_C_COMPILER and LLDB_TEST_CXX_COMPILER. This means there is no
   more support for gcc, but nobody was using this anyway (note: The
   functionality is still there for the dotest suite, just not the lit test
   suite). There is no longer a single substitution %cxx and %cc which maps
   to <arbitrary-compiler>, you now explicitly specify the compiler with a
   substitution like %clang or %clangxx or %clang_cl. We can revisit this
   in the future when someone needs gcc.

2. Introduction of the LLDB_LIT_TOOLS_DIR directory. This does in spirit
   what LLDB_TEST_C_COMPILER and LLDB_TEST_CXX_COMPILER used to do, but now
   more friendly. If this is not specified, all tools are expected to be
   the just-built tools. If it is specified, the tools which are not
   themselves being tested but are being used to construct and run checks
   (e.g. clang, FileCheck, llvm-mc, etc) will be searched for in this
   directory first, then the build output directory.

3. Changes to core llvm lit files. The use_lld() and use_clang()
   functions were introduced long ago in anticipation of using them in
   lldb, but since they were never actually used anywhere but their
   respective problems, there were some issues to be resolved regarding
   generality and ability to use them outside their project.

4. Changes to .test files - These are all just replacing things like
   clang-cl with %clang_cl and %cxx with %clangxx, etc.

5. Changes to lit.cfg.py - Previously we would load up some system
   environment variables and then add some new things to them. Then do a
   bunch of work building out our own substitutions. First, we delete the
   system environment variable code, making the environment hermetic. Then,
   we refactor the substitution logic into two separate helper functions,
   one which sets up substitutions for the tools we want to test (which
   must come from the build output directory), and another which sets up
   substitutions for support tools (like compilers, etc).

6. New substitutions for MSVC -- Previously we relied on location of
   MSVC by bringing in the entire parent's PATH and letting
   subprocess.Popen just run the command line. Now we set up real
   substitutions that should have the same effect. We use PATH to find
   them, and then look for INCLUDE and LIB to construct a substitution
   command line with appropriate /I and /LIBPATH: arguments. The nice thing
   about this is that it opens the door to having separate %msvc-cl32 and
   %msvc-cl64 substitutions, rather than only requiring the user to run
   vcvars first. Because we can deduce the path to 32-bit libraries from
   64-bit library directories, and vice versa. Without these substitutions
   this would have been impossible.

Differential Revision: https://reviews.llvm.org/D54567

llvm-svn: 347216
This commit is contained in:
Zachary Turner
2018-11-19 15:12:34 +00:00
parent 3a3d688cc8
commit 58db03a116
74 changed files with 313 additions and 229 deletions

View File

@@ -43,6 +43,10 @@ llvm_config.use_default_substitutions()
llvm_config.use_clang()
config.substitutions.append(
('%src_include_dir', config.clang_src_dir + '/include'))
# Propagate path to symbolizer for ASan/MSan.
llvm_config.with_system_environment(
['ASAN_SYMBOLIZER_PATH', 'MSAN_SYMBOLIZER_PATH'])

View File

@@ -2,7 +2,7 @@
# XFAIL: system-windows
# -> llvm.org/pr24528
#
# RUN: %cc %p/Inputs/case-sensitive.c -g -o %t
# RUN: %clang %p/Inputs/case-sensitive.c -g -o %t
# RUN: lldb-test breakpoints %t %s | FileCheck %s
breakpoint set -f case-sensitive.c -l 3

View File

@@ -1,6 +1,6 @@
# REQUIRES: nowindows
#
# RUN: %cc %p/Inputs/case-sensitive.c -g -o %t
# RUN: %clang %p/Inputs/case-sensitive.c -g -o %t
# RUN: lldb-test breakpoints %t %s | FileCheck %s
breakpoint set -f case-sensitive.c -l 3

View File

@@ -1,4 +1,4 @@
# RUN: %cxx %p/Inputs/stop-hook-threads.cpp -g -o %t
# RUN: %clangxx %p/Inputs/stop-hook-threads.cpp -g -o %t
# RUN: %lldb -b -s %p/Inputs/stop-hook-threads-1.lldbinit -s %s -f %t \
# RUN: | FileCheck --check-prefix=CHECK --check-prefix=CHECK-NO-FILTER %s
# RUN: %lldb -b -s %p/Inputs/stop-hook-threads-2.lldbinit -s %s -f %t \

View File

@@ -1,4 +1,4 @@
# RUN: %cc %p/Inputs/stop-hook.c -g -o %t
# RUN: %clang %p/Inputs/stop-hook.c -g -o %t
# Test setting stop-hook per-function
# RUN: %lldb -b -s %p/Inputs/stop-hook-1.lldbinit -s %s -f %t \
# RUN: | FileCheck --check-prefix=CHECK --check-prefix=CHECK-FUNC %s

View File

@@ -1,6 +1,6 @@
# UNSUPPORTED: windows
# RUN: %cxx %p/Inputs/call-function.cpp -g -o %t
# RUN: %clangxx %p/Inputs/call-function.cpp -g -o %t
# RUN: lldb-test ir-memory-map %t %S/Inputs/ir-memory-map-basic
# RUN: lldb-test ir-memory-map -host-only %t %S/Inputs/ir-memory-map-basic

View File

@@ -1,6 +1,6 @@
# REQUIRES: system-windows
# RUN: clang-cl /Zi %p/Inputs/call-function.cpp -o %t
# RUN: %clang_cl /Zi %p/Inputs/call-function.cpp -o %t
# RUN: lldb-test ir-memory-map %t %S/Inputs/ir-memory-map-basic
# RUN: lldb-test ir-memory-map -host-only %t %S/Inputs/ir-memory-map-basic

View File

@@ -1,3 +1,3 @@
# UNSUPPORTED: windows
# RUN: python %S/expect_exit_code.py 226 %lldb -b -s %s
# RUN: %python %S/expect_exit_code.py 226 %lldb -b -s %s
q -30

View File

@@ -1,3 +1,3 @@
# UNSUPPORTED: windows
# RUN: python %S/expect_exit_code.py 30 %lldb -b -s %s
# RUN: %python %S/expect_exit_code.py 30 %lldb -b -s %s
q 30

View File

@@ -1,3 +1,3 @@
# UNSUPPORTED: windows
# RUN: python %S/expect_exit_code.py 10 %lldb -b -s %s
# RUN: %python %S/expect_exit_code.py 10 %lldb -b -s %s
q 0xA

View File

@@ -1,5 +1,5 @@
// Test that we use the apple indexes.
// RUN: clang %s -g -c -o %t --target=x86_64-apple-macosx
// RUN: %clang %s -g -c -o %t --target=x86_64-apple-macosx
// RUN: lldb-test symbols %t | FileCheck %s
// CHECK: .apple_names index present

View File

@@ -3,7 +3,7 @@
// REQUIRES: lld, zlib
// RUN: clang -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf %s
// RUN: %clang -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf %s
// RUN: ld.lld %t.o -o %t --compress-debug-sections=zlib
// RUN: lldb-test symbols --find=variable --name=foo %t | FileCheck %s

View File

@@ -2,7 +2,7 @@
// REQUIRES: lld
// RUN: clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf -gpubnames
// RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf -gpubnames
// RUN: ld.lld %t.o -o %t
// RUN: lldb-test symbols %t | FileCheck %s

View File

@@ -3,8 +3,8 @@
// REQUIRES: lld
// RUN: clang %s -g -c -o %t-1.o --target=x86_64-pc-linux -DONE -mllvm -accel-tables=Dwarf
// RUN: clang %s -g -c -o %t-2.o --target=x86_64-pc-linux -DTWO -mllvm -accel-tables=Dwarf
// RUN: %clang %s -g -c -o %t-1.o --target=x86_64-pc-linux -DONE -mllvm -accel-tables=Dwarf
// RUN: %clang %s -g -c -o %t-2.o --target=x86_64-pc-linux -DTWO -mllvm -accel-tables=Dwarf
// RUN: ld.lld %t-1.o %t-2.o -o %t
// RUN: lldb-test symbols --find=variable --name=foo %t | FileCheck %s

View File

@@ -1,6 +1,6 @@
// REQUIRES: lld
// RUN: clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Disable
// RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Disable
// RUN: ld.lld %t.o -o %t
// RUN: lldb-test symbols --name=foo --find=function --function-flags=base %t | \
// RUN: FileCheck --check-prefix=BASE %s
@@ -15,7 +15,7 @@
// RUN: lldb-test symbols --name=not_there --find=function %t | \
// RUN: FileCheck --check-prefix=EMPTY %s
//
// RUN: clang %s -g -c -o %t --target=x86_64-apple-macosx
// RUN: %clang %s -g -c -o %t --target=x86_64-apple-macosx
// RUN: lldb-test symbols --name=foo --find=function --function-flags=base %t | \
// RUN: FileCheck --check-prefix=BASE %s
// RUN: lldb-test symbols --name=foo --find=function --function-flags=method %t | \
@@ -29,7 +29,7 @@
// RUN: lldb-test symbols --name=not_there --find=function %t | \
// RUN: FileCheck --check-prefix=EMPTY %s
// RUN: clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf
// RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf
// RUN: ld.lld %t.o -o %t
// RUN: lldb-test symbols --name=foo --find=function --function-flags=base %t | \
// RUN: FileCheck --check-prefix=BASE %s

View File

@@ -1,6 +1,6 @@
// REQUIRES: lld
// RUN: clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Disable
// RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Disable
// RUN: ld.lld %t.o -o %t
// RUN: lldb-test symbols --name=foo --find=namespace %t | \
// RUN: FileCheck --check-prefix=FOO %s
@@ -9,7 +9,7 @@
// RUN: lldb-test symbols --name=not_there --find=namespace %t | \
// RUN: FileCheck --check-prefix=EMPTY %s
//
// RUN: clang %s -g -c -o %t --target=x86_64-apple-macosx
// RUN: %clang %s -g -c -o %t --target=x86_64-apple-macosx
// RUN: lldb-test symbols --name=foo --find=namespace %t | \
// RUN: FileCheck --check-prefix=FOO %s
// RUN: lldb-test symbols --name=foo --find=namespace --context=context %t | \
@@ -17,7 +17,7 @@
// RUN: lldb-test symbols --name=not_there --find=namespace %t | \
// RUN: FileCheck --check-prefix=EMPTY %s
// RUN: clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf
// RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf
// RUN: ld.lld %t.o -o %t
// RUN: lldb-test symbols --name=foo --find=namespace %t | \
// RUN: FileCheck --check-prefix=FOO %s

View File

@@ -1,6 +1,6 @@
// REQUIRES: lld
// RUN: clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Disable
// RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Disable
// RUN: ld.lld %t.o -o %t
// RUN: lldb-test symbols --name=foo --find=type %t | \
// RUN: FileCheck --check-prefix=NAME %s
@@ -9,7 +9,7 @@
// RUN: lldb-test symbols --name=not_there --find=type %t | \
// RUN: FileCheck --check-prefix=EMPTY %s
//
// RUN: clang %s -g -c -o %t --target=x86_64-apple-macosx
// RUN: %clang %s -g -c -o %t --target=x86_64-apple-macosx
// RUN: lldb-test symbols --name=foo --find=type %t | \
// RUN: FileCheck --check-prefix=NAME %s
// RUN: lldb-test symbols --name=foo --context=context --find=type %t | \
@@ -17,7 +17,7 @@
// RUN: lldb-test symbols --name=not_there --find=type %t | \
// RUN: FileCheck --check-prefix=EMPTY %s
// RUN: clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf
// RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf
// RUN: ld.lld %t.o -o %t
// RUN: lldb-test symbols --name=foo --find=type %t | \
// RUN: FileCheck --check-prefix=NAME %s

View File

@@ -1,6 +1,6 @@
// REQUIRES: lld
// RUN: clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Disable
// RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Disable
// RUN: ld.lld %t.o -o %t
// RUN: lldb-test symbols --name=foo --find=variable --context=context %t | \
// RUN: FileCheck --check-prefix=CONTEXT %s
@@ -11,7 +11,7 @@
// RUN: lldb-test symbols --name=not_there --find=variable %t | \
// RUN: FileCheck --check-prefix=EMPTY %s
//
// RUN: clang %s -g -c -o %t --target=x86_64-apple-macosx
// RUN: %clang %s -g -c -o %t --target=x86_64-apple-macosx
// RUN: lldb-test symbols --name=foo --find=variable --context=context %t | \
// RUN: FileCheck --check-prefix=CONTEXT %s
// RUN: lldb-test symbols --name=foo --find=variable %t | \
@@ -21,7 +21,7 @@
// RUN: lldb-test symbols --name=not_there --find=variable %t | \
// RUN: FileCheck --check-prefix=EMPTY %s
//
// RUN: clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf
// RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf
// RUN: ld.lld %t.o -o %t
// RUN: lldb-test symbols --name=foo --find=variable --context=context %t | \
// RUN: FileCheck --check-prefix=CONTEXT %s

View File

@@ -1,13 +1,13 @@
// REQUIRES: lld
// RUN: clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Disable
// RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Disable
// RUN: ld.lld %t.o -o %t
// RUN: lldb-test symbols --name=f.o --regex --find=function %t | FileCheck %s
//
// RUN: clang %s -g -c -o %t --target=x86_64-apple-macosx
// RUN: %clang %s -g -c -o %t --target=x86_64-apple-macosx
// RUN: lldb-test symbols --name=f.o --regex --find=function %t | FileCheck %s
// RUN: clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf
// RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf
// RUN: ld.lld %t.o -o %t
// RUN: lldb-test symbols --name=f.o --regex --find=function %t | FileCheck %s

View File

@@ -1,4 +1,4 @@
// RUN: clang %s -g -c -o %t --target=x86_64-apple-macosx
// RUN: %clang %s -g -c -o %t --target=x86_64-apple-macosx
// RUN: lldb-test symbols --name=foo --find=function --function-flags=method %t | \
// RUN: FileCheck %s

View File

@@ -1,11 +1,11 @@
// REQUIRES: lld
// RUN: clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Disable
// RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Disable
// RUN: ld.lld %t.o -o %t
// RUN: lldb-test symbols --name=foo --find=function --function-flags=method %t | \
// RUN: FileCheck %s
//
// RUN: clang %s -g -c -o %t --target=x86_64-apple-macosx
// RUN: %clang %s -g -c -o %t --target=x86_64-apple-macosx
// RUN: lldb-test symbols --name=foo --find=function --function-flags=method %t | \
// RUN: FileCheck %s

View File

@@ -1,4 +1,4 @@
// RUN: clang %s -g -c -o %t --target=x86_64-apple-macosx
// RUN: %clang %s -g -c -o %t --target=x86_64-apple-macosx
// RUN: lldb-test symbols --name=A::foo --find=variable %t | FileCheck %s
// CHECK: Found 1 variables:

View File

@@ -2,7 +2,7 @@
// XFAIL: *
// RUN: clang %s -g -c -o %t.o --target=x86_64-pc-linux
// RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux
// RUN: ld.lld %t.o -o %t
// RUN: lldb-test symbols --name=foo --find=type %t | \
// RUN: FileCheck --check-prefix=NAME %s

View File

@@ -1,9 +1,9 @@
// REQUIRES: lld
// RUN: clang %s -g -gsplit-dwarf -c -emit-llvm -o - --target=x86_64-pc-linux -DONE | \
// RUN: %clang %s -g -gsplit-dwarf -c -emit-llvm -o - --target=x86_64-pc-linux -DONE | \
// RUN: llc -accel-tables=Dwarf -filetype=obj -split-dwarf-file=%t-1.dwo -o %t-1.o
// RUN: llvm-objcopy --split-dwo=%t-1.dwo %t-1.o
// RUN: clang %s -g -gsplit-dwarf -c -emit-llvm -o - --target=x86_64-pc-linux -DTWO | \
// RUN: %clang %s -g -gsplit-dwarf -c -emit-llvm -o - --target=x86_64-pc-linux -DTWO | \
// RUN: llc -accel-tables=Dwarf -filetype=obj -split-dwarf-file=%t-2.dwo -o %t-2.o
// RUN: llvm-objcopy --split-dwo=%t-2.dwo %t-2.o
// RUN: ld.lld %t-1.o %t-2.o -o %t

View File

@@ -1,15 +1,15 @@
// REQUIRES: lld
// RUN: clang -g -c -o %t-1.o --target=x86_64-pc-linux -mllvm -accel-tables=Disable %s
// RUN: clang -g -c -o %t-2.o --target=x86_64-pc-linux -mllvm -accel-tables=Disable %S/Inputs/find-variable-file-2.cpp
// RUN: %clang -g -c -o %t-1.o --target=x86_64-pc-linux -mllvm -accel-tables=Disable %s
// RUN: %clang -g -c -o %t-2.o --target=x86_64-pc-linux -mllvm -accel-tables=Disable %S/Inputs/find-variable-file-2.cpp
// RUN: ld.lld %t-1.o %t-2.o -o %t
// RUN: lldb-test symbols --file=find-variable-file.cpp --find=variable %t | \
// RUN: FileCheck --check-prefix=ONE %s
// RUN: lldb-test symbols --file=find-variable-file-2.cpp --find=variable %t | \
// RUN: FileCheck --check-prefix=TWO %s
// RUN: clang -g -c -o %t-1.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf %s
// RUN: clang -g -c -o %t-2.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf %S/Inputs/find-variable-file-2.cpp
// RUN: %clang -g -c -o %t-1.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf %s
// RUN: %clang -g -c -o %t-2.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf %S/Inputs/find-variable-file-2.cpp
// RUN: ld.lld %t-1.o %t-2.o -o %t
// RUN: lldb-test symbols --file=find-variable-file.cpp --find=variable %t | \
// RUN: FileCheck --check-prefix=ONE %s

View File

@@ -2,9 +2,9 @@
// REQUIRES: lld
// Test various interesting cases for AST reconstruction.
// RUN: clang-cl /Z7 /GS- /GR- /c /Fo%t.obj -- %s
// RUN: %clang_cl /Z7 /GS- /GR- /c /Fo%t.obj -- %s
// RUN: lld-link /DEBUG /nodefaultlib /entry:main /OUT:%t.exe /PDB:%t.pdb -- %t.obj
// RUN: env LLDB_USE_NATIVE_PDB_READER=1 lldb -f %t.exe -s \
// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \
// RUN: %p/Inputs/ast-reconstruction.lldbinit 2>&1 | FileCheck %s
// Test trivial versions of each tag type.

View File

@@ -2,9 +2,9 @@
// REQUIRES: lld
// Test various interesting cases for AST reconstruction.
// RUN: clang-cl /Z7 /GS- /GR- /std:c++latest -Xclang -fkeep-static-consts /c /Fo%t.obj -- %s
// RUN: %clang_cl /Z7 /GS- /GR- /std:c++latest -Xclang -fkeep-static-consts /c /Fo%t.obj -- %s
// RUN: lld-link /DEBUG /nodefaultlib /entry:main /OUT:%t.exe /PDB:%t.pdb -- %t.obj
// RUN: env LLDB_USE_NATIVE_PDB_READER=1 lldb -f %t.exe -s \
// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \
// RUN: %p/Inputs/bitfields.lldbinit 2>&1 | FileCheck %s
// Test trivial versions of each tag type.

View File

@@ -2,9 +2,9 @@
// REQUIRES: lld
// Test that we can show disassembly and source.
// RUN: clang-cl -m64 /Z7 /GS- /GR- /c /Fo%t.obj -- %s
// RUN: %clang_cl -m64 /Z7 /GS- /GR- /c /Fo%t.obj -- %s
// RUN: lld-link /DEBUG /nodefaultlib /entry:main /OUT:%t.exe /PDB:%t.pdb -- %t.obj
// RUN: env LLDB_USE_NATIVE_PDB_READER=1 lldb -f %t.exe -s \
// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \
// RUN: %p/Inputs/disassembly.lldbinit | FileCheck %s
// Some context lines before

View File

@@ -1,9 +1,9 @@
// clang-format off
// REQUIRES: lld
// RUN: clang-cl /Z7 /GS- /GR- /c -Xclang -fkeep-static-consts /Fo%t.obj -- %s
// RUN: %clang_cl /Z7 /GS- /GR- /c -Xclang -fkeep-static-consts /Fo%t.obj -- %s
// RUN: lld-link /DEBUG /nodefaultlib /entry:main /OUT:%t.exe /PDB:%t.pdb -- %t.obj
// RUN: env LLDB_USE_NATIVE_PDB_READER=1 lldb -f %t.exe -s \
// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \
// RUN: %p/Inputs/function-types-builtins.lldbinit | FileCheck %s
// Test that we can display function signatures with simple builtin

View File

@@ -1,9 +1,9 @@
// clang-format off
// REQUIRES: lld
// RUN: clang-cl -m32 /Z7 /GS- /GR- /c -Xclang -fkeep-static-consts /Fo%t.obj -- %s
// RUN: %clang_cl -m32 /Z7 /GS- /GR- /c -Xclang -fkeep-static-consts /Fo%t.obj -- %s
// RUN: lld-link /DEBUG /nodefaultlib /entry:main /OUT:%t.exe /PDB:%t.pdb -- %t.obj
// RUN: env LLDB_USE_NATIVE_PDB_READER=1 lldb -f %t.exe -s \
// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \
// RUN: %p/Inputs/function-types-calling-conv.lldbinit | FileCheck %s

View File

@@ -2,9 +2,9 @@
// REQUIRES: lld
// Test that we can display function signatures with class types.
// RUN: clang-cl /Z7 /GS- /GR- /c -fstandalone-debug -Xclang -fkeep-static-consts /Fo%t.obj -- %s
// RUN: %clang_cl /Z7 /GS- /GR- /c -fstandalone-debug -Xclang -fkeep-static-consts /Fo%t.obj -- %s
// RUN: lld-link /DEBUG /nodefaultlib /entry:main /OUT:%t.exe /PDB:%t.pdb -- %t.obj
// RUN: env LLDB_USE_NATIVE_PDB_READER=1 lldb -f %t.exe -s \
// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \
// RUN: %p/Inputs/function-types-classes.lldbinit | FileCheck %s
// This is just some unimportant helpers needed so that we can get reference and

View File

@@ -2,9 +2,9 @@
// REQUIRES: lld
// Test that we can display tag types.
// RUN: clang-cl /Z7 /GS- /GR- /c -Xclang -fkeep-static-consts /Fo%t.obj -- %s
// RUN: %clang_cl /Z7 /GS- /GR- /c -Xclang -fkeep-static-consts /Fo%t.obj -- %s
// RUN: lld-link /DEBUG /nodefaultlib /entry:main /OUT:%t.exe /PDB:%t.pdb -- %t.obj
// RUN: env LLDB_USE_NATIVE_PDB_READER=1 lldb -f %t.exe -s \
// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \
// RUN: %p/Inputs/globals-classes.lldbinit | FileCheck %s
enum class EnumType : unsigned {

View File

@@ -2,10 +2,10 @@
// REQUIRES: lld
// Make sure we can read variables from BSS
// RUN: clang-cl /Z7 /GS- /GR- /c /Fo%t.obj -- %s
// RUN: %clang_cl /Z7 /GS- /GR- /c /Fo%t.obj -- %s
// RUN: lld-link /DEBUG /nodefaultlib /entry:main /OUT:%t.exe /PDB:%t.pdb -- %t.obj
// RUN: llvm-readobj -s %t.exe | FileCheck --check-prefix=BSS %s
// RUN: env LLDB_USE_NATIVE_PDB_READER=1 lldb -f %t.exe -s \
// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \
// RUN: %p/Inputs/globals-bss.lldbinit 2>&1 | FileCheck %s
int GlobalVariable = 0;

View File

@@ -2,9 +2,9 @@
// REQUIRES: lld
// Test that we can display tag types.
// RUN: clang-cl /Z7 /GS- /GR- /c -Xclang -fkeep-static-consts /Fo%t.obj -- %s
// RUN: %clang_cl /Z7 /GS- /GR- /c -Xclang -fkeep-static-consts /Fo%t.obj -- %s
// RUN: lld-link /DEBUG /nodefaultlib /entry:main /OUT:%t.exe /PDB:%t.pdb -- %t.obj
// RUN: env LLDB_USE_NATIVE_PDB_READER=1 lldb -f %t.exe -s \
// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \
// RUN: %p/Inputs/globals-fundamental.lldbinit | FileCheck %s

View File

@@ -2,9 +2,9 @@
// REQUIRES: lld
// Test various interesting cases for AST reconstruction.
// RUN: clang-cl /Z7 /GS- /GR- -Xclang -fkeep-static-consts /c /Fo%t.obj -- %s
// RUN: %clang_cl /Z7 /GS- /GR- -Xclang -fkeep-static-consts /c /Fo%t.obj -- %s
// RUN: lld-link /DEBUG /nodefaultlib /entry:main /OUT:%t.exe /PDB:%t.pdb -- %t.obj
// RUN: env LLDB_USE_NATIVE_PDB_READER=1 lldb -f %t.exe -s \
// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \
// RUN: %p/Inputs/nested-types.lldbinit 2>&1 | FileCheck %s
struct S {

View File

@@ -5,7 +5,7 @@
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-win32 %p/Inputs/s_constant.s > %t.obj
// RUN: lld-link /DEBUG /nodefaultlib /entry:main /OUT:%t.exe /PDB:%t.pdb -- %t.obj
// RUN: env LLDB_USE_NATIVE_PDB_READER=1 lldb -f %t.exe -s \
// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \
// RUN: %p/Inputs/s_constant.lldbinit | FileCheck %s
// clang-cl cannot generate S_CONSTANT records, but we need to test that we can

View File

@@ -2,9 +2,9 @@
// REQUIRES: lld
// Test that we can set simple breakpoints using PDB on any platform.
// RUN: clang-cl /Z7 /GS- /GR- /c /Fo%t.obj -- %s
// RUN: %clang_cl /Z7 /GS- /GR- /c /Fo%t.obj -- %s
// RUN: lld-link /DEBUG /nodefaultlib /entry:main /OUT:%t.exe /PDB:%t.pdb -- %t.obj
// RUN: env LLDB_USE_NATIVE_PDB_READER=1 lldb -f %t.exe -s \
// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \
// RUN: %p/Inputs/breakpoints.lldbinit | FileCheck %s
// Use different indentation style for each overload so that the starting

View File

@@ -2,9 +2,9 @@
// REQUIRES: lld
// Test that we can set display source of functions.
// RUN: clang-cl /Z7 /GS- /GR- /c /Fo%t.obj -- %s
// RUN: %clang_cl /Z7 /GS- /GR- /c /Fo%t.obj -- %s
// RUN: lld-link /DEBUG /nodefaultlib /entry:main /OUT:%t.exe /PDB:%t.pdb -- %t.obj
// RUN: env LLDB_USE_NATIVE_PDB_READER=1 lldb -f %t.exe -s \
// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \
// RUN: %p/Inputs/source-list.lldbinit | FileCheck %s

View File

@@ -2,9 +2,9 @@
// REQUIRES: lld
// Test that we can display tag types.
// RUN: clang-cl /Z7 /GS- /GR- /c /Fo%t.obj -- %s
// RUN: %clang_cl /Z7 /GS- /GR- /c /Fo%t.obj -- %s
// RUN: lld-link /DEBUG /nodefaultlib /entry:main /OUT:%t.exe /PDB:%t.pdb -- %t.obj
// RUN: env LLDB_USE_NATIVE_PDB_READER=1 lldb -f %t.exe -s \
// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \
// RUN: %p/Inputs/tag-types.lldbinit | FileCheck %s
// Test struct

View File

@@ -1,6 +1,6 @@
REQUIRES: system-windows
RUN: cl /Zi /GS- /c %S/Inputs/AstRestoreTest.cpp /Fo%t.obj
RUN: link /debug:full /nodefaultlib /entry:main %t.obj /out:%t.exe
RUN: %msvc_cl /Zi /GS- /c %S/Inputs/AstRestoreTest.cpp /Fo%t.obj
RUN: %msvc_link /debug:full /nodefaultlib /entry:main %t.obj /out:%t.exe
RUN: lldb-test symbols -dump-ast %t.exe | FileCheck --check-prefix=ENUM %s
RUN: lldb-test symbols -dump-ast %t.exe | FileCheck --check-prefix=GLOBAL %s
RUN: lldb-test symbols -dump-ast %t.exe | FileCheck --check-prefix=BASE %s

View File

@@ -1,5 +1,5 @@
REQUIRES: system-windows, lld
RUN: clang-cl -m32 /Zi /GS- /c %S/Inputs/CallingConventionsTest.cpp /o %t.obj
RUN: %clang_cl -m32 /Zi /GS- /c %S/Inputs/CallingConventionsTest.cpp /o %t.obj
RUN: lld-link /debug:full /nodefaultlib /entry:main %t.obj /out:%t.exe
RUN: lldb-test symbols -dump-ast %t.exe | FileCheck %s

View File

@@ -1,6 +1,6 @@
REQUIRES: system-windows
RUN: clang-cl -m32 /Z7 /c /GS- %S/Inputs/ClassLayoutTest.cpp /o %T/ClassLayoutTest.cpp.obj
RUN: link %T/ClassLayoutTest.cpp.obj /DEBUG /nodefaultlib /ENTRY:main /OUT:%T/ClassLayoutTest.cpp.exe
REQUIRES: msvc
RUN: %clang_cl -m32 /Z7 /c /GS- %S/Inputs/ClassLayoutTest.cpp /o %T/ClassLayoutTest.cpp.obj
RUN: %msvc_link %T/ClassLayoutTest.cpp.obj /DEBUG /nodefaultlib /ENTRY:main /OUT:%T/ClassLayoutTest.cpp.exe
RUN: lldb-test symbols %T/ClassLayoutTest.cpp.exe | FileCheck %s
RUN: lldb-test symbols %T/ClassLayoutTest.cpp.exe | FileCheck --check-prefix=ENUM %s
RUN: lldb-test symbols %T/ClassLayoutTest.cpp.exe | FileCheck --check-prefix=UNION %s

View File

@@ -1,5 +1,6 @@
REQUIRES: system-windows
RUN: clang-cl /Z7 %S/Inputs/CompilandsTest.cpp /o %T/CompilandsTest.cpp.exe
REQUIRES: system-windows, msvc
RUN: %clang_cl /Z7 /c %S/Inputs/CompilandsTest.cpp /o %T/CompilandsTest.cpp.obj
RUN: %msvc_link /debug:full /nodefaultlib /entry:main %T/CompilandsTest.cpp.obj /out:%T/CompilandsTest.cpp.exe
RUN: lldb-test symbols %T/CompilandsTest.cpp.exe | FileCheck %s
; Link default libraries

View File

@@ -1,6 +1,6 @@
REQUIRES: system-windows
RUN: clang-cl -m32 /Z7 /c /GS- %S/Inputs/SimpleTypesTest.cpp /o %T/SimpleTypesTest.cpp.enums.obj
RUN: link %T/SimpleTypesTest.cpp.enums.obj /DEBUG /nodefaultlib /ENTRY:main /OUT:%T/SimpleTypesTest.cpp.enums.exe
REQUIRES: system-windows, msvc
RUN: %clang_cl -m32 /Z7 /c /GS- %S/Inputs/SimpleTypesTest.cpp /o %T/SimpleTypesTest.cpp.enums.obj
RUN: %msvc_link %T/SimpleTypesTest.cpp.enums.obj /DEBUG /nodefaultlib /ENTRY:main /OUT:%T/SimpleTypesTest.cpp.enums.exe
RUN: lldb-test symbols %T/SimpleTypesTest.cpp.enums.exe | FileCheck %s
; FIXME: PDB does not have information about scoped enumeration (Enum class) so the

View File

@@ -1,7 +1,7 @@
REQUIRES: system-windows
RUN: clang-cl -m32 /Z7 /c /GS- %S/Inputs/FuncSymbolsTestMain.cpp /o %T/FuncSymbolsTestMain.cpp.obj
RUN: clang-cl -m32 /Z7 /c /GS- %S/Inputs/FuncSymbols.cpp /o %T/FuncSymbols.cpp.obj
RUN: link %T/FuncSymbolsTestMain.cpp.obj %T/FuncSymbols.cpp.obj /DEBUG /nodefaultlib /Entry:main /OUT:%T/FuncSymbolsTest.exe
REQUIRES: system-windows, msvc
RUN: %clang_cl -m32 /Z7 /c /GS- %S/Inputs/FuncSymbolsTestMain.cpp /o %T/FuncSymbolsTestMain.cpp.obj
RUN: %clang_cl -m32 /Z7 /c /GS- %S/Inputs/FuncSymbols.cpp /o %T/FuncSymbols.cpp.obj
RUN: %msvc_link %T/FuncSymbolsTestMain.cpp.obj %T/FuncSymbols.cpp.obj /DEBUG /nodefaultlib /Entry:main /OUT:%T/FuncSymbolsTest.exe
RUN: lldb-test symbols %T/FuncSymbolsTest.exe | FileCheck --check-prefix=CHECK-ONE %s
RUN: lldb-test symbols %T/FuncSymbolsTest.exe | FileCheck --check-prefix=CHECK-TWO %s

View File

@@ -1,4 +1,4 @@
REQUIRES: system-windows, lld
RUN: clang-cl /c /Zi /Gy %S/Inputs/FunctionLevelLinkingTest.cpp /o %t.obj
RUN: %clang_cl /c /Zi /Gy %S/Inputs/FunctionLevelLinkingTest.cpp /o %t.obj
RUN: lld-link /debug:full /nodefaultlib /entry:main /order:@%S/Inputs/FunctionLevelLinkingTest.ord %t.obj /out:%t.exe
RUN: lldb-test symbols -verify %t.exe

View File

@@ -1,5 +1,5 @@
REQUIRES: system-windows, lld
RUN: clang-cl /c /Zi %S/Inputs/FunctionNestedBlockTest.cpp /o %t.obj
RUN: %clang_cl /c /Zi %S/Inputs/FunctionNestedBlockTest.cpp /o %t.obj
RUN: lld-link /debug:full /nodefaultlib /entry:main %t.obj /out:%t.exe
RUN: lldb-test symbols -find=function -file FunctionNestedBlockTest.cpp -line 4 %t.exe | FileCheck --check-prefix=CHECK-FUNCTION %s
RUN: lldb-test symbols -find=block -file FunctionNestedBlockTest.cpp -line 4 %t.exe | FileCheck --check-prefix=CHECK-BLOCK %s

View File

@@ -1,6 +1,6 @@
REQUIRES: system-windows
RUN: clang-cl -m32 /Z7 /c /GS- %S/Inputs/PointerTypeTest.cpp /o %T/PointerTypeTest.cpp.obj
RUN: link %T/PointerTypeTest.cpp.obj /DEBUG /nodefaultlib /ENTRY:main /OUT:%T/PointerTypeTest.cpp.exe
REQUIRES: system-windows, msvc
RUN: %clang_cl -m32 /Z7 /c /GS- %S/Inputs/PointerTypeTest.cpp /o %T/PointerTypeTest.cpp.obj
RUN: %msvc_link %T/PointerTypeTest.cpp.obj /DEBUG /nodefaultlib /ENTRY:main /OUT:%T/PointerTypeTest.cpp.exe
RUN: lldb-test symbols %T/PointerTypeTest.cpp.exe | FileCheck %s
RUN: lldb-test symbols %T/PointerTypeTest.cpp.exe | FileCheck --check-prefix=MAIN-ST-F %s
RUN: lldb-test symbols %T/PointerTypeTest.cpp.exe | FileCheck --check-prefix=MAIN-ST %s

View File

@@ -1,6 +1,6 @@
REQUIRES: system-windows
RUN: clang-cl -m32 /Z7 /c /GS- %S/Inputs/TypeQualsTest.cpp /o %T/TypeQualsTest.cpp.obj
RUN: link %T/TypeQualsTest.cpp.obj /DEBUG /nodefaultlib /ENTRY:main /OUT:%T/TypeQualsTest.cpp.exe
REQUIRES: system-windows, msvc
RUN: %clang_cl -m32 /Z7 /c /GS- %S/Inputs/TypeQualsTest.cpp /o %T/TypeQualsTest.cpp.obj
RUN: %msvc_link %T/TypeQualsTest.cpp.obj /DEBUG /nodefaultlib /ENTRY:main /OUT:%T/TypeQualsTest.cpp.exe
RUN: lldb-test symbols %T/TypeQualsTest.cpp.exe | FileCheck %s
CHECK: Module [[MOD:.*]]

View File

@@ -1,6 +1,6 @@
REQUIRES: system-windows
RUN: clang-cl -m32 /Z7 /c /GS- %S/Inputs/SimpleTypesTest.cpp /o %T/SimpleTypesTest.cpp.typedefs.obj
RUN: link %T/SimpleTypesTest.cpp.typedefs.obj /DEBUG /nodefaultlib /ENTRY:main /OUT:%T/SimpleTypesTest.cpp.typedefs.exe
REQUIRES: system-windows, msvc
RUN: %clang_cl -m32 /Z7 /c /GS- %S/Inputs/SimpleTypesTest.cpp /o %T/SimpleTypesTest.cpp.typedefs.obj
RUN: %msvc_link %T/SimpleTypesTest.cpp.typedefs.obj /DEBUG /nodefaultlib /ENTRY:main /OUT:%T/SimpleTypesTest.cpp.typedefs.exe
RUN: lldb-test symbols %T/SimpleTypesTest.cpp.typedefs.exe | FileCheck %s
; Generate 32-bit target

View File

@@ -1,5 +1,6 @@
REQUIRES: system-windows
RUN: clang-cl /Zi %S/Inputs/UdtLayoutTest.cpp /o %t.exe
REQUIRES: system-windows, msvc
RUN: %clang_cl /Zi %S/Inputs/UdtLayoutTest.cpp /c /o %t.obj
RUN: %msvc_link /DEBUG:FULL /out:%t.exe %t.obj
RUN: %lldb -b -s %S/Inputs/UdtLayoutTest.script -- %t.exe | FileCheck %s
CHECK:(int) int C::abc = 123

View File

@@ -1,5 +1,6 @@
REQUIRES: system-windows
RUN: clang-cl /Zi %S/Inputs/VariablesLocationsTest.cpp /o %t.exe
REQUIRES: system-windows, msvc
RUN: %clang_cl /Zi %S/Inputs/VariablesLocationsTest.cpp /c /o %t.obj
RUN: %msvc_link /debug:full %t.obj /out:%t.exe
RUN: %lldb -b -s %S/Inputs/VariablesLocationsTest.script -- %t.exe | FileCheck %s
CHECK: g_var = 2222

View File

@@ -1,6 +1,6 @@
REQUIRES: system-windows
RUN: clang-cl -m64 /Z7 /c /GS- %S/Inputs/VariablesTest.cpp /o %T/VariablesTest.cpp.obj
RUN: link %T/VariablesTest.cpp.obj /DEBUG /nodefaultlib /ENTRY:main /OUT:%T/VariablesTest.cpp.exe
REQUIRES: system-windows, msvc
RUN: %clang_cl -m64 /Z7 /c /GS- %S/Inputs/VariablesTest.cpp /o %T/VariablesTest.cpp.obj
RUN: %msvc_link %T/VariablesTest.cpp.obj /DEBUG /nodefaultlib /ENTRY:main /OUT:%T/VariablesTest.cpp.exe
RUN: lldb-test symbols %T/VariablesTest.cpp.exe | FileCheck %s
CHECK: Module [[MOD:.*]]

View File

@@ -1,5 +1,6 @@
REQUIRES: system-windows
RUN: clang-cl /Zi %S/Inputs/VBases.cpp /o %t.exe
REQUIRES: system-windows, msvc
RUN: %clang_cl /Zi %S/Inputs/VBases.cpp /c /o %t.obj
RUN: %msvc_link /debug:full %t.obj /out:%t.exe
RUN: %lldb -b -s %S/Inputs/VBases.script -- %t.exe | FileCheck %s
CHECK: {

View File

View File

@@ -0,0 +1,104 @@
import os
import platform
import subprocess
import sys
import lit.util
from lit.llvm import llvm_config
from lit.llvm.subst import FindTool
from lit.llvm.subst import ToolSubst
def use_lldb_substitutions(config):
# Set up substitutions for primary tools. These tools must come from config.lldb_tools_dir
# which is basically the build output directory. We do not want to find these in path or
# anywhere else, since they are specifically the programs which are actually being tested.
dsname = 'debugserver' if platform.system() in ['Darwin'] else 'lldb-server'
dsargs = [] if platform.system() in ['Darwin'] else ['gdbserver']
lldbmi = ToolSubst('%lldbmi',
command=FindTool('lldb-mi'),
extra_args=['--synchronous'],
unresolved='ignore')
primary_tools = [
ToolSubst('%lldb',
command=FindTool('lldb'),
extra_args=['-S',
os.path.join(config.test_source_root,
'lit-lldb-init')]),
lldbmi,
ToolSubst('%debugserver',
command=FindTool(dsname),
extra_args=dsargs,
unresolved='ignore'),
'lldb-test'
]
llvm_config.add_tool_substitutions(primary_tools,
[config.lldb_tools_dir])
if lldbmi.was_resolved:
config.available_features.add('lldb-mi')
def _use_msvc_substitutions(config):
# If running from a Visual Studio Command prompt (e.g. vcvars), this will
# detect the include and lib paths, and find cl.exe and link.exe and create
# substitutions for each of them that explicitly specify /I and /L paths
cl = '"' + lit.util.which('cl') + '"'
link = '"' + lit.util.which('link') + '"'
if not cl or not link:
return
includes = os.getenv('INCLUDE', '').split(';')
libs = os.getenv('LIB', '').split(';')
config.available_features.add('msvc')
compiler_flags = ['"/I{}"'.format(x) for x in includes if os.path.exists(x)]
linker_flags = ['"/LIBPATH:{}"'.format(x) for x in libs if os.path.exists(x)]
tools = [
ToolSubst('%msvc_cl', command=cl, extra_args=compiler_flags),
ToolSubst('%msvc_link', command=link, extra_args=linker_flags)]
llvm_config.add_tool_substitutions(tools)
return
def use_support_substitutions(config):
# Set up substitutions for support tools. These tools can be overridden at the CMake
# level (by specifying -DLLDB_LIT_TOOLS_DIR), installed, or as a last resort, we can use
# the just-built version.
flags = []
if platform.system() in ['Darwin']:
try:
out = subprocess.check_output(['xcrun', '--show-sdk-path']).strip()
res = 0
except OSError:
res = -1
if res == 0 and out:
sdk_path = lit.util.to_string(out)
lit_config.note('using SDKROOT: %r' % sdk_path)
flags = ['-isysroot', sdk_path]
elif platform.system() in ['OpenBSD']:
flags = ['-pthread']
additional_tool_dirs=[]
if config.lldb_lit_tools_dir:
additional_tool_dirs.append(config.lldb_lit_tools_dir)
llvm_config.use_clang(additional_flags=flags,
additional_tool_dirs=additional_tool_dirs,
required=True)
if sys.platform == 'win32':
_use_msvc_substitutions(config)
have_lld = llvm_config.use_lld(additional_tool_dirs=additional_tool_dirs,
required=False)
if have_lld:
config.available_features.add('lld')
support_tools = ['yaml2obj', 'obj2yaml', 'llvm-pdbutil',
'llvm-mc', 'llvm-readobj', 'llvm-objdump',
'llvm-objcopy']
additional_tool_dirs += [config.lldb_tools_dir, config.llvm_tools_dir]
llvm_config.add_tool_substitutions(support_tools, additional_tool_dirs)

View File

@@ -1,18 +1,18 @@
# -*- Python -*-
import os
import sys
import re
import platform
import shutil
import subprocess
import site
import sys
import lit.util
import lit.formats
from lit.llvm import llvm_config
from lit.llvm.subst import FindTool
from lit.llvm.subst import ToolSubst
from helper import toolchain
# name: The name of this test suite.
config.name = 'LLDB'
@@ -34,80 +34,17 @@ config.test_source_root = os.path.dirname(__file__)
# test_exec_root: The root path where tests should be run.
config.test_exec_root = os.path.join(config.lldb_obj_root, 'lit')
# Tweak the PATH to include the tools dir.
llvm_config.with_system_environment('PATH')
llvm_config.with_environment('PATH', config.lldb_tools_dir, append_path=True)
llvm_config.with_environment('PATH', config.llvm_tools_dir, append_path=True)
llvm_config.with_environment('LD_LIBRARY_PATH', config.lldb_libs_dir, append_path=True)
llvm_config.with_environment('LD_LIBRARY_PATH', config.llvm_libs_dir, append_path=True)
llvm_config.with_system_environment('LD_LIBRARY_PATH', append_path=True)
llvm_config.use_default_substitutions()
if platform.system() in ['Darwin']:
debugserver = lit.util.which('debugserver', config.lldb_tools_dir)
else:
debugserver = lit.util.which('lldb-server', config.lldb_tools_dir)
lldb = "%s -S %s/lit-lldb-init" % (lit.util.which('lldb', config.lldb_tools_dir),
config.test_source_root)
toolchain.use_lldb_substitutions(config)
lldbmi = lit.util.which('lldb-mi', config.lldb_tools_dir)
if lldbmi:
config.available_features.add('lldb-mi')
toolchain.use_support_substitutions(config)
config.cc = llvm_config.use_llvm_tool(config.cc, required=True)
config.cxx = llvm_config.use_llvm_tool(config.cxx, required=True)
if platform.system() in ['Darwin']:
try:
out = subprocess.check_output(['xcrun', '--show-sdk-path']).strip()
res = 0
except OSError:
res = -1
if res == 0 and out:
sdk_path = lit.util.to_string(out)
lit_config.note('using SDKROOT: %r' % sdk_path)
config.cc += " -isysroot %s" % sdk_path
config.cxx += " -isysroot %s" % sdk_path
if platform.system() in ['OpenBSD']:
config.cc += " -pthread"
config.cxx += " -pthread"
config.substitutions.append(('%cc', config.cc))
config.substitutions.append(('%cxx', config.cxx))
if lldbmi:
config.substitutions.append(('%lldbmi', lldbmi + " --synchronous"))
config.substitutions.append(('%lldb', lldb))
if debugserver is not None:
if platform.system() in ['Darwin']:
config.substitutions.append(('%debugserver', debugserver))
else:
config.substitutions.append(('%debugserver', debugserver + ' gdbserver'))
tools = ['lldb-test', 'yaml2obj', 'obj2yaml', 'llvm-pdbutil']
llvm_config.add_tool_substitutions(tools, [config.llvm_tools_dir, config.lldb_tools_dir])
if re.match(r'^arm(hf.*-linux)|(.*-linux-gnuabihf)', config.target_triple):
config.available_features.add("armhf-linux")
print("config.cc = {}".format(config.cc))
if re.match(r'icc', config.cc):
config.available_features.add("compiler-icc")
elif re.match(r'clang', config.cc):
config.available_features.add("compiler-clang")
elif re.match(r'gcc', config.cc):
config.available_features.add("compiler-gcc")
elif re.match(r'cl', config.cc):
config.available_features.add("compiler-msvc")
if config.have_lld:
config.available_features.add("lld")
def calculate_arch_features(arch_string):
# This will add a feature such as x86, arm, mips, etc for each built
# target

View File

@@ -4,26 +4,29 @@ config.llvm_src_root = "@LLVM_SOURCE_DIR@"
config.llvm_obj_root = "@LLVM_BINARY_DIR@"
config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
config.llvm_shlib_dir = "@SHLIBDIR@"
config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
config.lldb_obj_root = "@LLDB_BINARY_DIR@"
config.lldb_libs_dir = "@LLDB_LIBS_DIR@"
config.lldb_tools_dir = "@LLDB_TOOLS_DIR@"
# Since it comes from the command line, it may have backslashes which
# should not need to be escaped.
config.lldb_lit_tools_dir = r"@LLDB_LIT_TOOLS_DIR@"
config.target_triple = "@TARGET_TRIPLE@"
config.python_executable = "@PYTHON_EXECUTABLE@"
config.cc = "@LLDB_TEST_C_COMPILER@"
config.cxx = "@LLDB_TEST_CXX_COMPILER@"
config.have_zlib = @LLVM_ENABLE_ZLIB@
config.have_lld = @LLDB_HAVE_LLD@
config.host_triple = "@LLVM_HOST_TRIPLE@"
# Support substitution of the tools and libs dirs with user parameters. This is
# used when we can't determine the tool dir at configuration time.
try:
config.llvm_tools_dir = config.llvm_tools_dir % lit_config.params
config.llvm_libs_dir = config.llvm_libs_dir % lit_config.params
config.llvm_shlib_dir = config.llvm_shlib_dir % lit_config.params
config.lldb_libs_dir = config.lldb_libs_dir % lit_config.params
config.lldb_tools_dir = config.lldb_tools_dir % lit_config.params
config.cc = config.cc % lit_config.params
config.cxx = config.cxx % lit_config.params
config.lldb_lit_tools_dir = config.lldb_lit_tools_dir % lit_config.params
except KeyError as e:
key, = e.args
lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key,key))

View File

@@ -1,7 +1,7 @@
# XFAIL: system-windows
# -> llvm.org/pr24452
#
# RUN: %cc -o %t %p/inputs/break-insert-pending.c -g
# RUN: %clang -o %t %p/inputs/break-insert-pending.c -g
# RUN: %lldbmi %t < %s | FileCheck %s
# Test for enabling pending breakpoints globally

View File

@@ -1,7 +1,7 @@
# XFAIL: system-windows
# -> llvm.org/pr24452
#
# RUN: %cc -o a.exe %p/inputs/break-insert.c -g
# RUN: %clang -o a.exe %p/inputs/break-insert.c -g
# RUN: %lldbmi < %s | FileCheck %s
# Test that a breakpoint can be inserted before creating a target.

View File

@@ -1,7 +1,7 @@
# XFAIL: system-windows
# -> llvm.org/pr24452
#
# RUN: %cc -o %t %p/inputs/data-info-line.c -g
# RUN: %clang -o %t %p/inputs/data-info-line.c -g
# RUN: %lldbmi %t < %s | FileCheck %s
# Test lldb-mi -data-info-line command.

View File

@@ -1,7 +1,7 @@
# XFAIL: system-windows
# -> llvm.org/pr24452
#
# RUN: %cc -o %t %p/inputs/main.c -g
# RUN: %clang -o %t %p/inputs/main.c -g
# RUN: %lldbmi %t < %s | FileCheck %s
# Test lldb-mi -exec-continue command.

View File

@@ -1,7 +1,7 @@
# XFAIL: system-windows
# -> llvm.org/pr24452
#
# RUN: %cc -o %t %p/inputs/main.c -g
# RUN: %clang -o %t %p/inputs/main.c -g
# RUN: %lldbmi %t < %s | FileCheck %s
# Test lldb-mi -exec-finish command.

View File

@@ -1,7 +1,7 @@
# XFAIL: system-windows
# -> llvm.org/pr24452
#
# RUN: %cc -o %t %p/inputs/main.c -g
# RUN: %clang -o %t %p/inputs/main.c -g
# RUN: %lldbmi %t < %s | FileCheck %s
# Test lldb-mi -exec-interrupt command.

View File

@@ -1,7 +1,7 @@
# XFAIL: system-windows
# -> llvm.org/pr24452
#
# RUN: %cc -o %t %p/inputs/main.c -g
# RUN: %clang -o %t %p/inputs/main.c -g
# RUN: %lldbmi %t < %s | FileCheck %s
# Test lldb-mi -exec-next-instruction command.

View File

@@ -1,7 +1,7 @@
# XFAIL: system-windows
# -> llvm.org/pr24452
#
# RUN: %cc -o %t %p/inputs/main.c -g
# RUN: %clang -o %t %p/inputs/main.c -g
# RUN: %lldbmi %t < %s | FileCheck %s
# Test lldb-mi -exec-next command.

View File

@@ -1,7 +1,7 @@
# XFAIL: system-windows
# -> llvm.org/pr24452
#
# RUN: %cc -o %t %p/inputs/main.c -g
# RUN: %clang -o %t %p/inputs/main.c -g
# RUN: %lldbmi %t < %s | FileCheck %s
# Test lldb-mi -exec-step-instruction command.

View File

@@ -1,7 +1,7 @@
# XFAIL: system-windows
# -> llvm.org/pr24452
#
# RUN: %cc -o %t %p/inputs/main.c -g
# RUN: %clang -o %t %p/inputs/main.c -g
# RUN: %lldbmi %t < %s | FileCheck %s
# Test lldb-mi -exec-step command.

View File

@@ -1,7 +1,7 @@
# XFAIL: system-windows
# -> llvm.org/pr24452
#
# RUN: %cc -o %t %p/inputs/main.c %p/inputs/symbol-list-lines.c %p/inputs/list-lines-helper.c -g
# RUN: %clang -o %t %p/inputs/main.c %p/inputs/symbol-list-lines.c %p/inputs/list-lines-helper.c -g
# RUN: %lldbmi %t < %s | FileCheck %s
# Test lldb-mi -symbol-list-lines command.

View File

@@ -1,6 +1,6 @@
# UNSUPPORTED: windows, darwin
#
# RUN: %cc -o %t %p/inputs/main.c -g
# RUN: %clang -o %t %p/inputs/main.c -g
# RUN: %python %p/inputs/target-select-so-path.py "%debugserver" "%lldbmi %t" %s
# Test that -target-select command can hook up a path

View File

@@ -87,6 +87,12 @@ if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Windows|Darwin")
--env ARCHIVER=${CMAKE_AR} --env OBJCOPY=${CMAKE_OBJCOPY})
endif()
if (NOT "${LLDB_LIT_TOOLS_DIR}" STREQUAL "")
if (NOT EXISTS "${LLDB_LIT_TOOLS_DIR}")
message(WARNING "LLDB_LIT_TOOLS_DIR ${LLDB_LIT_TOOLS_DIR} does not exist.")
endif()
endif()
if(CMAKE_HOST_APPLE)
list(APPEND LLDB_TEST_COMMON_ARGS --server ${DEBUGSERVER_PATH})
endif()

View File

@@ -85,7 +85,9 @@ class TestingConfig:
cfg_globals['config'] = self
cfg_globals['lit_config'] = litConfig
cfg_globals['__file__'] = path
original_sys_path = list(sys.path)
try:
sys.path.insert(0, os.path.dirname(path))
exec(compile(data, path, 'exec'), cfg_globals, None)
if litConfig.debug:
litConfig.note('... loaded config %r' % path)
@@ -100,7 +102,7 @@ class TestingConfig:
litConfig.fatal(
'unable to parse config file %r, traceback: %s' % (
path, traceback.format_exc()))
sys.path = original_sys_path
self.finish(litConfig)
def __init__(self, parent, name, suffixes, test_format,

View File

@@ -333,7 +333,7 @@ class LLVMConfig(object):
self.lit_config.note('using {}: {}'.format(name, tool))
return tool
def use_clang(self, required=True):
def use_clang(self, additional_tool_dirs=[], additional_flags=[], required=True):
"""Configure the test suite to be able to invoke clang.
Sets up some environment variables important to clang, locates a
@@ -370,12 +370,16 @@ class LLVMConfig(object):
# Tweak the PATH to include the tools dir and the scripts dir.
# Put Clang first to avoid LLVM from overriding out-of-tree clang builds.
possible_paths = ['clang_tools_dir', 'llvm_tools_dir']
paths = [getattr(self.config, pp) for pp in possible_paths
exe_dir_props = [self.config.name.lower() + '_tools_dir', 'clang_tools_dir', 'llvm_tools_dir']
paths = [getattr(self.config, pp) for pp in exe_dir_props
if getattr(self.config, pp, None)]
paths = additional_tool_dirs + paths
self.with_environment('PATH', paths, append_path=True)
paths = [self.config.llvm_shlib_dir, self.config.llvm_libs_dir]
lib_dir_props = [self.config.name.lower() + '_libs_dir', 'clang_libs_dir', 'llvm_shlib_dir', 'llvm_libs_dir']
paths = [getattr(self.config, pp) for pp in lib_dir_props
if getattr(self.config, pp, None)]
self.with_environment('LD_LIBRARY_PATH', paths, append_path=True)
# Discover the 'clang' and 'clangcc' to use.
@@ -383,19 +387,21 @@ class LLVMConfig(object):
self.config.clang = self.use_llvm_tool(
'clang', search_env='CLANG', required=required)
self.config.substitutions.append(
('%llvmshlibdir', self.config.llvm_shlib_dir))
self.config.substitutions.append(
('%pluginext', self.config.llvm_plugin_ext))
shl = getattr(self.config, 'llvm_shlib_dir', None)
pext = getattr(self.config, 'llvm_plugin_ext', None)
if shl:
self.config.substitutions.append(('%llvmshlibdir', shl))
if pext:
self.config.substitutions.append(('%pluginext', pext))
builtin_include_dir = self.get_clang_builtin_include_dir(self.config.clang)
tool_substitutions = [
ToolSubst('%clang', command=self.config.clang),
ToolSubst('%clang_analyze_cc1', command='%clang_cc1', extra_args=['-analyze', '%analyze']),
ToolSubst('%clang_cc1', command=self.config.clang, extra_args=['-cc1', '-internal-isystem', builtin_include_dir, '-nostdsysteminc']),
ToolSubst('%clang_cpp', command=self.config.clang, extra_args=['--driver-mode=cpp']),
ToolSubst('%clang_cl', command=self.config.clang, extra_args=['--driver-mode=cl']),
ToolSubst('%clangxx', command=self.config.clang, extra_args=['--driver-mode=g++']),
ToolSubst('%clang', command=self.config.clang, extra_args=additional_flags),
ToolSubst('%clang_analyze_cc1', command='%clang_cc1', extra_args=['-analyze', '%analyze']+additional_flags),
ToolSubst('%clang_cc1', command=self.config.clang, extra_args=['-cc1', '-internal-isystem', builtin_include_dir, '-nostdsysteminc']+additional_flags),
ToolSubst('%clang_cpp', command=self.config.clang, extra_args=['--driver-mode=cpp']+additional_flags),
ToolSubst('%clang_cl', command=self.config.clang, extra_args=['--driver-mode=cl']+additional_flags),
ToolSubst('%clangxx', command=self.config.clang, extra_args=['--driver-mode=g++']+additional_flags),
]
self.add_tool_substitutions(tool_substitutions)
@@ -415,34 +421,34 @@ class LLVMConfig(object):
self.config.substitutions.append(
('%target_itanium_abi_host_triple', ''))
self.config.substitutions.append(
('%src_include_dir', self.config.clang_src_dir + '/include'))
# FIXME: Find nicer way to prohibit this.
self.config.substitutions.append(
(' clang ', """*** Do not use 'clang' in tests, use '%clang'. ***"""))
(' clang ', """\"*** Do not use 'clang' in tests, use '%clang'. ***\""""))
self.config.substitutions.append(
(' clang\+\+ ', """*** Do not use 'clang++' in tests, use '%clangxx'. ***"""))
(' clang\+\+ ', """\"*** Do not use 'clang++' in tests, use '%clangxx'. ***\""""))
self.config.substitutions.append(
(' clang-cc ',
"""*** Do not use 'clang-cc' in tests, use '%clang_cc1'. ***"""))
"""\"*** Do not use 'clang-cc' in tests, use '%clang_cc1'. ***\""""))
self.config.substitutions.append(
(' clang-cl ',
"""\"*** Do not use 'clang-cl' in tests, use '%clang_cl'. ***\""""))
self.config.substitutions.append(
(' clang -cc1 -analyze ',
"""*** Do not use 'clang -cc1 -analyze' in tests, use '%clang_analyze_cc1'. ***"""))
"""\"*** Do not use 'clang -cc1 -analyze' in tests, use '%clang_analyze_cc1'. ***\""""))
self.config.substitutions.append(
(' clang -cc1 ',
"""*** Do not use 'clang -cc1' in tests, use '%clang_cc1'. ***"""))
"""\"*** Do not use 'clang -cc1' in tests, use '%clang_cc1'. ***\""""))
self.config.substitutions.append(
(' %clang-cc1 ',
"""*** invalid substitution, use '%clang_cc1'. ***"""))
"""\"*** invalid substitution, use '%clang_cc1'. ***\""""))
self.config.substitutions.append(
(' %clang-cpp ',
"""*** invalid substitution, use '%clang_cpp'. ***"""))
"""\"*** invalid substitution, use '%clang_cpp'. ***\""""))
self.config.substitutions.append(
(' %clang-cl ',
"""*** invalid substitution, use '%clang_cl'. ***"""))
"""\"*** invalid substitution, use '%clang_cl'. ***\""""))
def use_lld(self, required=True):
def use_lld(self, additional_tool_dirs=[], required=True):
"""Configure the test suite to be able to invoke lld.
Sets up some environment variables important to lld, locates a
@@ -450,20 +456,36 @@ class LLVMConfig(object):
substitutions useful to any test suite that makes use of lld.
"""
# Tweak the PATH to include the tools dir
tool_dirs = [self.config.llvm_tools_dir]
lib_dirs = [self.config.llvm_libs_dir]
lld_tools_dir = getattr(self.config, 'lld_tools_dir', None)
lld_libs_dir = getattr(self.config, 'lld_libs_dir', None)
if lld_tools_dir:
tool_dirs = tool_dirs + [lld_tools_dir]
if lld_libs_dir:
lib_dirs = lib_dirs + [lld_libs_dir]
# Tweak the PATH to include the tools dir and the scripts dir.
exe_dir_props = [self.config.name.lower() + '_tools_dir', 'lld_tools_dir', 'llvm_tools_dir']
paths = [getattr(self.config, pp) for pp in exe_dir_props
if getattr(self.config, pp, None)]
paths = additional_tool_dirs + paths
self.with_environment('PATH', paths, append_path=True)
self.with_environment('PATH', tool_dirs, append_path=True)
self.with_environment('LD_LIBRARY_PATH', lib_dirs, append_path=True)
lib_dir_props = [self.config.name.lower() + '_libs_dir', 'lld_libs_dir', 'llvm_libs_dir']
paths = [getattr(self.config, pp) for pp in lib_dir_props
if getattr(self.config, pp, None)]
tool_patterns = ['lld', 'ld.lld', 'lld-link', 'ld64.lld', 'wasm-ld']
self.with_environment('LD_LIBRARY_PATH', paths, append_path=True)
self.add_tool_substitutions(tool_patterns, tool_dirs)
# Discover the 'clang' and 'clangcc' to use.
ld_lld = self.use_llvm_tool('ld.lld', required=required)
lld_link = self.use_llvm_tool('lld-link', required=required)
ld64_lld = self.use_llvm_tool('ld64.lld', required=required)
wasm_ld = self.use_llvm_tool('wasm-ld', required=required)
was_found = ld_lld and lld_link and ld64_lld and wasm_ld
tool_substitutions = []
if ld_lld:
tool_substitutions.append(ToolSubst('ld.lld', command=ld_lld))
if lld_link:
tool_substitutions.append(ToolSubst('lld-link', command=lld_link))
if ld64_lld:
tool_substitutions.append(ToolSubst('ld64.lld', command=ld64_lld))
if wasm_ld:
tool_substitutions.append(ToolSubst('wasm-ld', command=wasm_ld))
self.add_tool_substitutions(tool_substitutions)
return was_found

View File

@@ -80,6 +80,7 @@ class ToolSubst(object):
self.extra_args = extra_args
self.key = key
self.command = command if command is not None else FindTool(key)
self.was_resolved = False
if verbatim:
self.regex = key
return
@@ -141,5 +142,6 @@ class ToolSubst(object):
return None
else:
raise 'Unexpected value for ToolSubst.unresolved'
if command_str:
self.was_resolved = True
return (self.regex, tool_pipe, command_str)