Stackdb
Stackdb is a stackable, multi-target and -level source debugger and memory forensics library.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Macros | Functions | Variables
monitor.c File Reference
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <glib.h>
#include <pthread.h>
#include <inttypes.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <assert.h>
#include "log.h"
#include "alist.h"
#include "waitpipe.h"
#include "evloop.h"
#include "monitor.h"
Include dependency graph for monitor.c:

Go to the source code of this file.

Macros

#define __M_SAFE_IO(fn, fns, fd, buf, buflen, frc)
 

Functions

void monitor_init (void)
 
void monitor_fini (void)
 
int monitor_get_unique_objid (void)
 
int monitor_lookup_objid (int objid, int *objtype, void **obj, struct monitor **monitor)
 
int __monitor_lock_objtype (int objtype)
 
int monitor_lock_objtype (int objtype)
 
int __monitor_unlock_objtype (int objtype)
 
int monitor_unlock_objtype (int objtype)
 
int monitor_unlock_objtype_unsafe (int objtype)
 
struct array_listmonitor_list_objids_by_objtype_lock_objtype (int objtype, int include_null)
 
struct array_listmonitor_list_objs_by_objtype_lock_objtype (int objtype, int include_null)
 
int monitor_lookup_objid_lock_objtype (int objid, int objtype, void **obj, struct monitor **monitor)
 
int monitor_lookup_objid_lock_objtype_and_monitor (int objid, int objtype, void **obj, struct monitor **monitor)
 
int monitor_lookup_objid_lock_monitor (int objid, int *objtype, void **obj, struct monitor **monitor)
 
int monitor_lookup_obj (void *obj, int *objtype, int *objid, struct monitor **monitor)
 
int monitor_lookup_obj_lock_monitor (void *obj, int *objtype, int *objid, struct monitor **monitor)
 
int monitor_add_obj (struct monitor *monitor, int objid, int objtype, void *obj, void *objstate)
 
int monitor_close_obj (struct monitor *monitor, void *obj, int kill, int kill_sig)
 
int monitor_close_objid (struct monitor *monitor, int objid, int kill, int kill_sig)
 
int monitor_del_obj (struct monitor *monitor, void *obj)
 
int monitor_del_objid (struct monitor *monitor, int objid)
 
int monitor_shutdown (struct monitor *monitor)
 
int monitor_destroy (struct monitor *monitor)
 
int monitor_register_objtype (int objtype, struct monitor_objtype_ops *ops, pthread_mutex_t *mutex)
 
int __monitor_recv_evh (int fd, int fdtype, void *state)
 
int __monitor_child_recv_evh (int fd, int fdtype, void *state)
 
int __safe_write (int fd, char *buf, int count)
 
int __monitor_add_primary_obj (struct monitor *monitor, int objid, int objtype, void *obj, void *objstate)
 
struct monitormonitor_create_custom (monitor_type_t type, monitor_flags_t flags, int objid, int objtype, void *obj, void *objstate, evloop_handler_t custom_recv_evh, evloop_handler_t custom_child_recv_evh)
 
int monitor_add_primary_obj (struct monitor *monitor, int objid, int objtype, void *obj, void *objstate)
 
struct monitormonitor_create (monitor_type_t type, monitor_flags_t flags, int objid, int objtype, void *obj, void *objstate)
 
int monitor_can_attach (void)
 
int monitor_can_attach_bidi (void)
 
struct monitormonitor_attach (monitor_type_t type, monitor_flags_t flags, int objtype, void *obj, void *objstate, evloop_handler_t custom_child_recv_evh, monitor_stdio_callback_t stdin_callback, void *callback_state)
 
int __monitor_send_stdin_evh (int fd, int fdtype, void *state)
 
int monitor_setup_stdin (struct monitor *monitor, char *stdin_buf, int stdin_buflen)
 
int monitor_setup_stdout (struct monitor *monitor, int maxbufsiz, char *stdout_logfile, monitor_stdio_callback_t stdout_callback, void *callback_state)
 
int monitor_setup_stderr (struct monitor *monitor, int maxbufsiz, char *stderr_logfile, monitor_stdio_callback_t stderr_callback, void *callback_state)
 
int monitor_spawn (struct monitor *monitor, char *filename, char *const argv[], char *const envp[], char *dir)
 
int monitor_is_done (struct monitor *monitor)
 
