]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/gdbinit.in
gdbinit: add a new command and fix one
[thirdparty/gcc.git] / gcc / gdbinit.in
CommitLineData
a5544970 1# Copyright (C) 2001-2019 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
b3147e59
JM
19define pp
20call debug ($)
21end
22
23document pp
24Print a representation of the GCC data structure that is $.
25Works only when an inferior is executing.
26end
27
861bb6c1
JL
28define pr
29set debug_rtx ($)
30end
31
32document pr
33Print the full structure of the rtx that is $.
34Works only when an inferior is executing.
35end
36
37define prl
38set debug_rtx_list ($, debug_rtx_count)
39end
40
41document prl
42Print the full structure of all rtx insns beginning at $.
43Works only when an inferior is executing.
44Uses variable debug_rtx_count to control number of insns printed:
45 debug_rtx_count > 0: print from $ on.
46 debug_rtx_count < 0: print a window around $.
47
48There is also debug_rtx_find (rtx, uid) that will scan a list for UID and print
49it using debug_rtx_list. Usage example: set $foo=debug_rtx_find(first, 42)
50end
51
52define pt
53set debug_tree ($)
54end
55
56document pt
57Print the full structure of the tree that is $.
58Works only when an inferior is executing.
59end
60
b9d8832d
JM
61define pct
62set debug_c_tree ($)
63end
64
65document pct
66Print the tree that is $ in C syntax.
67Works only when an inferior is executing.
68end
69
f8bf9252
SP
70define pgg
71set debug_gimple_stmt ($)
72end
73
74document pgg
75Print the Gimple statement that is $ in C syntax.
76Works only when an inferior is executing.
77end
78
6e7e763e
JM
79define pgq
80set debug_gimple_seq ($)
81end
82
83document pgq
84Print the Gimple sequence that is $ in C syntax.
85Works only when an inferior is executing.
86end
87
6de9cd9a
DN
88define pgs
89set debug_generic_stmt ($)
90end
91
92document pgs
93Print the statement that is $ in C syntax.
94Works only when an inferior is executing.
95end
96
97define pge
98set debug_generic_expr ($)
99end
100
101document pge
102Print the expression that is $ in C syntax.
103Works only when an inferior is executing.
104end
105
605be31e
MS
106define pmz
107set mpz_out_str(stderr, 10, $)
108end
109
110document pmz
111Print the mpz value that is $
112Works only when an inferior is executing.
113end
114
861bb6c1 115define ptc
7c83619c 116output (enum tree_code) $.base.code
861bb6c1
JL
117echo \n
118end
119
120document ptc
121Print the tree-code of the tree node that is $.
122end
123
124define pdn
9391bc0d 125output $.decl_minimal.name->identifier.id.str
861bb6c1
JL
126echo \n
127end
128
129document pdn
130Print the name of the decl-node that is $.
131end
132
133define ptn
9391bc0d 134output $.type.name->decl_minimal.name->identifier.id.str
861bb6c1
JL
135echo \n
136end
137
138document ptn
139Print the name of the type-node that is $.
140end
141
b042534c
JM
142define pdd
143set debug_dwarf_die ($)
144end
145
146document pdd
147Print the dw_die_ref that is in $.
148end
149
861bb6c1
JL
150define prc
151output (enum rtx_code) $.code
152echo \ (
153output $.mode
154echo )\n
155end
156
157document prc
158Print the rtx-code and machine mode of the rtx that is $.
159end
160
161define pi
e0d9dfa2 162print $.u.fld[0].rt_rtx@7
861bb6c1
JL
163end
164
165document pi
166Print the fields of an instruction that is $.
167end
168
169define pbs
170set print_binding_stack ()
171end
172
173document pbs
174In cc1plus, print the current binding stack, frame by frame, up to and
175including the global binding level.
176end
177
55a9c4b2
HPN
178define pbm
179set bitmap_print (stderr, $, "", "\n")
180end
181
182document pbm
183Dump the bitmap that is in $ as a comma-separated list of numbers.
184end
185
71e55f04
MP
186define pel
187output expand_location ($)
188echo \n
189end
190
191document pel
192Print expanded location of $.
193end
194
2e1a9cdb
MP
195define pcfun
196output debug_function (cfun ? cfun->decl : current_function_decl, 0)
197echo \n
198end
199
200document pcfun
201Print current function.
202end
203
7c83619c
ML
204define trt
205print ($.typed.type)
206end
207
208document trt
209Print TREE_TYPE of the tree node that is $
210end
211
6e72eb34
DM
212define break-on-diagnostic
213break diagnostic_show_locus
214end
215
216document break-on-diagnostic
217Put a breakpoint on diagnostic_show_locus, called whenever a diagnostic
218is emitted (as opposed to those warnings that are suppressed by
219command-line options).
220end
221
0823efed
DN
222# Define some macros helpful to gdb when it is expanding macros.
223macro define __FILE__ "gdb"
224macro define __LINE__ 1
b57ca59b 225macro define __FUNCTION__ "gdb"
0bfdb81e 226macro define __null 0
2a0da5ad
JM
227macro define input_line expand_location(input_location).line
228macro define input_filename expand_location(input_location).file
0823efed 229
35a5722c
JJ
230# Remember previous pagination status and turn it off, so that
231# the messages for skip commands don't require pagination.
232python __gcc_prev_pagination=gdb.parameter("pagination")
233set pagination off
234
0823efed
DN
235# Gracefully handle aborts in functions used from gdb.
236set unwindonsignal on
237
22c4957e
MM
238# Put breakpoints at exit and fancy_abort in case abort is mapped
239# to either fprintf/exit or fancy_abort.
22c4957e
MM
240b fancy_abort
241
c9092111
BE
242# Put a breakpoint on internal_error to help with debugging ICEs.
243b internal_error
244
3a7f50dc 245set complaints 0
b14a4f5a
AS
246# Don't let abort actually run, as it will make
247# stdio stop working and therefore the `pr' command above as well.
248# Put this last because gcc does not reference it any more unless
249# USE_SYSTEM_ABORT is defined, so gdb may complain and bail out.
3aed1981 250b exit
b14a4f5a 251b abort
0823efed 252
2a936959
JL
253# Disable strict type checking. This allows developers to (for example)
254# make inferior calls without casting absolute address to a suitable
255# pointer type.
256set check type off
257
0823efed
DN
258# Skip all inline functions in tree.h.
259# These are used in accessor macros.
260# Note that this is added at the end because older gdb versions
261# do not understand the 'skip' command.
08216dfb 262# See https://sourceware.org/gdb/current/onlinedocs/gdb/Skipping-Over-Functions-and-Files.html
865ea646 263skip file tree.h
08216dfb 264
e6e860a2
JM
265# Also skip inline functions in is-a.h.
266skip file is-a.h
267
0d1892d2
JM
268# And line-map.h.
269skip file line-map.h
270
e1d74c91
JM
271# And timevar.h.
272skip file timevar.h
273
08216dfb
DM
274# Likewise, skip various inline functions in rtl.h.
275skip rtx_expr_list::next
276skip rtx_expr_list::element
277skip rtx_insn_list::next
278skip rtx_insn_list::insn
279skip rtx_sequence::len
280skip rtx_sequence::element
281skip rtx_sequence::insn
282skip INSN_UID
283skip PREV_INSN
284skip SET_PREV_INSN
285skip NEXT_INSN
286skip SET_NEXT_INSN
287skip BLOCK_FOR_INSN
288skip PATTERN
289skip INSN_LOCATION
290skip INSN_HAS_LOCATION
291skip JUMP_LABEL_AS_INSN
35a5722c
JJ
292
293# Restore pagination to the previous state.
294python if __gcc_prev_pagination: gdb.execute("set pagination on")