1030b9a7cSGreg Lehey# $FreeBSD$ 2030b9a7cSGreg Lehey# .gdbinit file for remote serial debugging. 3030b9a7cSGreg Lehey# see gdbinit(9) for further details. 4030b9a7cSGreg Lehey# 5747ca5f5SGreg Lehey# XXX Do not use this file directly. It contains parameters which are 6747ca5f5SGreg Lehey# XXX substituted by the kernel Makefile when you do a 'make gdbinit'. 7747ca5f5SGreg Lehey# XXX This also removes lines starting with '# XXX'. 8747ca5f5SGreg Lehey# XXX 9747ca5f5SGreg Lehey# To debug kernels, do: 10747ca5f5SGreg Lehey# 11747ca5f5SGreg Lehey# cd /usr/src/sys/GENERIC (or kernel build directory) 12747ca5f5SGreg Lehey# make gdbinit 13747ca5f5SGreg Lehey# gdb -k kernel.debug 14747ca5f5SGreg Lehey# 15747ca5f5SGreg Lehey# Read gdb(4) for more details. 16747ca5f5SGreg Lehey 17747ca5f5SGreg Lehey# The following lines (down to "***** End" comment) may need to be changed 18747ca5f5SGreg Lehey 19747ca5f5SGreg Lehey# Bit rate for serial link. Due to problems in the interface, 20747ca5f5SGreg Lehey# this may not work well above 9600 bps. 21747ca5f5SGreg Leheyset remotebaud 9600 22747ca5f5SGreg Lehey 23030b9a7cSGreg Leheyset output-radix 16 24030b9a7cSGreg Leheyset height 70 25030b9a7cSGreg Leheyset width 120 26030b9a7cSGreg Leheyset remotetimeout 1 27030b9a7cSGreg Leheyset complaints 1 28030b9a7cSGreg Leheyset print pretty 29030b9a7cSGreg Leheydir ../../.. 30747ca5f5SGreg Lehey 31747ca5f5SGreg Lehey# ***** End of things you're likely to need to change. 32747ca5f5SGreg Lehey 33747ca5f5SGreg Lehey# Connect to remote target via a serial port. 34747ca5f5SGreg Leheydefine tr 35747ca5f5SGreg Lehey# Remote debugging port 36747ca5f5SGreg Leheytarget remote $arg0 37747ca5f5SGreg Leheyend 38747ca5f5SGreg Lehey 39030b9a7cSGreg Leheydocument tr 40*6949461aSDavid E. O'BrienDebug a remote system via serial or firewire interface. For example, specify 'tr /dev/cuad0' to use first serial port, or 'tr localhost:5556' for default firewire port. See also tr0, tr1 and trf commands. 41747ca5f5SGreg Leheyend 42747ca5f5SGreg Lehey 43747ca5f5SGreg Lehey# Convenience functions. These call tr. 44*6949461aSDavid E. O'Brien# debug via cuad0 45747ca5f5SGreg Leheydefine tr0 46*6949461aSDavid E. O'Brientr /dev/cuad0 47747ca5f5SGreg Leheyend 48747ca5f5SGreg Leheydefine tr1 49*6949461aSDavid E. O'Brientr /dev/cuad1 50747ca5f5SGreg Leheyend 51747ca5f5SGreg Lehey# Firewire 52747ca5f5SGreg Leheydefine trf 53747ca5f5SGreg Leheytr localhost:5556 54747ca5f5SGreg Leheyend 55747ca5f5SGreg Lehey 56747ca5f5SGreg Leheydocument tr0 57*6949461aSDavid E. O'BrienDebug a remote system via serial interface /dev/cuad0. See also tr, tr1 and trf commands. 58747ca5f5SGreg Leheyend 59747ca5f5SGreg Leheydocument tr1 60*6949461aSDavid E. O'BrienDebug a remote system via serial interface /dev/cuad1. See also tr, tr0 and trf commands. 61747ca5f5SGreg Leheyend 62747ca5f5SGreg Leheydocument trf 63747ca5f5SGreg LeheyDebug a remote system via firewire interface at default port 5556. See also tr, tr0 and tr1 commands. 64747ca5f5SGreg Leheyend 65747ca5f5SGreg Lehey 66747ca5f5SGreg Lehey# Get symbols from klds. Unfortunately, there are a number of 67747ca5f5SGreg Lehey# landmines involved here: 68747ca5f5SGreg Lehey# 69747ca5f5SGreg Lehey# When debugging the same machine (via /dev/mem), we can get the 70747ca5f5SGreg Lehey# script to call kldstat and pass the info on to asf(8). This won't 71747ca5f5SGreg Lehey# work for crashes or remote debugging, of course, because we'd get 72747ca5f5SGreg Lehey# the information for the wrong system. Instead, we use the macro 73747ca5f5SGreg Lehey# "kldstat", which extracts the information from the "dump". The 74747ca5f5SGreg Lehey# trouble here is that it's a pain to use, since gdb doesn't have the 75747ca5f5SGreg Lehey# capability to pass data to scripts, so we have to mark it and paste 76747ca5f5SGreg Lehey# it into the script. This makes it silly to use this method for 77747ca5f5SGreg Lehey# debugging the local system. Instead, we have two scripts: 78747ca5f5SGreg Lehey# 79747ca5f5SGreg Lehey# getsyms uses the information in the "dump", and you have to paste it. 80747ca5f5SGreg Lehey# kldsyms uses the local kld information. 81747ca5f5SGreg Lehey# 82747ca5f5SGreg Lehey# Improvements in gdb should make this go away some day. 83747ca5f5SGreg Lehey# 84747ca5f5SGreg Leheydefine kldsyms 85747ca5f5SGreg Lehey# This will be replaced by the path of the real modules directory. 86747ca5f5SGreg Leheyshell asf -f -k MODPATH 87747ca5f5SGreg Leheysource .asf 88747ca5f5SGreg Leheyend 89747ca5f5SGreg Leheydocument kldsyms 90747ca5f5SGreg LeheyRead in the symbol tables for the debugging machine. This only makes sense when debugging /dev/mem; use the 'getsyms' macro for remote debugging. 91747ca5f5SGreg Leheyend 92747ca5f5SGreg Lehey 93747ca5f5SGreg Lehey# Remote system 94747ca5f5SGreg Leheydefine getsyms 95747ca5f5SGreg Leheykldstat 96747ca5f5SGreg Leheyecho Select the list above with the mouse, paste into the screen\n 97747ca5f5SGreg Leheyecho and then press ^D. Yes, this is annoying.\n 98747ca5f5SGreg Lehey# This will be replaced by the path of the real modules directory. 99747ca5f5SGreg Leheyshell asf -f MODPATH 100747ca5f5SGreg Leheysource .asf 101747ca5f5SGreg Leheyend 102747ca5f5SGreg Lehey 103747ca5f5SGreg Leheydocument getsyms 104747ca5f5SGreg LeheyDisplay 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. 105030b9a7cSGreg Leheyend 106030b9a7cSGreg Lehey 107030b9a7cSGreg Leheysource gdbinit.kernel 108b38d4c01SGreg Leheysource gdbinit.machine 109030b9a7cSGreg Lehey 110747ca5f5SGreg Leheyecho Ready to go. Enter 'tr' to connect to the remote target\n 111*6949461aSDavid E. O'Brienecho with /dev/cuad0, 'tr /dev/cuad1' to connect to a different port\n 112747ca5f5SGreg Leheyecho or 'trf portno' to connect to the remote target with the firewire\n 113747ca5f5SGreg Leheyecho interface. portno defaults to 5556.\n 114747ca5f5SGreg Leheyecho \n 115747ca5f5SGreg Leheyecho Type 'getsyms' after connection to load kld symbols.\n 116747ca5f5SGreg Leheyecho \n 117747ca5f5SGreg Leheyecho If you're debugging a local system, you can use 'kldsyms' instead\n 118747ca5f5SGreg Leheyecho to load the kld symbols. That's a less obnoxious interface.\n 119