xref: /llvm-project/lldb/test/API/macosx/ctf/test.c (revision fd4399cb11f4069888bc7eac01f74493b5a2af48)
1*fd4399cbSJonas Devlieghere #include <stdbool.h>
2ee44310aSJonas Devlieghere #include <stdio.h>
3ee44310aSJonas Devlieghere 
49c70a3d9SJonas Devlieghere struct ForwardDecl;
59c70a3d9SJonas Devlieghere 
6ee44310aSJonas Devlieghere typedef int MyInt;
7ee44310aSJonas Devlieghere 
8ee44310aSJonas Devlieghere void populate(MyInt i);
9ee44310aSJonas Devlieghere 
10ee44310aSJonas Devlieghere typedef enum MyEnum {
11ee44310aSJonas Devlieghere   eOne = 1,
12ee44310aSJonas Devlieghere   eTwo =2,
13ee44310aSJonas Devlieghere   eThree = 3,
14ee44310aSJonas Devlieghere } MyEnumT;
15ee44310aSJonas Devlieghere 
16ee44310aSJonas Devlieghere typedef union MyUnion {
17ee44310aSJonas Devlieghere     MyInt i;
18ee44310aSJonas Devlieghere     const char* s;
19ee44310aSJonas Devlieghere } MyUnionT;
20ee44310aSJonas Devlieghere 
21ee44310aSJonas Devlieghere typedef struct MyNestedStruct {
22ee44310aSJonas Devlieghere   MyInt i;
23ee44310aSJonas Devlieghere   const char* s;
24ee44310aSJonas Devlieghere   volatile char c;
25ee44310aSJonas Devlieghere   char a[4];
26ee44310aSJonas Devlieghere   MyEnumT e;
27ee44310aSJonas Devlieghere   MyUnionT u;
28*fd4399cbSJonas Devlieghere   _Bool b;
29ee44310aSJonas Devlieghere } MyNestedStructT;
30ee44310aSJonas Devlieghere 
31ee44310aSJonas Devlieghere typedef struct MyStruct {
32ee44310aSJonas Devlieghere   MyNestedStructT n;
33ee44310aSJonas Devlieghere   void (*f)(int);
34ee44310aSJonas Devlieghere } MyStructT;
35ee44310aSJonas Devlieghere 
36b9867df6SJonas Devlieghere struct LargeStruct {
37b9867df6SJonas Devlieghere   char buffer[9000];
38b9867df6SJonas Devlieghere   int b;
39b9867df6SJonas Devlieghere };
40b9867df6SJonas Devlieghere 
4112f3d97fSJonas Devlieghere struct RecursiveStruct {
4212f3d97fSJonas Devlieghere   struct RecursiveStruct *n;
4312f3d97fSJonas Devlieghere };
4412f3d97fSJonas Devlieghere 
45ee44310aSJonas Devlieghere MyStructT foo;
469c70a3d9SJonas Devlieghere struct ForwardDecl *forward;
47b9867df6SJonas Devlieghere struct LargeStruct bar;
4812f3d97fSJonas Devlieghere struct RecursiveStruct ke;
49ee44310aSJonas Devlieghere 
populate(MyInt i)50ee44310aSJonas Devlieghere void populate(MyInt i) {
51ee44310aSJonas Devlieghere   foo.n.i = i;
52ee44310aSJonas Devlieghere   foo.n.s = "foo";
53ee44310aSJonas Devlieghere   foo.n.c = 'c';
54ee44310aSJonas Devlieghere   foo.n.a[0] = 'a';
55ee44310aSJonas Devlieghere   foo.n.a[1] = 'b';
56ee44310aSJonas Devlieghere   foo.n.a[2] = 'c';
57ee44310aSJonas Devlieghere   foo.n.a[3] = 'd';
58ee44310aSJonas Devlieghere   foo.n.e = eOne;
59*fd4399cbSJonas Devlieghere   foo.n.b = false;
60ee44310aSJonas Devlieghere   foo.f = NULL;
619c70a3d9SJonas Devlieghere   forward = NULL;
62b9867df6SJonas Devlieghere   bar.b = i;
6312f3d97fSJonas Devlieghere   ke.n = NULL;
64ee44310aSJonas Devlieghere }
65ee44310aSJonas Devlieghere 
main(int argc,char ** argv)66ee44310aSJonas Devlieghere int main(int argc, char** argv) {
67ee44310aSJonas Devlieghere   populate(argc);
68ee44310aSJonas Devlieghere   printf("foo is at address: %p\n", (void*)&foo); // Break here
69ee44310aSJonas Devlieghere   return 0;
70ee44310aSJonas Devlieghere }
71