From 72943ad06ac8b3c42ee74ec561f49c53adf74723 Mon Sep 17 00:00:00 2001 From: Jim Kingdon Date: Wed, 21 Jul 1993 19:57:36 +0000 Subject: [PATCH] * hppa{b,h}-nat.c: Warning, not error, if can't access registers. --- gdb/ChangeLog | 2 ++ gdb/hppab-nat.c | 33 ++++++++++++++------------------ gdb/hppah-nat.c | 50 ++++++++++++++++++++----------------------------- 3 files changed, 36 insertions(+), 49 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 0cae3792d4d..e4a40737b7b 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,7 @@ Wed Jul 21 11:37:30 1993 Jim Kingdon (kingdon@deneb.cygnus.com) + * hppa{b,h}-nat.c: Warning, not error, if can't access registers. + * config/pa/hppa{b,h}.h: Define ATTACH_DETACH. Wed Jul 21 03:07:30 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de) diff --git a/gdb/hppab-nat.c b/gdb/hppab-nat.c index 615b66567ac..a77195ae721 100644 --- a/gdb/hppab-nat.c +++ b/gdb/hppab-nat.c @@ -169,7 +169,6 @@ fetch_register (regno) { register unsigned int regaddr; char buf[MAX_REGISTER_RAW_SIZE]; - char mess[128]; /* For messages */ register int i; /* Offset of registers within the u area. */ @@ -186,11 +185,17 @@ fetch_register (regno) regaddr += sizeof (int); if (errno != 0) { - sprintf (mess, "reading register %s (#%d)", reg_names[regno], regno); - perror_with_name (mess); + /* Warning, not error, in case we are attached; sometimes the + kernel doesn't let us at the registers. */ + char *err = safe_strerror (errno); + char *msg = alloca (strlen (err) + 128); + sprintf (msg, "reading register %s: %s", reg_names[regno], err); + warning (msg); + goto error_exit; } } supply_register (regno, buf); + error_exit:; } /* Fetch all registers, or just one, from the child process. */ @@ -215,7 +220,6 @@ store_inferior_registers (regno) int regno; { register unsigned int regaddr; - char buf[80]; extern char registers[]; register int i; @@ -231,8 +235,11 @@ store_inferior_registers (regno) *(int *) ®isters[REGISTER_BYTE (regno) + i]); if (errno != 0) { - sprintf (buf, "writing register number %d(%d)", regno, i); - perror_with_name (buf); + char *err = safe_strerror (errno); + char *msg = alloca (strlen (err) + 128); + sprintf (msg, "writing register %s: %s", reg_names[regno], err); + warning (msg); + errors_found = 1; } regaddr += sizeof(int); } @@ -243,19 +250,7 @@ store_inferior_registers (regno) { if (CANNOT_STORE_REGISTER (regno)) continue; - regaddr = register_addr (regno, offset); - for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof(int)) - { - errno = 0; - ptrace (PT_WUREGS, inferior_pid, (PTRACE_ARG3_TYPE) regaddr, - *(int *) ®isters[REGISTER_BYTE (regno) + i]); - if (errno != 0) - { - sprintf (buf, "writing register number %d(%d)", regno, i); - perror_with_name (buf); - } - regaddr += sizeof(int); - } + store_inferior_registers (regno); } } return; diff --git a/gdb/hppah-nat.c b/gdb/hppah-nat.c index ce9fde97712..aadaf9d2ca8 100644 --- a/gdb/hppah-nat.c +++ b/gdb/hppah-nat.c @@ -121,6 +121,8 @@ store_inferior_registers (regno) scratch, 0); if (errno != 0) { + /* Error, even if attached. Failing to write these two + registers is pretty serious. */ sprintf (buf, "writing register number %d", regno); perror_with_name (buf); } @@ -133,8 +135,14 @@ store_inferior_registers (regno) *(int *) ®isters[REGISTER_BYTE (regno) + i], 0); if (errno != 0) { - sprintf (buf, "writing register number %d(%d)", regno, i); - perror_with_name (buf); + /* Warning, not error, in case we are attached; sometimes the + kernel doesn't let us at the registers. */ + char *err = safe_strerror (errno); + char *msg = alloca (strlen (err) + 128); + sprintf (msg, "writing register %s: %s", + reg_names[regno], err); + warning (msg); + goto error_exit; } regaddr += sizeof(int); } @@ -145,34 +153,10 @@ store_inferior_registers (regno) { if (CANNOT_STORE_REGISTER (regno)) continue; - regaddr = register_addr (regno, offset); - errno = 0; - if (regno == PCOQ_HEAD_REGNUM || regno == PCOQ_TAIL_REGNUM) - { - scratch = *(int *) ®isters[REGISTER_BYTE (regno)] | 0x3; - ptrace (PT_WUREGS, inferior_pid, (PTRACE_ARG3_TYPE) regaddr, - scratch, 0); - if (errno != 0) - { - sprintf (buf, "writing register number %d", regno); - perror_with_name (buf); - } - } - else - for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof(int)) - { - errno = 0; - ptrace (PT_WUREGS, inferior_pid, (PTRACE_ARG3_TYPE) regaddr, - *(int *) ®isters[REGISTER_BYTE (regno) + i], 0); - if (errno != 0) - { - sprintf (buf, "writing register number %d(%d)", regno, i); - perror_with_name (buf); - } - regaddr += sizeof(int); - } + store_inferior_registers (regno); } } + error_exit: return; } @@ -201,13 +185,19 @@ fetch_register (regno) regaddr += sizeof (int); if (errno != 0) { - sprintf (mess, "reading register %s (#%d)", reg_names[regno], regno); - perror_with_name (mess); + /* Warning, not error, in case we are attached; sometimes the + kernel doesn't let us at the registers. */ + char *err = safe_strerror (errno); + char *msg = alloca (strlen (err) + 128); + sprintf (msg, "reading register %s: %s", reg_names[regno], err); + warning (msg); + goto error_exit; } } if (regno == PCOQ_HEAD_REGNUM || regno == PCOQ_TAIL_REGNUM) buf[3] &= ~0x3; supply_register (regno, buf); + error_exit:; } /* Resume execution of the inferior process. -- 2.30.2