Tornado API Reference : WDB Protocol
WDB - WDB Protocol Requests
WDB_CONTEXT_CONT - continue a context
WDB_CONTEXT_CREATE - create a context on the target
WDB_CONTEXT_KILL - kill a context on the target
WDB_CONTEXT_RESUME - resume a context on the target
WDB_CONTEXT_STATUS_GET - get the context of a status on the target
WDB_CONTEXT_STEP - single step a context
WDB_CONTEXT_SUSPEND - suspend a context on the target
WDB_DIRECT_CALL - call a function on the target in the agent's context
WDB_EVALUATE_GOPHER - execute a Gopher string
WDB_EVENTPOINT_ADD - add an asynchronous eventpoint
WDB_EVENTPOINT_DELETE - delete an eventpoint
WDB_EVENT_GET - upload an event from the target
WDB_FUNC_CALL - call a function on the target
WDB_MEM_CACHE_TEXT_UPDATE - synchronize cache after writing to the target
WDB_MEM_CHECKSUM - checksum a block of target memory
WDB_MEM_FILL - fill target memory with a pattern
WDB_MEM_MOVE - move memory on the target
WDB_MEM_PROTECT - write enable/disable a region of target memory
WDB_MEM_READ - read memory from the target
WDB_MEM_SCAN - scan a block of target memory for a pattern
WDB_MEM_WRITE - write the contents of host memory to target memory
WDB_MODE_GET - get the agent mode
WDB_MODE_SET - set the agent mode
WDB_REGS_GET - get the registers of a context on the target
WDB_REGS_SET - set the registers of a context on the target
WDB_TARGET_CONNECT - connect the target server to the target agent
WDB_TARGET_DISCONNECT - disconnect the target server from the target agent
WDB_TARGET_PING - probe the target
WDB_VIO_WRITE - write data to a virtual I/O channel
This document describes the Wind River Debug (WDB) version 2.0 protocol. It is the protocol used by the Tornado target server back ends that communicate with the target agent (WDB RPC, WDB Serial, WDB NetROM and WDB Pipe).
The diagram below gives an overview of the Tornado environment.
+---------+ +---------+ +---------+ +---------+ | | | | | | | | | Shell | | Debugger| | Browser | | Other | | | | | | | | Tools | +----+----+ +----+----+ +----+----+ +----+----+ | | | | +--------------------+ | +-----------+ | | | | +-----------------------+ WTX | | | | Protocol | | | | +--+--+--+--+---+ | | | Target Server | | | +-+--+--+--+--+-+ | | | | | | | | | +--------------------------+ | | | +-----------------+ | +----+ | +--------+ | | | | | | | Target Server +---+---+ +---+----+ +---+----+ +---+----+ +---+----+ Back Ends | WDB | | WDB | | WDB | | WDB | |Non-WDB | | RPC | | Netrom | | Serial | | Pipe | |Back End| +---+---+ +---+----+ +----+---+ +---+----+ +---+----+ | | | | | Host | | | | | - - - - - - - -- - - -|- - - - - |- - - - - - |- - - - - |- - - - - -|- - Target (or simulator)| | | | | | | | | | +---+---+ +---+----+ +----+---+ +---+----+ | |Network| | Netrom | | Serial | | Pipe | | WDB Target Agent |Comm if| |Comm if | |Comm if | |Comm if | | Communication +---+---+ +---+----+ +----+---+ +---+----+ | Interfaces | | | | | +--------+ | +----------+ | | | | | +-------------------+ | | | | | | +--+-+-+-+--+ +----+----+ |WDB Target | | Non-WDB | Agents | Agent | | Agent | +-----+-----+ +----+----+ | | +----+----+ | | | | | vxWorks +-----------------------------+ | | +---------+
If you want to create a new back end for Tornado, knowledge of the WDB protocol is not needed. Creating a back end that communicates with the WDB agent requires installing a new communication path between the host and target. Once the communication path is established, the target agent performs all the services needed. Creating a back end that communicates with a non-WDB agent (for example, an ICE) requires implementing all the target services required. For details, refer to the API Programmer's Guide: Target Server Back End.
The next few sections describe the format of messages sent between the host and target. The rest of this chapter describes the actual set of services provided by the agent.
The WDB protocol is an RPC-based protocol which uses UDP. The WDB agent acts as a server for requests sent by the target server. For more information, see one of the many generally available references on UDP and Sun RPC.
Some key definitions can be found in share/src/agents/wdb/wdb.h:
- The UDP port that the agent accepts request from, WDBPORT, is 0x4321.
- The agent's RPC program number, WDBPROG, is 0x55555555.
- The agent's RPC version number, WDBVERS, is 1.
A WDB request packet sent to the agent contains, in order:
- A 20-byte IP header.
- An 8-byte UDP header. It consists of four 16-bit words. WDBPORT is word 2.
- A 40-byte RPC request header. It consists of ten 32-bit words. WDBPROG is word 3. WDBVERS is word 4. The RPC procedure number is word 5.
- An XDR stream. The first 12 bytes of this stream is WDB-parameter- wrapper information. (See ${WIND_BASE}/share/src/agents/wdb for more information on the WDB_XDR functions.)
The diagram below shows the layout of the WDB request packet. The main WDB information is contained in the XDR stream. This is where the input parameters for the WDB functions are transferred to the target agent.
+-----+ IP HEADER | | 20 bytes | | | | | | | | +-----+ UDP HEADER | | WDBPORT 8 bytes | | +-----+ RPC REQUEST HEADER | | 40 bytes | | WDBPROG (10 32-bit words) | | WDBVERS | | RPC procedure # | | | | | | | | XDR Stream +-----+ WDB PARAMETER WRAPPER | | Checksum 12 bytes | | Packet Size | | Sequence # | - - | XDR encoded PARAMETERS | | (function input parameters) | | | | | |The WDB parameter wrapper contains three 4-byte words. The first word is a checksum over the whole RPC packet (RPC header + XDR stream). The second word is the packet size. These two words enable the agent to determine if a corrupted packet has arrived. The third word is a sequence number. The low order two bytes of the sequence number are used to allow the agent to ignore old or duplicated requests (which can occur with UDP transport). The high order two bytes are the host ID. When a host issues a WDB_TARGET_CONNECT request, the host ID portion of the sequence number is recorded. If a request arrives from a non-connected host, the RPC fails with the RPC error status PROG_UNAVAIL or SYSTEM_ERR, depending on whether the agent is already connected to another target server or not. The WDB_TARGET_CONNECT request always establishes a new connection, if necessary by dropping the old one. If the host wants to test whether or not the agent is already connected before trying to establish a connection, it should first issue a WDB_TARGET_PING request and see if the RPC fails with error status PROG_UNAVAIL. If so the connection is busy.The routine xdr_WDB_PARAM_WRAPPER is used to encode or decode the entire XDR stream (the procedure parameters plus the 12-byte parameter wrapper). The following example is a code stub from the host routine rpcCoreClntCall( ):
seqNumber++ ; ... wdbParamWrapper.xdr = inProc; /* xdr func for proc params */ wdbParamWrapper.pParams = in; /* pointer to proc params */ wdbParamWrapper.seqNum = processId | seqNumber; /* seq nb */ ... clntStatus = clnt_call (pWdbClnt, procNum, xdr_WDB_PARAM_WRAPPER, &wdbParamWrapper, ...);
A WDB reply packet sent by the agent contains, in order:
- A 20-byte IP header.
- An 8-byte UDP header.
- A 24-byte RPC reply header.
- An XDR stream. The first 12 bytes of this stream is WDB reply wrapper info (see below). The rest of the stream is the XDR- encoded reply from the procedure.
The diagram below shows the layout of the WDB reply packet. As with the WDB request packet, the main WDB information is contained in the XDR stream. The result of the WDB function is returned to the host in this stream.
+-----+ IP HEADER | | 20 bytes | | | | | | | | +-----+ UDP HEADER | | 8 bytes | | +-----+ RPC REPLY HEADER | | 24 BYTES | | WDBPROG (6 32-bit words) | | WDBVERS | | RPC procedure # | | | | | | | | XDR Stream +-----+ WDB REPLY WRAPPER | | Checksum 12 bytes | | Packet Size | | WDB Error Status | - - | XDR encoded REPLY | | (function output) | | | | | |Like the WDB parameter wrapper, the WDB reply wrapper contains three 4- byte words. The first word is a checksum over the whole RPC packet (RPC header plus XDR stream). The second word is the packet size. These two words enable the host to determine if a corrupted reply was returned (and, if so, to reissue the request). The third word is the WDB error status. The high order bit is set if there are events pending on the target, in which case the host can issue a WDB_EVENT_GET request to upload the event. The rest of the word is the actual error status.
After a remote procedure is called, the program should perform error checking. Error status can be communicated in one of two ways: in the RPC header or in the reply wrapper. If the failure is reported in the RPC header, then the host's clnt_call will return an RPC error status. These have conventional meanings according to the RPC specification. In addition, the WDB agent uses the following special codes:
- RPC_PROCUNAVAIL
- The RPC procedure requested is not configured into the agent. The agent is scalable, so this usually means the agent was built without that service.
- RPC_PROGUNAVAIL
- The agent refused to execute the procedure because it is connected to another host.
- RPC_SYSTEMERROR
- The agent refused to execute the procedure because it is not connected to any host. If you were previously connected, the target has rebooted.
Even if the RPC call succeeds (meaning that the agent tries to execute your command), the command may still fail. The errCode field in the reply wrapper can be checked; if the lower 30 bits are zero, the command succeeded. (Remember that the high-order bit is set if there are events pending on the target.) If the value is non-zero, then the procedure failed and the word contains the error code. Error codes have the format WDB_ERR_XXX and are defined in ${WIND_BASE}/share/src/agents/wdb/wdb.h.
The routine xdr_WDB_REPLY_WRAPPER is used to encode or decode the entire XDR stream (the reply data plus the 12-byte reply wrapper). The following pseudo code shows how it works:
wdbReplyWrapper.xdr = outProc; /* reply xdr function */ wdbReplyWrapper.pReply = out; /* where to decode reply */ wdbReplyWrapper.errCode = OK; /* just to clear this field */ ... clntStatus = clnt_call (pWdbClnt, procNum, xdr_WDB_PARAM_WRAPPER, &wdbParamWrapper, xdr_WDB_REPLY_WRAPPER, &wdbReplyWrapper, timeout); check (clntStatus) { if (RPC_TIMEDOUT or RPC_CANTDECODERES or RPC_CANTDECODEARGS) try again if (RPC_SYSTEMERROR) if we were previously connected, then target must have rebooted so resync and reconnect. if (RPC_PROCUNAVAIL) procedure not configured into agent. Try to rebuild the agent with that facility included (e.g., virtual I/O is an optional agent facility). if (RPC_SUCCESS) agent tried to execute the routine. check high order bit of wdbReplyWrapper.errCode to see if events are pending on the target. If so, execute a WDB_EVENT_GET request after finishing processing this reply. mask off the high order bit of wdbReplyWrapper.errCode. if (wdbReplyWrapper.errCode == 0) success! In this case wdbReplyWrapper.xdr decoded the reply and put it in wdbReplyWrapper.pReply. else wdbReplyWrapper.errCode contains the reason for procedure failure. The error coded are defined in wdb.h. }As the above pseudo code indicates, if you do not receive an RPC error or RPC_SUCCESS, wdbReplyWrapper.errCode contains the reason for the procedure failure. The possible error codes are as follows:
WDB_OK OK /* success */ WDB_ERR_INVALID_PARAMS 0x501 /* params invalid */ WDB_ERR_MEM_ACCES 0x502 /* memory fault */ WDB_ERR_AGENT_MODE 0x503 /* wrong agent mode */ WDB_ERR_RT_ERROR 0x504 /* run-time callout failed */ WDB_ERR_INVALID_CONTEXT 0x505 /* bad task ID */ WDB_ERR_INVALID_VIO_CHANNEL 0x506 /* bad virtual I/O channel */ WDB_ERR_INVALID_EVENT 0x507 /* no such event type */ WDB_ERR_INVALID_EVENTPOINT 0x508 /* no such eventpoint */ WDB_ERR_GOPHER_FAULT 0x509 /* gopher fault */ WDB_ERR_GOPHER_TRUNCATED 0x50a /* gopher tape too large */ WDB_ERR_EVENTPOINT_TABLE_FULL 0x50b /* out of room */ WDB_ERR_NO_AGENT_PROC 0x50c /* agent proc not installed */ WDB_ERR_NO_RT_PROC 0x50d /* run-time callout unavail */ WDB_ERR_GOPHER_SYNTAX 0x50e /* gopher syntax error */ WDB_ERR_NOT_FOUND 0x50f /* object not found */ WDB_ERR_HW_REGS_EXHAUSTED 0x510 /* hardware breakpoint registers full */ WDB_ERR_INVALID_HW_BP 0x511 /* invalid hardware breakpoint */ WDB_ERR_PROC_FAILED 0x5ff /* generic proc failure */ WDB_ERR_NO_CONNECTION 0x600 /* not connected */ WDB_ERR_CONNECTION_BUSY 0x601 /* someone else connected */ WDB_ERR_COMMUNICATION 0x6ff /* generic comm error */
Asynchronous events can be generated on the target. These include exceptions, breakpoints, and task exiting. These events are queued on the target until the host uploads them with the WDB_EVENT_GET service. In order to prevent the host from polling for events, the agent has two ways to notify the host that events are pending. One way is setting the high order bit in the errCode status of the reply wrapper. The other way is by sending a "notify packet".
Normally the agent only sends data to the host in response to RPC requests. The convention is that if the host receives data when it is not waiting for a reply, it means that an event is pending on the target. The target server waits for events from other host tools as well as from the target. When the target sends an event, the host issues a WDB_EVENT_GET request to upload the event (and keeps uploading events until the high order bit in the errCode field is clear). The actual notify packet sent by the agent is a packet that can not be confused with an RPC reply (in case it sends the notify packet just as the host issues an RPC request). In fact, it sends a bogus RPC request.
WDB transactions occur as described above. We now describe the set of WDB procedures. For each procedure, we list the input and output structures (if any), and some possible error codes. The error codes listed are in addition to the ones described in the previous sections. The actual values for the RPC procedure number, error status, and data types can be found in ${WIND_BASE}/share/src/agents/wdb/wdb.h.
WDB_CONTEXT_CONT - continue a context
INPUT: WDB_CTX OUTPUT: (
This routine continues a context that has been suspended or has hit a breakpoint. The input parameters are specified in WDB_CTX:
typedef struct wdb_ctx /* a particular context */ { WDB_CTX_TYPE contextType; /* type of context */ UINT32 contextId; /* context ID */ } WDB_CTX;If contextType is WDB_CTX_SYSTEM, the system context is continued. (This only makes sense if the agent is in system mode.) If contextType is WDB_CTX_TASK, the task whose ID is contextId is continued.
- WDB_ERR_AGENT_MODE
- Attempting to continue a task from system mode or the system from task mode.
- WDB_ERR_INVALID_CONTEXT
- The context does not exist.
- WDB_ERR_NO_RT_PROC
- The agent does not support this service.
- WDB and RPC errors
- As described in the "REPLY ERRORS" section of the WDB man page.
WDB_CONTEXT_CREATE - create a context on the target
INPUT: WDB_CTX_CREATE_DESC OUTPUT: UINT32
This routine creates a context on the target as specified in WDB_CTX_CREATE_DESC:
typedef struct wdb_ctx_create_desc /* how to create a context */ { WDB_CTX_TYPE contextType; /* task or system context */ /* the following are used for task and system contexts */ TGT_ADDR_T stackBase; /* bottom of stack (NULL = malloc) */ UINT32 stackSize; /* stack size */ TGT_ADDR_T entry; /* context entry point */ TGT_INT_T args[10]; /* arguments */ /* the following are only used for task contexts */ WDB_STRING_T name; /* name */ TGT_INT_T priority; /* priority */ TGT_INT_T options; /* options */ TGT_INT_T redirIn; /* redirect input file (or 0) */ TGT_INT_T redirOut; /* redirect output file (or 0) */ TGT_INT_T redirErr; /* redirect error output file (or 0) */ } WDB_CTX_CREATE_DESC;where WDB_CTX_TYPE is one of the following:
typedef enum wdb_ctx_type /* type of context on the target */ { WDB_CTX_SYSTEM = 0, /* system mode */ WDB_CTX_GROUP = 1, /* process group (not implemented) */ WDB_CTX_ANY = 2, /* any context (not implemented) */ WDB_CTX_TASK = 3, /* specific task or processes */ WDB_CTX_ANY_TASK = 4, /* any task */ WDB_CTX_ISR = 5, /* specific ISR (not implemented) */ WDB_CTX_ANY_ISR = 6 /* any ISR (not implemented) */ } WDB_CTX_TYPE;The output value is the task ID of the new task.
- WDB_ERR_RT_ERROR
- The task creation failed.
- WDB_ERR_NO_AGENT_PROC
- The agent is in external mode (the version 1.0 external-mode agent does not support context creation).
- WDB_ERR_NO_RT_PROC
- The agent does not support this service.
- WDB and RPC errors
- As described in the "REPLY ERRORS" section of the WDB man page.
WDB_CONTEXT_KILL - kill a context on the target
INPUT: WDB_CTX OUTPUT: (
This routine kills the context specified in WDB_CTX:
typedef struct wdb_ctx /* a particular context */ { WDB_CTX_TYPE contextType; /* type of context */ UINT32 contextId; /* context ID */ } WDB_CTX;If contextType is WDB_CTX_SYSTEM, the "system context" is killed. (This means VxWorks is rebooted.) Otherwise the task whose ID is contextId is killed.
- WDB_ERR_AGENT_MODE
- Trying to kill a task while in system mode.
- WDB_ERR_INVALID_CONTEXT
- The context does not exist.
- WDB_ERR_NO_RT_PROC
- The agent does not support this service.
- WDB and RPC errors
- As described in the "REPLY ERRORS" section of the WDB man page.
WDB_CONTEXT_RESUME - resume a context on the target
INPUT: WDB_CTX OUTPUT: (
This routine resumes the target context specified by WDB_CTX:
typedef struct wdb_ctx /* a particular context */ { WDB_CTX_TYPE contextType; /* type of context */ UINT32 contextId; /* context ID */ } WDB_CTX;If contextType is WDB_CTX_SYSTEM, the "system context" is resumed (in other words, VxWorks is resumed). Otherwise the task whose ID is contextId is resumed.
- WDB_ERR_AGENT_MODE
- Trying to resume a task while in system mode.
- WDB_ERR_INVALID_CONTEXT
- The context does not exist.
- WDB_ERR_NO_RT_PROC
- The agent does not support this service.
- WDB and RPC errors
- As described in the "REPLY ERRORS" section of the WDB man page.
WDB_CONTEXT_STATUS_GET - get the context of a status on the target
INPUT: ) OUTPUT: INPUT:
This request returns the status of the target context specified by WDB_CTX:
typedef struct wdb_ctx /* a particular context */ { WDB_CTX_TYPE contextType; /* type of context */ UINT32 contextId; /* context ID */ } WDB_CTX;If contextType is WDB_CTX_SYSTEM, we get the status of the "system context". At present, this request is only implemented for the "system context".
The return value can be :
- WDB_CTX_RUNNING
- The target context is running.
- WTX_CONTEXT_SUSPENDED
- The target context is suspended.
- WDB_ERR_AGENT_MODE
- Trying to get the status of a context other than the system context.
- WDB and RPC errors
- As described in the "REPLY ERRORS" section of the WDB man page.
WDB_CONTEXT_STEP - single step a context
INPUT: WDB_CTX_STEP_DESC OUTPUT: (
This routine single steps a context. The context is defined by WDB_CTX_STEP_DESC:
typedef struct wdb_ctx_step_desc /* how to single step a context */ { WDB_CTX context; /* context to step */ TGT_ADDR_T startAddr; /* lower bound of step range */ TGT_ADDR_T endAddr; /* upper bound of step range */ } WDB_CTX_STEP_DESC;where WDB_CTX describes the context to step:
typedef struct wdb_ctx /* a particular context */ { WDB_CTX_TYPE contextType; /* type of context */ UINT32 contextId; /* context ID */ } WDB_CTX;startAddr and endAddr specify the range of instructions to step over. If startAddr and endAddr both equal 0, then one instruction is stepped. Otherwise stepping occurs until the pointer is out of the step range.
When the step completes, notification occurs by issuing an asynchronous event of type WDB_EVT_BP. See WDB_EVENT_GET for details.
- WDB_ERR_AGENT_MODE
- Trying to step a task in system mode or trying to step the system in task mode.
- WDB_ERR_INVALID_CONTEXT
- Trying to step an invalid context.
- WDB_ERR_NO_RT_PROC
- The agent does not support this service.
- WDB and RPC errors
- As described in the "REPLY ERRORS" section of the WDB man page.
WDB_CONTEXT_SUSPEND - suspend a context on the target
INPUT: WDB_CTX OUTPUT: (
This routine suspends the target context specified by WDB_CTX:
typedef struct wdb_ctx /* a particular context */ { WDB_CTX_TYPE contextType; /* type of context */ UINT32 contextId; /* context ID */ } WDB_CTX;where WDB_CTX_TYPE is one of the following:
typedef enum wdb_ctx_type /* type of context on the target */ { WDB_CTX_SYSTEM = 0, /* system mode */ WDB_CTX_GROUP = 1, /* process group (not implemented) */ WDB_CTX_ANY = 2, /* any context (not implemented) */ WDB_CTX_TASK = 3, /* specific task or processes */ WDB_CTX_ANY_TASK = 4, /* any task */ WDB_CTX_ISR = 5, /* specific ISR (not implemented) */ WDB_CTX_ANY_ISR = 6 /* any ISR (not implemented) */ } WDB_CTX_TYPE;If contextType is WDB_CTX_SYSTEM, the "system context" is suspended (in other words, VxWorks is suspended). Otherwise the task whose ID is contextId is suspended.
- WDB_ERR_AGENT_MODE
- Trying to suspend a task while in system mode
- WDB_ERR_INVALID_CONTEXT
- The context does not exist.
- WDB_ERR_NO_RT_PROC
- The agent does not support this service.
- WDB and RPC errors
- As described in the "REPLY ERRORS" section of the WDB man page.
WDB_DIRECT_CALL - call a function on the target in the agent's context
INPUT: WDB_CTX_CREATE_DESC OUTPUT: UINT32
This routine calls the specified function in the target agent's context and waits for the function to return. The function is specified by the entry and args[10] members of WDB_CTX_CREATE_DESC. The other members are ignored and are set to NULL.
typedef struct wdb_ctx_create_desc /* how to create a context */ { WDB_CTX_TYPE contextType; /* task or system context */ /* the following are used for task and system contexts */ TGT_ADDR_T stackBase; /* bottom of stack (NULL = malloc) */ UINT32 stackSize; /* stack size */ TGT_ADDR_T entry; /* context entry point */ TGT_INT_T args[10]; /* arguments */ /* the following are only used for task contexts */ WDB_STRING_T name; /* name */ TGT_INT_T priority; /* priority */ TGT_INT_T options; /* options */ TGT_INT_T redirIn; /* redirect input file (or 0) */ TGT_INT_T redirOut; /* redirect output file (or 0) */ TGT_INT_T redirErr; /* redirect error output file (or 0) */ } WDB_CTX_CREATE_DESC;The output contains the result of the function and is a UINT32.
- WDB and RPC errors
- As described in the "REPLY ERRORS" section of the WDB man page.
WDB_EVALUATE_GOPHER - execute a Gopher string
INPUT: WDB_STRING_T OUTPUT: WDB_MEM_XFER
Gopher is a small, interpreted language that allows the traversal of simple data structures in target memory. This request sends the specified Gopher program to the target for evaluation and returns the result of the evaluation in a Gopher tape. The contents of the target memory specified by the Gopher program are written to the tape. For more information on the Gopher language, see the documentation of WTX_GOPHER_EVAL in the API Reference Manual: WTX Protocol or the discussion in the API User's Guide: The WTX Protocol. The string to be evaluated is passed in WDB_STRING_T.
The result of evaluating the Gopher string is returned in a WDB_MEM_XFER structure:
typedef struct wdb_mem_xfer /* transfer a block of memory */ { WDB_OPQ_DATA_T source; /* data to transfer */ TGT_ADDR_T destination; /* requested destination */ TGT_INT_T numBytes; /* number of bytes transferred */ } WDB_MEM_XFER;
- WDB_ERR_GOPHER_SYNTAX
- The Gopher string is malformed.
- WDB_ERR_GOPHER_FAULT
- A memory fault occurred while executing the string.
- WDB_ERR_GOPHER_TRUNCATED
- The resulting reply was too large to upload.
- WDB and RPC errors
- As described in the "REPLY ERRORS" section of the WDB man page.
WDB_EVENTPOINT_ADD - add an asynchronous eventpoint
INPUT: WDB_EVTPT_ADD_DESC OUTPUT: UINT32
This routine adds an asynchronous eventpoint to the target. The type of event to add an eventpoint for is specified by WDB_EVTPT_ADD_DESC:
typedef struct wdb_evtpt_add_desc /* how to add an eventpt */ { WDB_EVT_TYPE evtType; /* type of event to detect */ TGT_INT_T numArgs; /* eventType dependent arguments */ UINT32 * args; /* arg list */ WDB_CTX context; /* context in which event must occur */ WDB_ACTION action; /* action to perform */ } WDB_EVTPT_ADD_DESC;where args points to an argument list and context is:
typedef struct wdb_ctx /* a particular context */ { WDB_CTX_TYPE contextType; /* type of context */ UINT32 contextId; /* context ID */ } WDB_CTX;WDB_ACTION is:
typedef struct wdb_action /* a specific action */ { WDB_ACTION_TYPE actionType; UINT32 actionArg; TGT_ADDR_T callRtn; TGT_INT_T callArg; } WDB_ACTION;and WDB_ACTION_TYPE is:
typedef enum wdb_action_type /* what to do when an event occurs */ { WDB_ACTION_CALL = 1, /* condition the evtpt via a proc */ WDB_ACTION_NOTIFY = 2, /* notify the host */ WDB_ACTION_STOP = 4 /* stop the context */ } WDB_ACTION_TYPE;Currently, eventpoints can be added for the following event types:
- WDB_EVT_BP
- breakpoint
- WDB_EVT_HW_BP
- hardware breakpoint
- WDB_EVT_CTX_EXIT
- context exit
- WDB_EVT_CTX_START
- context creation
All possible event types are enumerated by WDB_EVT_TYPE:
typedef enum wdb_evt_type /* type of event on the target */ { WDB_EVT_NONE = 0, /* no event */ WDB_EVT_CTX_START = 1, /* context creation */ WDB_EVT_CTX_EXIT = 2, /* context exit */ WDB_EVT_BP = 3, /* breakpoint */ WDB_EVT_HW_BP = 4, /* hardware breakpoint */ WDB_EVT_WP = 5, /* watchpoint */ WDB_EVT_EXC = 6, /* exception */ WDB_EVT_VIO_WRITE = 7, /* virtual I/O write */ WDB_EVT_CALL_RET = 8, /* function call finished */ WDB_EVT_TSFS_OP = 9, /* VIO II operation */ WDB_EVT_USER = 10 /* user event */ } WDB_EVT_TYPE;context specifies the context for which the event should be detected. Currently, contextType can be WDB_CTX_SYSTEM (for a system mode breakpoint), WDB_CTX_TASK (for a task-specific eventpoint), or WDB_CTX_ANY_TASK for a tasking breakpoint that applies to any task.
numArgs and args specify arguments to pass to the eventpoint. For WDB_EVT_CTX_EXIT and WDB_EVT_CTX_START eventpoints, numArgs should be zero. For WDB_EVT_BP, numArgs should be one or two, args[0] should be the breakpoint address and args[1] (optional) should be the breakpoint count. For WDB_EVT_HW_BP, numArgs should be three, args[0] should be the breakpoint address, args[1] should be the breakpoint count and args[2] should be the hardware breakpoint access type. For more informations on hardware breakpoint access type, refer to the WTX_EVENTPOINT_ADD_2 documentation.
action is set to the appropriate action to perform when the breakpoint is hit as defined by the structures WDB_ACTION and WDB_ACTION_TYPE in wdb.h.
The return value is an eventpoint ID, which is a handle to the eventpoint.
- 1.
- Context-specific eventpoints are automatically deleted when the context exits. Otherwise eventpoints are persistent until WDB_EVENTPOINT_DELETE is called to delete them.
- 2.
- Tasking breakpoints are disabled if the agent switches to external mode (by way of WDB_MODE_SET), but are reenabled if the agent switches back again to tasking mode. Similarly, external-mode breakpoints are disabled if the agent switches to tasking mode and reenabled if the agent switches back again.
- 3.
- When the eventpoint is hit, notification occurs as described in the "ASYNCHRONOUS NOTIFICATION SENT BY THE AGENT" section of the WDB man page. After being notified, the host uploads the event with the WDB_EVENT_GET procedure.
- 4.
- A hardware breakpoints can generate WDB_EVT_BP if it is an instruction hardware breakpoint or WDB_EVT_WP if it is a data access breakpoint.
- WDB_ERR_INVALID_EVENT
- There is no handler for the specified event type.
- WDB and RPC errors
- As described in the "REPLY ERRORS" section of the WDB man page.
WDB_EVENTPOINT_DELETE - delete an eventpoint
INPUT: WDB_EVTPT_DEL_DESC OUTPUT: (
This routine deletes the eventpoint specified by WDB_EVTPT_DEL_DESC:
typedef struct wdb_evtpt_del_desc /* how to delete an eventpoint */ { WDB_EVT_TYPE evtType; /* type of event */ TGT_ADDR_T evtptId; /* eventpoint ID */ } WDB_EVTPT_DEL_DESC;evtType specifies the type of eventpoint to delete. evtptId specifies the eventpoint to delete. (-1 means delete all eventpoints of the given type.)
Context-specific eventpoints are automatically deleted when the context exits. Otherwise eventpoints are persistent until WDB_EVENTPOINT_DELETE is called to delete them.
- WDB_ERR_INVALID_EVENTPOINT
- The eventpoint specified does not exist.
- WDB and RPC errors
- As described in the "REPLY ERRORS" section of the WDB man page.
WDB_EVENT_GET - upload an event from the target
INPUT: ) OUTPUT: INPUT:
This routine uploads an asynchronous target event to the host. The return value, WDB_EVT_DATA, is:
typedef struct wdb_evt_data /* reply to a WDB_EVENT_GET */ { WDB_EVT_TYPE evtType; /* event type detected */ union /* eventType specific info */ { WDB_MEM_XFER vioWriteInfo; /* vio write event data */ WDB_CALL_RET_INFO callRetInfo; /* call return event data */ WDB_EVT_INFO evtInfo; /* any other event info */ } eventInfo; } WDB_EVT_DATA;The type of event uploaded can be determined by the value of evtType.
It is not necessary to poll for target events. Notification of events is given as described in the "ASYNCHRONOUS NOTIFICATION SENT BY THE AGENT" section of the WDB man page. Call WDB_EVENT_GET to retrieve the event data after being notified that an event has occurred.
- WDB and RPC errors
- As described in the "REPLY ERRORS" section of the WDB man page.
WDB_FUNC_CALL - call a function on the target
INPUT: WDB_CTX_CREATE_DESC OUTPUT: UINT32
This routine calls a function on the target. The call is not made directly by the WDB agent, but rather from a task created for the purpose. The WDB_CTX_CREATE_DESC structure describes how to create the context for invoking the function:
typedef struct wdb_ctx_create_desc /* how to create a context */ { WDB_CTX_TYPE contextType; /* task or system context */ /* the following are used for task and system contexts */ TGT_ADDR_T stackBase; /* bottom of stack (NULL = malloc) */ UINT32 stackSize; /* stack size */ TGT_ADDR_T entry; /* context entry point */ TGT_INT_T args[10]; /* arguments */ /* the following are only used for task contexts */ WDB_STRING_T name; /* name */ TGT_INT_T priority; /* priority */ TGT_INT_T options; /* options */ TGT_INT_T redirIn; /* redirect input file (or 0) */ TGT_INT_T redirOut; /* redirect output file (or 0) */ TGT_INT_T redirErr; /* redirect error output file (or 0) */ } WDB_CTX_CREATE_DESC;The return value is the task ID of the task which executes the function. The actual return value of the function is passed back to the host as an asynchronous event of event type WDB_EVT_CALL_RET. See WDB_EVENT_GET for details.
- WDB_ERR_AGENT_MODE
- This command cannot be executed in system mode.
- WDB_ERR_NO_RT_PROC
- The agent does not support this service.
- WDB_ERR_RT_ERROR
- The runtime callouts failed.
- WDB and RPC errors
- As described in the "REPLY ERRORS" section of the WDB man page.
WDB_MEM_CACHE_TEXT_UPDATE - synchronize cache after writing to the target
INPUT: WDB_MEM_REGION OUTPUT: (
This routine is used to synchronize the data and instruction caches after writing text to the target. WDB_MEM_REGION defines the input parameters:
typedef struct wdb_mem_region /* a region of target memory */ { TGT_ADDR_T baseAddr; /* memory region base address */ TGT_INT_T numBytes; /* memory region size */ UINT32 param; /* proc dependent parameter */ } WDB_MEM_REGION;baseAddr and numBytes specify the region of memory to update.
- WDB_ERR_MEM_ACCES
- The memory region is invalid.
- WDB and RPC errors
- As described in the "REPLY ERRORS" section of the WDB man page.
WDB_MEM_CHECKSUM - checksum a block of target memory
INPUT: WDB_MEM_REGION OUTPUT: UINT32
This request performs a standard TCP/IP checksum (it sums 16-bit words using one-compliment arithmetic and returns the one-compliment of the result).
typedef struct wdb_mem_region /* a region of target memory */ { TGT_ADDR_T baseAddr; /* memory region base address */ TGT_INT_T numBytes; /* memory region size */ UINT32 param; /* proc dependent parameter */ } WDB_MEM_REGION;where baseAddr and numBytes specify the source region. The checksum is returned as a 32-bit integer.
- WDB_ERR_MEM_ACCES
- The target memory cannot be read.
- WDB and RPC errors
- As described in the "REPLY ERRORS" section of the WDB man page.
WDB_MEM_FILL - fill target memory with a pattern
INPUT: WDB_MEM_REGION OUTPUT: (
This request fills the specified area of target memory with a pattern. The input parameter is WDB_MEM_REGION:
typedef struct wdb_mem_region /* a region of target memory */ { TGT_ADDR_T baseAddr; /* memory region base address */ TGT_INT_T numBytes; /* memory region size */ UINT32 param; /* proc dependent parameter */ } WDB_MEM_REGION;baseAddr and numBytes specify the region of target memory to fill. param specifies the 4-byte pattern used to fill the region.
- WDB_ERR_MEM_ACCES
- The target memory cannot be written.
- WDB and RPC errors
- As described in the "REPLY ERRORS" section of the WDB man page.
WDB_MEM_MOVE - move memory on the target
INPUT: WDB_MEM_REGION OUTPUT: (
This routine requests the agent to move the contents of the specified area of memory to another memory location. WDB_MEM_REGION specifies the various parameters:
typedef struct wdb_mem_region /* a region of target memory */ { TGT_ADDR_T baseAddr; /* memory region base address */ TGT_INT_T numBytes; /* memory region size */ UINT32 param; /* proc dependent parameter */ } WDB_MEM_REGION;where baseAddr and numBytes specify the source region and param specifies where to move the contents to.
- WDB_ERR_MEM_ACCES
- The target memory cannot be read/written.
- WDB and RPC errors
- As described in the "REPLY ERRORS" section of the WDB man page.
WDB_MEM_PROTECT - write enable/disable a region of target memory
INPUT: WDB_MEM_REGION OUTPUT: (
This request enables or disables write protection for a region of target memory. The input parameters are contained in WDB_MEM_REGION:
typedef struct wdb_mem_region /* a region of target memory */ { TGT_ADDR_T baseAddr; /* memory region base address */ TGT_INT_T numBytes; /* memory region size */ UINT32 param; /* proc dependent parameter */ } WDB_MEM_REGION;baseAddr and numBytes specify the region of target memory affected. To write-enable the region, set param to 0. To write-protect the region, set param to a non-zero value.
This routine will affect an entire MMU page on the target.
- WDB_ERR_NO_RT_PROC
- The target runtime has no procedure to support write protection.
- WDB_ERR_MEM_ACCES
- The protection routine failed.
- WDB and RPC errors
- As described in the "REPLY ERRORS" section of the WDB man page.
WDB_MEM_READ - read memory from the target
INPUT: WDB_MEM_REGION OUTPUT: WDB_MEM_XFER
This request reads the contents of a specified target memory region to a host buffer. The region to read is specified by WDB_MEM_REGION:
typedef struct wdb_mem_region /* a region of target memory */ { TGT_ADDR_T baseAddr; /* memory region base address */ TGT_INT_T numBytes; /* memory region size */ UINT32 param; /* proc dependent parameter */ } WDB_MEM_REGION;where baseAddr is the starting address and numBytes is the number of bytes to read.
The memory is returned in WDB_MEM_XFER:
typedef struct wdb_mem_xfer /* transfer a block of memory */ { WDB_OPQ_DATA_T source; /* data to transfer */ TGT_ADDR_T destination; /* requested destination */ TGT_INT_T numBytes; /* number of bytes transferred */ } WDB_MEM_XFER;This structure should be initialized to point to a host buffer (or zero to malloc).
- WDB_ERR_MEM_ACCES
- The target memory cannot be read.
- WDB and RPC errors
- As described in the "REPLY ERRORS" section of the WDB man page.
WDB_MEM_SCAN - scan a block of target memory for a pattern
INPUT: WDB_MEM_SCAN_DESC OUTPUT: TGT_ADDR_T
This routine scans a block of target memory for a pattern. The input parameters are specified in WDB_MEM_SCAN_DESC:
typedef struct wdb_mem_scan_desc { WDB_MEM_REGION memRegion; /* region of memory to scan */ WDB_MEM_XFER memXfer; /* pattern to scan for */ } WDB_MEM_SCAN_DESC;where WDB_MEM_REGION is:
typedef struct wdb_mem_region /* a region of target memory */ { TGT_ADDR_T baseAddr; /* memory region base address */ TGT_INT_T numBytes; /* memory region size */ UINT32 param; /* proc dependent parameter */ } WDB_MEM_REGION;and WDB_MEM_XFER is:
typedef struct wdb_mem_xfer /* transfer a block of memory */ { WDB_OPQ_DATA_T source; /* data to transfer */ TGT_ADDR_T destination; /* requested destination */ TGT_INT_T numBytes; /* number of bytes transferred */ } WDB_MEM_XFER;memRegion specifies the region of target memory to search and memXfer specifies the pattern to search for. If numBytes is greater than 0, search forwards. Otherwise a backwards search is performed. If param is equal to 0, the search tries to match the pattern specified by source. Otherwise the search continues until the pattern does not match.
The return value is the address at which the match was found. TGT_ADDR_T is a type defined in host.h.
- WDB_ERR_MEM_ACCES
- The target memory cannot be read.
- WDB_ERR_NOT_FOUND
- The pattern cannot be found.
- WDB and RPC errors
- As described in the "REPLY ERRORS" section of the WDB man page.
WDB_MEM_WRITE - write the contents of host memory to target memory
INPUT: WDB_MEM_XFER OUTPUT: (
This request writes from host memory to target memory. The source is specified by WDB_MEM_XFER:
typedef struct wdb_mem_xfer /* transfer a block of memory */ { WDB_OPQ_DATA_T source; /* data to transfer */ TGT_ADDR_T destination; /* requested destination */ TGT_INT_T numBytes; /* number of bytes transferred */ } WDB_MEM_XFER;source is set to the address of a memory block on the host. numBytes indicates the number of bytes to transfer. destination points to a target address to which the memory contents should be transferred.
- WDB_ERR_MEM_ACCES
- The target memory cannot be written.
- WDB and RPC errors
- As described in the "REPLY ERRORS" section of the WDB man page.
WDB_MODE_GET - get the agent mode
INPUT: ) OUTPUT: INPUT:
This request gets the agent mode. The return value can be either:
- WDB_MODE_TASK
- the agent runs as a task.
- WDB_MODE_EXTERN
- the agent runs in external mode.
- WDB and RPC errors
- As described in the "REPLY ERRORS" section of the WDB man page.
WDB_MODE_SET - set the agent mode
INPUT: UINT32 OUTPUT: (
This request sets the agent mode. The input parameter can be either:
- WDB_MODE_TASK
- the agent runs as a task.
- WDB_MODE_EXTERN
- the agent runs in external mode.
The agent can only perform external mode debugging if it is communicating using a driver that supports polled mode.
- WDB_ERR_AGENT_MODE
- The requested mode is not supported by the agent.
- WDB and RPC errors
- As described in the "REPLY ERRORS" section of the WDB man page.
WDB_REGS_GET - get the registers of a context on the target
INPUT: WDB_REG_READ_DESC OUTPUT: WDB_MEM_XFER
This routine gets the registers of the context specified by WDB_REG_READ_DESC:
typedef struct wdb_reg_read_desc /* register data to read */ { WDB_REG_SET_TYPE regSetType; /* type of register set to read */ WDB_CTX context; /* context associated with registers */ WDB_MEM_REGION memRegion; /* subregion of the register block */ } WDB_REG_READ_DESC;where WDB_CTX is:
typedef struct wdb_ctx /* a particular context */ { WDB_CTX_TYPE contextType; /* type of context */ UINT32 contextId; /* context ID */ } WDB_CTX;If contextType is WDB_CTX_SYSTEM the routine gets the VxWorks registers at the time the system-mode agent last stopped the system. (This only makes sense if you are doing external-mode debugging.) Otherwise the routine gets the registers of task contextId. regSetType determines the type of registers to get as specified by:
typedef enum wdb_reg_set_type /* a type of register set */ { WDB_REG_SET_IU = 0, /* integer unit register set */ WDB_REG_SET_FPU = 1, /* floating point unit register set */ WDB_REG_SET_MMU = 2, /* memory management unit reg set */ WDB_REG_SET_CU = 3, /* cache unit register set */ WDB_REG_SET_TPU = 4, /* timer processor unit register set */ WDB_REG_SET_SYS = 5 /* system registers */ } WDB_REG_SET_TYPE;Currently supported register sets include:
- WDB_REG_SET_IU
- integer unit register
- WDB_REG_SET_FPU
- floating point unit register set
The return structure WDB_MEM_XFER is:
typedef struct wdb_mem_xfer /* transfer a block of memory */ { WDB_OPQ_DATA_T source; /* data to transfer */ TGT_ADDR_T destination; /* requested destination */ TGT_INT_T numBytes; /* number of bytes transferred */ } WDB_MEM_XFER;source must point to a buffer on the host into which the contents of the register set can be copied. The register set is treated by the agent as an opaque block of memory; the bits are transferred with no swapping or other changes. The actual structure of the block is determined by the VxWorks data structures REG_SET and FPREG_SET. memRegion specifies the region within the block of memory to upload.
- WDB_ERR_INVALID_PARAMS
- The register-set type is unsupported.
- WDB_ERR_NO_RT_PROC
- The agent does not support this service.
- WDB and RPC errors
- As described in the "REPLY ERRORS" section of the WDB man page.
WDB_REGS_SET - set the registers of a context on the target
INPUT: WDB_REG_WRITE_DESC OUTPUT: (
This routine sets the registers of the context specified by WDB_REG_READ_DESC:
typedef struct wdb_reg_read_desc /* register data to read */ { WDB_REG_SET_TYPE regSetType; /* type of register set to read */ WDB_CTX context; /* context associated with registers */ WDB_MEM_REGION memRegion; /* subregion of the register block */ } WDB_REG_READ_DESC;where WDB_CTX is:
typedef struct wdb_ctx /* a particular context */ { WDB_CTX_TYPE contextType; /* type of context */ UINT32 contextId; /* context ID */ } WDB_CTX;If contextType is WDB_CTX_SYSTEM the routine sets the VxWorks registers at the time the system-mode agent last stopped the system. (This only makes sense if you are doing external mode debugging.) Otherwise the routine sets the registers of task contextId. regSetType determines the type of registers to set as specified by:
typedef enum wdb_reg_set_type /* a type of register set */ { WDB_REG_SET_IU = 0, /* integer unit register set */ WDB_REG_SET_FPU = 1, /* floating point unit register set */ WDB_REG_SET_MMU = 2, /* memory management unit reg set */ WDB_REG_SET_CU = 3, /* cache unit register set */ WDB_REG_SET_TPU = 4, /* timer processor unit register set */ WDB_REG_SET_SYS = 5 /* system registers */ } WDB_REG_SET_TYPE;Currently supported register sets include:
- WDB_REG_SET_IU
- integer unit register
- WDB_REG_SET_FPU
- floating point unit register set
The return structure WDB_MEM_XFER is:
typedef struct wdb_mem_xfer /* transfer a block of memory */ { WDB_OPQ_DATA_T source; /* data to transfer */ TGT_ADDR_T destination; /* requested destination */ TGT_INT_T numBytes; /* number of bytes transferred */ } WDB_MEM_XFER;The actual structure of the block is determined by the VxWorks data structures REG_SET and FPREG_SET. The memXfer field of WDB_REG_WRITE_DESC specifies where in the block to copy the data. The register set is treated by the agent as an opaque block of memory. source specifies a host buffer, which is copied exactly with no swapping or other changes. numBytes specifies the number of bytes of data to transfer. destination specifies the byte offset within the register block to copy to. This mechanism allows one to set all the registers at once or just a few registers at a time.
- WDB_ERR_INVALID_PARAMS
- The register-set type is unsupported.
- WDB_ERR_NO_RT_PROC
- The agent does not support this service.
- WDB and RPC errors
- As described in the "REPLY ERRORS" section of the WDB man page.
WDB_TARGET_CONNECT - connect the target server to the target agent
INPUT: ) OUTPUT: INPUT:
This routine connects the target server to the target agent. Any server can connect to the agent, but the agent only accepts requests from the last-connected host. For more details on connecting to the agent, see the section "REQUESTS SENT TO THE AGENT".
- WDB and RPC errors
- As described in the "REPLY ERRORS" section of the WDB man page.
WDB_TARGET_DISCONNECT - disconnect the target server from the target agent
INPUT: (none) OUTPUT: (
This request disconnects the target server from the target agent.
- WDB and RPC errors
- As described in the "REPLY ERRORS" section of the WDB man page.
WDB_TARGET_PING - probe the target
INPUT: (none) OUTPUT: (
This request tests the connection to the target.
- WDB and RPC errors
- As described in the "REPLY ERRORS" section of the WDB man page.
WDB_VIO_WRITE - write data to a virtual I/O channel
INPUT: WDB_MEM_XFER OUTPUT: UINT32
This routine writes data from the host to a virtual I/O channel on the target. The input parameters are supplied in WDB_MEM_XFER:
typedef struct wdb_mem_xfer /* transfer a block of memory */ { WDB_OPQ_DATA_T source; /* data to transfer */ TGT_ADDR_T destination; /* requested destination */ TGT_INT_T numBytes; /* number of bytes transferred */ } WDB_MEM_XFER;source and numBytes specify the block of memory to write to the target. destination is a virtual I/O channel number. The routine returns the number of bytes actually transferred (which could be less than numBytes if the VIO input buffer on the target is full). See the man page for wdbVioDrv for details on how to open a VIO channel on the target.
There is no WDB_VIO_READ routine. VIO data transferred from the target to the host is uploaded as an asynchronous event (with WDB_EVENT_GET).
- WDB_ERR_INVALID_VIO_CHANNEL
- There is no such virtual I/O channel open on the target.
- WDB and RPC errors
- As described in the "REPLY ERRORS" section of the WDB man page.