xref: /llvm-project/cross-project-tests/debuginfo-tests/llgdb-tests/asan-blocks.c (revision ac0f32970d2cd0bc263c29b7af16199d350e2c0a)
1 // RUN: %clang -fblocks %target_itanium_abi_host_triple -arch x86_64 %s -o %t.out -g -fsanitize=address
2 // RUN: %test_debuginfo %s %t.out
3 // FIXME: Remove system-darwin when we build BlocksRuntime everywhere.
4 // REQUIRES: !asan, compiler-rt, system-darwin
5 //           Zorg configures the ASAN stage2 bots to not build the asan
6 //           compiler-rt. Only run this test on non-asanified configurations.
7 // XFAIL: !system-darwin && gdb-clang-incompatibility
8 
9 void b();
10 struct S {
11   int a[8];
12 };
13 
f(struct S s,unsigned i)14 int f(struct S s, unsigned i) {
15   // DEBUGGER: break 19
16   // DEBUGGER: r
17   // DEBUGGER: p s
18   // CHECK: a = ([0] = 0, [1] = 1, [2] = 2, [3] = 3, [4] = 4, [5] = 5, [6] = 6, [7] = 7)
19   return s.a[i];
20 }
21 
main(int argc,const char ** argv)22 int main(int argc, const char **argv) {
23   struct S s = {{0, 1, 2, 3, 4, 5, 6, 7}};
24   if (f(s, 4) == 4) {
25     // DEBUGGER: break 29
26     // DEBUGGER: c
27     // DEBUGGER: p s
28     // CHECK: a = ([0] = 0, [1] = 1, [2] = 2, [3] = 3, [4] = 4, [5] = 5, [6] = 6, [7] = 7)
29     b();
30   }
31   return 0;
32 }
33 
c()34 void c() {}
35 
b()36 void b() {
37   // DEBUGGER: break 42
38   // DEBUGGER: c
39   // DEBUGGER: p x
40   // CHECK: 42
41   __block int x = 42;
42   c();
43 }
44