From c67f1a8b4ad05e35fb0cd03f93a2f2d531cd620f Mon Sep 17 00:00:00 2001 From: Ryan Fleury Date: Tue, 22 Oct 2024 16:19:01 -0700 Subject: [PATCH] fix empty file edge case in hash store / text cache --- src/hash_store/hash_store.c | 5 +---- src/raddbg/raddbg_main.c | 11 ++++++++--- src/raddbg/raddbg_views.c | 4 ++-- src/raddbg/raddbg_widgets.c | 8 ++------ src/text_cache/text_cache.c | 2 +- 5 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/hash_store/hash_store.c b/src/hash_store/hash_store.c index ef825fd9..5dadb646 100644 --- a/src/hash_store/hash_store.c +++ b/src/hash_store/hash_store.c @@ -14,10 +14,7 @@ internal U128 hs_hash_from_data(String8 data) { U128 u128 = {0}; - if(data.size != 0) - { - blake2b((U8 *)&u128.u64[0], sizeof(u128), data.str, data.size, 0, 0); - } + blake2b((U8 *)&u128.u64[0], sizeof(u128), data.str, data.size, 0, 0); return u128; } diff --git a/src/raddbg/raddbg_main.c b/src/raddbg/raddbg_main.c index febaf060..9ea18671 100644 --- a/src/raddbg/raddbg_main.c +++ b/src/raddbg/raddbg_main.c @@ -18,22 +18,27 @@ // [ ] disasm starting address - need to use debug info for more correct // results... // -// -// // [ ] linked list view rule +// // [ ] investigate false exceptions, being reported while stepping through init code // [ ] output: add option for scroll-to-bottom - ensure this shows up in universal ctx menu -// [ ] universal ctx menu address/watch options; e.g. watch -> memory; watch -> add watch +// // [ ] EVAL LOOKUP RULES -> currently going 0 -> rdis_count, but we need // to prioritize the primary rdi +// // [ ] (reported by forrest) 'set-next-statement' -> prioritize current // module/symbol, in cases where one line maps to many voffs +// // [ ] collapse upstream state for theme/bindings/settings into entities; use cache accelerators if needed to make up difference // [ ] collapse upstream state for windows/panels/tabs into entities; use downstream window/view resource cache to make up the difference // [ ] entity <-> mdesk paths +// +// [ ] universal ctx menu address/watch options; e.g. watch -> memory; watch -> add watch // [ ] rich hover coverage; bitmap <-> geo <-> memory <-> disassembly <-> text; etc. +// // [ ] save view column pcts; generalize to being a first-class thing in // RD_View, e.g. by just having a string -> f32 store +// // [ ] visualize all breakpoints everywhere - source view should show up in // disasm, disasm should show up in source view, function should show up in // both, etc. diff --git a/src/raddbg/raddbg_views.c b/src/raddbg/raddbg_views.c index 0d5955be..eeebc456 100644 --- a/src/raddbg/raddbg_views.c +++ b/src/raddbg/raddbg_views.c @@ -5716,7 +5716,7 @@ RD_VIEW_RULE_UI_FUNCTION_DEF(pending_file) { HS_Scope *hs_scope = hs_scope_open(); String8 data = hs_data_from_hash(hs_scope, file_hash); - if(data.size != 0) + if(!u128_match(file_hash, u128_zero())) { U64 num_utf8_bytes = 0; U64 num_unknown_bytes = 0; @@ -5737,7 +5737,7 @@ RD_VIEW_RULE_UI_FUNCTION_DEF(pending_file) } } file_is_ready = 1; - if(num_utf8_bytes > num_unknown_bytes*4) + if(num_utf8_bytes > num_unknown_bytes*4 || num_unknown_bytes == 0) { viewer_kind = RD_ViewRuleKind_Text; } diff --git a/src/raddbg/raddbg_widgets.c b/src/raddbg/raddbg_widgets.c index 1c63bdf2..145e13af 100644 --- a/src/raddbg/raddbg_widgets.c +++ b/src/raddbg/raddbg_widgets.c @@ -1734,9 +1734,8 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe mouse_pt = txt_pt(line_num, column); // rjf: clamp - if(dim_1s64(params->line_num_range) > 0) { - U64 last_line_size = params->line_text[dim_1s64(params->line_num_range)-1].size; + U64 last_line_size = params->line_text[dim_1s64(params->line_num_range)].size; TxtRng legal_pt_rng = txt_rng(txt_pt(params->line_num_range.min, 1), txt_pt(params->line_num_range.max, last_line_size+1)); if(txt_pt_less_than(mouse_pt, legal_pt_rng.min)) @@ -1748,10 +1747,7 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe mouse_pt = legal_pt_rng.max; } } - else - { - mouse_pt = txt_pt(1, 1); - } + result.mouse_pt = mouse_pt; } diff --git a/src/text_cache/text_cache.c b/src/text_cache/text_cache.c index 90fc2da1..a25dd24f 100644 --- a/src/text_cache/text_cache.c +++ b/src/text_cache/text_cache.c @@ -2168,7 +2168,7 @@ txt_parse_thread__entry_point(void *p) //- rjf: data -> text info Arena *info_arena = 0; TXT_TextInfo info = {0}; - if(got_task && data.size != 0) + if(got_task && !u128_match(hash, u128_zero())) { info_arena = arena_alloc();