validate info stream

This commit is contained in:
Nikita Smith
2026-04-10 17:02:04 -07:00
parent c5dc7bee3e
commit b4bbc38ab2
6 changed files with 90 additions and 37 deletions
+13 -3
View File
@@ -114,9 +114,19 @@ t_run_fail_handler(void *raw_ctx)
internal T_RunResult
t_run(T_Run run)
{
T_RunCtx ctx = {0};
ctx.run = run;
os_safe_call(t_run_caller, t_run_fail_handler, &ctx);
T_RunCtx ctx = { .run = run };
B32 do_safe_call = 1;
#if OS_WINDOWS
if (IsDebuggerPresent()) {
do_safe_call = 0;
}
#endif
if (do_safe_call) {
os_safe_call(t_run_caller, t_run_fail_handler, &ctx);
} else {
t_run_caller(&ctx);
}
return ctx.result;
}
+52 -1
View File
@@ -4626,7 +4626,58 @@ T_BeginTest(get_msf_stream_pages)
T_Ok(stream_data.first->string.size == 1);
}
msf_release(&msf);
msf_release(msf);
}
T_BeginTest(validate_info_stream)
{
COFF_TimeStamp time_stamp = 123;
U32 age = 1;
Guid guid = { .data1 = max_U32, .data2 = max_U16 - 1, .data3 = max_U16 - 2, .data4 = { 1, 2, 3, 4, 5, 6, 7, 8 } };
PDB_Context *pdb = pdb_alloc(MSF_DEFAULT_PAGE_SIZE, COFF_MachineType_X64, time_stamp, age, guid);
char *stream_names[] = { "one", "two", "three", "four", "five" };
MSF_StreamNumber stream_numbers[ArrayCount(stream_names)] = {0};
for EachElement(i, stream_names) {
stream_numbers[i] = pdb_push_named_stream(&pdb->info->named_stream_ht, pdb->msf, str8_cstring(stream_names[i]));
T_Ok(stream_numbers[i] != MSF_INVALID_STREAM_NUMBER);
}
TP_Context *tp = tp_alloc(arena, 1, 1, str8_lit("foo"));
TP_Arena *tp_arena = tp_arena_alloc(tp);
pdb_build(tp, tp_arena, pdb, (CV_StringHashTable){0}, 1, 0);
T_Ok(msf_build(pdb->msf) == MSF_Error_OK);
String8List raw_msf_list = msf_get_page_data_nodes(arena, pdb->msf);
T_Ok(t_write_file_list(str8_lit("test.pdb"), raw_msf_list));
String8 raw_msf = t_read_file(arena, str8_lit("test.pdb"));
MSF_Parsed *msf_parsed = msf_parsed_from_data(arena, raw_msf);
String8 info_data = msf_data_from_stream(msf_parsed, PDB_FixedStream_Info);
#if 0
fprintf(stderr, "\n");
for EachIndex(i, info_data.size) {
fprintf(stderr, "0x%02x, ", info_data.str[i]);
if (i % 19 == 18 && i > 0) { fprintf(stderr, "\n"); }
}
#endif
U8 expected_info_data[] = {
0x94, 0x2e, 0x31, 0x01, 0x7b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xfd,
0xff, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x22, 0x00, 0x00, 0x00, 0x6f, 0x6e, 0x65, 0x00, 0x74, 0x77,
0x6f, 0x00, 0x74, 0x68, 0x72, 0x65, 0x65, 0x00, 0x66, 0x6f, 0x75, 0x72, 0x00, 0x66, 0x69, 0x76, 0x65, 0x00, 0x2f,
0x4c, 0x69, 0x6e, 0x6b, 0x49, 0x6e, 0x66, 0x6f, 0x00, 0x06, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x01, 0x00,
0x00, 0x00, 0xb7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x13,
0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00,
0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x51, 0x33, 0x01,
};
T_Ok(str8_match(info_data, str8_array_fixed(expected_info_data), 0));
pdb_release(pdb);
tp_arena_release(&tp_arena);
tp_release(tp);
}
T_BeginTest(patch_cv_symbol_tree)