]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Restore unwind regs structure if VG_(use_CF_info) fails on MIPS.
authorPetar Jovanovic <mips32r2@gmail.com>
Sun, 9 Sep 2012 01:56:56 +0000 (01:56 +0000)
committerPetar Jovanovic <mips32r2@gmail.com>
Sun, 9 Sep 2012 01:56:56 +0000 (01:56 +0000)
If VG_(use_CF_info) fails to find the next frame using loaded debug symbols, it
will still change the data in uregs. Thus, we need to have uregs_copy before
calling VG_(use_CF_info), and restore uregs if the call returns wrong data.
This fixes drd/tests/tc04_free_lock on MIPS.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12962

coregrind/m_stacktrace.c

index fcbb23041a2031580a0b0cc6b7a62b778fc210bf..15a360afbef297a3b4d25841b2ce1c57c895f1b0 100644 (file)
@@ -925,16 +925,19 @@ UInt VG_(get_StackTrace_wrk) ( ThreadId tid_if_known,
       if (i >= max_n_ips)
          break;
 
+      D3UnwindRegs uregs_copy = uregs;
       if (VG_(use_CF_info)( &uregs, fp_min, fp_max )) {
          if (debug)
             VG_(printf)("USING CFI: pc: 0x%lx, sp: 0x%lx, ra: 0x%lx\n",
                         uregs.pc, uregs.sp, uregs.ra);
-         if (0 == uregs.pc || 1 == uregs.pc) break;
-         if (sps) sps[i] = uregs.sp;
-         if (fps) fps[i] = uregs.fp;
-         ips[i++] = uregs.pc - 4;
-         uregs.pc = uregs.pc - 4;
-         continue;
+         if (0 != uregs.pc && 1 != uregs.pc) {
+            if (sps) sps[i] = uregs.sp;
+            if (fps) fps[i] = uregs.fp;
+            ips[i++] = uregs.pc - 4;
+            uregs.pc = uregs.pc - 4;
+            continue;
+         } else
+            uregs = uregs_copy;
       }
 
       int seen_sp_adjust = 0;