Add $k{..} for numeric sdb query values and $P for debugged child pid
This commit is contained in:
parent
3f409fb490
commit
a6c0526bec
2 changed files with 29 additions and 2 deletions
|
|
@ -243,12 +243,14 @@ static int cmd_help(void *data, const char *input) {
|
|||
"$l", "", "opcode length",
|
||||
"$m", "", "opcode memory reference (e.g. mov eax,[0x10] => 0x10)",
|
||||
"$p", "", "getpid()",
|
||||
"$P", "", "pid of children (only in debug)",
|
||||
"$o", "", "here (current disk io offset)",
|
||||
"$s", "", "file size",
|
||||
"$v", "", "opcode immediate value (e.g. lui a0,0x8010 => 0x8010)",
|
||||
"$w", "", "get word size, 4 if asm.bits=32, 8 if 64, ...",
|
||||
"${ev}", "", "get value of eval config variable", //TODO: use ?k too
|
||||
"RNum", "", " $variables usable in math expressions",
|
||||
"${ev}", "", "get value of eval config variable",
|
||||
"$k{kv}", "", "get value of an sdb query value",
|
||||
"RNum", "", "$variables usable in math expressions",
|
||||
NULL};
|
||||
r_core_cmd_help (core, help_msg);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -125,6 +125,30 @@ static ut64 num_callback(RNum *userptr, const char *str, int *ok) {
|
|||
switch (str[1]) {
|
||||
case '.': // can use pc, sp, a0, a1, ...
|
||||
return r_debug_reg_get (core->dbg, str+2);
|
||||
case 'k':
|
||||
if (str[2]=='{') {
|
||||
bptr = strdup (str+3);
|
||||
ptr = strchr (bptr, '}');
|
||||
if (ptr != NULL) {
|
||||
char *out;
|
||||
ut64 ret = 0LL;
|
||||
ptr[0] = '\0';
|
||||
out = sdb_querys (core->sdb, NULL, 0, bptr);
|
||||
// XXX avoid recursivity here
|
||||
if (strstr (out, "$k{")) {
|
||||
eprintf ("Recursivity is not permitted here\n");
|
||||
} else {
|
||||
ret = r_num_math (core->num, out);
|
||||
}
|
||||
free (bptr);
|
||||
free (out);
|
||||
return ret;
|
||||
}
|
||||
free (bptr);
|
||||
} else {
|
||||
eprintf ("Expected '{' after 'k'.\n");
|
||||
}
|
||||
break;
|
||||
case '{':
|
||||
bptr = strdup (str+2);
|
||||
ptr = strchr (bptr, '}');
|
||||
|
|
@ -142,6 +166,7 @@ static ut64 num_callback(RNum *userptr, const char *str, int *ok) {
|
|||
case 'e': return r_anal_op_is_eob (&op);
|
||||
case 'j': return op.jump;
|
||||
case 'p': return r_sys_getpid ();
|
||||
case 'P': return (core->dbg->pid>0)? core->dbg->pid: 0;
|
||||
case 'f': return op.fail;
|
||||
case 'm': return op.ptr; // memref
|
||||
case 'v': return op.val; // immediate value
|
||||
|
|
|
|||
Loading…
Reference in a new issue