> On 28 Jan 2018, at 04:07, bijan <[email protected]> wrote: > > Thank you (for the quick response) and sorry if I was not as clear > as I should have been! what I meant and was hoping to find was > a source code debugger support, like gdb[1], where one can debug > a running kernel with full access to the source code in a gdb session > environment from a remote machine. > > I'm new to OpenBSD and found kgdb(7)[2] manual from 6.1 describing > the process very similar to what I do daily with FreeBSD but (as I > mentioned earlier) the code seems to be removed since 6.2. > > So, is there any alternative for remote debugging a running OpenBSD > kernel using gdb? anyhow, I appreciate it if one can point me to the > right direction and I don't mind any hard work in the process :-)
i dont think we support kgdb anymore, but we do support running gdb inside a system against its running kernel. to do this, you need to have the kern.allowkmem sysctl set, which is best done via /etc/sysctl.conf. after that you'll need a kernel with debug symbols in it. the easiest way to get that is just build a kernel. there'll be a bsd.gdb next to the bsd it produces. then you can do this: dlg@v215 GENERIC.MP$ pwd /usr/obj/sys/arch/sparc64/compile/GENERIC.MP dlg@v215 GENERIC.MP$ ls bsd bsd.gdb -rwxrwx--- 1 dlg wobj 10193351 Feb 2 10:58 bsd -rwxrwx--- 1 dlg wobj 39133335 Feb 2 10:58 bsd.gdb dlg@v215 GENERIC.MP$ cat /etc/sysctl.conf kern.allowkmem=1 dlg@v215 GENERIC.MP$ sysctl kern.allowkmem kern.allowkmem=1 dlg@v215 GENERIC.MP$ sudo gdb bsd.gdb GNU gdb 6.3 Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "sparc64-unknown-openbsd6.2"... (gdb) target kvm #0 mi_switch () at /usr/src/sys/kern/sched_bsd.c:410 410 cpu_switchto(p, nextproc); (gdb) print copyright $1 = "Copyright (c) 1982, 1986, 1989, 1991, 1993\n\tThe Regents of the University of California. All rights reserved.\nCopyright (c) 1995-2017 OpenBSD. All rights reserved. https://www.OpenBSD.org\n" the important thing is the "target kvm" inside gdb, which relies on allowkmem. because of the allowkmem requirement, this recommended for use on development boxes only. dlg > > [1]: > https://www.freebsd.org/doc/en/books/developers-handbook/kerneldebug-online-gdb.html > [2]: https://man.openbsd.org/OpenBSD-6.1/kgdb.7 > > > On 01/27/18 21:00, Todd C. Miller wrote: >> On Sat, 27 Jan 2018 20:46:18 +0330, bijan wrote: >> >>> does OpenBSD support on-line kernel debugging as FreeBSD does[1]? >> Yes, see the ddb(4) manual page. >> >> - todd >
