Eina_Debug

## Data Structures

struct | Eina_Debug_Packet_Header
| Header of Eina Debug packet. More...
struct | Eina_Debug_Opcode
| Structure to describe information for an opcode. More...

## Macros

#define | EINA_DEBUG_OPCODES_ARRAY_DEFINE(Name, ...)
| Helper for creating global opcodes arrays.

## Typedefs

typedef struct _Eina_Debug_Session | Eina_Debug_Session
| A handle used to interact with the debug daemon.
typedef Eina_Bool(* | Eina_Debug_Cb) (Eina_Debug_Session *session, int srcid, void *buffer, int size)
| A callback invoked when a specific packet is received.
typedef void(* | Eina_Debug_Opcode_Status_Cb) (void *data, Eina_Bool status)
| When the opcodes ids are retrieved, this callback is invoked with a true status.
typedef Eina_Bool(* | Eina_Debug_Dispatch_Cb) (Eina_Debug_Session *session, void *buffer)
| Dispatcher callback prototype used to override the default dispatcher of a session.
typedef Eina_Bool(* | Eina_Debug_Timer_Cb) (void *)
| A callback for a timer.
typedef struct _Eina_Debug_Timer | Eina_Debug_Timer

## Enumerations

enum | { EINA_DEBUG_OPCODE_INVALID = -1 , EINA_DEBUG_OPCODE_REGISTER = 0 , EINA_DEBUG_OPCODE_HELLO = 1 }

## Functions

EINA_API void | eina_debug_disable (void)
| Disable debugging.
EINA_API Eina_Debug_Session * | eina_debug_local_connect (Eina_Bool is_master)
| Connect to the local daemon.
EINA_API Eina_Debug_Session * | eina_debug_remote_connect (int port)
| Connect to remote daemon.
EINA_API void | eina_debug_session_terminate (Eina_Debug_Session *session)
| Terminate the session.
EINA_API void | eina_debug_session_dispatch_override (Eina_Debug_Session *session, Eina_Debug_Dispatch_Cb disp_cb)
| Override the dispatcher of a specific session.
EINA_API Eina_Debug_Dispatch_Cb | eina_debug_session_dispatch_get (Eina_Debug_Session *session)
| Get the dispatcher of a specific session.
EINA_API Eina_Bool | eina_debug_dispatch (Eina_Debug_Session *session, void *buffer)
| Dispatch a given packet according to its header.
EINA_API void | eina_debug_session_data_set (Eina_Debug_Session *session, void *data)
| Set data to a session.
EINA_API void * | eina_debug_session_data_get (Eina_Debug_Session *session)
| Get the data attached to a session.
EINA_API void | eina_debug_opcodes_register (Eina_Debug_Session *session, const Eina_Debug_Opcode ops[], Eina_Debug_Opcode_Status_Cb status_cb, void *status_data)
| Register opcodes to a session.
EINA_API int | eina_debug_session_send (Eina_Debug_Session *session, int dest_id, int op, void *data, int size)
| Send a packet to the given destination.
EINA_API Eina_Debug_Timer * | eina_debug_timer_add (unsigned int timeout_ms, Eina_Debug_Timer_Cb cb, void *data)
| Add a timer.
EINA_API void | eina_debug_timer_del (Eina_Debug_Timer *timer)
| Delete a timer.
EINA_API void | eina_debug_fork_reset (void)
| Reset the eina debug system after forking.

## Detailed Description

## Macro Definition Documentation

## EINA_DEBUG_OPCODES_ARRAY_DEFINE

#define EINA_DEBUG_OPCODES_ARRAY_DEFINE | ( |  | Name,
|  |  | ... )

Value:
static Eina_Debug_Opcode * \
Name(void) \
{ \
Eina_Debug_Opcode tmp[] = { __VA_ARGS__ }; \
static Eina_Debug_Opcode internal[EINA_C_ARRAY_LENGTH(tmp) + 1] = \
{ { 0, 0, 0 } }; \
if (internal[0].opcode_name == NULL) \
{ \
memcpy(internal, tmp, sizeof(tmp)); \
} \
return internal; \
}
EINA_C_ARRAY_LENGTH
#define EINA_C_ARRAY_LENGTH(arr)
Macro to return the array length of a standard c array.
Definition eina_types.h:621
Eina_Debug_Opcode
Structure to describe information for an opcode.
Definition eina_debug.h:152

