Chapter 4. Connecting gdb

If you are using kgdboc, you need to have used kgdbwait as a boot argument, issued a sysrq-g, or the system you are going to debug has already taken an exception and is waiting for the debugger to attach before you can connect gdb.

If you are not using different kgdb I/O driver other than kgdboc, you should be able to connect and the target will automatically respond.

Example (using a serial port):

    % gdb ./vmlinux
    (gdb) set remotebaud 115200
    (gdb) target remote /dev/ttyS0
    

Example (kgdb to a terminal server):

    % gdb ./vmlinux
    (gdb) target remote udp:192.168.2.2:6443
    

Example (kgdb over ethernet):

    % gdb ./vmlinux
    (gdb) target remote udp:192.168.2.2:6443
    

Once connected, you can debug a kernel the way you would debug an application program.

If you are having problems connecting or something is going seriously wrong while debugging, it will most often be the case that you want to enable gdb to be verbose about its target communications. You do this prior to issuing the target remote command by typing in: set remote debug 1