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.obj
6 # RUN: lld-link /debug:full /nodefaultlib /entry:main %t.obj /out:%t.exe /base:0x140000000
7 # RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -o "image lookup -a 0x14000103c -v" -o "exit" | FileCheck %s
9 # This file is compiled from following source file:
10 # $ clang-cl /Z7 /GS- /c /O2 test.cpp /Fatest.s
11 # __attribute__((optnone)) bool func(const char* cp, volatile char p[]) {
16 # const char* const kMfDLLs[] = {"a"};
18 # for (const char* kMfDLL : kMfDLLs) {
19 # volatile char path[10] = {0};
20 # if (func(kMfDLL, path))
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:10
33 # CHECK-NEXT: Variable: id = {{.*}}, name = "path", type = "volatile char[10]", valid ranges = <block>, location = [0x0000000140001025, 0x0000000140001046) -> DW_OP_breg7 RSP+40, decl =
34 # CHECK-NEXT: Variable: id = {{.*}}, name = "kMfDLL", type = "const char *", valid ranges = <block>, location = [0x000000014000103c, 0x0000000140001046) -> DW_OP_reg2 RCX, decl =
35 # CHECK-NEXT: Variable: id = {{.*}}, name = "__range1", type = "const char *const (&)[1]", valid ranges = <block>, location = <empty>, decl =
36 # CHECK-NEXT: Variable: id = {{.*}}, name = "__begin1", type = "const char *const *", valid ranges = <block>, location = <empty>, decl =
37 # CHECK-NEXT: Variable: id = {{.*}}, name = "__end1", type = "const char *const *", valid ranges = <block>, location = <empty>, decl =
38 # CHECK-NEXT: Variable: id = {{.*}}, name = "kMfDLLs", type = "const char *const[1]", valid ranges = <block>, location = [0x000000014000103c, 0x0000000140001046) -> DW_OP_reg2 RCX, decl =
48 .intel_syntax noprefix
50 .def "?func@@YA_NPEBDQECD@Z";
54 .section .text,"xr",one_only,"?func@@YA_NPEBDQECD@Z"
55 .globl "?func@@YA_NPEBDQECD@Z" # -- Begin function ?func@@YA_NPEBDQECD@Z
57 "?func@@YA_NPEBDQECD@Z": # @"?func@@YA_NPEBDQECD@Z"
60 .cv_file 1 "/tmp/test.cpp" "8CDAA03EE93954606427F9B409CE7638" 1
61 .cv_loc 0 1 1 0 # test.cpp:1:0
62 .seh_proc "?func@@YA_NPEBDQECD@Z"
67 mov qword ptr
[rsp
+ 8], rdx
68 mov qword ptr
[rsp
], rcx
70 .cv_loc 0 1 2 0 # test.cpp:2:0
84 .section .text,"xr",one_only,main
85 .globl main # -- Begin function main
90 .cv_loc 1 1 5 0 # test.cpp:5:0
97 .cv_loc 1 1 7 0 # test.cpp:7:0
102 #DEBUG_VALUE: __range1 <- undef
103 #DEBUG_VALUE: __begin1 <- undef
104 #DEBUG_VALUE: __end1 <- [DW_OP_plus_uconst 8, DW_OP_stack_value] undef
105 .cv_loc 1 1 9 0 # test.cpp:9:0
106 mov word ptr
[rsp
+ 48], 0
107 mov qword ptr
[rsp
+ 40], 0
108 .cv_loc 1 1 10 0 # test.cpp:10:0
109 lea rcx
, [rip
+ "??_C@_01MCMALHOG@a?$AA@"]
111 #DEBUG_VALUE: main:kMfDLLs <- $rcx
112 #DEBUG_VALUE: kMfDLL <- $rcx
114 call
"?func@@YA_NPEBDQECD@Z"
116 #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, undef
117 .cv_loc 1 1 14 0 # test.cpp:14:0
125 .section .rdata,"dr",discard,"??_C@_01MCMALHOG@a?$AA@"
126 .globl "??_C@_01MCMALHOG@a?$AA@" # @"??_C@_01MCMALHOG@a?$AA@"
127 "??_C@_01MCMALHOG@a?$AA@":
130 .section .debug$S,"dr"
132 .long 4 # Debug section magic
134 .long .Ltmp8-.Ltmp7 # Subsection size
136 .short .Ltmp12-.Ltmp11 # Record length
138 .short 4412 # Record kind: S_COMPILE3
139 .long 1 # Flags and language
141 .short 16 # Frontend version
145 .short 16000 # Backend version
149 .asciz "clang version 16.0.0" # Null-terminated compiler version string
154 .section .debug$S,"dr",associative,"?func@@YA_NPEBDQECD@Z"
156 .long 4 # Debug section magic
157 .long 241 # Symbol subsection for func
160 .cv_linetable 0, "?func@@YA_NPEBDQECD@Z", .Lfunc_end0
161 .section .debug$S,"dr",associative,main
163 .long 4 # Debug section magic
164 .long 241 # Symbol subsection for main
165 .long .Ltmp24-.Ltmp23 # Subsection size
167 .short .Ltmp26-.Ltmp25 # Record length
169 .short 4423 # Record kind: S_GPROC32_ID
173 .long .Lfunc_end1-main # Code size
174 .long 0 # Offset after prologue
175 .long 0 # Offset before epilogue
176 .long 4105 # Function type index
177 .secrel32 main # Function section relative address
178 .secidx main # Function section index
180 .asciz "main" # Function name
183 .short .Ltmp28-.Ltmp27 # Record length
185 .short 4114 # Record kind: S_FRAMEPROC
188 .long 0 # Offset of padding
189 .long 0 # Bytes of callee saved registers
190 .long 0 # Exception handler offset
191 .short 0 # Exception handler section
192 .long 1130504 # Flags (defines frame register)
195 .short .Ltmp30-.Ltmp29 # Record length
197 .short 4414 # Record kind: S_LOCAL
198 .long 4107 # TypeIndex
203 .cv_def_range .Ltmp4 .Ltmp5, reg, 330
204 .short .Ltmp32-.Ltmp31 # Record length
206 .short 4355 # Record kind: S_BLOCK32
209 .long .Ltmp5-.Ltmp3 # Code size
210 .secrel32 .Ltmp3 # Function section relative address
211 .secidx .Lfunc_begin1 # Function section index
212 .byte 0 # Lexical block name
215 .short .Ltmp34-.Ltmp33 # Record length
217 .short 4414 # Record kind: S_LOCAL
218 .long 4108 # TypeIndex
223 .short .Ltmp36-.Ltmp35 # Record length
225 .short 4414 # Record kind: S_LOCAL
226 .long 4109 # TypeIndex
231 .short .Ltmp38-.Ltmp37 # Record length
233 .short 4414 # Record kind: S_LOCAL
234 .long 4109 # TypeIndex
239 .short .Ltmp40-.Ltmp39 # Record length
241 .short 4355 # Record kind: S_BLOCK32
244 .long .Ltmp5-.Ltmp3 # Code size
245 .secrel32 .Ltmp3 # Function section relative address
246 .secidx .Lfunc_begin1 # Function section index
247 .byte 0 # Lexical block name
250 .short .Ltmp42-.Ltmp41 # Record length
252 .short 4414 # Record kind: S_LOCAL
253 .long 4097 # TypeIndex
258 .cv_def_range .Ltmp4 .Ltmp5, reg, 330
259 .short .Ltmp44-.Ltmp43 # Record length
261 .short 4355 # Record kind: S_BLOCK32
264 .long .Ltmp5-.Ltmp3 # Code size
265 .secrel32 .Ltmp3 # Function section relative address
266 .secidx .Lfunc_begin1 # Function section index
267 .byte 0 # Lexical block name
270 .short .Ltmp46-.Ltmp45 # Record length
272 .short 4414 # Record kind: S_LOCAL
273 .long 4110 # TypeIndex
278 .cv_def_range .Ltmp3 .Ltmp5, frame_ptr_rel, 40
279 .short 2 # Record length
280 .short 6 # Record kind: S_END
281 .short 2 # Record length
282 .short 6 # Record kind: S_END
283 .short 2 # Record length
284 .short 6 # Record kind: S_END
285 .short 2 # Record length
286 .short 4431 # Record kind: S_PROC_ID_END
289 .cv_linetable 1, main, .Lfunc_end1
290 .section .debug$S,"dr"
291 .cv_filechecksums # File index to string table offset subsection
292 .cv_stringtable # String table
296 .section .debug$T,"dr"
298 .long 4 # Debug section magic
300 .short 0xa # Record length
301 .short 0x1001 # Record kind: LF_MODIFIER
302 .long 0x70 # ModifiedType: char
303 .short 0x1 # Modifiers ( Const (0x1) )
307 .short 0xa # Record length
308 .short 0x1002 # Record kind: LF_POINTER
309 .long 0x1000 # PointeeType: const char
310 .long 0x1000c # Attrs: [ Type: Near64, Mode: Pointer, SizeOf: 8 ]
312 .short 0xa # Record length
313 .short 0x1001 # Record kind: LF_MODIFIER
314 .long 0x70 # ModifiedType: char
315 .short 0x2 # Modifiers ( Volatile (0x2) )
319 .short 0xa # Record length
320 .short 0x1002 # Record kind: LF_POINTER
321 .long 0x1002 # PointeeType: volatile char
322 .long 0x1000c # Attrs: [ Type: Near64, Mode: Pointer, SizeOf: 8 ]
324 .short 0xe # Record length
325 .short 0x1201 # Record kind: LF_ARGLIST
327 .long 0x1001 # Argument: const char*
328 .long 0x1003 # Argument: volatile char*
330 .short 0xe # Record length
331 .short 0x1008 # Record kind: LF_PROCEDURE
332 .long 0x30 # ReturnType: bool
333 .byte 0x0 # CallingConvention: NearC
334 .byte 0x0 # FunctionOptions
335 .short 0x2 # NumParameters
336 .long 0x1004 # ArgListType: (const char*, volatile char*)
338 .short 0x12 # Record length
339 .short 0x1601 # Record kind: LF_FUNC_ID
340 .long 0x0 # ParentScope
341 .long 0x1005 # FunctionType: bool (const char*, volatile char*)
347 .short 0x6 # Record length
348 .short 0x1201 # Record kind: LF_ARGLIST
351 .short 0xe # Record length
352 .short 0x1008 # Record kind: LF_PROCEDURE
353 .long 0x74 # ReturnType: int
354 .byte 0x0 # CallingConvention: NearC
355 .byte 0x0 # FunctionOptions
356 .short 0x0 # NumParameters
357 .long 0x1007 # ArgListType: ()
359 .short 0x12 # Record length
360 .short 0x1601 # Record kind: LF_FUNC_ID
361 .long 0x0 # ParentScope
362 .long 0x1008 # FunctionType: int ()
368 .short 0xa # Record length
369 .short 0x1002 # Record kind: LF_POINTER
370 .long 0x1000 # PointeeType: const char
371 .long 0x1040c # Attrs: [ Type: Near64, Mode: Pointer, SizeOf: 8, isConst ]
373 .short 0xe # Record length
374 .short 0x1503 # Record kind: LF_ARRAY
375 .long 0x100a # ElementType: const char* const
376 .long 0x23 # IndexType: unsigned __int64
381 .short 0xa # Record length
382 .short 0x1002 # Record kind: LF_POINTER
383 .long 0x100b # PointeeType
384 .long 0x1002c # Attrs: [ Type: Near64, Mode: LValueReference, SizeOf: 8 ]
386 .short 0xa # Record length
387 .short 0x1002 # Record kind: LF_POINTER
388 .long 0x100a # PointeeType: const char* const
389 .long 0x1000c # Attrs: [ Type: Near64, Mode: Pointer, SizeOf: 8 ]
391 .short 0xe # Record length
392 .short 0x1503 # Record kind: LF_ARRAY
393 .long 0x1002 # ElementType: volatile char
394 .long 0x23 # IndexType: unsigned __int64