Data Structures | Macros | Typedefs | Enumerations | Functions
Eina_Debug

Data Structures

struct  Eina_Debug_Packet_Header
 
struct  Eina_Debug_Opcode
 

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

void eina_debug_disable (void)
 Disable debugging. More...
 
Eina_Debug_Sessioneina_debug_local_connect (Eina_Bool is_master)
 Connect to the local daemon. More...
 
Eina_Debug_Sessioneina_debug_remote_connect (int port)
 Connect to remote daemon. More...
 
void eina_debug_session_terminate (Eina_Debug_Session *session)
 Terminate the session. More...
 
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_Debug_Dispatch_Cb eina_debug_session_dispatch_get (Eina_Debug_Session *session)
 Get the dispatcher of a specific session. More...
 
Eina_Bool eina_debug_dispatch (Eina_Debug_Session *session, void *buffer)
 Dispatch a given packet according to its header. More...
 
void eina_debug_session_data_set (Eina_Debug_Session *session, void *data)
 Set data to a session. More...
 
void * eina_debug_session_data_get (Eina_Debug_Session *session)
 Get the data attached to a session. More...
 
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...
 
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_Debug_Timer * eina_debug_timer_add (unsigned int timeout_ms, Eina_Debug_Timer_Cb cb, void *data)
 Add a timer. More...
 
void eina_debug_timer_del (Eina_Debug_Timer *timer)
 Delete a timer. More...
 

Detailed Description

Macro Definition Documentation

◆ EINA_DEBUG_OPCODES_ARRAY_DEFINE

#define EINA_DEBUG_OPCODES_ARRAY_DEFINE (   Name,
  ... 
)
Value:
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:522
Definition: eina_debug.h:151

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.

Referenced by eina_evlog_stop().

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
sessionthe session
srcidthe source id
bufferthe packet payload data. It doesn't contain any transport information.
sizethe packet payload size

return 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
datadata pointer given when registering opcodes
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
sessionthe session
bufferthe packet received

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

return 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()

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_Debug_Session* eina_debug_local_connect ( Eina_Bool  is_master)

Connect to the local daemon.

Parameters
is_mastertrue if the application is a debugger. EINA_FALSE otherwise.
Returns
the session on success or NULL otherwise

References eina_debug_dispatch(), eina_debug_remote_connect(), EINA_TRUE, fcntl(), and Eina_Debug_Packet_Header::opcode.

Referenced by eina_debug_session_data_get().

◆ eina_debug_remote_connect()

Eina_Debug_Session* eina_debug_remote_connect ( int  port)

Connect to remote daemon.

This function connects to localhost:port.

Parameters
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()

void eina_debug_session_terminate ( Eina_Debug_Session session)

Terminate the session.

Parameters
sessionthe session to terminate

◆ eina_debug_session_dispatch_override()

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
sessionthe session the new dispatcher for the given session

References eina_debug_dispatch().

◆ eina_debug_session_dispatch_get()

Eina_Debug_Dispatch_Cb eina_debug_session_dispatch_get ( Eina_Debug_Session session)

◆ eina_debug_dispatch()

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 into the packet and invokes the correct callback according to the opcode. This is the default dispatcher.

Parameters
sessionthe session
bufferthe packet

return 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_local_connect(), eina_debug_session_dispatch_get(), and eina_debug_session_dispatch_override().

◆ eina_debug_session_data_set()

void eina_debug_session_data_set ( Eina_Debug_Session session,
void *  data 
)

Set data to a session.

Parameters
sessionthe session
datathe data to set

◆ eina_debug_session_data_get()

void* eina_debug_session_data_get ( Eina_Debug_Session session)

Get the data attached to a session.

Parameters
sessionthe session
Returns
the data of the session

References eina_debug_local_connect(), EINA_FALSE, eina_spinlock_new(), eina_spinlock_release(), eina_spinlock_take(), and EINA_TRUE.

◆ eina_debug_opcodes_register()

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
sessionthe session
opsthe operations to register
status_cba function to call when the opcodes are received
status_datathe data to give to status_cb

References EINA_FALSE, and eina_list_append().

Referenced by eina_evlog_stop().

◆ eina_debug_session_send()

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
sessionthe session to use to send the packet
dest_idthe destination id to send the packet to
opthe opcode for this packet
datapayload to send
sizepayload size
Returns
the number of sent bytes

References alloca(), EINA_DEBUG_OPCODE_HELLO, EINA_DEBUG_OPCODE_INVALID, eina_debug_session_send(), eina_spinlock_release(), eina_spinlock_take(), Eina_Debug_Packet_Header::opcode, and Eina_Debug_Packet_Header::size.

Referenced by eina_debug_session_dispatch_get(), eina_debug_session_send(), and eina_evlog_stop().

◆ eina_debug_timer_add()

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

Add a timer.

Parameters
timeout_mstimeout in ms
cbcallback to call when the timeout is reached
datauser data
Returns
the timer handle, NULL on error

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

◆ eina_debug_timer_del()

void eina_debug_timer_del ( Eina_Debug_Timer *  timer)

Delete a timer.

Parameters
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_free(), eina_spinlock_new(), eina_spinlock_release(), eina_spinlock_take(), EINA_TRUE, and pipe.