mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-07-09 11:01:37 -07:00
expand dbgi asynchronous fuzzy matching system to allow selection of target table; this allows asynchronous fuzzy matching over types, globals, thread locals, and procedures
This commit is contained in:
+56
-7
@@ -385,7 +385,7 @@ dbgi_parse_from_exe_path(DBGI_Scope *scope, String8 exe_path, U64 endt_us)
|
||||
//~ rjf: Fuzzy Search Cache Functions
|
||||
|
||||
internal DBGI_FuzzySearchItemArray
|
||||
dbgi_fuzzy_search_items_from_key_exe_query(DBGI_Scope *scope, U128 key, String8 exe_path, String8 query, U64 endt_us, B32 *stale_out)
|
||||
dbgi_fuzzy_search_items_from_key_exe_query(DBGI_Scope *scope, U128 key, String8 exe_path, String8 query, DBGI_FuzzySearchTarget target, U64 endt_us, B32 *stale_out)
|
||||
{
|
||||
Temp scratch = scratch_begin(0, 0);
|
||||
DBGI_FuzzySearchItemArray items = {0};
|
||||
@@ -425,7 +425,9 @@ dbgi_fuzzy_search_items_from_key_exe_query(DBGI_Scope *scope, U128 key, String8
|
||||
|
||||
// rjf: try to grab last valid results for this key/query; determine if stale
|
||||
B32 stale = 1;
|
||||
if(str8_match(exe_path, node->buckets[node->gen%ArrayCount(node->buckets)].exe_path, 0) && node->gen != 0)
|
||||
if(str8_match(exe_path, node->buckets[node->gen%ArrayCount(node->buckets)].exe_path, 0) &&
|
||||
target == node->buckets[node->gen%ArrayCount(node->buckets)].target &&
|
||||
node->gen != 0)
|
||||
{
|
||||
dbgi_scope_touch_fuzzy_search__stripe_mutex_r_guarded(scope, node);
|
||||
items = node->gen_items;
|
||||
@@ -442,6 +444,7 @@ dbgi_fuzzy_search_items_from_key_exe_query(DBGI_Scope *scope, U128 key, String8
|
||||
arena_clear(node->buckets[node->submit_gen%ArrayCount(node->buckets)].arena);
|
||||
node->buckets[node->submit_gen%ArrayCount(node->buckets)].exe_path = push_str8_copy(node->buckets[node->submit_gen%ArrayCount(node->buckets)].arena, exe_path);
|
||||
node->buckets[node->submit_gen%ArrayCount(node->buckets)].query = push_str8_copy(node->buckets[node->submit_gen%ArrayCount(node->buckets)].arena, query);
|
||||
node->buckets[node->submit_gen%ArrayCount(node->buckets)].target = target;
|
||||
}
|
||||
if((node->submit_gen > node->gen+1 || os_now_microseconds() >= node->last_time_submitted_us+100000) &&
|
||||
dbgi_u2f_enqueue_req(key, endt_us))
|
||||
@@ -1117,6 +1120,7 @@ dbgi_fuzzy_thread__entry_point(void *p)
|
||||
Arena *task_arena = 0;
|
||||
String8 exe_path = {0};
|
||||
String8 query = {0};
|
||||
DBGI_FuzzySearchTarget target = DBGI_FuzzySearchTarget_Procedures;
|
||||
U64 initial_submit_gen = 0;
|
||||
OS_MutexScopeW(stripe->rw_mutex)
|
||||
{
|
||||
@@ -1129,6 +1133,7 @@ dbgi_fuzzy_thread__entry_point(void *p)
|
||||
task_arena = n->buckets[n->submit_gen%ArrayCount(n->buckets)].arena;
|
||||
exe_path = n->buckets[n->submit_gen%ArrayCount(n->buckets)].exe_path;
|
||||
query = n->buckets[n->submit_gen%ArrayCount(n->buckets)].query;
|
||||
target = n->buckets[n->submit_gen%ArrayCount(n->buckets)].target;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1139,14 +1144,58 @@ dbgi_fuzzy_thread__entry_point(void *p)
|
||||
RADDBG_Parsed *rdbg = &dbgi->rdbg;
|
||||
|
||||
//- rjf: rdbg * query -> item list
|
||||
U64 table_ptr_off = 0;
|
||||
U64 element_name_idx_off = 0;
|
||||
U64 element_count = 0;
|
||||
U64 element_size = 0;
|
||||
switch(target)
|
||||
{
|
||||
// NOTE(rjf): no default!
|
||||
case DBGI_FuzzySearchTarget_Procedures:
|
||||
{
|
||||
table_ptr_off = OffsetOf(RADDBG_Parsed, procedures);
|
||||
element_name_idx_off = OffsetOf(RADDBG_Procedure, name_string_idx);
|
||||
element_count = rdbg->procedures_count;
|
||||
element_size = sizeof(RADDBG_Procedure);
|
||||
}break;
|
||||
case DBGI_FuzzySearchTarget_GlobalVariables:
|
||||
{
|
||||
table_ptr_off = OffsetOf(RADDBG_Parsed, global_variables);
|
||||
element_name_idx_off = OffsetOf(RADDBG_GlobalVariable, name_string_idx);
|
||||
element_count = rdbg->global_variables_count;
|
||||
element_size = sizeof(RADDBG_GlobalVariable);
|
||||
}break;
|
||||
case DBGI_FuzzySearchTarget_ThreadVariables:
|
||||
{
|
||||
table_ptr_off = OffsetOf(RADDBG_Parsed, thread_variables);
|
||||
element_name_idx_off = OffsetOf(RADDBG_ThreadVariable, name_string_idx);
|
||||
element_count = rdbg->thread_variables_count;
|
||||
element_size = sizeof(RADDBG_ThreadVariable);
|
||||
}break;
|
||||
case DBGI_FuzzySearchTarget_UDTs:
|
||||
{
|
||||
table_ptr_off = OffsetOf(RADDBG_Parsed, udts);
|
||||
element_count = rdbg->udts_count;
|
||||
element_size = sizeof(RADDBG_UDT);
|
||||
}break;
|
||||
}
|
||||
DBGI_FuzzySearchItemChunkList items_list = {0};
|
||||
if(task_is_good)
|
||||
{
|
||||
for(U64 procedure_idx = 1; task_is_good && procedure_idx < rdbg->procedures_count; procedure_idx += 1)
|
||||
void *table_base = (U8*)rdbg + table_ptr_off;
|
||||
for(U64 idx = 1; task_is_good && idx < rdbg->procedures_count; idx += 1)
|
||||
{
|
||||
RADDBG_Procedure *procedure = &rdbg->procedures[procedure_idx];
|
||||
void *element = (U8 *)(*(void **)table_base) + element_size*idx;
|
||||
U32 *name_idx_ptr = (U32 *)((U8 *)element + element_name_idx_off);
|
||||
if(target == DBGI_FuzzySearchTarget_UDTs)
|
||||
{
|
||||
RADDBG_UDT *udt = (RADDBG_UDT *)element;
|
||||
RADDBG_TypeNode *type_node = raddbg_element_from_idx(rdbg, type_nodes, udt->self_type_idx);
|
||||
name_idx_ptr = &type_node->user_defined.name_string_idx;
|
||||
}
|
||||
U32 name_idx = *name_idx_ptr;
|
||||
U64 name_size = 0;
|
||||
U8 *name_base = raddbg_string_from_idx(rdbg, procedure->name_string_idx, &name_size);
|
||||
U8 *name_base = raddbg_string_from_idx(rdbg, name_idx, &name_size);
|
||||
String8 name = str8(name_base, name_size);
|
||||
if(name.size == 0) { continue; }
|
||||
FuzzyMatchRangeList matches = fuzzy_match_find(task_arena, query, name);
|
||||
@@ -1162,13 +1211,13 @@ dbgi_fuzzy_thread__entry_point(void *p)
|
||||
SLLQueuePush(items_list.first, items_list.last, chunk);
|
||||
items_list.chunk_count += 1;
|
||||
}
|
||||
chunk->v[chunk->count].procedure_idx = procedure_idx;
|
||||
chunk->v[chunk->count].idx = idx;
|
||||
chunk->v[chunk->count].match_ranges = matches;
|
||||
chunk->v[chunk->count].missed_size = (name_size > matches.total_dim) ? (name_size-matches.total_dim) : 0;
|
||||
chunk->count += 1;
|
||||
items_list.total_count += 1;
|
||||
}
|
||||
if(procedure_idx%100 == 99) OS_MutexScopeR(stripe->rw_mutex)
|
||||
if(idx%100 == 99) OS_MutexScopeR(stripe->rw_mutex)
|
||||
{
|
||||
for(DBGI_FuzzySearchNode *n = slot->first; n != 0; n = n->next)
|
||||
{
|
||||
|
||||
+13
-2
@@ -100,10 +100,20 @@ struct DBGI_BinaryStripe
|
||||
////////////////////////////////
|
||||
//~ rjf: Fuzzy Search Cache Types
|
||||
|
||||
typedef enum DBGI_FuzzySearchTarget
|
||||
{
|
||||
DBGI_FuzzySearchTarget_Procedures,
|
||||
DBGI_FuzzySearchTarget_GlobalVariables,
|
||||
DBGI_FuzzySearchTarget_ThreadVariables,
|
||||
DBGI_FuzzySearchTarget_UDTs,
|
||||
DBGI_FuzzySearchTarget_COUNT
|
||||
}
|
||||
DBGI_FuzzySearchTarget;
|
||||
|
||||
typedef struct DBGI_FuzzySearchItem DBGI_FuzzySearchItem;
|
||||
struct DBGI_FuzzySearchItem
|
||||
{
|
||||
U64 procedure_idx;
|
||||
U64 idx;
|
||||
U64 missed_size;
|
||||
FuzzyMatchRangeList match_ranges;
|
||||
};
|
||||
@@ -139,6 +149,7 @@ struct DBGI_FuzzySearchBucket
|
||||
Arena *arena;
|
||||
String8 exe_path;
|
||||
String8 query;
|
||||
DBGI_FuzzySearchTarget target;
|
||||
};
|
||||
|
||||
typedef struct DBGI_FuzzySearchNode DBGI_FuzzySearchNode;
|
||||
@@ -392,7 +403,7 @@ internal DBGI_Parse *dbgi_parse_from_exe_path(DBGI_Scope *scope, String8 exe_pat
|
||||
////////////////////////////////
|
||||
//~ rjf: Fuzzy Search Cache Functions
|
||||
|
||||
internal DBGI_FuzzySearchItemArray dbgi_fuzzy_search_items_from_key_exe_query(DBGI_Scope *scope, U128 key, String8 exe_path, String8 query, U64 endt_us, B32 *stale_out);
|
||||
internal DBGI_FuzzySearchItemArray dbgi_fuzzy_search_items_from_key_exe_query(DBGI_Scope *scope, U128 key, String8 exe_path, String8 query, DBGI_FuzzySearchTarget target, U64 endt_us, B32 *stale_out);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Parse Threads
|
||||
|
||||
@@ -3071,7 +3071,7 @@ DF_VIEW_UI_FUNCTION_DEF(SymbolLister)
|
||||
DBGI_Parse *dbgi = dbgi_parse_from_exe_path(scope, exe_path, os_now_microseconds()+100);
|
||||
RADDBG_Parsed *rdbg = &dbgi->rdbg;
|
||||
B32 items_stale = 0;
|
||||
DBGI_FuzzySearchItemArray items = dbgi_fuzzy_search_items_from_key_exe_query(scope, fuzzy_search_key, exe_path, query, os_now_microseconds()+100, &items_stale);
|
||||
DBGI_FuzzySearchItemArray items = dbgi_fuzzy_search_items_from_key_exe_query(scope, fuzzy_search_key, exe_path, query, DBGI_FuzzySearchTarget_Procedures, os_now_microseconds()+100, &items_stale);
|
||||
if(items_stale)
|
||||
{
|
||||
df_gfx_request_frame();
|
||||
@@ -3080,7 +3080,7 @@ DF_VIEW_UI_FUNCTION_DEF(SymbolLister)
|
||||
//- rjf: submit best match when hitting enter w/ no selection
|
||||
if(slv->cursor.y == 0 && items.count != 0 && os_key_press(ui_events(), ui_window(), 0, OS_Key_Return))
|
||||
{
|
||||
RADDBG_Procedure *procedure = raddbg_element_from_idx(rdbg, procedures, items.v[0].procedure_idx);
|
||||
RADDBG_Procedure *procedure = raddbg_element_from_idx(rdbg, procedures, items.v[0].idx);
|
||||
U64 name_size = 0;
|
||||
U8 *name_base = raddbg_string_from_idx(rdbg, procedure->name_string_idx, &name_size);
|
||||
String8 name = str8(name_base, name_size);
|
||||
@@ -3118,7 +3118,7 @@ DF_VIEW_UI_FUNCTION_DEF(SymbolLister)
|
||||
UI_Focus((slv->cursor.y == idx+1) ? UI_FocusKind_On : UI_FocusKind_Off)
|
||||
{
|
||||
DBGI_FuzzySearchItem *item = &items.v[idx];
|
||||
RADDBG_Procedure *procedure = raddbg_element_from_idx(rdbg, procedures, item->procedure_idx);
|
||||
RADDBG_Procedure *procedure = raddbg_element_from_idx(rdbg, procedures, item->idx);
|
||||
U64 name_size = 0;
|
||||
U8 *name_base = raddbg_string_from_idx(rdbg, procedure->name_string_idx, &name_size);
|
||||
String8 name = str8(name_base, name_size);
|
||||
@@ -3131,7 +3131,7 @@ DF_VIEW_UI_FUNCTION_DEF(SymbolLister)
|
||||
UI_BoxFlag_DrawText|
|
||||
UI_BoxFlag_DrawHotEffects|
|
||||
UI_BoxFlag_DrawActiveEffects,
|
||||
"###procedure_%I64x", item->procedure_idx);
|
||||
"###procedure_%I64x", item->idx);
|
||||
UI_Parent(box) UI_PrefWidth(ui_text_dim(10, 1))
|
||||
{
|
||||
UI_Box *box = df_code_label(1.f, 0, df_rgba_from_theme_color(DF_ThemeColor_CodeFunction), name);
|
||||
@@ -3158,7 +3158,7 @@ DF_VIEW_UI_FUNCTION_DEF(SymbolLister)
|
||||
S64 line_num = dasm2src_info.pt.line;
|
||||
df_code_label(1.f, 0, df_rgba_from_theme_color(DF_ThemeColor_CodeFunction), name);
|
||||
UI_Font(df_font_from_slot(DF_FontSlot_Main)) UI_TextColor(df_rgba_from_theme_color(DF_ThemeColor_WeakText))
|
||||
ui_labelf("Procedure #%I64u", item->procedure_idx);
|
||||
ui_labelf("Procedure #%I64u", item->idx);
|
||||
if(!df_entity_is_nil(dasm2src_info.file))
|
||||
{
|
||||
UI_Font(df_font_from_slot(DF_FontSlot_Main)) UI_TextColor(df_rgba_from_theme_color(DF_ThemeColor_WeakText))
|
||||
|
||||
Reference in New Issue
Block a user