From db1517609c217734dd5ef0bbc133cd2f23bb4465 Mon Sep 17 00:00:00 2001 From: "mostang.com!davidm" Date: Tue, 3 May 2005 09:13:17 +0000 Subject: [PATCH] (tdep_access_reg): Buffer writes to EH argument registers (EAX and EDX) in dwarf.eh_args[]. 2004/11/17 02:43:39-08:00 mostang.com!davidm (tdep_access_reg): Treat UNW_X86_ESP exactly like UNW_X86_CFA. (Logical change 1.290) --- src/x86/Gregs.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/src/x86/Gregs.c b/src/x86/Gregs.c index fa94cc0a..68afd376 100644 --- a/src/x86/Gregs.c +++ b/src/x86/Gregs.c @@ -136,6 +136,8 @@ tdep_access_reg (struct cursor *c, unw_regnum_t reg, unw_word_t *valp, int write) { dwarf_loc_t loc = DWARF_NULL_LOC; + unsigned int mask; + int arg_num; switch (reg) { @@ -147,25 +149,34 @@ tdep_access_reg (struct cursor *c, unw_regnum_t reg, unw_word_t *valp, break; case UNW_X86_CFA: + case UNW_X86_ESP: if (write) return -UNW_EREADONLYREG; *valp = c->dwarf.cfa; return 0; - case UNW_X86_EAX: loc = c->dwarf.loc[EAX]; break; - case UNW_X86_ECX: loc = c->dwarf.loc[ECX]; break; - case UNW_X86_EDX: loc = c->dwarf.loc[EDX]; break; - case UNW_X86_EBX: loc = c->dwarf.loc[EBX]; break; - case UNW_X86_ESP: - if (c->dwarf.cfa_is_sp) + case UNW_X86_EAX: + case UNW_X86_EDX: + arg_num = reg - UNW_X86_EAX; + mask = (1 << arg_num); + if (write) { - if (write) - return -UNW_EREADONLYREG; - *valp = c->dwarf.cfa; + c->dwarf.eh_args[arg_num] = *valp; + c->dwarf.eh_valid_mask |= mask; return 0; } - loc = c->dwarf.loc[ESP]; + else if ((c->dwarf.eh_valid_mask & mask) != 0) + { + *valp = c->dwarf.eh_args[arg_num]; + return 0; + } + else + loc = c->dwarf.loc[(reg == UNW_X86_EAX) ? EAX : EDX]; break; + + case UNW_X86_ECX: loc = c->dwarf.loc[ECX]; break; + case UNW_X86_EBX: loc = c->dwarf.loc[EBX]; break; + case UNW_X86_EBP: loc = c->dwarf.loc[EBP]; break; case UNW_X86_ESI: loc = c->dwarf.loc[ESI]; break; case UNW_X86_EDI: loc = c->dwarf.loc[EDI]; break;