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