From owner-freebsd-hackers Sun Apr 23 11:45:59 1995 Return-Path: hackers-owner Received: (from majordom@localhost) by freefall.cdrom.com (8.6.10/8.6.6) id LAA04337 for hackers-outgoing; Sun, 23 Apr 1995 11:45:59 -0700 Received: from inet-gw-1.pa.dec.com (inet-gw-1.pa.dec.com [16.1.0.22]) by freefall.cdrom.com (8.6.10/8.6.6) with SMTP id LAA04330 for ; Sun, 23 Apr 1995 11:45:58 -0700 Received: from rks32.pcs.dec.com by inet-gw-1.pa.dec.com (5.65/24Feb95) id AA01489; Sun, 23 Apr 95 11:43:17 -0700 Received: by rks32.pcs.dec.com (Smail3.1.27.1 #16) id m0s36Zj-0005PMC; Sun, 23 Apr 95 20:40 MSZ Message-Id: To: hackers%freebsd.org@inet-gw-1.pa.dec.com Subject: Re: How do I set a kernel variable? Reply-To: gj@FreeBSD.org Date: Sun, 23 Apr 95 18:40:06 GMT From: "gj%pcs.dec.com@inet-gw-1.pa.dec.com" Sender: hackers-owner@FreeBSD.org Precedence: bulk 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.