diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2018-07-28 11:09:23 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2018-07-28 11:09:23 +0000 |
commit | f73363f1dd94996356cefbf24388f561891acf0b (patch) | |
tree | e3c31248bdb36eaec5fd833490d4278162dba2a0 /lit | |
parent | 160ee69dd7ae18978f4068116777639ea98dc951 (diff) |
Notes
Diffstat (limited to 'lit')
104 files changed, 2772 insertions, 124 deletions
diff --git a/lit/Breakpoint/Inputs/case-sensitive.c b/lit/Breakpoint/Inputs/case-sensitive.c new file mode 100644 index 000000000000..6df38dcacd78 --- /dev/null +++ b/lit/Breakpoint/Inputs/case-sensitive.c @@ -0,0 +1,4 @@ +int main() { + int x = 47; // REGEX-THIS + return x; +} diff --git a/lit/Breakpoint/Inputs/ppc64-localentry.s b/lit/Breakpoint/Inputs/ppc64-localentry.s new file mode 100644 index 000000000000..5fe0a97d06d3 --- /dev/null +++ b/lit/Breakpoint/Inputs/ppc64-localentry.s @@ -0,0 +1,55 @@ + .text + .abiversion 2 + + .globl lfunc + .p2align 4 + .type lfunc,@function +lfunc: # @lfunc +.Lfunc_begin0: +.Lfunc_gep0: + addis 2, 12, .TOC.-.Lfunc_gep0@ha + addi 2, 2, .TOC.-.Lfunc_gep0@l +.Lfunc_lep0: + .localentry lfunc, .Lfunc_lep0-.Lfunc_gep0 +# BB#0: + mr 4, 3 + addis 3, 2, .LC0@toc@ha + ld 3, .LC0@toc@l(3) + stw 4, -12(1) + lwz 4, 0(3) + lwz 5, -12(1) + mullw 4, 4, 5 + extsw 3, 4 + blr + .long 0 + .quad 0 +.Lfunc_end0: + .size lfunc, .Lfunc_end0-.Lfunc_begin0 + + .globl simple + .p2align 4 + .type simple,@function +simple: # @simple +.Lfunc_begin1: +# %bb.0: # %entry + mr 4, 3 + stw 4, -12(1) + lwz 4, -12(1) + mulli 4, 4, 10 + extsw 3, 4 + blr + .long 0 + .quad 0 +.Lfunc_end1: + .size simple, .Lfunc_end1-.Lfunc_begin1 + + .section .toc,"aw",@progbits +.LC0: + .tc g_foo[TC],g_foo + .type g_foo,@object # @g_foo + .data + .globl g_foo + .p2align 2 +g_foo: + .long 2 # 0x2 + .size g_foo, 4 diff --git a/lit/Breakpoint/case-insensitive.test b/lit/Breakpoint/case-insensitive.test new file mode 100644 index 000000000000..841448c42990 --- /dev/null +++ b/lit/Breakpoint/case-insensitive.test @@ -0,0 +1,46 @@ +# REQUIRES: windows +# XFAIL: windows +# -> llvm.org/pr24528 +# +# RUN: %cc %p/Inputs/case-sensitive.c -g -o %t +# RUN: lldb-test breakpoints %t %s | FileCheck %s + +breakpoint set -f case-sensitive.c -l 3 +# CHECK-LABEL: breakpoint set -f case-sensitive.c -l 3 +# CHECK: At least one location. + +breakpoint set -f %p/Inputs/case-sensitive.c -l 3 +# CHECK-LABEL: breakpoint set -f {{.*}}/Inputs/case-sensitive.c -l 3 +# CHECK: At least one location. + +breakpoint set -f %p/INPUTS/case-sensitive.c -l 3 +# CHECK-LABEL: breakpoint set -f {{.*}}/INPUTS/case-sensitive.c -l 3 +# CHECK: At least one location. + +breakpoint set -f Case-Sensitive.c -l 3 +# CHECK-LABEL: breakpoint set -f Case-Sensitive.c -l 3 +# CHECK: At least one location. + +breakpoint set -f %p/INPUTS/Case-Sensitive.c -l 3 +# CHECK-LABEL: breakpoint set -f {{.*}}/INPUTS/Case-Sensitive.c -l 3 +# CHECK: At least one location. + +breakpoint set -f case-sensitive.c -p REGEX-THIS +# CHECK-LABEL: breakpoint set -f case-sensitive.c -p REGEX-THIS +# CHECK: At least one location. + +breakpoint set -f %p/Inputs/case-sensitive.c -p REGEX-THIS +# CHECK-LABEL: breakpoint set -f {{.*}}/Inputs/case-sensitive.c -p REGEX-THIS +# CHECK: At least one location. + +breakpoint set -f %p/INPUTS/case-sensitive.c -p REGEX-THIS +# CHECK-LABEL: breakpoint set -f {{.*}}/INPUTS/case-sensitive.c -p REGEX-THIS +# CHECK: At least one location. + +breakpoint set -f Case-Sensitive.c -p REGEX-THIS +# CHECK-LABEL: breakpoint set -f Case-Sensitive.c -p REGEX-THIS +# CHECK: At least one location. + +breakpoint set -f %p/INPUTS/Case-Sensitive.c -p REGEX-THIS +# CHECK-LABEL: breakpoint set -f {{.*}}/INPUTS/Case-Sensitive.c -p REGEX-THIS +# CHECK: At least one location. diff --git a/lit/Breakpoint/case-sensitive.test b/lit/Breakpoint/case-sensitive.test new file mode 100644 index 000000000000..dd5635b952d6 --- /dev/null +++ b/lit/Breakpoint/case-sensitive.test @@ -0,0 +1,46 @@ +# REQUIRES: nowindows +# +# RUN: %cc %p/Inputs/case-sensitive.c -g -o %t +# RUN: lldb-test breakpoints %t %s | FileCheck %s + +breakpoint set -f case-sensitive.c -l 3 +# CHECK-LABEL: breakpoint set -f case-sensitive.c -l 3 +# CHECK: At least one location. + +breakpoint set -f %p/Inputs/case-sensitive.c -l 3 +# CHECK-LABEL: breakpoint set -f {{.*}}/Inputs/case-sensitive.c -l 3 +# CHECK: At least one location. + +breakpoint set -f %p/INPUTS/case-sensitive.c -l 3 +# CHECK-LABEL: breakpoint set -f {{.*}}/INPUTS/case-sensitive.c -l 3 +# CHECK: 0 locations. + +breakpoint set -f Case-Sensitive.c -l 3 +# CHECK-LABEL: breakpoint set -f Case-Sensitive.c -l 3 +# CHECK: 0 locations. + +breakpoint set -f %p/INPUTS/Case-Sensitive.c -l 3 +# CHECK-LABEL: breakpoint set -f {{.*}}/INPUTS/Case-Sensitive.c -l 3 +# CHECK: 0 locations. + +breakpoint set -f case-sensitive.c -p REGEX-THIS +# CHECK-LABEL: breakpoint set -f case-sensitive.c -p REGEX-THIS +# CHECK: At least one location. + +breakpoint set -f %p/Inputs/case-sensitive.c -p REGEX-THIS +# CHECK-LABEL: breakpoint set -f {{.*}}/Inputs/case-sensitive.c -p REGEX-THIS +# CHECK: At least one location. + +breakpoint set -f %p/INPUTS/case-sensitive.c -p REGEX-THIS +# CHECK-LABEL: breakpoint set -f {{.*}}/INPUTS/case-sensitive.c -p REGEX-THIS +# CHECK: 0 locations. + +breakpoint set -f Case-Sensitive.c -p REGEX-THIS +# CHECK-LABEL: breakpoint set -f Case-Sensitive.c -p REGEX-THIS +# CHECK: 0 locations. + +breakpoint set -f %p/INPUTS/Case-Sensitive.c -p REGEX-THIS +# CHECK-LABEL: breakpoint set -f {{.*}}/INPUTS/Case-Sensitive.c -p REGEX-THIS +# CHECK: 0 locations. + + diff --git a/lit/Breakpoint/lit.local.cfg b/lit/Breakpoint/lit.local.cfg new file mode 100644 index 000000000000..df9b335dd131 --- /dev/null +++ b/lit/Breakpoint/lit.local.cfg @@ -0,0 +1 @@ +config.suffixes = ['.test'] diff --git a/lit/Breakpoint/ppc64-localentry.test b/lit/Breakpoint/ppc64-localentry.test new file mode 100644 index 000000000000..16cce703045c --- /dev/null +++ b/lit/Breakpoint/ppc64-localentry.test @@ -0,0 +1,12 @@ +# REQUIRES: powerpc +# +# RUN: llvm-mc -triple=powerpc64le -filetype=obj %p/Inputs/ppc64-localentry.s -o %t +# RUN: lldb-test breakpoints %t %s | FileCheck %s + +breakpoint set -n lfunc +# CHECK-LABEL: breakpoint set -n lfunc +# CHECK: Address: {{.*}}`lfunc + 8 + +breakpoint set -n simple +# CHECK-LABEL: breakpoint set -n simple +# CHECK: Address: {{.*}}`simple diff --git a/lit/CMakeLists.txt b/lit/CMakeLists.txt index 5488154318a9..8a93236d2cf0 100644 --- a/lit/CMakeLists.txt +++ b/lit/CMakeLists.txt @@ -1,45 +1,69 @@ -set(LLVM_SOURCE_DIR "${LLVM_MAIN_SRC_DIR}") -set(LLVM_BINARY_DIR "${LLVM_BINARY_DIR}") -set(LLVM_BUILD_MODE "%(build_mode)s") -set(LLVM_TOOLS_DIR "${LLVM_TOOLS_BINARY_DIR}/%(build_config)s") -set(LLVM_LIBS_DIR "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/%(build_config)s") -set(CLANG_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/..") -set(CLANG_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/..") +# Test runner infrastructure for LLDB. This configures the LLDB test trees +# for use by Lit, and delegates to LLVM's lit test handlers. + +if (CMAKE_CFG_INTDIR STREQUAL ".") + set(LLVM_BUILD_MODE ".") +else () + set(LLVM_BUILD_MODE "%(build_mode)s") +endif () + +if (NOT LLDB_TEST_USE_CUSTOM_C_COMPILER) + string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_TEST_C_COMPILER ${LLDB_TEST_C_COMPILER}) +endif () + +if (NOT LLDB_TEST_USE_CUSTOM_CXX_COMPILER) + string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_TEST_CXX_COMPILER ${LLDB_TEST_CXX_COMPILER}) +endif () + +get_property(LLDB_DOTEST_ARGS GLOBAL PROPERTY LLDB_DOTEST_ARGS_PROPERTY) + +string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_LIBS_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) +string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_TOOLS_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR}) +string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_DOTEST_ARGS "${LLDB_DOTEST_ARGS}") + +list(APPEND LLDB_TEST_DEPS + LLDBUnitTests + dsymutil + lldb + lldb-test + llvm-config + llvm-mc + llvm-objcopy + ) + +if(TARGET lld) + list(APPEND LLDB_TEST_DEPS lld) + set(LLDB_HAVE_LLD 1) +else() + set(LLDB_HAVE_LLD 0) +endif() + if(BUILD_SHARED_LIBS) set(ENABLE_SHARED 1) else() set(ENABLE_SHARED 0) endif(BUILD_SHARED_LIBS) +# the value is not canonicalized within LLVM +llvm_canonicalize_cmake_booleans( + LLDB_DISABLE_PYTHON + LLVM_ENABLE_ZLIB) + configure_lit_site_cfg( ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg) configure_lit_site_cfg( ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg - ) - -set(LLDB_TEST_DEPS - LLDBUnitTests - lldb - lldb-test - ) + ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg) +configure_lit_site_cfg( + ${CMAKE_CURRENT_SOURCE_DIR}/Suite/lit.site.cfg.in + ${CMAKE_CURRENT_BINARY_DIR}/Suite/lit.site.cfg) if(NOT LLDB_BUILT_STANDALONE) - list(APPEND LLDB_TEST_DEPS FileCheck not yaml2obj) -endif() - -# lldb-server is not built on every platform. -if (TARGET lldb-server) - list(APPEND LLDB_TEST_DEPS lldb-server) -endif() - -if(APPLE) - list(APPEND LLDB_TEST_DEPS debugserver) -endif() - -if(TARGET clang) - list(APPEND LLDB_TEST_DEPS clang) + list(APPEND LLDB_TEST_DEPS + FileCheck + not + ) endif() set(LLDB_TEST_PARAMS @@ -49,7 +73,7 @@ set(LLDB_TEST_PARAMS add_lit_testsuite(check-lldb-lit "Running lldb lit test suite" ${CMAKE_CURRENT_BINARY_DIR} PARAMS lldb_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg - lldb_unit_site_config=${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg + lldb_unit_site_config=${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg DEPENDS ${LLDB_TEST_DEPS} ) @@ -61,7 +85,8 @@ if (TARGET clang) add_dependencies(check-lldb-lit clang) endif() -add_lit_testsuites(LLDB ${CMAKE_CURRENT_SOURCE_DIR} +add_lit_testsuites(LLDB + ${CMAKE_CURRENT_BINARY_DIR} PARAMS lldb_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg lldb_unit_site_config=${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg DEPENDS ${LLDB_TEST_DEPS} diff --git a/lit/Expr/Inputs/anonymous-struct.cpp b/lit/Expr/Inputs/anonymous-struct.cpp deleted file mode 100644 index 5b170c5f943a..000000000000 --- a/lit/Expr/Inputs/anonymous-struct.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include <tgmath.h> - -typedef struct { - float f; - int i; -} my_untagged_struct; - -double multiply(my_untagged_struct *s) -{ - return s->f * s->i; -} - -double multiply(my_untagged_struct *s, int x) -{ - return multiply(s) * x; -} - -int main(int argc, char **argv) -{ - my_untagged_struct s = { - .f = (float)argc, - .i = argc, - }; - // lldb testsuite break - return !(multiply(&s, argc) == pow(argc, 3)); -} diff --git a/lit/Expr/Inputs/ir-memory-map-basic b/lit/Expr/Inputs/ir-memory-map-basic new file mode 100644 index 000000000000..c48392594ca7 --- /dev/null +++ b/lit/Expr/Inputs/ir-memory-map-basic @@ -0,0 +1,25 @@ +L1 = malloc 0 1 +L2 = malloc 1 1 + +L3 = malloc 2 1 +L4 = malloc 2 2 +L5 = malloc 2 4 + +L6 = malloc 3 1 +L7 = malloc 3 2 +L8 = malloc 3 4 + +L9 = malloc 128 1 +L10 = malloc 128 2 +L11 = malloc 128 4 +L12 = malloc 128 128 + +L13 = malloc 2048 1 +L14 = malloc 2048 2 +L15 = malloc 2048 4 + +L16 = malloc 3968 1 +L17 = malloc 3968 2 +L18 = malloc 3968 4 + +L19 = malloc 0 1 diff --git a/lit/Expr/Inputs/ir-memory-map-mix-malloc-free b/lit/Expr/Inputs/ir-memory-map-mix-malloc-free new file mode 100644 index 000000000000..3b57cc8bdf4c --- /dev/null +++ b/lit/Expr/Inputs/ir-memory-map-mix-malloc-free @@ -0,0 +1,272 @@ +L1 = malloc 32 2 +free L1 +L2 = malloc 3 4 +L3 = malloc 3 128 +free L3 +free L2 +L4 = malloc 2 16 +free L4 +L5 = malloc 4097 4 +free L5 +L6 = malloc 2 2 +L7 = malloc 3 2 +L8 = malloc 32 16 +free L6 +free L8 +free L7 +L9 = malloc 8192 2 +L10 = malloc 33 4 +free L9 +L11 = malloc 2047 2 +L12 = malloc 5 16 +L13 = malloc 4 16 +L14 = malloc 2048 2 +free L10 +L15 = malloc 4 128 +free L13 +L16 = malloc 1 2 +L17 = malloc 4095 128 +free L12 +free L15 +L18 = malloc 0 128 +L19 = malloc 2 128 +L20 = malloc 4096 2 +L21 = malloc 2 2 +L22 = malloc 8192 128 +L23 = malloc 4 2 +L24 = malloc 4097 4 +free L19 +free L20 +L25 = malloc 3 128 +free L23 +free L21 +free L22 +free L25 +free L16 +L26 = malloc 1 128 +L27 = malloc 4096 4 +free L14 +L28 = malloc 31 2 +free L24 +L29 = malloc 2048 128 +free L28 +free L11 +L30 = malloc 4 2 +L31 = malloc 32 16 +L32 = malloc 1 4 +free L30 +L33 = malloc 3 2 +L34 = malloc 4096 4 +free L17 +free L18 +free L32 +L35 = malloc 4097 4 +L36 = malloc 8193 2 +L37 = malloc 3 2 +free L34 +L38 = malloc 8193 16 +L39 = malloc 4096 4 +L40 = malloc 8192 16 +L41 = malloc 32 4 +free L26 +free L38 +free L37 +L42 = malloc 0 2 +free L31 +free L40 +free L36 +free L35 +L43 = malloc 2047 2 +free L41 +L44 = malloc 4 4 +free L43 +free L33 +free L42 +L45 = malloc 4097 16 +free L27 +L46 = malloc 32 128 +L47 = malloc 8191 16 +L48 = malloc 1 16 +L49 = malloc 32 128 +L50 = malloc 3 2 +L51 = malloc 4096 128 +free L51 +L52 = malloc 2048 4 +free L29 +L53 = malloc 4097 128 +free L44 +L54 = malloc 1 16 +L55 = malloc 4095 16 +L56 = malloc 2047 2 +L57 = malloc 0 2 +L58 = malloc 2048 2 +free L48 +L59 = malloc 1 4 +L60 = malloc 32 16 +free L50 +L61 = malloc 1 4 +L62 = malloc 4096 2 +free L60 +L63 = malloc 1 16 +L64 = malloc 32 128 +free L55 +L65 = malloc 8192 16 +free L57 +L66 = malloc 1 128 +free L65 +free L61 +free L45 +free L64 +free L39 +L67 = malloc 2048 2 +free L47 +L68 = malloc 2049 4 +free L63 +free L68 +free L54 +free L59 +free L52 +L69 = malloc 2 2 +L70 = malloc 8192 16 +L71 = malloc 2049 16 +L72 = malloc 3 16 +L73 = malloc 4097 16 +L74 = malloc 4096 2 +L75 = malloc 4097 4 +free L67 +free L71 +free L72 +free L75 +free L74 +L76 = malloc 3 4 +free L70 +free L69 +L77 = malloc 4 4 +free L49 +L78 = malloc 4096 16 +L79 = malloc 33 2 +free L76 +L80 = malloc 2 16 +free L58 +free L80 +free L56 +L81 = malloc 1 128 +free L73 +L82 = malloc 1 16 +free L53 +free L81 +free L77 +L83 = malloc 2 2 +L84 = malloc 3 16 +free L62 +L85 = malloc 2049 2 +free L83 +L86 = malloc 3 4 +L87 = malloc 4096 128 +free L86 +L88 = malloc 3 2 +free L82 +free L66 +free L84 +L89 = malloc 8192 4 +free L88 +L90 = malloc 3 4 +L91 = malloc 1 4 +L92 = malloc 4097 4 +L93 = malloc 5 16 +L94 = malloc 2 128 +L95 = malloc 4096 2 +L96 = malloc 32 16 +L97 = malloc 8192 16 +L98 = malloc 32 128 +free L90 +free L79 +L99 = malloc 8193 4 +free L46 +L100 = malloc 31 4 +L101 = malloc 8192 128 +free L99 +L102 = malloc 2049 16 +L103 = malloc 4 2 +L104 = malloc 32 2 +free L101 +free L98 +L105 = malloc 1 16 +free L92 +L106 = malloc 2 2 +L107 = malloc 31 16 +L108 = malloc 2 4 +free L94 +L109 = malloc 4097 4 +L110 = malloc 31 4 +free L103 +L111 = malloc 31 4 +free L111 +L112 = malloc 2049 2 +L113 = malloc 32 128 +free L106 +L114 = malloc 8191 2 +free L105 +free L97 +free L109 +L115 = malloc 2 16 +free L78 +free L93 +free L114 +free L115 +free L96 +free L85 +L116 = malloc 2 16 +free L89 +free L87 +L117 = malloc 33 2 +L118 = malloc 1 4 +L119 = malloc 4096 128 +free L107 +L120 = malloc 8192 4 +L121 = malloc 1 128 +L122 = malloc 3 4 +L123 = malloc 2047 4 +L124 = malloc 2 2 +free L121 +free L102 +L125 = malloc 2 4 +L126 = malloc 1 16 +L127 = malloc 2048 2 +L128 = malloc 2048 16 +L129 = malloc 32 128 +free L124 +L130 = malloc 2048 16 +L131 = malloc 32 16 +L132 = malloc 32 128 +free L100 +free L117 +free L126 +L133 = malloc 8192 4 +L134 = malloc 8192 2 +L135 = malloc 2 16 +free L119 +L136 = malloc 31 16 +free L118 +free L125 +free L132 +free L122 +free L134 +free L136 +free L130 +free L110 +free L123 +free L104 +free L116 +free L133 +free L91 +free L113 +free L128 +free L129 +free L95 +free L131 +free L127 +free L112 +free L108 +free L135 +free L120
\ No newline at end of file diff --git a/lit/Expr/Inputs/ir-memory-map-overlap1 b/lit/Expr/Inputs/ir-memory-map-overlap1 new file mode 100644 index 000000000000..6e842671fba7 --- /dev/null +++ b/lit/Expr/Inputs/ir-memory-map-overlap1 @@ -0,0 +1,10 @@ +L1 = malloc 8 16 +L2 = malloc 16 8 +L3 = malloc 64 32 +L4 = malloc 1 8 +L5 = malloc 64 32 +L6 = malloc 64 8 +L7 = malloc 1024 32 +L8 = malloc 1 16 +L9 = malloc 8 16 +L10 = malloc 1024 16 diff --git a/lit/Expr/TestCallStdStringFunction.test b/lit/Expr/TestCallStdStringFunction.test deleted file mode 100644 index dadb5dbd0961..000000000000 --- a/lit/Expr/TestCallStdStringFunction.test +++ /dev/null @@ -1,14 +0,0 @@ -# XFAIL: windows -# -> llvm.org/pr21765 - -# XFAIL: freebsd -# -> llvm.org/pr17807 - -# RUN: %cxx %p/Inputs/call-function.cpp -g -o %t && %lldb -b -s %s -- %t | FileCheck %s - -breakpoint set --file call-function.cpp --line 52 -run -print str -# CHECK: Hello world -print str.c_str() -# CHECK: Hello world diff --git a/lit/Expr/TestCallStopAndContinue.test b/lit/Expr/TestCallStopAndContinue.test deleted file mode 100644 index 263fa2a6f59a..000000000000 --- a/lit/Expr/TestCallStopAndContinue.test +++ /dev/null @@ -1,12 +0,0 @@ -# XFAIL: windows -# -> llvm.org/pr24489 - -# RUN: %cxx %p/Inputs/call-function.cpp -g -o %t && %lldb -b -s %s -o continue -o "thread list" -- %t 2>&1 | FileCheck %s - -breakpoint set --file call-function.cpp --line 52 -run -breakpoint set --file call-function.cpp --line 14 -expression -i false -- returnsFive() -# CHECK: Execution was interrupted, reason: breakpoint -# CHECK: stop reason = User Expression thread plan -# CHECK: Completed expression: (Five) $0 = (number = 5{{.*}}, name = "five") diff --git a/lit/Expr/TestCallUserAnonTypedef.test b/lit/Expr/TestCallUserAnonTypedef.test deleted file mode 100644 index 510f40c22e2d..000000000000 --- a/lit/Expr/TestCallUserAnonTypedef.test +++ /dev/null @@ -1,11 +0,0 @@ -# XFAIL: windows - -# XFAIL: armhf-linux -# -> llvm.org/pr27868 - -# RUN: %cxx %p/Inputs/anonymous-struct.cpp -g -o %t && %lldb -b -s %s -- %t | FileCheck %s - -breakpoint set --file anonymous-struct.cpp --line 24 -run -expression multiply(&s) -# CHECK: $0 = 1 diff --git a/lit/Expr/TestCallUserDefinedFunction.test b/lit/Expr/TestCallUserDefinedFunction.test deleted file mode 100644 index 0c98a9bae78c..000000000000 --- a/lit/Expr/TestCallUserDefinedFunction.test +++ /dev/null @@ -1,20 +0,0 @@ -# XFAIL: windows -# -> llvm.org/pr24489 - -# RUN: %cxx %p/Inputs/call-function.cpp -g -o %t && %lldb -b -s %s -- %t | FileCheck %s - -breakpoint set --file call-function.cpp --line 52 -run -expression fib(5) -# CHECK: $0 = 5 -expression add(4,8) -# CHECK: $1 = 12 - -expression add(add(5,2),add(3,4)) -# CHECK: $2 = 14 -expression add(add(5,2),fib(5)) -# CHECK: $3 = 12 -expression stringCompare((const char*) "Hello world") -# CHECK: $4 = true -expression stringCompare((const char*) "Hellworld") -# CHECK: $5 = false diff --git a/lit/Expr/TestIRMemoryMap.test b/lit/Expr/TestIRMemoryMap.test new file mode 100644 index 000000000000..23595945011d --- /dev/null +++ b/lit/Expr/TestIRMemoryMap.test @@ -0,0 +1,12 @@ +# XFAIL: windows + +# RUN: %cxx %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 + +# RUN: lldb-test ir-memory-map %t %S/Inputs/ir-memory-map-overlap1 +# RUN: lldb-test ir-memory-map -host-only %t %S/Inputs/ir-memory-map-overlap1 + +# RUN: lldb-test ir-memory-map %t %S/Inputs/ir-memory-map-mix-malloc-free +# RUN: lldb-test ir-memory-map -host-only %t %S/Inputs/ir-memory-map-mix-malloc-free diff --git a/lit/Expr/TestTypeOfDeclTypeExpr.test b/lit/Expr/TestTypeOfDeclTypeExpr.test new file mode 100644 index 000000000000..c156ae556a71 --- /dev/null +++ b/lit/Expr/TestTypeOfDeclTypeExpr.test @@ -0,0 +1,13 @@ +# RUN: %lldb -b -s %s | FileCheck %s + +expression int i; __typeof__(i) j = 1; j +# CHECK: (lldb) expression int i; __typeof__(i) j = 1; j +# CHECK-NEXT: (typeof (i)) {{.*}} = 1 + +expression int i; typeof(i) j = 1; j +# CHECK: (lldb) expression int i; typeof(i) j = 1; j +# CHECK-NEXT: (typeof (i)) {{.*}} = 1 + +expression int i; decltype(i) j = 1; j +# CHECK: (lldb) expression int i; decltype(i) j = 1; j +# CHECK-NEXT: (decltype(i)) {{.*}} = 1 diff --git a/lit/Modules/build-id-case.yaml b/lit/Modules/build-id-case.yaml new file mode 100644 index 000000000000..246163ad52af --- /dev/null +++ b/lit/Modules/build-id-case.yaml @@ -0,0 +1,43 @@ +# RUN: mkdir -p %t/.build-id/1b +# RUN: yaml2obj %s > %t/.build-id/1b/8a73ac238390e32a7ff4ac8ebe4d6a41ecf5c9.debug +# RUN: cd %t +# RUN: llvm-objcopy --strip-all --add-gnu-debuglink=.build-id/1b/8a73ac238390e32a7ff4ac8ebe4d6a41ecf5c9.debug %t/.build-id/1b/8a73ac238390e32a7ff4ac8ebe4d6a41ecf5c9.debug %t/stripped.out +# RUN: lldb-test object-file %t/stripped.out | FileCheck %s + +# CHECK: Name: .debug_frame +# CHECK-NEXT: Type: dwarf-frame +# CHECK-NEXT: VM size: 0 +# CHECK-NEXT: File size: 8 + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_X86_64 + Entry: 0x00000000004003D0 +Sections: + - Name: .note.gnu.build-id + Type: SHT_NOTE + Flags: [ SHF_ALLOC ] + Address: 0x0000000000400274 + AddressAlign: 0x0000000000000004 + Content: 040000001400000003000000474E55001B8A73AC238390E32A7FF4AC8EBE4D6A41ECF5C9 + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Address: 0x00000000004003D0 + AddressAlign: 0x0000000000000010 + Content: DEADBEEFBAADF00D + - Name: .debug_frame + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000008 + Content: DEADBEEFBAADF00D +Symbols: + Local: + - Name: main + Type: STT_FUNC + Section: .text + Value: 0x00000000004003D0 + Size: 0x0000000000000008 +... diff --git a/lit/Modules/compressed-sections.yaml b/lit/Modules/compressed-sections.yaml index 0eabd99f2d6d..c75dc857522a 100644 --- a/lit/Modules/compressed-sections.yaml +++ b/lit/Modules/compressed-sections.yaml @@ -1,6 +1,6 @@ # REQUIRES: zlib # RUN: yaml2obj %s > %t -# RUN: lldb-test module-sections --contents %t | FileCheck %s +# RUN: lldb-test object-file --contents %t | FileCheck %s --- !ELF FileHeader: Class: ELFCLASS32 @@ -18,12 +18,14 @@ Sections: Content: deadbeefbaadf00d # CHECK: Name: .hello_elf +# CHECK-NEXT: Type: regular # CHECK-NEXT: VM size: 0 # CHECK-NEXT: File size: 28 # CHECK-NEXT: Data: # CHECK-NEXT: 20304050 60708090 # CHECK: Name: .bogus +# CHECK-NEXT: Type: regular # CHECK-NEXT: VM size: 0 # CHECK-NEXT: File size: 8 # CHECK-NEXT: Data: diff --git a/lit/Modules/elf-duplicate-section.yaml b/lit/Modules/elf-duplicate-section.yaml new file mode 100644 index 000000000000..b4b391cc912d --- /dev/null +++ b/lit/Modules/elf-duplicate-section.yaml @@ -0,0 +1,42 @@ +# RUN: mkdir -p %t/.build-id/1b +# RUN: yaml2obj %s > %t/.build-id/1b/8a73ac238390e32a7ff4ac8ebe4d6a41ecf5c9.debug +# RUN: cd %t +# RUN: llvm-objcopy --strip-all --add-gnu-debuglink=.build-id/1b/8a73ac238390e32a7ff4ac8ebe4d6a41ecf5c9.debug %t/.build-id/1b/8a73ac238390e32a7ff4ac8ebe4d6a41ecf5c9.debug %t/stripped.out +# RUN: lldb-test object-file %t/stripped.out | FileCheck %s + +# Make sure that the debug_frame section is present only once. +# CHECK: Name: .debug_frame +# CHECK-NOT: .debug_frame + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_X86_64 + Entry: 0x00000000004003D0 +Sections: + - Name: .note.gnu.build-id + Type: SHT_NOTE + Flags: [ SHF_ALLOC ] + Address: 0x0000000000400274 + AddressAlign: 0x0000000000000004 + Content: 040000001400000003000000474E55001B8A73AC238390E32A7FF4AC8EBE4D6A41ECF5C9 + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Address: 0x00000000004003D0 + AddressAlign: 0x0000000000000010 + Content: DEADBEEFBAADF00D + - Name: .debug_frame + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000008 + Content: DEADBEEFBAADF00D +Symbols: + Local: + - Name: main + Type: STT_FUNC + Section: .text + Value: 0x00000000004003D0 + Size: 0x0000000000000008 +... diff --git a/lit/Modules/elf-many-sections.s b/lit/Modules/elf-many-sections.s new file mode 100644 index 000000000000..a5e4aee18821 --- /dev/null +++ b/lit/Modules/elf-many-sections.s @@ -0,0 +1,72 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux %s -o %t +# RUN: lldb-test object-file %t | FileCheck %s + +## Check that we are able to parse ELF files with more than SHN_LORESERVE +## sections. This generates a file that contains 64k sections from +## aaaaaaaa..dddddddd, plus a couple of standard ones (.strtab, etc.) +## Check the number is correct plus the names of a couple of chosen sections. + +# CHECK: Showing 65541 sections +# CHECK: Name: aaaaaaaa +# CHECK: Name: bbbbbbbb +# CHECK: Name: cccccccc +# CHECK: Name: abcdabcd +# CHECK: Name: dddddddd + +.macro gen_sections4 x + .section a\x + .section b\x + .section c\x + .section d\x +.endm + +.macro gen_sections16 x + gen_sections4 a\x + gen_sections4 b\x + gen_sections4 c\x + gen_sections4 d\x +.endm + +.macro gen_sections64 x + gen_sections16 a\x + gen_sections16 b\x + gen_sections16 c\x + gen_sections16 d\x +.endm + +.macro gen_sections256 x + gen_sections64 a\x + gen_sections64 b\x + gen_sections64 c\x + gen_sections64 d\x +.endm + +.macro gen_sections1024 x + gen_sections256 a\x + gen_sections256 b\x + gen_sections256 c\x + gen_sections256 d\x +.endm + +.macro gen_sections4096 x + gen_sections1024 a\x + gen_sections1024 b\x + gen_sections1024 c\x + gen_sections1024 d\x +.endm + +.macro gen_sections16384 x + gen_sections4096 a\x + gen_sections4096 b\x + gen_sections4096 c\x + gen_sections4096 d\x +.endm + +gen_sections16384 a +gen_sections16384 b +gen_sections16384 c +gen_sections16384 d + +.global _start +_start: diff --git a/lit/Modules/elf-section-types.yaml b/lit/Modules/elf-section-types.yaml new file mode 100644 index 000000000000..64906a9acf8b --- /dev/null +++ b/lit/Modules/elf-section-types.yaml @@ -0,0 +1,62 @@ +# RUN: yaml2obj %s > %t +# RUN: lldb-test object-file %t | FileCheck %s + +# CHECK: Name: .text +# CHECK-NEXT: Type: code + +# CHECK: Name: .debug_info +# CHECK-NEXT: Type: dwarf-info +# CHECK-NEXT: VM size: 0 +# CHECK-NEXT: File size: 8 + +# CHECK: Name: .debug_types +# CHECK-NEXT: Type: dwarf-types +# CHECK-NEXT: VM size: 0 +# CHECK-NEXT: File size: 8 + +# CHECK: Name: .debug_names +# CHECK-NEXT: Type: dwarf-names +# CHECK-NEXT: VM size: 0 +# CHECK-NEXT: File size: 8 + +# CHECK: Name: .gnu_debugaltlink +# CHECK-NEXT: Type: dwarf-gnu-debugaltlink +# CHECK-NEXT: VM size: 0 +# CHECK-NEXT: File size: 8 + +# CHECK: Name: __codesection +# CHECK-NEXT: Type: code + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_DYN + Machine: EM_X86_64 + Entry: 0x00000000000007A0 +Sections: + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Content: DEADBEEFBAADF00D + - Name: .debug_info + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: DEADBEEFBAADF00D + - Name: .debug_types + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: DEADBEEFBAADF00D + - Name: .debug_names + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: DEADBEEFBAADF00D + - Name: .gnu_debugaltlink + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: DEADBEEFBAADF00D + - Name: __codesection + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Content: DEADBEEFBAADF00D +... diff --git a/lit/Modules/lc_version_min.yaml b/lit/Modules/lc_version_min.yaml new file mode 100644 index 000000000000..e79107069f33 --- /dev/null +++ b/lit/Modules/lc_version_min.yaml @@ -0,0 +1,205 @@ +# RUN: yaml2obj %s > %t.out +# RUN: lldb-test object-file %t.out | FileCheck %s + +# Test that the deployment target is parsed from the load commands. +# CHECK: Architecture: x86_64-apple-macosx10.9.0 +--- !mach-o +FileHeader: + magic: 0xFEEDFACF + cputype: 0x01000007 + cpusubtype: 0x80000003 + filetype: 0x00000002 + ncmds: 14 + sizeofcmds: 728 + flags: 0x00200085 + reserved: 0x00000000 +LoadCommands: + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: __PAGEZERO + vmaddr: 0 + vmsize: 4294967296 + fileoff: 0 + filesize: 0 + maxprot: 0 + initprot: 0 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 232 + segname: __TEXT + vmaddr: 4294967296 + vmsize: 4096 + fileoff: 0 + filesize: 4096 + maxprot: 7 + initprot: 5 + nsects: 2 + flags: 0 + Sections: + - sectname: __text + segname: __TEXT + addr: 0x0000000100000FB0 + size: 8 + offset: 0x00000FB0 + align: 0 + reloff: 0x00000000 + nreloc: 0 + flags: 0x80000400 + reserved1: 0x00000000 + reserved2: 0x00000000 + reserved3: 0x00000000 + - sectname: __unwind_info + segname: __TEXT + addr: 0x0000000100000FB8 + size: 72 + offset: 0x00000FB8 + align: 2 + reloff: 0x00000000 + nreloc: 0 + flags: 0x00000000 + reserved1: 0x00000000 + reserved2: 0x00000000 + reserved3: 0x00000000 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: __LINKEDIT + vmaddr: 4294971392 + vmsize: 4096 + fileoff: 4096 + filesize: 152 + maxprot: 7 + initprot: 1 + nsects: 0 + flags: 0 + - cmd: LC_DYLD_INFO_ONLY + cmdsize: 48 + rebase_off: 0 + rebase_size: 0 + bind_off: 0 + bind_size: 0 + weak_bind_off: 0 + weak_bind_size: 0 + lazy_bind_off: 0 + lazy_bind_size: 0 + export_off: 4096 + export_size: 48 + - cmd: LC_SYMTAB + cmdsize: 24 + symoff: 4152 + nsyms: 3 + stroff: 4200 + strsize: 48 + - cmd: LC_DYSYMTAB + cmdsize: 80 + ilocalsym: 0 + nlocalsym: 0 + iextdefsym: 0 + nextdefsym: 2 + iundefsym: 2 + nundefsym: 1 + tocoff: 0 + ntoc: 0 + modtaboff: 0 + nmodtab: 0 + extrefsymoff: 0 + nextrefsyms: 0 + indirectsymoff: 0 + nindirectsyms: 0 + extreloff: 0 + nextrel: 0 + locreloff: 0 + nlocrel: 0 + - cmd: LC_LOAD_DYLINKER + cmdsize: 32 + name: 12 + PayloadString: /usr/lib/dyld + ZeroPadBytes: 7 + - cmd: LC_UUID + cmdsize: 24 + uuid: E75E737C-4FB3-312D-9B17-10987F48F957 + - cmd: LC_VERSION_MIN_MACOSX + cmdsize: 16 + version: 657664 + sdk: 658944 + - cmd: LC_SOURCE_VERSION + cmdsize: 16 + version: 0 + - cmd: LC_MAIN + cmdsize: 24 + entryoff: 4016 + stacksize: 0 + - cmd: LC_LOAD_DYLIB + cmdsize: 56 + dylib: + name: 24 + timestamp: 2 + current_version: 82102276 + compatibility_version: 65536 + PayloadString: /usr/lib/libSystem.B.dylib + ZeroPadBytes: 6 + - cmd: LC_FUNCTION_STARTS + cmdsize: 16 + dataoff: 4144 + datasize: 8 + - cmd: LC_DATA_IN_CODE + cmdsize: 16 + dataoff: 4152 + datasize: 0 +LinkEditData: + ExportTrie: + TerminalSize: 0 + NodeOffset: 0 + Name: '' + Flags: 0x0000000000000000 + Address: 0x0000000000000000 + Other: 0x0000000000000000 + ImportName: '' + Children: + - TerminalSize: 0 + NodeOffset: 5 + Name: _ + Flags: 0x0000000000000000 + Address: 0x0000000000000000 + Other: 0x0000000000000000 + ImportName: '' + Children: + - TerminalSize: 2 + NodeOffset: 33 + Name: _mh_execute_header + Flags: 0x0000000000000000 + Address: 0x0000000000000000 + Other: 0x0000000000000000 + ImportName: '' + - TerminalSize: 3 + NodeOffset: 37 + Name: main + Flags: 0x0000000000000000 + Address: 0x0000000000000FB0 + Other: 0x0000000000000000 + ImportName: '' + NameList: + - n_strx: 2 + n_type: 0x0F + n_sect: 1 + n_desc: 16 + n_value: 4294967296 + - n_strx: 22 + n_type: 0x0F + n_sect: 1 + n_desc: 0 + n_value: 4294971312 + - n_strx: 28 + n_type: 0x01 + n_sect: 0 + n_desc: 256 + n_value: 0 + StringTable: + - ' ' + - __mh_execute_header + - _main + - dyld_stub_binder + - '' + - '' + - '' +... diff --git a/lit/Modules/lit.local.cfg b/lit/Modules/lit.local.cfg index 8169b9f95e11..71a6605683a4 100644 --- a/lit/Modules/lit.local.cfg +++ b/lit/Modules/lit.local.cfg @@ -1 +1 @@ -config.suffixes = ['.yaml'] +config.suffixes = ['.s', '.yaml'] diff --git a/lit/Modules/short-build-id.yaml b/lit/Modules/short-build-id.yaml new file mode 100644 index 000000000000..907813473920 --- /dev/null +++ b/lit/Modules/short-build-id.yaml @@ -0,0 +1,26 @@ +# RUN: yaml2obj %s >%t +# RUN: lldb-test object-file %t | FileCheck %s + +# CHECK: UUID: 333059A4-3CC3-D5F9 + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_X86_64 + Entry: 0x0000000000201000 +Sections: + - Name: .note.gnu.build-id + Type: SHT_NOTE + Flags: [ SHF_ALLOC ] + Address: 0x0000000000200190 + AddressAlign: 0x0000000000000004 + Content: 040000000800000003000000474E5500333059A43CC3D5F9 + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Address: 0x0000000000201000 + AddressAlign: 0x0000000000000004 + Content: '' +... diff --git a/lit/Quit/TestQuitExitCode-30.test b/lit/Quit/TestQuitExitCode-30.test new file mode 100644 index 000000000000..0f6eff927f0c --- /dev/null +++ b/lit/Quit/TestQuitExitCode-30.test @@ -0,0 +1,3 @@ +# UNSUPPORTED: windows +# RUN: python %S/expect_exit_code.py 226 %lldb -b -s %s +q -30 diff --git a/lit/Quit/TestQuitExitCode0.test b/lit/Quit/TestQuitExitCode0.test new file mode 100644 index 000000000000..c15cb5e9ea7b --- /dev/null +++ b/lit/Quit/TestQuitExitCode0.test @@ -0,0 +1,3 @@ +# UNSUPPORTED: windows +# RUN: %lldb -b -s %s +q 0 diff --git a/lit/Quit/TestQuitExitCode30.test b/lit/Quit/TestQuitExitCode30.test new file mode 100644 index 000000000000..b5249400ec2f --- /dev/null +++ b/lit/Quit/TestQuitExitCode30.test @@ -0,0 +1,3 @@ +# UNSUPPORTED: windows +# RUN: python %S/expect_exit_code.py 30 %lldb -b -s %s +q 30 diff --git a/lit/Quit/TestQuitExitCodeHex0.test b/lit/Quit/TestQuitExitCodeHex0.test new file mode 100644 index 000000000000..3e1fc5dbeeb1 --- /dev/null +++ b/lit/Quit/TestQuitExitCodeHex0.test @@ -0,0 +1,3 @@ +# UNSUPPORTED: windows +# RUN: %lldb -b -s %s +q 0x0 diff --git a/lit/Quit/TestQuitExitCodeHexA.test b/lit/Quit/TestQuitExitCodeHexA.test new file mode 100644 index 000000000000..e06c25b0619f --- /dev/null +++ b/lit/Quit/TestQuitExitCodeHexA.test @@ -0,0 +1,3 @@ +# UNSUPPORTED: windows +# RUN: python %S/expect_exit_code.py 10 %lldb -b -s %s +q 0xA diff --git a/lit/Quit/TestQuitExitCodeImplicit0.test b/lit/Quit/TestQuitExitCodeImplicit0.test new file mode 100644 index 000000000000..1a95e8dc0bf1 --- /dev/null +++ b/lit/Quit/TestQuitExitCodeImplicit0.test @@ -0,0 +1,3 @@ +# UNSUPPORTED: windows +# RUN: %lldb -b -s %s +q diff --git a/lit/Quit/TestQuitExitCodeNonInt.test b/lit/Quit/TestQuitExitCodeNonInt.test new file mode 100644 index 000000000000..2b54163d6489 --- /dev/null +++ b/lit/Quit/TestQuitExitCodeNonInt.test @@ -0,0 +1,4 @@ +# UNSUPPORTED: windows +# RUN: %lldb -b -s %s 2>&1 | FileCheck %s +q str +// CHECK: Couldn't parse 'str' diff --git a/lit/Quit/TestQuitExitCodeTooManyArgs.test b/lit/Quit/TestQuitExitCodeTooManyArgs.test new file mode 100644 index 000000000000..05be357fd57a --- /dev/null +++ b/lit/Quit/TestQuitExitCodeTooManyArgs.test @@ -0,0 +1,4 @@ +# UNSUPPORTED: windows +# RUN: %lldb -b -s %s 2>&1 | FileCheck %s +q 1 2 +// CHECK: Too many arguments for 'quit' diff --git a/lit/Quit/expect_exit_code.py b/lit/Quit/expect_exit_code.py new file mode 100755 index 000000000000..f4a7590b7d52 --- /dev/null +++ b/lit/Quit/expect_exit_code.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python2 + +import subprocess +import sys + +args = sys.argv + +expected_exit_code = args[1] + +args = args[2:] +print("Running " + (" ".join(args))) +real_exit_code = subprocess.call(args) + +if str(real_exit_code) != expected_exit_code: + print("Got exit code %d but expected %s" % (real_exit_code, expected_exit_code)) + exit(1) diff --git a/lit/Quit/lit.local.cfg b/lit/Quit/lit.local.cfg new file mode 100644 index 000000000000..df9b335dd131 --- /dev/null +++ b/lit/Quit/lit.local.cfg @@ -0,0 +1 @@ +config.suffixes = ['.test'] diff --git a/lit/Suite/lit.cfg b/lit/Suite/lit.cfg new file mode 100644 index 000000000000..eb0fac9541ac --- /dev/null +++ b/lit/Suite/lit.cfg @@ -0,0 +1,37 @@ +# -*- Python -*- + +# Configuration file for the 'lit' test runner. + +import os +import shlex + +import lit.formats + +# name: The name of this test suite. +config.name = 'lldb-Suite' + +# suffixes: A list of file extensions to treat as test files. +config.suffixes = ['.py'] + +# test_source_root: The root path where tests are located. +# test_exec_root: The root path where tests should be run. +config.test_source_root = os.path.join(config.lldb_src_root, 'packages', + 'Python', 'lldbsuite', 'test') +config.test_exec_root = config.test_source_root + +# Build dotest command. +dotest_cmd = [config.dotest_path, '-q'] +dotest_cmd.extend(config.dotest_args_str.split(';')) + +# We don't want to force users passing arguments to lit to use `;` as a +# separator. We use Python's simple lexical analyzer to turn the args into a +# list. +if config.dotest_lit_args_str: + dotest_cmd.extend(shlex.split(config.dotest_lit_args_str)) + +# Load LLDB test format. +sys.path.append(os.path.join(config.lldb_src_root, "lit", "Suite")) +import lldbtest + +# testFormat: The test format to use to interpret tests. +config.test_format = lldbtest.LLDBTest(dotest_cmd) diff --git a/lit/Suite/lit.site.cfg.in b/lit/Suite/lit.site.cfg.in new file mode 100644 index 000000000000..40f3310c6129 --- /dev/null +++ b/lit/Suite/lit.site.cfg.in @@ -0,0 +1,37 @@ +@LIT_SITE_CFG_IN_HEADER@ + +config.test_exec_root = "@LLVM_BINARY_DIR@" +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_build_mode = "@LLVM_BUILD_MODE@" +config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@" +config.lldb_obj_root = "@LLDB_BINARY_DIR@" +config.lldb_src_root = "@LLDB_SOURCE_DIR@" +config.target_triple = "@TARGET_TRIPLE@" +config.python_executable = "@PYTHON_EXECUTABLE@" +config.dotest_path = "@LLDB_SOURCE_DIR@/test/dotest.py" +config.dotest_args_str = "@LLDB_DOTEST_ARGS@" +config.lldb_disable_python = @LLDB_DISABLE_PYTHON@ +config.dotest_lit_args_str = None + +# Additional dotest arguments can be passed to lit by providing a +# semicolon-separates list: --param dotest-args="arg;arg". +dotest_lit_args_str = lit_config.params.get('dotest-args', None) +if dotest_lit_args_str: + config.dotest_lit_args_str = dotest_lit_args_str + +# 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.dotest_args_str = config.dotest_args_str % lit_config.params + config.llvm_build_mode = config.llvm_build_mode % lit_config.params +except KeyError as e: + key, = e.args + lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key,key)) + +# Let the main config do the real work. +lit_config.load_config(config, "@LLDB_SOURCE_DIR@/lit/Suite/lit.cfg") diff --git a/lit/Suite/lldbtest.py b/lit/Suite/lldbtest.py new file mode 100644 index 000000000000..fbdab183a4a3 --- /dev/null +++ b/lit/Suite/lldbtest.py @@ -0,0 +1,70 @@ +from __future__ import absolute_import +import os + +import subprocess +import sys + +import lit.Test +import lit.TestRunner +import lit.util +from lit.formats.base import TestFormat + + +class LLDBTest(TestFormat): + def __init__(self, dotest_cmd): + self.dotest_cmd = dotest_cmd + + def getTestsInDirectory(self, testSuite, path_in_suite, litConfig, + localConfig): + source_path = testSuite.getSourcePath(path_in_suite) + for filename in os.listdir(source_path): + # Ignore dot files and excluded tests. + if (filename.startswith('.') or filename in localConfig.excludes): + continue + + # Ignore files that don't start with 'Test'. + if not filename.startswith('Test'): + continue + + filepath = os.path.join(source_path, filename) + if not os.path.isdir(filepath): + base, ext = os.path.splitext(filename) + if ext in localConfig.suffixes: + yield lit.Test.Test(testSuite, path_in_suite + + (filename, ), localConfig) + + def execute(self, test, litConfig): + if litConfig.noExecute: + return lit.Test.PASS, '' + + if test.config.lldb_disable_python: + return (lit.Test.UNSUPPORTED, 'Python module disabled') + + if test.config.unsupported: + return (lit.Test.UNSUPPORTED, 'Test is unsupported') + + testPath, testFile = os.path.split(test.getSourcePath()) + # On Windows, the system does not always correctly interpret shebang lines. + # To make sure we can execute the tests, add python exe as the first parameter + # of the command. + cmd = [sys.executable] + self.dotest_cmd + [testPath, '-p', testFile] + + try: + out, err, exitCode = lit.util.executeCommand( + cmd, + env=test.config.environment, + timeout=litConfig.maxIndividualTestTime) + except lit.util.ExecuteCommandTimeoutException: + return (lit.Test.TIMEOUT, 'Reached timeout of {} seconds'.format( + litConfig.maxIndividualTestTime)) + + if exitCode: + return lit.Test.FAIL, out + err + + passing_test_line = 'RESULT: PASSED' + if passing_test_line not in out and passing_test_line not in err: + msg = ('Unable to find %r in dotest output:\n\n%s%s' % + (passing_test_line, out, err)) + return lit.Test.UNRESOLVED, msg + + return lit.Test.PASS, '' diff --git a/lit/SymbolFile/DWARF/Inputs/find-variable-file-2.cpp b/lit/SymbolFile/DWARF/Inputs/find-variable-file-2.cpp new file mode 100644 index 000000000000..cd02cb07c62c --- /dev/null +++ b/lit/SymbolFile/DWARF/Inputs/find-variable-file-2.cpp @@ -0,0 +1,3 @@ +namespace two { +int foo; +} diff --git a/lit/SymbolFile/DWARF/apple-index-is-used.cpp b/lit/SymbolFile/DWARF/apple-index-is-used.cpp new file mode 100644 index 000000000000..104d86756e48 --- /dev/null +++ b/lit/SymbolFile/DWARF/apple-index-is-used.cpp @@ -0,0 +1,8 @@ +// Test that we use the apple indexes. +// RUN: clang %s -g -c -o %t --target=x86_64-apple-macosx +// RUN: lldb-test symbols %t | FileCheck %s + +// CHECK: .apple_names index present +// CHECK: .apple_types index present + +int foo; diff --git a/lit/SymbolFile/DWARF/debug-names-compressed.cpp b/lit/SymbolFile/DWARF/debug-names-compressed.cpp new file mode 100644 index 000000000000..076cac192522 --- /dev/null +++ b/lit/SymbolFile/DWARF/debug-names-compressed.cpp @@ -0,0 +1,14 @@ +// Test for a bug where we crashed while processing a compressed debug_names +// section (use after free). + +// REQUIRES: lld, zlib + +// 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 + +// CHECK: Found 1 variables: +int foo; +// ONE-DAG: name = "foo", type = {{.*}} (int), {{.*}} decl = debug-names-compressed.cpp:[[@LINE-1]] + +extern "C" void _start() {} diff --git a/lit/SymbolFile/DWARF/dwarf5-index-is-used.cpp b/lit/SymbolFile/DWARF/dwarf5-index-is-used.cpp new file mode 100644 index 000000000000..14d2bc076d78 --- /dev/null +++ b/lit/SymbolFile/DWARF/dwarf5-index-is-used.cpp @@ -0,0 +1,13 @@ +// Test that we use the DWARF v5 name indexes. + +// REQUIRES: lld + +// 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 %t | FileCheck %s + +// CHECK: Name Index +// CHECK: String: 0x{{.*}} "_start" +// CHECK: Tag: DW_TAG_subprogram + +extern "C" void _start() {} diff --git a/lit/SymbolFile/DWARF/dwarf5-partial-index.cpp b/lit/SymbolFile/DWARF/dwarf5-partial-index.cpp new file mode 100644 index 000000000000..3a2cf0122951 --- /dev/null +++ b/lit/SymbolFile/DWARF/dwarf5-partial-index.cpp @@ -0,0 +1,23 @@ +// Test that we return complete results when only a part of the binary is built +// with an index. + +// 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: ld.lld %t-1.o %t-2.o -o %t +// RUN: lldb-test symbols --find=variable --name=foo %t | FileCheck %s + +// CHECK: Found 2 variables: +#ifdef ONE +namespace one { +int foo; +// CHECK-DAG: name = "foo", {{.*}} decl = dwarf5-partial-index.cpp:[[@LINE-1]] +} // namespace one +extern "C" void _start() {} +#else +namespace two { +int foo; +// CHECK-DAG: name = "foo", {{.*}} decl = dwarf5-partial-index.cpp:[[@LINE-1]] +} // namespace two +#endif diff --git a/lit/SymbolFile/DWARF/find-basic-function.cpp b/lit/SymbolFile/DWARF/find-basic-function.cpp new file mode 100644 index 000000000000..d04c94b38547 --- /dev/null +++ b/lit/SymbolFile/DWARF/find-basic-function.cpp @@ -0,0 +1,106 @@ +// REQUIRES: lld + +// 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 +// RUN: lldb-test symbols --name=foo --find=function --function-flags=method %t | \ +// RUN: FileCheck --check-prefix=METHOD %s +// RUN: lldb-test symbols --name=foo --find=function --function-flags=full %t | \ +// RUN: FileCheck --check-prefix=FULL %s +// RUN: lldb-test symbols --name=_Z3fooi --find=function --function-flags=full %t | \ +// RUN: FileCheck --check-prefix=FULL-MANGLED %s +// RUN: lldb-test symbols --name=foo --context=context --find=function --function-flags=base %t | \ +// RUN: FileCheck --check-prefix=CONTEXT %s +// 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: 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 | \ +// RUN: FileCheck --check-prefix=METHOD %s +// RUN: lldb-test symbols --name=foo --find=function --function-flags=full %t | \ +// RUN: FileCheck --check-prefix=FULL %s +// RUN: lldb-test symbols --name=_Z3fooi --find=function --function-flags=full %t | \ +// RUN: FileCheck --check-prefix=FULL-MANGLED %s +// RUN: lldb-test symbols --name=foo --context=context --find=function --function-flags=base %t | \ +// RUN: FileCheck --check-prefix=CONTEXT %s +// 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: ld.lld %t.o -o %t +// 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 | \ +// RUN: FileCheck --check-prefix=METHOD %s +// RUN: lldb-test symbols --name=foo --find=function --function-flags=full %t | \ +// RUN: FileCheck --check-prefix=FULL %s +// RUN: lldb-test symbols --name=_Z3fooi --find=function --function-flags=full %t | \ +// RUN: FileCheck --check-prefix=FULL-MANGLED %s +// RUN: lldb-test symbols --name=foo --context=context --find=function --function-flags=base %t | \ +// RUN: FileCheck --check-prefix=CONTEXT %s +// RUN: lldb-test symbols --name=not_there --find=function %t | \ +// RUN: FileCheck --check-prefix=EMPTY %s + +// BASE: Found 4 functions: +// BASE-DAG: name = "foo()", mangled = "_Z3foov" +// BASE-DAG: name = "foo(int)", mangled = "_Z3fooi" +// BASE-DAG: name = "bar::foo()", mangled = "_ZN3bar3fooEv" +// BASE-DAG: name = "bar::baz::foo()", mangled = "_ZN3bar3baz3fooEv" + +// METHOD: Found 3 functions: +// METHOD-DAG: name = "sbar::foo()", mangled = "_ZN4sbar3fooEv" +// METHOD-DAG: name = "sbar::foo(int)", mangled = "_ZN4sbar3fooEi" +// METHOD-DAG: name = "ffbar()::sbaz::foo()", mangled = "_ZZ5ffbarvEN4sbaz3fooEv" + +// FULL: Found 7 functions: +// FULL-DAG: name = "foo()", mangled = "_Z3foov" +// FULL-DAG: name = "foo(int)", mangled = "_Z3fooi" +// FULL-DAG: name = "bar::foo()", mangled = "_ZN3bar3fooEv" +// FULL-DAG: name = "bar::baz::foo()", mangled = "_ZN3bar3baz3fooEv" +// FULL-DAG: name = "sbar::foo()", mangled = "_ZN4sbar3fooEv" +// FULL-DAG: name = "sbar::foo(int)", mangled = "_ZN4sbar3fooEi" +// FULL-DAG: name = "ffbar()::sbaz::foo()", mangled = "_ZZ5ffbarvEN4sbaz3fooEv" + +// FULL-MANGLED: Found 1 functions: +// FULL-MANGLED-DAG: name = "foo(int)", mangled = "_Z3fooi" + +// CONTEXT: Found 1 functions: +// CONTEXT-DAG: name = "bar::foo()", mangled = "_ZN3bar3fooEv" + +// EMPTY: Found 0 functions: + +void foo() {} +void foo(int) {} + +namespace bar { +int context; +void foo() {} +namespace baz { +void foo() {} +} // namespace baz +} // namespace bar + +struct foo {}; +void fbar(struct foo) {} + +void Foo() {} + +struct sbar { + void foo(); + static void foo(int); +}; +void sbar::foo() {} +void sbar::foo(int) {} + +void ffbar() { + struct sbaz { + void foo() {} + }; + sbaz a; + a.foo(); +} + +extern "C" void _start() {} diff --git a/lit/SymbolFile/DWARF/find-basic-namespace.cpp b/lit/SymbolFile/DWARF/find-basic-namespace.cpp new file mode 100644 index 000000000000..11a660bfba9f --- /dev/null +++ b/lit/SymbolFile/DWARF/find-basic-namespace.cpp @@ -0,0 +1,46 @@ +// REQUIRES: lld + +// 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 +// RUN: lldb-test symbols --name=foo --find=namespace --context=context %t | \ +// RUN: FileCheck --check-prefix=CONTEXT %s +// 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: 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 | \ +// RUN: FileCheck --check-prefix=CONTEXT %s +// 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: ld.lld %t.o -o %t +// 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 | \ +// RUN: FileCheck --check-prefix=CONTEXT %s +// RUN: lldb-test symbols --name=not_there --find=namespace %t | \ +// RUN: FileCheck --check-prefix=EMPTY %s + +// FOO: Found namespace: foo + +// CONTEXT: Found namespace: bar::foo + +// EMPTY: Namespace not found. + +namespace foo { +int X; +} + +namespace bar { +int context; +namespace foo { +int X; +} +} // namespace bar + +extern "C" void _start() {} diff --git a/lit/SymbolFile/DWARF/find-basic-type.cpp b/lit/SymbolFile/DWARF/find-basic-type.cpp new file mode 100644 index 000000000000..a470ef762e61 --- /dev/null +++ b/lit/SymbolFile/DWARF/find-basic-type.cpp @@ -0,0 +1,55 @@ +// REQUIRES: lld + +// 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 +// RUN: lldb-test symbols --name=foo --context=context --find=type %t | \ +// RUN: FileCheck --check-prefix=CONTEXT %s +// 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: 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 | \ +// RUN: FileCheck --check-prefix=CONTEXT %s +// 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: ld.lld %t.o -o %t +// 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 | \ +// RUN: FileCheck --check-prefix=CONTEXT %s +// RUN: lldb-test symbols --name=not_there --find=type %t | \ +// RUN: FileCheck --check-prefix=EMPTY %s + +// EMPTY: Found 0 types: +// NAME: Found 4 types: +// CONTEXT: Found 1 types: +struct foo { }; +// NAME-DAG: name = "foo", {{.*}} decl = find-basic-type.cpp:[[@LINE-1]] + +namespace bar { +int context; +struct foo {}; +// NAME-DAG: name = "foo", {{.*}} decl = find-basic-type.cpp:[[@LINE-1]] +// CONTEXT-DAG: name = "foo", {{.*}} decl = find-basic-type.cpp:[[@LINE-2]] +namespace baz { +struct foo {}; +// NAME-DAG: name = "foo", {{.*}} decl = find-basic-type.cpp:[[@LINE-1]] +} +} + +struct sbar { + struct foo {}; +// NAME-DAG: name = "foo", {{.*}} decl = find-basic-type.cpp:[[@LINE-1]] +}; + +struct foobar {}; + +struct Foo {}; + +extern "C" void _start(foo, bar::foo, bar::baz::foo, sbar::foo, foobar, Foo) {} diff --git a/lit/SymbolFile/DWARF/find-basic-variable.cpp b/lit/SymbolFile/DWARF/find-basic-variable.cpp new file mode 100644 index 000000000000..222ad420d400 --- /dev/null +++ b/lit/SymbolFile/DWARF/find-basic-variable.cpp @@ -0,0 +1,76 @@ +// REQUIRES: lld + +// 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 +// RUN: lldb-test symbols --name=foo --find=variable %t | \ +// RUN: FileCheck --check-prefix=NAME %s +// RUN: lldb-test symbols --regex --name=foo --find=variable %t | \ +// RUN: FileCheck --check-prefix=REGEX %s +// 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: 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 | \ +// RUN: FileCheck --check-prefix=NAME %s +// RUN: lldb-test symbols --regex --name=foo --find=variable %t | \ +// RUN: FileCheck --check-prefix=REGEX %s +// 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: ld.lld %t.o -o %t +// 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 | \ +// RUN: FileCheck --check-prefix=NAME %s +// RUN: lldb-test symbols --regex --name=foo --find=variable %t | \ +// RUN: FileCheck --check-prefix=REGEX %s +// RUN: lldb-test symbols --name=not_there --find=variable %t | \ +// RUN: FileCheck --check-prefix=EMPTY %s + +// EMPTY: Found 0 variables: +// NAME: Found 4 variables: +// CONTEXT: Found 1 variables: +// REGEX: Found 5 variables: +int foo; +// NAME-DAG: name = "foo", type = {{.*}} (int), {{.*}} decl = find-basic-variable.cpp:[[@LINE-1]] +// REGEX-DAG: name = "foo", type = {{.*}} (int), {{.*}} decl = find-basic-variable.cpp:[[@LINE-2]] +namespace bar { +int context; +long foo; +// NAME-DAG: name = "foo", type = {{.*}} (long int), {{.*}} decl = find-basic-variable.cpp:[[@LINE-1]] +// CONTEXT-DAG: name = "foo", type = {{.*}} (long int), {{.*}} decl = find-basic-variable.cpp:[[@LINE-2]] +// REGEX-DAG: name = "foo", type = {{.*}} (long int), {{.*}} decl = find-basic-variable.cpp:[[@LINE-3]] +namespace baz { +static short foo; +// NAME-DAG: name = "foo", type = {{.*}} (short), {{.*}} decl = find-basic-variable.cpp:[[@LINE-1]] +// REGEX-DAG: name = "foo", type = {{.*}} (short), {{.*}} decl = find-basic-variable.cpp:[[@LINE-2]] +} +} + +struct sbar { + static int foo; +// NAME-DAG: name = "foo", type = {{.*}} (int), {{.*}} decl = find-basic-variable.cpp:[[@LINE-1]] +// REGEX-DAG: name = "foo", type = {{.*}} (int), {{.*}} decl = find-basic-variable.cpp:[[@LINE-2]] +}; +int sbar::foo; + +int foobar; +// REGEX-DAG: name = "foobar", type = {{.*}} (int), {{.*}} decl = find-basic-variable.cpp:[[@LINE-1]] + +int fbar() { + static int foo; + return foo + bar::baz::foo; +} + +int Foo; + +struct ssbar { + int foo; +}; + +extern "C" void _start(sbar, ssbar) {} diff --git a/lit/SymbolFile/DWARF/find-function-regex.cpp b/lit/SymbolFile/DWARF/find-function-regex.cpp new file mode 100644 index 000000000000..2e099eb4fd74 --- /dev/null +++ b/lit/SymbolFile/DWARF/find-function-regex.cpp @@ -0,0 +1,26 @@ +// REQUIRES: lld + +// 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: 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: ld.lld %t.o -o %t +// RUN: lldb-test symbols --name=f.o --regex --find=function %t | FileCheck %s + +// CHECK: Found 3 functions: +// CHECK-DAG: name = "foo()", mangled = "_Z3foov" +// CHECK-DAG: name = "ffo()", mangled = "_Z3ffov" +// CHECK-DAG: name = "bar::foo()", mangled = "_ZN3bar3fooEv" + +void foo() {} +void ffo() {} +namespace bar { +void foo() {} +} // namespace bar +void fof() {} + +extern "C" void _start() {} diff --git a/lit/SymbolFile/DWARF/find-inline-method.s b/lit/SymbolFile/DWARF/find-inline-method.s new file mode 100644 index 000000000000..6910130ee92c --- /dev/null +++ b/lit/SymbolFile/DWARF/find-inline-method.s @@ -0,0 +1,152 @@ +# REQUIRES: lld + +# RUN: llvm-mc -triple x86_64-pc-linux %s -filetype=obj > %t.o +# RUN: ld.lld %t.o -o %t +# RUN: lldb-test symbols --find=function --name=inl --function-flags=method %t \ +# RUN: | FileCheck %s + +# CHECK: Function: {{.*}} mangled = "_Z8externali" +# CHECK: Blocks: {{.*}} range = [0x00201000-0x00201002) +# CHECK-NEXT: range = [0x00201000-0x00201002), name = "inl", mangled = _ZN1S3inlEi + + +# Generated via: +# clang -O2 -g -S + +# from file: +# int forward(int); +# struct S { +# static int inl(int a) { return forward(a); } +# }; +# int external(int a) { return S::inl(a); } + +# and then simplified. + + .text +_Z8externali: +.Lfunc_begin0: + jmp _Z7forwardi +.Lfunc_end0: + +.globl _start +_start: +_Z7forwardi: + ret + + .section .debug_str,"MS",@progbits,1 +.Linfo_string0: + .asciz "clang version 7.0.0 (trunk 332830) (llvm/trunk 332835) with manual modifications" +.Linfo_string3: + .asciz "_ZN1S3inlEi" +.Linfo_string4: + .asciz "inl" +.Linfo_string6: + .asciz "S" +.Linfo_string8: + .asciz "_Z8externali" +.Linfo_string9: + .asciz "external" + .section .debug_abbrev,"",@progbits + .byte 1 # Abbreviation Code + .byte 17 # DW_TAG_compile_unit + .byte 1 # DW_CHILDREN_yes + .byte 37 # DW_AT_producer + .byte 14 # DW_FORM_strp + .byte 19 # DW_AT_language + .byte 5 # DW_FORM_data2 + .byte 17 # DW_AT_low_pc + .byte 1 # DW_FORM_addr + .byte 18 # DW_AT_high_pc + .byte 6 # DW_FORM_data4 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 2 # Abbreviation Code + .byte 19 # DW_TAG_structure_type + .byte 1 # DW_CHILDREN_yes + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .byte 11 # DW_AT_byte_size + .byte 11 # DW_FORM_data1 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 3 # Abbreviation Code + .byte 46 # DW_TAG_subprogram + .byte 0 # DW_CHILDREN_no + .byte 110 # DW_AT_linkage_name + .byte 14 # DW_FORM_strp + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 6 # Abbreviation Code + .byte 46 # DW_TAG_subprogram + .byte 0 # DW_CHILDREN_no + .byte 71 # DW_AT_specification + .byte 19 # DW_FORM_ref4 + .byte 32 # DW_AT_inline + .byte 11 # DW_FORM_data1 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 8 # Abbreviation Code + .byte 46 # DW_TAG_subprogram + .byte 1 # DW_CHILDREN_yes + .byte 17 # DW_AT_low_pc + .byte 1 # DW_FORM_addr + .byte 18 # DW_AT_high_pc + .byte 6 # DW_FORM_data4 + .byte 110 # DW_AT_linkage_name + .byte 14 # DW_FORM_strp + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 10 # Abbreviation Code + .byte 29 # DW_TAG_inlined_subroutine + .byte 1 # DW_CHILDREN_yes + .byte 49 # DW_AT_abstract_origin + .byte 19 # DW_FORM_ref4 + .byte 17 # DW_AT_low_pc + .byte 1 # DW_FORM_addr + .byte 18 # DW_AT_high_pc + .byte 6 # DW_FORM_data4 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 0 # EOM(3) + .section .debug_info,"",@progbits +.Lcu_begin0: + .long .Lcu_end0-.Lcu_start0 # Length of Unit +.Lcu_start0: + .short 4 # DWARF version number + .long .debug_abbrev # Offset Into Abbrev. Section + .byte 8 # Address Size (in bytes) + .byte 1 # Abbrev [1] 0xb:0x9e DW_TAG_compile_unit + .long .Linfo_string0 # DW_AT_producer + .short 4 # DW_AT_language + .quad .Lfunc_begin0 # DW_AT_low_pc + .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc + .byte 2 # Abbrev [2] 0x2a:0x1f DW_TAG_structure_type + .long .Linfo_string6 # DW_AT_name + .byte 1 # DW_AT_byte_size +.Linl_spec: + .byte 3 # Abbrev [3] 0x33:0x15 DW_TAG_subprogram + .long .Linfo_string3 # DW_AT_linkage_name + .long .Linfo_string4 # DW_AT_name + .byte 0 # End Of Children Mark +.Linl_abstract: + .byte 6 # Abbrev [6] 0x50:0x12 DW_TAG_subprogram + .long .Linl_spec # DW_AT_specification + .byte 1 # DW_AT_inline +.Linl_a_abstract: + .byte 8 # Abbrev [8] 0x62:0x46 DW_TAG_subprogram + .quad .Lfunc_begin0 # DW_AT_low_pc + .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc + .long .Linfo_string8 # DW_AT_linkage_name + .long .Linfo_string9 # DW_AT_name + .byte 10 # Abbrev [10] 0x8c:0x1b DW_TAG_inlined_subroutine + .long .Linl_abstract # DW_AT_abstract_origin + .quad .Lfunc_begin0 # DW_AT_low_pc + .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc + .byte 0 # End Of Children Mark + .byte 0 # End Of Children Mark + .byte 0 # End Of Children Mark +.Lcu_end0: diff --git a/lit/SymbolFile/DWARF/find-method-local-struct.cpp b/lit/SymbolFile/DWARF/find-method-local-struct.cpp new file mode 100644 index 000000000000..19b41e77c17d --- /dev/null +++ b/lit/SymbolFile/DWARF/find-method-local-struct.cpp @@ -0,0 +1,19 @@ +// 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 + +// CHECK-DAG: name = "sbar::foo()", mangled = "_ZN4sbar3fooEv" +// CHECK-DAG: name = "ffbar()::sbar::foo()", mangled = "_ZZ5ffbarvEN4sbar3fooEv" + +struct sbar { + void foo(); +}; +void sbar::foo() {} + +void ffbar() { + struct sbar { + void foo() {} + }; + sbar a; + a.foo(); +} diff --git a/lit/SymbolFile/DWARF/find-method.cpp b/lit/SymbolFile/DWARF/find-method.cpp new file mode 100644 index 000000000000..013e13435b9f --- /dev/null +++ b/lit/SymbolFile/DWARF/find-method.cpp @@ -0,0 +1,31 @@ +// REQUIRES: lld + +// 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: lldb-test symbols --name=foo --find=function --function-flags=method %t | \ +// RUN: FileCheck %s + +// CHECK-DAG: name = "A::foo()", mangled = "_ZN1A3fooEv" +// CHECK-DAG: name = "B::foo()", mangled = "_ZN1B3fooEv" +// CHECK-DAG: name = "C::foo()", mangled = "_ZN1C3fooEv" + +struct A { + void foo(); +}; +void A::foo() {} + +class B { + void foo(); +}; +void B::foo() {} + +union C { + void foo(); +}; +void C::foo() {} + +extern "C" void _start() {} diff --git a/lit/SymbolFile/DWARF/find-qualified-variable.cpp b/lit/SymbolFile/DWARF/find-qualified-variable.cpp new file mode 100644 index 000000000000..ca1b3184fbe7 --- /dev/null +++ b/lit/SymbolFile/DWARF/find-qualified-variable.cpp @@ -0,0 +1,15 @@ +// 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: + +struct A { + static int foo; +}; +int A::foo; +// NAME-DAG: name = "foo", {{.*}} decl = find-qualified-variable.cpp:[[@LINE-1]] + +struct B { + static int foo; +}; +int B::foo; diff --git a/lit/SymbolFile/DWARF/find-type-in-function.cpp b/lit/SymbolFile/DWARF/find-type-in-function.cpp new file mode 100644 index 000000000000..a0894284fa26 --- /dev/null +++ b/lit/SymbolFile/DWARF/find-type-in-function.cpp @@ -0,0 +1,24 @@ +// REQUIRES: lld + +// XFAIL: * + +// 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 + +// Lookup for "foo" should find either both "struct foo" types or just the +// global one. Right now, it finds the definition inside bar(), which is +// definitely wrong. + +// NAME: Found 2 types: +struct foo {}; +// NAME-DAG: name = "foo", {{.*}} decl = find-type-in-function.cpp:[[@LINE-1]] + +void bar() { + struct foo {}; +// NAME-DAG: name = "foo", {{.*}} decl = find-type-in-function.cpp:[[@LINE-1]] + foo a; +} + +extern "C" void _start(foo) {} diff --git a/lit/SymbolFile/DWARF/find-variable-dwo.cpp b/lit/SymbolFile/DWARF/find-variable-dwo.cpp new file mode 100644 index 000000000000..142ddc82cdab --- /dev/null +++ b/lit/SymbolFile/DWARF/find-variable-dwo.cpp @@ -0,0 +1,25 @@ +// REQUIRES: lld + +// 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: 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 +// RUN: lldb-test symbols --name=foo --find=variable %t | FileCheck %s + +// CHECK: Found 2 variables: +#ifdef ONE +namespace one { +int foo; +// CHECK-DAG: name = "foo", type = {{.*}} (int), {{.*}} decl = find-variable-dwo.cpp:[[@LINE-1]] +} // namespace one + +extern "C" void _start() {} +#else +namespace two { +int foo; +// CHECK-DAG: name = "foo", type = {{.*}} (int), {{.*}} decl = find-variable-dwo.cpp:[[@LINE-1]] +} // namespace two +#endif diff --git a/lit/SymbolFile/DWARF/find-variable-file.cpp b/lit/SymbolFile/DWARF/find-variable-file.cpp new file mode 100644 index 000000000000..f71d4a2b09b6 --- /dev/null +++ b/lit/SymbolFile/DWARF/find-variable-file.cpp @@ -0,0 +1,28 @@ +// 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: 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: 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 + +// ONE: Found 1 variables: +namespace one { +int foo; +// ONE-DAG: name = "foo", type = {{.*}} (int), {{.*}} decl = find-variable-file.cpp:[[@LINE-1]] +} // namespace one + +extern "C" void _start() {} + +// TWO: Found 1 variables: +// TWO-DAG: name = "foo", {{.*}} decl = find-variable-file-2.cpp:2 diff --git a/lit/SymbolFile/DWARF/lit.local.cfg b/lit/SymbolFile/DWARF/lit.local.cfg new file mode 100644 index 000000000000..2f03ed183547 --- /dev/null +++ b/lit/SymbolFile/DWARF/lit.local.cfg @@ -0,0 +1 @@ +config.suffixes = ['.cpp', '.s'] diff --git a/lit/SymbolFile/PDB/Inputs/CompilandsTest.cpp b/lit/SymbolFile/PDB/Inputs/CompilandsTest.cpp new file mode 100644 index 000000000000..4cce7f667ff7 --- /dev/null +++ b/lit/SymbolFile/PDB/Inputs/CompilandsTest.cpp @@ -0,0 +1,3 @@ +int main() { + return 0; +} diff --git a/lit/SymbolFile/PDB/Inputs/FuncSymbols.cpp b/lit/SymbolFile/PDB/Inputs/FuncSymbols.cpp new file mode 100644 index 000000000000..ccccf6ffd108 --- /dev/null +++ b/lit/SymbolFile/PDB/Inputs/FuncSymbols.cpp @@ -0,0 +1,16 @@ +// Static function +namespace { +static long StaticFunction(int a) +{ + return 2; +} +} + +// Inlined function +static inline int InlinedFunction(long a) { return 10; } + +void FunctionCall() +{ + StaticFunction(1); + InlinedFunction(1); +} diff --git a/lit/SymbolFile/PDB/Inputs/FuncSymbolsTestMain.cpp b/lit/SymbolFile/PDB/Inputs/FuncSymbolsTestMain.cpp new file mode 100644 index 000000000000..17eeab7117bf --- /dev/null +++ b/lit/SymbolFile/PDB/Inputs/FuncSymbolsTestMain.cpp @@ -0,0 +1,59 @@ + +// Global functions +int Func_arg_array(int array[]) { return 1; } +void Func_arg_void(void) { return; } +void Func_arg_none(void) { return; } +void Func_varargs(...) { return; } + +// Class +namespace MemberTest { + class A { + public: + int Func(int a, ...) { return 1; } + }; +} + +// Template +template <int N=1, class ...T> +void TemplateFunc(T ...Arg) { + return; +} + +// namespace +namespace { + void Func(int a, const long b, volatile bool c, ...) { return; } +} + +namespace NS { + void Func(char a, int b) { + return; + } +} + +// Static function +static long StaticFunction(int a) +{ + return 2; +} + +// Inlined function +inline void InlinedFunction(long a) { return; } + +extern void FunctionCall(); + +int main() { + MemberTest::A v1; + v1.Func('a',10); + + Func(1, 5, true, 10, 8); + NS::Func('c', 2); + + TemplateFunc(10); + TemplateFunc(10,11,88); + + StaticFunction(2); + InlinedFunction(1); + + FunctionCall(); + return 0; +} diff --git a/lit/SymbolFile/PDB/Inputs/FunctionLevelLinkingTest.cpp b/lit/SymbolFile/PDB/Inputs/FunctionLevelLinkingTest.cpp new file mode 100644 index 000000000000..fa0030bacbf3 --- /dev/null +++ b/lit/SymbolFile/PDB/Inputs/FunctionLevelLinkingTest.cpp @@ -0,0 +1,9 @@ +#include "FunctionLevelLinkingTest.h" + +int foo() { + return 0; +} + +int main() { + return foo() + bar() + baz(); +} diff --git a/lit/SymbolFile/PDB/Inputs/FunctionLevelLinkingTest.h b/lit/SymbolFile/PDB/Inputs/FunctionLevelLinkingTest.h new file mode 100644 index 000000000000..0cc9d80d85d1 --- /dev/null +++ b/lit/SymbolFile/PDB/Inputs/FunctionLevelLinkingTest.h @@ -0,0 +1,12 @@ +#ifndef FUNCTION_LEVEL_LINKING_TEST_H +#define FUNCTION_LEVEL_LINKING_TEST_H + +int bar() { + return 0; +} + +int baz() { + return 0; +} + +#endif diff --git a/lit/SymbolFile/PDB/Inputs/FunctionLevelLinkingTest.ord b/lit/SymbolFile/PDB/Inputs/FunctionLevelLinkingTest.ord new file mode 100644 index 000000000000..48abd0b872f9 --- /dev/null +++ b/lit/SymbolFile/PDB/Inputs/FunctionLevelLinkingTest.ord @@ -0,0 +1,4 @@ +?foo@@YAHXZ +?bar@@YAHXZ +main +?baz@@YAHXZ diff --git a/lit/SymbolFile/PDB/Inputs/FunctionNestedBlockTest.cpp b/lit/SymbolFile/PDB/Inputs/FunctionNestedBlockTest.cpp new file mode 100644 index 000000000000..62e201df5fef --- /dev/null +++ b/lit/SymbolFile/PDB/Inputs/FunctionNestedBlockTest.cpp @@ -0,0 +1,8 @@ +int main() { + auto r = 0; + for (auto i = 1; i <= 10; i++) { + r += i & 1 + (i - 1) & 1 - 1; + } + + return r; +} diff --git a/lit/SymbolFile/PDB/Inputs/SimpleTypesTest.cpp b/lit/SymbolFile/PDB/Inputs/SimpleTypesTest.cpp new file mode 100644 index 000000000000..8e516201644c --- /dev/null +++ b/lit/SymbolFile/PDB/Inputs/SimpleTypesTest.cpp @@ -0,0 +1,49 @@ +// typedef +typedef unsigned long ULongArrayTypedef[10]; +ULongArrayTypedef ULongArrayVar; + +typedef long double*& RefTypedef; +long double* LongDoublePtrVar = 0; +RefTypedef RefVar = LongDoublePtrVar; + +typedef long long (*FuncPtrTypedef)(int&, unsigned char**, short[], const double, volatile bool); +FuncPtrTypedef FuncVar; + +typedef char (*VarArgsFuncTypedef)(void*, long, unsigned short, unsigned int, ...); +VarArgsFuncTypedef VarArgsFuncVar; + +typedef float (*VarArgsFuncTypedefA)(...); +VarArgsFuncTypedefA VarArgsFuncVarA; + +// unscoped enum +enum Enum { RED, GREEN, BLUE }; +Enum EnumVar; + +enum EnumConst { LOW, NORMAL = 10, HIGH }; +EnumConst EnumConstVar; + +enum EnumEmpty {}; +EnumEmpty EnumEmptyVar; + +enum EnumUChar : unsigned char { ON, OFF, AUTO }; +EnumUChar EnumCharVar; + +// scoped enum +enum class EnumClass { YES, NO, DEFAULT }; +EnumClass EnumClassVar; + +enum struct EnumStruct { red, blue, black }; +EnumStruct EnumStructVar; + +typedef char16_t WChar16Typedef; +WChar16Typedef WC16Var; + +typedef char32_t WChar32Typedef; +WChar32Typedef WC32Var; + +typedef wchar_t WCharTypedef; +WCharTypedef WCVar; + +int main() { + return 0; +} diff --git a/lit/SymbolFile/PDB/Inputs/TypeQualsTest.cpp b/lit/SymbolFile/PDB/Inputs/TypeQualsTest.cpp new file mode 100644 index 000000000000..bedafcdacfc3 --- /dev/null +++ b/lit/SymbolFile/PDB/Inputs/TypeQualsTest.cpp @@ -0,0 +1,46 @@ +// Rank > 0 array +typedef volatile int* RankNArray[10][100]; +RankNArray ArrayVar; + +typedef int __unaligned *UnalignedTypedef; +UnalignedTypedef UnVar; + +typedef long* __restrict RestrictTypedef; +RestrictTypedef RestrictVar; + +void Func1(const int* a, int const* b, const int ** const c, const int* const* d) { + return; +} + +void Func2(volatile int* a, int volatile* b) { + return; +} + +void Func3(int*& a, int& b, const int&c, int&& d) { + return; +} + +void Func4(int* __unaligned a, __unaligned int* b) { + return; +} + +void Func5(int a, int* __restrict b, int& __restrict c) { + return; +} + +void Func6(const volatile int* __restrict b) { + return; +} + +// LValue +typedef int& IntRef; +int x = 0; +IntRef IVar = x; + +// RValue +typedef int&& IIRef; +IIRef IIVar = int(1); + +int main() { + return 0; +} diff --git a/lit/SymbolFile/PDB/Inputs/VariablesLocationsTest.cpp b/lit/SymbolFile/PDB/Inputs/VariablesLocationsTest.cpp new file mode 100644 index 000000000000..54d54c0d56a6 --- /dev/null +++ b/lit/SymbolFile/PDB/Inputs/VariablesLocationsTest.cpp @@ -0,0 +1,15 @@ +int g_var = 2222; + +void __fastcall foo(short arg_0, float arg_1) { + char loc_0 = 'x'; + double loc_1 = 0.5678; +} + +int main(int argc, char *argv[]) { + bool loc_0 = true; + int loc_1 = 3333; + + foo(1111, 0.1234); + + return 0; +} diff --git a/lit/SymbolFile/PDB/Inputs/VariablesLocationsTest.script b/lit/SymbolFile/PDB/Inputs/VariablesLocationsTest.script new file mode 100644 index 000000000000..7058f29ae1c1 --- /dev/null +++ b/lit/SymbolFile/PDB/Inputs/VariablesLocationsTest.script @@ -0,0 +1,16 @@ +breakpoint set --file VariablesLocationsTest.cpp --line 6 + +run + +target variable g_var + +frame variable arg_0 +frame variable arg_1 + +frame variable loc_0 +frame variable loc_1 + +frame select 1 + +frame variable loc_0 +frame variable loc_1 diff --git a/lit/SymbolFile/PDB/Inputs/VariablesTest.cpp b/lit/SymbolFile/PDB/Inputs/VariablesTest.cpp new file mode 100644 index 000000000000..304d90566091 --- /dev/null +++ b/lit/SymbolFile/PDB/Inputs/VariablesTest.cpp @@ -0,0 +1,50 @@ +typedef int IntTypedef; +IntTypedef g_IntVar; // Testing globals. + +typedef enum Enum { // Testing constants. + RED, + GREEN, + BLUE +} EnumTypedef; +EnumTypedef g_EnumVar; // Testing members. + +// FIXME: `sg_IntVar` appears both in global scope's children and compiland's +// children but with different symbol's id. +static int sg_IntVar = -1; // Testing file statics. + +// FIXME: `g_Const` appears both in global scope's children and compiland's +// children but with different symbol's id. +const int g_Const = 0x88; // Testing constant data. +const int *g_pConst = &g_Const; // Avoid optimizing the const away + +thread_local int g_tls = 0; // Testing thread-local storage. + +class Class { + static int m_StaticClassMember; +public: + explicit Class(int a) {} + void Func() {} +}; +int Class::m_StaticClassMember = 10; // Testing static class members. +Class ClassVar(1); + +int f(int var_arg1, int var_arg2) { // Testing parameters. + long same_name_var = -1; + return 1; +} + +int same_name_var = 100; +int main() { + int same_name_var = 0; // Testing locals. + const char local_const = 0x1; + + // FIXME: 'local_CString` is not found through compiland's children. + const char local_CString[] = "abc"; // Testing constant string. + const char *local_pCString = local_CString; // Avoid optimizing the const away + + int a = 10; + a++; + + ClassVar.Func(); + return 0; +} diff --git a/lit/SymbolFile/PDB/compilands.test b/lit/SymbolFile/PDB/compilands.test new file mode 100644 index 000000000000..2e7b014fe966 --- /dev/null +++ b/lit/SymbolFile/PDB/compilands.test @@ -0,0 +1,9 @@ +REQUIRES: windows +RUN: clang-cl /Z7 %S/Inputs/CompilandsTest.cpp /o %T/CompilandsTest.cpp.exe +RUN: lldb-test symbols %T/CompilandsTest.cpp.exe | FileCheck %s + +; Link default libraries + +CHECK: Module [[CU:.*]] +CHECK: {{^[0-9A-F]+}}: SymbolVendor ([[CU]]) +CHECK: {{^[0-9A-F]+}}: CompileUnit{{[{]0x[0-9a-f]+[}]}}, language = "c++", file = '{{.*}}\CompilandsTest.cpp' diff --git a/lit/SymbolFile/PDB/enums-layout.test b/lit/SymbolFile/PDB/enums-layout.test new file mode 100644 index 000000000000..ce0b23f453be --- /dev/null +++ b/lit/SymbolFile/PDB/enums-layout.test @@ -0,0 +1,45 @@ +REQUIRES: 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 +RUN: lldb-test symbols %T/SimpleTypesTest.cpp.enums.exe | FileCheck %s + +; FIXME: PDB does not have information about scoped enumeration (Enum class) so the +; compiler type used is the same as the one for unscoped enumeration. + +CHECK: Module [[CU:.*]] +CHECK-DAG: {{^[0-9A-F]+}}: SymbolVendor ([[CU]]) +CHECK: Type{{.*}} , name = "Enum", size = 4, decl = SimpleTypesTest.cpp:19, compiler_type = {{.*}} enum Enum { +CHECK-NEXT: RED, +CHECK-NEXT: GREEN, +CHECK-NEXT: BLUE +CHECK-NEXT:} + +CHECK: Type{{.*}} , name = "EnumConst", size = 4, decl = SimpleTypesTest.cpp:22, compiler_type = {{.*}} enum EnumConst { +CHECK-NEXT: LOW, +CHECK-NEXT: NORMAL, +CHECK-NEXT: HIGH +CHECK-NEXT:} + +CHECK: Type{{.*}} , name = "EnumEmpty", size = 4, decl = SimpleTypesTest.cpp:25, compiler_type = {{.*}} enum EnumEmpty { +CHECK-NEXT:} + +CHECK: Type{{.*}} , name = "EnumUChar", size = 1, decl = SimpleTypesTest.cpp:28, compiler_type = {{.*}} enum EnumUChar { +CHECK-NEXT: ON, +CHECK-NEXT: OFF, +CHECK-NEXT: AUTO +CHECK-NEXT:} + +; Note that `enum EnumClass` is tested instead of `enum class EnumClass` +CHECK: Type{{.*}} , name = "EnumClass", size = 4, decl = SimpleTypesTest.cpp:32, compiler_type = {{.*}} enum EnumClass { +CHECK-NEXT: YES, +CHECK-NEXT: NO, +CHECK-NEXT: DEFAULT +CHECK-NEXT:} + +CHECK: Type{{.*}} , name = "EnumStruct", size = 4, decl = SimpleTypesTest.cpp:35, compiler_type = {{.*}} enum EnumStruct { +CHECK-NEXT: red, +CHECK-NEXT: blue, +CHECK-NEXT: black +CHECK-NEXT:} + +CHECK-DAG: {{^[0-9A-F]+}}: CompileUnit{{[{]0x[0-9a-f]+[}]}}, language = "c++", file = '{{.*}}\SimpleTypesTest.cpp' diff --git a/lit/SymbolFile/PDB/func-symbols.test b/lit/SymbolFile/PDB/func-symbols.test new file mode 100644 index 000000000000..b13ff7e65bb0 --- /dev/null +++ b/lit/SymbolFile/PDB/func-symbols.test @@ -0,0 +1,48 @@ +REQUIRES: 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 +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 + +; Link multiple objects +; In this test, We don't check demangled name of a mangled function. + +CHECK-ONE: Module [[MD:.*]] +CHECK-ONE-DAG: {{.*}}: SymbolVendor ([[MD]]) +CHECK-ONE-DAG: [[TY0:.*]]: Type{[[UID0:.*]]} , name = "Func_arg_array", decl = FuncSymbolsTestMain.cpp:3, compiler_type = {{.*}} int (int *) +CHECK-ONE-DAG: [[TY1:.*]]: Type{[[UID1:.*]]} , name = "Func_arg_void", decl = FuncSymbolsTestMain.cpp:4, compiler_type = {{.*}} void (void) +CHECK-ONE-DAG: [[TY2:.*]]: Type{[[UID2:.*]]} , name = "Func_arg_none", decl = FuncSymbolsTestMain.cpp:5, compiler_type = {{.*}} void (void) +CHECK-ONE-DAG: [[TY3:.*]]: Type{[[UID3:.*]]} , name = "Func_varargs", decl = FuncSymbolsTestMain.cpp:6, compiler_type = {{.*}} void (...) +CHECK-ONE-DAG: [[TY4:.*]]: Type{[[UID4:.*]]} , name = "NS::Func", decl = FuncSymbolsTestMain.cpp:28, compiler_type = {{.*}} void (signed char, int) +CHECK-ONE-DAG: [[TY5:.*]]: Type{[[UID5:.*]]} , name = "main", decl = FuncSymbolsTestMain.cpp:44, compiler_type = {{.*}} int (void) +CHECK-ONE-DAG: [[TY6:.*]]: Type{[[UID6:.*]]} , name = "`anonymous namespace'::Func", decl = FuncSymbolsTestMain.cpp:24, compiler_type = {{.*}} void (int, const long, volatile _Bool, ...) +CHECK-ONE-DAG: [[TY7:.*]]: Type{[[UID7:.*]]} , name = "StaticFunction", decl = FuncSymbolsTestMain.cpp:35, compiler_type = {{.*}} long (int) +CHECK-ONE-DAG: [[TY8:.*]]: Type{[[UID8:.*]]} , name = "MemberTest::A::Func", decl = FuncSymbolsTestMain.cpp:12, compiler_type = {{.*}} int (int, ...) +CHECK-ONE-DAG: [[TY9:.*]]: Type{[[UID9:.*]]} , name = "TemplateFunc<1,int>", decl = FuncSymbolsTestMain.cpp:18, compiler_type = {{.*}} void (int) +CHECK-ONE-DAG: [[TY10:.*]]: Type{[[UID10:.*]]} , name = "TemplateFunc<1,int,int,int>", decl = FuncSymbolsTestMain.cpp:18, compiler_type = {{.*}} void (int, int, int) +CHECK-ONE-DAG: [[TY11:.*]]: Type{[[UID11:.*]]} , name = "InlinedFunction", decl = FuncSymbolsTestMain.cpp:40, compiler_type = {{.*}} void (long) + +CHECK-ONE: {{.*}}: CompileUnit{{.*}}, language = "c++", file = '{{.*}}\FuncSymbolsTestMain.cpp' +CHECK-ONE-DAG: Function{[[UID0]]}, mangled = ?Func_arg_array@@YAHQAH@Z, demangled = {{.*}}, type = [[TY0]] +CHECK-ONE-DAG: Function{[[UID1]]}, mangled = ?Func_arg_void@@YAXXZ, demangled = {{.*}}, type = [[TY1]] +CHECK-ONE-DAG: Function{[[UID2]]}, mangled = ?Func_arg_none@@YAXXZ, demangled = {{.*}}, type = [[TY2]] +CHECK-ONE-DAG: Function{[[UID3]]}, mangled = ?Func_varargs@@YAXZZ, demangled = {{.*}}, type = [[TY3]] +CHECK-ONE-DAG: Function{[[UID4]]}, mangled = ?Func@NS@@YAXDH@Z, demangled = {{.*}}, type = [[TY4]] +CHECK-ONE-DAG: Function{[[UID5]]}, mangled = _main, demangled = {{.*}}, type = [[TY5]] +CHECK-ONE-DAG: Function{[[UID6]]}, demangled = {{.*}}`anonymous namespace'::Func{{.*}}, type = [[TY6]] +CHECK-ONE-DAG: Function{[[UID7]]}, demangled = {{.*}}StaticFunction{{.*}}, type = [[TY7]] +CHECK-ONE-DAG: Function{[[UID8]]}, mangled = ?Func@A@MemberTest@@QAAHHZZ, demangled = {{.*}}, type = [[TY8]] +CHECK-ONE-DAG: Function{[[UID9]]}, mangled = ??$TemplateFunc@$00H@@YAXH@Z, demangled = {{.*}}, type = [[TY9]] +CHECK-ONE-DAG: Function{[[UID10]]}, mangled = ??$TemplateFunc@$00HHH@@YAXHHH@Z, demangled = {{.*}}, type = [[TY10]] +CHECK-ONE-DAG: Function{[[UID11]]}, mangled = ?InlinedFunction@@YAXJ@Z, demangled = {{.*}}, type = [[TY11]] + +; We expect new types observed in another compile unit +CHECK-TWO-DAG: [[TY30:.*]]: Type{[[UID30:.*]]} , name = "FunctionCall", decl = FuncSymbols.cpp:13, compiler_type = {{.*}} void (void) +CHECK-TWO-DAG: [[TY31:.*]]: Type{[[UID31:.*]]} , name = "`anonymous namespace'::StaticFunction", decl = FuncSymbols.cpp:4, compiler_type = {{.*}} long (int) +CHECK-TWO-DAG: [[TY32:.*]]: Type{[[UID32:.*]]} , name = "InlinedFunction", decl = FuncSymbols.cpp:10, compiler_type = {{.*}} int (long) + +CHECK-TWO: {{.*}}: CompileUnit{{.*}}, language = "c++", file = '{{.*}}\FuncSymbols.cpp' +CHECK-TWO-DAG: Function{[[UID30]]}, mangled = ?FunctionCall@@YAXXZ, demangled = {{.*}}, type = [[TY30]] +CHECK-TWO-DAG: Function{[[UID31]]}, demangled = {{.*}}`anonymous namespace'::StaticFunction{{.*}}, type = [[TY31]] +CHECK-TWO-DAG: Function{[[UID32]]}, demangled = {{.*}}InlinedFunction{{.*}}, type = [[TY32]] diff --git a/lit/SymbolFile/PDB/function-level-linking.test b/lit/SymbolFile/PDB/function-level-linking.test new file mode 100644 index 000000000000..9b28ec1ba217 --- /dev/null +++ b/lit/SymbolFile/PDB/function-level-linking.test @@ -0,0 +1,4 @@ +REQUIRES: windows, lld +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 diff --git a/lit/SymbolFile/PDB/function-nested-block.test b/lit/SymbolFile/PDB/function-nested-block.test new file mode 100644 index 000000000000..93543c681130 --- /dev/null +++ b/lit/SymbolFile/PDB/function-nested-block.test @@ -0,0 +1,7 @@ +REQUIRES: windows, lld +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 %s + +CHECK: Found 1 functions: +CHECK: name = "{{.*}}", mangled = "{{_?}}main" diff --git a/lit/SymbolFile/PDB/lit.local.cfg b/lit/SymbolFile/PDB/lit.local.cfg new file mode 100644 index 000000000000..df9b335dd131 --- /dev/null +++ b/lit/SymbolFile/PDB/lit.local.cfg @@ -0,0 +1 @@ +config.suffixes = ['.test'] diff --git a/lit/SymbolFile/PDB/type-quals.test b/lit/SymbolFile/PDB/type-quals.test new file mode 100644 index 000000000000..fbe10c0d8d64 --- /dev/null +++ b/lit/SymbolFile/PDB/type-quals.test @@ -0,0 +1,39 @@ +REQUIRES: 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 +RUN: lldb-test symbols %T/TypeQualsTest.cpp.exe | FileCheck %s + +CHECK: Module [[MOD:.*]] +CHECK-DAG: {{^[0-9A-F]+}}: SymbolVendor ([[MOD]]) +CHECK: Type{{.*}} , name = "const int", size = 4, compiler_type = {{.*}} const int +CHECK: Type{{.*}} , size = 4, compiler_type = {{.*}} const int * +CHECK: Type{{.*}} , size = 4, compiler_type = {{.*}} const int **const +CHECK: Type{{.*}} , size = 4, compiler_type = {{.*}} const int *const +CHECK: Type{{.*}} , size = 4, compiler_type = {{.*}} const int *const * +CHECK: Type{{.*}} , name = "Func1", {{.*}}, compiler_type = {{.*}} void (const int *, const int *, const int **const, const int *const *) + +CHECK: Type{{.*}} , size = 4, compiler_type = {{.*}} volatile int * +CHECK: Type{{.*}} , name = "Func2", {{.*}}, compiler_type = {{.*}} void (volatile int *, volatile int *) + +CHECK: Type{{.*}} , size = 4, compiler_type = {{.*}} int * +CHECK: Type{{.*}} , size = 4, compiler_type = {{.*}} int *& +CHECK: Type{{.*}} , size = 4, compiler_type = {{.*}} int & +CHECK: Type{{.*}} , size = 4, compiler_type = {{.*}} const int & +CHECK: Type{{.*}} , size = 4, compiler_type = {{.*}} int && +CHECK: Type{{.*}} , name = "Func3", {{.*}}, compiler_type = {{.*}} void (int *&, int &, const int &, int &&) + +// FIXME: __unaligned is not supported. +CHECK: Type{{.*}} , name = "Func4", {{.*}}, compiler_type = {{.*}} void (int *, int *) + +CHECK: Type{{.*}} , size = 4, compiler_type = {{.*}} int *__restrict +CHECK: Type{{.*}} , size = 4, compiler_type = {{.*}} int &__restrict +CHECK: Type{{.*}} , name = "Func5", {{.*}}, compiler_type = {{.*}} void (int, int *__restrict, int &__restrict) + +CHECK: Type{{.*}} , name = "Func6", {{.*}}, compiler_type = {{.*}} void (const volatile int *__restrict) + +CHECK: Type{{.*}} , size = 400, compiler_type = {{.*}} volatile int *[100] +CHECK: Type{{.*}} , size = 4000, compiler_type = {{.*}} volatile int *[10][100] + +CHECK: Type{{.*}} , size = 4, compiler_type = {{.*}} long *__restrict + +CHECK-DAG: {{^[0-9A-F]+}}: CompileUnit{{[{]0x[0-9a-f]+[}]}}, language = "c++", file = '{{.*}}\TypeQualsTest.cpp' diff --git a/lit/SymbolFile/PDB/typedefs.test b/lit/SymbolFile/PDB/typedefs.test new file mode 100644 index 000000000000..659ef6392d1c --- /dev/null +++ b/lit/SymbolFile/PDB/typedefs.test @@ -0,0 +1,59 @@ +REQUIRES: 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 +RUN: lldb-test symbols %T/SimpleTypesTest.cpp.typedefs.exe | FileCheck %s + +; Generate 32-bit target + +; FIXME: PDB does not have line information for typedef statements so source +; and line information for them is not tested. + +; Note, types `long double` and `double` have same bit size in MSVC and there +; is no information in the PDB to distinguish them. So the compiler type for +; both of them is the same. + +CHECK: Module [[MOD:.*]] +CHECK: {{^[0-9A-F]+}}: SymbolVendor ([[MOD]]) +CHECK-DAG: name = "char32_t", size = 4, compiler_type = {{.*}} char32_t +CHECK-DAG: name = "char16_t", size = 2, compiler_type = {{.*}} char16_t +CHECK-DAG: Type{{.*}} , name = "unsigned long", size = 4, compiler_type = {{.*}} unsigned long +CHECK-DAG: Type{{.*}} , size = 40, compiler_type = {{.*}} unsigned long [10] +CHECK-DAG: Type{{.*}} , name = "ULongArrayTypedef", compiler_type = {{.*}} typedef ULongArrayTypedef + +; Note: compiler_type of `long double` is represented by the one for `double` +CHECK-DAG: Type{{.*}} , name = "double", size = 8, compiler_type = {{.*}} double +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} double * +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} double *& +CHECK-DAG: Type{{.*}} , name = "RefTypedef", compiler_type = {{.*}} typedef RefTypedef + +CHECK-DAG: Type{{.*}} , name = "wchar_t", size = 2, compiler_type = {{.*}} wchar_t + +CHECK-DAG: Type{{.*}} , name = "int", size = 4, compiler_type = {{.*}} int +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} int & +CHECK-DAG: Type{{.*}} , name = "unsigned char", size = 1, compiler_type = {{.*}} unsigned char +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} unsigned char * +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} unsigned char ** +CHECK-DAG: Type{{.*}} , name = "short", size = 2, compiler_type = {{.*}} short +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} short * +CHECK-DAG: Type{{.*}} , name = "const double", size = 8, compiler_type = {{.*}} const double +CHECK-DAG: Type{{.*}} , name = "volatile bool", size = 1, compiler_type = {{.*}} volatile _Bool +CHECK-DAG: Type{{.*}} , name = "long long", size = 8, compiler_type = {{.*}} long long +CHECK-DAG: Type{{.*}} , compiler_type = {{.*}} long long (int &, unsigned char **, short *, const double, volatile _Bool) +CHECK-DAG: Type{{.*}} , name = "FuncPtrTypedef", compiler_type = {{.*}} typedef FuncPtrTypedef + +CHECK-DAG: Type{{.*}} , name = "void", compiler_type = {{.*}} void +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} void * +CHECK-DAG: Type{{.*}} , name = "long", size = 4, compiler_type = {{.*}} long +CHECK-DAG: Type{{.*}} , name = "unsigned short", size = 2, compiler_type = {{.*}} unsigned short +CHECK-DAG: Type{{.*}} , name = "unsigned int", size = 4, compiler_type = {{.*}} unsigned int +CHECK-DAG: Type{{.*}} , name = "signed char", size = 1, compiler_type = {{.*}} signed char +CHECK-DAG: Type{{.*}} , compiler_type = {{.*}} signed char (void *, long, unsigned short, unsigned int, ...) +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} signed char (*)(void *, long, unsigned short, unsigned int, ...) +CHECK-DAG: Type{{.*}} , name = "VarArgsFuncTypedef", compiler_type = {{.*}} typedef VarArgsFuncTypedef + +CHECK-DAG: Type{{.*}} , name = "float", size = 4, compiler_type = {{.*}} float +CHECK-DAG: Type{{.*}} , compiler_type = {{.*}} float (...) +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} float (*)(...) +CHECK-DAG: Type{{.*}} , name = "VarArgsFuncTypedefA", compiler_type = {{.*}} typedef VarArgsFuncTypedefA + +CHECK-DAG: {{^[0-9A-F]+}}: CompileUnit{{[{]0x[0-9a-f]+[}]}}, language = "c++", file = '{{.*}}\SimpleTypesTest.cpp' diff --git a/lit/SymbolFile/PDB/variables-locations.test b/lit/SymbolFile/PDB/variables-locations.test new file mode 100644 index 000000000000..b70339fa23ac --- /dev/null +++ b/lit/SymbolFile/PDB/variables-locations.test @@ -0,0 +1,14 @@ +REQUIRES: windows +RUN: clang-cl /Zi %S/Inputs/VariablesLocationsTest.cpp /o %t.exe +RUN: %lldb -b -s %S/Inputs/VariablesLocationsTest.script -- %t.exe | FileCheck %s + +CHECK: g_var = 2222 + +CHECK: arg_0 = 1111 +CHECK: arg_1 = 0.123 + +CHECK: loc_0 = 'x' +CHECK: loc_1 = 0.567 + +CHECK: loc_0 = true +CHECK: loc_1 = 3333 diff --git a/lit/SymbolFile/PDB/variables.test b/lit/SymbolFile/PDB/variables.test new file mode 100644 index 000000000000..6d37cd975b45 --- /dev/null +++ b/lit/SymbolFile/PDB/variables.test @@ -0,0 +1,58 @@ +REQUIRES: windows +RUN: clang-cl /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 +RUN: lldb-test symbols %T/VariablesTest.cpp.exe | FileCheck %s + +CHECK: Module [[MOD:.*]] +CHECK: SymbolVendor ([[MOD]]) +CHECK: CompileUnit{{.*}}, language = "c++", file = '{{.*}}\VariablesTest.cpp' +CHECK-DAG: Variable{{.*}}, name = "g_IntVar" +CHECK-SAME: scope = global, location = {{.*}}, external +CHECK-DAG: Variable{{.*}}, name = "m_StaticClassMember" +CHECK-SAME: scope = global, location = {{.*}}, external +CHECK-DAG: Variable{{.*}}, name = "g_pConst" +CHECK-SAME: scope = global, location = {{.*}}, external +CHECK-DAG: Variable{{.*}}, name = "same_name_var" +CHECK-SAME: scope = global, location = {{.*}}, external +CHECK-DAG: Variable{{.*}}, name = "g_EnumVar" +CHECK-SAME: scope = global, location = {{.*}}, external +CHECK-DAG: Variable{{.*}}, name = "g_tls" +CHECK-SAME: scope = thread local, location = {{.*}}, external +CHECK-DAG: Variable{{.*}}, name = "ClassVar" +CHECK-SAME: scope = global, location = {{.*}}, external +CHECK-DAG: Variable{{.*}}, name = "g_Const" +CHECK-SAME: scope = ??? (2) + +CHECK-DAG: Function{[[FID1:.*]]}, mangled = ?f@@YAHHH@Z +CHECK-NEXT: Block{[[FID1]]} +CHECK-DAG: Variable{{.*}}, name = "var_arg1" +CHECK-SAME: scope = parameter +CHECK-DAG: Variable{{.*}}, name = "var_arg2" +CHECK-SAME: scope = parameter +CHECK-DAG: Variable{{.*}}, name = "same_name_var" +CHECK-SAME: scope = local + +CHECK-DAG: Function{[[FID2:.*]]}, mangled = main +CHECK-NEXT: Block{[[FID2]]} +CHECK-DAG: Variable{{.*}}, name = "same_name_var" +CHECK-SAME: scope = local +CHECK-DAG: Variable{{.*}}, name = "local_const" +CHECK-SAME: scope = local +CHECK-DAG: Variable{{.*}}, name = "local_pCString" +CHECK-SAME: scope = local +CHECK-DAG: Variable{{.*}}, name = "a" +CHECK-SAME: scope = local + +CHECK-DAG: Function{[[FID3:.*]]}, mangled = ??0Class@@QEAA@H@Z +CHECK-NEXT: Block{[[FID3]]} +CHECK-DAG: Variable{{.*}}, name = "this" +CHECK-SAME: scope = parameter +CHECK-SAME: artificial +CHECK-DAG: Variable{{.*}}, name = "a" +CHECK-SAME: scope = parameter + +CHECK-DAG: Function{[[FID4:.*]]}, mangled = ?Func@Class@@QEAAXXZ +CHECK-NEXT: Block{[[FID4]]} +CHECK-DAG: Variable{{.*}}, name = "this" +CHECK-SAME: scope = parameter +CHECK-SAME: artificial
\ No newline at end of file diff --git a/lit/lit-lldb-init b/lit/lit-lldb-init new file mode 100644 index 000000000000..b3a5d4dc9841 --- /dev/null +++ b/lit/lit-lldb-init @@ -0,0 +1,2 @@ +# LLDB init file for the LIT tests. +settings set symbols.enable-external-lookup false diff --git a/lit/lit.cfg b/lit/lit.cfg index 402d03947ca8..7e1fcf7520ca 100644 --- a/lit/lit.cfg +++ b/lit/lit.cfg @@ -28,6 +28,8 @@ config.test_format = lit.formats.ShTest(execute_external) # suffixes: We only support unit tests config.suffixes = [] +config.excludes = ['Inputs'] + # test_source_root: The root path where tests are located. config.test_source_root = os.path.dirname(__file__) @@ -55,7 +57,10 @@ config.environment['PYTHON_EXECUTABLE'] = getattr(config, 'python_executable', ' config.substitutions.append(('%python', config.python_executable)) debugserver = lit.util.which('debugserver', lldb_tools_dir) -lldb = lit.util.which('lldb', lldb_tools_dir) +lldb = "%s -S %s/lit-lldb-init" % (lit.util.which('lldb', lldb_tools_dir), + config.test_source_root) + +lldbmi = lit.util.which('lldb-mi', lldb_tools_dir) if not os.path.exists(config.cc): config.cc = lit.util.which(config.cc, config.environment['PATH']) @@ -75,9 +80,14 @@ if platform.system() in ['Darwin']: 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)) +config.substitutions.append(('%lldbmi', lldbmi + " --synchronous")) config.substitutions.append(('%lldb', lldb)) if debugserver is not None: @@ -91,11 +101,11 @@ for pattern in [r"\bFileCheck\b", pattern) tool_pipe = tool_match.group(2) tool_name = tool_match.group(4) - tool_path = lit.util.which(tool_name, config.llvm_tools_dir) + tool_path = lit.util.which(tool_name, config.environment['PATH']) if not tool_path: # Warn, but still provide a substitution. lit_config.note( - 'Did not find ' + tool_name + ' in ' + config.llvm_tools_dir) + 'Did not find ' + tool_name + ' in ' + config.environment['PATH']) config.substitutions.append((pattern, tool_pipe + tool_path)) # Shell execution @@ -115,8 +125,8 @@ if platform.system() in ['FreeBSD', 'Linux']: else: config.available_features.add('linux') -if platform.system() in ['Windows']: - config.available_features.add('windows') +config.available_features.add( + binary_feature(platform.system() in ['Windows'], 'windows', 'no')) if re.match(r'^arm(hf.*-linux)|(.*-linux-gnuabihf)', config.target_triple): config.available_features.add("armhf-linux") @@ -131,6 +141,8 @@ elif re.match(r'cl', config.cc): config.available_features.add("compiler-msvc") config.available_features.add(binary_feature(config.have_zlib, "zlib", "no")) +if config.have_lld: + config.available_features.add("lld") # llvm-config knows whether it is compiled with asserts (and) # whether we are operating in release/debug mode. @@ -155,6 +167,8 @@ if re.search(r'ARM', llvm_config_output_list[2]): config.available_features.add('arm') if re.search(r'Mips', llvm_config_output_list[2]): config.available_features.add('mips') +if re.search(r'PowerPC', llvm_config_output_list[2]): + config.available_features.add('powerpc') if re.search(r'X86', llvm_config_output_list[2]): config.available_features.add('x86') llvm_config_cmd.wait() diff --git a/lit/lit.site.cfg.in b/lit/lit.site.cfg.in index 2cfa677651a1..55942db64c4f 100644 --- a/lit/lit.site.cfg.in +++ b/lit/lit.site.cfg.in @@ -6,19 +6,24 @@ config.llvm_tools_dir = "@LLVM_TOOLS_DIR@" config.llvm_libs_dir = "@LLVM_LIBS_DIR@" config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@" config.lldb_obj_root = "@LLDB_BINARY_DIR@" -config.lldb_libs_dir = "@LLVM_LIBRARY_OUTPUT_INTDIR@" -config.lldb_tools_dir = "@LLVM_RUNTIME_OUTPUT_INTDIR@" +config.lldb_libs_dir = "@LLDB_LIBS_DIR@" +config.lldb_tools_dir = "@LLDB_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 = @HAVE_LIBZ@ +config.have_zlib = @LLVM_ENABLE_ZLIB@ +config.have_lld = @LLDB_HAVE_LLD@ # 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.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 except KeyError as e: key, = e.args lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key,key)) diff --git a/lit/tools/lldb-mi/breakpoint/break-insert.test b/lit/tools/lldb-mi/breakpoint/break-insert.test new file mode 100644 index 000000000000..cecf9e2443ae --- /dev/null +++ b/lit/tools/lldb-mi/breakpoint/break-insert.test @@ -0,0 +1,18 @@ +# XFAIL: windows +# -> llvm.org/pr24452 +# +# RUN: %cc -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. + +-break-insert breakpoint +# CHECK: ^done,bkpt={number="1" + +-file-exec-and-symbols a.exe +# CHECK: ^done + +-exec-run +# CHECK: ^running +# CHECK: *stopped,reason="breakpoint-hit" + diff --git a/lit/tools/lldb-mi/breakpoint/inputs/break-insert.c b/lit/tools/lldb-mi/breakpoint/inputs/break-insert.c new file mode 100644 index 000000000000..67d2e56ee597 --- /dev/null +++ b/lit/tools/lldb-mi/breakpoint/inputs/break-insert.c @@ -0,0 +1,7 @@ +int breakpoint() { // Breakpoint will be set here. + return 0; +} + +int main() { + return breakpoint(); +} diff --git a/lit/tools/lldb-mi/breakpoint/lit.local.cfg b/lit/tools/lldb-mi/breakpoint/lit.local.cfg new file mode 100644 index 000000000000..df9b335dd131 --- /dev/null +++ b/lit/tools/lldb-mi/breakpoint/lit.local.cfg @@ -0,0 +1 @@ +config.suffixes = ['.test'] diff --git a/lit/tools/lldb-mi/data/data-info-line.test b/lit/tools/lldb-mi/data/data-info-line.test new file mode 100644 index 000000000000..c224efa4de2d --- /dev/null +++ b/lit/tools/lldb-mi/data/data-info-line.test @@ -0,0 +1,36 @@ +# XFAIL: windows +# -> llvm.org/pr24452 +# +# RUN: %cc -o %t %p/inputs/data-info-line.c -g +# RUN: %lldbmi %t < %s | FileCheck %s + +# Test lldb-mi -data-info-line command. + +# Check that we have a valid target created via '%lldbmi %t'. +# CHECK: ^done + +-break-insert main +# CHECK: ^done,bkpt={number="1" + +-exec-run +# CHECK: ^running +# CHECK: *stopped,reason="breakpoint-hit" + +-data-info-line *0x0 +# Test that -data-info-line fails when invalid address is specified. +# CHECK: ^error,msg="Command 'data-info-line'. Error: The LineEntry is absent or has an unknown format." + +-data-info-line unknown_file:1 +# Test that -data-info-line fails when file is unknown. +# CHECK: ^error,msg="Command 'data-info-line'. Error: The LineEntry is absent or has an unknown format." + +-data-info-line data-info-line.c:bad_line +# Test that -data-info-line fails when line has invalid format. +# CHECK: ^error,msg="Command 'data-info-line'. Error: The LineEntry is absent or has an unknown format." + +-data-info-line data-info-line.c:0 +# Test that -data-info-line fails when invalid line is specified. +# CHECK: ^error,msg="Command 'data-info-line'. Error: The LineEntry is absent or has an unknown format." + +-data-info-line data-info-line.c:2 +# CHECK: ^done,start="0x{{[0-9a-f]+}}",end="0x{{[0-9a-f]+}}",file="{{.*}}data-info-line.c",line="{{[0-9]+}}" diff --git a/lit/tools/lldb-mi/data/inputs/data-info-line.c b/lit/tools/lldb-mi/data/inputs/data-info-line.c new file mode 100644 index 000000000000..61c3710bf203 --- /dev/null +++ b/lit/tools/lldb-mi/data/inputs/data-info-line.c @@ -0,0 +1,4 @@ +int main(void) { + int x = 0; + return 12345 + x; +} diff --git a/lit/tools/lldb-mi/data/lit.local.cfg b/lit/tools/lldb-mi/data/lit.local.cfg new file mode 100644 index 000000000000..df9b335dd131 --- /dev/null +++ b/lit/tools/lldb-mi/data/lit.local.cfg @@ -0,0 +1 @@ +config.suffixes = ['.test'] diff --git a/lit/tools/lldb-mi/exec/exec-continue.test b/lit/tools/lldb-mi/exec/exec-continue.test new file mode 100644 index 000000000000..c363422373d3 --- /dev/null +++ b/lit/tools/lldb-mi/exec/exec-continue.test @@ -0,0 +1,20 @@ +# XFAIL: windows +# -> llvm.org/pr24452 +# +# RUN: %cc -o %t %p/inputs/main.c -g +# RUN: %lldbmi %t < %s | FileCheck %s + +# Test lldb-mi -exec-continue command. + +# Check that we have a valid target created via '%lldbmi %t'. +# CHECK: ^done + +-break-insert main +# CHECK: ^done,bkpt={number="1" + +-exec-run +# CHECK: ^running +# CHECK: *stopped,reason="breakpoint-hit" + +-exec-continue +# CHECK: ^running diff --git a/lit/tools/lldb-mi/exec/exec-finish.test b/lit/tools/lldb-mi/exec/exec-finish.test new file mode 100644 index 000000000000..03c6b158fcf3 --- /dev/null +++ b/lit/tools/lldb-mi/exec/exec-finish.test @@ -0,0 +1,33 @@ +# XFAIL: windows +# -> llvm.org/pr24452 +# +# RUN: %cc -o %t %p/inputs/main.c -g +# RUN: %lldbmi %t < %s | FileCheck %s + +# Test lldb-mi -exec-finish command. + +# Check that we have a valid target created via '%lldbmi %t'. +# CHECK: ^done + +-break-insert main +# CHECK: ^done,bkpt={number="1" + +-break-insert dummyFunction +# CHECK: ^done,bkpt={number="2" + +-exec-run +# CHECK: ^running +# CHECK: *stopped,reason="breakpoint-hit" + +-exec-finish --thread 0 +# Check that exec-finish can process the case of invalid thread ID. +# CHECK: ^error,msg="Command 'exec-finish'. Thread ID invalid" + +-exec-finish --thread 1 +# CHECK: ^running +# CHECK: *stopped,reason="breakpoint-hit" + +-exec-finish +# Check exec-finish in a selected thread. +# CHECK: ^running +# CHECK: *stopped,reason="end-stepping-range" diff --git a/lit/tools/lldb-mi/exec/exec-interrupt.test b/lit/tools/lldb-mi/exec/exec-interrupt.test new file mode 100644 index 000000000000..81a3e72ee7e6 --- /dev/null +++ b/lit/tools/lldb-mi/exec/exec-interrupt.test @@ -0,0 +1,20 @@ +# XFAIL: windows +# -> llvm.org/pr24452 +# +# RUN: %cc -o %t %p/inputs/main.c -g +# RUN: %lldbmi %t < %s | FileCheck %s + +# Test lldb-mi -exec-interrupt command. + +# Check that we have a valid target created via '%lldbmi %t'. +# CHECK: ^done + +-break-insert main +# CHECK: ^done,bkpt={number="1" + +-exec-run +# CHECK: ^running +# CHECK: *stopped,reason="breakpoint-hit" + +-exec-interrupt +# CHECK: ^error,msg="Process is not running." diff --git a/lit/tools/lldb-mi/exec/exec-next-instruction.test b/lit/tools/lldb-mi/exec/exec-next-instruction.test new file mode 100644 index 000000000000..1dcca0468490 --- /dev/null +++ b/lit/tools/lldb-mi/exec/exec-next-instruction.test @@ -0,0 +1,30 @@ +# XFAIL: windows +# -> llvm.org/pr24452 +# +# RUN: %cc -o %t %p/inputs/main.c -g +# RUN: %lldbmi %t < %s | FileCheck %s + +# Test lldb-mi -exec-next-instruction command. + +# Check that we have a valid target created via '%lldbmi %t'. +# CHECK: ^done + +-break-insert main +# CHECK: ^done,bkpt={number="1" + +-exec-run +# CHECK: ^running +# CHECK: *stopped,reason="breakpoint-hit" + +-exec-next-instruction --thread 0 +# Check that exec-next-instruction can process the case of invalid thread ID. +# CHECK: ^error,msg="Command 'exec-next-instruction'. Thread ID invalid" + +-exec-next-instruction --thread 1 +# CHECK: ^running +# CHECK: *stopped,reason="end-stepping-range" + +-exec-next-instruction +# Check exec-next-instruction in a selected thread. +# CHECK: ^running +# CHECK: *stopped,reason="end-stepping-range" diff --git a/lit/tools/lldb-mi/exec/exec-next.test b/lit/tools/lldb-mi/exec/exec-next.test new file mode 100644 index 000000000000..a4dd737b5ddb --- /dev/null +++ b/lit/tools/lldb-mi/exec/exec-next.test @@ -0,0 +1,30 @@ +# XFAIL: windows +# -> llvm.org/pr24452 +# +# RUN: %cc -o %t %p/inputs/main.c -g +# RUN: %lldbmi %t < %s | FileCheck %s + +# Test lldb-mi -exec-next command. + +# Check that we have a valid target created via '%lldbmi %t'. +# CHECK: ^done + +-break-insert main +# CHECK: ^done,bkpt={number="1" + +-exec-run +# CHECK: ^running +# CHECK: *stopped,reason="breakpoint-hit" + +-exec-next --thread 0 +# Check that exec-next can process the case of invalid thread ID. +# CHECK: ^error,msg="Command 'exec-next'. Thread ID invalid" + +-exec-next --thread 1 +# CHECK: ^running +# CHECK: *stopped,reason="end-stepping-range" + +-exec-next +# Check that exec-next can step over in a selected thread. +# CHECK: ^running +# CHECK: *stopped,reason="end-stepping-range" diff --git a/lit/tools/lldb-mi/exec/exec-run-wrong-binary.test b/lit/tools/lldb-mi/exec/exec-run-wrong-binary.test new file mode 100644 index 000000000000..98dc75f509cd --- /dev/null +++ b/lit/tools/lldb-mi/exec/exec-run-wrong-binary.test @@ -0,0 +1,6 @@ +# RUN: %lldbmi < %s | FileCheck %s + +# Test that -exec-run command won't hang in case of wrong name of binary file. + +-file-exec-and-symbols name.exe +# CHECK: ^error,msg="Command 'file-exec-and-symbols'. Target binary 'name.exe' is invalid. diff --git a/lit/tools/lldb-mi/exec/exec-step-instruction.test b/lit/tools/lldb-mi/exec/exec-step-instruction.test new file mode 100644 index 000000000000..a02bc01a07d6 --- /dev/null +++ b/lit/tools/lldb-mi/exec/exec-step-instruction.test @@ -0,0 +1,30 @@ +# XFAIL: windows +# -> llvm.org/pr24452 +# +# RUN: %cc -o %t %p/inputs/main.c -g +# RUN: %lldbmi %t < %s | FileCheck %s + +# Test lldb-mi -exec-step-instruction command. + +# Check that we have a valid target created via '%lldbmi %t'. +# CHECK: ^done + +-break-insert main +# CHECK: ^done,bkpt={number="1" + +-exec-run +# CHECK: ^running +# CHECK: *stopped,reason="breakpoint-hit" + +-exec-step-instruction --thread 0 +# Check that exec-step-instruction can process the case of invalid thread ID. +# CHECK: ^error,msg="Command 'exec-step-instruction'. Thread ID invalid" + +-exec-next-instruction --thread 1 +# CHECK: ^running +# CHECK: *stopped,reason="end-stepping-range" + +-exec-step-instruction +# Check exec-step-instruction in a selected thread. +# CHECK: ^running +# CHECK: *stopped,reason="end-stepping-range" diff --git a/lit/tools/lldb-mi/exec/exec-step.test b/lit/tools/lldb-mi/exec/exec-step.test new file mode 100644 index 000000000000..095bba714ec8 --- /dev/null +++ b/lit/tools/lldb-mi/exec/exec-step.test @@ -0,0 +1,30 @@ +# XFAIL: windows +# -> llvm.org/pr24452 +# +# RUN: %cc -o %t %p/inputs/main.c -g +# RUN: %lldbmi %t < %s | FileCheck %s + +# Test lldb-mi -exec-step command. + +# Check that we have a valid target created via '%lldbmi %t'. +# CHECK: ^done + +-break-insert main +# CHECK: ^done,bkpt={number="1" + +-exec-run +# CHECK: ^running +# CHECK: *stopped,reason="breakpoint-hit" + +-exec-step --thread 0 +# Check that exec-step can process the case of invalid thread ID. +# CHECK: ^error,msg="Command 'exec-step'. Thread ID invalid" + +-exec-step --thread 1 +# CHECK: ^running +# CHECK: *stopped,reason="end-stepping-range" + +-exec-step +# Check that exec-step can step-in in a selected thread. +# CHECK: ^running +# CHECK: *stopped,reason="end-stepping-range" diff --git a/lit/tools/lldb-mi/exec/inputs/main.c b/lit/tools/lldb-mi/exec/inputs/main.c new file mode 100644 index 000000000000..b9d8f9d16f4d --- /dev/null +++ b/lit/tools/lldb-mi/exec/inputs/main.c @@ -0,0 +1,9 @@ +void dummyFunction() { + int a = 0; +} + +int main(void) { + int x = 0; + dummyFunction(); + return x; +} diff --git a/lit/tools/lldb-mi/exec/lit.local.cfg b/lit/tools/lldb-mi/exec/lit.local.cfg new file mode 100644 index 000000000000..df9b335dd131 --- /dev/null +++ b/lit/tools/lldb-mi/exec/lit.local.cfg @@ -0,0 +1 @@ +config.suffixes = ['.test'] diff --git a/lit/tools/lldb-mi/symbol/inputs/list-lines-helper.c b/lit/tools/lldb-mi/symbol/inputs/list-lines-helper.c new file mode 100644 index 000000000000..74e627645406 --- /dev/null +++ b/lit/tools/lldb-mi/symbol/inputs/list-lines-helper.c @@ -0,0 +1,3 @@ +void HelpFunction(void) { + int x = 12345; +} diff --git a/lit/tools/lldb-mi/symbol/inputs/list-lines-helper.h b/lit/tools/lldb-mi/symbol/inputs/list-lines-helper.h new file mode 100644 index 000000000000..05edab992a5f --- /dev/null +++ b/lit/tools/lldb-mi/symbol/inputs/list-lines-helper.h @@ -0,0 +1 @@ +void HelpFunction(void); diff --git a/lit/tools/lldb-mi/symbol/inputs/main.c b/lit/tools/lldb-mi/symbol/inputs/main.c new file mode 100644 index 000000000000..f21edf3230a5 --- /dev/null +++ b/lit/tools/lldb-mi/symbol/inputs/main.c @@ -0,0 +1,6 @@ +#include "symbol-list-lines.h" + +int main(void) { + int x = GetZero(); + return 0; +} diff --git a/lit/tools/lldb-mi/symbol/inputs/symbol-list-lines.c b/lit/tools/lldb-mi/symbol/inputs/symbol-list-lines.c new file mode 100644 index 000000000000..761f793548b6 --- /dev/null +++ b/lit/tools/lldb-mi/symbol/inputs/symbol-list-lines.c @@ -0,0 +1,6 @@ +#include "list-lines-helper.h" + +int GetZero() { + HelpFunction(); + return 0; +} diff --git a/lit/tools/lldb-mi/symbol/inputs/symbol-list-lines.h b/lit/tools/lldb-mi/symbol/inputs/symbol-list-lines.h new file mode 100644 index 000000000000..1b74ff621ecb --- /dev/null +++ b/lit/tools/lldb-mi/symbol/inputs/symbol-list-lines.h @@ -0,0 +1 @@ +int GetZero(); diff --git a/lit/tools/lldb-mi/symbol/lit.local.cfg b/lit/tools/lldb-mi/symbol/lit.local.cfg new file mode 100644 index 000000000000..df9b335dd131 --- /dev/null +++ b/lit/tools/lldb-mi/symbol/lit.local.cfg @@ -0,0 +1 @@ +config.suffixes = ['.test'] diff --git a/lit/tools/lldb-mi/symbol/symbol-list-lines.test b/lit/tools/lldb-mi/symbol/symbol-list-lines.test new file mode 100644 index 000000000000..f40ad2f94e40 --- /dev/null +++ b/lit/tools/lldb-mi/symbol/symbol-list-lines.test @@ -0,0 +1,20 @@ +# XFAIL: 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: %lldbmi %t < %s | FileCheck %s + +# Test lldb-mi -symbol-list-lines command. + +# Check that we have a valid target created via '%lldbmi %t'. +# CHECK: ^done + +-symbol-list-lines invalid_file.c +# Check a case of invalid file name. +# CHECK: ^error,msg="File Handler. Invalid file name path" + +-symbol-list-lines symbol-list-lines.c +# CHECK: ^done,lines=[{pc="0x{{[0-9A-Fa-f]+}}",line="3"},{pc="0x{{[0-9A-Fa-f]+}}",line="4"},{pc="0x{{[0-9A-Fa-f]+}}",line="5"}] + +-symbol-list-lines list-lines-helper.c +# CHECK: ^done,lines=[{pc="0x{{[0-9A-Fa-f]+}}",line="1"},{pc="0x{{[0-9A-Fa-f]+}}",line="2"},{pc="0x{{[0-9A-Fa-f]+}}",line="3"}] |