Skip to content

Commit

Permalink
Implement @c: temporal seek operator ##shell
Browse files Browse the repository at this point in the history
  • Loading branch information
trufae authored Apr 9, 2022
1 parent 7b83210 commit c566ff2
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
16 changes: 13 additions & 3 deletions libr/core/cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
#define INTERACTIVE_MAX_REP 1024

#include <r_core.h>
#include <r_anal.h>
#include <r_cons.h>
#include <r_cmd.h>
#include <stdint.h>
#include <sys/types.h>
#include <ctype.h>
Expand Down Expand Up @@ -4159,6 +4156,19 @@ static int r_core_cmd_subst_i(RCore *core, char *cmd, char *colon, bool *tmpseek
}
}
break;
case 'c': // "@c:"
{
char *s = r_core_cmd_str (core, ptr + 2);
if (*s) {
ut64 addr = r_num_math (core->num, s);
if (core->num->nc.errors == 0) {
r_core_seek (core, addr, true);
cmd_tmpseek = core->tmpseek = true;
}
}
free (s);
}
break;
case 'e': // "@e:"
{
char *cmd = parse_tmp_evals (core, ptr + 2);
Expand Down
11 changes: 4 additions & 7 deletions libr/core/cmd_help.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
/* radare - LGPL - Copyright 2009-2021 - pancake */
/* radare - LGPL - Copyright 2009-2022 - pancake */

#include <stddef.h>
#include <math.h> // required for signbit
#include "r_cons.h"
#include "r_core.h"
#include "r_util.h"
#include <r_core.h>

static const char *help_msg_at[] = {
"Usage: [.][#]<cmd>[*] [`cmd`] [@ addr] [~grep] [|syscmd] [>[>]file]", "", "",
Expand Down Expand Up @@ -34,7 +30,8 @@ static const char *help_msg_at[] = {
"@{", "from to}", "temporary set from and to for commands supporting ranges",
"@a:", "arch[:bits]", "temporary set arch and bits",
"@b:", "bits", "temporary set asm.bits",
"@B:", "nth", "temporary seek to nth instruction in current bb (negative numbers too)",
"@B:", "nth", "temporary seek to nth instruction in current bb (negative numbers too)", // XXX rename to @n:
"@c:", "cmd", "seek to the address printed by the given command. same as '@ `cmd`'",
"@e:", "k=v,k=v", "temporary change eval vars",
"@f:", "file", "temporary replace block with file contents",
"@F:", "flagspace", "temporary change flag space",
Expand Down
12 changes: 12 additions & 0 deletions test/db/cmd/feat_arroba
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
NAME=@c:
FILE=--
CMDS=<<EOF
?v $$ @c:?e 123
?v $$ @c:?e 0
EOF
EXPECT=<<EOF
0x7b
0x0
EOF
RUN

NAME=@ addr
FILE=--
CMDS=<<EOF
Expand Down

0 comments on commit c566ff2

Please sign in to comment.