Example #1
0
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;
}
Example #2
0
static void
dbg_add_location(proxy_msg *m, location *loc)
{
	proxy_msg_add_string(m, loc->file);
	proxy_msg_add_string(m, loc->func);
	proxy_msg_add_string(m, loc->addr);
	proxy_msg_add_int(m, loc->line);
}
Example #3
0
static void
dbg_add_memory(proxy_msg *m, memory *mem)
{
	if (mem == NULL) {
		proxy_msg_add_string(m, EMPTY);
		return;
	}

	proxy_msg_add_string(m, mem->addr);
	proxy_msg_add_string(m, mem->ascii);
	dbg_add_strings(m, mem->data);
}
Example #4
0
static void
dbg_add_signalinfo(proxy_msg *m, signal_info *sig)
{
	if (sig == NULL) {
		proxy_msg_add_string(m, EMPTY);
		return;
	}

	proxy_msg_add_string(m, sig->name);
	proxy_msg_add_int(m, sig->stop);
	proxy_msg_add_int(m, sig->print);
	proxy_msg_add_int(m, sig->pass);
	proxy_msg_add_string(m, sig->desc);
}
Example #5
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;
}
Example #6
0
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;
}
Example #7
0
static void
dbg_add_memoryinfo(proxy_msg *m, memoryinfo *meninfo)
{
	if (meninfo == NULL) {
		proxy_msg_add_string(m, EMPTY);
		return;
	}

	proxy_msg_add_string(m, meninfo->addr);
	proxy_msg_add_int(m, meninfo->nextRow);
	proxy_msg_add_int(m, meninfo->prevRow);
	proxy_msg_add_int(m, meninfo->nextPage);
	proxy_msg_add_int(m, meninfo->prevPage);
	proxy_msg_add_int(m, meninfo->numBytes);
	proxy_msg_add_int(m, meninfo->totalBytes);
	dbg_add_memories(m, meninfo->memories);
}
Example #8
0
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;
}
Example #9
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;
}
Example #10
0
static void
dbg_add_strings(proxy_msg *m, List *lst)
{
	char *	s;

	proxy_msg_add_int(m, SizeOfList(lst));

	for (SetList(lst); (s = (char *)GetListElement(lst)) != NULL; ) {
		proxy_msg_add_string(m, s);
	}
}
Example #11
0
static void
dbg_add_stackframe(proxy_msg *m, stackframe *sf)
{
	if (sf == NULL) {
		proxy_msg_add_string(m, EMPTY);
		return;
	}

	proxy_msg_add_int(m, sf->level);
	dbg_add_location(m, &sf->loc);
}
Example #12
0
static void
dbg_add_breakpoint(proxy_msg *m, breakpoint *bp)
{
	proxy_msg_add_int(m, bp->id);
	proxy_msg_add_int(m, bp->ignore);
	proxy_msg_add_int(m, bp->special);
	proxy_msg_add_int(m, bp->deleted);
	proxy_msg_add_string(m, bp->type);
	dbg_add_location(m, &bp->loc);
	proxy_msg_add_int(m, bp->hits);
}
Example #13
0
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;
}
Example #14
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;
}
Example #15
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;
}
Example #16
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;
}
Example #17
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;
}
Example #18
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;
}
Example #19
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;
}
Example #20
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;
}
Example #21
0
/*
 * 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;
}
Example #22
0
static void
dbg_add_aif(proxy_msg *m, AIF *a)
{
	proxy_msg_add_string(m, AIF_FORMAT(a));
	proxy_msg_add_data(m, AIF_DATA(a), AIF_LEN(a));
}