From: Julian Seward Date: Thu, 30 Jun 2005 12:21:04 +0000 (+0000) Subject: Fill in guest_ppc32_state_requires_precise_mem_exns() properly, so Vex X-Git-Tag: svn/VALGRIND_3_0_1^2~99 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ba166d2968e25db990608c4cf35fdb2e568397eb;p=thirdparty%2Fvalgrind.git Fill in guest_ppc32_state_requires_precise_mem_exns() properly, so Vex has a bit more of a chance of optimising the IR. git-svn-id: svn://svn.valgrind.org/vex/trunk@1235 --- diff --git a/VEX/priv/guest-ppc32/ghelpers.c b/VEX/priv/guest-ppc32/ghelpers.c index 13b777efb4..fb38a2ea2a 100644 --- a/VEX/priv/guest-ppc32/ghelpers.c +++ b/VEX/priv/guest-ppc32/ghelpers.c @@ -274,16 +274,46 @@ void LibVEX_GuestPPC32_initialise ( /*OUT*/VexGuestPPC32State* vex_state ) /* Figure out if any part of the guest state contained in minoff .. maxoff requires precise memory exceptions. If in doubt return True (but this is generates significantly slower code). + + By default we enforce precise exns for guest R1 (stack pointer), + CIA (current insn address) and LR (link register). These are the + minimum needed to extract correct stack backtraces from ppc32 + code. [[NB: not sure if keeping LR up to date is actually + necessary.]] */ Bool guest_ppc32_state_requires_precise_mem_exns ( Int minoff, - Int maxoff) + Int maxoff ) { - return True; // FIXME (also comment above) -} + Int lr_min = offsetof(VexGuestPPC32State, guest_LR); + Int lr_max = lr_min + 4 - 1; + Int r1_min = offsetof(VexGuestPPC32State, guest_GPR1); + Int r1_max = r1_min + 4 - 1; + Int cia_min = offsetof(VexGuestPPC32State, guest_CIA); + Int cia_max = cia_min + 4 - 1; + + if (maxoff < lr_min || minoff > lr_max) { + /* no overlap with LR */ + } else { + return True; + } + + if (maxoff < r1_min || minoff > r1_max) { + /* no overlap with R1 */ + } else { + return True; + } + + if (maxoff < cia_min || minoff > cia_max) { + /* no overlap with CIA */ + } else { + return True; + } + return False; +} -#define ALWAYSDEFD(field) \ +#define ALWAYSDEFD(field) \ { offsetof(VexGuestPPC32State, field), \ (sizeof ((VexGuestPPC32State*)0)->field) }