]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Merge r6045 and r6053 (callgrind: fix failed assertion when toggling
authorJulian Seward <jseward@acm.org>
Tue, 12 Sep 2006 21:13:11 +0000 (21:13 +0000)
committerJulian Seward <jseward@acm.org>
Tue, 12 Sep 2006 21:13:11 +0000 (21:13 +0000)
instrumentation mode) (JosefW)

git-svn-id: svn://svn.valgrind.org/valgrind/branches/VALGRIND_3_2_BRANCH@6057

callgrind/bb.c
callgrind/context.c
callgrind/global.h
callgrind/main.c

index 6f1dd6a3a5884dbfbd703fc1c871a811f4718482..32b1dfebf878ea7abaed53395ec3997237a5c30d 100644 (file)
@@ -306,7 +306,10 @@ void CLG_(delete_bb)(Addr addr)
        CLG_DEBUG(3, "  delete_bb (Obj %s, off %p): NOT FOUND\n",
                  obj->name, offset);
 
-       /* we didn't find it.  That's strange. */
+       /* we didn't find it.
+        * this happens when callgrinds instrumentation mode
+        * was off at BB translation time, ie. no BB was created.
+        */
        return;
     }
 
@@ -334,6 +337,7 @@ void CLG_(delete_bb)(Addr addr)
            + (bb->cjmp_count+1) * sizeof(CJmpInfo);
        VG_(memset)( bb, 0xAA, size );
        CLG_FREE(bb);
+       return;
     }
     CLG_DEBUG(3, "  delete_bb: BB in use, can not free!\n");
 }
index f174888a1c7ab360bc2b7115071b3785dfa894e0..04740354fcf79e8b4fbb19c39943d4ca17fd8a4c 100644 (file)
@@ -279,6 +279,11 @@ void CLG_(push_cxt)(fn_node* fn)
   call_stack* cs = &CLG_(current_call_stack);
   Int fn_entries;
 
+  CLG_DEBUG(5, "+ push_cxt(fn '%s'): old ctx %d\n", 
+           fn ? fn->name : (Char*)"0x0",
+           CLG_(current_state).cxt ?
+           CLG_(current_state).cxt->base_number : -1);
+
   /* save old context on stack (even if not changed at all!) */
   CLG_ASSERT(cs->sp < cs->size);
   CLG_ASSERT(cs->entry[cs->sp].cxt == 0);
@@ -321,8 +326,10 @@ void CLG_(push_cxt)(fn_node* fn)
   *(CLG_(current_fn_stack).top) = fn;
   CLG_(current_state).cxt = CLG_(get_cxt)(CLG_(current_fn_stack).top);
 
-  CLG_DEBUG(5, "  push_cxt(fn '%s'): %d\n", 
-          fn ? fn->name : (Char*)"0x0",
-          CLG_(current_fn_stack).top - CLG_(current_fn_stack).bottom);
+  CLG_DEBUG(5, "- push_cxt(fn '%s'): new cxt %d, fn_sp %d\n", 
+           fn ? fn->name : (Char*)"0x0",
+           CLG_(current_state).cxt ?
+             CLG_(current_state).cxt->base_number : -1,
+           CLG_(current_fn_stack).top - CLG_(current_fn_stack).bottom);
 }
                               
index f6190a206c7785bd874221901d084078ab8ab6b3..0079b4d3a0a75c1d7fb94399f4d719cbe43cc5ad 100644 (file)
@@ -688,7 +688,8 @@ void CLG_(delete_bb)(Addr addr);
 static __inline__ Addr bb_addr(BB* bb)
  { return bb->offset + bb->obj->offset; }
 static __inline__ Addr bb_jmpaddr(BB* bb)
- { return bb->instr[bb->instr_count-1].instr_offset + bb->offset + bb->obj->offset; }
+ { UInt off = (bb->instr_count > 0) ? bb->instr[bb->instr_count-1].instr_offset : 0;
+   return off + bb->offset + bb->obj->offset; }
 
 /* from fn.c */
 void CLG_(init_fn_array)(fn_array*);
index 2a21a9c53c86aa978a4070bdd5e207d042db2e56..aa88a9df3c2347a27c11eaff649eeda05d46863e 100644 (file)
@@ -771,6 +771,10 @@ void unwind_thread(thread_info* t)
   /* unwind regular call stack */
   while(CLG_(current_call_stack).sp>0)
     CLG_(pop_call_stack)();
+
+  /* reset context and function stack for context generation */
+  CLG_(init_exec_state)( &CLG_(current_state) );
+  CLG_(current_fn_stack).top = CLG_(current_fn_stack).bottom;
 }
 
 /* Ups, this can go wrong... */
@@ -795,11 +799,8 @@ void CLG_(set_instrument_state)(Char* reason, Bool state)
   if (0)
     CLG_(forall_threads)(zero_thread_cost);
 
-  if (!state)
-    CLG_(init_exec_state)( &CLG_(current_state) );
-
   if (VG_(clo_verbosity) > 1)
-    VG_(message)(Vg_DebugMsg, "%s: instrumentation switched %s\n",
+    VG_(message)(Vg_DebugMsg, "%s: instrumentation switched %s",
                 reason, state ? "ON" : "OFF");
 }