[qwaq] Add function to get a string from the target

This commit is contained in:
Bill Currie 2020-03-26 18:14:20 +09:00
parent 90d89e8874
commit 48f41142f5
3 changed files with 21 additions and 3 deletions

View file

@ -320,6 +320,21 @@ qdb_get_data (progs_t *pr)
R_INT (pr) = 0;
}
static void
qdb_get_string (progs_t *pr)
{
__auto_type debug = PR_Resources_Find (pr, "qwaq-debug");
pointer_t handle = P_INT (pr, 0);
qwaq_target_t *target = get_target (debug, __FUNCTION__, handle);
progs_t *tpr = target->pr;
string_t string = P_STRING (pr, 1);
R_STRING (pr) = 0;
if (PR_StringValid (tpr, string)) {
RETURN_STRING (pr, PR_GetString (tpr, string));
}
}
static void
qdb_find_global (progs_t *pr)
{
@ -491,6 +506,7 @@ static builtin_t builtins[] = {
{"qdb_continue", qdb_continue, -1},
{"qdb_get_state", qdb_get_state, -1},
{"qdb_get_data", qdb_get_data, -1},
{"qdb_get_string", qdb_get_string, -1},
{"qdb_find_global", qdb_find_global, -1},
{"qdb_find_field", qdb_find_field, -1},
{"qdb_find_function", qdb_find_function, -1},

View file

@ -28,7 +28,7 @@ typedef struct qdb_state_s {
typedef struct qdb_def_s {
unsigned type_size; // type in lower 16, size in upper 16
unsigned offset;
string_t name;
unsigned name; // string
unsigned type_encoding;
} qdb_def_t;
@ -37,8 +37,8 @@ typedef struct qdb_function_s {
unsigned local_data;
unsigned local_size;
unsigned profile;
string_t name;
string_t file;
unsigned name; // string
unsigned file; // string
unsigned num_params;
} qdb_function_t;
@ -64,6 +64,7 @@ extern int qdb_continue (qdb_target_t target);
extern qdb_state_t qdb_get_state (qdb_target_t target);
extern int qdb_get_data (qdb_target_t target, unsigned src, unsigned len,
void *dst);
extern string qdb_get_string (qdb_target_t target, unsigned str);
extern qdb_def_t qdb_find_global (qdb_target_t target, string name);
extern qdb_def_t qdb_find_field (qdb_target_t target, string name);
extern qdb_function_t *qdb_find_function (qdb_target_t target, string name);

View file

@ -181,6 +181,7 @@ int qdb_continue (qdb_target_t target) = #0;
qdb_state_t qdb_get_state (qdb_target_t target) = #0;
int qdb_get_data (qdb_target_t target, unsigned src, unsigned len,
void *dst) = #0;
string qdb_get_string (qdb_target_t target, unsigned str) = #0;
qdb_def_t qdb_find_global (qdb_target_t target, string name) = #0;
qdb_def_t qdb_find_field (qdb_target_t target, string name) = #0;
qdb_function_t *qdb_find_function (qdb_target_t target, string name) = #0;