Beispiel #1
0
void processWatchpoints(icmProcessorP processor)
{
    icmWatchPointP x;
    int first = 0;
    
    for(;;) {
        x = icmGetNextTriggeredWatchPoint();
        if(!x) break;
        
        if(first) {
            printf("Break by watchpoint:\n");
            first = 0;
        }
        
        print_watchpoint(x, 1);
        icmResetWatchPoint(x);
        
    }
}
//
// 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;
        }
    }
}