399 lines · plain
1# clang-format off2# REQUIRES: lld, x863 4# Test when nested S_BLOCK32 have same address range, ResolveSymbolContext should return the innnermost block.5# RUN: llvm-mc -triple=x86_64-windows-msvc --filetype=obj %s > %t.obj6# RUN: lld-link /debug:full /nodefaultlib /entry:main %t.obj /out:%t.exe /base:0x1400000007# RUN: %lldb -f %t.exe -o "image lookup -a 0x14000103c -v" -o "exit" | FileCheck %s8 9# This file is compiled from following source file:10# $ clang-cl /Z7 /GS- /c /O2 test.cpp /Fatest.s11# __attribute__((optnone)) bool func(const char* cp, volatile char p[]) {12# return false;13# }14#15# int main() {16# const char* const kMfDLLs[] = {"a"};17# asm("nop");18# for (const char* kMfDLL : kMfDLLs) {19# volatile char path[10] = {0};20# if (func(kMfDLL, path))21# break;22# }23# return 0;24# }25 26# CHECK: Function: id = {{.*}}, name = "main", range = [0x0000000140001020-0x000000014000104d)27# CHECK-NEXT: FuncType: id = {{.*}}, byte-size = 0, compiler_type = "int (void)"28# CHECK-NEXT: Blocks: id = {{.*}}, range = [0x140001020-0x14000104d)29# CHECK-NEXT: id = {{.*}}, range = [0x140001025-0x140001046)30# CHECK-NEXT: id = {{.*}}, range = [0x140001025-0x140001046)31# CHECK-NEXT: id = {{.*}}, range = [0x140001025-0x140001046)32# CHECK-NEXT: LineEntry: [0x0000000140001035-0x0000000140001046): /tmp/test.cpp:1033# CHECK-NEXT: Symbol: id = {{.*}}, range = [0x0000000140001020-0x000000014000104d), name="main"34# CHECK-NEXT: Variable: id = {{.*}}, name = "path", type = "volatile char[10]", valid ranges = <block>, location = [0x0000000140001025, 0x0000000140001046) -> DW_OP_breg7 RSP+40, decl =35# CHECK-NEXT: Variable: id = {{.*}}, name = "kMfDLL", type = "const char *", valid ranges = <block>, location = [0x000000014000103c, 0x0000000140001046) -> DW_OP_reg2 RCX, decl =36# CHECK-NEXT: Variable: id = {{.*}}, name = "__range1", type = "const char *const (&)[1]", valid ranges = <block>, location = <empty>, decl =37# CHECK-NEXT: Variable: id = {{.*}}, name = "__begin1", type = "const char *const *", valid ranges = <block>, location = <empty>, decl =38# CHECK-NEXT: Variable: id = {{.*}}, name = "__end1", type = "const char *const *", valid ranges = <block>, location = <empty>, decl =39# CHECK-NEXT: Variable: id = {{.*}}, name = "kMfDLLs", type = "const char *const[1]", valid ranges = <block>, location = [0x000000014000103c, 0x0000000140001046) -> DW_OP_reg2 RCX, decl =40 41 42 .text43 .def @feat.00;44 .scl 3;45 .type 0;46 .endef47 .globl @feat.0048.set @feat.00, 049 .intel_syntax noprefix50 .file "test.cpp"51 .def "?func@@YA_NPEBDQECD@Z";52 .scl 2;53 .type 32;54 .endef55 .section .text,"xr",one_only,"?func@@YA_NPEBDQECD@Z"56 .globl "?func@@YA_NPEBDQECD@Z" # -- Begin function ?func@@YA_NPEBDQECD@Z57 .p2align 4, 0x9058"?func@@YA_NPEBDQECD@Z": # @"?func@@YA_NPEBDQECD@Z"59.Lfunc_begin0:60 .cv_func_id 061 .cv_file 1 "/tmp/test.cpp" "8CDAA03EE93954606427F9B409CE7638" 162 .cv_loc 0 1 1 0 # test.cpp:1:063.seh_proc "?func@@YA_NPEBDQECD@Z"64# %bb.0: # %entry65 sub rsp, 1666 .seh_stackalloc 1667 .seh_endprologue68 mov qword ptr [rsp + 8], rdx69 mov qword ptr [rsp], rcx70.Ltmp0:71 .cv_loc 0 1 2 0 # test.cpp:2:072 xor eax, eax73 and al, 174 movzx eax, al75 add rsp, 1676 ret77.Ltmp1:78.Lfunc_end0:79 .seh_endproc80 # -- End function81 .def main;82 .scl 2;83 .type 32;84 .endef85 .section .text,"xr",one_only,main86 .globl main # -- Begin function main87 .p2align 4, 0x9088main: # @main89.Lfunc_begin1:90 .cv_func_id 191 .cv_loc 1 1 5 0 # test.cpp:5:092.seh_proc main93# %bb.0: # %entry94 sub rsp, 5695 .seh_stackalloc 5696 .seh_endprologue97.Ltmp2:98 .cv_loc 1 1 7 0 # test.cpp:7:099 #APP100 nop101 #NO_APP102.Ltmp3:103 #DEBUG_VALUE: __range1 <- undef104 #DEBUG_VALUE: __begin1 <- undef105 #DEBUG_VALUE: __end1 <- [DW_OP_plus_uconst 8, DW_OP_stack_value] undef106 .cv_loc 1 1 9 0 # test.cpp:9:0107 mov word ptr [rsp + 48], 0108 mov qword ptr [rsp + 40], 0109 .cv_loc 1 1 10 0 # test.cpp:10:0110 lea rcx, [rip + "??_C@_01MCMALHOG@a?$AA@"]111.Ltmp4:112 #DEBUG_VALUE: main:kMfDLLs <- $rcx113 #DEBUG_VALUE: kMfDLL <- $rcx114 lea rdx, [rsp + 40]115 call "?func@@YA_NPEBDQECD@Z"116.Ltmp5:117 #DEBUG_VALUE: __begin1 <- [DW_OP_LLVM_arg 0, DW_OP_LLVM_arg 1, DW_OP_constu 8, DW_OP_mul, DW_OP_plus, DW_OP_stack_value] undef, undef118 .cv_loc 1 1 14 0 # test.cpp:14:0119 xor eax, eax120 add rsp, 56121 ret122.Ltmp6:123.Lfunc_end1:124 .seh_endproc125 # -- End function126 .section .rdata,"dr",discard,"??_C@_01MCMALHOG@a?$AA@"127 .globl "??_C@_01MCMALHOG@a?$AA@" # @"??_C@_01MCMALHOG@a?$AA@"128"??_C@_01MCMALHOG@a?$AA@":129 .asciz "a"130 131 .section .debug$S,"dr"132 .p2align 2, 0x0133 .long 4 # Debug section magic134 .long 241135 .long .Ltmp8-.Ltmp7 # Subsection size136.Ltmp7:137 .short .Ltmp12-.Ltmp11 # Record length138.Ltmp11:139 .short 4412 # Record kind: S_COMPILE3140 .long 1 # Flags and language141 .short 208 # CPUType142 .short 16 # Frontend version143 .short 0144 .short 0145 .short 0146 .short 16000 # Backend version147 .short 0148 .short 0149 .short 0150 .asciz "clang version 16.0.0" # Null-terminated compiler version string151 .p2align 2, 0x0152.Ltmp12:153.Ltmp8:154 .p2align 2, 0x0155 .section .debug$S,"dr",associative,"?func@@YA_NPEBDQECD@Z"156 .p2align 2, 0x0157 .long 4 # Debug section magic158 .long 241 # Symbol subsection for func159.Ltmp14:160 .p2align 2, 0x0161 .cv_linetable 0, "?func@@YA_NPEBDQECD@Z", .Lfunc_end0162 .section .debug$S,"dr",associative,main163 .p2align 2, 0x0164 .long 4 # Debug section magic165 .long 241 # Symbol subsection for main166 .long .Ltmp24-.Ltmp23 # Subsection size167.Ltmp23:168 .short .Ltmp26-.Ltmp25 # Record length169.Ltmp25:170 .short 4423 # Record kind: S_GPROC32_ID171 .long 0 # PtrParent172 .long 0 # PtrEnd173 .long 0 # PtrNext174 .long .Lfunc_end1-main # Code size175 .long 0 # Offset after prologue176 .long 0 # Offset before epilogue177 .long 4105 # Function type index178 .secrel32 main # Function section relative address179 .secidx main # Function section index180 .byte 0 # Flags181 .asciz "main" # Function name182 .p2align 2, 0x0183.Ltmp26:184 .short .Ltmp28-.Ltmp27 # Record length185.Ltmp27:186 .short 4114 # Record kind: S_FRAMEPROC187 .long 56 # FrameSize188 .long 0 # Padding189 .long 0 # Offset of padding190 .long 0 # Bytes of callee saved registers191 .long 0 # Exception handler offset192 .short 0 # Exception handler section193 .long 1130504 # Flags (defines frame register)194 .p2align 2, 0x0195.Ltmp28:196 .short .Ltmp30-.Ltmp29 # Record length197.Ltmp29:198 .short 4414 # Record kind: S_LOCAL199 .long 4107 # TypeIndex200 .short 0 # Flags201 .asciz "kMfDLLs"202 .p2align 2, 0x0203.Ltmp30:204 .cv_def_range .Ltmp4 .Ltmp5, reg, 330205 .short .Ltmp32-.Ltmp31 # Record length206.Ltmp31:207 .short 4355 # Record kind: S_BLOCK32208 .long 0 # PtrParent209 .long 0 # PtrEnd210 .long .Ltmp5-.Ltmp3 # Code size211 .secrel32 .Ltmp3 # Function section relative address212 .secidx .Lfunc_begin1 # Function section index213 .byte 0 # Lexical block name214 .p2align 2, 0x0215.Ltmp32:216 .short .Ltmp34-.Ltmp33 # Record length217.Ltmp33:218 .short 4414 # Record kind: S_LOCAL219 .long 4108 # TypeIndex220 .short 256 # Flags221 .asciz "__range1"222 .p2align 2, 0x0223.Ltmp34:224 .short .Ltmp36-.Ltmp35 # Record length225.Ltmp35:226 .short 4414 # Record kind: S_LOCAL227 .long 4109 # TypeIndex228 .short 256 # Flags229 .asciz "__begin1"230 .p2align 2, 0x0231.Ltmp36:232 .short .Ltmp38-.Ltmp37 # Record length233.Ltmp37:234 .short 4414 # Record kind: S_LOCAL235 .long 4109 # TypeIndex236 .short 256 # Flags237 .asciz "__end1"238 .p2align 2, 0x0239.Ltmp38:240 .short .Ltmp40-.Ltmp39 # Record length241.Ltmp39:242 .short 4355 # Record kind: S_BLOCK32243 .long 0 # PtrParent244 .long 0 # PtrEnd245 .long .Ltmp5-.Ltmp3 # Code size246 .secrel32 .Ltmp3 # Function section relative address247 .secidx .Lfunc_begin1 # Function section index248 .byte 0 # Lexical block name249 .p2align 2, 0x0250.Ltmp40:251 .short .Ltmp42-.Ltmp41 # Record length252.Ltmp41:253 .short 4414 # Record kind: S_LOCAL254 .long 4097 # TypeIndex255 .short 0 # Flags256 .asciz "kMfDLL"257 .p2align 2, 0x0258.Ltmp42:259 .cv_def_range .Ltmp4 .Ltmp5, reg, 330260 .short .Ltmp44-.Ltmp43 # Record length261.Ltmp43:262 .short 4355 # Record kind: S_BLOCK32263 .long 0 # PtrParent264 .long 0 # PtrEnd265 .long .Ltmp5-.Ltmp3 # Code size266 .secrel32 .Ltmp3 # Function section relative address267 .secidx .Lfunc_begin1 # Function section index268 .byte 0 # Lexical block name269 .p2align 2, 0x0270.Ltmp44:271 .short .Ltmp46-.Ltmp45 # Record length272.Ltmp45:273 .short 4414 # Record kind: S_LOCAL274 .long 4110 # TypeIndex275 .short 0 # Flags276 .asciz "path"277 .p2align 2, 0x0278.Ltmp46:279 .cv_def_range .Ltmp3 .Ltmp5, frame_ptr_rel, 40280 .short 2 # Record length281 .short 6 # Record kind: S_END282 .short 2 # Record length283 .short 6 # Record kind: S_END284 .short 2 # Record length285 .short 6 # Record kind: S_END286 .short 2 # Record length287 .short 4431 # Record kind: S_PROC_ID_END288.Ltmp24:289 .p2align 2, 0x0290 .cv_linetable 1, main, .Lfunc_end1291 .section .debug$S,"dr"292 .cv_filechecksums # File index to string table offset subsection293 .cv_stringtable # String table294.Ltmp50:295.Ltmp48:296 .p2align 2, 0x0297 .section .debug$T,"dr"298 .p2align 2, 0x0299 .long 4 # Debug section magic300 # Modifier (0x1000)301 .short 0xa # Record length302 .short 0x1001 # Record kind: LF_MODIFIER303 .long 0x70 # ModifiedType: char304 .short 0x1 # Modifiers ( Const (0x1) )305 .byte 242306 .byte 241307 # Pointer (0x1001)308 .short 0xa # Record length309 .short 0x1002 # Record kind: LF_POINTER310 .long 0x1000 # PointeeType: const char311 .long 0x1000c # Attrs: [ Type: Near64, Mode: Pointer, SizeOf: 8 ]312 # Modifier (0x1002)313 .short 0xa # Record length314 .short 0x1001 # Record kind: LF_MODIFIER315 .long 0x70 # ModifiedType: char316 .short 0x2 # Modifiers ( Volatile (0x2) )317 .byte 242318 .byte 241319 # Pointer (0x1003)320 .short 0xa # Record length321 .short 0x1002 # Record kind: LF_POINTER322 .long 0x1002 # PointeeType: volatile char323 .long 0x1000c # Attrs: [ Type: Near64, Mode: Pointer, SizeOf: 8 ]324 # ArgList (0x1004)325 .short 0xe # Record length326 .short 0x1201 # Record kind: LF_ARGLIST327 .long 0x2 # NumArgs328 .long 0x1001 # Argument: const char*329 .long 0x1003 # Argument: volatile char*330 # Procedure (0x1005)331 .short 0xe # Record length332 .short 0x1008 # Record kind: LF_PROCEDURE333 .long 0x30 # ReturnType: bool334 .byte 0x0 # CallingConvention: NearC335 .byte 0x0 # FunctionOptions336 .short 0x2 # NumParameters337 .long 0x1004 # ArgListType: (const char*, volatile char*)338 # FuncId (0x1006)339 .short 0x12 # Record length340 .short 0x1601 # Record kind: LF_FUNC_ID341 .long 0x0 # ParentScope342 .long 0x1005 # FunctionType: bool (const char*, volatile char*)343 .asciz "func" # Name344 .byte 243345 .byte 242346 .byte 241347 # ArgList (0x1007)348 .short 0x6 # Record length349 .short 0x1201 # Record kind: LF_ARGLIST350 .long 0x0 # NumArgs351 # Procedure (0x1008)352 .short 0xe # Record length353 .short 0x1008 # Record kind: LF_PROCEDURE354 .long 0x74 # ReturnType: int355 .byte 0x0 # CallingConvention: NearC356 .byte 0x0 # FunctionOptions357 .short 0x0 # NumParameters358 .long 0x1007 # ArgListType: ()359 # FuncId (0x1009)360 .short 0x12 # Record length361 .short 0x1601 # Record kind: LF_FUNC_ID362 .long 0x0 # ParentScope363 .long 0x1008 # FunctionType: int ()364 .asciz "main" # Name365 .byte 243366 .byte 242367 .byte 241368 # Pointer (0x100A)369 .short 0xa # Record length370 .short 0x1002 # Record kind: LF_POINTER371 .long 0x1000 # PointeeType: const char372 .long 0x1040c # Attrs: [ Type: Near64, Mode: Pointer, SizeOf: 8, isConst ]373 # Array (0x100B)374 .short 0xe # Record length375 .short 0x1503 # Record kind: LF_ARRAY376 .long 0x100a # ElementType: const char* const377 .long 0x23 # IndexType: unsigned __int64378 .short 0x8 # SizeOf379 .byte 0 # Name380 .byte 241381 # Pointer (0x100C)382 .short 0xa # Record length383 .short 0x1002 # Record kind: LF_POINTER384 .long 0x100b # PointeeType385 .long 0x1002c # Attrs: [ Type: Near64, Mode: LValueReference, SizeOf: 8 ]386 # Pointer (0x100D)387 .short 0xa # Record length388 .short 0x1002 # Record kind: LF_POINTER389 .long 0x100a # PointeeType: const char* const390 .long 0x1000c # Attrs: [ Type: Near64, Mode: Pointer, SizeOf: 8 ]391 # Array (0x100E)392 .short 0xe # Record length393 .short 0x1503 # Record kind: LF_ARRAY394 .long 0x1002 # ElementType: volatile char395 .long 0x23 # IndexType: unsigned __int64396 .short 0xa # SizeOf397 .byte 0 # Name398 .byte 241399