dbgi: fix incorrect grab of raddbg header; raddbg_from_pdb: fix unsigned interpretation of offsets in defrange symbols; fix incorrect byte position/size encoding ordering in some location info cases

This commit is contained in:
Ryan Fleury
2024-01-24 11:57:17 -08:00
parent 3edc67e19e
commit 69f77456b8
6 changed files with 38 additions and 19 deletions
+1 -1
View File
@@ -653,7 +653,7 @@ dbgi_parse_thread_entry_point(void *p)
file_base = os_file_map_view_open(file_map, OS_AccessFlag_Read, r1u64(0, file_props.size)); file_base = os_file_map_view_open(file_map, OS_AccessFlag_Read, r1u64(0, file_props.size));
if(sizeof(RADDBG_Header) <= file_props.size) if(sizeof(RADDBG_Header) <= file_props.size)
{ {
RADDBG_Header *header = (RADDBG_Header*)&file_base; RADDBG_Header *header = (RADDBG_Header*)file_base;
if(header->encoding_version != RADDBG_ENCODING_VERSION) if(header->encoding_version != RADDBG_ENCODING_VERSION)
{ {
raddbg_file_is_up_to_date = 0; raddbg_file_is_up_to_date = 0;
+13 -1
View File
@@ -857,7 +857,19 @@ eval_parse_expr_from_text_tokens__prec(Arena *arena, EVAL_ParseCtx *ctx, String8
case RADDBG_LocationKind_ValBytecodeStream: case RADDBG_LocationKind_ValBytecodeStream:
{ {
U8 *bytecode_base = ctx->rdbg->location_data + block->location_data_off + sizeof(RADDBG_LocationKind); U8 *bytecode_base = ctx->rdbg->location_data + block->location_data_off + sizeof(RADDBG_LocationKind);
loc_bytecode = str8_cstring((char *)bytecode_base); U64 bytecode_size = 0;
for(U64 idx = 0; idx < ctx->rdbg->location_data_size; idx += 1)
{
U8 op = bytecode_base[idx];
if(op == 0)
{
break;
}
U8 ctrlbits = raddbg_eval_opcode_ctrlbits[op];
U32 p_size = RADDBG_DECODEN_FROM_CTRLBITS(ctrlbits);
bytecode_size += 1+p_size;
}
loc_bytecode = str8(bytecode_base, bytecode_size);
}break; }break;
case RADDBG_LocationKind_AddrRegisterPlusU16: case RADDBG_LocationKind_AddrRegisterPlusU16:
case RADDBG_LocationKind_AddrAddrRegisterPlusU16: case RADDBG_LocationKind_AddrAddrRegisterPlusU16:
+9 -1
View File
@@ -82,10 +82,12 @@ update_and_render(OS_Handle repaint_window_handle, void *user_data)
{ {
if(os_key_press(&events, os_handle_zero(), 0, OS_Key_Esc)) if(os_key_press(&events, os_handle_zero(), 0, OS_Key_Esc))
{ {
df_gfx_request_frame();
df_gfx_state->bind_change_active = 0; df_gfx_state->bind_change_active = 0;
} }
if(os_key_press(&events, os_handle_zero(), 0, OS_Key_Delete)) if(os_key_press(&events, os_handle_zero(), 0, OS_Key_Delete))
{ {
df_gfx_request_frame();
df_unbind_spec(df_gfx_state->bind_change_cmd_spec, df_gfx_state->bind_change_binding); df_unbind_spec(df_gfx_state->bind_change_cmd_spec, df_gfx_state->bind_change_binding);
df_gfx_state->bind_change_active = 0; df_gfx_state->bind_change_active = 0;
DF_CmdParams p = df_cmd_params_from_gfx(); DF_CmdParams p = df_cmd_params_from_gfx();
@@ -117,6 +119,7 @@ update_and_render(OS_Handle repaint_window_handle, void *user_data)
os_eat_event(&events, event); os_eat_event(&events, event);
DF_CmdParams p = df_cmd_params_from_gfx(); DF_CmdParams p = df_cmd_params_from_gfx();
df_push_cmd__root(&p, df_cmd_spec_from_core_cmd_kind(df_g_cfg_src_write_cmd_kind_table[DF_CfgSrc_User])); df_push_cmd__root(&p, df_cmd_spec_from_core_cmd_kind(df_g_cfg_src_write_cmd_kind_table[DF_CfgSrc_User]));
df_gfx_request_frame();
break; break;
} }
} }
@@ -151,8 +154,8 @@ update_and_render(OS_Handle repaint_window_handle, void *user_data)
{ {
window->menu_bar_focus_press_started = 0; window->menu_bar_focus_press_started = 0;
} }
df_gfx_request_frame();
} }
df_gfx_request_frame();
} }
else if(event->kind == OS_EventKind_Text) else if(event->kind == OS_EventKind_Text)
{ {
@@ -180,28 +183,33 @@ update_and_render(OS_Handle repaint_window_handle, void *user_data)
} }
if(event->kind == OS_EventKind_Press && event->key == OS_Key_Alt && event->is_repeat == 0) if(event->kind == OS_EventKind_Press && event->key == OS_Key_Alt && event->is_repeat == 0)
{ {
df_gfx_request_frame();
ws->menu_bar_focused_on_press = ws->menu_bar_focused; ws->menu_bar_focused_on_press = ws->menu_bar_focused;
ws->menu_bar_key_held = 1; ws->menu_bar_key_held = 1;
ws->menu_bar_focus_press_started = 1; ws->menu_bar_focus_press_started = 1;
} }
if(event->kind == OS_EventKind_Release && event->key == OS_Key_Alt && event->is_repeat == 0) if(event->kind == OS_EventKind_Release && event->key == OS_Key_Alt && event->is_repeat == 0)
{ {
df_gfx_request_frame();
ws->menu_bar_key_held = 0; ws->menu_bar_key_held = 0;
} }
if(ws->menu_bar_focused && event->kind == OS_EventKind_Press && event->key == OS_Key_Alt && event->is_repeat == 0) if(ws->menu_bar_focused && event->kind == OS_EventKind_Press && event->key == OS_Key_Alt && event->is_repeat == 0)
{ {
os_eat_event(&events, event); os_eat_event(&events, event);
df_gfx_request_frame();
ws->menu_bar_focused = 0; ws->menu_bar_focused = 0;
} }
else if(ws->menu_bar_focus_press_started && !ws->menu_bar_focused && event->kind == OS_EventKind_Release && event->key == OS_Key_Alt && event->is_repeat == 0) else if(ws->menu_bar_focus_press_started && !ws->menu_bar_focused && event->kind == OS_EventKind_Release && event->key == OS_Key_Alt && event->is_repeat == 0)
{ {
os_eat_event(&events, event); os_eat_event(&events, event);
df_gfx_request_frame();
ws->menu_bar_focused = !ws->menu_bar_focused_on_press; ws->menu_bar_focused = !ws->menu_bar_focused_on_press;
ws->menu_bar_focus_press_started = 0; ws->menu_bar_focus_press_started = 0;
} }
else if(event->kind == OS_EventKind_Press && event->key == OS_Key_Esc && ws->menu_bar_focused && !ui_any_ctx_menu_is_open()) else if(event->kind == OS_EventKind_Press && event->key == OS_Key_Esc && ws->menu_bar_focused && !ui_any_ctx_menu_is_open())
{ {
os_eat_event(&events, event); os_eat_event(&events, event);
df_gfx_request_frame();
ws->menu_bar_focused = 0; ws->menu_bar_focused = 0;
} }
} }
+3 -3
View File
@@ -1868,7 +1868,7 @@ typedef struct CV_SymDefrangeRegister{
// (SymKind: DEFRANGE_FRAMEPOINTER_REL) // (SymKind: DEFRANGE_FRAMEPOINTER_REL)
typedef struct CV_SymDefrangeFramepointerRel{ typedef struct CV_SymDefrangeFramepointerRel{
U32 off; S32 off;
CV_LvarAddrRange range; CV_LvarAddrRange range;
// CV_LvarAddrGap[] gaps (rest of data) // CV_LvarAddrGap[] gaps (rest of data)
} CV_SymDefrangeFramepointerRel; } CV_SymDefrangeFramepointerRel;
@@ -1884,7 +1884,7 @@ typedef struct CV_SymDefrangeSubfieldRegister{
// (SymKind: DEFRANGE_FRAMEPOINTER_REL_FULL_SCOPE) // (SymKind: DEFRANGE_FRAMEPOINTER_REL_FULL_SCOPE)
typedef struct CV_SymDefrangeFramepointerRelFullScope{ typedef struct CV_SymDefrangeFramepointerRelFullScope{
U32 off; S32 off;
} CV_SymDefrangeFramepointerRelFullScope; } CV_SymDefrangeFramepointerRelFullScope;
// (SymKind: DEFRANGE_REGISTER_REL) // (SymKind: DEFRANGE_REGISTER_REL)
@@ -1897,7 +1897,7 @@ enum{
typedef struct CV_SymDefrangeRegisterRel{ typedef struct CV_SymDefrangeRegisterRel{
CV_Reg reg; CV_Reg reg;
CV_DefrangeRegisterRelFlags flags; CV_DefrangeRegisterRelFlags flags;
U32 reg_off; S32 reg_off;
CV_LvarAddrRange range; CV_LvarAddrRange range;
// CV_LvarAddGap[] gaps (rest of data) // CV_LvarAddGap[] gaps (rest of data)
} CV_SymDefrangeRegisterRel; } CV_SymDefrangeRegisterRel;
+10 -11
View File
@@ -2107,7 +2107,7 @@ pdbconv_symbol_cons(PDBCONV_Ctx *ctx, CV_SymParsed *sym, U32 sym_unique_id){
// set location case // set location case
CONS_Location *loc = CONS_Location *loc =
pdbconv_location_from_addr_reg_off(ctx, register_code, byte_size, byte_pos, pdbconv_location_from_addr_reg_off(ctx, register_code, byte_size, byte_pos,
var_off, extra_indirection_to_value); (S64)(S32)var_off, extra_indirection_to_value);
CONS_LocationSet *locset = cons_location_set_from_local(ctx->root, local_var); CONS_LocationSet *locset = cons_location_set_from_local(ctx->root, local_var);
cons_location_set_add_case(ctx->root, locset, 0, max_U64, loc); cons_location_set_add_case(ctx->root, locset, 0, max_U64, loc);
@@ -2275,12 +2275,11 @@ pdbconv_symbol_cons(PDBCONV_Ctx *ctx, CV_SymParsed *sym, U32 sym_unique_id){
B32 extra_indirection = 0; B32 extra_indirection = 0;
U32 byte_size = ctx->addr_size; U32 byte_size = ctx->addr_size;
U32 byte_pos = 0; U32 byte_pos = 0;
U64 var_off = defrange_fprel->off; S64 var_off = (S64)defrange_fprel->off;
CONS_Location *location = CONS_Location *location =
pdbconv_location_from_addr_reg_off(ctx, fp_register_code, byte_size, byte_pos, pdbconv_location_from_addr_reg_off(ctx, fp_register_code, byte_size, byte_pos,
var_off, extra_indirection); var_off, extra_indirection);
// extract range info // extract range info
CV_LvarAddrRange *range = &defrange_fprel->range; CV_LvarAddrRange *range = &defrange_fprel->range;
CV_LvarAddrGap *gaps = (CV_LvarAddrGap*)(defrange_fprel + 1); CV_LvarAddrGap *gaps = (CV_LvarAddrGap*)(defrange_fprel + 1);
@@ -2352,7 +2351,7 @@ pdbconv_symbol_cons(PDBCONV_Ctx *ctx, CV_SymParsed *sym, U32 sym_unique_id){
B32 extra_indirection = 0; B32 extra_indirection = 0;
U32 byte_size = ctx->addr_size; U32 byte_size = ctx->addr_size;
U32 byte_pos = 0; U32 byte_pos = 0;
U64 var_off = defrange_fprel_full_scope->off; S64 var_off = (S64)defrange_fprel_full_scope->off;
CONS_Location *location = CONS_Location *location =
pdbconv_location_from_addr_reg_off(ctx, fp_register_code, byte_size, byte_pos, pdbconv_location_from_addr_reg_off(ctx, fp_register_code, byte_size, byte_pos,
var_off, extra_indirection); var_off, extra_indirection);
@@ -2385,7 +2384,7 @@ pdbconv_symbol_cons(PDBCONV_Ctx *ctx, CV_SymParsed *sym, U32 sym_unique_id){
U32 byte_pos = 0; U32 byte_pos = 0;
B32 extra_indirection_to_value = 0; B32 extra_indirection_to_value = 0;
U64 var_off = defrange_register_rel->reg_off; S64 var_off = defrange_register_rel->reg_off;
// setup location // setup location
CONS_Location *location = CONS_Location *location =
@@ -2670,17 +2669,17 @@ pdbconv_known_global_insert(Arena *arena, PDBCONV_KnownGlobalSet *set, String8 n
static CONS_Location* static CONS_Location*
pdbconv_location_from_addr_reg_off(PDBCONV_Ctx *ctx, pdbconv_location_from_addr_reg_off(PDBCONV_Ctx *ctx,
RADDBG_RegisterCode reg_code, RADDBG_RegisterCode reg_code,
U32 reg_byte_pos,
U32 reg_byte_size, U32 reg_byte_size,
U64 offset, U32 reg_byte_pos,
S64 offset,
B32 extra_indirection){ B32 extra_indirection){
CONS_Location *result = 0; CONS_Location *result = 0;
if (offset <= max_U16){ if (0 <= offset && offset <= (S64)max_U16){
if (extra_indirection){ if (extra_indirection){
result = cons_location_addr_addr_reg_plus_u16(ctx->root, reg_code, offset); result = cons_location_addr_addr_reg_plus_u16(ctx->root, reg_code, (U16)offset);
} }
else{ else{
result = cons_location_addr_reg_plus_u16(ctx->root, reg_code, offset); result = cons_location_addr_reg_plus_u16(ctx->root, reg_code, (U16)offset);
} }
} }
else{ else{
@@ -2689,7 +2688,7 @@ pdbconv_location_from_addr_reg_off(PDBCONV_Ctx *ctx,
CONS_EvalBytecode bytecode = {0}; CONS_EvalBytecode bytecode = {0};
U32 regread_param = RADDBG_EncodeRegReadParam(reg_code, reg_byte_size, reg_byte_pos); U32 regread_param = RADDBG_EncodeRegReadParam(reg_code, reg_byte_size, reg_byte_pos);
cons_bytecode_push_op(arena, &bytecode, RADDBG_EvalOp_RegRead, regread_param); cons_bytecode_push_op(arena, &bytecode, RADDBG_EvalOp_RegRead, regread_param);
cons_bytecode_push_uconst(arena, &bytecode, offset); cons_bytecode_push_sconst(arena, &bytecode, offset);
cons_bytecode_push_op(arena, &bytecode, RADDBG_EvalOp_Add, 0); cons_bytecode_push_op(arena, &bytecode, RADDBG_EvalOp_Add, 0);
if (extra_indirection){ if (extra_indirection){
cons_bytecode_push_op(arena, &bytecode, RADDBG_EvalOp_MemRead, ctx->addr_size); cons_bytecode_push_op(arena, &bytecode, RADDBG_EvalOp_MemRead, ctx->addr_size);
+2 -2
View File
@@ -219,9 +219,9 @@ static void pdbconv_known_global_insert(Arena *arena, PDBCONV_KnownGlobalSet *se
// location info helpers // location info helpers
static CONS_Location* pdbconv_location_from_addr_reg_off(PDBCONV_Ctx *ctx, static CONS_Location* pdbconv_location_from_addr_reg_off(PDBCONV_Ctx *ctx,
RADDBG_RegisterCode reg_code, RADDBG_RegisterCode reg_code,
U32 reg_byte_pos,
U32 reg_byte_size, U32 reg_byte_size,
U64 offset, U32 reg_byte_pos,
S64 offset,
B32 extra_indirection); B32 extra_indirection);
static CV_EncodedFramePtrReg pdbconv_cv_encoded_fp_reg_from_proc(PDBCONV_Ctx *ctx, static CV_EncodedFramePtrReg pdbconv_cv_encoded_fp_reg_from_proc(PDBCONV_Ctx *ctx,