diff --git a/src/ctrl/ctrl_core.c b/src/ctrl/ctrl_core.c index ab26cef7..dafd1426 100644 --- a/src/ctrl/ctrl_core.c +++ b/src/ctrl/ctrl_core.c @@ -5598,7 +5598,8 @@ ctrl_mem_stream_thread__entry_point(void *p) if(got_task && pre_read_mem_gen != preexisting_mem_gen) { range_size = dim_1u64(vaddr_range_clamped); - U64 arena_size = AlignPow2(range_size + ARENA_HEADER_SIZE, os_get_system_info()->page_size); + U64 page_size = os_get_system_info()->page_size; + U64 arena_size = AlignPow2(range_size + ARENA_HEADER_SIZE, page_size); range_arena = arena_alloc(.reserve_size = range_size+ARENA_HEADER_SIZE, .commit_size = range_size+ARENA_HEADER_SIZE); if(range_arena == 0) { @@ -5609,14 +5610,17 @@ ctrl_mem_stream_thread__entry_point(void *p) range_base = push_array_no_zero(range_arena, U8, range_size); U64 bytes_read = 0; U64 retry_count = 0; - U64 retry_limit = (zero_terminated ? 64 : 0); - for(Rng1U64 vaddr_range_clamped_retry = vaddr_range_clamped; retry_count <= retry_limit; retry_count += 1) + U64 retry_limit = range_size > page_size ? 64 : 0; + for(Rng1U64 vaddr_range_clamped_retry = vaddr_range_clamped; + retry_count <= retry_limit; + retry_count += 1) { bytes_read = dmn_process_read(process.dmn_handle, vaddr_range_clamped_retry, range_base); if(bytes_read == 0 && vaddr_range_clamped_retry.max > vaddr_range_clamped_retry.min) { U64 diff = (vaddr_range_clamped_retry.max-vaddr_range_clamped_retry.min)/2; vaddr_range_clamped_retry.max -= diff; + vaddr_range_clamped_retry.max = AlignDownPow2(vaddr_range_clamped_retry.max, page_size); if(diff == 0) { break; diff --git a/src/ctrl/ctrl_core.h b/src/ctrl/ctrl_core.h index 06a1b0fe..8dde24f6 100644 --- a/src/ctrl/ctrl_core.h +++ b/src/ctrl/ctrl_core.h @@ -86,7 +86,9 @@ Y(String8, type(CTRL_PathString8), dbg, "Debug Info Path")\ Y(String8, type(CTRL_PlainString8), args, "Arguments")\ Y(String8, type(CTRL_PathString8), working_directory, "Working Directory")\ Y(String8, type(CTRL_CodeString8), entry_point, "Custom Entry Point")\ -Y(String8, type(CTRL_PlainString8), location, "Location")\ +Y(String8, type(CTRL_PathString8), source_location, "Source Location")\ +Y(String8, type(CTRL_CodeString8), function_location, "Function Location")\ +Y(String8, type(CTRL_CodeString8), address_location, "Address Location")\ Y(String8, type(CTRL_CodeString8), condition, "Condition")\ X(CTRL_MetaEvalFrameArray, callstack, "Call Stack") #define X(T, name, pretty_name) T name; @@ -109,12 +111,14 @@ struct_type(CTRL_MetaEval); struct_members(CTRL_BreakpointMetaEval) { - member_lit_comp(CTRL_MetaEval, type(B32), enabled, .pretty_name = str8_lit_comp("Enabled")), - member_lit_comp(CTRL_MetaEval, type(U32), color, .pretty_name = str8_lit_comp("Color")), - member_lit_comp(CTRL_MetaEval, type(U64), hit_count, .pretty_name = str8_lit_comp("Hit Count")), - member_lit_comp(CTRL_MetaEval, type(CTRL_CodeString8), label, .pretty_name = str8_lit_comp("Label")), - member_lit_comp(CTRL_MetaEval, type(CTRL_CodeString8), condition, .pretty_name = str8_lit_comp("Condition")), - member_lit_comp(CTRL_MetaEval, type(CTRL_PlainString8),location, .pretty_name = str8_lit_comp("Location")), + member_lit_comp(CTRL_MetaEval, type(B32), enabled, .pretty_name = str8_lit_comp("Enabled")), + member_lit_comp(CTRL_MetaEval, type(U32), color, .pretty_name = str8_lit_comp("Color")), + member_lit_comp(CTRL_MetaEval, type(U64), hit_count, .pretty_name = str8_lit_comp("Hit Count")), + member_lit_comp(CTRL_MetaEval, type(CTRL_CodeString8), label, .pretty_name = str8_lit_comp("Label")), + member_lit_comp(CTRL_MetaEval, type(CTRL_CodeString8), condition, .pretty_name = str8_lit_comp("Condition")), + member_lit_comp(CTRL_MetaEval, type(CTRL_PathString8), source_location, .pretty_name = str8_lit_comp("Source Location")), + member_lit_comp(CTRL_MetaEval, type(CTRL_CodeString8), function_location, .pretty_name = str8_lit_comp("Function Location")), + member_lit_comp(CTRL_MetaEval, type(CTRL_CodeString8), address_location, .pretty_name = str8_lit_comp("Address Location")), }; struct_members(CTRL_TargetMetaEval) @@ -130,7 +134,8 @@ struct_members(CTRL_PinMetaEval) { member_lit_comp(CTRL_MetaEval, type(CTRL_CodeString8), label, .pretty_name = str8_lit_comp("Expression")), member_lit_comp(CTRL_MetaEval, type(U32), color, .pretty_name = str8_lit_comp("Color")), - member_lit_comp(CTRL_MetaEval, type(CTRL_PathString8), location, .pretty_name = str8_lit_comp("Location")), + member_lit_comp(CTRL_MetaEval, type(CTRL_PathString8), source_location, .pretty_name = str8_lit_comp("Source Location")), + member_lit_comp(CTRL_MetaEval, type(CTRL_CodeString8), address_location, .pretty_name = str8_lit_comp("Address Location")), }; struct_members(CTRL_MachineMetaEval) diff --git a/src/dbg_engine/dbg_engine_core.c b/src/dbg_engine/dbg_engine_core.c index cd7da78e..06934731 100644 --- a/src/dbg_engine/dbg_engine_core.c +++ b/src/dbg_engine/dbg_engine_core.c @@ -2142,7 +2142,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P // rjf: no targets -> error if(targets_to_launch->count == 0) { - log_user_error(str8_lit("No active targets exist; cannot launch.")); + log_user_error(str8_lit("No active targets exist; cannot launch. You must select target first.")); } }break; case D_CmdKind_Kill: diff --git a/src/eval/eval.mdesk b/src/eval/eval.mdesk index 07528417..0a8e3e55 100644 --- a/src/eval/eval.mdesk +++ b/src/eval/eval.mdesk @@ -117,6 +117,7 @@ E_ExprKindTable: { LeafBytecode Null 0 "bytecode" "" "" "" } { LeafMember Null 0 "member" "" "" "" } { LeafStringLiteral Null 0 "string_literal" "" "" "" } + { LeafBool Null 0 "B32" "" "" "" } { LeafU64 Null 0 "U64" "" "" "" } { LeafF64 Null 0 "F64" "" "" "" } { LeafF32 Null 0 "F32" "" "" "" } diff --git a/src/eval/eval_ir.c b/src/eval/eval_ir.c index 5c9c1e77..4fdb399f 100644 --- a/src/eval/eval_ir.c +++ b/src/eval/eval_ir.c @@ -1221,6 +1221,14 @@ e_irtree_and_type_from_expr(Arena *arena, E_Expr *expr) result.mode = E_Mode_Value; }break; + //- rjf: leaf bools + case E_ExprKind_LeafBool: + { + result.root = e_irtree_const_u(arena, expr->value.u64); + result.type_key = expr->type_key; + result.mode = E_Mode_Value; + }break; + //- rjf: leaf U64s case E_ExprKind_LeafU64: { diff --git a/src/eval/eval_parse.c b/src/eval/eval_parse.c index 02adee52..d3380764 100644 --- a/src/eval/eval_parse.c +++ b/src/eval/eval_parse.c @@ -789,6 +789,7 @@ e_append_strings_from_expr(Arena *arena, E_Expr *expr, String8List *out) str8_list_pushf(arena, out, "\"%S\"", expr->string); }break; case E_ExprKind_LeafU64: + case E_ExprKind_LeafBool: { str8_list_pushf(arena, out, "%I64u", expr->value.u64); }break; @@ -1297,12 +1298,14 @@ e_parse_expr_from_text_tokens__prec(Arena *arena, String8 text, E_TokenArray *to case E_TokenKind_Identifier: { B32 mapped_identifier = 0; + B32 identifier_is_constant_value = 0; B32 identifier_type_is_possibly_dynamically_overridden = 0; B32 identifier_looks_like_type_expr = 0; RDI_LocationKind loc_kind = RDI_LocationKind_NULL; RDI_LocationReg loc_reg = {0}; RDI_LocationRegPlusU16 loc_reg_u16 = {0}; String8 loc_bytecode = {0}; + U64 constant_value = 0; REGS_RegCode reg_code = 0; REGS_AliasCode alias_code = 0; E_TypeKey type_key = zero_struct; @@ -1589,6 +1592,22 @@ e_parse_expr_from_text_tokens__prec(Arena *arena, String8 text, E_TokenArray *to } } + //- rjf: try basic constants + if(mapped_identifier == 0 && str8_match(token_string, str8_lit("true"), 0)) + { + mapped_identifier = 1; + identifier_is_constant_value = 1; + type_key = e_type_key_basic(E_TypeKind_Bool); + constant_value = 1; + } + if(mapped_identifier == 0 && str8_match(token_string, str8_lit("false"), 0)) + { + mapped_identifier = 1; + identifier_is_constant_value = 1; + type_key = e_type_key_basic(E_TypeKind_Bool); + constant_value = 0; + } + //- rjf: attach on map if(mapped_identifier != 0) { @@ -1599,7 +1618,13 @@ e_parse_expr_from_text_tokens__prec(Arena *arena, String8 text, E_TokenArray *to { default: { - if(identifier_looks_like_type_expr) + if(identifier_is_constant_value) + { + atom = e_push_expr(arena, E_ExprKind_LeafBool, token_string.str); + atom->value.u64 = constant_value; + atom->type_key = type_key; + } + else if(identifier_looks_like_type_expr) { E_TokenArray type_parse_tokens = e_token_array_make_first_opl(it-1, it_opl); E_Parse type_parse = e_parse_type_from_text_tokens(arena, text, &type_parse_tokens); diff --git a/src/eval/generated/eval.meta.c b/src/eval/generated/eval.meta.c index ef118f84..aa532147 100644 --- a/src/eval/generated/eval.meta.c +++ b/src/eval/generated/eval.meta.c @@ -14,7 +14,7 @@ str8_lit_comp("CharLiteral"), str8_lit_comp("Symbol"), }; -String8 e_expr_kind_strings[45] = +String8 e_expr_kind_strings[46] = { str8_lit_comp("Nil"), str8_lit_comp("Ref"), @@ -50,6 +50,7 @@ str8_lit_comp("Ternary"), str8_lit_comp("LeafBytecode"), str8_lit_comp("LeafMember"), str8_lit_comp("LeafStringLiteral"), +str8_lit_comp("LeafBool"), str8_lit_comp("LeafU64"), str8_lit_comp("LeafF64"), str8_lit_comp("LeafF32"), @@ -78,7 +79,7 @@ str8_lit_comp("Insufficient evaluation machine stack space."), str8_lit_comp("Malformed bytecode."), }; -E_OpInfo e_expr_kind_op_info_table[45] = +E_OpInfo e_expr_kind_op_info_table[46] = { { E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") }, { E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") }, @@ -124,6 +125,7 @@ E_OpInfo e_expr_kind_op_info_table[45] = { E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") }, { E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") }, { E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") }, +{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") }, { E_OpKind_Binary, 13, str8_lit_comp(""), str8_lit_comp("="), str8_lit_comp("") }, }; diff --git a/src/eval/generated/eval.meta.h b/src/eval/generated/eval.meta.h index 8bbb319a..30ad06ba 100644 --- a/src/eval/generated/eval.meta.h +++ b/src/eval/generated/eval.meta.h @@ -125,6 +125,7 @@ E_ExprKind_Ternary, E_ExprKind_LeafBytecode, E_ExprKind_LeafMember, E_ExprKind_LeafStringLiteral, +E_ExprKind_LeafBool, E_ExprKind_LeafU64, E_ExprKind_LeafF64, E_ExprKind_LeafF32, @@ -157,9 +158,9 @@ E_InterpretationCode_COUNT, C_LINKAGE_BEGIN extern String8 e_token_kind_strings[6]; -extern String8 e_expr_kind_strings[45]; +extern String8 e_expr_kind_strings[46]; extern String8 e_interpretation_code_display_strings[11]; -extern E_OpInfo e_expr_kind_op_info_table[45]; +extern E_OpInfo e_expr_kind_op_info_table[46]; extern U8 e_kind_basic_byte_size_table[56]; extern String8 e_kind_basic_string_table[56]; diff --git a/src/raddbg/generated/raddbg.meta.c b/src/raddbg/generated/raddbg.meta.c index c2825de2..6ac81fc6 100644 --- a/src/raddbg/generated/raddbg.meta.c +++ b/src/raddbg/generated/raddbg.meta.c @@ -405,7 +405,7 @@ RD_CmdKindInfo rd_cmd_kind_info_table[214] = { str8_lit_comp("enable_entity"), str8_lit_comp("Enables an entity."), str8_lit_comp(""), str8_lit_comp("Enable Entity"), RD_IconKind_Null, (RD_CmdKindFlag_ListInUI*0)|(RD_CmdKindFlag_ListInIPCDocs*0), {(RD_QueryFlag_AllowFiles*0)|(RD_QueryFlag_AllowFolders*0)|(RD_QueryFlag_CodeInput*0)|(RD_QueryFlag_KeepOldInput*0)|(RD_QueryFlag_SelectOldInput*0)|(RD_QueryFlag_Required*0), RD_RegSlot_Null, str8_lit_comp(""), RD_EntityKind_Nil}}, { str8_lit_comp("disable_entity"), str8_lit_comp("Disables an entity."), str8_lit_comp(""), str8_lit_comp("Disable Entity"), RD_IconKind_Null, (RD_CmdKindFlag_ListInUI*0)|(RD_CmdKindFlag_ListInIPCDocs*0), {(RD_QueryFlag_AllowFiles*0)|(RD_QueryFlag_AllowFolders*0)|(RD_QueryFlag_CodeInput*0)|(RD_QueryFlag_KeepOldInput*0)|(RD_QueryFlag_SelectOldInput*0)|(RD_QueryFlag_Required*0), RD_RegSlot_Null, str8_lit_comp(""), RD_EntityKind_Nil}}, { str8_lit_comp("select_entity"), str8_lit_comp("Selects an entity, disabling all others of the same kind."), str8_lit_comp(""), str8_lit_comp("Select Entity"), RD_IconKind_CheckHollow, (RD_CmdKindFlag_ListInUI*0)|(RD_CmdKindFlag_ListInIPCDocs*0), {(RD_QueryFlag_AllowFiles*0)|(RD_QueryFlag_AllowFolders*0)|(RD_QueryFlag_CodeInput*0)|(RD_QueryFlag_KeepOldInput*0)|(RD_QueryFlag_SelectOldInput*0)|(RD_QueryFlag_Required*0), RD_RegSlot_Null, str8_lit_comp(""), RD_EntityKind_Nil}}, -{ str8_lit_comp("remove_entity"), str8_lit_comp("Removes an entity."), str8_lit_comp(""), str8_lit_comp("Remove Entity"), RD_IconKind_Null, (RD_CmdKindFlag_ListInUI*0)|(RD_CmdKindFlag_ListInIPCDocs*0), {(RD_QueryFlag_AllowFiles*0)|(RD_QueryFlag_AllowFolders*0)|(RD_QueryFlag_CodeInput*0)|(RD_QueryFlag_KeepOldInput*0)|(RD_QueryFlag_SelectOldInput*0)|(RD_QueryFlag_Required*0), RD_RegSlot_Null, str8_lit_comp(""), RD_EntityKind_Nil}}, +{ str8_lit_comp("remove_entity"), str8_lit_comp("Removes an entity."), str8_lit_comp(""), str8_lit_comp("Remove Entity"), RD_IconKind_Trash, (RD_CmdKindFlag_ListInUI*0)|(RD_CmdKindFlag_ListInIPCDocs*0), {(RD_QueryFlag_AllowFiles*0)|(RD_QueryFlag_AllowFolders*0)|(RD_QueryFlag_CodeInput*0)|(RD_QueryFlag_KeepOldInput*0)|(RD_QueryFlag_SelectOldInput*0)|(RD_QueryFlag_Required*0), RD_RegSlot_Null, str8_lit_comp(""), RD_EntityKind_Nil}}, { str8_lit_comp("name_entity"), str8_lit_comp("Equips an entity with a name."), str8_lit_comp(""), str8_lit_comp("Name Entity"), RD_IconKind_Null, (RD_CmdKindFlag_ListInUI*0)|(RD_CmdKindFlag_ListInIPCDocs*0), {(RD_QueryFlag_AllowFiles*0)|(RD_QueryFlag_AllowFolders*0)|(RD_QueryFlag_CodeInput*0)|(RD_QueryFlag_KeepOldInput*0)|(RD_QueryFlag_SelectOldInput*0)|(RD_QueryFlag_Required*0), RD_RegSlot_Null, str8_lit_comp(""), RD_EntityKind_Nil}}, { str8_lit_comp("duplicate_entity"), str8_lit_comp("Duplicates an entity."), str8_lit_comp(""), str8_lit_comp("Duplicate Entity"), RD_IconKind_Null, (RD_CmdKindFlag_ListInUI*0)|(RD_CmdKindFlag_ListInIPCDocs*0), {(RD_QueryFlag_AllowFiles*0)|(RD_QueryFlag_AllowFolders*0)|(RD_QueryFlag_CodeInput*0)|(RD_QueryFlag_KeepOldInput*0)|(RD_QueryFlag_SelectOldInput*0)|(RD_QueryFlag_Required*0), RD_RegSlot_Null, str8_lit_comp(""), RD_EntityKind_Nil}}, { str8_lit_comp("relocate_entity"), str8_lit_comp("Relocates an entity."), str8_lit_comp(""), str8_lit_comp("Relocate Entity"), RD_IconKind_Null, (RD_CmdKindFlag_ListInUI*0)|(RD_CmdKindFlag_ListInIPCDocs*0), {(RD_QueryFlag_AllowFiles*0)|(RD_QueryFlag_AllowFolders*0)|(RD_QueryFlag_CodeInput*0)|(RD_QueryFlag_KeepOldInput*0)|(RD_QueryFlag_SelectOldInput*0)|(RD_QueryFlag_Required*0), RD_RegSlot_Null, str8_lit_comp(""), RD_EntityKind_Nil}}, diff --git a/src/raddbg/raddbg.mdesk b/src/raddbg/raddbg.mdesk index 08e85f3f..1dd2806b 100644 --- a/src/raddbg/raddbg.mdesk +++ b/src/raddbg/raddbg.mdesk @@ -416,7 +416,7 @@ RD_CmdTable: // | | | | {EnableEntity 0 0 Null null Nil 0 0 0 0 0 0 Null "enable_entity" "Enable Entity" "Enables an entity." "" } {DisableEntity 0 0 Null null Nil 0 0 0 0 0 0 Null "disable_entity" "Disable Entity" "Disables an entity." "" } {SelectEntity 0 0 Null null Nil 0 0 0 0 0 0 CheckHollow "select_entity" "Select Entity" "Selects an entity, disabling all others of the same kind." "" } - {RemoveEntity 0 0 Null null Nil 0 0 0 0 0 0 Null "remove_entity" "Remove Entity" "Removes an entity." "" } + {RemoveEntity 0 0 Null null Nil 0 0 0 0 0 0 Trash "remove_entity" "Remove Entity" "Removes an entity." "" } {NameEntity 0 0 Null null Nil 0 0 0 0 0 0 Null "name_entity" "Name Entity" "Equips an entity with a name." "" } {DuplicateEntity 0 0 Null null Nil 0 0 0 0 0 0 Null "duplicate_entity" "Duplicate Entity" "Duplicates an entity." "" } {RelocateEntity 0 0 Null null Nil 0 0 0 0 0 0 Null "relocate_entity" "Relocate Entity" "Relocates an entity." "" } diff --git a/src/raddbg/raddbg_core.c b/src/raddbg/raddbg_core.c index 601029ae..1ab05a75 100644 --- a/src/raddbg/raddbg_core.c +++ b/src/raddbg/raddbg_core.c @@ -1774,6 +1774,12 @@ rd_title_fstrs_from_entity(Arena *arena, RD_Entity *entity, Vec4F32 secondary_co else if(loc->string.size != 0) { location = loc->string; + location_is_code = 1; + } + else if(loc->flags & RD_EntityFlag_HasVAddr) + { + location = push_str8f(arena, "0x%I64x", loc->vaddr); + location_is_code = 1; } } B32 extra = 0; @@ -1792,7 +1798,17 @@ rd_title_fstrs_from_entity(Arena *arena, RD_Entity *entity, Vec4F32 secondary_co { dr_fancy_string_list_push_new(arena, &result, rd_font_from_slot(RD_FontSlot_Code), size, v4f32(0, 0, 0, 0), str8_lit(" ")); } - dr_fancy_string_list_push_new(arena, &result, rd_font_from_slot(location_is_code ? RD_FontSlot_Code : RD_FontSlot_Main), size_extrafied, color_extrafied, location); + if(location_is_code) + { + DR_FancyStringList loc_fstrs = {0}; + RD_Font(RD_FontSlot_Code) + loc_fstrs = rd_fancy_string_list_from_code_string(arena, 1.f, 0, color_extrafied, location); + dr_fancy_string_list_concat_in_place(&result, &loc_fstrs); + } + else + { + dr_fancy_string_list_push_new(arena, &result, rd_font_from_slot(RD_FontSlot_Main), size_extrafied, color_extrafied, location); + } extra = 1; size_extrafied = size*0.95f; color_extrafied = secondary_color; @@ -2057,14 +2073,20 @@ rd_ctrl_meta_eval_from_entity(Arena *arena, RD_Entity *entity) RD_Entity *loc = rd_entity_child_from_kind(entity, RD_EntityKind_Location); RD_Entity *cnd = rd_entity_child_from_kind(entity, RD_EntityKind_Condition); String8 label_string = push_str8_copy(arena, entity->string); - String8 loc_string = {0}; + String8 src_loc_string = {0}; + String8 vaddr_loc_string = {0}; + String8 function_loc_string = {0}; if(loc->flags & RD_EntityFlag_HasTextPoint) { - loc_string = push_str8f(arena, "%S:%I64u:%I64u", loc->string, loc->text_point.line, loc->text_point.column); + src_loc_string = push_str8f(arena, "%S:%I64u:%I64u", loc->string, loc->text_point.line, loc->text_point.column); } else if(loc->flags & RD_EntityFlag_HasVAddr) { - loc_string = push_str8f(arena, "0x%I64x", loc->vaddr); + vaddr_loc_string = push_str8f(arena, "0x%I64x", loc->vaddr); + } + else if(loc->string.size != 0) + { + function_loc_string = push_str8_copy(arena, loc->string); } String8 cnd_string = push_str8_copy(arena, cnd->string); meval->enabled = !entity->disabled; @@ -2075,7 +2097,9 @@ rd_ctrl_meta_eval_from_entity(Arena *arena, RD_Entity *entity) meval->args = args->string; meval->working_directory = wdir->string; meval->entry_point = entr->string; - meval->location = loc_string; + meval->source_location = src_loc_string; + meval->address_location = vaddr_loc_string; + meval->function_location = function_loc_string; meval->condition = cnd_string; return meval; } @@ -2289,6 +2313,24 @@ rd_eval_space_write(void *u, E_Space space, void *in, Rng1U64 range) StringMemberCase(working_directory) {result = 1; rd_entity_equip_name(rd_entity_child_from_kind_or_alloc(entity, RD_EntityKind_WorkingDirectory), str8_cstring_capped(in, (U8 *)in + 4096));} StringMemberCase(entry_point) {result = 1; rd_entity_equip_name(rd_entity_child_from_kind_or_alloc(entity, RD_EntityKind_EntryPoint), str8_cstring_capped(in, (U8 *)in + 4096));} StringMemberCase(condition) {result = 1; rd_entity_equip_name(rd_entity_child_from_kind_or_alloc(entity, RD_EntityKind_Condition), str8_cstring_capped(in, (U8 *)in + 4096));} + StringMemberCase(source_location) + { + result = 1; + String8TxtPtPair src_loc = str8_txt_pt_pair_from_string(str8_cstring_capped(in, (U8 *)in + 4096)); + RD_Entity *loc = rd_entity_child_from_kind_or_alloc(entity, RD_EntityKind_Location); + rd_entity_equip_name(loc, src_loc.string); + rd_entity_equip_txt_pt(loc, src_loc.pt); + } + StringMemberCase(address_location) + { + } + StringMemberCase(function_location) + { + result = 1; + RD_Entity *loc = rd_entity_child_from_kind_or_alloc(entity, RD_EntityKind_Location); + loc->flags &= ~RD_EntityFlag_HasTextPoint; + rd_entity_equip_name(loc, str8_cstring_capped(in, (U8 *)in + 4096)); + } #undef FlatMemberCase #undef StringMemberCase scratch_end(scratch); @@ -2413,17 +2455,9 @@ rd_commit_eval_value_string(E_Eval dst_eval, String8 string) E_Eval src_eval = e_eval_from_string(scratch.arena, string); E_Eval src_eval_value = e_value_eval_from_eval(src_eval); E_TypeKind src_eval_value_type_kind = e_type_kind_from_key(src_eval_value.type_key); - if(type_kind == E_TypeKind_Ptr && - (e_type_kind_is_pointer_or_ref(src_eval_value_type_kind) || - e_type_kind_is_integer(src_eval_value_type_kind)) && - src_eval_value.mode == E_Mode_Value) - { - commit_data = push_str8_copy(scratch.arena, str8_struct(&src_eval.value)); - commit_data.size = Min(commit_data.size, e_type_byte_size_from_key(type_key)); - } - else if(direct_type_kind == E_TypeKind_Char8 || - direct_type_kind == E_TypeKind_UChar8 || - e_type_kind_is_integer(direct_type_kind)) + if(direct_type_kind == E_TypeKind_Char8 || + direct_type_kind == E_TypeKind_UChar8 || + e_type_kind_is_integer(direct_type_kind)) { B32 is_quoted = 0; if(string.size >= 1 && string.str[0] == '"') @@ -2449,6 +2483,15 @@ rd_commit_eval_value_string(E_Eval dst_eval, String8 string) commit_at_ptr_dest = 1; } } + else if(type_kind == E_TypeKind_Ptr && + (e_type_kind_is_pointer_or_ref(src_eval_value_type_kind) || + e_type_kind_is_integer(src_eval_value_type_kind)) && + src_eval_value.mode == E_Mode_Value) + { + commit_data = push_str8_copy(scratch.arena, str8_struct(&src_eval.value)); + commit_data.size = Min(commit_data.size, e_type_byte_size_from_key(src_eval.type_key)); + commit_data.size = Min(commit_data.size, e_type_byte_size_from_key(type_key)); + } } if(commit_data.size != 0 && e_type_byte_size_from_key(type_key) != 0) { @@ -3373,7 +3416,7 @@ rd_window_frame(RD_Window *ws) RD_RegSlot slot = ((rd_state->drag_drop_regs_slot != RD_RegSlot_Null && rd_drag_is_active()) ? rd_state->drag_drop_regs_slot : rd_state->hover_regs_slot); RD_Regs *regs = (((rd_state->drag_drop_regs_slot != RD_RegSlot_Null && rd_drag_is_active()) ? rd_state->drag_drop_regs : rd_state->hover_regs)); CTRL_Entity *ctrl_entity = &ctrl_entity_nil; - UI_Tooltip RD_Palette(RD_PaletteCode_Floating) switch(slot) + RD_Palette(RD_PaletteCode_Floating) switch(slot) { default:{}break; @@ -3381,6 +3424,7 @@ rd_window_frame(RD_Window *ws) //- rjf: frontend entity tooltips // case RD_RegSlot_Entity: + UI_Tooltip { // rjf: unpack RD_Entity *entity = rd_entity_from_handle(regs->entity); @@ -3403,6 +3447,7 @@ rd_window_frame(RD_Window *ws) case RD_RegSlot_Thread: {ctrl_entity = ctrl_entity_from_handle(d_state->ctrl_entity_store, regs->thread); }goto ctrl_entity_tooltip; case RD_RegSlot_CtrlEntity:{ctrl_entity = ctrl_entity_from_handle(d_state->ctrl_entity_store, regs->ctrl_entity); }goto ctrl_entity_tooltip; ctrl_entity_tooltip:; + UI_Tooltip { // rjf: unpack DI_Scope *di_scope = di_scope_open(); @@ -3980,10 +4025,11 @@ rd_window_frame(RD_Window *ws) ////////////////////// //- rjf: ctrl entities // - case RD_RegSlot_Machine: ctrl_entity = ctrl_entity_from_handle(d_state->ctrl_entity_store, regs->machine); goto ctrl_entity_title; - case RD_RegSlot_Process: ctrl_entity = ctrl_entity_from_handle(d_state->ctrl_entity_store, regs->process); goto ctrl_entity_title; - case RD_RegSlot_Module: ctrl_entity = ctrl_entity_from_handle(d_state->ctrl_entity_store, regs->module); goto ctrl_entity_title; - case RD_RegSlot_Thread: ctrl_entity = ctrl_entity_from_handle(d_state->ctrl_entity_store, regs->thread); goto ctrl_entity_title; + case RD_RegSlot_Machine: ctrl_entity = ctrl_entity_from_handle(d_state->ctrl_entity_store, regs->machine); goto ctrl_entity_title; + case RD_RegSlot_Process: ctrl_entity = ctrl_entity_from_handle(d_state->ctrl_entity_store, regs->process); goto ctrl_entity_title; + case RD_RegSlot_Module: ctrl_entity = ctrl_entity_from_handle(d_state->ctrl_entity_store, regs->module); goto ctrl_entity_title; + case RD_RegSlot_Thread: ctrl_entity = ctrl_entity_from_handle(d_state->ctrl_entity_store, regs->thread); goto ctrl_entity_title; + case RD_RegSlot_CtrlEntity: ctrl_entity = ctrl_entity_from_handle(d_state->ctrl_entity_store, regs->ctrl_entity); goto ctrl_entity_title; ctrl_entity_title:; { //- rjf: title @@ -4271,6 +4317,38 @@ rd_window_frame(RD_Window *ws) #endif }break; + ////////////////////// + //- rjf: frontend entities + // + case RD_RegSlot_Entity: + { + RD_Entity *entity = rd_entity_from_handle(regs->entity); + + //- rjf: title + UI_Row + UI_PrefWidth(ui_text_dim(5, 1)) + UI_TextAlignment(UI_TextAlign_Center) + UI_TextPadding(ui_top_font_size()*1.5f) + { + DR_FancyStringList fstrs = rd_title_fstrs_from_entity(scratch.arena, entity, ui_top_palette()->text_weak, ui_top_font_size()); + UI_Box *title_box = ui_build_box_from_key(UI_BoxFlag_DrawText, ui_key_zero()); + ui_box_equip_display_fancy_strings(title_box, &fstrs); + if(ctrl_entity->kind == CTRL_EntityKind_Thread) + { + ui_spacer(ui_em(0.5f, 1.f)); + UI_FontSize(ui_top_font_size() - 1.f) + UI_CornerRadius(ui_top_font_size()*0.5f) + RD_Palette(RD_PaletteCode_NeutralPopButton) + UI_TextPadding(ui_top_font_size()*0.5f) + { + UI_FlagsAdd(UI_BoxFlag_DrawTextWeak|UI_BoxFlag_DrawBorder) ui_label(string_from_arch(ctrl_entity->arch)); + ui_spacer(ui_em(0.5f, 1.f)); + UI_FlagsAdd(UI_BoxFlag_DrawTextWeak|UI_BoxFlag_DrawBorder) ui_labelf("TID: %i", (U32)ctrl_entity->id); + } + } + } + }break; + } } @@ -9789,8 +9867,8 @@ rd_cfg_strings_from_gfx(Arena *arena, String8 root_path, RD_CfgSrc source) entity_name_escaped = escaped_from_raw_str8(arena, e->string); } EntityInfoFlags info_flags = 0; - if(entity_name_escaped.size != 0) { info_flags |= EntityInfoFlag_HasName; } - if(!!e->disabled) { info_flags |= EntityInfoFlag_HasDisabled; } + if(entity_name_escaped.size != 0) { info_flags |= EntityInfoFlag_HasName; } + if(!!e->disabled) { info_flags |= EntityInfoFlag_HasDisabled; } if(e->flags & RD_EntityFlag_HasTextPoint) { info_flags |= EntityInfoFlag_HasTxtPt; } if(e->flags & RD_EntityFlag_HasVAddr) { info_flags |= EntityInfoFlag_HasVAddr; } if(e->flags & RD_EntityFlag_HasColor) { info_flags |= EntityInfoFlag_HasColor; } @@ -14570,9 +14648,12 @@ rd_frame(void) } }break; case RD_CmdKind_AddAddressBreakpoint: + { + rd_cmd(RD_CmdKind_AddBreakpoint, .string = str8_zero()); + }break; case RD_CmdKind_AddFunctionBreakpoint: { - rd_cmd(RD_CmdKind_AddBreakpoint); + rd_cmd(RD_CmdKind_AddBreakpoint, .vaddr = 0); }break; //- rjf: watch pins diff --git a/src/raddbg/raddbg_views.c b/src/raddbg/raddbg_views.c index 650ec40e..697dac88 100644 --- a/src/raddbg/raddbg_views.c +++ b/src/raddbg/raddbg_views.c @@ -1204,9 +1204,12 @@ rd_watch_view_build(RD_WatchViewState *ewv, RD_WatchViewFlags flags, String8 roo } RD_WatchViewRowCtrl row_ctrls_[] = { - {RD_EntityKind_Target, CTRL_EntityKind_Null, RD_CmdKind_LaunchAndRun }, - {RD_EntityKind_Target, CTRL_EntityKind_Null, RD_CmdKind_LaunchAndInit }, - {RD_EntityKind_Target, CTRL_EntityKind_Null, RD_CmdKind_SelectEntity }, + {RD_EntityKind_Target, CTRL_EntityKind_Null, RD_CmdKind_LaunchAndRun }, + {RD_EntityKind_Target, CTRL_EntityKind_Null, RD_CmdKind_LaunchAndInit }, + {RD_EntityKind_Target, CTRL_EntityKind_Null, RD_CmdKind_SelectEntity }, + {RD_EntityKind_Target, CTRL_EntityKind_Null, RD_CmdKind_RemoveEntity }, + {RD_EntityKind_Breakpoint, CTRL_EntityKind_Null, RD_CmdKind_EnableEntity }, + {RD_EntityKind_Breakpoint, CTRL_EntityKind_Null, RD_CmdKind_RemoveEntity }, {RD_EntityKind_Nil, CTRL_EntityKind_Thread, RD_CmdKind_FreezeThread }, {RD_EntityKind_Nil, CTRL_EntityKind_Thread, RD_CmdKind_SelectThread }, }; @@ -2599,7 +2602,7 @@ rd_watch_view_build(RD_WatchViewState *ewv, RD_WatchViewFlags flags, String8 roo B32 is_frozen = ctrl_entity_tree_is_frozen(ctrl_entity); RD_IconKind icon_kind = rd_cmd_kind_info_table[ctrl->kind].icon_kind; UI_Palette *palette = ui_top_palette(); - if(ctrl->kind == RD_CmdKind_SelectEntity) + if(ctrl->kind == RD_CmdKind_SelectEntity || ctrl->kind == RD_CmdKind_EnableEntity) { icon_kind = entity->disabled ? RD_IconKind_CheckHollow : RD_IconKind_CheckFilled; } @@ -2623,6 +2626,10 @@ rd_watch_view_build(RD_WatchViewState *ewv, RD_WatchViewFlags flags, String8 roo sig.event_flags & OS_Modifier_Ctrl && !entity->disabled ? RD_CmdKind_DisableEntity : RD_CmdKind_SelectEntity, .entity = rd_handle_from_entity(entity)); } + else if(ctrl->kind == RD_CmdKind_EnableEntity) + { + rd_cmd(entity->disabled ? RD_CmdKind_EnableEntity : RD_CmdKind_DisableEntity, .entity = rd_handle_from_entity(entity)); + } else if(ctrl->kind == RD_CmdKind_SelectThread) { rd_cmd(RD_CmdKind_SelectThread, .thread = ctrl_entity->handle); @@ -5371,7 +5378,7 @@ RD_VIEW_RULE_UI_FUNCTION_DEF(breakpoints) rd_watch_view_column_alloc(wv, RD_WatchViewColumnKind_Value, 0.75f, .dequote_string = 1); } rd_watch_view_build(wv, RD_WatchViewFlag_NoHeader|RD_WatchViewFlag_PrettyNameMembers|RD_WatchViewFlag_PrettyEntityRows|RD_WatchViewFlag_DisableCacheLines, - str8_lit("breakpoints"), str8_lit("only: label condition str hit_count location"), 0, 10, rect); + str8_lit("breakpoints"), str8_lit("only: label condition str hit_count source_location address_location function_location"), 0, 10, rect); ProfEnd(); } @@ -6525,6 +6532,10 @@ RD_VIEW_RULE_UI_FUNCTION_DEF(memory) { eval.space = rd_eval_space_from_ctrl_entity(ctrl_entity_from_handle(d_state->ctrl_entity_store, rd_regs()->process), RD_EvalSpaceKind_CtrlEntity); space_range = rd_whole_range_from_eval_space(eval.space); + if(dim_1u64(space_range) == 0) + { + space_range = r1u64(0, 0x7FFFFFFFFFFFull); + } } U64 cursor = rd_value_from_params_key(params, str8_lit("cursor_vaddr")).u64; U64 mark = rd_value_from_params_key(params, str8_lit("mark_vaddr")).u64; @@ -6564,10 +6575,8 @@ RD_VIEW_RULE_UI_FUNCTION_DEF(memory) }break; case RD_CmdKind_GoToAddress: { - // NOTE(rjf): go-to-address occurs with disassembly snaps, and we don't - // generally want to respond to those in thise view, so just skip any - // go-to-address commands that haven't been *explicitly* parameterized - // with this view. + cursor = mark = cmd->regs->vaddr; + mv->center_cursor = 1; }break; case RD_CmdKind_SetColumns: { @@ -6594,7 +6603,7 @@ RD_VIEW_RULE_UI_FUNCTION_DEF(memory) ////////////////////////////// //- rjf: determine legal scroll range // - Rng1S64 scroll_idx_rng = r1s64(0, space_range.max/num_columns); + Rng1S64 scroll_idx_rng = r1s64(0, dim_1u64(space_range)/num_columns); ////////////////////////////// //- rjf: determine info about visible range of rows @@ -6608,12 +6617,13 @@ RD_VIEW_RULE_UI_FUNCTION_DEF(memory) viz_range_rows.max = scroll_pos.y.idx + (S64)scroll_pos.y.off + num_possible_visible_rows, viz_range_rows.min = clamp_1s64(scroll_idx_rng, viz_range_rows.min); viz_range_rows.max = clamp_1s64(scroll_idx_rng, viz_range_rows.max); - viz_range_bytes.min = viz_range_rows.min*num_columns; - viz_range_bytes.max = (viz_range_rows.max+1)*num_columns+1; + viz_range_bytes.min = space_range.min + viz_range_rows.min*num_columns; + viz_range_bytes.max = space_range.min + (viz_range_rows.max+1)*num_columns+1; if(viz_range_bytes.min > viz_range_bytes.max) { Swap(U64, viz_range_bytes.min, viz_range_bytes.max); } + viz_range_bytes = intersect_1u64(space_range, viz_range_bytes); } ////////////////////////////// @@ -6670,7 +6680,6 @@ RD_VIEW_RULE_UI_FUNCTION_DEF(memory) cell_delta.y = ClampBot(cell_delta.y, (S64)-(next_cursor/num_columns)); next_cursor += cell_delta.x; next_cursor += cell_delta.y*num_columns; - next_cursor = ClampTop(0x7FFFFFFFFFFFull, next_cursor); } if(good_action && evt->flags & UI_EventFlag_PickSelectSide && cursor != mark) { @@ -6702,6 +6711,10 @@ RD_VIEW_RULE_UI_FUNCTION_DEF(memory) // { Rng1U64 cursor_valid_rng = space_range; + if(cursor_valid_rng.max != 0) + { + cursor_valid_rng.max -= 1; + } cursor = clamp_1u64(cursor_valid_rng, cursor); mark = clamp_1u64(cursor_valid_rng, mark); } @@ -7071,7 +7084,8 @@ RD_VIEW_RULE_UI_FUNCTION_DEF(memory) UI_WidthFill UI_PrefHeight(ui_px(row_height_px, 1.f)) for(S64 row_idx = viz_range_rows.min; row_idx <= viz_range_rows.max; row_idx += 1) { - Rng1U64 row_range_bytes = r1u64(row_idx*num_columns, (row_idx+1)*num_columns); + Rng1U64 row_range_bytes = r1u64(viz_range_bytes.min + row_idx*num_columns, + viz_range_bytes.min + (row_idx+1)*num_columns); B32 row_is_boundary = 0; Vec4F32 row_boundary_color = {0}; if(row_range_bytes.min%64 == 0) @@ -7096,77 +7110,94 @@ RD_VIEW_RULE_UI_FUNCTION_DEF(memory) { for(U64 col_idx = 0; col_idx < num_columns; col_idx += 1) { + // rjf: unpack information about this slot U64 visible_byte_idx = (row_idx-viz_range_rows.min)*num_columns + col_idx; U64 global_byte_idx = viz_range_bytes.min+visible_byte_idx; U64 global_byte_num = global_byte_idx+1; - U8 byte_value = visible_memory[visible_byte_idx]; - Annotation *annotation = visible_memory_annotations[visible_byte_idx].first; - UI_BoxFlags cell_flags = 0; - Vec4F32 cell_border_rgba = {0}; - Vec4F32 cell_bg_rgba = {0}; - if(global_byte_num == mouse_hover_byte_num) + + // rjf: build space, if this cell is out-of-range + if(global_byte_idx >= viz_range_bytes.max) { - cell_flags |= UI_BoxFlag_DrawBorder|UI_BoxFlag_DrawSideTop|UI_BoxFlag_DrawSideBottom|UI_BoxFlag_DrawSideLeft|UI_BoxFlag_DrawSideRight; - cell_border_rgba = rd_rgba_from_theme_color(RD_ThemeColor_Hover); + ui_build_box_from_key(0, ui_key_zero()); } - if(annotation != 0) + + // rjf: build actual cell + else { - cell_flags |= UI_BoxFlag_DrawBackground; - cell_bg_rgba = annotation->color; - if(contains_1u64(annotation->vaddr_range, mouse_hover_byte_num-1)) + // rjf: unpack byte info + U8 byte_value = visible_memory[visible_byte_idx]; + Annotation *annotation = visible_memory_annotations[visible_byte_idx].first; + + // rjf: unpack visual cell info + UI_BoxFlags cell_flags = 0; + Vec4F32 cell_border_rgba = {0}; + Vec4F32 cell_bg_rgba = {0}; + if(global_byte_num == mouse_hover_byte_num) { - cell_bg_rgba.w *= 0.15f; + cell_flags |= UI_BoxFlag_DrawBorder|UI_BoxFlag_DrawSideTop|UI_BoxFlag_DrawSideBottom|UI_BoxFlag_DrawSideLeft|UI_BoxFlag_DrawSideRight; + cell_border_rgba = rd_rgba_from_theme_color(RD_ThemeColor_Hover); } - else + if(annotation != 0) { - cell_bg_rgba.w *= 0.08f; - } - } - if(selection.min <= global_byte_idx && global_byte_idx <= selection.max) - { - cell_flags |= UI_BoxFlag_DrawBackground; - cell_bg_rgba = rd_rgba_from_theme_color(RD_ThemeColor_SelectionOverlay); - } - ui_set_next_palette(ui_build_palette(ui_top_palette(), .background = cell_bg_rgba)); - UI_Box *cell_box = ui_build_box_from_key(UI_BoxFlag_DrawText|cell_flags, ui_key_zero()); - ui_box_equip_display_fancy_strings(cell_box, &byte_fancy_strings[byte_value]); - { - F32 off = 0; - for(Annotation *a = annotation; a != 0; a = a->next) - { - if(global_byte_idx == a->vaddr_range.min) UI_Parent(row_overlay_box) + cell_flags |= UI_BoxFlag_DrawBackground; + cell_bg_rgba = annotation->color; + if(contains_1u64(annotation->vaddr_range, mouse_hover_byte_num-1)) { - ui_set_next_palette(ui_build_palette(ui_top_palette(), .background = annotation->color)); - ui_set_next_fixed_x(big_glyph_advance*18.f + col_idx*cell_width_px + -cell_width_px/8.f + off); - ui_set_next_fixed_y((row_idx-viz_range_rows.min)*row_height_px + -cell_width_px/8.f); - ui_set_next_fixed_width(cell_width_px/4.f); - ui_set_next_fixed_height(cell_width_px/4.f); - ui_set_next_corner_radius_00(cell_width_px/8.f); - ui_set_next_corner_radius_01(cell_width_px/8.f); - ui_set_next_corner_radius_10(cell_width_px/8.f); - ui_set_next_corner_radius_11(cell_width_px/8.f); - ui_build_box_from_key(UI_BoxFlag_Floating|UI_BoxFlag_DrawBackground|UI_BoxFlag_DrawDropShadow, ui_key_zero()); - off += cell_width_px/8.f + cell_width_px/16.f; + cell_bg_rgba.w *= 0.15f; + } + else + { + cell_bg_rgba.w *= 0.08f; } } - } - if(annotation != 0 && mouse_hover_byte_num == global_byte_num) UI_Tooltip UI_FontSize(ui_top_font_size()) UI_PrefHeight(ui_px(ui_top_font_size()*1.75f, 1.f)) - { - for(Annotation *a = annotation; a != 0; a = a->next) + if(selection.min <= global_byte_idx && global_byte_idx <= selection.max) { - UI_PrefWidth(ui_children_sum(1)) UI_Row UI_PrefWidth(ui_text_dim(10, 1)) + cell_flags |= UI_BoxFlag_DrawBackground; + cell_bg_rgba = rd_rgba_from_theme_color(RD_ThemeColor_SelectionOverlay); + } + + // rjf: build + ui_set_next_palette(ui_build_palette(ui_top_palette(), .background = cell_bg_rgba)); + UI_Box *cell_box = ui_build_box_from_key(UI_BoxFlag_DrawText|cell_flags, ui_key_zero()); + ui_box_equip_display_fancy_strings(cell_box, &byte_fancy_strings[byte_value]); + { + F32 off = 0; + for(Annotation *a = annotation; a != 0; a = a->next) { - RD_Font(RD_FontSlot_Code) ui_label(a->name_string); - RD_Font(RD_FontSlot_Main) UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) ui_label(a->kind_string); + if(global_byte_idx == a->vaddr_range.min) UI_Parent(row_overlay_box) + { + ui_set_next_palette(ui_build_palette(ui_top_palette(), .background = annotation->color)); + ui_set_next_fixed_x(big_glyph_advance*18.f + col_idx*cell_width_px + -cell_width_px/8.f + off); + ui_set_next_fixed_y((row_idx-viz_range_rows.min)*row_height_px + -cell_width_px/8.f); + ui_set_next_fixed_width(cell_width_px/4.f); + ui_set_next_fixed_height(cell_width_px/4.f); + ui_set_next_corner_radius_00(cell_width_px/8.f); + ui_set_next_corner_radius_01(cell_width_px/8.f); + ui_set_next_corner_radius_10(cell_width_px/8.f); + ui_set_next_corner_radius_11(cell_width_px/8.f); + ui_build_box_from_key(UI_BoxFlag_Floating|UI_BoxFlag_DrawBackground|UI_BoxFlag_DrawDropShadow, ui_key_zero()); + off += cell_width_px/8.f + cell_width_px/16.f; + } } - if(a->type_string.size != 0) + } + if(annotation != 0 && mouse_hover_byte_num == global_byte_num) UI_Tooltip UI_FontSize(ui_top_font_size()) UI_PrefHeight(ui_px(ui_top_font_size()*1.75f, 1.f)) + { + for(Annotation *a = annotation; a != 0; a = a->next) { - rd_code_label(1.f, 1, rd_rgba_from_theme_color(RD_ThemeColor_CodeType), a->type_string); - } - UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) ui_label(str8_from_memory_size(scratch.arena, dim_1u64(a->vaddr_range))); - if(a->next != 0) - { - ui_spacer(ui_em(1.5f, 1.f)); + UI_PrefWidth(ui_children_sum(1)) UI_Row UI_PrefWidth(ui_text_dim(10, 1)) + { + RD_Font(RD_FontSlot_Code) ui_label(a->name_string); + RD_Font(RD_FontSlot_Main) UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) ui_label(a->kind_string); + } + if(a->type_string.size != 0) + { + rd_code_label(1.f, 1, rd_rgba_from_theme_color(RD_ThemeColor_CodeType), a->type_string); + } + UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) ui_label(str8_from_memory_size(scratch.arena, dim_1u64(a->vaddr_range))); + if(a->next != 0) + { + ui_spacer(ui_em(1.5f, 1.f)); + } } } } @@ -7176,16 +7207,22 @@ RD_VIEW_RULE_UI_FUNCTION_DEF(memory) UI_WidthFill { MemoryZero(row_ascii_buffer, num_columns); + U64 num_bytes_this_row = 0; for(U64 col_idx = 0; col_idx < num_columns; col_idx += 1) { - U8 byte_value = visible_memory[(row_idx-viz_range_rows.min)*num_columns + col_idx]; - row_ascii_buffer[col_idx] = byte_value; - if(byte_value <= 32 || 127 < byte_value) + U64 visible_byte_idx = (row_idx-viz_range_rows.min)*num_columns + col_idx; + if(visible_byte_idx < visible_memory_size) { - row_ascii_buffer[col_idx] = '.'; + U8 byte_value = visible_memory[visible_byte_idx]; + row_ascii_buffer[col_idx] = byte_value; + if(byte_value <= 32 || 127 < byte_value) + { + row_ascii_buffer[col_idx] = '.'; + } + num_bytes_this_row += 1; } } - String8 ascii_text = str8(row_ascii_buffer, num_columns); + String8 ascii_text = str8(row_ascii_buffer, num_bytes_this_row); UI_Box *ascii_box = ui_build_box_from_stringf(UI_BoxFlag_DrawText, "%S###ascii_row_%I64x", ascii_text, row_range_bytes.min); if(selection.max >= row_range_bytes.min && selection.min < row_range_bytes.max) {