mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-06-15 00:22:23 -07:00
make eval ctxs more robust to missing info, e.g. in the test harness case
This commit is contained in:
@@ -4624,7 +4624,7 @@ ctrl_thread__eval_scope_begin(Arena *arena, CTRL_Entity *thread)
|
||||
U64 eval_modules_count = Max(1, ctrl_state->ctrl_thread_entity_store->entity_kind_counts[CTRL_EntityKind_Module]);
|
||||
E_Module *eval_modules = push_array(arena, E_Module, eval_modules_count);
|
||||
E_Module *eval_modules_primary = &eval_modules[0];
|
||||
eval_modules_primary->rdi = &di_rdi_parsed_nil;
|
||||
eval_modules_primary->rdi = &rdi_parsed_nil;
|
||||
eval_modules_primary->vaddr_range = r1u64(0, max_U64);
|
||||
{
|
||||
U64 eval_module_idx = 0;
|
||||
|
||||
@@ -532,7 +532,7 @@ ASYNC_WORK_DEF(dasm_parse_work)
|
||||
}
|
||||
|
||||
//- rjf: get dbg info
|
||||
RDI_Parsed *rdi = &di_rdi_parsed_nil;
|
||||
RDI_Parsed *rdi = &rdi_parsed_nil;
|
||||
if(got_task && params.dbgi_key.path.size != 0)
|
||||
{
|
||||
rdi = di_rdi_from_key(di_scope, ¶ms.dbgi_key, max_U64);
|
||||
@@ -573,7 +573,7 @@ ASYNC_WORK_DEF(dasm_parse_work)
|
||||
// rjf: push strings derived from voff -> line info
|
||||
if(params.style_flags & (DASM_StyleFlag_SourceFilesNames|DASM_StyleFlag_SourceLines))
|
||||
{
|
||||
if(rdi != &di_rdi_parsed_nil)
|
||||
if(rdi != &rdi_parsed_nil)
|
||||
{
|
||||
U64 voff = (params.vaddr+off) - params.base_vaddr;
|
||||
U32 unit_idx = rdi_vmap_idx_from_section_kind_voff(rdi, RDI_SectionKind_UnitVMap, voff);
|
||||
@@ -655,7 +655,7 @@ ASYNC_WORK_DEF(dasm_parse_work)
|
||||
String8 addr_part = {0};
|
||||
if(params.style_flags & DASM_StyleFlag_Addresses)
|
||||
{
|
||||
addr_part = push_str8f(scratch.arena, "%s0x%016I64x ", rdi != &di_rdi_parsed_nil ? " " : "", params.vaddr+off);
|
||||
addr_part = push_str8f(scratch.arena, "%s0x%016I64x ", rdi != &rdi_parsed_nil ? " " : "", params.vaddr+off);
|
||||
}
|
||||
String8 code_bytes_part = {0};
|
||||
if(params.style_flags & DASM_StyleFlag_CodeBytes)
|
||||
@@ -677,7 +677,7 @@ ASYNC_WORK_DEF(dasm_parse_work)
|
||||
code_bytes_part = str8_list_join(scratch.arena, &code_bytes_strings, 0);
|
||||
}
|
||||
String8 symbol_part = {0};
|
||||
if(inst.jump_dest_vaddr != 0 && rdi != &di_rdi_parsed_nil && params.style_flags & DASM_StyleFlag_SymbolNames)
|
||||
if(inst.jump_dest_vaddr != 0 && rdi != &rdi_parsed_nil && params.style_flags & DASM_StyleFlag_SymbolNames)
|
||||
{
|
||||
RDI_U32 scope_idx = rdi_vmap_idx_from_section_kind_voff(rdi, RDI_SectionKind_ScopeVMap, inst.jump_dest_vaddr-params.base_vaddr);
|
||||
if(scope_idx != 0)
|
||||
@@ -752,7 +752,7 @@ ASYNC_WORK_DEF(dasm_parse_work)
|
||||
{
|
||||
n->info_arena = info_arena;
|
||||
MemoryCopyStruct(&n->info, &info);
|
||||
if(rdi != &di_rdi_parsed_nil && params.style_flags & (DASM_StyleFlag_SourceLines|DASM_StyleFlag_SourceFilesNames))
|
||||
if(rdi != &rdi_parsed_nil && params.style_flags & (DASM_StyleFlag_SourceLines|DASM_StyleFlag_SourceFilesNames))
|
||||
{
|
||||
n->change_gen = change_gen;
|
||||
}
|
||||
|
||||
@@ -811,7 +811,7 @@ d_voff_from_dbgi_key_symbol_name(DI_Key *dbgi_key, String8 symbol_name)
|
||||
RDI_NameMapKind_GlobalVariables,
|
||||
RDI_NameMapKind_Procedures,
|
||||
};
|
||||
if(rdi != &di_rdi_parsed_nil)
|
||||
if(rdi != &rdi_parsed_nil)
|
||||
{
|
||||
for(U64 name_map_kind_idx = 0;
|
||||
name_map_kind_idx < ArrayCount(name_map_kinds);
|
||||
@@ -1038,7 +1038,7 @@ d_lines_array_from_dbgi_key_file_path_line_range(Arena *arena, DI_Key dbgi_key,
|
||||
// rjf: file_path_normalized * rdi -> src_id
|
||||
B32 good_src_id = 0;
|
||||
U32 src_id = 0;
|
||||
if(rdi != &di_rdi_parsed_nil) ProfScope("file_path_normalized * rdi -> src_id")
|
||||
if(rdi != &rdi_parsed_nil) ProfScope("file_path_normalized * rdi -> src_id")
|
||||
{
|
||||
RDI_NameMap *mapptr = rdi_element_from_name_idx(rdi, NameMaps, RDI_NameMapKind_NormalSourcePaths);
|
||||
RDI_ParsedNameMap map = {0};
|
||||
@@ -1136,7 +1136,7 @@ d_lines_array_from_file_path_line_range(Arena *arena, String8 file_path, Rng1S64
|
||||
// rjf: file_path_normalized * rdi -> src_id
|
||||
B32 good_src_id = 0;
|
||||
U32 src_id = 0;
|
||||
if(rdi != &di_rdi_parsed_nil) ProfScope("file_path_normalized * rdi -> src_id")
|
||||
if(rdi != &rdi_parsed_nil) ProfScope("file_path_normalized * rdi -> src_id")
|
||||
{
|
||||
RDI_NameMap *mapptr = rdi_element_from_name_idx(rdi, NameMaps, RDI_NameMapKind_NormalSourcePaths);
|
||||
RDI_ParsedNameMap map = {0};
|
||||
|
||||
+2
-2
@@ -582,7 +582,7 @@ internal RDI_Parsed *
|
||||
di_rdi_from_key(DI_Scope *scope, DI_Key *key, U64 endt_us)
|
||||
{
|
||||
ProfBeginFunction();
|
||||
RDI_Parsed *result = &di_rdi_parsed_nil;
|
||||
RDI_Parsed *result = &rdi_parsed_nil;
|
||||
if(key->path.size != 0)
|
||||
{
|
||||
Temp scratch = scratch_begin(0, 0);
|
||||
@@ -1086,7 +1086,7 @@ ASYNC_WORK_DEF(di_parse_work)
|
||||
////////////////////////////
|
||||
//- rjf: do initial parse of rdi
|
||||
//
|
||||
RDI_Parsed rdi_parsed_maybe_compressed = di_rdi_parsed_nil;
|
||||
RDI_Parsed rdi_parsed_maybe_compressed = rdi_parsed_nil;
|
||||
{
|
||||
RDI_ParseStatus parse_status = rdi_parse((U8 *)file_base, file_props.size, &rdi_parsed_maybe_compressed);
|
||||
(void)parse_status;
|
||||
|
||||
@@ -379,7 +379,6 @@ struct DI_Shared
|
||||
|
||||
global DI_Shared *di_shared = 0;
|
||||
thread_static DI_TCTX *di_tctx = 0;
|
||||
global RDI_Parsed di_rdi_parsed_nil = {0};
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Basic Helpers
|
||||
|
||||
+1
-1
@@ -125,7 +125,7 @@ E_ExprKindTable:
|
||||
{ LeafU64 Null 0 "U64" "" "" "" }
|
||||
{ LeafF64 Null 0 "F64" "" "" "" }
|
||||
{ LeafF32 Null 0 "F32" "" "" "" }
|
||||
{ LeafIdent Null 0 "leaf_ident" "" "" "" }
|
||||
{ LeafIdentifier Null 0 "leaf_identifier" "" "" "" }
|
||||
{ LeafOffset Null 0 "leaf_offset" "" "" "" }
|
||||
{ LeafValue Null 0 "leaf_value" "" "" "" }
|
||||
{ LeafFilePath Null 0 "leaf_filepath" "" "" "" }
|
||||
|
||||
@@ -142,6 +142,11 @@ struct E_Module
|
||||
|
||||
#include "eval/generated/eval.meta.h"
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Globals
|
||||
|
||||
global read_only E_Module e_module_nil = {&rdi_parsed_nil};
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Basic Helper Functions
|
||||
|
||||
|
||||
+4
-3
@@ -75,6 +75,7 @@ e_select_ir_ctx(E_IRCtx *ctx)
|
||||
e_ir_state->arena_eval_start_pos = arena_pos(arena);
|
||||
}
|
||||
arena_pop_to(e_ir_state->arena, e_ir_state->arena_eval_start_pos);
|
||||
if(ctx->macro_map == 0) {ctx->macro_map = &e_string2expr_map_nil;}
|
||||
e_ir_state->ctx = ctx;
|
||||
e_ir_state->used_tag_map = push_array(e_ir_state->arena, E_UsedTagMap, 1);
|
||||
e_ir_state->used_tag_map->slots_count = 64;
|
||||
@@ -1230,7 +1231,7 @@ E_IRGEN_FUNCTION_DEF(wrap)
|
||||
Task *last_task = first_task;
|
||||
for(Task *t = first_task; t != 0; t = t->next)
|
||||
{
|
||||
if(t->expr->kind == E_ExprKind_LeafIdent && str8_match(t->expr->string, str8_lit("$expr"), 0))
|
||||
if(t->expr->kind == E_ExprKind_LeafIdentifier && str8_match(t->expr->string, str8_lit("$expr"), 0))
|
||||
{
|
||||
E_Expr *original_expr_ref = e_expr_ref(arena, expr);
|
||||
if(t->parent != &e_expr_nil)
|
||||
@@ -2530,7 +2531,7 @@ E_IRGEN_FUNCTION_DEF(default)
|
||||
}break;
|
||||
|
||||
//- rjf: leaf identifiers
|
||||
case E_ExprKind_LeafIdent:
|
||||
case E_ExprKind_LeafIdentifier:
|
||||
{
|
||||
E_Expr *macro_expr = e_string2expr_lookup(e_ir_state->ctx->macro_map, expr->string);
|
||||
if(macro_expr == &e_expr_nil)
|
||||
@@ -2618,7 +2619,7 @@ E_IRGEN_FUNCTION_DEF(default)
|
||||
E_Expr *lhs = expr->first;
|
||||
E_Expr *rhs = lhs->next;
|
||||
result = e_irtree_and_type_from_expr(arena, rhs);
|
||||
if(lhs->kind != E_ExprKind_LeafIdent)
|
||||
if(lhs->kind != E_ExprKind_LeafIdentifier)
|
||||
{
|
||||
e_msgf(arena, &result.msgs, E_MsgKind_MalformedInput, expr->location, "Left side of assignment must be an unused identifier.");
|
||||
}
|
||||
|
||||
@@ -637,6 +637,7 @@ e_select_parse_ctx(E_ParseCtx *ctx)
|
||||
if(ctx->reg_alias_map == 0) { ctx->reg_alias_map = &e_string2num_map_nil; }
|
||||
if(ctx->locals_map == 0) { ctx->locals_map = &e_string2num_map_nil; }
|
||||
if(ctx->member_map == 0) { ctx->member_map = &e_string2num_map_nil; }
|
||||
if(ctx->primary_module == 0){ ctx->primary_module = &e_module_nil; }
|
||||
e_parse_state->ctx = ctx;
|
||||
}
|
||||
|
||||
@@ -855,7 +856,7 @@ e_append_strings_from_expr(Arena *arena, E_Expr *expr, String8List *out)
|
||||
}break;
|
||||
case E_ExprKind_LeafBytecode:
|
||||
case E_ExprKind_LeafMember:
|
||||
case E_ExprKind_LeafIdent:
|
||||
case E_ExprKind_LeafIdentifier:
|
||||
{
|
||||
str8_list_push(arena, out, expr->string);
|
||||
}break;
|
||||
@@ -1058,7 +1059,7 @@ e_push_leaf_ident_exprs_from_expr__in_place(Arena *arena, E_String2ExprMap *map,
|
||||
{
|
||||
E_Expr *exprl = expr->first;
|
||||
E_Expr *exprr = exprl->next;
|
||||
if(exprl->kind == E_ExprKind_LeafIdent)
|
||||
if(exprl->kind == E_ExprKind_LeafIdentifier)
|
||||
{
|
||||
e_string2expr_map_insert(arena, map, exprl->string, exprr);
|
||||
}
|
||||
@@ -1869,7 +1870,7 @@ e_parse_expr_from_text_tokens__prec(Arena *arena, String8 text, E_TokenArray *to
|
||||
//- rjf: map failure -> attach as leaf identifier, to be resolved later
|
||||
if(!mapped_identifier)
|
||||
{
|
||||
atom = e_push_expr(arena, E_ExprKind_LeafIdent, token_string.str);
|
||||
atom = e_push_expr(arena, E_ExprKind_LeafIdentifier, token_string.str);
|
||||
atom->string = token_string;
|
||||
it += 1;
|
||||
}
|
||||
|
||||
@@ -241,6 +241,7 @@ e_select_type_ctx(E_TypeCtx *ctx)
|
||||
e_type_state->arena = arena;
|
||||
e_type_state->arena_eval_start_pos = arena_pos(e_type_state->arena);
|
||||
}
|
||||
if(ctx->primary_module == 0) {ctx->primary_module = &e_module_nil;}
|
||||
arena_pop_to(e_type_state->arena, e_type_state->arena_eval_start_pos);
|
||||
e_type_state->ctx = ctx;
|
||||
e_type_state->cons_id_gen = 0;
|
||||
|
||||
@@ -57,7 +57,7 @@ str8_lit_comp("LeafBool"),
|
||||
str8_lit_comp("LeafU64"),
|
||||
str8_lit_comp("LeafF64"),
|
||||
str8_lit_comp("LeafF32"),
|
||||
str8_lit_comp("LeafIdent"),
|
||||
str8_lit_comp("LeafIdentifier"),
|
||||
str8_lit_comp("LeafOffset"),
|
||||
str8_lit_comp("LeafValue"),
|
||||
str8_lit_comp("LeafFilePath"),
|
||||
|
||||
@@ -132,7 +132,7 @@ E_ExprKind_LeafBool,
|
||||
E_ExprKind_LeafU64,
|
||||
E_ExprKind_LeafF64,
|
||||
E_ExprKind_LeafF32,
|
||||
E_ExprKind_LeafIdent,
|
||||
E_ExprKind_LeafIdentifier,
|
||||
E_ExprKind_LeafOffset,
|
||||
E_ExprKind_LeafValue,
|
||||
E_ExprKind_LeafFilePath,
|
||||
|
||||
@@ -132,6 +132,7 @@ static union
|
||||
RDI_Local local;
|
||||
}
|
||||
rdi_nil_element_union = {0};
|
||||
static RDI_Parsed rdi_parsed_nil = {0};
|
||||
|
||||
////////////////////////////////
|
||||
//~ Top-Level Parsing API
|
||||
|
||||
@@ -3376,7 +3376,7 @@ rd_query_from_eval_string(Arena *arena, String8 string)
|
||||
{
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
E_Expr *expr = e_parse_expr_from_text(scratch.arena, string).exprs.last;
|
||||
if(expr->kind == E_ExprKind_LeafIdent &&
|
||||
if(expr->kind == E_ExprKind_LeafIdentifier &&
|
||||
str8_match(expr->qualifier, str8_lit("query"), 0))
|
||||
{
|
||||
result = expr->string;
|
||||
@@ -6036,7 +6036,7 @@ rd_tex2dformat_from_eval_tag(E_Eval eval, E_Expr *tag)
|
||||
// rjf: try implicit non-define arguments
|
||||
for(E_Expr *param = tag->first->next; param != &e_expr_nil && !got_fmt; param = param->next)
|
||||
{
|
||||
if(param->kind == E_ExprKind_LeafIdent)
|
||||
if(param->kind == E_ExprKind_LeafIdentifier)
|
||||
{
|
||||
for EachEnumVal(R_Tex2DFormat, f)
|
||||
{
|
||||
@@ -10747,7 +10747,7 @@ rd_append_value_strings_from_eval(Arena *arena, String8 filter, EV_StringFlags f
|
||||
}break;
|
||||
case E_Mode_Value:
|
||||
{
|
||||
MemoryCopy(string_buffer, &eval.value.u512[0], Min(string_buffer_size, sizeof(eval.value)));
|
||||
MemoryCopy(string_buffer, &eval.value.u512.u64[0], Min(string_buffer_size, sizeof(eval.value)));
|
||||
}break;
|
||||
}
|
||||
String8 string = {0};
|
||||
@@ -13449,7 +13449,7 @@ rd_frame(void)
|
||||
U64 eval_modules_count = Max(1, all_modules.count);
|
||||
E_Module *eval_modules = push_array(scratch.arena, E_Module, eval_modules_count);
|
||||
E_Module *eval_modules_primary = &eval_modules[0];
|
||||
eval_modules_primary->rdi = &di_rdi_parsed_nil;
|
||||
eval_modules_primary->rdi = &rdi_parsed_nil;
|
||||
eval_modules_primary->vaddr_range = r1u64(0, max_U64);
|
||||
DI_Key primary_dbgi_key = {0};
|
||||
ProfScope("produce all eval modules")
|
||||
@@ -15640,7 +15640,7 @@ Z(getting_started)
|
||||
// rjf: snap to resolved line
|
||||
B32 missing_rip = (rip_vaddr == 0);
|
||||
B32 dbgi_missing = (dbgi_key.min_timestamp == 0 || dbgi_key.path.size == 0);
|
||||
B32 dbgi_pending = !dbgi_missing && rdi == &di_rdi_parsed_nil;
|
||||
B32 dbgi_pending = !dbgi_missing && rdi == &rdi_parsed_nil;
|
||||
B32 has_line_info = (line.voff_range.max != 0);
|
||||
B32 has_module = (module != &ctrl_entity_nil);
|
||||
B32 has_dbg_info = has_module && !dbgi_missing;
|
||||
@@ -17312,7 +17312,7 @@ Z(getting_started)
|
||||
ExprWalkTask *first_task = &start_task;
|
||||
for(ExprWalkTask *t = first_task; t != 0; t = t->next)
|
||||
{
|
||||
if(t->expr->kind == E_ExprKind_LeafIdent)
|
||||
if(t->expr->kind == E_ExprKind_LeafIdentifier)
|
||||
{
|
||||
E_Expr *macro_expr = e_string2expr_lookup(e_ir_state->ctx->macro_map, t->expr->string);
|
||||
if(macro_expr != &e_expr_nil)
|
||||
|
||||
@@ -1468,7 +1468,7 @@ rd_info_from_watch_row_cell(Arena *arena, EV_Row *row, EV_StringFlags string_fla
|
||||
Task *last_task = first_task;
|
||||
for(Task *t = first_task; t != 0; t = t->next)
|
||||
{
|
||||
if(t->expr->kind == E_ExprKind_LeafIdent && str8_match(t->expr->string, str8_lit("$expr"), 0))
|
||||
if(t->expr->kind == E_ExprKind_LeafIdentifier && str8_match(t->expr->string, str8_lit("$expr"), 0))
|
||||
{
|
||||
E_Expr *original_expr_ref = e_expr_ref(scratch.arena, row->expr);
|
||||
if(t->parent != &e_expr_nil)
|
||||
|
||||
@@ -501,7 +501,7 @@ rd_title_fstrs_from_ctrl_entity(Arena *arena, CTRL_Entity *entity, B32 include_e
|
||||
U64 rip_voff = ctrl_voff_from_vaddr(module, rip_vaddr);
|
||||
DI_Key dbgi_key = ctrl_dbgi_key_from_module(module);
|
||||
RDI_Parsed *rdi = di_rdi_from_key(di_scope, &dbgi_key, 0);
|
||||
if(rdi != &di_rdi_parsed_nil)
|
||||
if(rdi != &rdi_parsed_nil)
|
||||
{
|
||||
RDI_Procedure *procedure = rdi_procedure_from_voff(rdi, rip_voff);
|
||||
String8 name = {0};
|
||||
|
||||
@@ -41,6 +41,7 @@ entry_point(CmdLine *cmdline)
|
||||
str8_lit("123"),
|
||||
str8_lit("1 + 2"),
|
||||
str8_lit("foo"),
|
||||
str8_lit("foo(bar)"),
|
||||
};
|
||||
for EachElement(idx, exprs)
|
||||
{
|
||||
@@ -82,6 +83,10 @@ entry_point(CmdLine *cmdline)
|
||||
{
|
||||
raddbg_log(" (%I64u)", expr->value.u64);
|
||||
}break;
|
||||
case E_ExprKind_LeafIdentifier:
|
||||
{
|
||||
raddbg_log(" (`%S`)", expr->string);
|
||||
}break;
|
||||
}
|
||||
raddbg_log("\n");
|
||||
Task *last_task = t;
|
||||
@@ -153,5 +158,6 @@ entry_point(CmdLine *cmdline)
|
||||
}
|
||||
}
|
||||
|
||||
raddbg_log("\n");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user