xref: /freebsd/tools/debugscripts/dot.gdbinit (revision 4543ef516683042d46f3bd3bb8a4f3f746e00499)
1# .gdbinit file for remote serial debugging.
2#
3# XXX Do not use this file directly.  It contains parameters which are
4# XXX substituted by the kernel Makefile when you do a 'make gdbinit'.
5# XXX This also removes lines starting with '# XXX'.
6# XXX
7# To debug kernels, do:
8#
9#  cd /usr/obj/usr/src/sys/GENERIC   (or kernel build directory)
10#  make gdbinit
11#  gdb kernel.debug
12#
13# Read gdb(4) for more details.
14
15# The following lines (down to "***** End" comment) may need to be changed
16
17# Bit rate for serial link.  Due to problems in the interface,
18# this may not work well above 9600 bps.
19set remotebaud 9600
20
21set output-radix 16
22set height 70
23set width 120
24set remotetimeout 1
25set complaints 1
26set print pretty
27dir ../../..
28
29# ***** End of things you're likely to need to change.
30
31# Connect to remote target via a serial port.
32define tr
33# Remote debugging port
34target remote $arg0
35end
36
37document tr
38Debug a remote system via serial or firewire interface.  For example, specify 'tr /dev/cuau0' to use first serial port, or 'tr localhost:5556' for default firewire port.  See also tr0, tr1 and trf commands.
39end
40
41# Convenience functions.  These call tr.
42# debug via cuau0
43define tr0
44tr /dev/cuau0
45end
46define tr1
47tr /dev/cuau1
48end
49# Firewire
50define trf
51tr localhost:5556
52end
53
54document tr0
55Debug a remote system via serial interface /dev/cuau0.  See also tr, tr1 and trf commands.
56end
57document tr1
58Debug a remote system via serial interface /dev/cuau1.  See also tr, tr0 and trf commands.
59end
60document trf
61Debug a remote system via firewire interface at default port 5556.  See also tr, tr0 and tr1 commands.
62end
63
64# Get symbols from klds.  Unfortunately, there are a number of
65# landmines involved here:
66#
67# When debugging the same machine (via /dev/mem), we can get the
68# script to call kldstat and pass the info on to asf(8).  This won't
69# work for crashes or remote debugging, of course, because we'd get
70# the information for the wrong system.  Instead, we use the macro
71# "kldstat", which extracts the information from the "dump".  The
72# trouble here is that it's a pain to use, since gdb doesn't have the
73# capability to pass data to scripts, so we have to mark it and paste
74# it into the script.  This makes it silly to use this method for
75# debugging the local system.  Instead, we have two scripts:
76#
77# getsyms uses the information in the "dump", and you have to paste it.
78# kldsyms uses the local kld information.
79#
80# Improvements in gdb should make this go away some day.
81#
82define kldsyms
83# This will be replaced by the path of the real modules directory.
84shell asf -f -k MODPATH
85source .asf
86end
87document kldsyms
88Read in the symbol tables for the debugging machine.  This only makes sense when debugging /dev/mem; use the 'getsyms' macro for remote debugging.
89end
90
91# Remote system
92define getsyms
93kldstat
94echo Select the list above with the mouse, paste into the screen\n
95echo and then press ^D.  Yes, this is annoying.\n
96# This will be replaced by the path of the real modules directory.
97shell asf -f MODPATH
98source .asf
99end
100
101document getsyms
102Display kldstat information for the target machine and invite user to paste it back in.  This causes the symbols for the KLDs to be loaded.  When doing memory debugging, use the command kldsyms instead.
103end
104
105source gdbinit.kernel
106source gdbinit.machine
107
108echo Ready to go.  Enter 'tr' to connect to the remote target\n
109echo with /dev/cuau0, 'tr /dev/cuau1' to connect to a different port\n
110echo or 'trf portno' to connect to the remote target with the firewire\n
111echo interface.  portno defaults to 5556.\n
112echo \n
113echo Type 'getsyms' after connection to load kld symbols.\n
114echo \n
115echo If you're debugging a local system, you can use 'kldsyms' instead\n
116echo to load the kld symbols.  That's a less obnoxious interface.\n
117