mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-08-14 17:28:07 +00:00
extend eval language w/ identifier disambiguators - used to pick amongst many identically-named things. for instance, local_static#0 will match the first local_static, local_static#1 will match the second, etc.
This commit is contained in:
@@ -1591,9 +1591,10 @@ di_match_artifact_create(String8 key, B32 *cancel_signal, B32 *retry_out, U64 *g
|
||||
U32 *run = rdi_matches_from_map_node(rdi, map_node, &num);
|
||||
if(num != 0)
|
||||
{
|
||||
U64 run_idx = (num-1) - Min(index, num-1);
|
||||
lane_matches[lane_idx()].key = dbgi_key;
|
||||
lane_matches[lane_idx()].section_kind = name_map_section_kinds[name_map_kind_idx];
|
||||
lane_matches[lane_idx()].idx = run[num-1];
|
||||
lane_matches[lane_idx()].idx = run[run_idx];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -263,6 +263,7 @@ struct E_Expr
|
||||
E_Value value;
|
||||
String8 string;
|
||||
String8 qualifier;
|
||||
String8 disambiguator;
|
||||
String8 bytecode;
|
||||
};
|
||||
|
||||
|
||||
+9
-1
@@ -1696,6 +1696,7 @@ e_push_irtree_and_type_from_expr(Arena *arena, E_IRTreeAndType *root_parent, E_I
|
||||
case E_ExprKind_LeafIdentifier:
|
||||
{
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
String8 disambiguator = expr->disambiguator;
|
||||
String8 qualifier = expr->qualifier;
|
||||
String8 string = expr->string;
|
||||
String8 string__redirected = string;
|
||||
@@ -1890,8 +1891,15 @@ e_push_irtree_and_type_from_expr(Arena *arena, E_IRTreeAndType *root_parent, E_I
|
||||
{
|
||||
Access *access = access_open();
|
||||
|
||||
// rjf: determine disambiguating index
|
||||
U64 match_disambiguating_idx = 0;
|
||||
if(disambiguator.size != 0)
|
||||
{
|
||||
try_u64_from_str8_c_rules(disambiguator, &match_disambiguating_idx);
|
||||
}
|
||||
|
||||
// rjf: find match
|
||||
DI_Match match = di_match_from_string(string, 0, e_base_ctx->primary_dbg_info->dbgi_key, 0);
|
||||
DI_Match match = di_match_from_string(string, match_disambiguating_idx, e_base_ctx->primary_dbg_info->dbgi_key, 0);
|
||||
if(match.idx == 0)
|
||||
{
|
||||
String8List namespaceified_strings = {0};
|
||||
|
||||
+37
-5
@@ -113,7 +113,8 @@ e_token_array_from_text(Arena *arena, String8 text)
|
||||
byte == '-' || byte == '=' || byte == '+' || byte == '[' ||
|
||||
byte == ']' || byte == '{' || byte == '}' || byte == ':' ||
|
||||
byte == ';' || byte == ',' || byte == '.' || byte == '<' ||
|
||||
byte == '>' || byte == '/' || byte == '?' || byte == '|')
|
||||
byte == '>' || byte == '/' || byte == '?' || byte == '|' ||
|
||||
byte == '#')
|
||||
{
|
||||
active_token_kind = E_TokenKind_Symbol;
|
||||
active_token_start_idx = idx;
|
||||
@@ -224,7 +225,8 @@ e_token_array_from_text(Arena *arena, String8 text)
|
||||
byte != '-' && byte != '=' && byte != '+' && byte != '[' &&
|
||||
byte != ']' && byte != '{' && byte != '}' && byte != ':' &&
|
||||
byte != ';' && byte != ',' && byte != '.' && byte != '<' &&
|
||||
byte != '>' && byte != '/' && byte != '?' && byte != '|')
|
||||
byte != '>' && byte != '/' && byte != '?' && byte != '|' &&
|
||||
byte != '#')
|
||||
{
|
||||
advance = 0;
|
||||
token_formed = 1;
|
||||
@@ -361,9 +363,10 @@ e_expr_copy(Arena *arena, E_Expr *src)
|
||||
dst->space = t->src->space;
|
||||
dst->type_key = t->src->type_key;
|
||||
dst->value = t->src->value;
|
||||
dst->string = push_str8_copy(arena, t->src->string);
|
||||
dst->bytecode = push_str8_copy(arena, t->src->bytecode);
|
||||
dst->qualifier = push_str8_copy(arena, t->src->qualifier);
|
||||
dst->string = str8_copy(arena, t->src->string);
|
||||
dst->bytecode = str8_copy(arena, t->src->bytecode);
|
||||
dst->disambiguator = str8_copy(arena, t->src->disambiguator);
|
||||
dst->qualifier = str8_copy(arena, t->src->qualifier);
|
||||
if(t->dst_parent == &e_expr_nil)
|
||||
{
|
||||
result = dst;
|
||||
@@ -468,6 +471,10 @@ e_append_strings_from_expr(Arena *arena, E_Expr *expr, String8 parent_expr_strin
|
||||
case E_ExprKind_LeafBytecode:
|
||||
case E_ExprKind_LeafIdentifier:
|
||||
{
|
||||
if(expr->qualifier.size != 0)
|
||||
{
|
||||
str8_list_pushf(arena, out, "%S:", expr->qualifier);
|
||||
}
|
||||
if(str8_match(expr->string, str8_lit("$"), 0) && parent_expr_string.size != 0)
|
||||
{
|
||||
str8_list_push(arena, out, parent_expr_string);
|
||||
@@ -476,6 +483,10 @@ e_append_strings_from_expr(Arena *arena, E_Expr *expr, String8 parent_expr_strin
|
||||
{
|
||||
str8_list_push(arena, out, expr->string);
|
||||
}
|
||||
if(expr->disambiguator.size != 0)
|
||||
{
|
||||
str8_list_pushf(arena, out, "#%S", expr->disambiguator);
|
||||
}
|
||||
}break;
|
||||
case E_ExprKind_LeafStringLiteral:
|
||||
{
|
||||
@@ -1046,6 +1057,27 @@ e_push_parse_from_string_tokens__prec(Arena *arena, String8 text, E_TokenArray t
|
||||
it += 1;
|
||||
got_new_atom = 1;
|
||||
}
|
||||
|
||||
// rjf: equip disambiguator
|
||||
if(got_new_atom)
|
||||
{
|
||||
E_Token possible_hash = e_token_at_it(it, &tokens);
|
||||
E_Token possible_numeric = e_token_at_it(it+1, &tokens);
|
||||
String8 possible_hash_string = str8_substr(text, possible_hash.range);
|
||||
String8 possible_numeric_string = str8_substr(text, possible_numeric.range);
|
||||
if(possible_hash.kind == E_TokenKind_Symbol && str8_match(possible_hash_string, str8_lit("#"), 0))
|
||||
{
|
||||
if(possible_numeric.kind == E_TokenKind_Numeric)
|
||||
{
|
||||
atom->disambiguator = possible_numeric_string;
|
||||
it += 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
e_msgf(arena, &result.msgs, E_MsgKind_MalformedInput, possible_numeric.range, "Expected disambiguating number after `#`.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
#if !defined(RADDBG_MARKUP_STUBS)
|
||||
# define raddbg_is_attached(...) raddbg_is_attached__impl()
|
||||
# define raddbg_thread_id(...) raddbg_thread_id__impl()
|
||||
# define raddbg_thread_name(fmt, ...) raddbg_thread_name__impl(raddbg_thread_id(), (fmt), __VA_ARGS__)
|
||||
# define raddbg_thread_id_name(id, fmt, ...) raddbg_thread_name__impl((id), (fmt), __VA_ARGS__)
|
||||
# define raddbg_thread_name(...) raddbg_thread_name__impl(raddbg_thread_id(), __VA_ARGS__)
|
||||
# define raddbg_thread_id_name(id, ...) raddbg_thread_name__impl((id), __VA_ARGS__)
|
||||
# define raddbg_thread_color_u32(u32) raddbg_thread_color__impl(raddbg_thread_id(), (u32))
|
||||
# define raddbg_thread_color_rgba(r, g, b, a) raddbg_thread_color__impl(raddbg_thread_id(), ((unsigned int)((r)*255) << 24) | ((unsigned int)((g)*255) << 16) | ((unsigned int)((b)*255) << 8) | ((unsigned int)(a)*255))
|
||||
# define raddbg_thread_id_color_u32(id, u32) raddbg_thread_color__impl((id), (u32))
|
||||
@@ -32,7 +32,7 @@
|
||||
# define raddbg_break_if(expr, ...) ((expr) ? raddbg_break__impl() : (void)0)
|
||||
# define raddbg_watch(fmt, ...) raddbg_watch__impl((fmt), __VA_ARGS__)
|
||||
# define raddbg_pin(expr, ...) /* NOTE(rjf): inspected by debugger ui - does not change program execution */
|
||||
# define raddbg_log(fmt, ...) raddbg_log__impl((fmt), __VA_ARGS__)
|
||||
# define raddbg_log(...) raddbg_log__impl(__VA_ARGS__)
|
||||
# define raddbg_entry_point(...) raddbg_exe_data char raddbg_gen_data_id()[] = ("entry_point: \"" #__VA_ARGS__ "\"")
|
||||
# define raddbg_type_view(type, ...) raddbg_exe_data char raddbg_gen_data_id()[] = ("type_view: {type: ```" #type "```, expr: ```" #__VA_ARGS__ "```}")
|
||||
# define raddbg_add_breakpoint(ptr, size, r, w, x) raddbg_add_or_remove_breakpoint__impl((ptr), (1), (size), (r), (w), (x))
|
||||
|
||||
+14
-3
@@ -910,8 +910,6 @@ static int g_abc = 100;
|
||||
static float g_xyz = 21.f;
|
||||
static Alias1 g_kind = Kind_First;
|
||||
|
||||
// TODO(allen): more global test types
|
||||
|
||||
static void
|
||||
complicated_global_mutation(int *x){
|
||||
*x = (int)g_xyz;
|
||||
@@ -922,8 +920,19 @@ cross_unit_global_mutation(void){
|
||||
fixed_frac_bits = 10;
|
||||
}
|
||||
|
||||
static int
|
||||
function_with_duplicate_local_statics(void)
|
||||
{
|
||||
static char *l_abc = "foobar";
|
||||
static int l_xyz = 123;
|
||||
static Kind l_kind = Kind_First;
|
||||
int x = l_xyz + (int)(int64_t)(l_abc);
|
||||
return x;
|
||||
}
|
||||
|
||||
static void
|
||||
global_eval_tests(void){
|
||||
global_eval_tests(void)
|
||||
{
|
||||
g_abc = 11*11;
|
||||
g_xyz = (float)g_abc - 21.f;
|
||||
|
||||
@@ -946,6 +955,8 @@ global_eval_tests(void){
|
||||
l_abc = g_abc*2;
|
||||
l_xyz = g_xyz*2;
|
||||
l_kind = (Alias1)(g_kind + 1);
|
||||
|
||||
function_with_duplicate_local_statics();
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
|
||||
Reference in New Issue
Block a user