Re: ptrace(PT_GETDBREGS) message in remote debugging
Thanks. I tried this on FreeBSD 4.2-Release (because I do not have a stable or current), but I failed: # make Warning: Object directory not changed from original /usr/src/gnu/usr.bin/binutils/gdb cc: ../libbfd/libbfd.a: No such file or directory cc: ../libopcodes/libopcodes.a: No such file or directory cc: ../libiberty/libiberty.a: No such file or directory *** Error code 1 Stop in /usr/src/gnu/usr.bin/binutils/gdb. What should I do? -Zhihui On Wed, 6 Dec 2000, Brian Dean wrote: 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 [EMAIL PROTECTED] with "unsubscribe freebsd-hackers" in the body of the message
Re: ptrace(PT_GETDBREGS) message in remote debugging
On Thu, Dec 07, 2000 at 03:30:51PM -0500, Zhiui Zhang wrote: Thanks. I tried this on FreeBSD 4.2-Release (because I do not have a stable or current), but I failed: # make Warning: Object directory not changed from original /usr/src/gnu/usr.bin/binutils/gdb cc: ../libbfd/libbfd.a: No such file or directory cc: ../libopcodes/libopcodes.a: No such file or directory cc: ../libiberty/libiberty.a: No such file or directory *** Error code 1 Stop in /usr/src/gnu/usr.bin/binutils/gdb. What should I do? Hmmm, looks like you haven't built world on this machine. No worries, just do this: % cd /usr/src/gnu/usr.bin/binutils % (cd libbfd make) % (cd libopcodes make) % (cd libiberty make) % (cd gdb make make install) This should build the missing libs and then gdb should link correctly. -Brian -- Brian Dean [EMAIL PROTECTED] [EMAIL PROTECTED] To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-hackers" in the body of the message
Re: ptrace(PT_GETDBREGS) message in remote debugging
Your patch works for me on FreeBSD 4.2-Release. Thanks. -Zhihui On Thu, 7 Dec 2000, Brian Dean wrote: On Thu, Dec 07, 2000 at 03:30:51PM -0500, Zhiui Zhang wrote: Thanks. I tried this on FreeBSD 4.2-Release (because I do not have a stable or current), but I failed: # make Warning: Object directory not changed from original /usr/src/gnu/usr.bin/binutils/gdb cc: ../libbfd/libbfd.a: No such file or directory cc: ../libopcodes/libopcodes.a: No such file or directory cc: ../libiberty/libiberty.a: No such file or directory *** Error code 1 Stop in /usr/src/gnu/usr.bin/binutils/gdb. What should I do? Hmmm, looks like you haven't built world on this machine. No worries, just do this: % cd /usr/src/gnu/usr.bin/binutils % (cd libbfd make) % (cd libopcodes make) % (cd libiberty make) % (cd gdb make make install) This should build the missing libs and then gdb should link correctly. To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-hackers" in the body of the message
Re: ptrace(PT_GETDBREGS) message in remote debugging
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 [EMAIL PROTECTED] [EMAIL PROTECTED] 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 [EMAIL PROTECTED] with "unsubscribe freebsd-hackers" in the body of the message