Date: Wed, 6 Dec 2000 19:42:09 -0500 From: Brian Dean <bsd@bsdhome.com> To: Zhiui Zhang <zzhang@cs.binghamton.edu> Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: ptrace(PT_GETDBREGS) message in remote debugging Message-ID: <20001206194209.B94389@vger.bsdhome.com> In-Reply-To: <Pine.SOL.4.21.0012061249540.14735-100000@jade>; from zzhang@cs.binghamton.edu on Wed, Dec 06, 2000 at 01:04:36PM -0500 References: <Pine.SOL.4.21.0012061249540.14735-100000@jade>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Dec 06, 2000 at 01:04:36PM -0500, Zhiui Zhang wrote: > I tried remote debugging on FreeBSD 4.2 this morning. Everything was > fine, except that I saw the following messages: > > (gdb) step > ptrace(PT_GETDBREGS) failed: No such process > ptrace(PT_GETDBREGS) failed: No such process > ptrace(PT_GETDBREGS) failed: No such process > 201 cred = p ? p->p_ucred : NOCRED; > > This ptrace stuff never appear before. Is this a new feature or was I > doing something wrong? > > Any help is appreciated. You're not doing anything wrong, and this is a new feature. The problem is that gdb is trying to load the debug registers for its target process, except that it doesn't realize that it's a remote target. In looking through the GDB code, its not at all obvious to me how to determine this fact, except maybe by checking inferior_pid against MAGIC_NULL_PID, but that is defined local to remote.c only. The following patch below simply checks the return code from ptrace() and doesn't complain of the pid is not found, making the assumption that if the pid is not found, it must be a remote target. Whether or not this is a valid assumption or not in all cases, I'm not sure. The patch is against -STABLE, but I don't think this has diverged any from -CURRENT. Give this a try and let me know. -Brian -- Brian Dean bsd@FreeBSD.org bsd@bsdhome.com Index: freebsd-nat.c =================================================================== RCS file: /usr00/FreeBSD/mirror/ncvs/src/gnu/usr.bin/binutils/gdb/i386/freebsd-nat.c,v retrieving revision 1.21.4.2 diff -u -r1.21.4.2 freebsd-nat.c --- freebsd-nat.c 2000/08/22 12:28:19 1.21.4.2 +++ freebsd-nat.c 2000/12/07 00:31:52 @@ -478,14 +478,16 @@ { struct dbreg dbr; extern int inferior_pid; - + if (inferior_pid != 0 && core_bfd == NULL) { int pid = inferior_pid & ((1 << 17) - 1); /* XXX extract pid from tid */ - + if (ptrace(PT_GETDBREGS, pid, (caddr_t)&dbr, 0) == -1) { - perror("ptrace(PT_GETDBREGS) failed"); + /* don't complain on ESRCH, assume we are debugging a remote target */ + if (errno != ESRCH) + perror("ptrace(PT_GETDBREGS) failed"); return 0; } #if WATCHPOINT_DEBUG > 1 @@ -520,7 +522,10 @@ if (ptrace(PT_GETDBREGS, pid, (caddr_t)&dbr, 0) == -1) { - perror("ptrace(PT_GETDBREGS) failed"); + /* don't complain on ESRCH, assume we are debugging a remote target */ + if (errno != ESRCH) + perror("ptrace(PT_GETDBREGS) failed"); + return 0; } @@ -615,7 +620,9 @@ if (ptrace(PT_GETDBREGS, pid, (caddr_t)&dbr, 0) == -1) { - perror("ptrace(PT_GETDBREGS) failed"); + /* don't complain on ESRCH, assume we are debugging a remote target */ + if (errno != ESRCH) + perror("ptrace(PT_GETDBREGS) failed"); return 0; } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20001206194209.B94389>