mirror of
https://github.com/radareorg/radare2.git
synced 2025-02-21 14:50:49 +00:00
Add r_bp_del_all (db-*) and fix some more bugs
This commit is contained in:
parent
5ec72d68c8
commit
887f15b03d
@ -166,6 +166,13 @@ R_API struct r_bp_item_t *r_bp_add_hw(RBreakpoint *bp, ut64 addr, int size, int
|
||||
return r_bp_add (bp, NULL, addr, size, R_BP_TYPE_HW, rwx);
|
||||
}
|
||||
|
||||
R_API int r_bp_del_all(RBreakpoint *bp) {
|
||||
if (r_list_empty (bp->bps))
|
||||
return R_FALSE;
|
||||
r_list_purge (bp->bps);
|
||||
return R_TRUE;
|
||||
}
|
||||
|
||||
R_API int r_bp_del(RBreakpoint *bp, ut64 addr) {
|
||||
RListIter *iter;
|
||||
RBreakpointItem *b;
|
||||
|
@ -85,7 +85,7 @@ static int var_cmd(RCore *core, const char *str) {
|
||||
int rw = 0; // 0 = read, 1 = write
|
||||
char kind = 'v';
|
||||
RAnalVar *var = r_anal_var_get (core->anal, fcn->addr,
|
||||
kind, atoi (str+2), R_ANAL_VAR_SCOPE_LOCAL);
|
||||
&kind, atoi (str+2), R_ANAL_VAR_SCOPE_LOCAL);
|
||||
if (var != NULL) {
|
||||
int scope = (str[1]=='g')?0: 1;
|
||||
r_anal_var_access (core->anal, fcn->addr, kind,
|
||||
@ -120,10 +120,9 @@ static int var_cmd(RCore *core, const char *str) {
|
||||
p3=p3+1;
|
||||
}
|
||||
// p2 - name of variable
|
||||
r_anal_var_add (core->anal, fcn, core->offset, delta, scope,
|
||||
r_anal_var_add (core->anal, fcn->addr, core->offset, delta, scope,
|
||||
//r_anal_str_to_type (core->anal, p)
|
||||
NULL
|
||||
, p2, p3? atoi (p3): 0);
|
||||
NULL, p3? atoi (p3): 0, p2);
|
||||
} else var_help (*str);
|
||||
break;
|
||||
default:
|
||||
|
@ -688,7 +688,9 @@ static void r_core_cmd_bp(RCore *core, const char *input) {
|
||||
case '*': r_bp_list (core->dbg->bp, 1); break;
|
||||
case '\0': r_bp_list (core->dbg->bp, 0); break;
|
||||
case '-':
|
||||
r_bp_del (core->dbg->bp, r_num_math (core->num, input+2));
|
||||
if (input[2] == '*') {
|
||||
r_bp_del_all (core->dbg->bp);
|
||||
} else r_bp_del (core->dbg->bp, r_num_math (core->num, input+2));
|
||||
break;
|
||||
case 'c':
|
||||
addr = r_num_math (core->num, input+2);
|
||||
|
@ -31,13 +31,12 @@ static int cmd_help(void *data, const char *input) {
|
||||
if (input[1] == '6' && input[2] == '4') {
|
||||
//b64 decoding takes at most strlen(str) * 4
|
||||
const int buflen = (strlen (input+3) * 4) + 1;
|
||||
unsigned char* buf = calloc (buflen, sizeof(char));
|
||||
ut8* buf = calloc (buflen, sizeof(char));
|
||||
if (!buf)
|
||||
return R_FALSE;
|
||||
if (input[3] == '-')
|
||||
r_base64_decode (buf, input+5, strlen (input+5));
|
||||
else
|
||||
r_base64_encode (buf, input+4, strlen (input+4));
|
||||
else r_base64_encode (buf, (const ut8*)input+4, strlen (input+4));
|
||||
r_cons_printf ("%s\n", buf);
|
||||
free (buf);
|
||||
} else {
|
||||
|
@ -1176,11 +1176,11 @@ static int handle_print_middle (RCore *core, RDisasmState *ds, int ret ){
|
||||
}
|
||||
|
||||
static int handle_print_fcn_locals (RCore *core, RDisasmState *ds, RAnalFunction *f, RAnalFunction *cf) {
|
||||
RAnalFcnLocal *l;
|
||||
RListIter *iter;
|
||||
ut8 have_local = 0;
|
||||
eprintf ("TODO: sdbize locals\n");
|
||||
#if 0
|
||||
RAnalFcnLocal *l;
|
||||
RListIter *iter;
|
||||
r_list_foreach (f->locals, iter, l) {
|
||||
if (ds->analop.jump == l->addr) {
|
||||
if ((cf != NULL) && (f->addr == cf->addr)) {
|
||||
|
@ -235,7 +235,7 @@ static int r_core_file_do_load_for_debug (RCore *r, ut64 loadaddr, const char *f
|
||||
RBinFile *binfile = NULL;
|
||||
RBinPlugin *plugin;
|
||||
ut64 baseaddr = 0;
|
||||
int va = r->io->va || r->io->debug;
|
||||
//int va = r->io->va || r->io->debug;
|
||||
int xtr_idx = 0; // if 0, load all if xtr is used
|
||||
int treat_as_rawstr = R_FALSE;
|
||||
|
||||
@ -622,7 +622,6 @@ R_API RCoreFile *r_core_file_open(RCore *r, const char *file, int mode, ut64 loa
|
||||
return fh;
|
||||
}
|
||||
|
||||
|
||||
R_API int r_core_files_free (const RCore *core, RCoreFile *cf) {
|
||||
if (!core || !core->files || !cf) return R_FALSE;
|
||||
return r_list_delete_data (core->files, cf);
|
||||
@ -725,10 +724,11 @@ R_API int r_core_file_bin_raise (RCore *core, ut32 binfile_idx) {
|
||||
|
||||
R_API int r_core_file_binlist(RCore *core) {
|
||||
int count = 0;
|
||||
RCoreFile *f;
|
||||
RCoreFile *f = NULL;
|
||||
RListIter *iter;
|
||||
RCoreFile *cur_cf = core->file, *cf = NULL;
|
||||
RBinFile *cur_bf = r_core_bin_cur (core), *binfile = NULL;
|
||||
RCoreFile *cur_cf = core->file;
|
||||
//RBinFile *cur_bf = r_core_bin_cur (core);
|
||||
RBinFile *binfile = NULL;
|
||||
RBin *bin = core->bin;
|
||||
const RList *binfiles = bin ? bin->binfiles: NULL;
|
||||
|
||||
@ -736,8 +736,8 @@ R_API int r_core_file_binlist(RCore *core) {
|
||||
|
||||
r_list_foreach (binfiles, iter, binfile) {
|
||||
ut32 fd = binfile->fd;
|
||||
cf = r_core_file_get_by_fd (core, fd);
|
||||
if (cf && cf->map) {
|
||||
f = r_core_file_get_by_fd (core, fd);
|
||||
if (f && f->map) {
|
||||
r_cons_printf ("%c %d %s @ 0x%"PFMT64x" ; %s\n",
|
||||
core->io->raised == f->fd->fd?'*':'-',
|
||||
fd, f->uri, f->map->from,
|
||||
@ -853,13 +853,12 @@ R_API int r_core_file_set_by_file (RCore * core, RCoreFile *cf) {
|
||||
|
||||
R_API ut32 r_core_file_cur_fd (RCore *core) {
|
||||
RIODesc *desc = core->file ? core->file->fd : NULL;
|
||||
if (desc) {
|
||||
if (desc)
|
||||
return desc->fd;
|
||||
}
|
||||
return (ut32)-1;
|
||||
return UT32_MAX;
|
||||
}
|
||||
|
||||
R_API RCoreFile * r_core_file_cur (RCore *r) {
|
||||
// Add any locks here
|
||||
return r->file;
|
||||
}
|
||||
}
|
||||
|
@ -93,6 +93,7 @@ R_API RBreakpoint *r_bp_new();
|
||||
R_API RBreakpoint *r_bp_free(RBreakpoint *bp);
|
||||
|
||||
R_API int r_bp_del(RBreakpoint *bp, ut64 addr);
|
||||
R_API int r_bp_del_all(RBreakpoint *bp);
|
||||
|
||||
R_API int r_bp_plugin_add(RBreakpoint *bp, RBreakpointPlugin *foo);
|
||||
R_API int r_bp_use(RBreakpoint *bp, const char *name);
|
||||
|
@ -205,6 +205,7 @@ R_API int r_core_block_size(RCore *core, int bsize);
|
||||
R_API int r_core_read_at(RCore *core, ut64 addr, ut8 *buf, int size);
|
||||
R_API int r_core_shift_block(RCore *core, ut64 addr, ut64 b_size, st64 dist);
|
||||
R_API int r_core_visual(RCore *core, const char *input);
|
||||
R_API int r_core_visual_graph(RCore *core, RAnalFunction *_fcn);
|
||||
R_API int r_core_visual_cmd(RCore *core, int ch);
|
||||
R_API void r_core_visual_seek_animation (RCore *core, ut64 addr);
|
||||
R_API void r_core_visual_asm(RCore *core, ut64 addr);
|
||||
|
@ -51,7 +51,6 @@ R_API int r_list_length(RList *list) {
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
/* remove all elements of a list */
|
||||
R_API void r_list_purge (RList *list) {
|
||||
RListIter *it;
|
||||
@ -66,7 +65,6 @@ R_API void r_list_purge (RList *list) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* free the list */
|
||||
R_API void r_list_free (RList *list) {
|
||||
if (list) {
|
||||
@ -88,7 +86,6 @@ R_API boolt r_list_delete_data (RList *list, void *ptr) {
|
||||
return R_FALSE;
|
||||
}
|
||||
|
||||
|
||||
R_API void r_list_delete (RList *list, RListIter *iter) {
|
||||
r_list_split_iter (list, iter);
|
||||
if (list->free && iter->data)
|
||||
@ -97,7 +94,6 @@ R_API void r_list_delete (RList *list, RListIter *iter) {
|
||||
free (iter);
|
||||
}
|
||||
|
||||
|
||||
R_API void r_list_split (RList *list, void *ptr) {
|
||||
RListIter *iter = r_list_iterator (list);
|
||||
while (iter) {
|
||||
@ -111,7 +107,6 @@ R_API void r_list_split (RList *list, void *ptr) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
R_API void r_list_split_iter (RList *list, RListIter *iter) {
|
||||
if (list->head == iter) list->head = iter->n;
|
||||
if (list->tail == iter) list->tail = iter->p;
|
||||
@ -119,7 +114,6 @@ R_API void r_list_split_iter (RList *list, RListIter *iter) {
|
||||
if (iter->n) iter->n->p = iter->p;
|
||||
}
|
||||
|
||||
|
||||
//Warning: free functions must be compatible
|
||||
R_API void r_list_join (RList *list1, RList *list2) {
|
||||
if (list1->tail == NULL) {
|
||||
@ -130,28 +124,24 @@ R_API void r_list_join (RList *list1, RList *list2) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
R_API RList *r_list_new() {
|
||||
RList *list = R_NEW0(RList);
|
||||
r_list_init (list);
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
R_API RList *r_list_newf(RListFree f) {
|
||||
RList *l = r_list_new ();
|
||||
if (l) l->free = f;
|
||||
return l;
|
||||
}
|
||||
|
||||
|
||||
R_API RListIter *r_list_item_new (void *data) {
|
||||
RListIter *new = R_NEW (RListIter);
|
||||
new->data = data;
|
||||
return new;
|
||||
}
|
||||
|
||||
|
||||
R_API RListIter *r_list_append(RList *list, void *data) {
|
||||
RListIter *new = NULL;
|
||||
if (list && data) {
|
||||
@ -181,7 +171,6 @@ R_API RListIter *r_list_prepend(RList *list, void *data) {
|
||||
return new;
|
||||
}
|
||||
|
||||
|
||||
R_API void *r_list_pop(RList *list) {
|
||||
void *data = NULL;
|
||||
RListIter *iter;
|
||||
@ -199,7 +188,6 @@ R_API void *r_list_pop(RList *list) {
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
R_API int r_list_del_n(RList *list, int n) {
|
||||
RListIter *it;
|
||||
int i;
|
||||
@ -226,14 +214,12 @@ R_API int r_list_del_n(RList *list, int n) {
|
||||
return R_FALSE;
|
||||
}
|
||||
|
||||
|
||||
R_API void *r_list_get_top(RList *list) {
|
||||
if (list && list->tail)
|
||||
return list->tail->data;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
R_API void r_list_reverse(RList *list) {
|
||||
RListIter *it, *tmp;
|
||||
if (list) {
|
||||
@ -248,7 +234,6 @@ R_API void r_list_reverse(RList *list) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
R_API RList *r_list_clone (RList *list) {
|
||||
RList *l = NULL;
|
||||
RListIter *iter;
|
||||
@ -263,7 +248,6 @@ R_API RList *r_list_clone (RList *list) {
|
||||
return l;
|
||||
}
|
||||
|
||||
|
||||
R_API void r_list_sort(RList *list, RListComparator cmp) {
|
||||
RListIter *it;
|
||||
RListIter *it2;
|
||||
@ -278,31 +262,27 @@ R_API void r_list_sort(RList *list, RListComparator cmp) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
R_API RListIter *r_list_add_sorted(RList *list, void *data, RListComparator cmp) {
|
||||
RListIter *it, *new = NULL;
|
||||
if (list && data && cmp) {
|
||||
for (it = list->head; it && it->data && cmp (data, it->data)>0; it = it->n) ;
|
||||
if (it) {
|
||||
new = R_NEW (RListIter);
|
||||
new->n = it;
|
||||
new->p = it->p;
|
||||
new->data = data;
|
||||
new->n->p = new;
|
||||
if (new->p == NULL)
|
||||
list->head = new;
|
||||
else
|
||||
new->p->n = new;
|
||||
} else {
|
||||
r_list_append (list, data);
|
||||
}
|
||||
return new;
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
RListIter *it, *new = NULL;
|
||||
if (list && data && cmp) {
|
||||
for (it = list->head; it && it->data && cmp (data, it->data)>0; it = it->n) ;
|
||||
if (it) {
|
||||
new = R_NEW (RListIter);
|
||||
new->n = it;
|
||||
new->p = it->p;
|
||||
new->data = data;
|
||||
new->n->p = new;
|
||||
if (new->p == NULL)
|
||||
list->head = new;
|
||||
else new->p->n = new;
|
||||
} else {
|
||||
r_list_append (list, data);
|
||||
}
|
||||
return new;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
R_API int r_list_set_n(RList *list, int n, void *p) {
|
||||
RListIter *it;
|
||||
int i;
|
||||
@ -316,7 +296,6 @@ R_API int r_list_set_n(RList *list, int n, void *p) {
|
||||
return R_FALSE;
|
||||
}
|
||||
|
||||
|
||||
R_API void *r_list_get_n(RList *list, int n) {
|
||||
RListIter *it;
|
||||
int i;
|
||||
@ -327,7 +306,6 @@ R_API void *r_list_get_n(RList *list, int n) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
R_API void *r_list_get_by_int(RList *list, int off, int n) {
|
||||
ut8 *p;
|
||||
RListIter *iter;
|
||||
@ -338,7 +316,6 @@ R_API void *r_list_get_by_int(RList *list, int off, int n) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
R_API void *r_list_get_by_int64(RList *list, int off, ut64 n) {
|
||||
ut8 *p;
|
||||
RListIter *iter;
|
||||
@ -349,7 +326,6 @@ R_API void *r_list_get_by_int64(RList *list, int off, ut64 n) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
R_API void *r_list_get_by_string(RList *list, int off, const char *str) {
|
||||
char *p;
|
||||
RListIter *iter;
|
||||
@ -361,7 +337,6 @@ R_API void *r_list_get_by_string(RList *list, int off, const char *str) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
R_API RListIter *r_list_contains (RList *list, void *p) {
|
||||
void *q;
|
||||
RListIter *iter;
|
||||
@ -372,7 +347,6 @@ R_API RListIter *r_list_contains (RList *list, void *p) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
R_API RListIter *r_list_find (RList *list, void *p, RListComparator cmp) {
|
||||
void *q;
|
||||
RListIter *iter;
|
||||
|
Loading…
x
Reference in New Issue
Block a user