1
0
Fork 0
mirror of https://github.com/tobast/libunwind-eh_elf.git synced 2024-07-01 13:31:43 +02:00

(_UPT_access_reg): When ptrace() returns an error, branch to common

"badreg" error handler.

(Logical change 1.81)
This commit is contained in:
hp.com!davidm 2003-04-21 23:14:14 +00:00
parent de5b16e4a8
commit 060850b2c7

View file

@ -58,7 +58,7 @@ _UPT_access_reg (unw_addr_space_t as, unw_regnum_t reg, unw_word_t *val,
#else #else
nat_bits = ptrace (PTRACE_PEEKUSER, pid, PT_NAT_BITS, 0); nat_bits = ptrace (PTRACE_PEEKUSER, pid, PT_NAT_BITS, 0);
if (errno) if (errno)
return -UNW_EBADREG; goto badreg;
#endif #endif
if (write) if (write)
@ -73,7 +73,7 @@ _UPT_access_reg (unw_addr_space_t as, unw_regnum_t reg, unw_word_t *val,
errno = 0; errno = 0;
ptrace (PTRACE_POKEUSER, pid, PT_NAT_BITS, nat_bits); ptrace (PTRACE_POKEUSER, pid, PT_NAT_BITS, nat_bits);
if (errno) if (errno)
return -UNW_EBADREG; goto badreg;
#endif #endif
} }
goto out; goto out;
@ -83,7 +83,7 @@ _UPT_access_reg (unw_addr_space_t as, unw_regnum_t reg, unw_word_t *val,
{ {
case UNW_IA64_GR + 0: case UNW_IA64_GR + 0:
if (write) if (write)
return -UNW_EBADREG; goto badreg;
*val = 0; *val = 0;
return 0; return 0;
@ -98,7 +98,7 @@ _UPT_access_reg (unw_addr_space_t as, unw_regnum_t reg, unw_word_t *val,
errno = 0; errno = 0;
psr = ptrace (PTRACE_PEEKUSER, pid, PT_CR_IPSR, 0); psr = ptrace (PTRACE_PEEKUSER, pid, PT_CR_IPSR, 0);
if (errno) if (errno)
return -UNW_EBADREG; goto badreg;
#endif #endif
if (write) if (write)
{ {
@ -111,7 +111,7 @@ _UPT_access_reg (unw_addr_space_t as, unw_regnum_t reg, unw_word_t *val,
ptrace (PTRACE_POKEUSER, pid, PT_CR_IIP, ip); ptrace (PTRACE_POKEUSER, pid, PT_CR_IIP, ip);
ptrace (PTRACE_POKEUSER, pid, PT_CR_IPSR, psr); ptrace (PTRACE_POKEUSER, pid, PT_CR_IPSR, psr);
if (errno) if (errno)
return -UNW_EBADREG; goto badreg;
#endif #endif
} }
else else
@ -122,7 +122,7 @@ _UPT_access_reg (unw_addr_space_t as, unw_regnum_t reg, unw_word_t *val,
errno = 0; errno = 0;
ip = ptrace (PTRACE_PEEKUSER, pid, PT_CR_IIP, 0); ip = ptrace (PTRACE_PEEKUSER, pid, PT_CR_IIP, 0);
if (errno) if (errno)
return -UNW_EBADREG; goto badreg;
#endif #endif
*val = ip + ((psr >> 41) & 0x3); *val = ip + ((psr >> 41) & 0x3);
} }
@ -146,7 +146,7 @@ _UPT_access_reg (unw_addr_space_t as, unw_regnum_t reg, unw_word_t *val,
errno = 0; errno = 0;
cfm = ptrace (PTRACE_PEEKUSER, pid, PT_CFM, 0); cfm = ptrace (PTRACE_PEEKUSER, pid, PT_CFM, 0);
if (errno) if (errno)
return -UNW_EBADREG; goto badreg;
#endif #endif
sof = (cfm & 0x7f); sof = (cfm & 0x7f);
@ -159,7 +159,7 @@ _UPT_access_reg (unw_addr_space_t as, unw_regnum_t reg, unw_word_t *val,
errno = 0; errno = 0;
ptrace (PTRACE_POKEUSER, pid, PT_AR_BSP, bsp); ptrace (PTRACE_POKEUSER, pid, PT_AR_BSP, bsp);
if (errno) if (errno)
return -UNW_EBADREG; goto badreg;
#endif #endif
} }
else else
@ -170,7 +170,7 @@ _UPT_access_reg (unw_addr_space_t as, unw_regnum_t reg, unw_word_t *val,
errno = 0; errno = 0;
bsp = ptrace (PTRACE_PEEKUSER, pid, PT_AR_BSP, 0); bsp = ptrace (PTRACE_PEEKUSER, pid, PT_AR_BSP, 0);
if (errno) if (errno)
return -UNW_EBADREG; goto badreg;
#endif #endif
*val = ia64_rse_skip_regs (bsp, -sof); *val = ia64_rse_skip_regs (bsp, -sof);
} }
@ -192,7 +192,7 @@ _UPT_access_reg (unw_addr_space_t as, unw_regnum_t reg, unw_word_t *val,
cfm = ptrace (PTRACE_PEEKUSER, pid, PT_CFM, 0); cfm = ptrace (PTRACE_PEEKUSER, pid, PT_CFM, 0);
#endif #endif
if (errno) if (errno)
return -UNW_EBADREG; goto badreg;
old_sof = (cfm & 0x7f); old_sof = (cfm & 0x7f);
new_sof = (*val & 0x7f); new_sof = (*val & 0x7f);
if (old_sof != new_sof) if (old_sof != new_sof)
@ -204,7 +204,7 @@ _UPT_access_reg (unw_addr_space_t as, unw_regnum_t reg, unw_word_t *val,
errno = 0; errno = 0;
ptrace (PTRACE_POKEUSER, pid, PT_AR_BSP, 0); ptrace (PTRACE_POKEUSER, pid, PT_AR_BSP, 0);
if (errno) if (errno)
return -UNW_EBADREG; goto badreg;
#endif #endif
} }
#ifdef HAVE_TTRACE #ifdef HAVE_TTRACE
@ -213,7 +213,7 @@ _UPT_access_reg (unw_addr_space_t as, unw_regnum_t reg, unw_word_t *val,
errno = 0; errno = 0;
ptrace (PTRACE_POKEUSER, pid, PT_CFM, *val); ptrace (PTRACE_POKEUSER, pid, PT_CFM, *val);
if (errno) if (errno)
return -UNW_EBADREG; goto badreg;
#endif #endif
goto out; goto out;
} }
@ -222,7 +222,7 @@ _UPT_access_reg (unw_addr_space_t as, unw_regnum_t reg, unw_word_t *val,
#endif #endif
if ((unsigned) reg >= sizeof (_UPT_reg_offset) / sizeof (_UPT_reg_offset[0])) if ((unsigned) reg >= sizeof (_UPT_reg_offset) / sizeof (_UPT_reg_offset[0]))
return -UNW_EBADREG; goto badreg;
#ifdef HAVE_TTRACE #ifdef HAVE_TTRACE
# warning No support for ttrace() yet. # warning No support for ttrace() yet.
@ -233,7 +233,7 @@ _UPT_access_reg (unw_addr_space_t as, unw_regnum_t reg, unw_word_t *val,
else else
*val = ptrace (PTRACE_PEEKUSER, pid, _UPT_reg_offset[reg], 0); *val = ptrace (PTRACE_PEEKUSER, pid, _UPT_reg_offset[reg], 0);
if (errno) if (errno)
return -UNW_EBADREG; goto badreg;
#endif #endif
out: out:
@ -242,4 +242,8 @@ _UPT_access_reg (unw_addr_space_t as, unw_regnum_t reg, unw_word_t *val,
debug (100, "%s: %s -> %lx\n", __FUNCTION__, unw_regname (reg), *val); debug (100, "%s: %s -> %lx\n", __FUNCTION__, unw_regname (reg), *val);
#endif #endif
return 0; return 0;
badreg:
debug (1, "%s: bad register number %u\n", __FUNCTION__, reg);
return -UNW_EBADREG;
} }