From owner-freebsd-hackers Sat Apr 5 07:09:05 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id HAA12041 for hackers-outgoing; Sat, 5 Apr 1997 07:09:05 -0800 (PST) Received: from nlsystems.com (nlsys.demon.co.uk [158.152.125.33]) by freefall.freebsd.org (8.8.5/8.8.5) with ESMTP id HAA12030 for ; Sat, 5 Apr 1997 07:08:59 -0800 (PST) Received: from herring.nlsystems.com (herring.nlsystems.com [10.0.0.2]) by nlsystems.com (8.8.5/8.8.5) with SMTP id QAA22412 for ; Sat, 5 Apr 1997 16:08:48 +0100 (BST) Date: Sat, 5 Apr 1997 16:08:48 +0100 (BST) From: Doug Rabson To: hackers@freebsd.org Subject: Debugging lkms using GDB Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk Ever been frustrated by the lack of symbols in LKMs when debugging? Just use kgdb over a serial line: On debugging machine # cd /usr/src/lkm/linux # make clean; make COPTS=-g # gdb -k /...path to kernel/kernel On test machine # ... install debug version of linux_mod.o ... # linux # modstat Type Id Off Loadaddr Size Info Rev Module Name EXEC 0 4 f5109000 001c f510f010 1 linux_mod DEV 1 30 f5114000 0154 f514804c 1 oss_mod ... attach to remote gdb ... On debugging machine (kgdb) add-symbol-file /usr/src/lkm/linux/linux_mod.o 0xf5109020 add symbol table from file "/usr/src/lkm/linux/linux_mod.o" at text_addr = 0xf5109020? (y or n) y (kgdb) ... debug the lkm with full debugging symbols! ... The important thing is to add 0x20 to the address the module was loaded at (I guess this is the size of the a.out header). -- Doug Rabson Mail: dfr@nlsystems.com Nonlinear Systems Ltd. Phone: +44 181 951 1891