xref: /llvm-project/lldb/test/Shell/SymbolFile/DWARF/DW_OP_piece-O3.c (revision 4be09f06242be9349f05016fb50d3dbb378600bf)
1 // Check that optimized with -O3 values that have a file address can be read
2 // DWARF info:
3 // 0x00000023:   DW_TAG_variable
4 //                 DW_AT_name      ("array")
5 //                 DW_AT_type      (0x00000032 "char[5]")
6 //                 DW_AT_location  (DW_OP_piece 0x2, DW_OP_addrx 0x0, DW_OP_piece 0x1)
7 
8 // UNSUPPORTED: system-windows
9 // RUN: %clang_host -O3 -gdwarf %s -o %t
10 // RUN: %lldb %t \
11 // RUN:   -o "b 26" \
12 // RUN:   -o "r" \
13 // RUN:   -o "p/x array[2]" \
14 // RUN:   -b | FileCheck %s
15 //
16 // CHECK: (lldb) p/x array[2]
17 // CHECK: (char) 0x03
18 
19 static char array[5] = {0, 1, 2, 3, 4};
20 
21 void func() __attribute__((noinline));
22 void func() { ++array[2]; };
23 
24 int main(void) {
25   func();
26   return 0;
27 }
28