Data Structures | Macros | Typedefs | Enumerations | Functions
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. More...
 

Typedefs

typedef struct _Eina_Debug_Session Eina_Debug_Session
 A handle used to interact with the debug daemon. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
EINA_API Eina_Debug_Sessioneina_debug_local_connect (Eina_Bool is_master)
 Connect to the local daemon. More...
 
EINA_API Eina_Debug_Sessioneina_debug_remote_connect (int port)
 Connect to remote daemon. More...
 
EINA_API void eina_debug_session_terminate (Eina_Debug_Session *session)
 Terminate the session. More...
 
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. More...
 
EINA_API Eina_Debug_Dispatch_Cb eina_debug_session_dispatch_get (Eina_Debug_Session *session)
 Get the dispatcher of a specific session. More...
 
EINA_API Eina_Bool eina_debug_dispatch (Eina_Debug_Session *session, void *buffer)
 Dispatch a given packet according to its header. More...
 
EINA_API void eina_debug_session_data_set (Eina_Debug_Session *session, void *data)
 Set data to a session. More...
 
EINA_API void * eina_debug_session_data_get (Eina_Debug_Session *session)
 Get the data attached to a session. More...
 
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. More...
 
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. More...
 
EINA_API Eina_Debug_Timer * eina_debug_timer_add (unsigned int timeout_ms, Eina_Debug_Timer_Cb cb, void *data)
 Add a timer. More...
 
EINA_API void eina_debug_timer_del (Eina_Debug_Timer *timer)
 Delete a timer. More...
 
EINA_API void eina_debug_fork_reset (void)
 Reset the eina debug system after forking. More...
 

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; \
}
#define EINA_C_ARRAY_LENGTH(arr)
Macro to return the array length of a standard c array.
Definition: eina_types.h:621
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

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

Eina_Debug_Cb

A callback invoked when a specific packet is received.

Parameters
[in,out]sessionthe session
[in]srcidthe source id
[in]bufferthe packet payload data. It doesn't contain any transport information.
[in]sizethe packet payload size
Returns
True on success, false if the connection seems compromised.

◆ Eina_Debug_Opcode_Status_Cb

Eina_Debug_Opcode_Status_Cb

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]datadata pointer given when registering opcodes
[in]statusEINA_TRUE if opcodes have been received from the daemon, EINA_FALSE otherwise.

◆ Eina_Debug_Dispatch_Cb

Eina_Debug_Dispatch_Cb

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

Parameters
[in,out]sessionthe session
[in]bufferthe 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_mastertrue 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]portthe 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]sessionthe session to terminate

References eina_lock_release(), and eina_lock_take().

◆ 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]sessionthe session
[in]disp_cbthe 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]sessionthe 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]sessionthe session
[in]bufferthe 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]sessionthe session
[in]datathe 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]sessionthe 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]sessionthe session
[in]opsthe operations to register
[in]status_cba function to call when the opcodes are received
[in]status_datathe 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]sessionthe session to use to send the packet
[in]dest_idthe destination id to send the packet to
[in]opthe opcode for this packet
[in]datapayload to send
[in]sizepayload size
Returns
The number of sent bytes.

References EINA_DEBUG_OPCODE_INVALID, eina_spinlock_release(), eina_spinlock_take(), 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_mstimeout in ms
[in]cbcallback to call when the timeout is reached
[in]datauser data
Returns
The timer handle, NULL on error.

References eina_spinlock_release(), eina_spinlock_take(), and EINA_TRUE.

◆ eina_debug_timer_del()

EINA_API void eina_debug_timer_del ( Eina_Debug_Timer *  timer)

Delete a timer.

Parameters
[in,out]timerthe 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(), eina_list_remove_list(), eina_spinlock_release(), and eina_spinlock_take().

◆ 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().