blob: b1c1e2ad6ad6e57605962f55051115f780698772 [file] [log] [blame]
Chris Lattner9214a472004-12-04 23:44:42 +00001;; RUN: echo create > %t.commands
2;; RUN: echo s >> %t.commands
3;; RUN: echo s >> %t.commands
4;; RUN: echo finish >> %t.commands
5;; RUN: echo bt >> %t.commands
6;; RUN: echo q >> %t.commands
7;; RUN: echo y >> %t.commands
Chris Lattner13eef452004-11-30 17:12:00 +00008;; RUN: llvm-as -f %s -o %t.bc
Chris Lattner9214a472004-12-04 23:44:42 +00009;; RUN: llvm-db %t.bc < %t.commands | grep 'in main at funccall.c:11:2'
Chris Lattner7eed62b2004-11-06 21:07:31 +000010
Chris Lattnerc8746d72005-11-16 07:24:31 +000011; XFAIL: alpha|ia64
Chris Lattner7eed62b2004-11-06 21:07:31 +000012
Chris Lattner019314c2004-01-06 05:37:45 +000013;; Debugger type declarations
14%lldb.compile_unit = type { uint, ushort, ushort, sbyte*, sbyte*, sbyte*, {}* }
15%lldb.global = type { uint, %lldb.compile_unit*, sbyte*, {}*, sbyte*, bool, bool }
16%lldb.local = type { uint, %lldb.global*, sbyte*, sbyte*, bool, bool }
17
18
19;; Debugger intrinsic declarations...
20declare {}* %llvm.dbg.stoppoint({}*, uint, uint, %lldb.compile_unit*)
21declare {}* %llvm.dbg.func.start(%lldb.global*)
22declare {}* %llvm.dbg.region.start({}*)
23declare {}* %llvm.dbg.region.end({}*)
24declare {}* %llvm.dbg.declare({}*, ...)
25
26;; Global object anchors
27%llvm.dbg.translation_units = linkonce global {} {}
28%llvm.dbg.globals = linkonce global {} {}
29
30
31%.str_1 = internal constant [11 x sbyte] c"funccall.c\00"
32%.str_2 = internal constant [12 x sbyte] c"/home/sabre\00"
33%.str_3 = internal constant [14 x sbyte] c"llvmgcc 3.4.x\00"
34
35%d.compile_unit = internal constant %lldb.compile_unit {
36 uint 17, ;; DW_TAG_compile_unit
37 ushort 0, ;; LLVM Debug version #
38 ushort 1, ;; Language: DW_LANG_C89
39 sbyte* getelementptr ([11 x sbyte]* %.str_1, long 0, long 0), ;; Source filename
40 sbyte* getelementptr ([12 x sbyte]* %.str_2, long 0, long 0), ;; Working directory
41 sbyte* getelementptr ([14 x sbyte]* %.str_3, long 0, long 0), ;; producer
42 {}* %llvm.dbg.translation_units ;; Anchor
43}
44
45
46%.str_5 = internal global [5 x sbyte] c"main\00"
47%.str_6 = internal global [4 x sbyte] c"foo\00"
48%.str_7 = internal global [2 x sbyte] c"q\00"
49%.str_8 = internal global [2 x sbyte] c"t\00"
50
51%d.main = global %lldb.global {
52 uint 46, ;; DW_TAG_subprogram
53 %lldb.compile_unit* %d.compile_unit, ;; context pointer
54 sbyte* getelementptr ([5 x sbyte]* %.str_5, long 0, long 0), ;; name
55 {}* %llvm.dbg.globals, ;; anchor
56 sbyte* null, ;; EVENTUALLY the type
57 bool true, ;; non-static linkage?
58 bool false ;; definition, not declaration
59}
60
61%d.foo = global %lldb.global {
62 uint 46, ;; DW_TAG_subprogram
63 %lldb.compile_unit* %d.compile_unit, ;; context pointer
64 sbyte* getelementptr ([4 x sbyte]* %.str_6, long 0, long 0), ;; name
65 {}* %llvm.dbg.globals, ;; anchor
66 sbyte* null, ;; EVENTUALLY the type
67 bool true, ;; non-static linkage
68 bool false ;; definition, not declaration
69}
70
71%d.q = internal global %lldb.global {
72 uint 52, ;; DW_TAG_variable
73 %lldb.compile_unit* %d.compile_unit, ;; context pointer
74 sbyte* getelementptr ([2 x sbyte]* %.str_7, long 0, long 0), ;; name
75 {}* %llvm.dbg.globals, ;; anchor
76 sbyte* null, ;; EVENTUALLY the type
77 bool false, ;; static linkage
78 bool false ;; definition, not declaration
79}
80
81
82%d.t = internal global %lldb.local {
83 uint 52, ;; DW_TAG_variable
84 %lldb.global* %d.foo, ;; context pointer
85 sbyte* getelementptr ([2 x sbyte]* %.str_8, long 0, long 0), ;; name
86 sbyte* null, ;; EVENTUALLY the type
87 bool false, ;; local variable
88 bool false ;; definition, not declaratation
89}
90
91
92
93%q = internal global int 0
Chris Lattner94276b62004-01-05 05:32:40 +000094
95implementation ; Functions:
96
Chris Lattner94276b62004-01-05 05:32:40 +000097void %foo() {
Chris Lattner019314c2004-01-06 05:37:45 +000098entry:
99 %t = alloca int
100 %.1 = call {}* %llvm.dbg.func.start(%lldb.global* %d.foo)
101 %.2 = call {}* %llvm.dbg.stoppoint({}* %.1, uint 5, uint 2, %lldb.compile_unit* %d.compile_unit)
102
103 %.3 = call {}*({}*, ...)* %llvm.dbg.declare({}* %.2, %lldb.local* %d.t, int* %t)
104 %tmp.0 = load int* %q
Chris Lattner94276b62004-01-05 05:32:40 +0000105 store int %tmp.0, int* %t
Chris Lattner019314c2004-01-06 05:37:45 +0000106 %.4 = call {}* %llvm.dbg.stoppoint({}* %.3, uint 6, uint 2, %lldb.compile_unit* %d.compile_unit)
107 %tmp.01 = load int* %t
108 %tmp.1 = add int %tmp.01, 1
Chris Lattner94276b62004-01-05 05:32:40 +0000109 store int %tmp.1, int* %q
Chris Lattner019314c2004-01-06 05:37:45 +0000110 %.5 = call {}* %llvm.dbg.stoppoint({}* %.4, uint 7, uint 1, %lldb.compile_unit* %d.compile_unit)
111 call {}* %llvm.dbg.region.end({}* %.5)
Chris Lattner94276b62004-01-05 05:32:40 +0000112 ret void
113}
114
115int %main() {
116entry:
Chris Lattner019314c2004-01-06 05:37:45 +0000117 %.1 = call {}* %llvm.dbg.func.start(%lldb.global* %d.main)
118 %result = alloca int
119 %.2 = call {}* %llvm.dbg.stoppoint({}* %.1, uint 9, uint 2, %lldb.compile_unit* %d.compile_unit)
Chris Lattner94276b62004-01-05 05:32:40 +0000120 store int 0, int* %q
Chris Lattner019314c2004-01-06 05:37:45 +0000121 %.3 = call {}* %llvm.dbg.stoppoint({}* %.2, uint 10, uint 2, %lldb.compile_unit* %d.compile_unit)
122 call void %foo()
123 %.4 = call {}* %llvm.dbg.stoppoint({}* %.3, uint 11, uint 2, %lldb.compile_unit* %d.compile_unit)
124 %tmp.2 = load int* %q
125 %tmp.3 = sub int %tmp.2, 1
Chris Lattner94276b62004-01-05 05:32:40 +0000126 store int %tmp.3, int* %q
Chris Lattner019314c2004-01-06 05:37:45 +0000127 %.5 = call {}* %llvm.dbg.stoppoint({}* %.4, uint 13, uint 2, %lldb.compile_unit* %d.compile_unit)
128 %tmp.4 = load int* %q
Chris Lattner94276b62004-01-05 05:32:40 +0000129 store int %tmp.4, int* %result
Chris Lattner019314c2004-01-06 05:37:45 +0000130 %tmp.5 = load int* %result
131 %.6 = call {}* %llvm.dbg.stoppoint({}* %.5, uint 14, uint 1, %lldb.compile_unit* %d.compile_unit)
132 call {}* %llvm.dbg.region.end({}* %.6)
Chris Lattner94276b62004-01-05 05:32:40 +0000133 ret int %tmp.5
134}