]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Add %EBP/%RBP to the set of registers for which redundant-PUT
authorJulian Seward <jseward@acm.org>
Wed, 16 Mar 2005 11:52:25 +0000 (11:52 +0000)
committerJulian Seward <jseward@acm.org>
Wed, 16 Mar 2005 11:52:25 +0000 (11:52 +0000)
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

VEX/priv/guest-amd64/ghelpers.c
VEX/priv/guest-x86/ghelpers.c

index 3008fff3fcad1785710473cdedaadc0f85aa93c3..3066daedba4201d276fa4843ff759bf3410e0b78 100644 (file)
@@ -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 {
index 2b4e5d11f4abb0281d57ef9c5a94e5505fa4facb..8ba555c2701a20cfeb0136cdf3bc188c356c3c2f 100644 (file)
@@ -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 {