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