2015-03-03 23:46:59 +00:00
|
|
|
/* radare - LGPL - Copyright 2009-2015 - pancake */
|
2012-02-27 01:40:27 +00:00
|
|
|
|
2015-12-22 19:51:06 +00:00
|
|
|
static void __init_seek_line (RCore *core) {
|
|
|
|
ut64 from, to;
|
|
|
|
|
|
|
|
r_config_bump (core->config, "lines.to");
|
|
|
|
from = r_config_get_i (core->config, "lines.from");
|
|
|
|
to = r_config_get_i (core->config, "lines.to");
|
2016-01-02 17:18:48 +00:00
|
|
|
if (r_core_lines_initcache (core, from, to) == -1) {
|
2015-12-22 19:51:06 +00:00
|
|
|
eprintf ("ERROR: \"lines.from\" and \"lines.to\" must be set\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __get_current_line (RCore *core) {
|
|
|
|
if (core->print->lines_cache_sz > 0) {
|
|
|
|
int curr = r_util_lines_getline (core->print->lines_cache, core->print->lines_cache_sz, core->offset);
|
|
|
|
r_cons_printf ("%d\n", curr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __seek_line_absolute (RCore *core, int numline) {
|
|
|
|
if (numline < 1 || numline > core->print->lines_cache_sz - 1) {
|
|
|
|
eprintf ("ERROR: Line must be between 1 and %d\n", core->print->lines_cache_sz-1);
|
|
|
|
} else {
|
|
|
|
r_core_seek (core, core->print->lines_cache[numline-1], 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __seek_line_relative (RCore *core, int numlines) {
|
|
|
|
int curr = r_util_lines_getline (core->print->lines_cache, core->print->lines_cache_sz, core->offset);
|
|
|
|
if (numlines > 0 && curr+numlines >= core->print->lines_cache_sz-1) {
|
|
|
|
eprintf ("ERROR: Line must be < %d\n", core->print->lines_cache_sz-1);
|
|
|
|
} else if (numlines < 0 && curr+numlines < 1) {
|
|
|
|
eprintf ("ERROR: Line must be > 1\n");
|
|
|
|
} else {
|
|
|
|
r_core_seek (core, core->print->lines_cache[curr+numlines-1], 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __clean_lines_cache (RCore *core) {
|
|
|
|
core->print->lines_cache_sz = -1;
|
|
|
|
R_FREE (core->print->lines_cache);
|
|
|
|
}
|
|
|
|
|
|
|
|
R_API int r_core_lines_currline (RCore *core) { // make priv8 again
|
2015-12-21 21:27:05 +00:00
|
|
|
int imin = 0;
|
2015-12-22 19:51:06 +00:00
|
|
|
int imax = core->print->lines_cache_sz;
|
2015-12-21 21:27:05 +00:00
|
|
|
int imid = 0;
|
|
|
|
|
|
|
|
while (imin <= imax) {
|
|
|
|
imid = imin + ((imax - imin) / 2);
|
2015-12-22 19:51:06 +00:00
|
|
|
if (core->print->lines_cache[imid] == core->offset) {
|
2015-12-21 21:27:05 +00:00
|
|
|
return imid;
|
|
|
|
}
|
2015-12-22 19:51:06 +00:00
|
|
|
else if (core->print->lines_cache[imid] < core->offset)
|
2015-12-21 21:27:05 +00:00
|
|
|
imin = imid + 1;
|
|
|
|
else
|
|
|
|
imax = imid - 1;
|
|
|
|
}
|
|
|
|
return imin;
|
|
|
|
}
|
|
|
|
|
2015-12-22 19:51:06 +00:00
|
|
|
R_API int r_core_lines_initcache (RCore *core, ut64 start_addr, ut64 end_addr) {
|
|
|
|
int i, line_count;
|
|
|
|
int bsz = core->blocksize;
|
|
|
|
char *buf;
|
|
|
|
ut64 off = start_addr;
|
2016-01-03 02:10:09 +00:00
|
|
|
ut64 baddr;
|
2015-12-22 19:51:06 +00:00
|
|
|
if (start_addr == UT64_MAX || end_addr == UT64_MAX) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
free (core->print->lines_cache);
|
|
|
|
core->print->lines_cache = R_NEWS0 (ut64, bsz);
|
|
|
|
if (!core->print->lines_cache) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2016-01-03 02:10:09 +00:00
|
|
|
{
|
|
|
|
RIOSection *s = r_io_section_mget_in (core->io, core->offset);
|
|
|
|
baddr = s ? s->offset : r_config_get_i (core->config, "bin.baddr");
|
|
|
|
}
|
|
|
|
|
2015-12-29 10:06:32 +00:00
|
|
|
line_count = start_addr ? 0 : 1;
|
2016-01-02 17:18:48 +00:00
|
|
|
core->print->lines_cache[0] = start_addr ? 0 : baddr;
|
2015-12-22 19:51:06 +00:00
|
|
|
r_cons_break (NULL, NULL);
|
|
|
|
buf = malloc (bsz);
|
|
|
|
if (!buf) return -1;
|
|
|
|
while (off < end_addr) {
|
|
|
|
if (r_cons_singleton ()->breaked) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
r_io_read_at (core->io, off, (ut8*)buf, bsz);
|
|
|
|
for (i=0; i<bsz; i++) {
|
|
|
|
if (buf[i] == '\n') {
|
2016-01-02 17:18:48 +00:00
|
|
|
core->print->lines_cache[line_count] = start_addr ? off+i+1 : off+i+1+baddr;
|
2015-12-22 19:51:06 +00:00
|
|
|
line_count++;
|
|
|
|
if (line_count % bsz == 0) {
|
|
|
|
ut64 *tmp = realloc (core->print->lines_cache,
|
|
|
|
(line_count+bsz)*sizeof(ut64));
|
|
|
|
if (tmp) {
|
|
|
|
core->print->lines_cache = tmp;
|
|
|
|
} else {
|
|
|
|
R_FREE (core->print->lines_cache);
|
|
|
|
goto beach;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
off += bsz;
|
|
|
|
}
|
|
|
|
free (buf);
|
|
|
|
r_cons_break_end ();
|
|
|
|
return line_count;
|
|
|
|
beach:
|
|
|
|
free (buf);
|
|
|
|
r_cons_break_end();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2012-02-27 01:40:27 +00:00
|
|
|
static int cmd_seek(void *data, const char *input) {
|
|
|
|
RCore *core = (RCore *)data;
|
|
|
|
char *cmd, *p;
|
|
|
|
ut64 off;
|
|
|
|
|
|
|
|
if (*input=='r') {
|
|
|
|
if (input[1] && input[2]) {
|
|
|
|
if (core->io->debug) {
|
|
|
|
off = r_debug_reg_get (core->dbg, input+2);
|
|
|
|
r_io_sundo_push (core->io, core->offset);
|
|
|
|
r_core_seek (core, off, 1);
|
2014-06-17 08:23:11 +00:00
|
|
|
} else {
|
|
|
|
RReg *orig = core->dbg->reg;
|
|
|
|
core->dbg->reg = core->anal->reg;
|
|
|
|
off = r_debug_reg_get (core->dbg, input+2);
|
|
|
|
core->dbg->reg = orig;
|
|
|
|
r_core_seek (core, off, 1);
|
|
|
|
}
|
2015-10-31 00:57:52 +00:00
|
|
|
} else eprintf ("|Usage| 'sr PC' seek to program counter register\n");
|
2015-11-09 14:14:41 +00:00
|
|
|
}
|
2012-02-27 01:40:27 +00:00
|
|
|
if (*input) {
|
2014-09-13 16:15:11 +00:00
|
|
|
const char *inputnum = strchr (input, ' ');
|
2012-02-27 01:40:27 +00:00
|
|
|
int sign = 1;
|
2013-01-02 23:47:58 +00:00
|
|
|
inputnum = inputnum? inputnum+1: input+1;
|
2012-12-30 00:05:12 +00:00
|
|
|
off = r_num_math (core->num, inputnum);
|
2013-09-30 00:19:19 +00:00
|
|
|
if (*inputnum== '-') off = -off;
|
2014-03-12 01:44:49 +00:00
|
|
|
#if 0
|
2012-12-30 00:05:12 +00:00
|
|
|
if (input[0]!='/' && inputnum && isalpha (inputnum[0]) && off == 0) {
|
|
|
|
if (!r_flag_get (core->flags, inputnum)) {
|
|
|
|
eprintf ("Cannot find address for '%s'\n", inputnum);
|
2015-09-14 10:35:38 +00:00
|
|
|
return false;
|
2012-02-27 01:40:27 +00:00
|
|
|
}
|
|
|
|
}
|
2014-03-12 01:44:49 +00:00
|
|
|
#endif
|
2012-02-27 01:40:27 +00:00
|
|
|
if (input[0]==' ') {
|
|
|
|
switch (input[1]) {
|
|
|
|
case '-': sign=-1;
|
|
|
|
case '+': input++; break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (*input) {
|
|
|
|
case 'C':
|
2012-07-12 02:21:56 +00:00
|
|
|
if (input[1]=='*') {
|
2014-03-12 01:44:49 +00:00
|
|
|
r_core_cmd0 (core, "C*~^\"CC");
|
2014-06-23 01:20:58 +00:00
|
|
|
} else
|
2012-02-27 01:40:27 +00:00
|
|
|
if (input[1]==' ') {
|
2014-03-12 01:44:49 +00:00
|
|
|
typedef struct {
|
|
|
|
ut64 addr;
|
|
|
|
char *str;
|
|
|
|
} MetaCallback;
|
|
|
|
int count = 0;
|
|
|
|
MetaCallback cb = { 0, NULL };
|
|
|
|
ut64 addr;
|
|
|
|
char key[128];
|
|
|
|
const char *val, *comma;
|
|
|
|
char *list = sdb_get (core->anal->sdb_meta, "meta.C", 0);
|
|
|
|
char *str, *next, *cur = list;
|
|
|
|
if (list) {
|
|
|
|
for (;;) {
|
2014-03-26 03:16:03 +00:00
|
|
|
cur = sdb_anext (cur, &next);
|
2014-03-12 01:44:49 +00:00
|
|
|
addr = sdb_atoi (cur);
|
2014-04-02 16:07:47 +00:00
|
|
|
snprintf (key, sizeof (key)-1, "meta.C.0x%"PFMT64x, addr);
|
2014-03-12 01:44:49 +00:00
|
|
|
val = sdb_const_get (core->anal->sdb_meta, key, 0);
|
2014-04-02 16:07:47 +00:00
|
|
|
if (val) {
|
|
|
|
comma = strchr (val, ',');
|
|
|
|
if (comma) {
|
|
|
|
str = (char *)sdb_decode (comma+1, 0);
|
|
|
|
if (strstr (str, input+2)) {
|
|
|
|
r_cons_printf ("0x%08"PFMT64x" %s\n", addr, str);
|
|
|
|
count++;
|
|
|
|
cb.addr = addr;
|
|
|
|
free (cb.str);
|
|
|
|
cb.str = str;
|
|
|
|
} else free (str);
|
|
|
|
}
|
|
|
|
} else eprintf ("sdb_const_get key not found '%s'\n", key);
|
2014-03-12 01:44:49 +00:00
|
|
|
if (!next)
|
|
|
|
break;
|
|
|
|
cur = next;
|
2012-02-27 01:40:27 +00:00
|
|
|
}
|
|
|
|
}
|
2014-06-23 01:20:58 +00:00
|
|
|
|
2014-03-12 01:44:49 +00:00
|
|
|
switch (count) {
|
2012-02-27 01:40:27 +00:00
|
|
|
case 0:
|
|
|
|
eprintf ("No matching comments\n");
|
|
|
|
break;
|
|
|
|
case 1:
|
2014-03-12 01:44:49 +00:00
|
|
|
off = cb.addr;
|
2012-02-27 01:40:27 +00:00
|
|
|
r_io_sundo_push (core->io, core->offset);
|
|
|
|
r_core_seek (core, off, 1);
|
|
|
|
r_core_block_read (core, 0);
|
|
|
|
break;
|
2014-03-12 01:44:49 +00:00
|
|
|
default:
|
|
|
|
eprintf ("Too many results\n");
|
|
|
|
break;
|
2012-02-27 01:40:27 +00:00
|
|
|
}
|
2014-03-12 01:44:49 +00:00
|
|
|
free (cb.str);
|
2012-07-12 02:21:56 +00:00
|
|
|
} else eprintf ("Usage: sC[?*] comment-grep\n"
|
|
|
|
"sC* list all comments\n"
|
|
|
|
"sC const seek to comment matching 'const'\n");
|
2012-02-27 01:40:27 +00:00
|
|
|
break;
|
|
|
|
case ' ':
|
|
|
|
r_io_sundo_push (core->io, core->offset);
|
|
|
|
r_core_seek (core, off*sign, 1);
|
|
|
|
r_core_block_read (core, 0);
|
|
|
|
break;
|
|
|
|
case '/':
|
|
|
|
{
|
|
|
|
const char *pfx = r_config_get (core->config, "search.prefix");
|
2015-03-03 21:34:44 +00:00
|
|
|
ut64 from = r_config_get_i (core->config, "search.from");
|
2012-12-30 00:05:12 +00:00
|
|
|
//kwidx cfg var is ignored
|
|
|
|
int kwidx = core->search->n_kws; //(int)r_config_get_i (core->config, "search.kwidx")-1;
|
2012-02-27 01:40:27 +00:00
|
|
|
if (kwidx<0) kwidx = 0;
|
2012-06-10 21:58:34 +00:00
|
|
|
switch (input[1]) {
|
2012-12-30 00:05:12 +00:00
|
|
|
case ' ':
|
2015-03-03 21:34:44 +00:00
|
|
|
case 'v':
|
|
|
|
case 'V':
|
|
|
|
case 'w':
|
|
|
|
case 'W':
|
|
|
|
case 'z':
|
|
|
|
case 'm':
|
|
|
|
case 'c':
|
2015-03-03 23:46:59 +00:00
|
|
|
case 'A':
|
|
|
|
case 'e':
|
|
|
|
case 'E':
|
|
|
|
case 'i':
|
|
|
|
case 'R':
|
|
|
|
case 'r':
|
2015-03-03 21:34:44 +00:00
|
|
|
case '/':
|
2012-06-10 21:58:34 +00:00
|
|
|
case 'x':
|
2015-03-03 21:34:44 +00:00
|
|
|
r_config_set_i (core->config, "search.from", core->offset+1);
|
2012-12-30 00:05:12 +00:00
|
|
|
r_config_set_i (core->config, "search.count", 1);
|
2015-03-03 21:34:44 +00:00
|
|
|
r_core_cmdf (core, "s+1; %s; s-1; s %s%d_0; f-%s%d_0",
|
2012-12-30 00:05:12 +00:00
|
|
|
input, pfx, kwidx, pfx, kwidx, pfx, kwidx);
|
2015-03-03 21:34:44 +00:00
|
|
|
r_config_set_i (core->config, "search.from", from);
|
2012-12-30 00:05:12 +00:00
|
|
|
r_config_set_i (core->config, "search.count", 0);
|
2012-06-10 21:58:34 +00:00
|
|
|
break;
|
2015-03-03 21:34:44 +00:00
|
|
|
case '?':
|
|
|
|
eprintf ("Usage: s/.. arg.\n");
|
|
|
|
r_cons_printf ("/?\n");
|
|
|
|
break;
|
2012-12-30 00:05:12 +00:00
|
|
|
default:
|
|
|
|
eprintf ("unknown search method\n");
|
2012-06-10 21:58:34 +00:00
|
|
|
break;
|
|
|
|
}
|
2012-02-27 01:40:27 +00:00
|
|
|
}
|
|
|
|
break;
|
2013-09-11 23:55:45 +00:00
|
|
|
case '.':
|
|
|
|
for (input++;*input=='.';input++);
|
|
|
|
r_core_seek_base (core, input);
|
|
|
|
break;
|
2012-02-27 01:40:27 +00:00
|
|
|
case '*':
|
|
|
|
r_io_sundo_list (core->io);
|
|
|
|
break;
|
|
|
|
case '+':
|
|
|
|
if (input[1]!='\0') {
|
2012-12-30 00:05:12 +00:00
|
|
|
int delta = (input[1]=='+')? core->blocksize: off;
|
2012-02-27 01:40:27 +00:00
|
|
|
r_io_sundo_push (core->io, core->offset);
|
|
|
|
r_core_seek_delta (core, delta);
|
|
|
|
} else {
|
|
|
|
off = r_io_sundo_redo (core->io);
|
|
|
|
if (off != UT64_MAX)
|
|
|
|
r_core_seek (core, off, 0);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case '-':
|
|
|
|
if (input[1]!='\0') {
|
2012-12-30 00:05:12 +00:00
|
|
|
int delta = (input[1]=='-') ? -core->blocksize: -off;
|
2012-02-27 01:40:27 +00:00
|
|
|
r_io_sundo_push (core->io, core->offset);
|
|
|
|
r_core_seek_delta (core, delta);
|
|
|
|
} else {
|
|
|
|
off = r_io_sundo (core->io, core->offset);
|
|
|
|
if (off != UT64_MAX)
|
|
|
|
r_core_seek (core, off, 0);
|
|
|
|
}
|
2014-07-02 00:53:50 +00:00
|
|
|
r_core_block_read (core, 1);
|
2012-02-27 01:40:27 +00:00
|
|
|
break;
|
2012-09-28 00:20:52 +00:00
|
|
|
case 'n':
|
2012-02-27 01:40:27 +00:00
|
|
|
r_io_sundo_push (core->io, core->offset);
|
2012-09-28 00:20:52 +00:00
|
|
|
r_core_seek_next (core, r_config_get (core->config, "scr.nkey"));
|
2012-02-27 01:40:27 +00:00
|
|
|
break;
|
2013-10-08 22:29:49 +00:00
|
|
|
case 'p':
|
2012-02-27 01:40:27 +00:00
|
|
|
r_io_sundo_push (core->io, core->offset);
|
2012-09-28 00:20:52 +00:00
|
|
|
r_core_seek_previous (core, r_config_get (core->config, "scr.nkey"));
|
2012-02-27 01:40:27 +00:00
|
|
|
break;
|
|
|
|
case 'a':
|
|
|
|
off = core->blocksize;
|
|
|
|
if (input[1]&&input[2]) {
|
|
|
|
cmd = strdup (input);
|
|
|
|
p = strchr (cmd+2, ' ');
|
|
|
|
if (p) {
|
|
|
|
off = r_num_math (core->num, p+1);;
|
|
|
|
*p = '\0';
|
|
|
|
}
|
|
|
|
cmd[0] = 's';
|
|
|
|
// perform real seek if provided
|
2012-09-19 12:08:44 +00:00
|
|
|
r_cmd_call (core->rcmd, cmd);
|
2012-02-27 01:40:27 +00:00
|
|
|
free (cmd);
|
|
|
|
}
|
|
|
|
r_io_sundo_push (core->io, core->offset);
|
|
|
|
r_core_seek_align (core, off, 0);
|
|
|
|
break;
|
|
|
|
case 'b':
|
2012-08-03 00:05:50 +00:00
|
|
|
if (off == 0)
|
|
|
|
off = core->offset;
|
2012-02-27 01:40:27 +00:00
|
|
|
r_io_sundo_push (core->io, core->offset);
|
|
|
|
r_core_anal_bb_seek (core, off);
|
|
|
|
break;
|
2015-12-22 01:30:34 +00:00
|
|
|
case 'f': // "sf"
|
2014-05-18 12:17:43 +00:00
|
|
|
if (strlen(input) > 2 && input[1]==' ') {
|
|
|
|
RAnalFunction *fcn = r_anal_fcn_find_name (core->anal, input+2);
|
|
|
|
if (fcn) {
|
|
|
|
r_core_seek (core, fcn->addr, 1);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2014-09-26 13:40:17 +00:00
|
|
|
RAnalFunction *fcn = r_anal_get_fcn_in (core->anal, core->offset, 0);
|
2014-05-18 12:17:43 +00:00
|
|
|
if (fcn) {
|
2013-10-19 22:25:37 +00:00
|
|
|
r_core_seek (core, fcn->addr+fcn->size, 1);
|
|
|
|
}
|
|
|
|
break;
|
2015-12-22 01:30:34 +00:00
|
|
|
case 'o': // "so"
|
2012-02-27 01:40:27 +00:00
|
|
|
{
|
|
|
|
RAnalOp op;
|
2013-12-03 02:36:56 +00:00
|
|
|
int val=0, ret, i, n = r_num_math (core->num, input+1);
|
2013-12-10 00:58:06 +00:00
|
|
|
if (n==0) n = 1;
|
2013-12-02 13:34:32 +00:00
|
|
|
if (n<0) {
|
2015-02-03 03:23:27 +00:00
|
|
|
int instr_len;
|
|
|
|
ut64 addr = core->offset;
|
|
|
|
int numinstr = n * -1;
|
|
|
|
ret = r_core_asm_bwdis_len (core, &instr_len, &addr, numinstr);
|
2015-09-14 10:35:38 +00:00
|
|
|
r_core_seek (core, addr, true);
|
2013-12-02 13:34:32 +00:00
|
|
|
val += ret;
|
2015-02-03 03:23:27 +00:00
|
|
|
} else {
|
2015-01-29 01:49:04 +00:00
|
|
|
for (val=i=0; i<n; i++) {
|
|
|
|
ret = r_anal_op (core->anal, &op,
|
|
|
|
core->offset, core->block, core->blocksize);
|
|
|
|
if (ret<1)
|
|
|
|
ret = 1;
|
|
|
|
r_core_seek_delta (core, ret);
|
|
|
|
val += ret;
|
|
|
|
}
|
2013-11-25 01:03:54 +00:00
|
|
|
}
|
|
|
|
core->num->value = val;
|
2012-02-27 01:40:27 +00:00
|
|
|
}
|
|
|
|
break;
|
2015-12-22 01:30:34 +00:00
|
|
|
case 'g': // "sg"
|
2013-12-10 00:58:06 +00:00
|
|
|
{
|
2014-05-28 02:34:12 +00:00
|
|
|
RIOSection *s = r_io_section_vget (core->io, core->offset);
|
2013-12-10 00:58:06 +00:00
|
|
|
if (s) r_core_seek (core, s->vaddr, 1);
|
|
|
|
else r_core_seek (core, 0, 1);
|
|
|
|
}
|
|
|
|
break;
|
2015-12-22 01:30:34 +00:00
|
|
|
case 'G': // "sG"
|
2013-12-10 00:58:06 +00:00
|
|
|
{
|
2015-06-13 23:30:40 +00:00
|
|
|
if (!core->file) break;
|
2014-05-28 02:34:12 +00:00
|
|
|
RIOSection *s = r_io_section_vget (core->io, core->offset);
|
2013-12-10 00:58:06 +00:00
|
|
|
// XXX: this +2 is a hack. must fix gap between sections
|
|
|
|
if (s) r_core_seek (core, s->vaddr+s->size+2, 1);
|
2014-09-27 22:05:20 +00:00
|
|
|
else r_core_seek (core, r_io_desc_size (core->io, core->file->desc), 1);
|
2013-12-10 00:58:06 +00:00
|
|
|
}
|
|
|
|
break;
|
2015-12-22 01:30:34 +00:00
|
|
|
case 'l': // "sl"
|
2015-12-21 21:27:05 +00:00
|
|
|
{
|
|
|
|
int sl_arg = r_num_math (core->num, input+2);
|
2015-12-22 19:51:06 +00:00
|
|
|
const char *help_msg[] = {
|
|
|
|
"Usage:", "sl+ or sl- or slc", "",
|
|
|
|
"sl", " [line]", "Seek to absolute line",
|
|
|
|
"sl", "[+-][line]", "Seek to relative line",
|
|
|
|
"slc", "", "Clear line cache",
|
2016-01-02 17:18:48 +00:00
|
|
|
"sll", "", "Show total number of lines",
|
2015-12-22 19:51:06 +00:00
|
|
|
NULL };
|
2015-12-21 21:27:05 +00:00
|
|
|
switch (input[1]) {
|
2015-12-22 01:30:34 +00:00
|
|
|
case 0:
|
2016-01-02 17:18:48 +00:00
|
|
|
if (!core->print->lines_cache) {
|
|
|
|
__init_seek_line (core);
|
|
|
|
}
|
2015-12-22 19:51:06 +00:00
|
|
|
__get_current_line (core);
|
2015-12-22 01:30:34 +00:00
|
|
|
break;
|
2015-12-21 21:27:05 +00:00
|
|
|
case ' ':
|
2016-01-02 17:18:48 +00:00
|
|
|
if (!core->print->lines_cache) {
|
|
|
|
__init_seek_line (core);
|
|
|
|
}
|
2015-12-22 19:51:06 +00:00
|
|
|
__seek_line_absolute (core, sl_arg);
|
2015-12-21 21:27:05 +00:00
|
|
|
break;
|
|
|
|
case '-':
|
2016-01-02 17:18:48 +00:00
|
|
|
if (!core->print->lines_cache) {
|
|
|
|
__init_seek_line (core);
|
|
|
|
}
|
2015-12-22 19:51:06 +00:00
|
|
|
__seek_line_relative (core, -sl_arg);
|
2015-12-21 21:27:05 +00:00
|
|
|
break;
|
|
|
|
case '+':
|
2016-01-02 17:18:48 +00:00
|
|
|
if (!core->print->lines_cache) {
|
|
|
|
__init_seek_line (core);
|
|
|
|
}
|
2015-12-22 19:51:06 +00:00
|
|
|
__seek_line_relative (core, sl_arg);
|
|
|
|
break;
|
|
|
|
case 'c':
|
|
|
|
__clean_lines_cache (core);
|
|
|
|
break;
|
2016-01-02 17:18:48 +00:00
|
|
|
case 'l':
|
|
|
|
if (!core->print->lines_cache) {
|
|
|
|
__init_seek_line (core);
|
|
|
|
}
|
|
|
|
eprintf ("%d lines\n", core->print->lines_cache_sz-1);
|
|
|
|
break;
|
2015-12-22 19:51:06 +00:00
|
|
|
case '?':
|
|
|
|
r_core_cmd_help (core, help_msg);
|
2015-12-21 21:27:05 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2014-06-23 01:20:58 +00:00
|
|
|
case '?': {
|
|
|
|
const char * help_message[] = {
|
|
|
|
"Usage: s", "", " # Seek commands",
|
|
|
|
"s", "", "Print current address",
|
|
|
|
"s", " addr", "Seek to address",
|
|
|
|
"s-", "", "Undo seek",
|
|
|
|
"s-", " n", "Seek n bytes backward",
|
|
|
|
"s--", "", "Seek blocksize bytes backward",
|
|
|
|
"s+", "", "Redo seek",
|
|
|
|
"s+", " n", "Seek n bytes forward",
|
|
|
|
"s++", "", "Seek blocksize bytes forward",
|
|
|
|
"s*", "", "List undo seek history",
|
|
|
|
"s/", " DATA", "Search for next occurrence of 'DATA'",
|
|
|
|
"s/x", " 9091", "Search for next occurrence of \\x90\\x91",
|
|
|
|
"s.", "hexoff", "Seek honoring a base from core->offset",
|
|
|
|
"sa", " [[+-]a] [asz]", "Seek asz (or bsize) aligned to addr",
|
|
|
|
"sb", "", "Seek aligned to bb start",
|
|
|
|
"sC", " string", "Seek to comment matching given string",
|
|
|
|
"sf", "", "Seek to next function (f->addr+f->size)",
|
|
|
|
"sf", " function", "Seek to address of specified function",
|
|
|
|
"sg/sG", "", "Seek begin (sg) or end (sG) of section or file",
|
2015-12-21 21:27:05 +00:00
|
|
|
"sl", "[+-]line", "Seek to line",
|
2014-06-23 01:20:58 +00:00
|
|
|
"sn/sp", "", "Seek next/prev scr.nkey",
|
|
|
|
"so", " [N]", "Seek to N next opcode(s)",
|
|
|
|
"sr", " pc", "Seek to register",
|
|
|
|
//"sp [page] seek page N (page = block)",
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
r_core_cmd_help(core, help_message);
|
|
|
|
}
|
2012-02-27 01:40:27 +00:00
|
|
|
break;
|
|
|
|
}
|
2014-05-22 02:30:53 +00:00
|
|
|
} else r_cons_printf ("0x%"PFMT64x"\n", core->offset);
|
2012-02-27 01:40:27 +00:00
|
|
|
return 0;
|
|
|
|
}
|