add memory view rule; adjust memory view to appropriately use eval parameterizations, so that it can be used as a view rule correctly

This commit is contained in:
Ryan Fleury
2024-08-27 13:47:38 -07:00
parent 4b75145ec0
commit 645db07493
11 changed files with 148 additions and 253 deletions
+51 -13
View File
@@ -3731,6 +3731,40 @@ df_key_from_eval_space_range(E_Space space, Rng1U64 range, B32 zero_terminated)
return result;
}
//- rjf: space -> entire range
internal Rng1U64
df_whole_range_from_eval_space(E_Space space)
{
Rng1U64 result = r1u64(0, 0);
DF_Entity *entity = df_entity_from_eval_space(space);
switch(entity->kind)
{
//- rjf: nil space -> filesystem key encoded inside of `space`
case DF_EntityKind_Nil:
{
HS_Scope *scope = hs_scope_open();
U128 hash = {0};
for(U64 idx = 0; idx < 2; idx += 1)
{
hash = hs_hash_from_key(space, idx);
if(!u128_match(hash, u128_zero()))
{
break;
}
}
String8 data = hs_data_from_hash(scope, hash);
result = r1u64(0, data.size);
hs_scope_close(scope);
}break;
case DF_EntityKind_Process:
{
result = r1u64(0, 0x7FFFFFFFFFFFull);
}break;
}
return result;
}
////////////////////////////////
//~ rjf: Evaluation Views
@@ -5280,20 +5314,24 @@ df_range_from_eval_params(E_Eval eval, MD_Node *params)
{
Temp scratch = scratch_begin(0, 0);
U64 size = df_value_from_params_key(params, str8_lit("size")).u64;
if(size == 0 &&
(e_type_kind_from_key(eval.type_key) == E_TypeKind_Array ||
e_type_kind_from_key(e_type_direct_from_key(eval.type_key)) == E_TypeKind_Array))
E_TypeKey type_key = e_type_unwrap(eval.type_key);
E_TypeKind type_kind = e_type_kind_from_key(type_key);
E_TypeKey direct_type_key = e_type_unwrap(e_type_direct_from_key(eval.type_key));
E_TypeKind direct_type_kind = e_type_kind_from_key(direct_type_key);
if(size == 0 && e_type_kind_is_pointer_or_ref(type_kind) && (direct_type_kind == E_TypeKind_Struct ||
direct_type_kind == E_TypeKind_Union ||
direct_type_kind == E_TypeKind_Class ||
direct_type_kind == E_TypeKind_Array ||
e_type_kind_is_basic_or_enum(direct_type_kind)))
{
E_Type *type = e_type_from_key(scratch.arena, eval.type_key);
E_Type *array_type = type;
if(array_type->kind != E_TypeKind_Array)
{
array_type = e_type_from_key(scratch.arena, array_type->direct_type_key);
}
if(array_type->kind != E_TypeKind_Array)
{
size = array_type->count;
}
size = e_type_byte_size_from_key(e_type_direct_from_key(e_type_unwrap(eval.type_key)));
}
if(size == 0 && eval.mode == E_Mode_Offset && (type_kind == E_TypeKind_Struct ||
type_kind == E_TypeKind_Union ||
type_kind == E_TypeKind_Class ||
type_kind == E_TypeKind_Array))
{
size = e_type_byte_size_from_key(e_type_unwrap(eval.type_key));
}
if(size == 0)
{
+4
View File
@@ -1558,6 +1558,9 @@ internal B32 df_eval_space_write(void *u, E_Space space, void *in, Rng1U64 range
//- rjf: asynchronous streamed reads -> hashes from spaces
internal U128 df_key_from_eval_space_range(E_Space space, Rng1U64 range, B32 zero_terminated);
//- rjf: space -> entire range
internal Rng1U64 df_whole_range_from_eval_space(E_Space space);
////////////////////////////////
//~ rjf: Evaluation Views
@@ -1629,6 +1632,7 @@ internal B32 df_viz_row_is_editable(DF_EvalVizRow *row);
//- rjf: eval / view rule params tree info extraction
internal U64 df_base_offset_from_eval(E_Eval eval);
internal U64 df_size_from_eval_params(E_Eval eval, MD_Node *params);
internal E_Value df_value_from_params(MD_Node *params);
internal E_TypeKey df_type_key_from_params(MD_Node *params);
internal E_Value df_value_from_params_key(MD_Node *params, String8 key);
+1
View File
@@ -537,6 +537,7 @@ DF_CoreViewRuleTable:
{RGBA rgba "rgba" - x - x "Color (RGBA)" x "" "Displays as a color, interpreting the data as encoding R, G, B, and A values." }
{Text text "text" - x - x "Text" x "x:{'lang':lang, 'size':expr}" "Displays as text." }
{Disasm disasm "disasm" - x - x "Disassembly" x "x:{'arch':arch, 'size':expr}" "Displays as disassembled instructions, interpreting the data as raw machine code." }
{Memory memory "memory" - x - x "Memory" x "x:{'size':expr}" "Displays as a raw memory grid." }
{Graph graph "graph" - x - x "Graph" x "" "Displays as a pointer graph, visualizing nodes and edges formed by pointers directly." }
{Bitmap bitmap "bitmap" - x - x "Bitmap" x "x:{'w':expr, 'h':expr, 'fmt':tex2dformat}" "Displays as a bitmap, interpreting the data as raw pixel data." }
{Geo geo "geo" - x - x "Geometry" x "x:{'count':expr, 'vertices_base':expr, 'vertices_size':expr}" "Displays as geometry, interpreting the data as vertex data." }
+2 -1
View File
@@ -481,7 +481,7 @@ DF_CmdSpecInfo df_g_core_cmd_kind_spec_info_table[221] =
{ str8_lit_comp("log_marker"), str8_lit_comp("Logs a marker in the application log, to denote specific points in time within the log."), str8_lit_comp(""), str8_lit_comp("Log Marker"), (DF_CmdSpecFlag_ListInUI*1)|(DF_CmdSpecFlag_ListInIPCDocs*1), {DF_CmdParamSlot_Null, DF_EntityKind_Nil, (DF_CmdQueryFlag_AllowFiles*0)|(DF_CmdQueryFlag_AllowFolders*0)|(DF_CmdQueryFlag_CodeInput*0)|(DF_CmdQueryFlag_KeepOldInput*0)|(DF_CmdQueryFlag_SelectOldInput*0)|(DF_CmdQueryFlag_Required*0)}, DF_IconKind_Null},
};
DF_CoreViewRuleSpecInfo df_g_core_view_rule_spec_info_table[20] =
DF_CoreViewRuleSpecInfo df_g_core_view_rule_spec_info_table[21] =
{
{str8_lit_comp("default"), str8_lit_comp("Default"), str8_lit_comp(""), str8_lit_comp(""), (DF_CoreViewRuleSpecInfoFlag_Inherited*0)|(DF_CoreViewRuleSpecInfoFlag_Expandable*0)|(DF_CoreViewRuleSpecInfoFlag_ExprResolution*0)|(DF_CoreViewRuleSpecInfoFlag_VizBlockProd*1), 0, DF_CORE_VIEW_RULE_VIZ_BLOCK_PROD_FUNCTION_NAME(default) , },
{str8_lit_comp("array"), str8_lit_comp("Array"), str8_lit_comp("x:{expr}"), str8_lit_comp("Specifies that a pointer points to N elements, rather than only 1."), (DF_CoreViewRuleSpecInfoFlag_Inherited*0)|(DF_CoreViewRuleSpecInfoFlag_Expandable*0)|(DF_CoreViewRuleSpecInfoFlag_ExprResolution*1)|(DF_CoreViewRuleSpecInfoFlag_VizBlockProd*0), DF_CORE_VIEW_RULE_EXPR_RESOLUTION_FUNCTION_NAME(array) , 0, },
@@ -500,6 +500,7 @@ DF_CoreViewRuleSpecInfo df_g_core_view_rule_spec_info_table[20] =
{str8_lit_comp("rgba"), str8_lit_comp("Color (RGBA)"), str8_lit_comp(""), str8_lit_comp("Displays as a color, interpreting the data as encoding R, G, B, and A values."), (DF_CoreViewRuleSpecInfoFlag_Inherited*0)|(DF_CoreViewRuleSpecInfoFlag_Expandable*1)|(DF_CoreViewRuleSpecInfoFlag_ExprResolution*0)|(DF_CoreViewRuleSpecInfoFlag_VizBlockProd*1), 0, DF_CORE_VIEW_RULE_VIZ_BLOCK_PROD_FUNCTION_NAME(rgba) , },
{str8_lit_comp("text"), str8_lit_comp("Text"), str8_lit_comp("x:{'lang':lang, 'size':expr}"), str8_lit_comp("Displays as text."), (DF_CoreViewRuleSpecInfoFlag_Inherited*0)|(DF_CoreViewRuleSpecInfoFlag_Expandable*1)|(DF_CoreViewRuleSpecInfoFlag_ExprResolution*0)|(DF_CoreViewRuleSpecInfoFlag_VizBlockProd*1), 0, DF_CORE_VIEW_RULE_VIZ_BLOCK_PROD_FUNCTION_NAME(text) , },
{str8_lit_comp("disasm"), str8_lit_comp("Disassembly"), str8_lit_comp("x:{'arch':arch, 'size':expr}"), str8_lit_comp("Displays as disassembled instructions, interpreting the data as raw machine code."), (DF_CoreViewRuleSpecInfoFlag_Inherited*0)|(DF_CoreViewRuleSpecInfoFlag_Expandable*1)|(DF_CoreViewRuleSpecInfoFlag_ExprResolution*0)|(DF_CoreViewRuleSpecInfoFlag_VizBlockProd*1), 0, DF_CORE_VIEW_RULE_VIZ_BLOCK_PROD_FUNCTION_NAME(disasm) , },
{str8_lit_comp("memory"), str8_lit_comp("Memory"), str8_lit_comp("x:{'size':expr}"), str8_lit_comp("Displays as a raw memory grid."), (DF_CoreViewRuleSpecInfoFlag_Inherited*0)|(DF_CoreViewRuleSpecInfoFlag_Expandable*1)|(DF_CoreViewRuleSpecInfoFlag_ExprResolution*0)|(DF_CoreViewRuleSpecInfoFlag_VizBlockProd*1), 0, DF_CORE_VIEW_RULE_VIZ_BLOCK_PROD_FUNCTION_NAME(memory) , },
{str8_lit_comp("graph"), str8_lit_comp("Graph"), str8_lit_comp(""), str8_lit_comp("Displays as a pointer graph, visualizing nodes and edges formed by pointers directly."), (DF_CoreViewRuleSpecInfoFlag_Inherited*0)|(DF_CoreViewRuleSpecInfoFlag_Expandable*1)|(DF_CoreViewRuleSpecInfoFlag_ExprResolution*0)|(DF_CoreViewRuleSpecInfoFlag_VizBlockProd*1), 0, DF_CORE_VIEW_RULE_VIZ_BLOCK_PROD_FUNCTION_NAME(graph) , },
{str8_lit_comp("bitmap"), str8_lit_comp("Bitmap"), str8_lit_comp("x:{'w':expr, 'h':expr, 'fmt':tex2dformat}"), str8_lit_comp("Displays as a bitmap, interpreting the data as raw pixel data."), (DF_CoreViewRuleSpecInfoFlag_Inherited*0)|(DF_CoreViewRuleSpecInfoFlag_Expandable*1)|(DF_CoreViewRuleSpecInfoFlag_ExprResolution*0)|(DF_CoreViewRuleSpecInfoFlag_VizBlockProd*1), 0, DF_CORE_VIEW_RULE_VIZ_BLOCK_PROD_FUNCTION_NAME(bitmap) , },
{str8_lit_comp("geo"), str8_lit_comp("Geometry"), str8_lit_comp("x:{'count':expr, 'vertices_base':expr, 'vertices_size':expr}"), str8_lit_comp("Displays as geometry, interpreting the data as vertex data."), (DF_CoreViewRuleSpecInfoFlag_Inherited*0)|(DF_CoreViewRuleSpecInfoFlag_Expandable*1)|(DF_CoreViewRuleSpecInfoFlag_ExprResolution*0)|(DF_CoreViewRuleSpecInfoFlag_VizBlockProd*1), 0, DF_CORE_VIEW_RULE_VIZ_BLOCK_PROD_FUNCTION_NAME(geo) , },
+2
View File
@@ -367,6 +367,7 @@ DF_CoreViewRuleKind_Checkbox,
DF_CoreViewRuleKind_RGBA,
DF_CoreViewRuleKind_Text,
DF_CoreViewRuleKind_Disasm,
DF_CoreViewRuleKind_Memory,
DF_CoreViewRuleKind_Graph,
DF_CoreViewRuleKind_Bitmap,
DF_CoreViewRuleKind_Geo,
@@ -442,6 +443,7 @@ DF_CORE_VIEW_RULE_VIZ_BLOCK_PROD_FUNCTION_DEF(omit);
DF_CORE_VIEW_RULE_VIZ_BLOCK_PROD_FUNCTION_DEF(rgba);
DF_CORE_VIEW_RULE_VIZ_BLOCK_PROD_FUNCTION_DEF(text);
DF_CORE_VIEW_RULE_VIZ_BLOCK_PROD_FUNCTION_DEF(disasm);
DF_CORE_VIEW_RULE_VIZ_BLOCK_PROD_FUNCTION_DEF(memory);
DF_CORE_VIEW_RULE_VIZ_BLOCK_PROD_FUNCTION_DEF(graph);
DF_CORE_VIEW_RULE_VIZ_BLOCK_PROD_FUNCTION_DEF(bitmap);
DF_CORE_VIEW_RULE_VIZ_BLOCK_PROD_FUNCTION_DEF(geo);