Date: Sun, 23 Apr 95 18:40:06 GMT From: "gj%pcs.dec.com@inet-gw-1.pa.dec.com" <garyj@rks32.pcs.dec.com> To: hackers%freebsd.org@inet-gw-1.pa.dec.com Subject: Re: How do I set a kernel variable? Message-ID: <m0s36Zj-0005PMC@rks32.pcs.dec.com>
next in thread | raw e-mail | index | archive | help
It turns out that it _is_ possible to set a variable, but there's a trick to it. Normally, gdb opens the core-file (e.g. /dev/mem) read-only. In order to get it to open the core-file for writing, you need to do the following: root:peedub:bash:69> gdb -k /kernel <--- this... GDB is free software and you are welcome to 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. GDB 4.13 (i386-unknown-freebsd), Copyright 1994 Free Software Foundation, Inc... (kgdb) set write <--- and this... (kgdb) core-file /dev/mem <--- and this IdlePTD 19a000 current pcb at 624000 #0 0xf010dcf3 in mi_switch () (kgdb) p/x ttydebug $1 = 0x0 (kgdb) set ttydebug=1 (kgdb) p/x ttydebug $2 = 0x1 (kgdb) set ttydebug=0 (kgdb) p/x ttydebug $3 = 0x0 (kgdb) q this opens the core-file for writing. It has to be done in this order because the "set write" command sets a variable (write_files) in exec.c which is tested in kcorelow.c when the core-file is opened. If you try to just do the following: gdb -k set write exec-file /kernel you'll get an error, because gdb tries to open /kernel for writing, which (for some reason) fails miserably. Maybe we should have a "-w" flag to specify opening the core-file for writing ? Any opinions ? Could you add this tip to the kernel-debug.FAQ, J"org ? Gary J.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?m0s36Zj-0005PMC>