gdbinit.in 5.73 KB
Newer Older
1
# Copyright (C) 2001-2017 Free Software Foundation, Inc.
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#
# This file is part of GCC.
#
# GCC is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# GCC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GCC; see the file COPYING3.  If not see
# <http://www.gnu.org/licenses/>.

Jeff Law committed
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
define pr
set debug_rtx ($)
end

document pr
Print the full structure of the rtx that is $.
Works only when an inferior is executing.
end

define prl
set debug_rtx_list ($, debug_rtx_count)
end

document prl
Print the full structure of all rtx insns beginning at $.
Works only when an inferior is executing.
Uses variable debug_rtx_count to control number of insns printed:
  debug_rtx_count > 0: print from $ on.
  debug_rtx_count < 0: print a window around $.

There is also debug_rtx_find (rtx, uid) that will scan a list for UID and print
it using debug_rtx_list. Usage example: set $foo=debug_rtx_find(first, 42)
end

define pt
set debug_tree ($)
end

document pt
Print the full structure of the tree that is $.
Works only when an inferior is executing.
end

52 53 54 55 56 57 58 59 60
define pct
set debug_c_tree ($)
end

document pct
Print the tree that is $ in C syntax.
Works only when an inferior is executing.
end

61 62 63 64 65 66 67 68 69
define pgg
set debug_gimple_stmt ($)
end

document pgg
Print the Gimple statement that is $ in C syntax.
Works only when an inferior is executing.
end

70 71 72 73 74 75 76 77 78
define pgq
set debug_gimple_seq ($)
end

document pgq
Print the Gimple sequence that is $ in C syntax.
Works only when an inferior is executing.
end

79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
define pgs
set debug_generic_stmt ($)
end

document pgs
Print the statement that is $ in C syntax.
Works only when an inferior is executing.
end

define pge
set debug_generic_expr ($)
end

document pge
Print the expression that is $ in C syntax.
Works only when an inferior is executing.
end

97 98 99 100 101 102 103 104 105
define pmz
set mpz_out_str(stderr, 10, $)
end

document pmz
Print the mpz value that is $
Works only when an inferior is executing.
end

Jeff Law committed
106 107 108 109 110 111 112 113 114 115
define ptc
output (enum tree_code) $.common.code
echo \n
end

document ptc
Print the tree-code of the tree node that is $.
end

define pdn
116
output $.decl_minimal.name->identifier.id.str
Jeff Law committed
117 118 119 120 121 122 123 124
echo \n
end

document pdn
Print the name of the decl-node that is $.
end

define ptn
125
output $.type.name->decl_minimal.name->identifier.id.str
Jeff Law committed
126 127 128 129 130 131 132
echo \n
end

document ptn
Print the name of the type-node that is $.
end

133 134 135 136 137 138 139 140
define pdd
set debug_dwarf_die ($)
end

document pdd
Print the dw_die_ref that is in $.
end

Jeff Law committed
141 142 143 144 145 146 147 148 149 150 151 152
define prc
output (enum rtx_code) $.code
echo \ (
output $.mode
echo )\n
end

document prc
Print the rtx-code and machine mode of the rtx that is $.
end

define pi
153
print $.u.fld[0].rt_rtx@7
Jeff Law committed
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
end

document pi
Print the fields of an instruction that is $.
end

define pbs
set print_binding_stack ()
end

document pbs
In cc1plus, print the current binding stack, frame by frame, up to and
including the global binding level.
end

169
define pbb
170
set debug ($)
171 172 173 174 175 176 177 178 179 180 181 182 183 184
end

document pbb
Dump the basic block that is in $, including rtx.
end

define pbm
set bitmap_print (stderr, $, "", "\n")
end

document pbm
Dump the bitmap that is in $ as a comma-separated list of numbers.
end

185 186 187 188 189 190 191 192 193
define pel
output expand_location ($)
echo \n
end

document pel
Print expanded location of $.
end

194 195 196 197 198 199 200 201 202
define pcfun
output debug_function (cfun ? cfun->decl : current_function_decl, 0)
echo \n
end

document pcfun
Print current function.
end

203 204 205 206 207 208 209 210 211 212
define break-on-diagnostic
break diagnostic_show_locus
end

document break-on-diagnostic
Put a breakpoint on diagnostic_show_locus, called whenever a diagnostic
is emitted (as opposed to those warnings that are suppressed by
command-line options).
end

213 214 215
# Define some macros helpful to gdb when it is expanding macros.
macro define __FILE__ "gdb"
macro define __LINE__ 1
216
macro define __FUNCTION__ "gdb"
Mike Stump committed
217
macro define __null 0
218 219
macro define input_line expand_location(input_location).line
macro define input_filename expand_location(input_location).file
220 221 222 223

# Gracefully handle aborts in functions used from gdb.
set unwindonsignal on

224 225 226 227
# Put breakpoints at exit and fancy_abort in case abort is mapped
# to either fprintf/exit or fancy_abort.
b fancy_abort

228 229 230
# Put a breakpoint on internal_error to help with debugging ICEs.
b internal_error

231
set complaints 0
232 233 234 235
# Don't let abort actually run, as it will make
# stdio stop working and therefore the `pr' command above as well.
# Put this last because gcc does not reference it any more unless
# USE_SYSTEM_ABORT is defined, so gdb may complain and bail out.
236
b exit
237
b abort
238

239 240 241 242 243
# Disable strict type checking.  This allows developers to (for example)
# make inferior calls without casting absolute address to a suitable
# pointer type.
set check type off

244 245 246 247
# Skip all inline functions in tree.h.
# These are used in accessor macros.
# Note that this is added at the end because older gdb versions
# do not understand the 'skip' command.
248
# See https://sourceware.org/gdb/current/onlinedocs/gdb/Skipping-Over-Functions-and-Files.html
249
skip file tree.h
250

251 252 253
# Also skip inline functions in is-a.h.
skip file is-a.h

254 255 256
# And line-map.h.
skip file line-map.h

257 258 259
# And timevar.h.
skip file timevar.h

260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277
# Likewise, skip various inline functions in rtl.h.
skip rtx_expr_list::next
skip rtx_expr_list::element
skip rtx_insn_list::next
skip rtx_insn_list::insn
skip rtx_sequence::len
skip rtx_sequence::element
skip rtx_sequence::insn
skip INSN_UID
skip PREV_INSN
skip SET_PREV_INSN
skip NEXT_INSN
skip SET_NEXT_INSN
skip BLOCK_FOR_INSN
skip PATTERN
skip INSN_LOCATION
skip INSN_HAS_LOCATION
skip JUMP_LABEL_AS_INSN