diff --git a/src/ctrl/ctrl_core.c b/src/ctrl/ctrl_core.c index 6d4ebd1b..c5b8edcd 100644 --- a/src/ctrl/ctrl_core.c +++ b/src/ctrl/ctrl_core.c @@ -1299,12 +1299,6 @@ ctrl_init(void) ctrl_state->u2ms_ring_cv = os_condition_variable_alloc(); ctrl_state->ctrl_thread_log = log_alloc(); ctrl_state->ctrl_thread = os_thread_launch(ctrl_thread__entry_point, 0, 0); - ctrl_state->ms_thread_count = Clamp(1, os_get_system_info()->logical_processor_count-1, 4); - ctrl_state->ms_threads = push_array(arena, OS_Handle, ctrl_state->ms_thread_count); - for(U64 idx = 0; idx < ctrl_state->ms_thread_count; idx += 1) - { - ctrl_state->ms_threads[idx] = os_thread_launch(ctrl_mem_stream_thread__entry_point, (void *)idx, 0); - } } //////////////////////////////// @@ -1468,6 +1462,7 @@ ctrl_stored_hash_from_process_vaddr_range(CTRL_Handle process, Rng1U64 range, B3 } } } + async_push_work(ctrl_mem_stream_work); } } @@ -5854,170 +5849,166 @@ ctrl_u2ms_dequeue_req(CTRL_Handle *out_process, Rng1U64 *out_vaddr_range, B32 *o //- rjf: entry point -internal void -ctrl_mem_stream_thread__entry_point(void *p) +ASYNC_WORK_DEF(ctrl_mem_stream_work) { - ThreadNameF("[ctrl] mem stream thread #%I64u", (U64)p); CTRL_ProcessMemoryCache *cache = &ctrl_state->process_memory_cache; - for(;;) + //- rjf: unpack next request + CTRL_Handle process = {0}; + Rng1U64 vaddr_range = {0}; + B32 zero_terminated = 0; + ctrl_u2ms_dequeue_req(&process, &vaddr_range, &zero_terminated); + U128 key = ctrl_calc_hash_store_key_from_process_vaddr_range(process, vaddr_range, zero_terminated); + ProfBegin("memory stream request"); + + //- rjf: unpack process memory cache key + U64 process_hash = ctrl_hash_from_string(str8_struct(&process)); + U64 process_slot_idx = process_hash%cache->slots_count; + U64 process_stripe_idx = process_slot_idx%cache->stripes_count; + CTRL_ProcessMemoryCacheSlot *process_slot = &cache->slots[process_slot_idx]; + CTRL_ProcessMemoryCacheStripe *process_stripe = &cache->stripes[process_stripe_idx]; + + //- rjf: unpack address range hash cache key + U64 range_hash = ctrl_hash_from_string(str8_struct(&vaddr_range)); + + //- rjf: take task + B32 got_task = 0; + U64 preexisting_mem_gen = 0; + U128 preexisting_hash = {0}; + Rng1U64 vaddr_range_clamped = {0}; + OS_MutexScopeW(process_stripe->rw_mutex) { - //- rjf: unpack next request - CTRL_Handle process = {0}; - Rng1U64 vaddr_range = {0}; - B32 zero_terminated = 0; - ctrl_u2ms_dequeue_req(&process, &vaddr_range, &zero_terminated); - U128 key = ctrl_calc_hash_store_key_from_process_vaddr_range(process, vaddr_range, zero_terminated); - ProfBegin("memory stream request"); - - //- rjf: unpack process memory cache key - U64 process_hash = ctrl_hash_from_string(str8_struct(&process)); - U64 process_slot_idx = process_hash%cache->slots_count; - U64 process_stripe_idx = process_slot_idx%cache->stripes_count; - CTRL_ProcessMemoryCacheSlot *process_slot = &cache->slots[process_slot_idx]; - CTRL_ProcessMemoryCacheStripe *process_stripe = &cache->stripes[process_stripe_idx]; - - //- rjf: unpack address range hash cache key - U64 range_hash = ctrl_hash_from_string(str8_struct(&vaddr_range)); - - //- rjf: take task - B32 got_task = 0; - U64 preexisting_mem_gen = 0; - U128 preexisting_hash = {0}; - Rng1U64 vaddr_range_clamped = {0}; - OS_MutexScopeW(process_stripe->rw_mutex) + for(CTRL_ProcessMemoryCacheNode *n = process_slot->first; n != 0; n = n->next) { - for(CTRL_ProcessMemoryCacheNode *n = process_slot->first; n != 0; n = n->next) + if(ctrl_handle_match(n->handle, process)) { - if(ctrl_handle_match(n->handle, process)) + U64 range_slot_idx = range_hash%n->range_hash_slots_count; + CTRL_ProcessMemoryRangeHashSlot *range_slot = &n->range_hash_slots[range_slot_idx]; + for(CTRL_ProcessMemoryRangeHashNode *range_n = range_slot->first; range_n != 0; range_n = range_n->next) { - U64 range_slot_idx = range_hash%n->range_hash_slots_count; - CTRL_ProcessMemoryRangeHashSlot *range_slot = &n->range_hash_slots[range_slot_idx]; - for(CTRL_ProcessMemoryRangeHashNode *range_n = range_slot->first; range_n != 0; range_n = range_n->next) + if(MemoryMatchStruct(&range_n->vaddr_range, &vaddr_range) && range_n->zero_terminated == zero_terminated) { - if(MemoryMatchStruct(&range_n->vaddr_range, &vaddr_range) && range_n->zero_terminated == zero_terminated) - { - got_task = !ins_atomic_u32_eval_cond_assign(&range_n->is_taken, 1, 0); - preexisting_mem_gen = range_n->mem_gen; - preexisting_hash = range_n->hash; - vaddr_range_clamped = range_n->vaddr_range_clamped; - goto take_task__break_all; - } + got_task = !ins_atomic_u32_eval_cond_assign(&range_n->is_taken, 1, 0); + preexisting_mem_gen = range_n->mem_gen; + preexisting_hash = range_n->hash; + vaddr_range_clamped = range_n->vaddr_range_clamped; + goto take_task__break_all; } } } - take_task__break_all:; } - - //- rjf: task was taken -> read memory - U64 range_size = 0; - Arena *range_arena = 0; - void *range_base = 0; - U64 zero_terminated_size = 0; - U64 pre_read_mem_gen = dmn_mem_gen(); - U64 post_read_mem_gen = 0; - if(got_task && pre_read_mem_gen != preexisting_mem_gen) + take_task__break_all:; + } + + //- rjf: task was taken -> read memory + U64 range_size = 0; + Arena *range_arena = 0; + void *range_base = 0; + U64 zero_terminated_size = 0; + U64 pre_read_mem_gen = dmn_mem_gen(); + U64 post_read_mem_gen = 0; + if(got_task && pre_read_mem_gen != preexisting_mem_gen) + { + range_size = dim_1u64(vaddr_range_clamped); + U64 page_size = os_get_system_info()->page_size; + U64 arena_size = AlignPow2(range_size + ARENA_HEADER_SIZE, page_size); + range_arena = arena_alloc(.reserve_size = range_size+ARENA_HEADER_SIZE, .commit_size = range_size+ARENA_HEADER_SIZE); + if(range_arena == 0) { - range_size = dim_1u64(vaddr_range_clamped); - U64 page_size = os_get_system_info()->page_size; - U64 arena_size = AlignPow2(range_size + ARENA_HEADER_SIZE, page_size); - range_arena = arena_alloc(.reserve_size = range_size+ARENA_HEADER_SIZE, .commit_size = range_size+ARENA_HEADER_SIZE); - if(range_arena == 0) + range_size = 0; + } + else + { + range_base = push_array_no_zero(range_arena, U8, range_size); + U64 bytes_read = 0; + U64 retry_count = 0; + U64 retry_limit = range_size > page_size ? 64 : 0; + for(Rng1U64 vaddr_range_clamped_retry = vaddr_range_clamped; + retry_count <= retry_limit; + retry_count += 1) { - range_size = 0; - } - else - { - range_base = push_array_no_zero(range_arena, U8, range_size); - U64 bytes_read = 0; - U64 retry_count = 0; - U64 retry_limit = range_size > page_size ? 64 : 0; - for(Rng1U64 vaddr_range_clamped_retry = vaddr_range_clamped; - retry_count <= retry_limit; - retry_count += 1) + bytes_read = dmn_process_read(process.dmn_handle, vaddr_range_clamped_retry, range_base); + if(bytes_read == 0 && vaddr_range_clamped_retry.max > vaddr_range_clamped_retry.min) { - bytes_read = dmn_process_read(process.dmn_handle, vaddr_range_clamped_retry, range_base); - if(bytes_read == 0 && vaddr_range_clamped_retry.max > vaddr_range_clamped_retry.min) - { - U64 diff = (vaddr_range_clamped_retry.max-vaddr_range_clamped_retry.min)/2; - vaddr_range_clamped_retry.max -= diff; - vaddr_range_clamped_retry.max = AlignDownPow2(vaddr_range_clamped_retry.max, page_size); - if(diff == 0) - { - break; - } - } - else + U64 diff = (vaddr_range_clamped_retry.max-vaddr_range_clamped_retry.min)/2; + vaddr_range_clamped_retry.max -= diff; + vaddr_range_clamped_retry.max = AlignDownPow2(vaddr_range_clamped_retry.max, page_size); + if(diff == 0) { break; } } - if(bytes_read == 0) + else { - arena_release(range_arena); - range_base = 0; - range_size = 0; - range_arena = 0; - } - else if(bytes_read < range_size) - { - MemoryZero((U8 *)range_base + bytes_read, range_size-bytes_read); - } - zero_terminated_size = range_size; - if(zero_terminated) - { - for(U64 idx = 0; idx < bytes_read; idx += 1) - { - if(((U8 *)range_base)[idx] == 0) - { - zero_terminated_size = idx; - break; - } - } + break; } } - post_read_mem_gen = dmn_mem_gen(); - } - - //- rjf: read successful -> submit to hash store - U128 hash = {0}; - if(got_task && range_base != 0 && pre_read_mem_gen == post_read_mem_gen) - { - hash = hs_submit_data(key, &range_arena, str8((U8*)range_base, zero_terminated_size)); - } - else if(range_arena != 0) - { - arena_release(range_arena); - } - - //- rjf: commit hash to cache - if(got_task) OS_MutexScopeW(process_stripe->rw_mutex) - { - for(CTRL_ProcessMemoryCacheNode *n = process_slot->first; n != 0; n = n->next) + if(bytes_read == 0) { - if(ctrl_handle_match(n->handle, process)) + arena_release(range_arena); + range_base = 0; + range_size = 0; + range_arena = 0; + } + else if(bytes_read < range_size) + { + MemoryZero((U8 *)range_base + bytes_read, range_size-bytes_read); + } + zero_terminated_size = range_size; + if(zero_terminated) + { + for(U64 idx = 0; idx < bytes_read; idx += 1) { - U64 range_slot_idx = range_hash%n->range_hash_slots_count; - CTRL_ProcessMemoryRangeHashSlot *range_slot = &n->range_hash_slots[range_slot_idx]; - for(CTRL_ProcessMemoryRangeHashNode *range_n = range_slot->first; range_n != 0; range_n = range_n->next) + if(((U8 *)range_base)[idx] == 0) { - if(MemoryMatchStruct(&range_n->vaddr_range, &vaddr_range) && range_n->zero_terminated == zero_terminated) - { - if(!u128_match(u128_zero(), hash)) - { - range_n->hash = hash; - range_n->mem_gen = post_read_mem_gen; - } - ins_atomic_u32_eval_assign(&range_n->is_taken, 0); - goto commit__break_all; - } + zero_terminated_size = idx; + break; } } } - commit__break_all:; } - - //- rjf: broadcast changes - os_condition_variable_broadcast(process_stripe->cv); - ProfEnd(); + post_read_mem_gen = dmn_mem_gen(); } + + //- rjf: read successful -> submit to hash store + U128 hash = {0}; + if(got_task && range_base != 0 && pre_read_mem_gen == post_read_mem_gen) + { + hash = hs_submit_data(key, &range_arena, str8((U8*)range_base, zero_terminated_size)); + } + else if(range_arena != 0) + { + arena_release(range_arena); + } + + //- rjf: commit hash to cache + if(got_task) OS_MutexScopeW(process_stripe->rw_mutex) + { + for(CTRL_ProcessMemoryCacheNode *n = process_slot->first; n != 0; n = n->next) + { + if(ctrl_handle_match(n->handle, process)) + { + U64 range_slot_idx = range_hash%n->range_hash_slots_count; + CTRL_ProcessMemoryRangeHashSlot *range_slot = &n->range_hash_slots[range_slot_idx]; + for(CTRL_ProcessMemoryRangeHashNode *range_n = range_slot->first; range_n != 0; range_n = range_n->next) + { + if(MemoryMatchStruct(&range_n->vaddr_range, &vaddr_range) && range_n->zero_terminated == zero_terminated) + { + if(!u128_match(u128_zero(), hash)) + { + range_n->hash = hash; + range_n->mem_gen = post_read_mem_gen; + } + ins_atomic_u32_eval_assign(&range_n->is_taken, 0); + goto commit__break_all; + } + } + } + } + commit__break_all:; + } + + //- rjf: broadcast changes + os_condition_variable_broadcast(process_stripe->cv); + ProfEnd(); + return 0; } diff --git a/src/ctrl/ctrl_core.h b/src/ctrl/ctrl_core.h index adc93c76..47c0078d 100644 --- a/src/ctrl/ctrl_core.h +++ b/src/ctrl/ctrl_core.h @@ -888,10 +888,6 @@ struct CTRL_State U64 u2ms_ring_read_pos; OS_Handle u2ms_ring_mutex; OS_Handle u2ms_ring_cv; - - // rjf: memory stream threads - U64 ms_thread_count; - OS_Handle *ms_threads; }; //////////////////////////////// @@ -1156,6 +1152,7 @@ internal B32 ctrl_u2ms_enqueue_req(CTRL_Handle process, Rng1U64 vaddr_range, B32 internal void ctrl_u2ms_dequeue_req(CTRL_Handle *out_process, Rng1U64 *out_vaddr_range, B32 *out_zero_terminated); //- rjf: entry point +ASYNC_WORK_DEF(ctrl_mem_stream_work); internal void ctrl_mem_stream_thread__entry_point(void *p); #endif // CTRL_CORE_H diff --git a/src/dasm_cache/dasm_cache.c b/src/dasm_cache/dasm_cache.c index f0c6a411..156678d5 100644 --- a/src/dasm_cache/dasm_cache.c +++ b/src/dasm_cache/dasm_cache.c @@ -274,12 +274,6 @@ dasm_init(void) dasm_shared->u2p_ring_base = push_array_no_zero(arena, U8, dasm_shared->u2p_ring_size); dasm_shared->u2p_ring_cv = os_condition_variable_alloc(); dasm_shared->u2p_ring_mutex = os_mutex_alloc(); - dasm_shared->parse_thread_count = 1; - dasm_shared->parse_threads = push_array(arena, OS_Handle, dasm_shared->parse_thread_count); - for(U64 idx = 0; idx < dasm_shared->parse_thread_count; idx += 1) - { - dasm_shared->parse_threads[idx] = os_thread_launch(dasm_parse_thread__entry_point, (void *)idx, 0); - } dasm_shared->evictor_detector_thread = os_thread_launch(dasm_evictor_detector_thread__entry_point, 0, 0); } @@ -430,6 +424,7 @@ dasm_info_from_hash_params(DASM_Scope *scope, U128 hash, DASM_Params *params) if(node_is_new) { dasm_u2p_enqueue_req(hash, params, max_U64); + async_push_work(dasm_parse_work); } } return info; @@ -522,284 +517,280 @@ dasm_u2p_dequeue_req(Arena *arena, U128 *hash_out, DASM_Params *params_out) os_condition_variable_broadcast(dasm_shared->u2p_ring_cv); } -internal void -dasm_parse_thread__entry_point(void *p) +ASYNC_WORK_DEF(dasm_parse_work) { - ThreadNameF("[dasm] parse thread #%I64u", (U64)p); - for(;;) + Temp scratch = scratch_begin(0, 0); + HS_Scope *hs_scope = hs_scope_open(); + DI_Scope *di_scope = di_scope_open(); + TXT_Scope *txt_scope = txt_scope_open(); + + //- rjf: get next request + U128 hash = {0}; + DASM_Params params = {0}; + dasm_u2p_dequeue_req(scratch.arena, &hash, ¶ms); + U64 change_gen = fs_change_gen(); + + //- rjf: unpack hash + U64 slot_idx = hash.u64[1]%dasm_shared->slots_count; + U64 stripe_idx = slot_idx%dasm_shared->stripes_count; + DASM_Slot *slot = &dasm_shared->slots[slot_idx]; + DASM_Stripe *stripe = &dasm_shared->stripes[stripe_idx]; + + //- rjf: take task + B32 got_task = 0; + OS_MutexScopeR(stripe->rw_mutex) { - Temp scratch = scratch_begin(0, 0); - HS_Scope *hs_scope = hs_scope_open(); - DI_Scope *di_scope = di_scope_open(); - TXT_Scope *txt_scope = txt_scope_open(); - - //- rjf: get next request - U128 hash = {0}; - DASM_Params params = {0}; - dasm_u2p_dequeue_req(scratch.arena, &hash, ¶ms); - U64 change_gen = fs_change_gen(); - - //- rjf: unpack hash - U64 slot_idx = hash.u64[1]%dasm_shared->slots_count; - U64 stripe_idx = slot_idx%dasm_shared->stripes_count; - DASM_Slot *slot = &dasm_shared->slots[slot_idx]; - DASM_Stripe *stripe = &dasm_shared->stripes[stripe_idx]; - - //- rjf: take task - B32 got_task = 0; - OS_MutexScopeR(stripe->rw_mutex) + for(DASM_Node *n = slot->first; n != 0; n = n->next) { - for(DASM_Node *n = slot->first; n != 0; n = n->next) + if(u128_match(n->hash, hash) && dasm_params_match(&n->params, ¶ms)) { - if(u128_match(n->hash, hash) && dasm_params_match(&n->params, ¶ms)) - { - got_task = !ins_atomic_u32_eval_cond_assign(&n->is_working, 1, 0); - break; - } + got_task = !ins_atomic_u32_eval_cond_assign(&n->is_working, 1, 0); + break; } } - - //- rjf: get dbg info - RDI_Parsed *rdi = &di_rdi_parsed_nil; - if(got_task && params.dbgi_key.path.size != 0) - { - rdi = di_rdi_from_key(di_scope, ¶ms.dbgi_key, max_U64); - } - - //- rjf: hash -> data - String8 data = {0}; - if(got_task) - { - data = hs_data_from_hash(hs_scope, hash); - } - - //- rjf: data * arch * addr * dbg -> decode artifacts - DASM_LineChunkList line_list = {0}; - String8List inst_strings = {0}; - if(got_task) - { - switch(params.arch) - { - default:{}break; - - //- rjf: x86/x64 decoding - case Arch_x64: - case Arch_x86: - { - // rjf: disassemble - RDI_SourceFile *last_file = &rdi_nil_element_union.source_file; - RDI_Line *last_line = 0; - for(U64 off = 0; off < data.size;) - { - // rjf: disassemble one instruction - DASM_Inst inst = dasm_inst_from_code(scratch.arena, params.arch, params.vaddr+off, str8_skip(data, off), params.syntax); - if(inst.size == 0) - { - break; - } - - // rjf: push strings derived from voff -> line info - if(params.style_flags & (DASM_StyleFlag_SourceFilesNames|DASM_StyleFlag_SourceLines)) - { - if(rdi != &di_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); - RDI_Unit *unit = rdi_element_from_name_idx(rdi, Units, unit_idx); - RDI_LineTable *line_table = rdi_element_from_name_idx(rdi, LineTables, unit->line_table_idx); - RDI_ParsedLineTable unit_line_info = {0}; - rdi_parsed_from_line_table(rdi, line_table, &unit_line_info); - U64 line_info_idx = rdi_line_info_idx_from_voff(&unit_line_info, voff); - if(line_info_idx < unit_line_info.count) - { - RDI_Line *line = &unit_line_info.lines[line_info_idx]; - RDI_SourceFile *file = rdi_element_from_name_idx(rdi, SourceFiles, line->file_idx); - String8 file_normalized_full_path = {0}; - file_normalized_full_path.str = rdi_string_from_idx(rdi, file->normal_full_path_string_idx, &file_normalized_full_path.size); - if(file != last_file) - { - if(params.style_flags & DASM_StyleFlag_SourceFilesNames && - file->normal_full_path_string_idx != 0 && file_normalized_full_path.size != 0) - { - String8 inst_string = push_str8f(scratch.arena, "> %S", file_normalized_full_path); - DASM_Line inst = {u32_from_u64_saturate(off), DASM_LineFlag_Decorative, 0, r1u64(inst_strings.total_size + inst_strings.node_count, - inst_strings.total_size + inst_strings.node_count + inst_string.size)}; - dasm_line_chunk_list_push(scratch.arena, &line_list, 1024, &inst); - str8_list_push(scratch.arena, &inst_strings, inst_string); - } - if(params.style_flags & DASM_StyleFlag_SourceFilesNames && file->normal_full_path_string_idx == 0) - { - String8 inst_string = str8_lit(">"); - DASM_Line inst = {u32_from_u64_saturate(off), DASM_LineFlag_Decorative, 0, r1u64(inst_strings.total_size + inst_strings.node_count, - inst_strings.total_size + inst_strings.node_count + inst_string.size)}; - dasm_line_chunk_list_push(scratch.arena, &line_list, 1024, &inst); - str8_list_push(scratch.arena, &inst_strings, inst_string); - } - last_file = file; - } - if(line && line != last_line && file->normal_full_path_string_idx != 0 && - params.style_flags & DASM_StyleFlag_SourceLines && - file_normalized_full_path.size != 0) - { - FileProperties props = os_properties_from_file_path(file_normalized_full_path); - if(props.modified != 0) - { - // TODO(rjf): need redirection path - this may map to a different path on the local machine, - // need frontend to communicate path remapping info to this layer - U128 key = fs_key_from_path_range(file_normalized_full_path, r1u64(0, max_U64)); - TXT_LangKind lang_kind = txt_lang_kind_from_extension(file_normalized_full_path); - U64 endt_us = max_U64; - U128 hash = {0}; - TXT_TextInfo text_info = {0}; - for(;os_now_microseconds() <= endt_us;) - { - text_info = txt_text_info_from_key_lang(txt_scope, key, lang_kind, &hash); - if(!u128_match(hash, u128_zero())) - { - break; - } - } - if(0 < line->line_num && line->line_num < text_info.lines_count) - { - String8 data = hs_data_from_hash(hs_scope, hash); - String8 line_text = str8_skip_chop_whitespace(str8_substr(data, text_info.lines_ranges[line->line_num-1])); - if(line_text.size != 0) - { - String8 inst_string = push_str8f(scratch.arena, "> %S", line_text); - DASM_Line inst = {u32_from_u64_saturate(off), DASM_LineFlag_Decorative, 0, r1u64(inst_strings.total_size + inst_strings.node_count, - inst_strings.total_size + inst_strings.node_count + inst_string.size)}; - dasm_line_chunk_list_push(scratch.arena, &line_list, 1024, &inst); - str8_list_push(scratch.arena, &inst_strings, inst_string); - } - } - } - last_line = line; - } - } - } - } - - // rjf: push line - 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); - } - String8 code_bytes_part = {0}; - if(params.style_flags & DASM_StyleFlag_CodeBytes) - { - String8List code_bytes_strings = {0}; - str8_list_push(scratch.arena, &code_bytes_strings, str8_lit("{")); - for(U64 byte_idx = 0; byte_idx < inst.size || byte_idx < 16; byte_idx += 1) - { - if(byte_idx < inst.size) - { - str8_list_pushf(scratch.arena, &code_bytes_strings, "%02x%s ", (U32)data.str[off+byte_idx], byte_idx == inst.size-1 ? "}" : ""); - } - else if(byte_idx < 8) - { - str8_list_push(scratch.arena, &code_bytes_strings, str8_lit(" ")); - } - } - str8_list_push(scratch.arena, &code_bytes_strings, str8_lit(" ")); - 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) - { - 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) - { - RDI_Scope *scope = rdi_element_from_name_idx(rdi, Scopes, scope_idx); - RDI_U32 procedure_idx = scope->proc_idx; - RDI_Procedure *procedure = rdi_element_from_name_idx(rdi, Procedures, procedure_idx); - String8 procedure_name = {0}; - procedure_name.str = rdi_string_from_idx(rdi, procedure->name_string_idx, &procedure_name.size); - if(procedure_name.size != 0) - { - symbol_part = push_str8f(scratch.arena, " (%S)", procedure_name); - } - } - } - String8 inst_string = push_str8f(scratch.arena, "%S%S%S%S", addr_part, code_bytes_part, inst.string, symbol_part); - DASM_Line line = {u32_from_u64_saturate(off), 0, inst.jump_dest_vaddr, r1u64(inst_strings.total_size + inst_strings.node_count, - inst_strings.total_size + inst_strings.node_count + inst_string.size)}; - dasm_line_chunk_list_push(scratch.arena, &line_list, 1024, &line); - str8_list_push(scratch.arena, &inst_strings, inst_string); - - // rjf: increment - off += inst.size; - } - }break; - } - } - - //- rjf: artifacts -> value bundle - Arena *info_arena = 0; - DASM_Info info = {0}; - if(got_task) - { - //- rjf: produce joined text - Arena *text_arena = arena_alloc(); - StringJoin text_join = {0}; - text_join.sep = str8_lit("\n"); - String8 text = str8_list_join(text_arena, &inst_strings, &text_join); - - //- rjf: produce unique key for this disassembly's text - U128 text_key = {0}; - { - U64 hash_data[] = - { - hash.u64[0], - hash.u64[1], - params.vaddr, - (U64)params.arch, - (U64)params.style_flags, - (U64)params.syntax, - (U64)rdi, - 0x4d534144, - }; - text_key = hs_hash_from_data(str8((U8 *)hash_data, sizeof(hash_data))); - } - - //- rjf: submit text data to hash store - U128 text_hash = hs_submit_data(text_key, &text_arena, text); - - //- rjf: produce value bundle - info_arena = arena_alloc(); - info.text_key = text_key; - info.lines = dasm_line_array_from_chunk_list(info_arena, &line_list); - } - - //- rjf: commit results to cache - if(got_task) OS_MutexScopeW(stripe->rw_mutex) - { - for(DASM_Node *n = slot->first; n != 0; n = n->next) - { - if(u128_match(n->hash, hash) && dasm_params_match(&n->params, ¶ms)) - { - n->info_arena = info_arena; - MemoryCopyStruct(&n->info, &info); - if(rdi != &di_rdi_parsed_nil && params.style_flags & (DASM_StyleFlag_SourceLines|DASM_StyleFlag_SourceFilesNames)) - { - n->change_gen = change_gen; - } - else - { - n->change_gen = 0; - } - ins_atomic_u32_eval_assign(&n->is_working, 0); - ins_atomic_u64_inc_eval(&n->load_count); - break; - } - } - } - - txt_scope_close(txt_scope); - di_scope_close(di_scope); - hs_scope_close(hs_scope); - scratch_end(scratch); } + + //- rjf: get dbg info + RDI_Parsed *rdi = &di_rdi_parsed_nil; + if(got_task && params.dbgi_key.path.size != 0) + { + rdi = di_rdi_from_key(di_scope, ¶ms.dbgi_key, max_U64); + } + + //- rjf: hash -> data + String8 data = {0}; + if(got_task) + { + data = hs_data_from_hash(hs_scope, hash); + } + + //- rjf: data * arch * addr * dbg -> decode artifacts + DASM_LineChunkList line_list = {0}; + String8List inst_strings = {0}; + if(got_task) + { + switch(params.arch) + { + default:{}break; + + //- rjf: x86/x64 decoding + case Arch_x64: + case Arch_x86: + { + // rjf: disassemble + RDI_SourceFile *last_file = &rdi_nil_element_union.source_file; + RDI_Line *last_line = 0; + for(U64 off = 0; off < data.size;) + { + // rjf: disassemble one instruction + DASM_Inst inst = dasm_inst_from_code(scratch.arena, params.arch, params.vaddr+off, str8_skip(data, off), params.syntax); + if(inst.size == 0) + { + break; + } + + // rjf: push strings derived from voff -> line info + if(params.style_flags & (DASM_StyleFlag_SourceFilesNames|DASM_StyleFlag_SourceLines)) + { + if(rdi != &di_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); + RDI_Unit *unit = rdi_element_from_name_idx(rdi, Units, unit_idx); + RDI_LineTable *line_table = rdi_element_from_name_idx(rdi, LineTables, unit->line_table_idx); + RDI_ParsedLineTable unit_line_info = {0}; + rdi_parsed_from_line_table(rdi, line_table, &unit_line_info); + U64 line_info_idx = rdi_line_info_idx_from_voff(&unit_line_info, voff); + if(line_info_idx < unit_line_info.count) + { + RDI_Line *line = &unit_line_info.lines[line_info_idx]; + RDI_SourceFile *file = rdi_element_from_name_idx(rdi, SourceFiles, line->file_idx); + String8 file_normalized_full_path = {0}; + file_normalized_full_path.str = rdi_string_from_idx(rdi, file->normal_full_path_string_idx, &file_normalized_full_path.size); + if(file != last_file) + { + if(params.style_flags & DASM_StyleFlag_SourceFilesNames && + file->normal_full_path_string_idx != 0 && file_normalized_full_path.size != 0) + { + String8 inst_string = push_str8f(scratch.arena, "> %S", file_normalized_full_path); + DASM_Line inst = {u32_from_u64_saturate(off), DASM_LineFlag_Decorative, 0, r1u64(inst_strings.total_size + inst_strings.node_count, + inst_strings.total_size + inst_strings.node_count + inst_string.size)}; + dasm_line_chunk_list_push(scratch.arena, &line_list, 1024, &inst); + str8_list_push(scratch.arena, &inst_strings, inst_string); + } + if(params.style_flags & DASM_StyleFlag_SourceFilesNames && file->normal_full_path_string_idx == 0) + { + String8 inst_string = str8_lit(">"); + DASM_Line inst = {u32_from_u64_saturate(off), DASM_LineFlag_Decorative, 0, r1u64(inst_strings.total_size + inst_strings.node_count, + inst_strings.total_size + inst_strings.node_count + inst_string.size)}; + dasm_line_chunk_list_push(scratch.arena, &line_list, 1024, &inst); + str8_list_push(scratch.arena, &inst_strings, inst_string); + } + last_file = file; + } + if(line && line != last_line && file->normal_full_path_string_idx != 0 && + params.style_flags & DASM_StyleFlag_SourceLines && + file_normalized_full_path.size != 0) + { + FileProperties props = os_properties_from_file_path(file_normalized_full_path); + if(props.modified != 0) + { + // TODO(rjf): need redirection path - this may map to a different path on the local machine, + // need frontend to communicate path remapping info to this layer + U128 key = fs_key_from_path_range(file_normalized_full_path, r1u64(0, max_U64)); + TXT_LangKind lang_kind = txt_lang_kind_from_extension(file_normalized_full_path); + U64 endt_us = max_U64; + U128 hash = {0}; + TXT_TextInfo text_info = {0}; + for(;os_now_microseconds() <= endt_us;) + { + text_info = txt_text_info_from_key_lang(txt_scope, key, lang_kind, &hash); + if(!u128_match(hash, u128_zero())) + { + break; + } + } + if(0 < line->line_num && line->line_num < text_info.lines_count) + { + String8 data = hs_data_from_hash(hs_scope, hash); + String8 line_text = str8_skip_chop_whitespace(str8_substr(data, text_info.lines_ranges[line->line_num-1])); + if(line_text.size != 0) + { + String8 inst_string = push_str8f(scratch.arena, "> %S", line_text); + DASM_Line inst = {u32_from_u64_saturate(off), DASM_LineFlag_Decorative, 0, r1u64(inst_strings.total_size + inst_strings.node_count, + inst_strings.total_size + inst_strings.node_count + inst_string.size)}; + dasm_line_chunk_list_push(scratch.arena, &line_list, 1024, &inst); + str8_list_push(scratch.arena, &inst_strings, inst_string); + } + } + } + last_line = line; + } + } + } + } + + // rjf: push line + 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); + } + String8 code_bytes_part = {0}; + if(params.style_flags & DASM_StyleFlag_CodeBytes) + { + String8List code_bytes_strings = {0}; + str8_list_push(scratch.arena, &code_bytes_strings, str8_lit("{")); + for(U64 byte_idx = 0; byte_idx < inst.size || byte_idx < 16; byte_idx += 1) + { + if(byte_idx < inst.size) + { + str8_list_pushf(scratch.arena, &code_bytes_strings, "%02x%s ", (U32)data.str[off+byte_idx], byte_idx == inst.size-1 ? "}" : ""); + } + else if(byte_idx < 8) + { + str8_list_push(scratch.arena, &code_bytes_strings, str8_lit(" ")); + } + } + str8_list_push(scratch.arena, &code_bytes_strings, str8_lit(" ")); + 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) + { + 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) + { + RDI_Scope *scope = rdi_element_from_name_idx(rdi, Scopes, scope_idx); + RDI_U32 procedure_idx = scope->proc_idx; + RDI_Procedure *procedure = rdi_element_from_name_idx(rdi, Procedures, procedure_idx); + String8 procedure_name = {0}; + procedure_name.str = rdi_string_from_idx(rdi, procedure->name_string_idx, &procedure_name.size); + if(procedure_name.size != 0) + { + symbol_part = push_str8f(scratch.arena, " (%S)", procedure_name); + } + } + } + String8 inst_string = push_str8f(scratch.arena, "%S%S%S%S", addr_part, code_bytes_part, inst.string, symbol_part); + DASM_Line line = {u32_from_u64_saturate(off), 0, inst.jump_dest_vaddr, r1u64(inst_strings.total_size + inst_strings.node_count, + inst_strings.total_size + inst_strings.node_count + inst_string.size)}; + dasm_line_chunk_list_push(scratch.arena, &line_list, 1024, &line); + str8_list_push(scratch.arena, &inst_strings, inst_string); + + // rjf: increment + off += inst.size; + } + }break; + } + } + + //- rjf: artifacts -> value bundle + Arena *info_arena = 0; + DASM_Info info = {0}; + if(got_task) + { + //- rjf: produce joined text + Arena *text_arena = arena_alloc(); + StringJoin text_join = {0}; + text_join.sep = str8_lit("\n"); + String8 text = str8_list_join(text_arena, &inst_strings, &text_join); + + //- rjf: produce unique key for this disassembly's text + U128 text_key = {0}; + { + U64 hash_data[] = + { + hash.u64[0], + hash.u64[1], + params.vaddr, + (U64)params.arch, + (U64)params.style_flags, + (U64)params.syntax, + (U64)rdi, + 0x4d534144, + }; + text_key = hs_hash_from_data(str8((U8 *)hash_data, sizeof(hash_data))); + } + + //- rjf: submit text data to hash store + U128 text_hash = hs_submit_data(text_key, &text_arena, text); + + //- rjf: produce value bundle + info_arena = arena_alloc(); + info.text_key = text_key; + info.lines = dasm_line_array_from_chunk_list(info_arena, &line_list); + } + + //- rjf: commit results to cache + if(got_task) OS_MutexScopeW(stripe->rw_mutex) + { + for(DASM_Node *n = slot->first; n != 0; n = n->next) + { + if(u128_match(n->hash, hash) && dasm_params_match(&n->params, ¶ms)) + { + n->info_arena = info_arena; + MemoryCopyStruct(&n->info, &info); + if(rdi != &di_rdi_parsed_nil && params.style_flags & (DASM_StyleFlag_SourceLines|DASM_StyleFlag_SourceFilesNames)) + { + n->change_gen = change_gen; + } + else + { + n->change_gen = 0; + } + ins_atomic_u32_eval_assign(&n->is_working, 0); + ins_atomic_u64_inc_eval(&n->load_count); + break; + } + } + } + + txt_scope_close(txt_scope); + di_scope_close(di_scope); + hs_scope_close(hs_scope); + scratch_end(scratch); + return 0; } //////////////////////////////// @@ -870,6 +861,7 @@ dasm_evictor_detector_thread__entry_point(void *p) { if(dasm_u2p_enqueue_req(n->hash, &n->params, max_U64)) { + async_push_work(dasm_parse_work); n->last_time_requested_us = os_now_microseconds(); n->last_user_clock_idx_requested = check_time_user_clocks; } diff --git a/src/dasm_cache/dasm_cache.h b/src/dasm_cache/dasm_cache.h index 5ca4c1ee..5ce7ea00 100644 --- a/src/dasm_cache/dasm_cache.h +++ b/src/dasm_cache/dasm_cache.h @@ -263,10 +263,6 @@ struct DASM_Shared OS_Handle u2p_ring_cv; OS_Handle u2p_ring_mutex; - // rjf: parse threads - U64 parse_thread_count; - OS_Handle *parse_threads; - // rjf: evictor/detector thread OS_Handle evictor_detector_thread; }; @@ -329,7 +325,7 @@ internal DASM_Info dasm_info_from_key_params(DASM_Scope *scope, U128 key, DASM_P internal B32 dasm_u2p_enqueue_req(U128 hash, DASM_Params *params, U64 endt_us); internal void dasm_u2p_dequeue_req(Arena *arena, U128 *hash_out, DASM_Params *params_out); -internal void dasm_parse_thread__entry_point(void *p); +ASYNC_WORK_DEF(dasm_parse_work); //////////////////////////////// //~ rjf: Evictor/Detector Thread diff --git a/src/dbgi/dbgi.c b/src/dbgi/dbgi.c index 1a2c5343..496b13e7 100644 --- a/src/dbgi/dbgi.c +++ b/src/dbgi/dbgi.c @@ -878,309 +878,3 @@ ASYNC_WORK_DEF(di_parse_work) scratch_end(scratch); return 0; } - -internal void -di_parse_thread__entry_point(void *p) -{ - ThreadNameF("[di] parse #%I64u", (U64)p); - for(;;) - { - Temp scratch = scratch_begin(0, 0); - - //////////////////////////// - //- rjf: grab next key - // - DI_Key key = {0}; - di_u2p_dequeue_key(scratch.arena, &key); - String8 og_path = key.path; - U64 min_timestamp = key.min_timestamp; - - //////////////////////////// - //- rjf: unpack key - // - U64 hash = di_hash_from_string(og_path, StringMatchFlag_CaseInsensitive); - U64 slot_idx = hash%di_shared->slots_count; - U64 stripe_idx = slot_idx%di_shared->stripes_count; - DI_Slot *slot = &di_shared->slots[slot_idx]; - DI_Stripe *stripe = &di_shared->stripes[stripe_idx]; - - //////////////////////////// - //- rjf: take task - // - B32 got_task = 0; - OS_MutexScopeR(stripe->rw_mutex) - { - DI_Node *node = di_node_from_key_slot__stripe_mutex_r_guarded(slot, &key); - if(node != 0) - { - got_task = !ins_atomic_u64_eval_cond_assign(&node->is_working, 1, 0); - } - } - - //////////////////////////// - //- rjf: got task -> open O.G. file (may or may not be RDI) - // - B32 og_format_is_known = 0; - B32 og_is_pe = 0; - B32 og_is_pdb = 0; - B32 og_is_elf = 0; - B32 og_is_rdi = 0; - FileProperties og_props = {0}; - if(got_task) ProfScope("analyze %.*s", str8_varg(og_path)) - { - OS_Handle file = os_file_open(OS_AccessFlag_Read|OS_AccessFlag_ShareRead, og_path); - OS_Handle file_map = os_file_map_open(OS_AccessFlag_Read, file); - FileProperties props = og_props = os_properties_from_file(file); - void *base = os_file_map_view_open(file_map, OS_AccessFlag_Read, r1u64(0, props.size)); - String8 data = str8((U8 *)base, props.size); - if(!og_format_is_known) - { - String8 msf20_magic = str8_lit("Microsoft C/C++ program database 2.00\r\n\x1aJG\0\0"); - String8 msf70_magic = str8_lit("Microsoft C/C++ MSF 7.00\r\n\032DS\0\0"); - String8 msfxx_magic = str8_lit("Microsoft C/C++"); - if((data.size >= msf20_magic.size && str8_match(data, msf20_magic, StringMatchFlag_RightSideSloppy)) || - (data.size >= msf70_magic.size && str8_match(data, msf70_magic, StringMatchFlag_RightSideSloppy)) || - (data.size >= msfxx_magic.size && str8_match(data, msfxx_magic, StringMatchFlag_RightSideSloppy))) - { - og_format_is_known = 1; - og_is_pdb = 1; - } - } - if(!og_format_is_known) - { - if(data.size >= 8 && *(U64 *)data.str == RDI_MAGIC_CONSTANT) - { - og_format_is_known = 1; - og_is_rdi = 1; - } - } - if(!og_format_is_known) - { - if(data.size >= 4 && - data.str[0] == 0x7f && - data.str[1] == 'E' && - data.str[2] == 'L' && - data.str[3] == 'F') - { - og_format_is_known = 1; - og_is_elf = 1; - } - } - if(!og_format_is_known) - { - if(data.size >= 2 && *(U16 *)data.str == 0x5a4d) - { - og_format_is_known = 1; - og_is_pe = 1; - } - } - os_file_map_view_close(file_map, base, r1u64(0, props.size)); - os_file_map_close(file_map); - os_file_close(file); - } - - //////////////////////////// - //- rjf: given O.G. path & analysis, determine RDI path - // - String8 rdi_path = {0}; - if(got_task) - { - if(og_is_rdi) - { - rdi_path = og_path; - } - else if(og_format_is_known && og_is_pdb) - { - rdi_path = push_str8f(scratch.arena, "%S.rdi", str8_chop_last_dot(og_path)); - } - } - - //////////////////////////// - //- rjf: check if rdi file is up-to-date - // - B32 rdi_file_is_up_to_date = 0; - if(got_task) - { - if(rdi_path.size != 0) ProfScope("check %.*s is up-to-date", str8_varg(rdi_path)) - { - FileProperties props = os_properties_from_file_path(rdi_path); - rdi_file_is_up_to_date = (props.modified > og_props.modified); - } - } - - //////////////////////////// - //- rjf: if raddbg file is up to date based on timestamp, check the - // encoding generation number & size, to see if we need to regenerate it - // regardless - // - if(got_task && rdi_file_is_up_to_date) ProfScope("check %.*s version matches our's", str8_varg(rdi_path)) - { - OS_Handle file = {0}; - OS_Handle file_map = {0}; - FileProperties file_props = {0}; - void *file_base = 0; - file = os_file_open(OS_AccessFlag_Read|OS_AccessFlag_ShareRead, rdi_path); - file_map = os_file_map_open(OS_AccessFlag_Read, file); - file_props = os_properties_from_file(file); - file_base = os_file_map_view_open(file_map, OS_AccessFlag_Read, r1u64(0, file_props.size)); - if(sizeof(RDI_Header) <= file_props.size) - { - RDI_Header *header = (RDI_Header*)file_base; - if(header->encoding_version != RDI_ENCODING_VERSION) - { - rdi_file_is_up_to_date = 0; - } - } - else - { - rdi_file_is_up_to_date = 0; - } - os_file_map_view_close(file_map, file_base, r1u64(0, file_props.size)); - os_file_map_close(file_map); - os_file_close(file); - } - - //////////////////////////// - //- rjf: heuristically choose compression settings - // - B32 should_compress = 0; -#if 0 - if(og_dbg_props.size > MB(64)) - { - should_compress = 1; - } -#endif - - //////////////////////////// - //- rjf: rdi file not up-to-date? we need to generate it - // - if(got_task && !rdi_file_is_up_to_date) ProfScope("generate %.*s", str8_varg(rdi_path)) - { - if(og_is_pdb) - { - //- rjf: push conversion task begin event - { - DI_Event event = {DI_EventKind_ConversionStarted}; - event.string = rdi_path; - di_p2u_push_event(&event); - } - - //- rjf: kick off process - OS_Handle process = {0}; - { - OS_ProcessLaunchParams params = {0}; - params.path = os_get_process_info()->binary_path; - params.inherit_env = 1; - params.consoleless = 1; - str8_list_pushf(scratch.arena, ¶ms.cmd_line, "raddbg"); - str8_list_pushf(scratch.arena, ¶ms.cmd_line, "--convert"); - str8_list_pushf(scratch.arena, ¶ms.cmd_line, "--quiet"); - if(should_compress) - { - str8_list_pushf(scratch.arena, ¶ms.cmd_line, "--compress"); - } - // str8_list_pushf(scratch.arena, ¶ms.cmd_line, "--capture"); - str8_list_pushf(scratch.arena, ¶ms.cmd_line, "--pdb:%S", og_path); - str8_list_pushf(scratch.arena, ¶ms.cmd_line, "--out:%S", rdi_path); - process = os_process_launch(¶ms); - } - - //- rjf: wait for process to complete - { - U64 start_wait_t = os_now_microseconds(); - for(;;) - { - B32 wait_done = os_process_join(process, os_now_microseconds()+1000); - if(wait_done) - { - rdi_file_is_up_to_date = 1; - break; - } - } - } - - //- rjf: push conversion task end event - { - DI_Event event = {DI_EventKind_ConversionEnded}; - event.string = rdi_path; - di_p2u_push_event(&event); - } - } - else - { - // NOTE(rjf): we cannot convert from this O.G. debug info format right now. - //- rjf: push conversion task failure event - { - DI_Event event = {DI_EventKind_ConversionFailureUnsupportedFormat}; - event.string = rdi_path; - di_p2u_push_event(&event); - } - } - } - - //////////////////////////// - //- rjf: got task -> open file - // - OS_Handle file = {0}; - OS_Handle file_map = {0}; - FileProperties file_props = {0}; - void *file_base = 0; - if(got_task) - { - file = os_file_open(OS_AccessFlag_Read|OS_AccessFlag_ShareRead|OS_AccessFlag_ShareWrite, rdi_path); - file_map = os_file_map_open(OS_AccessFlag_Read, file); - file_props = os_properties_from_file(file); - file_base = os_file_map_view_open(file_map, OS_AccessFlag_Read, r1u64(0, file_props.size)); - } - - //////////////////////////// - //- rjf: do initial parse of rdi - // - RDI_Parsed rdi_parsed_maybe_compressed = di_rdi_parsed_nil; - if(got_task) - { - RDI_ParseStatus parse_status = rdi_parse((U8 *)file_base, file_props.size, &rdi_parsed_maybe_compressed); - (void)parse_status; - } - - //////////////////////////// - //- rjf: decompress & re-parse, if necessary - // - Arena *rdi_parsed_arena = 0; - RDI_Parsed rdi_parsed = rdi_parsed_maybe_compressed; - if(got_task) - { - U64 decompressed_size = rdi_decompressed_size_from_parsed(&rdi_parsed_maybe_compressed); - if(decompressed_size > file_props.size) - { - rdi_parsed_arena = arena_alloc(); - U8 *decompressed_data = push_array_no_zero(rdi_parsed_arena, U8, decompressed_size); - rdi_decompress_parsed(decompressed_data, decompressed_size, &rdi_parsed_maybe_compressed); - RDI_ParseStatus parse_status = rdi_parse(decompressed_data, decompressed_size, &rdi_parsed); - (void)parse_status; - } - } - - //////////////////////////// - //- rjf: commit parsed info to cache - // - if(got_task) OS_MutexScopeW(stripe->rw_mutex) - { - DI_Node *node = di_node_from_key_slot__stripe_mutex_r_guarded(slot, &key); - if(node != 0) - { - node->is_working = 0; - node->file = file; - node->file_map = file_map; - node->file_base = file_base; - node->file_props = file_props; - node->arena = rdi_parsed_arena; - node->rdi = rdi_parsed; - node->parse_done = 1; - } - } - os_condition_variable_broadcast(stripe->cv); - - scratch_end(scratch); - } -} diff --git a/src/dbgi/dbgi.h b/src/dbgi/dbgi.h index a2d2d64f..03ebb3d3 100644 --- a/src/dbgi/dbgi.h +++ b/src/dbgi/dbgi.h @@ -248,6 +248,5 @@ internal void di_p2u_push_event(DI_Event *event); internal DI_EventList di_p2u_pop_events(Arena *arena, U64 endt_us); ASYNC_WORK_DEF(di_parse_work); -internal void di_parse_thread__entry_point(void *p); #endif // DBGI_H diff --git a/src/file_stream/file_stream.c b/src/file_stream/file_stream.c index a9cfbe0c..3a128aa7 100644 --- a/src/file_stream/file_stream.c +++ b/src/file_stream/file_stream.c @@ -423,7 +423,7 @@ ASYNC_WORK_DEF(fs_stream_work) internal void fs_detector_thread__entry_point(void *p) { - ThreadNameF("[fs] detector"); + ThreadNameF("[fs] detector thread"); for(;;) { U64 slots_per_stripe = fs_shared->slots_count/fs_shared->stripes_count; diff --git a/src/hash_store/hash_store.c b/src/hash_store/hash_store.c index 5dadb646..c99f2eea 100644 --- a/src/hash_store/hash_store.c +++ b/src/hash_store/hash_store.c @@ -296,6 +296,7 @@ hs_data_from_hash(HS_Scope *scope, U128 hash) internal void hs_evictor_thread__entry_point(void *p) { + ThreadNameF("[hs] evictor thread"); for(;;) { for(U64 slot_idx = 0; slot_idx < hs_shared->slots_count; slot_idx += 1) diff --git a/src/text_cache/text_cache.c b/src/text_cache/text_cache.c index eee9c4f8..3501dab1 100644 --- a/src/text_cache/text_cache.c +++ b/src/text_cache/text_cache.c @@ -2347,6 +2347,7 @@ ASYNC_WORK_DEF(txt_parse_work) internal void txt_evictor_thread__entry_point(void *p) { + ThreadNameF("[txt] evictor thread"); for(;;) { U64 check_time_us = os_now_microseconds();