📄 wdblib.c
字号:
wdbMode = newMode; return (OK); }/******************************************************************************** wdbRunsExternal - check if the agent runs externally.** NOMANUAL*/BOOL wdbRunsExternal (void) { return ((wdbAvailModes & WDB_MODE_EXTERN) != 0); }/******************************************************************************** wdbIsNowExternal - Check if the agent is now in external mode.** NOMANUAL*/BOOL wdbIsNowExternal (void) { return (wdbMode & WDB_MODE_EXTERN); }/******************************************************************************** wdbRunsTasking - check if the agent runs as a task.** NOMANUAL*/BOOL wdbRunsTasking (void) { return ((wdbAvailModes & WDB_MODE_TASK) != 0); }/******************************************************************************** wdbIsNowTasking - Check if the agent is now in tasking mode.** NOMANUAL*/BOOL wdbIsNowTasking (void) { return (!wdbIsNowExternal()); }/******************************************************************************** wdbCmdLoop - agent command loop.** This is the command loop used by both agents.** NOMANUAL*/static void wdbCmdLoop (void) { WDB_XPORT * pXport; /* get the RPC transport handle */ if (wdbIsNowExternal()) pXport = pWdbExternXport; else pXport = pWdbTaskXport; /* check if the external agent needs to perform a callback */ if (wdbIsNowExternal() && (wdbSuspendCallbackRtn != NULL)) { (*wdbSuspendCallbackRtn)(wdbSuspendCallbackArg); wdbSuspendCallbackRtn = NULL; } /* the main command loop */ while (1) { /* try to process an RPC command (with timeout) */ if (!wdbRpcRcv (pXport, (wdbEventListIsEmpty() ? NULL : &wdbTv))) { /* on time out, see if we need to notify the host of events */ if (!wdbEventListIsEmpty()) wdbRpcNotifyHost(pXport); } if ((wdbState & WDB_STATE_EXTERN_RUNNING) && wdbOneShot && wdbEventListIsEmpty()) wdbResumeSystem(); } }/******************************************************************************** wdbCmdOnce - Process one external agent command, then return to the system.** This routine is installed as an interrupt on first packet hook to* notify the external agent.** XXX - should really change the way the hook is done. E.g., examine the* packet, and if it is for the agent use it, else let the comm layer* keep it. Right now we assume that any packet must be for the agent,* and the agent just discards packets that are not really for it.** NOMANUAL*/static void wdbCmdOnce (void) { wdbOneShot = TRUE; wdbSuspendSystemHere (NULL, 0); }/******************************************************************************** wdbSuspendSystem - suspend the run-time system.* * This routine transfers control from the runtime system to the extern agent.* The integer-unit context of the run-time sstem is passed to us (which we* save). We are also passed a callback to execute after the system has been* suspended.* This routine is called by the system breakpoint library.** INTERNAL* Do not confuse with wdbSystemSuspend() routine. This routine is not part* of the API and should not be called by the user.** NOMANUAL*/void wdbSuspendSystem ( WDB_IU_REGS * pRegs, /* runtime context to save */ void (*callBack)(), /* callback after system is stopped */ int arg /* callback argument */ ) { dll_t * pThisNode; WDB_REG_SET_OBJ * pRegSet; intLock(); wdbSuspendCallbackRtn = callBack; /* install the callback */ wdbSuspendCallbackArg = arg; /* and the callback argument */ wdbState |= WDB_STATE_EXTERN_RUNNING; /* mark extern agent running */ wdbExternEnterHook(); /* call extern enter hook */ (*pWdbExternCommIf->modeSet) /* reset communication stack */ (pWdbExternCommIf->commId, WDB_COMM_MODE_POLL); bcopy ((caddr_t)pRegs, /* save inferior context */ (caddr_t)&wdbExternSystemRegs, sizeof (WDB_IU_REGS)); for (pThisNode = dll_head (&wdbRegSetList); pThisNode != dll_end (&wdbRegSetList); pThisNode = dll_next (pThisNode)) { pRegSet = (WDB_REG_SET_OBJ *)pThisNode; (*pRegSet->save)(); }#if CPU_FAMILY==MC680X0 wdbExternAgentRegs.regSet.sr &= 0xefff; wdbExternAgentRegs.regSet.sr |= (wdbExternSystemRegs.regSet.sr & 0x1000);#endif WDB_CTX_LOAD (&wdbExternAgentRegs); /* run external agent */ /*NOTREACHED*/ }/******************************************************************************** wdbResumeSystem - resume the runtime system.** This routine transfers control from the external agent back to the runtime* system.* This routine is called by the system breakpoint library to continue or step.** NOMANUAL*/void wdbResumeSystem (void) { dll_t * pThisNode; WDB_REG_SET_OBJ * pRegSet; wdbState &= (~WDB_STATE_EXTERN_RUNNING); /* mark extern agent done */ /* * Set driver in interrupt mode only if task mode is supported by the * agent. Otherwise, it is not usefull. */ if (wdbRunsTasking ()) { (*pWdbExternCommIf->modeSet) /* reset communication stack */ (pWdbExternCommIf->commId, WDB_COMM_MODE_INT); } wdbOneShot = FALSE; /* ... */ wdbExternExitHook(); /* call extern exit hook */ /* restore inferior context */ for (pThisNode = dll_head (&wdbRegSetList); pThisNode != dll_end (&wdbRegSetList); pThisNode = dll_next (pThisNode)) { pRegSet = (WDB_REG_SET_OBJ *)pThisNode; (*pRegSet->load)(); } WDB_CTX_LOAD (&wdbExternSystemRegs); /*NOTREACHED*/ }/******************************************************************************** wdbNotifyCallback - callback to notify host of target events** NOMANUAL*/ static void wdbNotifyCallback (void) { wdbRpcNotifyHost (pWdbExternXport); wdbResumeSystem(); }/******************************************************************************** wdbNotifyHost - notify the host that an event has occured on the target.** This routine is not called directly by anyone. It is called indirectly* by wdbEventPost().** NOMANUAL*/void wdbNotifyHost (void) { /* don't notify the host if we are not connected */ if (!wdbTargetIsConnected()) return; /* if the task agent is currently active, let it do the notify */ if (wdbIsNowTasking()) { (*pWdbTaskCommIf->cancel)(pWdbTaskCommIf->commId); } /* if the external agent is running right now, do the notify now */ else if (wdbState & WDB_STATE_EXTERN_RUNNING) { wdbRpcNotifyHost(pWdbExternXport); } /* * else the external agent is active, but not currently running. * In this case, we suspend the system and have the external agent * do the notify as a callback. */ else { wdbSuspendSystemHere (wdbNotifyCallback, 0); } }/******************************************************************************** wdbSuspendSystemHere - suspend the system.** This routine transfers control from the run time system to the external* agent. This routine is just like wdbSuspendSystem, except we don't pass* it a register set to save (it uses setjmp to get the register set).** NOMANUAL*/void wdbSuspendSystemHere ( void (*callback)(), int arg ) { u_int lockKey; WDB_IU_REGS regSet; lockKey = intLock();#if CPU==SIMNT sysClkDisable();#endif if (WDB_CTX_SAVE (®Set) == 0) { _sigCtxRtnValSet (®Set, 1); wdbSuspendSystem (®Set, callback, arg); }#if CPU==SIMNT sysClkEnable();#endif intUnlock (lockKey); }/******************************************************************************** wdbSystemSuspend - suspend the system.** This routine transfers control from the run time system to the WDB * agent running in external mode. In order to give back the control to* the system it must be resumed by the the external WDB agent.** EXAMPLE** The code below, called in a vxWorks application, suspends the system :* * .CS* if (wdbSystemSuspend != OK)* printf ("External mode is not supported by the WDB agent.\n");* .CE** From a host tool, we can detect that the system is suspended.** First, attach to the target server :** .CS* wtxtcl> wtxToolAttach EP960CX* EP960CX_ps@sevre* .CE**Then, you can get the agent mode :** .CS* wtxtcl> wtxAgentModeGet* AGENT_MODE_EXTERN* .CE** To get the status of the system context, execute :** .CS* wtxtcl> wtxContextStatusGet CONTEXT_SYSTEM 0* CONTEXT_SUSPENDED* .CE** In order to resume the system, simply execute :** .CS* wtxtcl> wtxContextResume CONTEXT_SYSTEM 0* 0* .CE** You will see that the system is now running :** .CS* wtxtcl> wtxContextStatusGet CONTEXT_SYSTEM 0* CONTEXT_RUNNING* .CE** INTERNAL* This routine is only a user interface for wdbSuspendSystemHere() routine.* Its name is derived from wdbSuspendSystem but has been modified to* handle vxWorks API specifications.** RETURNS:* OK upon successful completion, ERROR if external mode is not supported* by the WDB agent.*/STATUS wdbSystemSuspend (void) { if (wdbIsNowTasking ()) /* set the agent mode if necessary */ { if (wdbModeSet (WDB_MODE_EXTERN) != OK) return (ERROR); } wdbSuspendSystemHere (NULL, 0); /* suspend the system */ return (OK); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -