rizin/libr/debug/map.c
pancake 822a33377b * Initial working implementation of the r_diff with delta in C
- Uses the mercurial's C algorithm for delta diffing
  - Remove r_diff_lines .. do we need a line-level diffing tool?
  - Remove -l flag from radiff2
* Rename RIo to RIO
* Added r_reg_arena_new () to simplify arena creation
  - Some sanity fixes in r_reg arena.c
* Add -C in rasm2 to output in C string format
* Initial working implementation of r_debug_execute to inject code
  in child process and restore memory and registers
  - Returns %a0 register value in ut64
* Added 'c' command to r_core - to compare -- just dummy
  - Will use r_diff
  - if rdiff callback returns NULL, we must stop scanning
  - old r_diff_buffers_delta is now named buffers_radiff
  - Added test files in diff/t/{file1,file2}
* Added doc/plugins documentation file
* Fix ${EXT_SO} in bin/p and asm/p (dejavu?)
* Added dummy asm_gas r_asm plugin
* Various random syntax fixes
* Rename 'dbg.ptrace' to 'dbg.native'
* Added r_debug_io_bind () to sync dbg and bp io_bind
* r_debug_map_list is now in a nicer format
* Append ${EXT_EXE} in diff/t
* Add missing util/log.c and vapi/r_line.vapi

--HG--
rename : libr/debug/p/debug_ptrace.c => libr/debug/p/debug_native.c
rename : libr/debug/p/ptrace.mk => libr/debug/p/native.mk
2010-02-05 12:21:37 +01:00

120 lines
2.7 KiB
C

/* radare - LGPL - Copyright 2009-2010 pancake<nopcode.org> */
#include <r_debug.h>
#include <r_list.h>
R_API void r_debug_map_list(struct r_debug_t *dbg, ut64 addr) {
char here;
RListIter *iter = r_list_iterator (dbg->maps);
while (r_list_iter_next (iter)) {
RDebugMap *map = r_list_iter_get (iter);
if (addr>=map->addr && addr<=map->addr_end)
here = '*';
else here = '-';
eprintf ("sys 0x%08llx %c 0x%08llx %c %x %s\n",
map->addr, here, map->addr_end,
map->user?'u':'s',
map->perm, map->name);
}
iter = r_list_iterator (dbg->maps_user);
while (r_list_iter_next (iter)) {
RDebugMap *map = r_list_iter_get (iter);
eprintf ("usr 0x%08llx - 0x%08llx %c %x %s\n",
map->addr, map->addr_end,
map->user?'u':'s',
map->perm, map->name);
}
}
R_API RDebugMap *r_debug_map_new (char *name, ut64 addr, ut64 addr_end, int perm, int user) {
RDebugMap *map;
if (name == NULL || addr >= addr_end)
return NULL;
map = R_NEW (RDebugMap);
if (map) {
map->name = strdup (name);
map->addr = addr;
map->addr_end = addr_end;
map->size = addr_end-addr;
map->perm = perm;
map->user = user;
}
return map;
}
R_API int r_debug_map_sync(RDebug *dbg) {
int ret = R_FALSE;
RList *newmaps;
if (dbg->h && dbg->h->map_get) {
newmaps = dbg->h->map_get (dbg);
if (newmaps) {
// XXX free all non-user maps // but not unallocate!! only unlink from list
r_debug_map_list_free (dbg->maps);
dbg->maps = newmaps;
ret = R_TRUE;
}
}
return ret;
}
R_API int r_debug_map_alloc(RDebug *dbg, RDebugMap *map)
{
int ret = R_FALSE;
if (dbg->h && dbg->h->map_alloc) {
if (dbg->h->map_alloc (dbg, map)) {
ret = R_TRUE;
r_list_append (dbg->maps_user, map);
}
}
return ret;
}
R_API int r_debug_map_dealloc(RDebug *dbg, RDebugMap *map)
{
int ret = R_FALSE;
ut64 addr = map->addr;
if (dbg->h && dbg->h->map_dealloc)
if (dbg->h->map_dealloc (dbg, addr)) {
ret = R_TRUE;
r_list_unlink (dbg->maps_user, map);
}
//r_debug_map_free (map);
return ret;
}
R_API RDebugMap *r_debug_map_get(RDebug *dbg, ut64 addr) {
RDebugMap *ret = NULL;
RListIter *iter = r_list_iterator (dbg->maps);
while (r_list_iter_next (iter)) {
RDebugMap *map = r_list_iter_get (iter);
if (addr >= map->addr && addr <= map->addr_end) {
ret = map;
break;
}
}
return ret;
}
R_API void r_debug_map_free(RDebugMap *map)
{
//r_list_unlink (dbg->maps_user, map);
free (map->name);
free (map);
}
R_API RList *r_debug_map_list_new()
{
RList *list = r_list_new ();
list->free = r_debug_map_free;
return list;
}
R_API void r_debug_map_list_free(RList *maps)
{
RListIter *iter = r_list_iterator (maps);
while (r_list_iter_next (iter)) {
RDebugMap *map = r_list_iter_get (iter);
r_debug_map_free (map);
}
r_list_free (maps);
}