* Apply r_parse fixes from edu to support more than one numeric

to flag replacment and avoid 0x0 substitutions
* Implement 'fr' command
* Add autocompletion for /a
This commit is contained in:
pancake 2010-07-12 14:46:43 +02:00
parent b2fbe15105
commit 87512b23b0
5 changed files with 37 additions and 12 deletions

2
TODO
View File

@ -36,9 +36,9 @@ Bugs:
0x08048eec 0 c20400 ret 0x4
-> this opcodes increments the stack 8 bytes (4+4) . it is not handled correctly
TODO:
-----
* asm.syntax=att doesnt seems to work
* Test r_lib^w32/osx support
* port r_sign to RList
* pancake: implement callback for conditional breakpoints

View File

@ -180,6 +180,7 @@ log "[==] Logging ${LOGFILE}"
:> ${LOGFILE}
ln -fs ${LOGFILE} ${WD}/build.log
log "[==] Retrieving system information"
date >> ${LOGFILE}
uname -a >> ${LOGFILE}
cat /proc/cpuinfo >> ${LOGFILE}

View File

@ -1419,6 +1419,24 @@ static int cmd_flag(void *data, const char *input) {
}
}
break;
case 'r':
{
char *old, *new;
RFlagItem *item;
old = str+1;
new = strchr (old, ' ');
if (new) {
*new = 0;
new++;
item = r_flag_get (core->flags, old);
} else {
new = old;
item = r_flag_get_i (core->flags, core->offset);
}
if (item) strncpy (item->name, new, sizeof (item->name));
else eprintf ("Cannot find flag\n");
}
break;
case '*':
r_flag_list (core->flags, 1);
break;
@ -1435,6 +1453,7 @@ static int cmd_flag(void *data, const char *input) {
" f-@addr ; remove flag at address expression\n"
" f ; list flags\n"
" f* ; list flags in r commands\n"
" fr [old] [new] ; rename flag\n"
" fs functions ; set flagspace\n"
" fs * ; set no flagspace\n"
" fs ; display flagspaces\n"

View File

@ -78,12 +78,14 @@ static int autocomplete(RLine *line) {
if (core) {
if ((!memcmp (line->buffer.data, "s ", 2)) ||
(!memcmp (line->buffer.data, "f ", 2)) ||
(!memcmp (line->buffer.data, "/a ", 3)) ||
(!memcmp (line->buffer.data, "? ", 2))) {
int n, i = 0;
n = strlen (line->buffer.data+2);
int sdelta = (line->buffer.data[0]=='/')?3:2;
n = strlen (line->buffer.data+sdelta);
list_for_each_prev (pos, &core->flags->flags) {
RFlagItem *flag = list_entry (pos, RFlagItem, list);
if (!memcmp (flag->name, line->buffer.data+2, n)) {
if (!memcmp (flag->name, line->buffer.data+sdelta, n)) {
tmp_argv[i++] = flag->name;
if (i==TMP_ARGV_SZ)
break;

View File

@ -1,4 +1,4 @@
/* radare - LGPL - Copyright 2009 nibble<.ds@gmail.com> */
/* radare - LGPL - Copyright 2009-2010 nibble<.ds@gmail.com> */
#include <stdio.h>
#include <stdlib.h>
@ -9,8 +9,7 @@
#include <r_flags.h>
#include <r_parse.h>
static int replace(int argc, const char *argv[], char *newstr)
{
static int replace(int argc, const char *argv[], char *newstr) {
int i,j,k;
struct {
char *op;
@ -125,10 +124,9 @@ static int parse(struct r_parse_t *p, void *data, char *str)
return R_TRUE;
}
static int assemble(struct r_parse_t *p, void *data, char *str)
{
static int assemble(struct r_parse_t *p, void *data, char *str) {
char *ptr;
printf("assembling '%s' to generate real asm code\n", str);
printf ("assembling '%s' to generate real asm code\n", str);
ptr = strchr(str, '=');
if (ptr) {
*ptr='\0';
@ -137,13 +135,17 @@ static int assemble(struct r_parse_t *p, void *data, char *str)
return R_TRUE;
}
static int filter(struct r_parse_t *p, struct r_flag_t *f, char *data, char *str)
{
static int filter(struct r_parse_t *p, struct r_flag_t *f, char *data, char *str) {
struct list_head *pos;
char *ptr, *ptr2;
ut64 off;
if ((ptr = strstr (data, "0x"))) {
ptr = data;
while ((ptr = strstr (ptr, "0x"))) {
for (ptr2 = ptr; *ptr2 && !isseparator (*ptr2); ptr2++);
if (!strcmp (ptr, "0x0")) {
ptr = ptr2;
continue;
}
off = r_num_math (NULL, ptr);
list_for_each_prev (pos, &f->flags) {
RFlagItem *flag = list_entry (pos, RFlagItem, list);
@ -153,6 +155,7 @@ static int filter(struct r_parse_t *p, struct r_flag_t *f, char *data, char *str
return R_TRUE;
}
}
ptr = ptr2;
}
strcpy (str, data);
return R_FALSE;