From: Julian Seward Date: Wed, 16 Mar 2005 11:52:25 +0000 (+0000) Subject: Add %EBP/%RBP to the set of registers for which redundant-PUT X-Git-Tag: svn/VALGRIND_3_0_1^2~292 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f7a3fb1d877afcc8bdac9f070de9f4fee43e71ad;p=thirdparty%2Fvalgrind.git Add %EBP/%RBP to the set of registers for which redundant-PUT elimination is not done. This is needed so that Valgrind can construct correct stack traces on x86/amd64. Curiously enough old UCode valgrind didn't do this correctly, but because it doesn't optimise as aggressively as Vex, we didn't notice this. Overall result is that Vex-based valgrind now produces more accurate stack traces, at least on x86, than valgrind-2.4.X will. git-svn-id: svn://svn.valgrind.org/vex/trunk@1042 --- diff --git a/VEX/priv/guest-amd64/ghelpers.c b/VEX/priv/guest-amd64/ghelpers.c index 3008fff3fc..3066daedba 100644 --- a/VEX/priv/guest-amd64/ghelpers.c +++ b/VEX/priv/guest-amd64/ghelpers.c @@ -1316,16 +1316,26 @@ void LibVEX_GuestAMD64_initialise ( /*OUT*/VexGuestAMD64State* vex_state ) .. maxoff requires precise memory exceptions. If in doubt return True (but this is generates significantly slower code). - We enforce precise exns for guest %RSP and %RIP only. + By default we enforce precise exns for guest %RSP, %RBP and %RIP + only. These are the minimum needed to extract correct stack + backtraces from amd64 code. */ Bool guest_amd64_state_requires_precise_mem_exns ( Int minoff, Int maxoff) { + Int rbp_min = offsetof(VexGuestAMD64State, guest_RBP); + Int rbp_max = rbp_min + 8 - 1; Int rsp_min = offsetof(VexGuestAMD64State, guest_RSP); Int rsp_max = rsp_min + 8 - 1; Int rip_min = offsetof(VexGuestAMD64State, guest_RIP); Int rip_max = rip_min + 8 - 1; + if (maxoff < rbp_min || minoff > rbp_max) { + /* no overlap with rbp */ + } else { + return True; + } + if (maxoff < rsp_min || minoff > rsp_max) { /* no overlap with rsp */ } else { diff --git a/VEX/priv/guest-x86/ghelpers.c b/VEX/priv/guest-x86/ghelpers.c index 2b4e5d11f4..8ba555c270 100644 --- a/VEX/priv/guest-x86/ghelpers.c +++ b/VEX/priv/guest-x86/ghelpers.c @@ -2329,16 +2329,26 @@ void LibVEX_GuestX86_initialise ( /*OUT*/VexGuestX86State* vex_state ) .. maxoff requires precise memory exceptions. If in doubt return True (but this is generates significantly slower code). - We enforce precise exns for guest %ESP and %EIP only. + By default we enforce precise exns for guest %ESP, %EBP and %EIP + only. These are the minimum needed to extract correct stack + backtraces from x86 code. */ Bool guest_x86_state_requires_precise_mem_exns ( Int minoff, Int maxoff) { + Int ebp_min = offsetof(VexGuestX86State, guest_EBP); + Int ebp_max = ebp_min + 4 - 1; Int esp_min = offsetof(VexGuestX86State, guest_ESP); Int esp_max = esp_min + 4 - 1; Int eip_min = offsetof(VexGuestX86State, guest_EIP); Int eip_max = eip_min + 4 - 1; + if (maxoff < ebp_min || minoff > ebp_max) { + /* no overlap with ebp */ + } else { + return True; + } + if (maxoff < esp_min || minoff > esp_max) { /* no overlap with esp */ } else {