* Use glob to check flags in @@

- Document @@ suffix
* Fix hexdump indentation when offset is >32bits
* Optimize glob for null needle
This commit is contained in:
pancake 2011-06-07 17:53:15 +02:00
parent 822eaa1499
commit 1c035d4b52
5 changed files with 41 additions and 28 deletions

14
TODO
View File

@ -5,6 +5,20 @@
CODENAME: #DRY
* TODO: Implement r_flag_unset_i () ftw
** BUG **
* fix for indirect list manipulations -- looks like a similar problem with r_cons recusivity
- when you are iterating a list you CANT remove items from it
- this is..you CANT call r_core_cmd() while iterating flags unless you want to crash
- we probably need to queue the deletions and use a commit-like methodology
- this way we avoid duplications
RListBox *b = r_flag_get_list ();
r_list_foreach (b, iter, item) {
r_list_delete_iter_later (b, iter);
}
r_list_commit (b);
[[ 0.8 ]] -- TODO
* Tracing features for the debugger
* We need a 64 bit x86 assembler working!! nasm fails

View File

@ -1248,6 +1248,7 @@ static int cmd_help(void *data, const char *input) {
"Use '?""?""?' evaluation, special vars and scripting facilities\n"
"Append '?' to any char command to get detailed help\n"
"Suffix '@ addr[:bsize]' for a temporary seek and/or bsize\n"
"Suffix '@@ glob1 glob2i ..' space separated glob greps for flags to seek\n"
"Suffix '~string:linenumber[column]' to filter output\n"
);
break;
@ -4013,6 +4014,7 @@ R_API int r_core_cmd_foreach(RCore *core, const char *cmd, char *each) {
default:
core->cmd->macro.counter = 0;
//while(str[i]) && !core->interrupted) {
// split by keywords
while (str[i]) {
j = i;
for (;str[j]&&str[j]==' ';j++); // skip spaces
@ -4023,36 +4025,17 @@ R_API int r_core_cmd_foreach(RCore *core, const char *cmd, char *each) {
if (word == NULL)
break;
str[i] = ch;
if (strchr (word, '*')) {
#if 0
{
/* for all flags in current flagspace */
list_for_each(pos, &flags) {
flag_t *flag = (flag_t *)list_entry(pos, flag_t, list);
//if (core->interrupted)
// break;
/* filter per flag spaces */
// if ((flag_space_idx != -1) && (flag->space != flag_space_idx))
// continue;
core->offset = flag->offset;
radare_read(0);
cons_printf("; @@ 0x%08"PFMT64x" (%s)\n", core->offset, flag->name);
radare_cmd(cmd,0);
}
#else
eprintf ("No flags foreach implemented\n");
#endif
} else {
/* for all flags in current flagspace */
r_list_foreach (core->flags->flags, iter, flag) {
// XXX: dont ask why, but this only works with _prev..
r_list_foreach_prev (core->flags->flags, iter, flag) {
if (r_cons_singleton()->breaked)
break;
/* filter per flag spaces */
if ((core->flags->space_idx != -1) && (flag->space != core->flags->space_idx))
continue;
if (word[0]=='\0' || strstr(flag->name, word) != NULL) {
if (r_str_glob (flag->name, word)) {
r_core_seek (core, flag->offset, 1);
// TODO: Debug mode print
//r_cons_printf ("# @@ 0x%08"PFMT64x" (%s)\n", core->offset, flag->name);
r_core_cmd (core, cmd, 0);
}

View File

@ -1,5 +1,4 @@
/* radare - LGPL - Copyright 2007-2011 pancake<nopcode.org> */
#include "r_cons.h"
#include "r_print.h"
#include "r_util.h"
@ -220,10 +219,14 @@ R_API void r_print_hexdump(RPrint *p, ut64 addr, const ut8 *buf, int len, int ba
inc = p->cols;
if (p->flags & R_PRINT_FLAGS_HEADER) {
// only for color..too many options .. brbr
//p->printf(r_cons_palette[PAL_HEADER]);
ut32 opad = (ut32)(addr >> 32);
p->printf (" offset ");
while (opad>0) {
p->printf (" ");
opad >>= 4;
}
k = 0; // TODO: ??? SURE??? config.seek & 0xF;
/* extra padding for offsets > 8 digits */
for (i=0; i<inc; i++) {
p->printf (pre);
p->printf (" %c", hex[(i+k)%16]);

View File

@ -676,8 +676,10 @@ R_API void r_str_filter(char *str, int len) {
R_API int r_str_glob (const char *str, const char *glob) {
const char *p;
int glen = strlen (glob);
int slen = strlen (str);
int slen, glen;
if (!*str) return R_TRUE;
glen = strlen (glob);
slen = strlen (str);
if (*glob == '*') {
if (glob[1] == '\0')
return R_TRUE;
@ -703,6 +705,7 @@ R_API int r_str_glob (const char *str, const char *glob) {
}
}
}
return R_FALSE; // statement never reached
}
// XXX: remove this limit .. use realloc

10
test/offtest Normal file
View File

@ -0,0 +1,10 @@
x @ 0x10000000
x @ 0x100000000
x @ 0x1000000000
x @ 0x10000000000
x @ 0x100000000000
x @ 0x1000000000000
x @ 0x10000000000000
x @ 0x100000000000000
x @ 0x1000000000000000
x @ 0x10000000000000000