mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-08-07 14:28:40 +00:00
eliminate weird rollback/re-adjust rules for threads hitting int3s - rollback should only ever happen for temporary traps, e.g. user breakpoints or stepping. the fact that the thread shows *after* the trap later is a visualization issue, not a functionality issue
This commit is contained in:
@@ -1544,32 +1544,6 @@ dmn_ctrl_run(Arena *arena, DMN_CtrlCtx *ctx, DMN_RunCtrls *ctrls)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////
|
|
||||||
//- rjf: if run threads are marked as having reported an explicit trap
|
|
||||||
// on their last run, shift their RIPs past that trap instruction, so
|
|
||||||
// that they may continue
|
|
||||||
//
|
|
||||||
for(DMN_W32_EntityNode *n = first_run_thread; n != 0; n = n->next)
|
|
||||||
{
|
|
||||||
DMN_W32_Entity *thread = n->v;
|
|
||||||
if(thread->thread.last_run_reported_trap)
|
|
||||||
{
|
|
||||||
Temp temp = temp_begin(scratch.arena);
|
|
||||||
U64 regs_block_size = regs_block_size_from_architecture(thread->arch);
|
|
||||||
void *regs_block = push_array(temp.arena, U8, regs_block_size);
|
|
||||||
B32 good = dmn_w32_thread_read_reg_block(thread->arch, thread->handle, regs_block);
|
|
||||||
U64 pre_rip = regs_rip_from_arch_block(thread->arch, regs_block);
|
|
||||||
if(good && pre_rip == thread->thread.last_run_reported_trap_pre_rip)
|
|
||||||
{
|
|
||||||
regs_arch_block_write_rip(thread->arch, regs_block, thread->thread.last_run_reported_trap_post_rip);
|
|
||||||
dmn_w32_thread_write_reg_block(thread->arch, thread->handle, regs_block);
|
|
||||||
}
|
|
||||||
temp_end(temp);
|
|
||||||
thread->thread.last_run_reported_trap = 0;
|
|
||||||
thread->thread.last_run_reported_trap_post_rip = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////
|
//////////////////////////
|
||||||
//- rjf: choose win32 resume code
|
//- rjf: choose win32 resume code
|
||||||
//
|
//
|
||||||
@@ -2007,7 +1981,7 @@ dmn_ctrl_run(Arena *arena, DMN_CtrlCtx *ctx, DMN_RunCtrls *ctrls)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//- rjf: determine whether to roll back instruction pointer
|
//- rjf: determine whether to roll back instruction pointer
|
||||||
B32 should_do_rollback = (is_trap);
|
B32 should_do_rollback = (hit_user_trap);
|
||||||
|
|
||||||
//- rjf: roll back thread's instruction pointer
|
//- rjf: roll back thread's instruction pointer
|
||||||
U64 post_trap_rip = 0;
|
U64 post_trap_rip = 0;
|
||||||
@@ -2044,14 +2018,6 @@ dmn_ctrl_run(Arena *arena, DMN_CtrlCtx *ctx, DMN_RunCtrls *ctrls)
|
|||||||
e->flags = exception->ExceptionFlags;
|
e->flags = exception->ExceptionFlags;
|
||||||
e->instruction_pointer = (U64)exception->ExceptionAddress;
|
e->instruction_pointer = (U64)exception->ExceptionAddress;
|
||||||
|
|
||||||
// rjf: explicit trap -> mark this thread as having reported this trap
|
|
||||||
if(hit_explicit_trap)
|
|
||||||
{
|
|
||||||
thread->thread.last_run_reported_trap = 1;
|
|
||||||
thread->thread.last_run_reported_trap_pre_rip = instruction_pointer;
|
|
||||||
thread->thread.last_run_reported_trap_post_rip = post_trap_rip;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- rjf: fill according to exception code
|
//- rjf: fill according to exception code
|
||||||
switch(exception->ExceptionCode)
|
switch(exception->ExceptionCode)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -118,9 +118,6 @@ struct DMN_W32_Entity
|
|||||||
U64 thread_local_base;
|
U64 thread_local_base;
|
||||||
U64 last_name_hash;
|
U64 last_name_hash;
|
||||||
U64 name_gather_time_us;
|
U64 name_gather_time_us;
|
||||||
B32 last_run_reported_trap;
|
|
||||||
U64 last_run_reported_trap_pre_rip;
|
|
||||||
U64 last_run_reported_trap_post_rip;
|
|
||||||
}
|
}
|
||||||
thread;
|
thread;
|
||||||
struct
|
struct
|
||||||
|
|||||||
@@ -2280,6 +2280,10 @@ debug_string_tests(void)
|
|||||||
static void
|
static void
|
||||||
interrupt_stepping_tests(void)
|
interrupt_stepping_tests(void)
|
||||||
{
|
{
|
||||||
|
__debugbreak();
|
||||||
|
__debugbreak();
|
||||||
|
__debugbreak();
|
||||||
|
__debugbreak();
|
||||||
for(int i = 0; i < 1000; i += 1)
|
for(int i = 0; i < 1000; i += 1)
|
||||||
{
|
{
|
||||||
if(i == 999)
|
if(i == 999)
|
||||||
@@ -2297,6 +2301,19 @@ interrupt_stepping_tests(void)
|
|||||||
int x = 0;
|
int x = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
//~ rjf: JIT Stepping Tests
|
||||||
|
|
||||||
|
static void
|
||||||
|
jit_stepping_tests(void)
|
||||||
|
{
|
||||||
|
OutputDebugString("A\n");
|
||||||
|
VOID *code = VirtualAlloc(0, 0x1000, MEM_COMMIT|MEM_RESERVE, PAGE_EXECUTE_READWRITE);
|
||||||
|
*((uint32_t*)code) = 0xC39090CC;
|
||||||
|
((void (__fastcall *)()) code)();
|
||||||
|
OutputDebugString("B\n");
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
// NOTE(allen): Exception Stepping
|
// NOTE(allen): Exception Stepping
|
||||||
|
|
||||||
@@ -2592,6 +2609,8 @@ mule_main(int argc, char** argv){
|
|||||||
|
|
||||||
debug_string_tests();
|
debug_string_tests();
|
||||||
|
|
||||||
|
jit_stepping_tests();
|
||||||
|
|
||||||
interrupt_stepping_tests();
|
interrupt_stepping_tests();
|
||||||
|
|
||||||
exception_stepping_tests();
|
exception_stepping_tests();
|
||||||
|
|||||||
@@ -39,5 +39,4 @@ dll_type_eval_tests(void)
|
|||||||
Basics basics2 = {4, 5, 6, 7};
|
Basics basics2 = {4, 5, 6, 7};
|
||||||
int x = 0;
|
int x = 0;
|
||||||
(void)x;
|
(void)x;
|
||||||
*(int *)0 = 0;
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user