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

📄 wtx.c

📁 VXWORKS源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
static const char *	WTX_EVT_VIO_WRITE	= "VIO_WRITE";static const char *	WTX_EVT_TOOL_ATTACH	= "TOOL_ATTACH";static const char *	WTX_EVT_TOOL_DETACH	= "TOOL_DETACH";static const char *	WTX_EVT_TOOL_MSG	= "TOOL_MSG";static const char *	WTX_EVT_DATA_ACCESS	= "DATA_ACCESS";static const char *	WTX_EVT_CALL_RETURN	= "CALL_RETURN";static const char *	WTX_EVT_USER		= "USER";static const char *	WTX_EVT_HW_BP           = "HW_BP";static const char *	WTX_EVT_OTHER		= "OTHER";static const char *	WTX_EVT_INVALID		= "INVALID";static const char *	WTX_EVT_UNKNOWN		= "UNKNOWN";static const char *	WTX_EVT_TS_KILLED	= "TS_KILLED";static const char *	WTX_EVT_EVTPT_ADDED	= "EVTPT_ADDED";static const char *	WTX_EVT_EVTPT_DELETED	= "EVTPT_DELETED";#if !defined (_DEBUG) && defined (NO_LICENSE)static BOOL envVarChecked  = FALSE;	/* do we checked NO_LICENSE env. var? */#endif	/* NO_LICENSE */#if defined (HOST) && !defined (_DEBUG)static BOOL	licenseCheck   = TRUE;	/* do check for license ?             */LOCAL int	gotLicense	= 0;	/* Do we own a license ?              */#endif /* HOST *//* XXX : fle : put in comment as it was not used anywhere *//* static const char * WTX_EVT_CALL_GOT_EXC=	"CALL_GOT_EXC"; *//* Externals *//* globals */static BOOL	internalLoadCall;	/* states if it is an internal load *//* forward declarations */LOCAL WTX_ERROR_T exchange    (    HWTX	hWtx,    UINT32	svcNum,    void *	pIn,    void *	pOut    );LOCAL WTX_ERROR_T registryConnect	/* establish a connection with regd */    (    HWTX	hWtx			/* WTX session handler              */    );LOCAL void registryDisconnect    (    HWTX hWtx    );STATUS wtxFreeAdd			/* adds elt in wtxResultFree() list  */    (    HWTX		hWtx,		/* wtx session handler               */    void *		pToFree,	/* pointer to be freed               */    FUNCPTR		pFreeFunc,	/* routine to use to free pToFree    */    void *		pMsgToFree,	/* message to free if needed         */    WTX_REQUEST		svcNum,		/* service num to free if needed     */    WTX_XID		server,		/* RPC server to connect to          */    WTX_SVR_TYPE	svrType		/* connected server type             */    );LOCAL STATUS wtxMemDisassembleFree		/* free disassembled insts.  */    (    WTX_DASM_INST_LIST *	pDasmInstList	/* disassembled list to free */    );#if 0/* XXX : fle : for SRP#67326 */#ifdef HOSTLOCAL STATUS wtxObjModuleLoadProgressReportFree	/* free a status report */    (    HWTX			hWtx,		/* WTX session handler  */    WTX_LOAD_REPORT_INFO *	pToFree		/* pointer to free      */    );#endif /* HOST */#endif /* 0 */LOCAL BOOL wtxResultFreeListTerminate	/* empty the wtxResultFree ptrs list */    (    WTX_FREE_NODE *	pWtxFreeNode,	/* element in singaly linked list    */    HWTX *		hWtx		/* WTX session handler               */    );LOCAL BOOL wtxResultFreeServerListTerminate	/* empty tgtsvr pointers list */    (    WTX_FREE_NODE *	pWtxFreeNode,	/* element in singaly linked list     */    HWTX *		hWtx		/* WTX session handler                */    );#if 0/* XXX : fle : for SRP#67326 */#ifdef HOSTLOCAL STATUS wtxAsyncResultFree_2	/* frees async event list       */    (    WTX_EVENT_DESC *	eventDesc	/* pointer to structure to free */    );#endif /* HOST */#endif /* 0 */LOCAL BOOL wtxPtrMatch			/* matches a pointer value        */    (    WTX_FREE_NODE *	pWtxFreeNode,	/* element in singaly linked list */    void *		pToMatch	/* pointer value to find          */    );LOCAL void wtxDescFree			/* free a WTX_DESC structure */    (    WTX_DESC *	pDescToFree		/* WTX_DESC pointer to free  */    );LOCAL WTX_DESC * wtxDescDuplicate	/* duplicates a WTX_DESC       */    (    HWTX	hWtx,			/* current WTX session handler */    WTX_DESC *	pDesc			/* WTX_DESC to duplicate       */    );LOCAL void toolCleanup			/* cleanups when a tool detaches */    (    HWTX		hWtx		/* WTX API handler */    );LOCAL void serverDescFree		/* frees server description item */    (    HWTX		hWtx		/* WTX API handler */    );#ifndef HOSTLOCAL char * stringDup			/* duplicates a string */    (    const char *	strToDup	/* string to duplicate */    );#define	strdup	stringDup#endif /* ! HOST *//* * NOTE: This is a list of WTX protocol calls not accessible from the  *       WTX C API and is based on the service numbers in wtxmsg.h * * WTX_VIO_READ			- not implemented in server (obsolete?) * WTX_SYM_TBL_CREATE/DELETE	- to do * WTX_SYM_TBL_LIST		- to do * WTX_WTX_SERVICE_LIST		- not implemented in server - undefined * WTX_WDB_SERVICE_LIST		- not implemented in server - undefined * WTX_OBJ_KILL			- (currently TS kill only) Enough ? * WTX_OBJ_RESTART		- undefined (obsolete ?) */#if defined (HOST) && !defined (_DEBUG)/********************************************************************************* wtxLmDeauthorize - Check-in a license** This routine releases a license previously checked-out by wtxLmAuthorize ().* Typically, it is called when the process exits.** RETURNS: N/A** SEE ALSO: wtxLmAuthorize ()** NOMANUAL*/void wtxLmDeauthorize (void)    {    /* if we own a license, release it. */    if (gotLicense)	{	flexlmDeauthorize ();	}    }/********************************************************************************* wtxLmAuthorize - Check-out a license** This routine establishes a connection to the license server, and tries to* Check out a license.* Currently, we check a license upon first call to this routine. Once we get a* license, we always return OK to any subsequent call to this routine.* We register a handle to release the license when the tool exits.** RETURNS: WTX_OK or WTX_ERROR if the check-out fails.** SEE ALSO: wtxLmDeauthorize ()** NOMANUAL*/STATUS wtxLmAuthorize (void)    {    /* If we already got a license return OK */        if (gotLicense)	return OK;    /* First time: check for a valid license */    if (flexlmAuthorize (FEATURE_TORNADO_2_2, VERSION_TORNADO_2_2, 1) != OK)	return ERROR;    gotLicense = 1;	/* we got one! */        /* Record a handler to release the license when the process exits */    atexit (wtxLmDeauthorize);    return OK;	/* Return sucess */    }#endif/********************************************************************************* wtxToolAttach - connect a WTX client to the target server** This routine establishes a connection to the target server* called <serverName> and announces the client as a WTX tool called* <toolName>. If <serverName> does not contain an `@' character, it is* used as a regular expression; if it matches more than one (registered)* target server name, an error is returned.  If <serverName> contains * an `@' character then it must be an exact match for a valid target * server name.** RETURNS: WTX_OK or WTX_ERROR if the attach fails.** ERRORS:* .iP WTX_ERR_API_ALREADY_CONNECTED 12* The handle is already connected to a target server.* .iP WTX_ERR_API_SERVER_NOT_FOUND * <serverName> does not match a target server name using the above criteria.* .iP WTX_ERR_API_AMBIGUOUS_SERVER_NAME * <serverName> matches more than one target server name.* .iP WTX_ERR_SVR_DOESNT_RESPOND* <serverName> is dead : no RPC connection can be achieved* .iP WTX_ERR_SVR_IS_DEAD* <serverName> is dead : server has been found dead* .iP WTX_ERR_SVR_INVALID_LICENSE* No license could be checked-out for this tool.** SEE ALSO: WTX_TOOL_ATTACH, wtxToolDetach(), wtxToolConnected(), wtxInfoQ()*/STATUS wtxToolAttach     (    HWTX		hWtx,			/* WTX API handle             */    const char *	serverName,		/* Target Server name         */    const char *	toolName		/* tool name                  */    )        {    WTX_MSG_TOOL_DESC	in;			/* WTX param                  */    WTX_MSG_TOOL_DESC *	pOut = NULL;		/* WTX result                 */    WTX_DESC_Q *	pTsDescQ = NULL;	/* Q Info about Target Server */    WTX_ERROR_T		callStat;		/* status of WTX call         */    WTX_ERROR_T		errCode=WTX_ERR_NONE;	/* connection init status     */    WTX_DESC *		pSaveDesc = NULL;	/* saved server desc          */    WTX_DESC *		pTsDesc = NULL;		/* Info about Target Server   */    WTX_DESC *		pNewDesc = NULL;	/* for updated tgtsvr entry   */    char *		envUser = NULL;		/* result of getenv(USER)     */    char *		oldKey = NULL;		/* for multi adapters tgtsvrs */    char *		tmpKey = NULL;		/* for multi adapters tgtsvrs */    BOOL		usePMap = FALSE;	/* do we use port mapper ?    */    char		userName [256];		/* to format "user@host"      */    char		serverAtHost [256];	/* serverName@host            */    char		hostNameBuf [32];	/* for gethostname ()         */    int			ipNum = 0;		/* number of IP addr in list  */#ifdef WIN32    char                usrName [256];		/* holds name for Win32       */#endif    WTX_CHECK_HANDLE (hWtx, WTX_ERROR);    if (wtxToolConnected (hWtx))	WTX_ERROR_RETURN (hWtx, WTX_ERR_API_ALREADY_CONNECTED, WTX_ERROR);    if (hWtx->pServerDesc) 	{	wtxResultFree (hWtx, hWtx->pServerDesc);	hWtx->pServerDesc = NULL;	}    if (toolName == NULL)	WTX_ERROR_RETURN (hWtx, WTX_ERR_API_INVALID_ARG, WTX_ERROR);#if defined (HOST) && !defined (_DEBUG)    /*      * License check (HOST side, release version only):     * if NO_LICENSE if defined for this module, we'll look if NO_LICENSE is     * defined in the process' environment. If this is the case, we skip     * license check.      * In all cases, GDB won't be checked for license.     */#ifdef NO_LICENSE    if (!envVarChecked)	{	licenseCheck = (wpwrGetEnv ("NO_LICENSE") != NULL)?FALSE:TRUE;	envVarChecked = TRUE;	}#endif /* NO_LICENSE */     if (licenseCheck)	 licenseCheck = (strstr (toolName, "gdb") == NULL)?TRUE:FALSE;	    if ((licenseCheck) && (wtxLmAuthorize () != OK))	{	WTX_ERROR_RETURN (hWtx, WTX_ERR_SVR_INVALID_LICENSE, WTX_ERROR);	}#endif /* HOST */    /* save current name in serverAtHost */    strcpy (serverAtHost, serverName);    if (!strchr (serverName, '@'))			/* name: tgtsvr */	{	pTsDescQ = wtxInfoQ (hWtx, (char *)serverName, "tgtsvr", NULL);	if (pTsDescQ == NULL)	    WTX_ERROR_RETURN (hWtx, WTX_ERR_API_SERVER_NOT_FOUND, WTX_ERROR);		if (pTsDescQ->pNext != NULL)	    {	    wtxResultFree (hWtx, pTsDescQ);	    WTX_ERROR_RETURN (hWtx, WTX_ERR_API_AMBIGUOUS_SERVER_NAME, 			      WTX_ERROR);	    }	/*	 * There is an @ in the target server name, let's see if it is really	 * in registry data base.	 */	strcpy (serverAtHost, pTsDescQ->wpwrName);	wtxResultFree (hWtx, pTsDescQ);	}    pTsDesc = wtxInfo (hWtx, (char *)serverAtHost);	/* name: tgtsvr@host */    if (pTsDesc == NULL)	WTX_ERROR_RETURN (hWtx, hWtx->errCode, WTX_ERROR);    hWtx->pServerDesc = pTsDesc;    /* allocate space to copy server information */    if ( (pSaveDesc = (WTX_DESC *) malloc (sizeof (WTX_DESC))) == NULL)	{	wtxResultFree (hWtx, hWtx->pServerDesc);	WTX_ERROR_RETURN (hWtx, WTX_ERR_API_MEMALLOC, WTX_ERROR);	}    /* copy server information */    memcpy ((void *) pSaveDesc, (void *) hWtx->pServerDesc, sizeof (WTX_DESC));    if (hWtx->pServerDesc->wpwrName != NULL)	{	if ((pSaveDesc->wpwrName = (char *) malloc (strlen			    (hWtx->pServerDesc->wpwrName) + 1)) == NULL)	    {	    free (pSaveDesc);	    wtxResultFree (hWtx, hWtx->pServerDesc);	    WTX_ERROR_RETURN (hWtx, WTX_ERR_API_MEMALLOC, WTX_ERROR);	    }	            strcpy (pSaveDesc->wpwrName, hWtx->pServerDesc->wpwrName);	}    if (hWtx->pServerDesc->wpwrKey != NULL)	{	if ((pSaveDesc->wpwrKey = (char *) malloc (strlen			    (hWtx->pServerDesc->wpwrKey) + 1)) == NULL)	    {	    free (pSaveDesc->wpwrName);	    free (pSaveDesc);	    wtxResultFree (hWtx, hWtx->pServerDesc);	    WTX_ERROR_RETURN (hWtx, WTX_ERR_API_MEMALLOC, WTX_ERROR);	    }	            strcpy (pSaveDesc->wpwrKey, hWtx->pServerDesc->wpwrKey);	}    if (hWtx->pServerDesc->wpwrType != NULL)	{	if ((pSaveDesc->wpwrType = (char *) malloc (strlen			    (hWtx->pServerDesc->wpwrType) + 1)) == NULL)	    {	    free (pSaveDesc->wpwrKey);	    free (pSaveDesc->wpwrName);	    free (pSaveDesc);	    wtxResultFree (hWtx, hWtx->pServerDesc);	    WTX_ERROR_RETURN (hWtx, WTX_ERR_API_MEMALLOC, WTX_ERROR);	    }	            strcpy (pSaveDesc->wpwrType, hWtx->pServerDesc->wpwrType);	}    wtxResultFree (hWtx, hWtx->pServerDesc);    registryDisconnect (hWtx);    hWtx->pServerDesc = pSaveDesc;    /* first just initialise the connection */    if (wtxExchangeInitialize (&hWtx->server) != WTX_OK ||	wtxExchangeInstall (hWtx->server, 			    wtxRpcExchangeCreate, 			    wtxRpcExchangeDelete, 			    wtxRpcExchange, 			    wtxRpcExchangeFree, 			    wtxRpcExchangeControl) != WTX_OK)	{	/* Record the error code */	errCode = wtxExchangeErrGet ((WTX_XID) hWtx->server);	/* free server descriptor */	serverDescFree (hWtx);

⌨️ 快捷键说明

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