static void print_watchpoint(icmWatchPointP w, int active) { printf("Watch %08lx-%08lx type=%08lx\n", icmGetWatchPointLowAddress(w), icmGetWatchPointHighAddress(w), icmGetWatchPointType(w) ); }
static icmWatchPointP find_watchpoint(Addr start, Addr end) { int i; for(i = 0; i < watchpoints_cnt; i++) if(icmGetWatchPointLowAddress(watchpoints[i]) == start && icmGetWatchPointHighAddress(watchpoints[i]) == end) return watchpoints[i]; return 0; }
// // Handle all active watchpoints // static void handleWatchpoints(void) { icmWatchPointP wp; while((wp=icmGetNextTriggeredWatchPoint())) { Uns32 id = getWatchpointId(wp); icmProcessorP processor = icmGetWatchPointTriggeredBy(wp); switch(icmGetWatchPointType(wp)) { case ICMWP_REGISTER: { // a register watchpoint was triggered icmRegInfoP reg = icmGetWatchPointRegister(wp); Uns32 *newValueP = (Uns32 *)icmGetWatchPointCurrentValue(wp); Uns32 *oldValueP = (Uns32 *)icmGetWatchPointPreviousValue(wp); // indicate old and new value of the affected register icmPrintf( " watchpoint %u (processor %s:%s) triggered 0x%08x->0x%08x\n", id, icmGetProcessorName(processor, "/"), icmGetRegInfoName(reg), *oldValueP, *newValueP ); // delete watchpoint after 100 triggerings if(regWatchPointCount++>100) { icmDeleteWatchPoint(wp); } else { icmResetWatchPoint(wp); } break; } case ICMWP_MEM_READ: case ICMWP_MEM_WRITE: case ICMWP_MEM_ACCESS: // a memory watchpoint was triggered icmPrintf( " watchpoint %u (range 0x%08x:0x%08x) triggered by processor %s\n", id, (Uns32)icmGetWatchPointLowAddress(wp), (Uns32)icmGetWatchPointHighAddress(wp), icmGetProcessorName(processor, "/") ); icmResetWatchPoint(wp); break; default: icmPrintf( " unknown watchpoint type triggered by processor %s\n", icmGetProcessorName(processor, "/") ); break; } } }