]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/gdbinit.in
RISC-V: Add testcase for pr114734
[thirdparty/gcc.git] / gcc / gdbinit.in
1 # Copyright (C) 2001-2020 Free Software Foundation, Inc.
2 #
3 # This file is part of GCC.
4 #
5 # GCC is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3, or (at your option)
8 # any later version.
9 #
10 # GCC is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with GCC; see the file COPYING3. If not see
17 # <http://www.gnu.org/licenses/>.
18
19 define help-gcc-hooks
20 help help-gcc-hooks
21 end
22
23 document help-gcc-hooks
24 GCC gdbinit file introduces several debugging shorthands:
25
26 pr [rtx], prl [rtx], prc [rtx], pi [rtx_insn],
27 pt [tree], pct [tree], ptc [tree], trt [tree],
28 pgs [tree], pge [tree], pdn [tree], ptn [tree],
29 pgg [gimple], pgq [gimple_seq],
30 pmz [mpz_t],
31 pdd [dw_die_ref],
32 pbm [bitmap],
33 pel [location_t],
34 pp, pbs, pcfun
35
36 They are generally implemented by calling a function that prints to stderr,
37 and therefore will not work when the compiler is not executing.
38
39 Most shorthands accept an optional argument. When it is not supplied,
40 they use value in GDB register $, i.e. the last printed value.
41 end
42
43 define pp
44 eval "set $debug_arg = $%s", $argc ? "arg0" : ""
45 call debug ($debug_arg)
46 end
47
48 document pp
49 GCC hook: pp [any]
50 Print a representation of any GCC data structure for which an instance of
51 overloaded function 'debug' is available.
52 See also 'help-gcc-hooks'.
53 end
54
55 define pr
56 eval "set $debug_arg = $%s", $argc ? "arg0" : ""
57 call debug_rtx ($debug_arg)
58 end
59
60 document pr
61 GCC hook: pr [rtx]
62 Print the full structure of given rtx.
63 See also 'help-gcc-hooks'.
64 end
65
66 define prl
67 eval "set $debug_arg = $%s", $argc ? "arg0" : ""
68 call debug_rtx_list ($debug_arg, debug_rtx_count)
69 end
70
71 document prl
72 GCC hook: prl [rtx]
73 Print the full structure of all rtx insns beginning at given rtx.
74 Uses variable debug_rtx_count to control number of insns printed:
75 debug_rtx_count > 0: print from given rtx on.
76 debug_rtx_count < 0: print a window around given rtx.
77
78 There is also debug_rtx_find (rtx, uid) that will scan a list for UID and print
79 it using debug_rtx_list. Usage example: set $foo=debug_rtx_find(first, 42)
80 end
81
82 define pt
83 eval "set $debug_arg = $%s", $argc ? "arg0" : ""
84 call debug_tree ($debug_arg)
85 end
86
87 document pt
88 GCC hook: pt [tree]
89 Print the full structure of given tree.
90 See also 'help-gcc-hooks'.
91 end
92
93 define pct
94 eval "set $debug_arg = $%s", $argc ? "arg0" : ""
95 call debug_c_tree ($debug_arg)
96 end
97
98 document pct
99 GCC hook: pct [tree]
100 Print given tree in C syntax.
101 See also 'help-gcc-hooks'.
102 end
103
104 define pgg
105 eval "set $debug_arg = $%s", $argc ? "arg0" : ""
106 call debug_gimple_stmt ($debug_arg)
107 end
108
109 document pgg
110 GCC hook: pgg [gimple]
111 Print given GIMPLE statement in C syntax.
112 See also 'help-gcc-hooks'.
113 end
114
115 define pgq
116 eval "set $debug_arg = $%s", $argc ? "arg0" : ""
117 call debug_gimple_seq ($debug_arg)
118 end
119
120 document pgq
121 GCC hook: pgq [gimple_seq]
122 Print given GIMPLE sequence in C syntax.
123 See also 'help-gcc-hooks'.
124 end
125
126 define pgs
127 eval "set $debug_arg = $%s", $argc ? "arg0" : ""
128 call debug_generic_stmt ($debug_arg)
129 end
130
131 document pgs
132 GCC hook: pgs [tree]
133 Print given GENERIC statement in C syntax.
134 See also 'help-gcc-hooks'.
135 end
136
137 define pge
138 eval "set $debug_arg = $%s", $argc ? "arg0" : ""
139 call debug_generic_expr ($debug_arg)
140 end
141
142 document pge
143 GCC hook: pge [tree]
144 Print given GENERIC expression in C syntax.
145 See also 'help-gcc-hooks'.
146 end
147
148 define pmz
149 eval "set $debug_arg = $%s", $argc ? "arg0" : ""
150 call mpz_out_str(stderr, 10, $debug_arg)
151 end
152
153 document pmz
154 GCC hook: pmz [mpz_t]
155 Print given mpz value.
156 See also 'help-gcc-hooks'.
157 end
158
159 define ptc
160 eval "set $debug_arg = $%s", $argc ? "arg0" : ""
161 output (enum tree_code) $debug_arg.base.code
162 echo \n
163 end
164
165 document ptc
166 GCC hook: ptc [tree]
167 Print the tree-code of given tree node.
168 See also 'help-gcc-hooks'.
169 end
170
171 define pdn
172 eval "set $debug_arg = $%s", $argc ? "arg0" : ""
173 output $debug_arg.decl_minimal.name->identifier.id.str
174 echo \n
175 end
176
177 document pdn
178 GCC hook: pdn [tree]
179 Print the name of given decl-node.
180 See also 'help-gcc-hooks'.
181 end
182
183 define ptn
184 eval "set $debug_arg = $%s", $argc ? "arg0" : ""
185 output $debug_arg.type.name->decl_minimal.name->identifier.id.str
186 echo \n
187 end
188
189 document ptn
190 GCC hook: ptn [tree]
191 Print the name of given type-node.
192 See also 'help-gcc-hooks'.
193 end
194
195 define pdd
196 eval "set $debug_arg = $%s", $argc ? "arg0" : ""
197 call debug_dwarf_die ($debug_arg)
198 end
199
200 document pdd
201 GCC hook: pdd [dw_die_ref]
202 Print given dw_die_ref.
203 See also 'help-gcc-hooks'.
204 end
205
206 define prc
207 eval "set $debug_arg = $%s", $argc ? "arg0" : ""
208 output (enum rtx_code) $debug_arg.code
209 echo \ (
210 output $debug_arg.mode
211 echo )\n
212 end
213
214 document prc
215 GCC hook: prc [rtx]
216 Print the rtx-code and machine mode of given rtx.
217 See also 'help-gcc-hooks'.
218 end
219
220 define pi
221 eval "set $debug_arg = $%s", $argc ? "arg0" : ""
222 print $debug_arg.u.fld[0].rt_rtx@7
223 end
224
225 document pi
226 GCC hook: pi [rtx_insn]
227 Print the fields of given RTL instruction.
228 See also 'help-gcc-hooks'.
229 end
230
231 define pbs
232 call print_binding_stack ()
233 end
234
235 document pbs
236 In cc1plus, print the current binding stack, frame by frame, up to and
237 including the global binding level.
238 end
239
240 define pbm
241 eval "set $debug_arg = $%s", $argc ? "arg0" : ""
242 call bitmap_print (stderr, $debug_arg, "", "\n")
243 end
244
245 document pbm
246 GCC hook: pbm [bitmap]
247 Dump given bitmap as a comma-separated list of numbers.
248 See also 'help-gcc-hooks'.
249 end
250
251 define pel
252 eval "set $debug_arg = $%s", $argc ? "arg0" : ""
253 output expand_location ($debug_arg)
254 echo \n
255 end
256
257 document pel
258 GCC hook: pel [location_t]
259 Print given location.
260 See also 'help-gcc-hooks'.
261 end
262
263 define pcfun
264 output debug_function (cfun ? cfun->decl : current_function_decl, 0)
265 echo \n
266 end
267
268 document pcfun
269 Print current function.
270 end
271
272 define trt
273 eval "set $debug_arg = $%s", $argc ? "arg0" : ""
274 print ($debug_arg.typed.type)
275 end
276
277 document trt
278 GCC hook: trt [tree]
279 Print TREE_TYPE of given tree node.
280 See also 'help-gcc-hooks'.
281 end
282
283 define break-on-diagnostic
284 break diagnostic_show_locus
285 end
286
287 document break-on-diagnostic
288 Put a breakpoint on diagnostic_show_locus, called whenever a diagnostic
289 is emitted (as opposed to those warnings that are suppressed by
290 command-line options).
291 end
292
293 define break-on-saved-diagnostic
294 break ana::diagnostic_manager::add_diagnostic
295 end
296
297 document break-on-saved-diagnostic
298 Put a breakpoint on ana::diagnostic_manager::add_diagnostic, called within
299 the analyzer whenever a diagnostic is saved for later de-duplication and
300 possible emission.
301 end
302
303 define reload-gdbhooks
304 python import imp; imp.reload(gdbhooks)
305 end
306
307 document reload-gdbhooks
308 Load the gdbhooks.py module again in order to pick up any changes made to it.
309 end
310
311 alias rh = reload-gdbhooks
312
313 # Define some macros helpful to gdb when it is expanding macros.
314 macro define __FILE__ "gdb"
315 macro define __LINE__ 1
316 macro define __FUNCTION__ "gdb"
317 macro define __null 0
318 macro define input_line expand_location(input_location).line
319 macro define input_filename expand_location(input_location).file
320
321 # Remember previous pagination status and turn it off, so that
322 # the messages for skip commands don't require pagination.
323 python __gcc_prev_pagination=gdb.parameter("pagination")
324 set pagination off
325
326 # Gracefully handle aborts in functions used from gdb.
327 set unwindonsignal on
328
329 # Put breakpoints at exit and fancy_abort in case abort is mapped
330 # to either fprintf/exit or fancy_abort.
331 b fancy_abort
332
333 # Put a breakpoint on internal_error to help with debugging ICEs.
334 b internal_error
335
336 set complaints 0
337 # Don't let abort actually run, as it will make
338 # stdio stop working and therefore the `pr' command above as well.
339 # Put this last because gcc does not reference it any more unless
340 # USE_SYSTEM_ABORT is defined, so gdb may complain and bail out.
341 b exit
342 b abort
343
344 # Disable strict type checking. This allows developers to (for example)
345 # make inferior calls without casting absolute address to a suitable
346 # pointer type.
347 set check type off
348
349 # Skip all inline functions in tree.h.
350 # These are used in accessor macros.
351 # Note that this is added at the end because older gdb versions
352 # do not understand the 'skip' command.
353 # See https://sourceware.org/gdb/current/onlinedocs/gdb/Skipping-Over-Functions-and-Files.html
354 skip file tree.h
355
356 # Also skip inline functions in is-a.h.
357 skip file is-a.h
358
359 # And line-map.h.
360 skip file line-map.h
361
362 # And timevar.h.
363 skip file timevar.h
364
365 # Likewise, skip various inline functions in rtl.h.
366 skip rtx_expr_list::next
367 skip rtx_expr_list::element
368 skip rtx_insn_list::next
369 skip rtx_insn_list::insn
370 skip rtx_sequence::len
371 skip rtx_sequence::element
372 skip rtx_sequence::insn
373 skip INSN_UID
374 skip PREV_INSN
375 skip SET_PREV_INSN
376 skip NEXT_INSN
377 skip SET_NEXT_INSN
378 skip BLOCK_FOR_INSN
379 skip PATTERN
380 skip INSN_LOCATION
381 skip INSN_HAS_LOCATION
382 skip JUMP_LABEL_AS_INSN
383
384 # Restore pagination to the previous state.
385 python if __gcc_prev_pagination: gdb.execute("set pagination on")