further debugging / logging / work on tester, trynig to get to the bottom of nondeterministic rdi generation

This commit is contained in:
Ryan Fleury
2024-10-15 17:41:18 -07:00
parent 65b5176468
commit 4671458e8e
7 changed files with 177 additions and 22 deletions
-1
View File
@@ -3510,7 +3510,6 @@ rdim_bake_file_paths(RDIM_Arena *arena, RDIM_BakeStringMapTight *strings, RDIM_B
RDI_PROC RDIM_StringBakeResult
rdim_bake_strings(RDIM_Arena *arena, RDIM_BakeStringMapTight *strings)
{
RDIM_BakeSectionList sections = {0};
RDI_U32 *str_offs = rdim_push_array_no_zero(arena, RDI_U32, strings->total_count + 1);
RDI_U32 off_cursor = 0;
{
+10
View File
@@ -193,6 +193,8 @@ os_cmd_line_launch(String8 string)
OS_Handle stdout_handle = {0};
if(stdout_path.size != 0)
{
OS_Handle file = os_file_open(OS_AccessFlag_Write|OS_AccessFlag_Read, stdout_path);
os_file_close(file);
stdout_handle = os_file_open(OS_AccessFlag_Write|OS_AccessFlag_Append|OS_AccessFlag_ShareRead|OS_AccessFlag_ShareWrite|OS_AccessFlag_Inherited, stdout_path);
}
@@ -210,6 +212,14 @@ os_cmd_line_launch(String8 string)
params.inherit_env = 1;
params.stdout_file = stdout_handle;
handle = os_process_launch(&params);
// rjf: close stdout handle
{
if(stdout_path.size != 0)
{
os_file_close(stdout_handle);
}
}
}
scratch_end(scratch);
return handle;
+5 -5
View File
@@ -294,13 +294,13 @@ os_file_open(OS_AccessFlags flags, String8 path)
DWORD share_mode = 0;
DWORD creation_disposition = OPEN_EXISTING;
SECURITY_ATTRIBUTES security_attributes = {sizeof(security_attributes), 0, 0};
if(flags & OS_AccessFlag_Read) {access_flags |= GENERIC_READ;}
if(flags & OS_AccessFlag_Write) {access_flags |= GENERIC_WRITE;}
if(flags & OS_AccessFlag_Execute) {access_flags |= GENERIC_EXECUTE;}
if(flags & OS_AccessFlag_Read) {access_flags |= GENERIC_READ;}
if(flags & OS_AccessFlag_Write) {access_flags |= GENERIC_WRITE;}
if(flags & OS_AccessFlag_Execute) {access_flags |= GENERIC_EXECUTE;}
if(flags & OS_AccessFlag_ShareRead) {share_mode |= FILE_SHARE_READ;}
if(flags & OS_AccessFlag_ShareWrite) {share_mode |= FILE_SHARE_WRITE|FILE_SHARE_DELETE;}
if(flags & OS_AccessFlag_Write) {creation_disposition = CREATE_ALWAYS;}
if(flags & OS_AccessFlag_Append) {creation_disposition = OPEN_ALWAYS; access_flags |= FILE_APPEND_DATA; }
if(flags & OS_AccessFlag_Write) {creation_disposition = CREATE_ALWAYS;}
if(flags & OS_AccessFlag_Append) {creation_disposition = OPEN_ALWAYS; access_flags |= FILE_APPEND_DATA; }
if(flags & OS_AccessFlag_Inherited)
{
security_attributes.bInheritHandle = 1;
+2
View File
@@ -4,6 +4,8 @@
////////////////////////////////
//~ rjf: post-0.9.12 TODO notes
//
// [ ] per-target stdout/stderr file output paths
//
// [ ] double click on breakpoints/watch-pins/etc. to go to location
// [ ] auto view rule templates (?)
// [ ] single-line visualization busted with auto-view-rules applied, it seems...
+112 -3
View File
@@ -4488,7 +4488,7 @@ p2r_bake(Arena *arena, P2R_Convert2Bake *in)
}
// rjf: UDTs
ProfScope("kick off udts string map build tasks")
if(0) ProfScope("kick off udts string map build tasks")
{
U64 items_per_task = 4096;
U64 num_tasks = (in_params->udts.total_count+items_per_task-1)/items_per_task;
@@ -4520,7 +4520,7 @@ p2r_bake(Arena *arena, P2R_Convert2Bake *in)
}
// rjf: symbols
ProfScope("kick off symbols string map build tasks")
if(0) ProfScope("kick off symbols string map build tasks")
{
RDIM_SymbolChunkList *symbol_lists[] =
{
@@ -4561,7 +4561,7 @@ p2r_bake(Arena *arena, P2R_Convert2Bake *in)
}
// rjf: scope chunks
ProfScope("kick off scope chunks string map build tasks")
if(0) ProfScope("kick off scope chunks string map build tasks")
{
U64 items_per_task = 4096;
U64 num_tasks = (in_params->scopes.total_count+items_per_task-1)/items_per_task;
@@ -4618,6 +4618,38 @@ p2r_bake(Arena *arena, P2R_Convert2Bake *in)
}
}
//////////////////////////////
//- rjf: [DEBUG] dump unsorted *per-thread* loose string maps
//
#if 0
{
U64 slots_count = bake_string_map_topology.slots_count;
RDIM_BakeStringMapLoose **maps = bake_string_maps__in_progress;
U64 maps_count = ts_thread_count();
for EachIndex(map_idx, maps_count)
{
RDIM_BakeStringMapLoose *map = maps[map_idx];
if(map && map->slots != 0)
{
for EachIndex(slot_idx, slots_count)
{
RDIM_BakeStringChunkList *slot = map->slots[slot_idx];
if(slot != 0)
{
for(RDIM_BakeStringChunkNode *n = slot->first; n != 0; n = n->next)
{
for EachIndex(idx, n->count)
{
printf("string: %.*s\n", str8_varg(n->v[idx].string));
}
}
}
}
}
}
}
#endif
//////////////////////////////
//- rjf: produce joined string map
//
@@ -4653,6 +4685,35 @@ p2r_bake(Arena *arena, P2R_Convert2Bake *in)
rdim_bake_string_map_loose_push_path_tree(arena, &bake_string_map_topology, unsorted_bake_string_map, path_tree);
}
//////////////////////////////
//- rjf: [DEBUG] dump unsorted *joined* loose string map
//
#if 0
{
U64 string_idx = 0;
U64 slots_count = bake_string_map_topology.slots_count;
RDIM_BakeStringMapLoose *map = unsorted_bake_string_map;
if(map && map->slots != 0)
{
for EachIndex(slot_idx, slots_count)
{
RDIM_BakeStringChunkList *slot = map->slots[slot_idx];
if(slot != 0)
{
for(RDIM_BakeStringChunkNode *n = slot->first; n != 0; n = n->next)
{
for EachIndex(idx, n->count)
{
printf("string: %.*s\n", str8_varg(n->v[idx].string));
string_idx += 1;
}
}
}
}
}
}
#endif
//////////////////////////////
//- rjf: kick off string map sorting tasks
//
@@ -4691,6 +4752,35 @@ p2r_bake(Arena *arena, P2R_Convert2Bake *in)
}
RDIM_BakeStringMapLoose *sorted_bake_string_map = sorted_bake_string_map__in_progress;
//////////////////////////////
//- rjf: [DEBUG] dump sorted, joined loose string map
//
#if 0
{
U64 string_idx = 0;
U64 slots_count = bake_string_map_topology.slots_count;
RDIM_BakeStringMapLoose *map = sorted_bake_string_map;
if(map && map->slots != 0)
{
for EachIndex(slot_idx, slots_count)
{
RDIM_BakeStringChunkList *slot = map->slots[slot_idx];
if(slot != 0)
{
for(RDIM_BakeStringChunkNode *n = slot->first; n != 0; n = n->next)
{
for EachIndex(idx, n->count)
{
printf("string: %.*s\n", str8_varg(n->v[idx].string));
string_idx += 1;
}
}
}
}
}
}
#endif
//////////////////////////////
//- rjf: build finalized string map
//
@@ -4701,6 +4791,25 @@ p2r_bake(Arena *arena, P2R_Convert2Bake *in)
RDIM_BakeStringMapTight bake_strings = rdim_bake_string_map_tight_from_loose(arena, &bake_string_map_topology, &bake_string_map_base_idxes, sorted_bake_string_map);
ProfEnd();
//////////////////////////////
//- rjf: [DEBUG] dump sorted, joined tight string map
//
#if 0
{
for EachIndex(slot_idx, bake_strings.slots_count)
{
RDIM_BakeStringChunkList *slot = &bake_strings.slots[slot_idx];
for(RDIM_BakeStringChunkNode *n = slot->first; n != 0; n = n->next)
{
for EachIndex(idx, n->count)
{
printf("string: %.*s\n", str8_varg(n->v[idx].string));
}
}
}
}
#endif
//////////////////////////////
//- rjf: kick off pass 2 tasks
//
+1 -1
View File
@@ -40,7 +40,7 @@ ts_init(void)
ts_shared->u2t_ring_base = push_array_no_zero(arena, U8, ts_shared->u2t_ring_size);
ts_shared->u2t_ring_mutex = os_mutex_alloc();
ts_shared->u2t_ring_cv = os_condition_variable_alloc();
ts_shared->task_threads_count = os_get_system_info()->logical_processor_count-1;
ts_shared->task_threads_count = Max(1, os_get_system_info()->logical_processor_count-1);
ts_shared->task_threads = push_array(arena, TS_TaskThread, ts_shared->task_threads_count);
for(U64 idx = 0; idx < ts_shared->task_threads_count; idx += 1)
{
+47 -12
View File
@@ -48,7 +48,7 @@ entry_point(CmdLine *cmdline)
U64 num_repeats_per_pdb = 4;
String8 pdb_paths[] =
{
str8_lit_comp("odintest/test.pdb"),
// str8_lit_comp("odintest/test.pdb"),
str8_lit_comp("mule_main.pdb"),
};
for EachElement(pdb_idx, pdb_paths)
@@ -61,13 +61,14 @@ entry_point(CmdLine *cmdline)
// rjf: generate all RDIs
String8List rdi_paths = {0};
String8List dump_paths = {0};
{
OS_HandleList processes = {0};
for EachIndex(repeat_idx, num_repeats_per_pdb)
{
String8 rdi_path = push_str8f(arena, "%S/repeat_%I64u.rdi", repeat_folder, repeat_idx);
str8_list_push(arena, &rdi_paths, rdi_path);
os_handle_list_push(arena, &processes, os_cmd_line_launchf("rdi_from_pdb --pdb:%S --out:%S", pdb_path, rdi_path));
os_handle_list_push(arena, &processes, os_cmd_line_launchf("rdi_from_pdb --pdb:%S --out:%S > %S/repeat_%I64u.dump", pdb_path, rdi_path, repeat_folder, repeat_idx));
}
for(OS_HandleNode *n = processes.first; n != 0; n = n->next)
{
@@ -82,30 +83,60 @@ entry_point(CmdLine *cmdline)
{
String8 rdi_path = n->string;
String8 dump_path = push_str8f(arena, "%S.dump", rdi_path);
str8_list_push(arena, &dump_paths, dump_path);
os_handle_list_push(arena, &processes, os_cmd_line_launchf("rdi_dump %S > %S", rdi_path, dump_path));
}
for(OS_HandleNode *n = processes.first; n != 0; n = n->next)
{
os_process_join(n->v, max_U64);
}
}
// rjf: gather all hashes/paths
U64 hashes_count = rdi_paths.node_count;
U128 *hashes = push_array(arena, U128, hashes_count);
String8 *paths = push_array(arena, String8, hashes_count);
U64 rdi_hashes_count = rdi_paths.node_count;
U128 *rdi_hashes = push_array(arena, U128, rdi_hashes_count);
String8 *rdi_paths_array = push_array(arena, String8, rdi_hashes_count);
U64 dump_hashes_count = dump_paths.node_count;
U128 *dump_hashes = push_array(arena, U128, dump_hashes_count);
String8 *dump_paths_array = push_array(arena, String8, dump_hashes_count);
{
U64 idx = 0;
for(String8Node *n = rdi_paths.first; n != 0; n = n->next, idx += 1)
{
Temp scratch = scratch_begin(0, 0);
String8 path = n->string;
String8 data = os_data_from_file_path(arena, path);
hashes[idx] = hs_hash_from_data(data);
paths[idx] = path;
String8 data = os_data_from_file_path(scratch.arena, path);
rdi_hashes[idx] = hs_hash_from_data(data);
rdi_paths_array[idx] = path;
scratch_end(scratch);
}
}
{
U64 idx = 0;
for(String8Node *n = dump_paths.first; n != 0; n = n->next, idx += 1)
{
Temp scratch = scratch_begin(0, 0);
String8 path = n->string;
String8 data = os_data_from_file_path(scratch.arena, path);
dump_hashes[idx] = hs_hash_from_data(data);
dump_paths_array[idx] = path;
scratch_end(scratch);
}
}
// rjf: determine if all hashes match
B32 matches = 1;
for EachIndex(idx, hashes_count)
for EachIndex(idx, rdi_hashes_count)
{
if(!u128_match(hashes[idx], hashes[0]))
if(!u128_match(rdi_hashes[idx], rdi_hashes[0]))
{
matches = 0;
break;
}
}
for EachIndex(idx, dump_hashes_count)
{
if(!u128_match(dump_hashes[idx], dump_hashes[0]))
{
matches = 0;
break;
@@ -117,9 +148,13 @@ entry_point(CmdLine *cmdline)
{
good = 0;
str8_list_pushf(arena, &out, " pdb[%I64u] \"%S\"\n", pdb_idx, pdb_path);
for EachIndex(idx, hashes_count)
for EachIndex(idx, rdi_hashes_count)
{
str8_list_pushf(arena, &out, " rdi[%I64u] \"%S\": 0x%I64x:%I64x\n", idx, paths[idx], hashes[idx].u64[0], hashes[idx].u64[1]);
str8_list_pushf(arena, &out, " rdi[%I64u] \"%S\": 0x%I64x:%I64x\n", idx, rdi_paths_array[idx], rdi_hashes[idx].u64[0], rdi_hashes[idx].u64[1]);
}
for EachIndex(idx, dump_hashes_count)
{
str8_list_pushf(arena, &out, " dump[%I64u] \"%S\": 0x%I64x:%I64x\n", idx, dump_paths_array[idx], dump_hashes[idx].u64[0], dump_hashes[idx].u64[1]);
}
}
}