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; }
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 DbgListInfoThreads(session *s, bitset *set) { proxy_msg * msg = new_proxy_msg(DBG_LISTINFOTHREADS_CMD, 0); proxy_msg_add_bitset(msg, set); proxy_clnt_queue_msg(s->sess_proxy, msg); free_proxy_msg(msg); return 0; }
int DbgListGlobalVariables(session *s, bitset *set) { proxy_msg * msg = new_proxy_msg(DBG_LISTGLOBALVARIABLES_CMD, 0); proxy_msg_add_bitset(msg, set); proxy_clnt_queue_msg(s->sess_proxy, msg); free_proxy_msg(msg); return 0; }
int DbgTerminate(session *s, bitset *set) { proxy_msg * msg = new_proxy_msg(DBG_TERMINATE_CMD, 0); proxy_msg_add_bitset(msg, set); proxy_clnt_queue_msg(s->sess_proxy, msg); free_proxy_msg(msg); return 0; }
int DbgStackInfoDepth(session *s, bitset *set) { proxy_msg * msg = new_proxy_msg(DBG_STACKINFODEPTH_CMD, 0); proxy_msg_add_bitset(msg, set); proxy_clnt_queue_msg(s->sess_proxy, msg); free_proxy_msg(msg); return 0; }
int DbgSuspend(session *s, bitset *set) { proxy_msg * msg = new_proxy_msg(DBG_SUSPEND_CMD, 0); proxy_msg_add_bitset(msg, set); proxy_clnt_queue_msg(s->sess_proxy, msg); free_proxy_msg(msg); return 0; }
int DbgGetType(session *s, bitset *set, char *exp) { proxy_msg * msg = new_proxy_msg(DBG_GETTYPE_CMD, 0); proxy_msg_add_bitset(msg, set); proxy_msg_add_string(msg, exp); proxy_clnt_queue_msg(s->sess_proxy, msg); free_proxy_msg(msg); return 0; }
int DbgSetCurrentStackframe(session *s, bitset *set, int level) { proxy_msg * msg = new_proxy_msg(DBG_SETCURRENTSTACKFRAME_CMD, 0); proxy_msg_add_bitset(msg, set); proxy_msg_add_int(msg, level); proxy_clnt_queue_msg(s->sess_proxy, msg); free_proxy_msg(msg); return 0; }
int DbgListSignals(session *s, bitset *set, char *name) { proxy_msg * msg = new_proxy_msg(DBG_LISTSIGNALS_CMD, 0); proxy_msg_add_bitset(msg, set); proxy_msg_add_string(msg, name); proxy_clnt_queue_msg(s->sess_proxy, msg); free_proxy_msg(msg); return 0; }
int DbgCLIHandle(session *s, bitset *set, char *arg) { proxy_msg * msg = new_proxy_msg(DBG_CLIHANDLE_CMD, 0); proxy_msg_add_bitset(msg, set); proxy_msg_add_string(msg, arg); proxy_clnt_queue_msg(s->sess_proxy, msg); free_proxy_msg(msg); return 0; }
int DbgDeletePartialExpression(session *s, bitset *set, char *arg) { proxy_msg * msg = new_proxy_msg(DBG_DELETEPARTIALEXPRESSION_CMD, 0); proxy_msg_add_bitset(msg, set); proxy_msg_add_string(msg, arg); proxy_clnt_queue_msg(s->sess_proxy, msg); free_proxy_msg(msg); return 0; }
int DbgDisableBreakpoint(session *s, bitset *set, int bpid) { proxy_msg * msg = new_proxy_msg(DBG_DISABLEBREAKPOINT_CMD, 0); proxy_msg_add_bitset(msg, set); proxy_msg_add_int(msg, bpid); proxy_clnt_queue_msg(s->sess_proxy, msg); free_proxy_msg(msg); return 0; }
int DbgSetThreadSelect(session *s, bitset *set, int threadNum) { proxy_msg * msg = new_proxy_msg(DBG_SETTHREADSELECT_CMD, 0); proxy_msg_add_bitset(msg, set); proxy_msg_add_int(msg, threadNum); proxy_clnt_queue_msg(s->sess_proxy, msg); free_proxy_msg(msg); return 0; }
int DbgListArguments(session *s, bitset *set, int low, int high) { proxy_msg * msg = new_proxy_msg(DBG_LISTARGUMENTS_CMD, 0); proxy_msg_add_bitset(msg, set); proxy_msg_add_int(msg, low); proxy_msg_add_int(msg, high); proxy_clnt_queue_msg(s->sess_proxy, msg); free_proxy_msg(msg); return 0; }
int DbgConditionBreakpoint(session *s, bitset *set, int bpid, char *expr) { proxy_msg * msg = new_proxy_msg(DBG_CONDITIONBREAKPOINT_CMD, 0); proxy_msg_add_bitset(msg, set); proxy_msg_add_int(msg, bpid); proxy_msg_add_string(msg, expr); proxy_clnt_queue_msg(s->sess_proxy, msg); free_proxy_msg(msg); return 0; }
int DbgBreakpointAfter(session *s, bitset *set, int bpid, int icount) { proxy_msg * msg = new_proxy_msg(DBG_BREAKPOINTAFTER_CMD, 0); proxy_msg_add_bitset(msg, set); proxy_msg_add_int(msg, bpid); proxy_msg_add_int(msg, icount); proxy_clnt_queue_msg(s->sess_proxy, msg); free_proxy_msg(msg); return 0; }
int DbgSetFuncBreakpoint(session *s, bitset *set, int bpid, char *file, char *func) { proxy_msg * msg = new_proxy_msg(DBG_SETFUNCBREAKPOINT_CMD, 0); proxy_msg_add_bitset(msg, set); proxy_msg_add_int(msg, bpid); proxy_msg_add_string(msg, file); proxy_msg_add_string(msg, func); proxy_clnt_queue_msg(s->sess_proxy, msg); free_proxy_msg(msg); 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; }
int DbgEvaluatePartialExpression(session *s, bitset *set, char *name, char *key, int listChildren, int express) { proxy_msg * msg = new_proxy_msg(DBG_EVALUATEPARTIALEXPRESSION_CMD, 0); proxy_msg_add_bitset(msg, set); proxy_msg_add_string(msg, name); proxy_msg_add_string(msg, key); proxy_msg_add_int(msg, listChildren); proxy_msg_add_int(msg, express); proxy_clnt_queue_msg(s->sess_proxy, msg); free_proxy_msg(msg); return 0; }
/* * 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 DbgDataWriteMemory(session *s, bitset *set, long offset, char *address, char *format, int wordSize, char *value) { proxy_msg * msg = new_proxy_msg(DBG_DATAWRITEMEMORY_CMD, 0); proxy_msg_add_bitset(msg, set); proxy_msg_add_int(msg, offset); proxy_msg_add_string(msg, address); proxy_msg_add_string(msg, format); proxy_msg_add_int(msg, wordSize); proxy_msg_add_string(msg, value); proxy_clnt_queue_msg(s->sess_proxy, msg); free_proxy_msg(msg); return 0; }
int DbgSetWatchpoint(session *s, bitset *set, int bpid, char *expr, int access, int read, char *condition, int icount) { proxy_msg * msg = new_proxy_msg(DBG_SETWATCHPOINT_CMD, 0); proxy_msg_add_bitset(msg, set); proxy_msg_add_int(msg, bpid); proxy_msg_add_string(msg, expr); proxy_msg_add_int(msg, access); proxy_msg_add_int(msg, read); proxy_msg_add_string(msg, condition); proxy_msg_add_int(msg, icount); proxy_clnt_queue_msg(s->sess_proxy, msg); free_proxy_msg(msg); return 0; }
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; }
int DbgDataReadMemory(session *s, bitset *set, long offset, char *address, char *format, int wordSize, int rows, int cols, char *asChar) { proxy_msg * msg = new_proxy_msg(DBG_DATAREADMEMORY_CMD, 0); proxy_msg_add_bitset(msg, set); proxy_msg_add_int(msg, offset); proxy_msg_add_string(msg, address); proxy_msg_add_string(msg, format); proxy_msg_add_int(msg, wordSize); proxy_msg_add_int(msg, rows); proxy_msg_add_int(msg, cols); proxy_msg_add_string(msg, asChar); proxy_clnt_queue_msg(s->sess_proxy, msg); free_proxy_msg(msg); return 0; }
/* * 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; }