From e7c80443b4fee4e0010138c3d0f11cf9e0f9293a Mon Sep 17 00:00:00 2001 From: Bruce Evans Date: Tue, 12 May 1998 16:49:13 +0000 Subject: [PATCH] Don't attempt to read process context from the kernel when (the kernel's) curproc is null. This fixes endless recursion in xfer_umem() for attempts to read from user addresses, in particular for attempts to read %fs and %gs from the pcb for `info reg'. --- gnu/usr.bin/binutils/gdb/i386/kvm-fbsd.c | 4 ++-- gnu/usr.bin/binutils/gdb/kvm-fbsd.c | 4 ++-- gnu/usr.bin/gdb/gdb/kvm-fbsd.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gnu/usr.bin/binutils/gdb/i386/kvm-fbsd.c b/gnu/usr.bin/binutils/gdb/i386/kvm-fbsd.c index 1f75dbe8a01..eca0f706a1b 100644 --- a/gnu/usr.bin/binutils/gdb/i386/kvm-fbsd.c +++ b/gnu/usr.bin/binutils/gdb/i386/kvm-fbsd.c @@ -361,7 +361,7 @@ get_kcore_registers (regno) struct user *uaddr; /* find the pcb for the current process */ - if (kvread (&cur_proc->p_addr, &uaddr)) + if (cur_proc == NULL || kvread (&cur_proc->p_addr, &uaddr)) error ("cannot read u area ptr for proc at %#x", cur_proc); if (read_pcb (core_kd, (CORE_ADDR)&uaddr->u_pcb) < 0) error ("cannot read pcb at %#x", &uaddr->u_pcb); @@ -418,7 +418,7 @@ xfer_umem (memaddr, myaddr, len, write) int n; struct proc proc; - if (kvread (cur_proc, &proc)) + if (cur_proc == NULL || kvread (cur_proc, &proc)) error ("cannot read proc at %#x", cur_proc); n = kvm_uread (core_kd, &proc, memaddr, myaddr, len) ; diff --git a/gnu/usr.bin/binutils/gdb/kvm-fbsd.c b/gnu/usr.bin/binutils/gdb/kvm-fbsd.c index 1f75dbe8a01..eca0f706a1b 100644 --- a/gnu/usr.bin/binutils/gdb/kvm-fbsd.c +++ b/gnu/usr.bin/binutils/gdb/kvm-fbsd.c @@ -361,7 +361,7 @@ get_kcore_registers (regno) struct user *uaddr; /* find the pcb for the current process */ - if (kvread (&cur_proc->p_addr, &uaddr)) + if (cur_proc == NULL || kvread (&cur_proc->p_addr, &uaddr)) error ("cannot read u area ptr for proc at %#x", cur_proc); if (read_pcb (core_kd, (CORE_ADDR)&uaddr->u_pcb) < 0) error ("cannot read pcb at %#x", &uaddr->u_pcb); @@ -418,7 +418,7 @@ xfer_umem (memaddr, myaddr, len, write) int n; struct proc proc; - if (kvread (cur_proc, &proc)) + if (cur_proc == NULL || kvread (cur_proc, &proc)) error ("cannot read proc at %#x", cur_proc); n = kvm_uread (core_kd, &proc, memaddr, myaddr, len) ; diff --git a/gnu/usr.bin/gdb/gdb/kvm-fbsd.c b/gnu/usr.bin/gdb/gdb/kvm-fbsd.c index 1f75dbe8a01..eca0f706a1b 100644 --- a/gnu/usr.bin/gdb/gdb/kvm-fbsd.c +++ b/gnu/usr.bin/gdb/gdb/kvm-fbsd.c @@ -361,7 +361,7 @@ get_kcore_registers (regno) struct user *uaddr; /* find the pcb for the current process */ - if (kvread (&cur_proc->p_addr, &uaddr)) + if (cur_proc == NULL || kvread (&cur_proc->p_addr, &uaddr)) error ("cannot read u area ptr for proc at %#x", cur_proc); if (read_pcb (core_kd, (CORE_ADDR)&uaddr->u_pcb) < 0) error ("cannot read pcb at %#x", &uaddr->u_pcb); @@ -418,7 +418,7 @@ xfer_umem (memaddr, myaddr, len, write) int n; struct proc proc; - if (kvread (cur_proc, &proc)) + if (cur_proc == NULL || kvread (cur_proc, &proc)) error ("cannot read proc at %#x", cur_proc); n = kvm_uread (core_kd, &proc, memaddr, myaddr, len) ;