Helper for creating global opcodes arrays.

The problem is on windows where you can't declare a static array with external symbols in it, because the addresses are only known at runtime.

## Typedef Documentation

## Eina_Debug_Session

typedef struct _Eina_Debug_Session Eina_Debug_Session

A handle used to interact with the debug daemon.

It contains all the information related to this connection and needed to send/receive/dispatch/...

## Eina_Debug_Cb

typedef Eina_Bool(* Eina_Debug_Cb) (Eina_Debug_Session *session, int srcid, void *buffer, int size)

A callback invoked when a specific packet is received.

Parameters

  [in,out] | session | the session
  [in] | srcid | the source id
  [in] | buffer | the packet payload data. It doesn't contain any transport information.
  [in] | size | the packet payload size

Returns
  True on success, false if the connection seems compromised.

## Eina_Debug_Opcode_Status_Cb

typedef void(* Eina_Debug_Opcode_Status_Cb) (void *data, Eina_Bool status)

When the opcodes ids are retrieved, this callback is invoked with a true status.

When a disconnection to the daemon is happening, the opcodes ids are set as invalid and this callback is invoked with a false status. The upper layer should not try to send more requests until a new connection is established.

Parameters

  [in,out] | data | data pointer given when registering opcodes
  [in] | status | EINA_TRUE if opcodes have been received from the daemon, EINA_FALSE otherwise.

## Eina_Debug_Dispatch_Cb

typedef Eina_Bool(* Eina_Debug_Dispatch_Cb) (Eina_Debug_Session *session, void *buffer)

Dispatcher callback prototype used to override the default dispatcher of a session.

Parameters

  [in,out] | session | the session
  [in] | buffer | the packet received

The given packet is the entire data received, including the header.

Returns
  The return result of the invoked callback.

## Enumeration Type Documentation

## anonymous enum

anonymous enum

Enumerator
EINA_DEBUG_OPCODE_INVALID | Invalid opcode value.
EINA_DEBUG_OPCODE_REGISTER | Opcode used to register other opcodes.
EINA_DEBUG_OPCODE_HELLO | Opcode used to send greetings to the daemon.

## Function Documentation

## eina_debug_disable()

EINA_API void eina_debug_disable | ( | void |  | ) |

Disable debugging.

Useful for applications that don't want debugging. The debug daemon is one of them. Need to be invoked before eina_init. Otherwise it won't have any effect.

References EINA_TRUE.

## eina_debug_local_connect()

EINA_API Eina_Debug_Session * eina_debug_local_connect | ( | Eina_Bool | is_master | ) |

Connect to the local daemon.

Parameters

  [in] | is_master | true if the application is a debugger. EINA_FALSE otherwise.

Returns
  The session on success or NULL otherwise.

References eina_debug_remote_connect(), and fcntl().

## eina_debug_remote_connect()

EINA_API Eina_Debug_Session * eina_debug_remote_connect | ( | int | port | ) |

Connect to remote daemon.

This function connects to localhost:port.

Parameters

  [in] | port | the port to connect to

Returns
  The session on success or NULL otherwise.

References fcntl().

Referenced by eina_debug_local_connect().

## eina_debug_session_terminate()

EINA_API void eina_debug_session_terminate | ( | Eina_Debug_Session * | session | ) |

Terminate the session.

Parameters

  [in,out] | session | the session to terminate

## eina_debug_session_dispatch_override()

EINA_API void eina_debug_session_dispatch_override | ( | Eina_Debug_Session * | session,
|  | Eina_Debug_Dispatch_Cb | disp_cb )

Override the dispatcher of a specific session.

For example, it can be used to forward a packet to the main thread and to use the default dispatcher there. All the packets received in this session will use this dispatcher.

Parameters

  [in,out] | session | the session
  [in] | disp_cb | the new dispatcher for the given session

