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

📄 wtx.c

📁 VXWORKS源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
** This routine returns the running mode of the target agent that the * current target server is attached to.  ** EXPAND ../../../include/wtxtypes.h WTX_AGENT_MODE_TYPE** RETURNS: The current agent running mode or WTX_ERROR.** SEE ALSO: WTX_AGENT_MODE_GET, wtxTsInfoGet(), wtxAgentModeSet()*/WTX_AGENT_MODE_TYPE wtxAgentModeGet     (    HWTX		hWtx		/* WTX API handle */    )    {    WTX_ERROR_T		callStat;	/* client status */    WTX_AGENT_MODE_TYPE	result;		/* debug agent mode */    WTX_MSG_RESULT	out;		/* WTX result */    /*     * All API calls that require a connection to the target server     * should use the WTX_CHECK_CONNECTED macro before doing anything else.     * This macro also calls WTX_CHECK_HANDLE to validate the handle.     */    WTX_CHECK_CONNECTED (hWtx, WTX_ERROR);    /* Always remember to initialize the out params */    memset (&out, 0, sizeof (out));    callStat = exchange (hWtx, WTX_AGENT_MODE_GET, &hWtx->msgToolId, &out);    /*     * If there is an error we don't need to free the result with      * wtxExchangeFree() because wtxExchange() (called by exchange())      * does this for us when there is an error.     */    if (callStat != WTX_ERR_NONE)	/*	 * On error the WTX_ERROR_RETURN macro calls wtxErrDispatch() for	 * us (which sets the error code in the API handle and calls any	 * registered error handlers). It then returns the last param as	 * the result. In the case where the out param was dynamically	 * allocated (see wtxEventGet() for example) is the API call fails	 * then we must call free() on the result before the error return.	 */	WTX_ERROR_RETURN (hWtx, callStat, WTX_ERROR);    /*      * Here we extract any information we want from the out param, then     * free it using wtxExchangeFree() so any exchange allocated memory is     * released and then return the desired result value.     */    result = out.val.value_u.v_int32;    wtxExchangeFree (hWtx->server, WTX_AGENT_MODE_GET, &out);    return result;    }/********************************************************************************* wtxAgentModeSet - set the mode of the target agent** This routine sets the mode of the target agent that the current target* server is attached to.  A given agent may not support all the possible * modes.** EXPAND ../../../include/wtxtypes.h WTX_AGENT_MODE_TYPE** RETURNS: WTX_OK or WTX_ERROR.** SEE ALSO: WTX_AGENT_MODE_SET, wtxTsInfoGet(), wtxAgentModeGet()*/STATUS wtxAgentModeSet     (    HWTX		hWtx,		/* WTX API handle */    WTX_AGENT_MODE_TYPE	agentMode	/* debug agent mode */    )    {    WTX_ERROR_T		callStat;	/* client status */    WTX_MSG_PARAM	in;		/* WTX param */    WTX_MSG_RESULT	out;		/* WTX result */    /*     * All API calls that require a connection to the target server     * should use the WTX_CHECK_CONNECTED macro before doing anything else.     * This macro also calls WTX_CHECK_HANDLE to validate the handle.     */    WTX_CHECK_CONNECTED (hWtx, WTX_ERROR);    /* Always remember to initialize the in and out params */    memset (&in, 0, sizeof (in));    memset (&out, 0, sizeof (out));    /* Fill in the relevant fields of the in params for the call */    in.param.valueType = V_UINT32;    in.param.value_u.v_uint32 = agentMode;    /* Now make the call recording the result status */    callStat = exchange (hWtx, WTX_AGENT_MODE_SET, &in, &out);    /*     * If there is an error we don't need to free the result with      * wtxExchangeFree() because wtxExchange() (called by exchange())      * does this for us when there is an error.     */    if (callStat != WTX_ERR_NONE)	/*	 * On error the WTX_ERROR_RETURN macro calls wtxErrDispatch() for	 * us (which sets the error code in the API handle and calls any	 * registered error handlers). It then returns the last param as	 * the result. In the case where the out param was dynamically	 * allocated (see wtxEventGet() for example) is the API call fails	 * then we must call free() on the result before the error return.	 */	WTX_ERROR_RETURN (hWtx, callStat, WTX_ERROR);    /*      * Here we extract any information we want from the out param, then     * free it using wtxExchangeFree() so any exchange allocated memory is     * released and then return the desired result value.     */    wtxExchangeFree (hWtx->server, WTX_AGENT_MODE_SET, &out);    return (WTX_OK);    }/********************************************************************************* wtxAsyncNotifyEnable - start the asynchronous event notification** This function creates a socket-based link between the target server and * the client where events will be sent. If a user defined function * is given (pFunc != NULL) then this function is called each time an * event is received by the target server, this function must take * a WTX_EVENT_DESC as input parameter. If no user defined function is * given then received events are just stored in the asynchronous event * list, those events can be get using wtxAsyncEventGet().** In conjunction with wtxAsyncNotifyEnable(), wtxRegisterForEvent() (or* wtxUnregisterForEvent()) must be used to specify which type of events must* be sent to the requester.** Upon calling this function, the wtxEventGet() and wtxEventListGet() * routines will always return nothing.** When an event is coming to the client, the event is put in an * WTX_EVENT_DESC structure and passed to the user provided function * pointed to by <pFunc>.** All strings contained in the WTX_EVENT_DESC structure must be copied * before to be used because their life duration is depending on the events* stream.** The user defined function must take a WTX_EVENT_DESC * as input * parameter. It is called each time an event is received by the target* server.* * NOTE:* This service uses WTX_COMMAND_SEND request of the WTX protocol. ** EXAMPLE:** Declaration of a simple event handler.** .CS*   LOCAL void eventHookRtn	/@ Hook routine used by the notification @/*       (*       WTX_EVENT_DESC * event  /@ Event received from the target server @/*       )*       {*	/@ Just print the event string and exit @/**       if (event->event != NULL)*           printf ("Received event: %s\n", event->event);*	}* .CE** Start of the asynchronous notification from the C API.** .CS*	/@ Initialization @/*		.*		.**	/@ Start the notification @/**       if (wtxAsyncNotifyEnable (wtxh, (FUNCPTR) eventHookRtn) *	    != (UINT32) WTX_OK)*	    return (WTX_ERROR);**	/@ core of the WTX application @/*		.*		.* .CE** RETURN: WTX_OK or WTX_ERROR if the request failed.** ERRORS:* .iP WTX_ERR_API_SERVICE_ALREADY_STARTED 12* An wtxAsyncNotifyDisable must be called before.* .iP WTX_ERR_API_CANT_OPEN_SOCKET* Socket creation, bind or listen failed.* .iP WTX_ERR_API_CANT_GET_HOSTNAME* Cannot get name of current host.** SEE ALSO: WTX_COMMAND_SEND, wtxAsyncNotifyEnable(), wtxAsyncEventGet()*/STATUS wtxAsyncNotifyEnable    (    HWTX            hWtx,              /* WTX API handle        */    FUNCPTR         pFunc              /* User defined function */    )    {#ifdef HOST    WTX_MSG_PARAM       in;            /* Query parameters         */    WTX_MSG_RESULT      out;           /* Query result             */    WTX_ERROR_T         callStat;      /* Exchange result          */    int			status;	       /* Return value		   */    struct hostent *    he;            /* Host entries             */    char                buf [128];     /* Input param. string      */    char                bufPort [32];  /* String for port #        */    char                hostName [32]; /* Host name                */    SOCK_DESC           sockDesc;      /* Socket descriptor        */    /*     * All API calls that require a connection to the target server     * should use the WTX_CHECK_CONNECTED macro before doing anything else.     * This macro also calls WTX_CHECK_HANDLE to validate the handle.     */    WTX_CHECK_CONNECTED (hWtx, WTX_ERROR);    /* Open a socket, create the event list and start the threads */    status = wtxAsyncInitialize (&sockDesc, pFunc, &hWtx->asyncHandle);    if (status != WTX_OK)        {        return (status);        }    /* Set input - ouput parameters for WTX_COMMAND_SEND */    in.param.valueType = V_PCHAR;    if (gethostname (hostName, sizeof (hostName)) != OK)        {        /* Tchao */        return (WTX_ERR_API_CANT_GET_HOSTNAME);        }    he = gethostbyname (hostName);    memset (buf, 0, sizeof (buf));    strcpy (buf, WTX_ASYNC_NOTIFY_ENABLE_CMD);    strcat (buf, SEPARATOR);    strcat (buf, (const char *) inet_ntoa (*((struct in_addr *)he->h_addr)));    strcat (buf, SEPARATOR);    sprintf (bufPort, "%d", sockDesc.portNumber);    strcat (buf, bufPort);    in.param.value_u.v_pchar = buf;    memset (&out, 0, sizeof (out));    /* Call WTX_COMMAND_SEND - wtxAsyncNotifyEnable service */    callStat = exchange (hWtx, WTX_COMMAND_SEND, &in, &out);    if (callStat != WTX_ERR_NONE)        {        /* Set off the asynchronous notification */	wtxAsyncStop (&hWtx->asyncHandle);	hWtx->asyncHandle = NULL;        /* Tchao */        WTX_ERROR_RETURN (hWtx, callStat, WTX_ERROR);        }    wtxExchangeFree (hWtx->server, WTX_COMMAND_SEND, &out);#endif /* HOST */    return (WTX_OK);    }/********************************************************************************* wtxAsyncNotifyDisable - stop the asynchronous event notification** This function sends to the target server an order to stop the asynchronous* notification of events.** NOTE:* This service uses WTX_COMMAND_SEND request of the WTX protocol.** RETURN: WTX_OK or WTX_ERROR if exchange failed.** SEE ALSO: WTX_COMMAND_SEND, wtxAsyncNotifyEnable(), wtxAsyncEventGet()*/STATUS wtxAsyncNotifyDisable    (    HWTX        hWtx                       /* WTX API handle */    )    {#ifdef HOST    WTX_ERROR_T         callStat = WTX_OK; /* Exchange result */    WTX_MSG_PARAM       in;            /* Query parameters */    WTX_MSG_RESULT      out;           /* Query result     */    char                buf [32];      /* Input buffer     */    /*     * All API calls that require a connection to the target server     * should use the WTX_CHECK_CONNECTED macro before doing anything else.     * This macro also calls WTX_CHECK_HANDLE to validate the handle.     */    WTX_CHECK_CONNECTED (hWtx, WTX_ERROR);    /* Set input - ouput parameters for WTX_COMMAND_SEND */    in.param.valueType = V_PCHAR;    strcpy (buf, WTX_ASYNC_NOTIFY_DISABLE_CMD);    in.param.value_u.v_pchar = buf;    memset (&out, 0, sizeof (out));    /* Call WTX_COMMAND_SEND - wtxAsyncNotifyDisable service */    callStat = exchange (hWtx, WTX_COMMAND_SEND, &in, &out);    if (callStat == WTX_ERR_NONE)	wtxExchangeFree (hWtx->server, WTX_COMMAND_SEND, &out);    /* Free the event list and stop the async. notif. mechanism */    wtxAsyncStop (&hWtx->asyncHandle);    hWtx->asyncHandle = NULL;    /* Tchao */#endif    return (WTX_OK);    }/********************************************************************************* wtxBreakpointAdd - create a new WTX eventpoint of type breakpoint** This routine creates a new eventpoint on the target to represent a* breakpoint at the address <tgtAddr> for the target context <contextId>.* The target server maintains a list of eventpoints created on the target* and this can be queried using wtxEventpointList().  When a context is* destroyed on the target or the target is reset, eventpoints are deleted* automatically without intervention from the creator.** The context types are given by:** EXPAND ../../../include/wtxtypes.h WTX_CONTEXT_TYPE** When <contextType> is set to WTX_CONTEXT_SYSTEM, then only breakpoints* in system mode can be added. When <contextType> is set to WTX_CONTEXT_TASK,* then only breakpoints in context task can be added.** RETURNS: The ID of the new breakpoint or WTX_ERROR if the add fails.** SEE ALSO: WTX_EVENTPOINT_ADD, wtxEventpointAdd(), wtxEventpointDelete(), * wtxEventpointList()*/UINT32 wtxBreakpointAdd     (    HWTX		hWtx,		/* WTX API handle */    WTX_CONTEXT_TYPE	contextType,	/* type of context to put bp in */    WTX_CONTEXT_ID_T	contextId,	/* associated context */    TGT_ADDR_T		tgtAddr		/* breakpoint address */    )    {    WTX_MSG_RESULT	out;    WTX_MSG_EVTPT_DESC	in;    WTX_ERROR_T		callStat;    UINT32		bpId;        WTX_CHECK_CONNECTED (hWtx, WTX_ERROR);    memset (&out, 0, sizeof (out));    memset (&in, 0, sizeof (in));    in.wtxEvtpt.event.eventType = WTX_EVENT_TEXT_ACCESS;    in.wtxEvtpt.event.eventArg = (TGT_ARG_T) tgtAddr;    in.wtxEvtpt.context.contextType = contextType;    in.wtxEvtpt.context.contextId = contextId;    /* ??? Not used by target agent */    in.wtxEvtpt.action.actionType = WTX_ACTION_STOP | WTX_ACTION_NOTIFY;     in.wtxEvtpt.action.actionArg = 0;	/* ??? Not used by target agent */    in.wtxEvtpt.action.callRtn = 0;	/* ??? Not used by target agent */    in.wtxEvtpt.action.callArg = 0;	/* ??? Not used by target agent */    callStat = exchange (hWtx, WTX_EVENTPOINT_ADD, &in, &out);    if (callStat != WTX_ERR_NONE)	WTX_ERROR_RETURN (hWtx, callStat, WTX_ERROR);    bpId = out.val.value_u.v_uint32;     wtxExc

⌨️ 快捷键说明

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