JerryScript debugger transport interface

The transport interface support allows dynamic selection of transportation layers which can encode/decode or send/receive messages transmitted between the debugger client and server.

Types

jerry_debugger_transport_receive_context_t

Summary

This context represents the current status of processing received data. The final state is returned by jerry_debugger_transport_receive and must be passed to jerry_debugger_transport_receive_completed after the message is processed.

Prototype

  1. typedef struct
  2. {
  3. uint8_t *buffer_p; /**< buffer for storing the received data */
  4. size_t received_length; /**< number of currently received bytes */
  5. uint8_t *message_p; /**< start of the received message */
  6. size_t message_length; /**< length of the received message */
  7. size_t message_total_length; /**< total length for datagram protocols,
  8. * 0 for stream protocols */
  9. } jerry_debugger_transport_receive_context_t;

jerry_debugger_transport_header_t

Summary

Shared header for each transport interface. It mostly contains callback functions used by the JerryScript debugger server.

Prototype

  1. typedef struct jerry_debugger_transport_layer_t
  2. {
  3. /* The following fields must be filled before calling jerry_debugger_transport_add(). */
  4. jerry_debugger_transport_close_t close; /**< close connection callback */
  5. jerry_debugger_transport_send_t send; /**< send data callback */
  6. jerry_debugger_transport_receive_t receive; /**< receive data callback */
  7. /* The following fields are filled by jerry_debugger_transport_add(). */
  8. struct jerry_debugger_transport_layer_t *next_p; /**< next transport layer */
  9. } jerry_debugger_transport_header_t;

jerry_debugger_transport_close_t

Summary

Called when the connection is closed. Must release all resources (including the memory area for the transport interface) allocated for the transport interface.

Prototype

  1. typedef void (*jerry_debugger_transport_close_t) (struct jerry_debugger_transport_interface_t *header_p);

jerry_debugger_transport_send_t

Summary

Called when a message needs to be sent. Must either transmit the message or call the header_p->next_p->send() method.

Prototype

  1. typedef bool (*jerry_debugger_transport_send_t) (struct jerry_debugger_transport_interface_t *header_p,
  2. uint8_t *message_p, size_t message_length);

jerry_debugger_transport_receive_t

Summary

Called during message processing. If messages are available it must return with the next message.

Prototype

  1. typedef bool (*jerry_debugger_transport_receive_t) (struct jerry_debugger_transport_interface_t *header_p,
  2. jerry_debugger_transport_receive_context_t *context_p);

Transport interface API functions

jerry_debugger_transport_add

Summary

Add a new interface to the transporation interface chain. The interface will be the first item of the interface chain.

Prototype

  1. void jerry_debugger_transport_add (jerry_debugger_transport_header_t *header_p,
  2. size_t send_message_header_size, size_t max_send_message_size,
  3. size_t receive_message_header_size, size_t max_receive_message_size);
  • header_p: header of a transporation interface.
  • send_message_header_size: size of the outgoing message header, can be 0.
  • max_send_message_size: maximum outgoing message size supported by the interface.
  • receive_message_header_size: size of the incoming message header, can be 0.
  • max_receive_message_size: maximum incoming message size supported by the interface.

jerry_debugger_transport_start

Summary

Starts the communication to the debugger client. Must be called after the connection is successfully established.

Prototype

  1. void jerry_debugger_transport_start (void);

jerry_debugger_transport_is_connected

Summary

Tells whether a debugger client is connected to the debugger server.

Prototype

  1. bool jerry_debugger_transport_is_connected (void);
  • return value: true, if a client is connected, false otherwise.

jerry_debugger_transport_close

Summary

Disconnect from the current debugger client. It does nothing if a client is not connected.

Prototype

  1. void jerry_debugger_transport_close (void);

jerry_debugger_transport_send

Summary

Send message to the client.

Prototype

  1. bool jerry_debugger_transport_send (const uint8_t *message_p, size_t message_length);
  • message_p: message to be sent.
  • message_length: message length in bytes.
  • return value: true, if a client is still connected, false otherwise.

jerry_debugger_transport_receive

Summary

Receive message from the client.

Prototype

  1. bool jerry_debugger_transport_receive (jerry_debugger_transport_receive_context_t *context_p);

jerry_debugger_transport_receive_completed

Summary

Must be called after jerry_debugger_transport_receive returns with a valid message. Must not be called otherwise.

Prototype

  1. void jerry_debugger_transport_receive_completed (jerry_debugger_transport_receive_context_t *context_p);

jerry_debugger_transport_sleep

Summary

Can be used to wait for incoming messages. Currently the delay is 100ms.

Prototype

  1. void jerry_debugger_transport_sleep (void);