mirror of
https://github.com/radareorg/radare2.git
synced 2025-01-23 14:28:07 +00:00
some fix in windows debugger
This commit is contained in:
parent
887897e02b
commit
39c4a0c35f
16
libr/debug/debug.c
Normal file → Executable file
16
libr/debug/debug.c
Normal file → Executable file
@ -542,7 +542,6 @@ R_API RDebugReasonType r_debug_wait(RDebug *dbg) {
|
||||
/* if our debugger plugin has wait */
|
||||
if (dbg->h && dbg->h->wait) {
|
||||
reason = dbg->h->wait (dbg, dbg->pid);
|
||||
|
||||
if (reason == R_DEBUG_REASON_DEAD) {
|
||||
eprintf ("\n==> Process finished\n\n");
|
||||
// XXX(jjd): TODO: handle fallback or something else
|
||||
@ -753,7 +752,7 @@ R_API void r_debug_io_bind(RDebug *dbg, RIO *io) {
|
||||
|
||||
R_API int r_debug_step_over(RDebug *dbg, int steps) {
|
||||
RAnalOp op;
|
||||
ut64 buf_pc, pc;
|
||||
ut64 buf_pc, pc, ins_size;
|
||||
ut8 buf[DBG_BUF_SIZE];
|
||||
int steps_taken = 0;
|
||||
|
||||
@ -791,21 +790,24 @@ R_API int r_debug_step_over(RDebug *dbg, int steps) {
|
||||
eprintf ("Decode error at %"PFMT64x"\n", pc);
|
||||
return steps_taken;
|
||||
}
|
||||
|
||||
if (op.fail == -1) {
|
||||
ins_size = pc + op.size;
|
||||
} else {
|
||||
// Use op.fail here instead of pc+op.size to enforce anal backends to fill in this field
|
||||
ins_size = op.fail;
|
||||
}
|
||||
// Skip over all the subroutine calls
|
||||
if (op.type == R_ANAL_OP_TYPE_CALL ||
|
||||
op.type == R_ANAL_OP_TYPE_CCALL ||
|
||||
op.type == R_ANAL_OP_TYPE_UCALL ||
|
||||
op.type == R_ANAL_OP_TYPE_UCCALL) {
|
||||
|
||||
// Use op.fail here instead of pc+op.size to enforce anal backends to fill in this field
|
||||
if (!r_debug_continue_until (dbg, op.fail)) {
|
||||
if (!r_debug_continue_until (dbg, ins_size)) {
|
||||
eprintf ("Could not step over call @ 0x%"PFMT64x"\n", pc);
|
||||
return steps_taken;
|
||||
}
|
||||
} else if ((op.prefix & (R_ANAL_OP_PREFIX_REP | R_ANAL_OP_PREFIX_REPNE | R_ANAL_OP_PREFIX_LOCK))) {
|
||||
//eprintf ("REP: skip to next instruction...\n");
|
||||
if (!r_debug_continue_until (dbg, pc+op.size)) {
|
||||
if (!r_debug_continue_until (dbg, ins_size)) {
|
||||
eprintf ("step over failed over rep\n");
|
||||
return steps_taken;
|
||||
}
|
||||
|
8
libr/debug/p/debug_native.c
Normal file → Executable file
8
libr/debug/p/debug_native.c
Normal file → Executable file
@ -287,10 +287,10 @@ static RDebugReasonType r_debug_native_wait (RDebug *dbg, int pid) {
|
||||
|
||||
#if __WINDOWS__ && !__CYGWIN__
|
||||
int mode = 0;
|
||||
status = w32_dbg_wait (dbg, pid);
|
||||
if (status == R_DEBUG_REASON_NEW_LIB) {
|
||||
reason = w32_dbg_wait (dbg, pid);
|
||||
if (reason == R_DEBUG_REASON_NEW_LIB) {
|
||||
mode = 'l';
|
||||
} else if (status == R_DEBUG_REASON_EXIT_LIB) {
|
||||
} else if (reason == R_DEBUG_REASON_EXIT_LIB) {
|
||||
mode = 'u';
|
||||
} else {
|
||||
mode = 0;
|
||||
@ -299,7 +299,7 @@ static RDebugReasonType r_debug_native_wait (RDebug *dbg, int pid) {
|
||||
RDebugInfo *r = r_debug_native_info (dbg, "");
|
||||
if (r && r->lib) {
|
||||
if (tracelib (dbg, mode=='l'? "load":"unload", r->lib))
|
||||
status = R_DEBUG_REASON_TRAP;
|
||||
reason = R_DEBUG_REASON_TRAP;
|
||||
} else {
|
||||
eprintf ("%soading unknown library.\n", mode?"L":"Unl");
|
||||
}
|
||||
|
37
libr/debug/p/native/w32.c
Normal file → Executable file
37
libr/debug/p/native/w32.c
Normal file → Executable file
@ -587,13 +587,8 @@ static int w32_dbg_wait(RDebug *dbg, int pid) {
|
||||
if (dllname) {
|
||||
free (dllname);
|
||||
}
|
||||
next_event = 1;
|
||||
return R_DEBUG_REASON_NEW_LIB;
|
||||
/*
|
||||
r_debug_native_continue (dbg, pid, tid, -1);
|
||||
next_event = 1;
|
||||
next_event = 0;
|
||||
ret = R_DEBUG_REASON_NEW_LIB;
|
||||
*/
|
||||
break;
|
||||
case UNLOAD_DLL_DEBUG_EVENT:
|
||||
//eprintf ("(%d) Unloading library at %p\n", pid, de.u.UnloadDll.lpBaseOfDll);
|
||||
@ -605,13 +600,8 @@ static int w32_dbg_wait(RDebug *dbg, int pid) {
|
||||
if (dllname)
|
||||
free(dllname);
|
||||
}
|
||||
next_event = 1;
|
||||
return R_DEBUG_REASON_EXIT_LIB;
|
||||
/*
|
||||
r_debug_native_continue (dbg, pid, tid, -1);
|
||||
next_event = 1;
|
||||
next_event = 0;
|
||||
ret = R_DEBUG_REASON_EXIT_LIB;
|
||||
*/
|
||||
break;
|
||||
case OUTPUT_DEBUG_STRING_EVENT:
|
||||
eprintf ("(%d) Debug string\n", pid);
|
||||
@ -625,19 +615,32 @@ static int w32_dbg_wait(RDebug *dbg, int pid) {
|
||||
// XXX unknown ret = R_DEBUG_REASON_TRAP;
|
||||
break;
|
||||
case EXCEPTION_DEBUG_EVENT:
|
||||
next_event = debug_exception_event (&de);
|
||||
if (!next_event) {
|
||||
return R_DEBUG_REASON_TRAP;
|
||||
} else {
|
||||
switch (de.u.Exception.ExceptionRecord.ExceptionCode) {
|
||||
case EXCEPTION_BREAKPOINT:
|
||||
ret = R_DEBUG_REASON_BREAKPOINT;
|
||||
next_event = 0;
|
||||
break;
|
||||
case EXCEPTION_SINGLE_STEP:
|
||||
ret = R_DEBUG_REASON_STEP;
|
||||
next_event = 0;
|
||||
break;
|
||||
default:
|
||||
if (!debug_exception_event (&de)) {
|
||||
ret = R_DEBUG_REASON_TRAP;
|
||||
next_event = 0;
|
||||
}
|
||||
else {
|
||||
next_event = 1;
|
||||
r_debug_native_continue (dbg, pid, tid, -1);
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
default:
|
||||
eprintf ("(%d) unknown event: %d\n", pid, code);
|
||||
return -1;
|
||||
}
|
||||
} while (next_event);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user