blob: 3774bd6813a29f5b2c83022c13d0cb8aaa8c6d42 [file] [log] [blame]
Chris Lattner7eed62b2004-11-06 21:07:31 +00001;; RUN: llvm-as -f %s -o %s.bc
2;; RUN: echo -e "create\ns\ns\nfinish\nbt\nq\ny" | llvm-db %s.bc
3
4
Chris Lattner019314c2004-01-06 05:37:45 +00005;; Debugger type declarations
6%lldb.compile_unit = type { uint, ushort, ushort, sbyte*, sbyte*, sbyte*, {}* }
7%lldb.global = type { uint, %lldb.compile_unit*, sbyte*, {}*, sbyte*, bool, bool }
8%lldb.local = type { uint, %lldb.global*, sbyte*, sbyte*, bool, bool }
9
10
11;; Debugger intrinsic declarations...
12declare {}* %llvm.dbg.stoppoint({}*, uint, uint, %lldb.compile_unit*)
13declare {}* %llvm.dbg.func.start(%lldb.global*)
14declare {}* %llvm.dbg.region.start({}*)
15declare {}* %llvm.dbg.region.end({}*)
16declare {}* %llvm.dbg.declare({}*, ...)
17
18;; Global object anchors
19%llvm.dbg.translation_units = linkonce global {} {}
20%llvm.dbg.globals = linkonce global {} {}
21
22
23%.str_1 = internal constant [11 x sbyte] c"funccall.c\00"
24%.str_2 = internal constant [12 x sbyte] c"/home/sabre\00"
25%.str_3 = internal constant [14 x sbyte] c"llvmgcc 3.4.x\00"
26
27%d.compile_unit = internal constant %lldb.compile_unit {
28 uint 17, ;; DW_TAG_compile_unit
29 ushort 0, ;; LLVM Debug version #
30 ushort 1, ;; Language: DW_LANG_C89
31 sbyte* getelementptr ([11 x sbyte]* %.str_1, long 0, long 0), ;; Source filename
32 sbyte* getelementptr ([12 x sbyte]* %.str_2, long 0, long 0), ;; Working directory
33 sbyte* getelementptr ([14 x sbyte]* %.str_3, long 0, long 0), ;; producer
34 {}* %llvm.dbg.translation_units ;; Anchor
35}
36
37
38%.str_5 = internal global [5 x sbyte] c"main\00"
39%.str_6 = internal global [4 x sbyte] c"foo\00"
40%.str_7 = internal global [2 x sbyte] c"q\00"
41%.str_8 = internal global [2 x sbyte] c"t\00"
42
43%d.main = global %lldb.global {
44 uint 46, ;; DW_TAG_subprogram
45 %lldb.compile_unit* %d.compile_unit, ;; context pointer
46 sbyte* getelementptr ([5 x sbyte]* %.str_5, long 0, long 0), ;; name
47 {}* %llvm.dbg.globals, ;; anchor
48 sbyte* null, ;; EVENTUALLY the type
49 bool true, ;; non-static linkage?
50 bool false ;; definition, not declaration
51}
52
53%d.foo = global %lldb.global {
54 uint 46, ;; DW_TAG_subprogram
55 %lldb.compile_unit* %d.compile_unit, ;; context pointer
56 sbyte* getelementptr ([4 x sbyte]* %.str_6, long 0, long 0), ;; name
57 {}* %llvm.dbg.globals, ;; anchor
58 sbyte* null, ;; EVENTUALLY the type
59 bool true, ;; non-static linkage
60 bool false ;; definition, not declaration
61}
62
63%d.q = internal global %lldb.global {
64 uint 52, ;; DW_TAG_variable
65 %lldb.compile_unit* %d.compile_unit, ;; context pointer
66 sbyte* getelementptr ([2 x sbyte]* %.str_7, long 0, long 0), ;; name
67 {}* %llvm.dbg.globals, ;; anchor
68 sbyte* null, ;; EVENTUALLY the type
69 bool false, ;; static linkage
70 bool false ;; definition, not declaration
71}
72
73
74%d.t = internal global %lldb.local {
75 uint 52, ;; DW_TAG_variable
76 %lldb.global* %d.foo, ;; context pointer
77 sbyte* getelementptr ([2 x sbyte]* %.str_8, long 0, long 0), ;; name
78 sbyte* null, ;; EVENTUALLY the type
79 bool false, ;; local variable
80 bool false ;; definition, not declaratation
81}
82
83
84
85%q = internal global int 0
Chris Lattner94276b62004-01-05 05:32:40 +000086
87implementation ; Functions:
88
Chris Lattner94276b62004-01-05 05:32:40 +000089void %foo() {
Chris Lattner019314c2004-01-06 05:37:45 +000090entry:
91 %t = alloca int
92 %.1 = call {}* %llvm.dbg.func.start(%lldb.global* %d.foo)
93 %.2 = call {}* %llvm.dbg.stoppoint({}* %.1, uint 5, uint 2, %lldb.compile_unit* %d.compile_unit)
94
95 %.3 = call {}*({}*, ...)* %llvm.dbg.declare({}* %.2, %lldb.local* %d.t, int* %t)
96 %tmp.0 = load int* %q
Chris Lattner94276b62004-01-05 05:32:40 +000097 store int %tmp.0, int* %t
Chris Lattner019314c2004-01-06 05:37:45 +000098 %.4 = call {}* %llvm.dbg.stoppoint({}* %.3, uint 6, uint 2, %lldb.compile_unit* %d.compile_unit)
99 %tmp.01 = load int* %t
100 %tmp.1 = add int %tmp.01, 1
Chris Lattner94276b62004-01-05 05:32:40 +0000101 store int %tmp.1, int* %q
Chris Lattner019314c2004-01-06 05:37:45 +0000102 %.5 = call {}* %llvm.dbg.stoppoint({}* %.4, uint 7, uint 1, %lldb.compile_unit* %d.compile_unit)
103 call {}* %llvm.dbg.region.end({}* %.5)
Chris Lattner94276b62004-01-05 05:32:40 +0000104 ret void
105}
106
107int %main() {
108entry:
Chris Lattner019314c2004-01-06 05:37:45 +0000109 %.1 = call {}* %llvm.dbg.func.start(%lldb.global* %d.main)
110 %result = alloca int
111 %.2 = call {}* %llvm.dbg.stoppoint({}* %.1, uint 9, uint 2, %lldb.compile_unit* %d.compile_unit)
Chris Lattner94276b62004-01-05 05:32:40 +0000112 store int 0, int* %q
Chris Lattner019314c2004-01-06 05:37:45 +0000113 %.3 = call {}* %llvm.dbg.stoppoint({}* %.2, uint 10, uint 2, %lldb.compile_unit* %d.compile_unit)
114 call void %foo()
115 %.4 = call {}* %llvm.dbg.stoppoint({}* %.3, uint 11, uint 2, %lldb.compile_unit* %d.compile_unit)
116 %tmp.2 = load int* %q
117 %tmp.3 = sub int %tmp.2, 1
Chris Lattner94276b62004-01-05 05:32:40 +0000118 store int %tmp.3, int* %q
Chris Lattner019314c2004-01-06 05:37:45 +0000119 %.5 = call {}* %llvm.dbg.stoppoint({}* %.4, uint 13, uint 2, %lldb.compile_unit* %d.compile_unit)
120 %tmp.4 = load int* %q
Chris Lattner94276b62004-01-05 05:32:40 +0000121 store int %tmp.4, int* %result
Chris Lattner019314c2004-01-06 05:37:45 +0000122 %tmp.5 = load int* %result
123 %.6 = call {}* %llvm.dbg.stoppoint({}* %.5, uint 14, uint 1, %lldb.compile_unit* %d.compile_unit)
124 call {}* %llvm.dbg.region.end({}* %.6)
Chris Lattner94276b62004-01-05 05:32:40 +0000125 ret int %tmp.5
126}