int monitor_live_children (struct monitor *monitor)
 
int monitor_live_objects (struct monitor *monitor)
 
int monitor_objects (struct monitor *monitor)
 
int monitor_run (struct monitor *monitor)
 
void monitor_store_msg_obj (struct monitor *monitor, struct monitor_msg *msg)
 
void monitor_msg_free (struct monitor_msg *msg)
 
void monitor_msg_free_save_buffer (struct monitor_msg *msg)
 
struct monitor_msgmonitor_msg_create (int objid, int id, short cmd, short seqno, int buflen, char *buf, void *msg_obj)
 
int monitor_send (struct monitor_msg *msg)
 
struct monitor_msgmonitor_recv (struct monitor *monitor)
 
int monitor_child_send (struct monitor_msg *msg, struct monitor *monitor)
 
struct monitor_msgmonitor_child_recv (struct monitor *monitor)
 

Variables

char ** environ
 

Macro Definition Documentation

#define __M_SAFE_IO (   fn,
  fns,
  fd,
  buf,
  buflen,
  frc 
)

Definition at line 2573 of file monitor.c.

Function Documentation

int __monitor_add_primary_obj ( struct monitor monitor,
int  objid,
int  objtype,
void *  obj,
void *  objstate 
)

Definition at line 1559 of file monitor.c.

int __monitor_child_recv_evh ( int  fd,
int  fdtype,
void *  state 
)

Definition at line 1138 of file monitor.c.

int __monitor_lock_objtype ( int  objtype)

Definition at line 231 of file monitor.c.

int __monitor_recv_evh ( int  fd,
int  fdtype,
void *  state 
)

Definition at line 1077 of file monitor.c.

int __monitor_send_stdin_evh ( int  fd,
int  fdtype,
void *  state 
)

Definition at line 1762 of file monitor.c.

int __monitor_unlock_objtype ( int  objtype)

Definition at line 253 of file monitor.c.

int __safe_write ( int  fd,
char *  buf,
int  count 
)

Definition at line 1191 of file monitor.c.

int monitor_add_obj ( struct monitor monitor,
int  objid,
int  objtype,
void *  obj,
void *  objstate 
)

Definition at line 554 of file monitor.c.

int monitor_add_primary_obj ( struct monitor monitor,
int  objid,
int  objtype,
void *  obj,
void *  objstate 
)

Definition at line 1576 of file monitor.c.

struct monitor* monitor_attach ( monitor_type_t  type,
monitor_flags_t  flags,
int  objtype,
void *  obj,
void *  objstate,
evloop_handler_t  custom_child_recv_evh,
monitor_stdio_callback_t  stdin_callback,
void *  callback_state 
)

Definition at line 1616 of file monitor.c.

int monitor_can_attach ( void  )

Definition at line 1603 of file monitor.c.

int monitor_can_attach_bidi ( void  )

Definition at line 1609 of file monitor.c.

struct monitor_msg* monitor_child_recv ( struct monitor monitor)

Definition at line 2914 of file monitor.c.

int monitor_child_send ( struct monitor_msg msg,
struct monitor monitor 
)

Definition at line 2798 of file monitor.c.

int monitor_close_obj ( struct monitor monitor,
void *  obj,
int  kill,
int  kill_sig 
)

Definition at line 622 of file monitor.c.

int monitor_close_objid ( struct monitor monitor,
int  objid,
int  kill,
int  kill_sig 
)

Definition at line 648 of file monitor.c.

struct monitor* monitor_create ( monitor_type_t  type,
monitor_flags_t  flags,
int  objid,
int  objtype,
void *  obj,
void *  objstate 
)

Definition at line 1594 of file monitor.c.

struct monitor* monitor_create_custom ( monitor_type_t  type,
monitor_flags_t  flags,
int  objid,
int  objtype,
void *  obj,
void *  objstate,
evloop_handler_t  custom_recv_evh,
evloop_handler_t  custom_child_recv_evh 
)

Definition at line 1411 of file monitor.c.

int monitor_del_obj ( struct monitor monitor,
void *  obj 
)

Definition at line 763 of file monitor.c.

int monitor_del_objid ( struct monitor monitor,
int  objid 
)

Definition at line 788 of file monitor.c.

int monitor_destroy ( struct monitor monitor)

Definition at line 1039 of file monitor.c.

