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;
}
+ (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");
}
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);
*(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);
}
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*);
/* 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... */
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");
}