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