References eina_debug_dispatch().

## eina_debug_session_dispatch_get()

EINA_API Eina_Debug_Dispatch_Cb eina_debug_session_dispatch_get | ( | Eina_Debug_Session * | session | ) |

Get the dispatcher of a specific session.

Parameters

  [in,out] | session | the session

Returns
  The session dispatcher.

## eina_debug_dispatch()

EINA_API Eina_Bool eina_debug_dispatch | ( | Eina_Debug_Session * | session,
|  | void * | buffer )

Dispatch a given packet according to its header.

This function checks the header contained in the packet and invokes the correct callback according to the opcode. This is the default dispatcher.

Parameters

  [in,out] | session | the session
  [in] | buffer | the packet

Returns
  True on success, false if the connection seems compromised.

References EINA_FALSE, EINA_LIST_FOREACH, EINA_TRUE, Eina_Debug_Packet_Header::opcode, and Eina_Debug_Packet_Header::size.

Referenced by eina_debug_session_dispatch_override().

## eina_debug_session_data_set()

EINA_API void eina_debug_session_data_set | ( | Eina_Debug_Session * | session,
|  | void * | data )

Set data to a session.

Parameters

  [in,out] | session | the session
  [in] | data | the data to set

## eina_debug_session_data_get()

EINA_API void * eina_debug_session_data_get | ( | Eina_Debug_Session * | session | ) |

Get the data attached to a session.

Parameters

  [in,out] | session | the session

Returns
  The data of the session.

## eina_debug_opcodes_register()

EINA_API void eina_debug_opcodes_register | ( | Eina_Debug_Session * | session,
|  | const Eina_Debug_Opcode | ops[],
|  | Eina_Debug_Opcode_Status_Cb | status_cb,
|  | void * | status_data )

Register opcodes to a session.

This function registers opcodes for the given session. If the session is not connected, the request is not sent to the daemon. Otherwise, the request for the opcodes ids is sent. On the reception from the daemon, status_cb function is invoked to inform the requester that the opcodes can now be used.

Parameters

  [in,out] | session | the session
  [in] | ops | the operations to register
  [in] | status_cb | a function to call when the opcodes are received
  [in] | status_data | the data to give to status_cb

References EINA_FALSE, and eina_list_append().

## eina_debug_session_send()

EINA_API int eina_debug_session_send | ( | Eina_Debug_Session * | session,
|  | int | dest_id,
|  | int | op,
|  | void * | data,
|  | int | size )

Send a packet to the given destination.

The packet will be treated by the debug thread itself.

Parameters

  [in,out] | session | the session to use to send the packet
  [in] | dest_id | the destination id to send the packet to
  [in] | op | the opcode for this packet
  [in] | data | payload to send
  [in] | size | payload size

Returns
  The number of sent bytes.

References EINA_DEBUG_OPCODE_INVALID, Eina_Debug_Packet_Header::opcode, and Eina_Debug_Packet_Header::size.

## eina_debug_timer_add()

EINA_API Eina_Debug_Timer * eina_debug_timer_add | ( | unsigned int | timeout_ms,
|  | Eina_Debug_Timer_Cb | cb,
|  | void * | data )

Add a timer.

Parameters

  [in] | timeout_ms | timeout in ms
  [in] | cb | callback to call when the timeout is reached
  [in] | data | user data

Returns
  The timer handle, NULL on error.

References EINA_TRUE.

## eina_debug_timer_del()

EINA_API void eina_debug_timer_del | ( | Eina_Debug_Timer * | timer | ) |

Delete a timer.

Parameters

  [in,out] | timer | the timer to delete

If the timer reaches the end and has not be renewed, trying to delete it will lead to a crash, as it has already been deleted internally.

References eina_list_data_find_list(), and eina_list_remove_list().

## eina_debug_fork_reset()

EINA_API void eina_debug_fork_reset | ( | void |  | ) |

Reset the eina debug system after forking.

Call this any time the application forks

Since
  1.21

References EINA_FALSE, and EINA_TRUE.

Referenced by ecore_fork_reset().