Add snap_set command (#7032)

This commit is contained in:
Ren Kimura 2017-03-16 18:09:17 +09:00 committed by radare
parent bf5649a2e9
commit 863e3566d2
3 changed files with 22 additions and 0 deletions

View File

@ -584,6 +584,7 @@ static int cmd_debug_map_snapshot(RCore *core, const char *input) {
"dms*", "", "list snapshots in r2 commands",
"dms", " addr", "take snapshot with given id of map at address",
"dms", "-id", "delete memory snapshot",
"dmsA", " id", "apply memory snapshot",
"dmsC", " id comment", "add comment for given snapshot",
"dmsd", " id", "hexdiff given snapshot. See `ccc`.",
"dmsw", "", "snapshot of the writable maps",
@ -658,6 +659,9 @@ static int cmd_debug_map_snapshot(RCore *core, const char *input) {
case ' ':
r_debug_snap (core->dbg, r_num_math (core->num, input + 1));
break;
case 'A':
r_debug_snap_set (core->dbg, atoi (input + 1));
break;
case 'C':
r_debug_snap_comment (core->dbg, atoi (input + 1), strchr (input, ' '));
break;

View File

@ -78,6 +78,23 @@ R_API RDebugSnap* r_debug_snap_get (RDebug *dbg, ut64 addr) {
return NULL;
}
R_API int r_debug_snap_set (RDebug *dbg, int idx) {
RDebugSnap *snap;
RListIter *iter;
ut32 count = 0;
if (!dbg || idx < 0)
return 0;
r_list_foreach (dbg->snaps, iter, snap) {
if (count == idx) {
eprintf ("Writing %d bytes to 0x%08"PFMT64x"...\n", snap->size, snap->addr);
dbg->iob.write_at (dbg->iob.io, snap->addr, snap->data, snap->size);
break;
}
count++;
}
return 1;
}
static int r_debug_snap_map (RDebug *dbg, RDebugMap *map) {
RDebugSnap *snap;
if (map->size<1) {

View File

@ -499,6 +499,7 @@ R_API int r_debug_snap(RDebug *dbg, ut64 addr);
R_API int r_debug_snap_comment (RDebug *dbg, int idx, const char *msg);
R_API int r_debug_snap_all(RDebug *dbg, int perms);
R_API RDebugSnap* r_debug_snap_get (RDebug *dbg, ut64 addr);
R_API int r_debug_snap_set (RDebug *dbg, int idx);
/* plugin pointers */
extern RDebugPlugin r_debug_plugin_native;