* gdbinit.in: Add macros for tree accessors.
[official-gcc.git] / gcc / gdbinit.in
blob50f8b55db48e2889ba0bfa15516a6b7995a6389e
1 define pr
2 set debug_rtx ($)
3 end
5 document pr
6 Print the full structure of the rtx that is $.
7 Works only when an inferior is executing.
8 end
10 define prl
11 set debug_rtx_list ($, debug_rtx_count)
12 end
14 document prl
15 Print the full structure of all rtx insns beginning at $.
16 Works only when an inferior is executing.
17 Uses variable debug_rtx_count to control number of insns printed:
18   debug_rtx_count > 0: print from $ on.
19   debug_rtx_count < 0: print a window around $.
21 There is also debug_rtx_find (rtx, uid) that will scan a list for UID and print
22 it using debug_rtx_list. Usage example: set $foo=debug_rtx_find(first, 42)
23 end
25 define pt
26   if $argc == 0
27     set debug_tree ($)
28   else
29     set debug_tree ($arg0)
30   end
31 end
33 document pt
34 Print the full structure of a tree.
35 The tree may be passed as an argument to pt.
36 If no argument is given, uses $.
37 Works only when an inferior is executing.
38 end
40 define pct
41 set debug_c_tree ($)
42 end
44 document pct
45 Print the tree that is $ in C syntax.
46 Works only when an inferior is executing.
47 end
49 define pgs
50 set debug_generic_stmt ($)
51 end
53 document pgs
54 Print the statement that is $ in C syntax.
55 Works only when an inferior is executing.
56 end
58 define pge
59 set debug_generic_expr ($)
60 end
62 document pge
63 Print the expression that is $ in C syntax.
64 Works only when an inferior is executing.
65 end
67 define ptc
68 output (enum tree_code) $.common.code
69 echo \n
70 end
72 document ptc
73 Print the tree-code of the tree node that is $.
74 end
76 define pdn
77 output $.decl_minimal.name->identifier.id.str
78 echo \n
79 end
81 document pdn
82 Print the name of the decl-node that is $.
83 end
85 define ptn
86 output $.type.name->decl_minimal.name->identifier.id.str
87 echo \n
88 end
90 document ptn
91 Print the name of the type-node that is $.
92 end
94 define prc
95 output (enum rtx_code) $.code
96 echo \ (
97 output $.mode
98 echo )\n
99 end
101 document prc
102 Print the rtx-code and machine mode of the rtx that is $.
105 define pi
106 print $.u.fld[0].rt_rtx@7
109 document pi
110 Print the fields of an instruction that is $.
113 define pbs
114 set print_binding_stack ()
117 document pbs
118 In cc1plus, print the current binding stack, frame by frame, up to and
119 including the global binding level.
122 define pbb
123 set dump_bb ($, stderr, 0)
126 document pbb
127 Dump the basic block that is in $, including rtx.
130 define pbm
131 set bitmap_print (stderr, $, "", "\n")
134 document pbm
135 Dump the bitmap that is in $ as a comma-separated list of numbers.
138 # Put breakpoints at exit and fancy_abort in case abort is mapped
139 # to either fprintf/exit or fancy_abort.
140 b fancy_abort
142 # Put a breakpoint on internal_error to help with debugging ICEs.
143 b internal_error
145 set complaints 0
146 # Don't let abort actually run, as it will make
147 # stdio stop working and therefore the `pr' command above as well.
148 # Put this last because gcc does not reference it any more unless
149 # USE_SYSTEM_ABORT is defined, so gdb may complain and bail out.
150 b exit
151 b abort
153 # Redefine any macro from tree.h that uses a statement expression.
154 # Last in case of failure.
155 macro define TREE_CHECK(T, CODE) (T)
156 macro define TREE_NOT_CHECK(T, CODE) (T)
157 macro define TREE_CHECK2(T, CODE1, CODE2) (T)
158 macro define TREE_NOT_CHECK2(T, CODE1, CODE2) (T)
159 macro define TREE_CHECK3(T, CODE1, CODE2, CODE3) (T)
160 macro define TREE_NOT_CHECK3(T, CODE1, CODE2, CODE3) (T)
161 macro define TREE_CHECK4(T, CODE1, CODE2, CODE3, CODE4) (T)
162 macro define NON_TREE_CHECK4(T, CODE1, CODE2, CODE3, CODE4) (T)
163 macro define TREE_CHECK5(T, CODE1, CODE2, CODE3, CODE4, CODE5) (T)
164 macro define TREE_NOT_CHECK5(T, CODE1, CODE2, CODE3, CODE4, CODE5) (T)
165 macro define CONTAINS_STRUCT_CHECK(T, STRUCT) (T)
166 macro define TREE_CLASS_CHECK(T, CLASS) (T)
167 macro define TREE_RANGE_CHECK(T, CODE1, CODE2) (T)
168 macro define OMP_CLAUSE_SUBCODE_CHECK(T, CODE) (T)
169 macro define OMP_CLAUSE_RANGE_CHECK(T, CODE1, CODE2) (T)
170 macro define EXPR_CHECK(T) (T)
171 macro define GIMPLE_STMT_CHECK(T) (T)
172 macro define NON_TYPE_CHECK(T) (T)
173 macro define TREE_VEC_ELT_CHECK(T, I) ((T)->vec.a[I])
174 macro define PHI_NODE_ELT_CHECK(T, I) ((T)->phi.a[I])
175 macro define OMP_CLAUSE_ELT_CHECK(T, I) ((T)->omp_clause.ops[I])
176 macro define TREE_OPERAND_CHECK(T, I) ((T)->exp.operands[I])
177 macro define TREE_OPERAND_CHECK_CODE(T, CODE, I) ((T)->exp.operands[I])
178 macro define GIMPLE_STMT_OPERAND_CHECK(T, I) ((T)->gstmt.operands[I])
179 macro define TREE_RTL_OPERAND_CHECK(T, CODE, I) ((T)->exp.operands[I])
180 macro define TREE_CHAIN(NODE) ((T)->common.chain)
181 macro define TREE_TYPE(NODE) ((T)->common.type)
182 # Another handy one.
183 macro define __builtin_offsetof(T, F) ((int) &(((T *) 0)->F))