void monitor_fini ( void  )

Definition at line 127 of file monitor.c.

int monitor_get_unique_objid ( void  )

Definition at line 161 of file monitor.c.

void monitor_init ( void  )

Definition at line 93 of file monitor.c.

int monitor_is_done ( struct monitor monitor)

Definition at line 2224 of file monitor.c.

struct array_list* monitor_list_objids_by_objtype_lock_objtype ( int  objtype,
int  include_null 
)

Definition at line 279 of file monitor.c.

struct array_list* monitor_list_objs_by_objtype_lock_objtype ( int  objtype,
int  include_null 
)

Definition at line 315 of file monitor.c.

int monitor_live_children ( struct monitor monitor)

Definition at line 2231 of file monitor.c.

int monitor_live_objects ( struct monitor monitor)

Definition at line 2241 of file monitor.c.

int monitor_lock_objtype ( int  objtype)

Definition at line 243 of file monitor.c.

int monitor_lookup_obj ( void *  obj,
int *  objtype,
int *  objid,
struct monitor **  monitor 
)

Definition at line 444 of file monitor.c.

int monitor_lookup_obj_lock_monitor ( void *  obj,
int *  objtype,
int *  objid,
struct monitor **  monitor 
)

Definition at line 456 of file monitor.c.

int monitor_lookup_objid ( int  objid,
int *  objtype,
void **  obj,
struct monitor **  monitor 
)

Definition at line 219 of file monitor.c.

int monitor_lookup_objid_lock_monitor ( int  objid,
int *  objtype,
void **  obj,
struct monitor **  monitor 
)

Definition at line 400 of file monitor.c.

int monitor_lookup_objid_lock_objtype ( int  objid,
int  objtype,
void **  obj,
struct monitor **  monitor 
)

Definition at line 350 of file monitor.c.

int monitor_lookup_objid_lock_objtype_and_monitor ( int  objid,
int  objtype,
void **  obj,
struct monitor **  monitor 
)

Definition at line 372 of file monitor.c.

struct monitor_msg* monitor_msg_create ( int  objid,
int  id,
short  cmd,
short  seqno,
int  buflen,
char *  buf,
void *  msg_obj 
)

Definition at line 2525 of file monitor.c.

void monitor_msg_free ( struct monitor_msg msg)

Definition at line 2515 of file monitor.c.

void monitor_msg_free_save_buffer ( struct monitor_msg msg)

Definition at line 2521 of file monitor.c.

int monitor_objects ( struct monitor monitor)

Definition at line 2251 of file monitor.c.

struct monitor_msg* monitor_recv ( struct monitor monitor)

Definition at line 2719 of file monitor.c.

int monitor_register_objtype ( int  objtype,
struct monitor_objtype_ops ops,
pthread_mutex_t *  mutex 
)

Definition at line 1052 of file monitor.c.

int monitor_run ( struct monitor monitor)

Definition at line 2274 of file monitor.c.

int monitor_send ( struct monitor_msg msg)

Definition at line 2607 of file monitor.c.

int monitor_setup_stderr ( struct monitor monitor,
int  maxbufsiz,
char *  stderr_logfile,
monitor_stdio_callback_t  stderr_callback,
void *  callback_state 
)

Definition at line 1897 of file monitor.c.

int monitor_setup_stdin ( struct monitor monitor,
char *  stdin_buf,
int  stdin_buflen 
)

Definition at line 1817 of file monitor.c.

int monitor_setup_stdout ( struct monitor monitor,
int  maxbufsiz,
char *  stdout_logfile,
monitor_stdio_callback_t  stdout_callback,
void *  callback_state 
)

Definition at line 1847 of file monitor.c.

int monitor_shutdown ( struct monitor monitor)

Definition at line 947 of file monitor.c.

int monitor_spawn ( struct monitor monitor,
char *  filename,
char *const  argv[],
char *const  envp[],
char *  dir 
)

Definition at line 2002 of file monitor.c.

void monitor_store_msg_obj ( struct monitor monitor,
struct monitor_msg msg 
)

Definition at line 2484 of file monitor.c.

int monitor_unlock_objtype ( int  objtype)

Definition at line 265 of file monitor.c.

int monitor_unlock_objtype_unsafe ( int  objtype)

Definition at line 275 of file monitor.c.

Variable Documentation

char** environ