Beispiel #1
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;
}
Beispiel #2
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;
}
Beispiel #3
0
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;
}
Beispiel #4
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;
}
Beispiel #5
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;
}
Beispiel #6
0
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;
}
Beispiel #7
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;
}
Beispiel #8
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;
}
Beispiel #9
0
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;
}
Beispiel #10
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;
}