Removed end point trace session

This commit is contained in:
Ren Kimura 2017-06-28 07:56:41 +09:00 committed by radare
parent 34dfc489c8
commit fd765893dc
3 changed files with 31 additions and 22 deletions

View File

@ -932,11 +932,8 @@ R_API int r_debug_step_back(RDebug *dbg) {
end = r_debug_reg_get (dbg, dbg->reg->name[R_REG_NAME_PC]);
/* Save current session. It is marked as a finish point of reverse execution */
r_debug_session_add (dbg, &tail);
/* Get previous state */
before = r_debug_session_get (dbg, tail);
before = r_debug_session_get (dbg, dbg->sessions->tail);
if (!before) {
return 0;
}
@ -946,7 +943,7 @@ R_API int r_debug_step_back(RDebug *dbg) {
r_debug_session_set (dbg, before);
pc = r_debug_reg_get (dbg, dbg->reg->name[R_REG_NAME_PC]);
eprintf ("execute from 0x%08"PFMT64x" to 0x%08"PFMT64x"\n", pc, end);
//eprintf ("execute from 0x%08"PFMT64x" to 0x%08"PFMT64x"\n", pc, end);
/* Get the previous operation address.
* XXX: too slow... */

View File

@ -157,14 +157,9 @@ R_API bool r_debug_session_set_idx(RDebug *dbg, int idx) {
/* Get most recent used session at the time */
R_API RDebugSession *r_debug_session_get(RDebug *dbg, RListIter *tail) {
RDebugSession *session;
RListIter *prev;
if (!tail) {
return NULL;
}
prev = tail->p;
if (!prev) {
return NULL;
}
session = (RDebugSession *) prev->data;
session = (RDebugSession *) tail->data;
return session;
}

View File

@ -114,11 +114,17 @@ static void r_page_data_set(RDebug *dbg, RPageData *page) {
R_API void r_debug_diff_set(RDebug *dbg, RDebugSnapDiff *diff) {
RPageData *prev_page, *last_page;
RDebugSnap *snap = diff->base;
// assert (r_list_length (snap->history) > 0);
RDebugSnapDiff *latest = (RDebugSnapDiff *) r_list_tail (snap->history)->data;
RDebugMap *cur_map = r_debug_map_get (dbg, snap->addr + 1);
RDebugSnapDiff *latest;
ut64 addr;
ut32 page_off;
/* Save current snapshot. It is marked as a finish point of reverse execution */
latest = r_debug_snap_map (dbg, cur_map);
if (!latest) {
return;
}
eprintf ("Apply diff [0x%08"PFMT64x ", 0x%08"PFMT64x "]\n", snap->addr, snap->addr_end);
/* Role back page datas that's been changed **after** specified SnapDiff 'diff' */
@ -142,19 +148,26 @@ R_API void r_debug_diff_set(RDebug *dbg, RDebugSnapDiff *diff) {
eprintf ("Update 0x%08"PFMT64x "(page: %d)\n", addr, page_off);
}
}
r_list_pop (snap->history);
r_debug_diff_free (latest);
}
/* Role back to base snapshot */
R_API void r_debug_diff_set_base(RDebug *dbg, RDebugSnap *base) {
RPageData *last_page;
RDebugMap *cur_map = r_debug_map_get (dbg, base->addr + 1);
RDebugSnapDiff *latest;
eprintf ("Role back to base [0x%08"PFMT64x ", 0x%08"PFMT64x "]\n", base->addr, base->addr_end);
ut64 addr;
ut32 page_off;
if (!r_list_length (base->history)) {
/* Save current snapshot. It is marked as a finish point of reverse execution */
latest = r_debug_snap_map (dbg, cur_map);
if (!latest) {
return;
}
latest = (RDebugSnapDiff *) r_list_tail (base->history)->data;
eprintf ("Role back to base [0x%08"PFMT64x ", 0x%08"PFMT64x "]\n", cur_map->addr, cur_map->addr_end);
for (addr = base->addr; addr < base->addr_end; addr += SNAP_PAGE_SIZE) {
page_off = (addr - base->addr) / SNAP_PAGE_SIZE;
if ((last_page = latest->last_changes[page_off])) {
@ -164,6 +177,9 @@ R_API void r_debug_diff_set_base(RDebug *dbg, RDebugSnap *base) {
eprintf ("Role back 0x%08"PFMT64x "(page: %d)\n", addr, page_off);
}
}
r_list_pop (base->history);
r_debug_diff_free (latest);
}
// XXX: snap_set will be duplicated soon
@ -195,7 +211,7 @@ R_API int r_debug_snap_set_idx(RDebug *dbg, int idx) {
eprintf ("%02"PFMT32x, hash[i]);
}
eprintf ("\n");
} */
}*/
R_API RDebugSnapDiff *r_debug_snap_map(RDebug *dbg, RDebugMap *map) {
if (!dbg || !map || map->size < 1) {
@ -329,7 +345,6 @@ R_API RDebugSnapDiff *r_debug_diff_add(RDebug *dbg, RDebugSnap *base) {
new_diff->base = base;
new_diff->pages = r_list_newf (r_page_data_free);
new_diff->last_changes = R_NEWS0 (RPageData *, base->page_num);
if (r_list_length (base->history)) {
/* Inherit last changes from previous SnapDiff */
prev_diff = (RDebugSnapDiff *) r_list_tail (base->history)->data;
@ -349,11 +364,11 @@ R_API RDebugSnapDiff *r_debug_diff_add(RDebug *dbg, RDebugSnap *base) {
/* Check If there is any last change for this page. */
if (prev_diff && (last_page = prev_diff->last_changes[page_off])) {
/* Use hash of last SnapDiff */
// eprintf ("found diff\n");
// eprintf ("use hash of diff\n");
prev_hash = last_page->hash;
} else {
/* Use hash of base snapshot */
// eprintf ("use base\n");
// eprintf ("use hash of base\n");
prev_hash = base->hashes[page_off];
}
/* Memory has been changed. So add new diff entry for this addr */
@ -371,13 +386,15 @@ R_API RDebugSnapDiff *r_debug_diff_add(RDebug *dbg, RDebugSnap *base) {
}
}
if (r_list_length (new_diff->pages)) {
#if 0
RPageData *page;
RListIter *iter;
eprintf ("saved: 0x%08"PFMT64x "(page: ", addr);
eprintf ("saved: 0x%08"PFMT64x "(page: ", base->addr);
r_list_foreach (new_diff->pages, iter, page) {
eprintf ("%d ", page->page_off);
eprintf ("%d ", page->page_off);
}
eprintf (")\n");
#endif
r_list_append (base->history, new_diff);
return new_diff;
} else {