Add -w parameter which tells kgdb to open kmem-based targets in read-write

mode. This allows one to use kgdb on /dev/mem and be able to patch memory
on a live system. This is identical to what -wcore used to do in previous
gdb versions for FreeBSD.

Requested by:	wpaul
This commit is contained in:
kan 2006-01-04 23:17:52 +00:00
parent 56aa38e89c
commit de096a0825

View File

@ -302,7 +302,7 @@ main(int argc, char *argv[])
struct stat st;
struct captured_main_args args;
char *s;
int a, ch, quiet;
int a, ch, quiet, writecore;
dumpnr = -1;
@ -327,8 +327,9 @@ main(int argc, char *argv[])
}
quiet = 0;
writecore = 0;
while ((ch = getopt(argc, argv, "ac:d:fn:qr:v")) != -1) {
while ((ch = getopt(argc, argv, "ac:d:fn:qr:vw")) != -1) {
switch (ch) {
case 'a':
annotation_level++;
@ -372,6 +373,9 @@ main(int argc, char *argv[])
case 'v': /* increase verbosity. */
verbose++;
break;
case 'w': /* core file is writeable. */
writecore = 1;
break;
case '?':
default:
usage();
@ -464,7 +468,8 @@ main(int argc, char *argv[])
}
if (remote == NULL) {
kvm = kvm_openfiles(kernel, vmcore, NULL, O_RDONLY, kvm_err);
kvm = kvm_openfiles(kernel, vmcore, NULL,
writecore ? O_RDWR : O_RDONLY, kvm_err);
if (kvm == NULL)
errx(1, kvm_err);
atexit(kgdb_atexit);