⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 debugger.c

📁 Nucleus_2_kvm_Hello 是kvm移植到Nucleus系统的源代码。。。好东西啊
💻 C
📖 第 1 页 / 共 5 页
字号:
    else        return FALSE;}/*======================================================================== * Function:        setNotification() * Overview:        tells the debugger to only listen for only  *                  one type of event *                   * Interface: *  parameters:     debugger event type *  returns:        void * * Notes: *=======================================================================*/static void setNotification(long n){    debuggerNotifyList = n;}/*======================================================================== * Function:        addNotification() * Overview:        tells the debugger to listen to the event as well as *                  anything else that was set previously *                   * Interface: *  parameters:     debugger event type *  returns:        void * * Notes: *=======================================================================*/static void addNotification(long n){    debuggerNotifyList |= n;}/*======================================================================== * Function:        FreeCEModifier() * Overview:        free a modifier structure for an event *                   * Interface: *  parameters:      *  returns:        void * * Notes: *=======================================================================*/void FreeCEModifier(CEModPtr cep) {    cep->inUse = FALSE;    cep->nextEvent = NULL;}/*======================================================================== * Function:        GetCEModifier() * Overview:        get a free modifier structure for an event *                   * Interface: *  parameters:      *  returns:        void * * Notes: *=======================================================================*/CEModPtr GetCEModifier() {    CEModPtr cep = CE_ModHead;    CEModPtr lastCep;    while (cep) {        if (!cep->inUse) {            lastCep = cep->next;            memset(cep, 0, sizeof(*cep));            cep->next = lastCep;            cep->inUse = TRUE;            return (cep);        }        lastCep = cep;        cep = cep->next;    }    cep = (CEModPtr)allocAlignedBytes(sizeof(*cep));    if (CE_ModHead == NIL) {        CE_ModHead = cep;    } else {        lastCep->next = cep;    }    cep->inUse = TRUE;    return(cep);}/*======================================================================== * Function:        getModPtr() * Overview:        get a free modifier structure for an event *                   * Interface: *  parameters:      *  returns:        void * * Notes: *=======================================================================*/static EVENTMODIFIER getModPtr() {    EVENTMODIFIER newMod = modHead;    EVENTMODIFIER lastMod = NULL;    while (newMod) {        if (!newMod->inUse) {            lastMod = newMod->freeNext;            memset(newMod, 0, sizeof(*newMod));            newMod->freeNext = lastMod;            newMod->inUse = TRUE;            return (newMod);        }        lastMod = newMod;        newMod = newMod->freeNext;    }    newMod = (EVENTMODIFIER)allocAlignedBytes(sizeof(*newMod));    if (modHead == NIL) {            modHead = newMod;    } else {        lastMod->freeNext = newMod;    }    newMod->inUse = TRUE;    return(newMod);}/*======================================================================== * Function:        createVmEvent() * Overview:        creates an event structure but doesn't put it in *                  the list of events *                   * Interface: *  parameters:      *  returns:        void * * Notes: *=======================================================================*/static VMEventPtr createVmEvent(){    VMEventPtr  ep = eventHead;    VMEventPtr lastEp = NULL;    /* first try to find an event to be reaped */    while (ep != NULL) {        if (!ep->inUse) {            lastEp = ep->next;            memset(ep, 0, sizeof(*ep));            ep->next = lastEp;            ep->active = TRUE;            ep->mods = NIL;            ep->numModifiers = 0;            ep->inUse = TRUE;            return (ep);        }        lastEp = ep;        ep = ep->next;    }    ep = (VMEventPtr)callocPermanentObject(SIZEOF_VMEVENT);    ep->active = TRUE;    ep->mods = NIL;    ep->numModifiers = 0;    ep->inUse = TRUE;    if (eventHead == NIL) {            eventHead = ep;    } else {        lastEp->next = ep;    }    return ep;}/*======================================================================== * Function:        installBreakpoint() * Overview:        set a breakpoint in the given method * Interface: *   parameters:    pointer to event modifier *   returns:       TRUE if installed, FALSE otherwise * *=======================================================================*/static bool_t installBreakpoint(EVENTMODIFIER *mods){    unsigned char bk = BREAKPOINT;    unsigned long classID = (*mods)->u.loc.classID;    INSTANCE_CLASS clazz = (INSTANCE_CLASS)GET_DEBUGGERID_CLASS(classID);    METHOD thisMethod = &clazz->methodTable->methods[(*mods)->u.loc.methodIndex - _method_index_base];    unsigned int offset = (*mods)->u.loc.offset;    ByteCode opcode;    char *start;#if INCLUDEDEBUGCODE    /* Determine if this is a legal offset      * into the bytecode for this method      */    if (!isLegalOffset(thisMethod, offset))        return FALSE;#endif    if (thisMethod->u.java.code[offset] == BREAKPOINT) {        if (findBreakEventAndOpcode(&opcode, NIL, classID,             (*mods)->u.loc.methodIndex, offset) == NIL) {             return FALSE;        }    } else {         opcode = thisMethod->u.java.code[offset];    }    start = (char *)((INSTANCE_CLASS)GET_DEBUGGERID_CLASS(classID))->constPool;    setBreakpoint(thisMethod, offset, start, bk);    (*mods)->u.loc.opcode = opcode;    return TRUE;}/*======================================================================== * Function:        processBreakCommands() * Overview:        called  after we send an event to debugger * Interface: *   parameters:    none *   returns:       nothing * * Notes: *=======================================================================*/void processBreakCommands(){    resumeOK = FALSE;    /* wait for some command to come from the debugger */    for (;;) {        ProcessDebugCmds(-1);   /* wait forever */        if (resumeOK) {            resumeOK = FALSE;            return;        }    }}/*======================================================================== * Function:        suspendAllThreads() * Overview:        Suspends all threads *                   * Interface: *  parameters:     void *  returns:        void * * Notes: *=======================================================================*/static void suspendAllThreads() {     START_TEMPORARY_ROOTS        DECLARE_TEMPORARY_ROOT(THREAD, tptr, AllThreads);        for (; tptr != NIL; tptr = tptr->nextAliveThread) {            suspendSpecificThread(tptr);        }        allThreadsSuspended = TRUE;        if (waitOnSuspend) {             processBreakCommands();        }    END_TEMPORARY_ROOTS}/*======================================================================== * Function:        handleSuspendPolicy() * Overview:        determines which suspend policy this event was to *                  use and acts appropriately *                   * Interface: *  parameters:     policy, thread pointer, bool_t (unused) *  returns:        void * * Notes: *=======================================================================*/static void handleSuspendPolicy(BYTE policy, THREAD thread, bool_t forceWait){    switch(policy)    {        case JDWP_SuspendPolicy_NONE:            /* do nothing */            break;        case JDWP_SuspendPolicy_EVENT_THREAD:            suspendSpecificThread(thread);            break;        case JDWP_SuspendPolicy_ALL:            waitOnSuspend = forceWait;            suspendAllThreads();            break;    }    }/*======================================================================== * Function:        getMethodIndex() * Overview:        given a class and method address, find the index *          of that method in the methodtable * * Interface: *  parameters: Class, method *  returns:    int * * Notes: *=======================================================================*/static long getMethodIndex(METHOD thisMethod) {    return thisMethod - thisMethod->ofClass->methodTable->methods + _method_index_base;}/*======================================================================== * Function:        replaceEvnetOpcode() * Overview:        replace the opcode in the breakpoint event with the new *                      fast bytecode * Interface: *   parameters:    new fast bytecode *   returns:       nothing * *=======================================================================*/void replaceEventOpcode(ByteCode bcode){    METHOD thisMethod = fp_global->thisMethod;    INSTANCE_CLASS clazz = thisMethod->ofClass;    unsigned long classID = GET_CLASS_DEBUGGERID(clazz);    VMEventPtr ep;    unsigned long offset;    ByteCode opcode;    EVENTMODIFIER modp;    offset = ip_global - thisMethod->u.java.code;   /* where are we? */    /* find this breakpoint */    ep = findBreakEventAndOpcode(&opcode, &modp,         GET_CLASS_DEBUGGERID(&clazz->clazz),         getMethodIndex(thisMethod), offset);    if (ep == NIL) {        *ip_global = bcode;    } else {        modp->u.loc.opcode = bcode;    }    return;}static void sendEvent(CEModPtr cep) {    switch (cep->eventKind) {    case JDWP_EventKind_CLASS_PREPARE:        setEvent_ClassPrepare(cep);        break;    case JDWP_EventKind_CLASS_LOAD:        setEvent_ClassLoad(cep);        break;    case JDWP_EventKind_THREAD_START:        setEvent_ThreadStart(cep);        break;    }}void insertDebugEvent(CEModPtr cep) {    CEModPtr lastcep;    if (CurrentThread != NULL) {        if (CurrentThread->debugEvent == NULL)            CurrentThread->debugEvent = cep;        else {            lastcep = CurrentThread->debugEvent;            while (lastcep->nextEvent != NULL) {                lastcep = lastcep->nextEvent;            }            lastcep->nextEvent = cep;        }        CurrentThread->needEvent = TRUE;        signalTimeToReschedule();    } else {        sendEvent(cep);        FreeCEModifier(cep);    }}void checkDebugEvent(THREAD tptr) {    CEModPtr cep;    START_TEMPORARY_ROOTS    IS_TEMPORARY_ROOT(tptr, tptr);    tptr->needEvent = FALSE;    while ((cep = tptr->debugEvent) != NULL) {        sendEvent(cep);        tptr->debugEvent = cep->nextEvent;        FreeCEModifier(cep);    }    END_TEMPORARY_ROOTS    return;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -