mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-06-13 23:52:22 -07:00
pass through data breakpoint length, more progress on fixes/correctness in first pass
This commit is contained in:
+16
-2
@@ -121,6 +121,16 @@ ctrl_entity_kind_from_string(String8 string)
|
||||
return result;
|
||||
}
|
||||
|
||||
internal DMN_TrapFlags
|
||||
ctrl_dmn_trap_flags_from_user_breakpoint_flags(CTRL_UserBreakpointFlags flags)
|
||||
{
|
||||
DMN_TrapFlags result = 0;
|
||||
if(flags & CTRL_UserBreakpointFlag_BreakOnWrite) { result |= DMN_TrapFlag_BreakOnWrite; }
|
||||
if(flags & CTRL_UserBreakpointFlag_BreakOnRead) { result |= DMN_TrapFlag_BreakOnRead; }
|
||||
if(flags & CTRL_UserBreakpointFlag_BreakOnExecute) { result |= DMN_TrapFlag_BreakOnExecute; }
|
||||
return result;
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Machine/Handle Pair Type Functions
|
||||
|
||||
@@ -389,7 +399,7 @@ ctrl_serialized_string_from_msg_list(Arena *arena, CTRL_MsgList *msgs)
|
||||
str8_serial_push_struct(scratch.arena, &msgs_srlzed, &bp->string.size);
|
||||
str8_serial_push_data(scratch.arena, &msgs_srlzed, bp->string.str, bp->string.size);
|
||||
str8_serial_push_struct(scratch.arena, &msgs_srlzed, &bp->pt);
|
||||
str8_serial_push_struct(scratch.arena, &msgs_srlzed, &bp->u64);
|
||||
str8_serial_push_struct(scratch.arena, &msgs_srlzed, &bp->size);
|
||||
str8_serial_push_struct(scratch.arena, &msgs_srlzed, &bp->condition.size);
|
||||
str8_serial_push_data(scratch.arena, &msgs_srlzed, bp->condition.str, bp->condition.size);
|
||||
}
|
||||
@@ -512,7 +522,7 @@ ctrl_msg_list_from_serialized_string(Arena *arena, String8 string)
|
||||
bp->string.str = push_array_no_zero(arena, U8, bp->string.size);
|
||||
read_off += str8_deserial_read(string, read_off, bp->string.str, bp->string.size, 1);
|
||||
read_off += str8_deserial_read_struct(string, read_off, &bp->pt);
|
||||
read_off += str8_deserial_read_struct(string, read_off, &bp->u64);
|
||||
read_off += str8_deserial_read_struct(string, read_off, &bp->size);
|
||||
read_off += str8_deserial_read_struct(string, read_off, &bp->condition.size);
|
||||
bp->condition.str = push_array_no_zero(arena, U8, bp->condition.size);
|
||||
read_off += str8_deserial_read(string, read_off, bp->condition.str, bp->condition.size, 1);
|
||||
@@ -3561,6 +3571,8 @@ ctrl_thread__append_resolved_module_user_bp_traps(Arena *arena, CTRL_EvalScope *
|
||||
if(value.u64 != 0)
|
||||
{
|
||||
DMN_Trap trap = {process.dmn_handle, value.u64, (U64)bp};
|
||||
trap.flags = ctrl_dmn_trap_flags_from_user_breakpoint_flags(bp->flags);
|
||||
trap.size = bp->size;
|
||||
dmn_trap_chunk_list_push(arena, traps_out, 256, &trap);
|
||||
}
|
||||
}break;
|
||||
@@ -3582,6 +3594,8 @@ ctrl_thread__append_resolved_process_user_bp_traps(Arena *arena, CTRL_EvalScope
|
||||
if(value.u64 != 0)
|
||||
{
|
||||
DMN_Trap trap = {process.dmn_handle, value.u64, (U64)bp};
|
||||
trap.flags = ctrl_dmn_trap_flags_from_user_breakpoint_flags(bp->flags);
|
||||
trap.size = bp->size;
|
||||
dmn_trap_chunk_list_push(arena, traps_out, 256, &trap);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -283,7 +283,7 @@ struct CTRL_UserBreakpoint
|
||||
CTRL_UserBreakpointFlags flags;
|
||||
String8 string;
|
||||
TxtPt pt;
|
||||
U64 u64;
|
||||
U64 size;
|
||||
String8 condition;
|
||||
};
|
||||
|
||||
@@ -753,6 +753,7 @@ internal CTRL_ExceptionKind ctrl_exception_kind_from_dmn(DMN_ExceptionKind kind)
|
||||
internal String8 ctrl_string_from_event_kind(CTRL_EventKind kind);
|
||||
internal String8 ctrl_string_from_msg_kind(CTRL_MsgKind kind);
|
||||
internal CTRL_EntityKind ctrl_entity_kind_from_string(String8 string);
|
||||
internal DMN_TrapFlags ctrl_dmn_trap_flags_from_user_breakpoint_flags(CTRL_UserBreakpointFlags flags);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Handle Type Functions
|
||||
|
||||
@@ -2420,6 +2420,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
|
||||
ctrl_user_bp.string = n->string;
|
||||
ctrl_user_bp.pt = bp->pt;
|
||||
ctrl_user_bp.condition = bp->condition;
|
||||
ctrl_user_bp.size = bp->size;
|
||||
ctrl_user_breakpoint_list_push(scratch.arena, &msg->user_bps, &ctrl_user_bp);
|
||||
}
|
||||
}
|
||||
@@ -2431,6 +2432,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
|
||||
ctrl_user_bp.flags = ctrl_bp_flags;
|
||||
ctrl_user_bp.string = bp->vaddr_expr;
|
||||
ctrl_user_bp.condition = bp->condition;
|
||||
ctrl_user_bp.size = bp->size;
|
||||
ctrl_user_breakpoint_list_push(scratch.arena, &msg->user_bps, &ctrl_user_bp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ struct D_Breakpoint
|
||||
TxtPt pt;
|
||||
String8 vaddr_expr;
|
||||
String8 condition;
|
||||
U64 size;
|
||||
};
|
||||
|
||||
typedef struct D_BreakpointArray D_BreakpointArray;
|
||||
|
||||
@@ -115,7 +115,7 @@ struct DMN_Trap
|
||||
U64 vaddr;
|
||||
U64 id;
|
||||
DMN_TrapFlags flags;
|
||||
U32 length;
|
||||
U32 size;
|
||||
};
|
||||
|
||||
typedef struct DMN_TrapChunkNode DMN_TrapChunkNode;
|
||||
|
||||
@@ -1630,7 +1630,7 @@ dmn_ctrl_run(Arena *arena, DMN_CtrlCtx *ctx, DMN_RunCtrls *ctrls)
|
||||
case Arch_x64:
|
||||
{
|
||||
REGS_RegBlockX64 regs = {0};
|
||||
dmn_thread_read_reg_block(ctrls->single_step_thread, ®s);
|
||||
dmn_w32_thread_read_reg_block(child->arch, child->handle, ®s);
|
||||
{
|
||||
U64 trap_idx = 0;
|
||||
for(DMN_TrapChunkNode *n = t->traps.first; n != 0; n = n->next)
|
||||
@@ -1648,8 +1648,9 @@ dmn_ctrl_run(Arena *arena, DMN_CtrlCtx *ctx, DMN_RunCtrls *ctrls)
|
||||
case 3:{addr_reg = ®s.dr3;}break;
|
||||
}
|
||||
addr_reg->u64 = trap->vaddr;
|
||||
regs.dr7.u64 |= (1ull << (trap_idx*4));
|
||||
regs.dr7.u64 &= ~((U64)(bit16|bit17|bit18|bit19) << (trap_idx*4));
|
||||
regs.dr7.u64 |= (1ull << (trap_idx*2));
|
||||
regs.dr7.u64 |= (1ull << (trap_idx*2+1));
|
||||
regs.dr7.u64 &= ~((U64)(bit17|bit18|bit19|bit20) << (trap_idx*4));
|
||||
switch(trap->flags)
|
||||
{
|
||||
case DMN_TrapFlag_BreakOnExecute:
|
||||
@@ -1657,37 +1658,37 @@ dmn_ctrl_run(Arena *arena, DMN_CtrlCtx *ctx, DMN_RunCtrls *ctrls)
|
||||
case DMN_TrapFlag_BreakOnWrite:
|
||||
case DMN_TrapFlag_BreakOnWrite|DMN_TrapFlag_BreakOnExecute:
|
||||
{
|
||||
regs.dr7.u64 |= ((U64)bit16) << (trap_idx*4);
|
||||
regs.dr7.u64 |= ((U64)bit17) << (trap_idx*4);
|
||||
}break;
|
||||
case DMN_TrapFlag_BreakOnRead|DMN_TrapFlag_BreakOnWrite|DMN_TrapFlag_BreakOnExecute:
|
||||
case DMN_TrapFlag_BreakOnRead|DMN_TrapFlag_BreakOnWrite:
|
||||
{
|
||||
regs.dr7.u64 |= (((U64)bit16) << (trap_idx*4));
|
||||
regs.dr7.u64 |= (((U64)bit17) << (trap_idx*4));
|
||||
regs.dr7.u64 |= (((U64)bit18) << (trap_idx*4));
|
||||
}break;
|
||||
}
|
||||
switch(trap->length)
|
||||
switch(trap->size)
|
||||
{
|
||||
case 1:
|
||||
default:{}break;
|
||||
case 2:
|
||||
{
|
||||
regs.dr7.u64 |= (((U64)bit18) << (trap_idx*4));
|
||||
regs.dr7.u64 |= (((U64)bit19) << (trap_idx*4));
|
||||
}break;
|
||||
case 4:
|
||||
{
|
||||
regs.dr7.u64 |= (((U64)bit18) << (trap_idx*4));
|
||||
regs.dr7.u64 |= (((U64)bit19) << (trap_idx*4));
|
||||
regs.dr7.u64 |= (((U64)bit20) << (trap_idx*4));
|
||||
}break;
|
||||
case 8:
|
||||
{
|
||||
regs.dr7.u64 |= (((U64)bit19) << (trap_idx*4));
|
||||
regs.dr7.u64 |= (((U64)bit20) << (trap_idx*4));
|
||||
}break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
dmn_thread_write_reg_block(ctrls->single_step_thread, ®s);
|
||||
dmn_w32_thread_write_reg_block(child->arch, child->handle, ®s);
|
||||
}break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15793,6 +15793,13 @@ Z(getting_started)
|
||||
flags |= D_BreakpointFlag_BreakOnExecute;
|
||||
}
|
||||
|
||||
//- rjf: compute address range size
|
||||
U64 addr_range_size = 0;
|
||||
{
|
||||
RD_Cfg *address_range_size_cfg = rd_cfg_child_from_string(src_bp, str8_lit("address_range_size"));
|
||||
try_u64_from_str8_c_rules(address_range_size_cfg->first->string, &addr_range_size);
|
||||
}
|
||||
|
||||
//- rjf: fill breakpoint
|
||||
D_Breakpoint *dst_bp = &breakpoints.v[idx];
|
||||
dst_bp->flags = flags;
|
||||
@@ -15800,6 +15807,7 @@ Z(getting_started)
|
||||
dst_bp->pt = src_bp_loc.pt;
|
||||
dst_bp->vaddr_expr = src_bp_loc.expr;
|
||||
dst_bp->condition = non_ctrl_thread_static_condition;
|
||||
dst_bp->size = addr_range_size;
|
||||
idx += 1;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user