mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-06-16 17:12:23 -07:00
correctly pipe through exception info, visualize exceptions better
This commit is contained in:
@@ -43,6 +43,21 @@ ctrl_event_cause_from_dmn_event_kind(DMN_EventKind event_kind)
|
||||
return cause;
|
||||
}
|
||||
|
||||
internal CTRL_ExceptionKind
|
||||
ctrl_exception_kind_from_dmn(DMN_ExceptionKind kind)
|
||||
{
|
||||
CTRL_ExceptionKind result = CTRL_ExceptionKind_Null;
|
||||
switch(kind)
|
||||
{
|
||||
default:{}break;
|
||||
case DMN_ExceptionKind_MemoryRead: {result = CTRL_ExceptionKind_MemoryRead;}break;
|
||||
case DMN_ExceptionKind_MemoryWrite: {result = CTRL_ExceptionKind_MemoryWrite;}break;
|
||||
case DMN_ExceptionKind_MemoryExecute: {result = CTRL_ExceptionKind_MemoryExecute;}break;
|
||||
case DMN_ExceptionKind_CppThrow: {result = CTRL_ExceptionKind_CppThrow;}break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
internal String8
|
||||
ctrl_string_from_event_kind(CTRL_EventKind kind)
|
||||
{
|
||||
@@ -5924,6 +5939,7 @@ ctrl_thread__run(DMN_CtrlCtx *ctrl_ctx, CTRL_Msg *msg)
|
||||
event->entity = ctrl_handle_make(CTRL_MachineID_Local, stop_event->thread);
|
||||
event->parent = ctrl_handle_make(CTRL_MachineID_Local, stop_event->process);
|
||||
event->exception_code = stop_event->code;
|
||||
event->exception_kind = ctrl_exception_kind_from_dmn(stop_event->exception_kind);
|
||||
event->vaddr_rng = r1u64(stop_event->address, stop_event->address);
|
||||
event->rip_vaddr = stop_event->instruction_pointer;
|
||||
ctrl_c2u_push_events(&evts);
|
||||
@@ -5998,6 +6014,7 @@ ctrl_thread__single_step(DMN_CtrlCtx *ctrl_ctx, CTRL_Msg *msg)
|
||||
event->entity = ctrl_handle_make(CTRL_MachineID_Local, stop_event->thread);
|
||||
event->parent = ctrl_handle_make(CTRL_MachineID_Local, stop_event->process);
|
||||
event->exception_code = stop_event->code;
|
||||
event->exception_kind = ctrl_exception_kind_from_dmn(stop_event->exception_kind);
|
||||
event->vaddr_rng = r1u64(stop_event->address, stop_event->address);
|
||||
event->rip_vaddr = stop_event->instruction_pointer;
|
||||
}
|
||||
|
||||
@@ -738,6 +738,7 @@ read_only global CTRL_Entity ctrl_entity_nil =
|
||||
internal U64 ctrl_hash_from_string(String8 string);
|
||||
internal U64 ctrl_hash_from_handle(CTRL_Handle handle);
|
||||
internal CTRL_EventCause ctrl_event_cause_from_dmn_event_kind(DMN_EventKind event_kind);
|
||||
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);
|
||||
|
||||
+15
-16
@@ -11758,13 +11758,14 @@ rd_stop_explanation_fstrs_from_ctrl_event(Arena *arena, CTRL_Event *event)
|
||||
if(thread != &ctrl_entity_nil)
|
||||
{
|
||||
dr_fstrs_push_new(arena, &fstrs, ¶ms, rd_icon_kind_text_table[RD_IconKind_WarningBig], .font = rd_font_from_slot(RD_FontSlot_Icons), .raster_flags = rd_raster_flags_from_slot(RD_FontSlot_Icons));
|
||||
dr_fstrs_push_new(arena, &fstrs, ¶ms, str8_lit(" "));
|
||||
switch(event->exception_kind)
|
||||
{
|
||||
default:
|
||||
{
|
||||
dr_fstrs_push_new(arena, &fstrs, ¶ms, str8_lit(" "));
|
||||
dr_fstrs_concat_in_place(&fstrs, &thread_fstrs);
|
||||
dr_fstrs_push_new(arena, &fstrs, ¶ms, str8_lit(" hit an exception - "));
|
||||
dr_fstrs_push_new(arena, &fstrs, ¶ms, str8_lit(" "));
|
||||
dr_fstrs_push_new(arena, &fstrs, ¶ms, str8_lit(" hit an exception: "));
|
||||
String8 exception_code_string = str8_from_u64(arena, event->exception_code, 16, 0, 0);
|
||||
String8 exception_explanation_string = rd_string_from_exception_code(event->exception_code);
|
||||
String8 exception_info_string = push_str8f(arena, "%S%s%S%s",
|
||||
@@ -11776,37 +11777,35 @@ rd_stop_explanation_fstrs_from_ctrl_event(Arena *arena, CTRL_Event *event)
|
||||
}break;
|
||||
case CTRL_ExceptionKind_CppThrow:
|
||||
{
|
||||
dr_fstrs_push_new(arena, &fstrs, ¶ms, str8_lit(" "));
|
||||
dr_fstrs_concat_in_place(&fstrs, &thread_fstrs);
|
||||
dr_fstrs_push_new(arena, &fstrs, ¶ms, str8_lit(" hit a C++ exception - "));
|
||||
dr_fstrs_push_new(arena, &fstrs, ¶ms, str8_lit(" "));
|
||||
dr_fstrs_push_new(arena, &fstrs, ¶ms, str8_lit(" hit a C++ exception: "));
|
||||
String8 exception_code_string = str8_from_u64(arena, event->exception_code, 16, 0, 0);
|
||||
dr_fstrs_push_new(arena, &fstrs, ¶ms, exception_code_string);
|
||||
}break;
|
||||
case CTRL_ExceptionKind_MemoryRead:
|
||||
{
|
||||
dr_fstrs_push_new(arena, &fstrs, ¶ms, str8_lit(" "));
|
||||
dr_fstrs_concat_in_place(&fstrs, &thread_fstrs);
|
||||
dr_fstrs_push_new(arena, &fstrs, ¶ms, str8_lit(" hit an exception - "));
|
||||
String8 exception_code_string = str8_from_u64(arena, event->exception_code, 16, 0, 0);
|
||||
String8 exception_info_string = push_str8f(arena, "%S (Access violation reading 0x%I64x)", exception_code_string, event->vaddr_rng.min);
|
||||
dr_fstrs_push_new(arena, &fstrs, ¶ms, str8_lit(" "));
|
||||
dr_fstrs_push_new(arena, &fstrs, ¶ms, str8_lit(" hit an exception: "));
|
||||
String8 exception_info_string = push_str8f(arena, "Access violation reading from address 0x%I64x", event->vaddr_rng.min);
|
||||
dr_fstrs_push_new(arena, &fstrs, ¶ms, exception_info_string);
|
||||
}break;
|
||||
case CTRL_ExceptionKind_MemoryWrite:
|
||||
{
|
||||
dr_fstrs_push_new(arena, &fstrs, ¶ms, str8_lit(" "));
|
||||
dr_fstrs_concat_in_place(&fstrs, &thread_fstrs);
|
||||
dr_fstrs_push_new(arena, &fstrs, ¶ms, str8_lit(" hit an exception - "));
|
||||
String8 exception_code_string = str8_from_u64(arena, event->exception_code, 16, 0, 0);
|
||||
String8 exception_info_string = push_str8f(arena, "%S (Access violation writing 0x%I64x)", exception_code_string, event->vaddr_rng.min);
|
||||
dr_fstrs_push_new(arena, &fstrs, ¶ms, str8_lit(" "));
|
||||
dr_fstrs_push_new(arena, &fstrs, ¶ms, str8_lit(" hit an exception: "));
|
||||
String8 exception_info_string = push_str8f(arena, "Access violation writing to address 0x%I64x", event->vaddr_rng.min);
|
||||
dr_fstrs_push_new(arena, &fstrs, ¶ms, exception_info_string);
|
||||
}break;
|
||||
case CTRL_ExceptionKind_MemoryExecute:
|
||||
{
|
||||
dr_fstrs_push_new(arena, &fstrs, ¶ms, str8_lit(" "));
|
||||
dr_fstrs_concat_in_place(&fstrs, &thread_fstrs);
|
||||
dr_fstrs_push_new(arena, &fstrs, ¶ms, str8_lit(" hit an exception - "));
|
||||
dr_fstrs_push_new(arena, &fstrs, ¶ms, str8_lit(" "));
|
||||
dr_fstrs_push_new(arena, &fstrs, ¶ms, str8_lit(" hit an exception: "));
|
||||
String8 exception_code_string = str8_from_u64(arena, event->exception_code, 16, 0, 0);
|
||||
String8 exception_info_string = push_str8f(arena, "%S (Access violation executing 0x%I64x)", exception_code_string, event->vaddr_rng.min);
|
||||
String8 exception_info_string = push_str8f(arena, "Access violation executing at address 0x%I64x", event->vaddr_rng.min);
|
||||
dr_fstrs_push_new(arena, &fstrs, ¶ms, exception_info_string);
|
||||
}break;
|
||||
}
|
||||
@@ -11814,7 +11813,7 @@ rd_stop_explanation_fstrs_from_ctrl_event(Arena *arena, CTRL_Event *event)
|
||||
else
|
||||
{
|
||||
dr_fstrs_push_new(arena, &fstrs, ¶ms, rd_icon_kind_text_table[RD_IconKind_WarningBig], .font = rd_font_from_slot(RD_FontSlot_Icons), .raster_flags = rd_raster_flags_from_slot(RD_FontSlot_Icons));
|
||||
dr_fstrs_push_new(arena, &fstrs, ¶ms, str8_lit("Hit an exception - "));
|
||||
dr_fstrs_push_new(arena, &fstrs, ¶ms, str8_lit("Hit an exception: "));
|
||||
String8 exception_code_string = str8_from_u64(arena, event->exception_code, 16, 0, 0);
|
||||
String8 exception_explanation_string = rd_string_from_exception_code(event->exception_code);
|
||||
String8 exception_info_string = push_str8f(arena, "%S%s%S%s",
|
||||
|
||||
@@ -1765,8 +1765,8 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe
|
||||
line_num += 1, line_idx += 1)
|
||||
{
|
||||
String8 line_text = params->line_text[line_idx];
|
||||
F32 line_text_dim = fnt_dim_from_tag_size_string(params->font, params->font_size, 0, params->tab_size, line_text).x + params->line_num_width_px;
|
||||
line_extras_off[line_idx] = Max(line_text_dim, params->font_size*50);
|
||||
F32 line_text_dim = fnt_dim_from_tag_size_string(params->font, params->font_size, 0, params->tab_size, line_text).x + params->line_num_width_px + params->catchall_margin_width_px + params->priority_margin_width_px;
|
||||
line_extras_off[line_idx] = Max(line_text_dim, params->font_size*30);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1806,7 +1806,7 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe
|
||||
stop_event.cause == CTRL_EventCause_InterruptedByTrap))
|
||||
{
|
||||
DR_FStrList explanation_fstrs = rd_stop_explanation_fstrs_from_ctrl_event(scratch.arena, &stop_event);
|
||||
UI_Parent(line_extras_boxes[line_idx]) UI_PrefWidth(ui_children_sum(1)) UI_PrefHeight(ui_px(params->line_height_px, 1.f))
|
||||
UI_Parent(line_extras_boxes[line_idx]) UI_PrefWidth(ui_text_dim(10, 1)) UI_TextAlignment(UI_TextAlign_Center) UI_PrefHeight(ui_px(params->line_height_px, 1.f))
|
||||
UI_TagF("bad_pop")
|
||||
{
|
||||
UI_Box *box = ui_build_box_from_stringf(UI_BoxFlag_DrawText, "###exception_info");
|
||||
|
||||
Reference in New Issue
Block a user