int DbgStartSession(session *s, char *exe, char *path, char *args) { int res; int len; unsigned char * buf; bitset * procs = bitset_new(s->sess_procs); proxy_msg * msg = new_proxy_msg(DBG_STARTSESSION_CMD, 0); proxy_msg_add_int(msg, SERVER_TIMEOUT); proxy_msg_add_string(msg, exe); proxy_msg_add_string(msg, path); proxy_msg_add_string(msg, args); proxy_serialize_msg(msg, &buf, &len); /* * Create a bitset containing all processes */ bitset_invert(procs); res = send_command(procs, DBG_EV_WAITALL, buf, len, NULL); free_proxy_msg(msg); bitset_free(procs); return res; }
int DbgMasterSignalInfo(int tid, int nargs, char **args) { int res; int len; unsigned char * buf; proxy_msg * msg; bitset * set; DEBUG_PRINTA(DEBUG_LEVEL_MASTER, "DbgMasterSignalInfo", nargs, args); set = bitset_decode((unsigned char *)args[0], NULL); if (set == NULL) { DbgSetError(DBGERR_PROCSET, NULL); return DBGRES_ERR; } msg = new_proxy_msg(DBG_SIGNALINFO_CMD, tid); proxy_msg_add_args(msg, --nargs, &args[1]); proxy_serialize_msg(msg, &buf, &len); res = send_command(bitset_to_idset(set), DBG_EV_WAITALL, buf, len, NULL); bitset_free(set); free_proxy_msg(msg); return res; }
/* * Stack frame operations */ int DbgListStackframes(session *s, bitset *set, int low, int depth) { int res; int len; unsigned char * buf; proxy_msg * msg = new_proxy_msg(DBG_LISTSTACKFRAMES_CMD, 0); proxy_msg_add_int(msg, low); proxy_msg_add_int(msg, depth); proxy_serialize_msg(msg, &buf, &len); res = send_command(set, DBG_EV_WAITALL, buf, len, NULL); return 0; }
/* * Process control operations */ int DbgGo(session *s, bitset *set) { int res; int len; unsigned char * buf; proxy_msg * msg = new_proxy_msg(DBG_GO_CMD, 0); proxy_serialize_msg(msg, &buf, &len); res = send_command(set, DBG_EV_WAITSOME, buf, len, NULL); free_proxy_msg(msg); return res; }
/* * Expression/variable operations */ int DbgEvaluateExpression(session *s, bitset *set, char *exp) { int res; int len; unsigned char * buf; proxy_msg * msg = new_proxy_msg(DBG_EVALUATEEXPRESSION_CMD, 0); proxy_msg_add_string(msg, exp); proxy_serialize_msg(msg, &buf, &len); res = send_command(set, DBG_EV_WAITSOME, buf, len, NULL); free_proxy_msg(msg); return res; }
int DbgStep(session *s, bitset *set, int count, int type) { int res; int len; unsigned char * buf; proxy_msg * msg = new_proxy_msg(DBG_STEP_CMD, 0); proxy_msg_add_int(msg, count); proxy_msg_add_int(msg, type); proxy_serialize_msg(msg, &buf, &len); res = send_command(set, DBG_EV_WAITSOME, buf, len, NULL); free_proxy_msg(msg); return res; }
int DbgMasterStartSession(int tid, int nargs, char **args) { int res; int len; unsigned char * buf; proxy_msg * msg = new_proxy_msg(DBG_STARTSESSION_CMD, tid); DEBUG_PRINTA(DEBUG_LEVEL_MASTER, "DbgMasterStartSession", nargs, args); proxy_msg_add_int(msg, SERVER_TIMEOUT); proxy_msg_add_args(msg, nargs, args); proxy_serialize_msg(msg, &buf, &len); res = send_command(dbg_procs, DBG_EV_WAITALL, buf, len, NULL); free_proxy_msg(msg); return res; }
int DbgQuit(session *s) { int res; int len; unsigned char * buf; bitset * procs = bitset_new(s->sess_procs); proxy_msg * msg = new_proxy_msg(DBG_QUIT_CMD, 0); proxy_serialize_msg(msg, &buf, &len); bitset_invert(procs); res = send_command(procs, DBG_EV_WAITALL, buf, len, NULL); free_proxy_msg(msg); bitset_free(procs); return res; }
/* * Breakpoint operations */ int DbgSetLineBreakpoint(session *s, bitset *set, int bpid, char *file, int line) { int res; int len; unsigned char * buf; proxy_msg * msg = new_proxy_msg(DBG_SETLINEBREAKPOINT_CMD, 0); proxy_msg_add_int(msg, bpid); proxy_msg_add_string(msg, file); proxy_msg_add_int(msg, line); proxy_serialize_msg(msg, &buf, &len); res = send_command(set, DBG_EV_WAITALL, buf, len, NULL); free_proxy_msg(msg); return res; }
int DbgMasterQuit(int tid, int nargs, char **args) { int res; int len; unsigned char * buf; proxy_msg * msg; DEBUG_PRINTA(DEBUG_LEVEL_MASTER, "DbgMasterQuit", nargs, args); dbg_state = SHUTDOWN_STARTED; msg = new_proxy_msg(DBG_QUIT_CMD, tid); proxy_msg_add_args(msg, nargs, args); proxy_serialize_msg(msg, &buf, &len); res = send_command(dbg_procs, DBG_EV_WAITALL, buf, len, NULL); free_proxy_msg(msg); return res; }
/* * Serialize a debug event for sending between debug servers. * * Note that the serialized event does not include the bitset, since it is * only relevant to communication with the client. The bitset is * added just prior to sending back to the client. */ int DbgSerializeEvent(dbg_event *e, unsigned char **result, int *len) { int res = 0; proxy_msg * p = NULL; if (e == NULL) return -1; p = new_proxy_msg(e->event_id, e->trans_id); switch (e->event_id) { case DBGEV_OK: break; case DBGEV_ERROR: proxy_msg_add_int(p, e->dbg_event_u.error_event.error_code); proxy_msg_add_string(p, e->dbg_event_u.error_event.error_msg); break; case DBGEV_OUTPUT: proxy_msg_add_string(p, e->dbg_event_u.output); break; case DBGEV_SUSPEND: proxy_msg_add_int(p, e->dbg_event_u.suspend_event.reason); switch (e->dbg_event_u.suspend_event.reason) { case DBGEV_SUSPEND_BPHIT: proxy_msg_add_int(p, e->dbg_event_u.suspend_event.ev_u.bpid); proxy_msg_add_int(p, e->dbg_event_u.suspend_event.thread_id); proxy_msg_add_int(p, e->dbg_event_u.suspend_event.depth); dbg_add_strings(p, e->dbg_event_u.suspend_event.changed_vars); break; case DBGEV_SUSPEND_SIGNAL: dbg_add_signalinfo(p, e->dbg_event_u.suspend_event.ev_u.sig); dbg_add_stackframe(p, e->dbg_event_u.suspend_event.frame); proxy_msg_add_int(p, e->dbg_event_u.suspend_event.thread_id); proxy_msg_add_int(p, e->dbg_event_u.suspend_event.depth); dbg_add_strings(p, e->dbg_event_u.suspend_event.changed_vars); break; case DBGEV_SUSPEND_STEP: case DBGEV_SUSPEND_INT: dbg_add_stackframe(p, e->dbg_event_u.suspend_event.frame); proxy_msg_add_int(p, e->dbg_event_u.suspend_event.thread_id); proxy_msg_add_int(p, e->dbg_event_u.suspend_event.depth); dbg_add_strings(p, e->dbg_event_u.suspend_event.changed_vars); break; } break; case DBGEV_BPSET: proxy_msg_add_int(p, e->dbg_event_u.bpset_event.bpid); dbg_add_breakpoint(p, e->dbg_event_u.bpset_event.bp); break; case DBGEV_SIGNALS: dbg_add_signals(p, e->dbg_event_u.list); break; case DBGEV_EXIT: proxy_msg_add_int(p, e->dbg_event_u.exit_event.reason); switch (e->dbg_event_u.exit_event.reason) { case DBGEV_EXIT_NORMAL: proxy_msg_add_int(p, e->dbg_event_u.exit_event.ev_u.exit_status); break; case DBGEV_EXIT_SIGNAL: dbg_add_signalinfo(p, e->dbg_event_u.exit_event.ev_u.sig); break; } break; case DBGEV_FRAMES: dbg_add_stackframes(p, e->dbg_event_u.list); break; case DBGEV_THREAD_SELECT: proxy_msg_add_int(p, e->dbg_event_u.thread_select_event.thread_id); dbg_add_stackframe(p, e->dbg_event_u.thread_select_event.frame); break; case DBGEV_THREADS: proxy_msg_add_int(p, e->dbg_event_u.threads_event.thread_id); dbg_add_strings(p, e->dbg_event_u.threads_event.list); break; case DBGEV_STACK_DEPTH: proxy_msg_add_int(p, e->dbg_event_u.stack_depth); break; case DBGEV_DATAR_MEM: dbg_add_memoryinfo(p, e->dbg_event_u.meminfo); break; case DBGEV_VARS: dbg_add_strings(p, e->dbg_event_u.list); break; case DBGEV_ARGS: dbg_add_strings(p, e->dbg_event_u.list); break; case DBGEV_TYPE: proxy_msg_add_string(p, e->dbg_event_u.type_desc); break; case DBGEV_DATA: dbg_add_aif(p, e->dbg_event_u.data_event.data); proxy_msg_add_string(p, e->dbg_event_u.data_event.type_desc); proxy_msg_add_string(p, e->dbg_event_u.data_event.name); break; default: res = -1; break; } res = proxy_serialize_msg(p, result, len); free_proxy_msg(p); return res; }