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