mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-11-20 21:10:16 -08:00
radlink: strip LF_PRECOMP earlier before parsing .debug$T to exclude it from leaf arrays
This commit is contained in:
1 parent
0ac6b35a98
commit
48ba845a91
6 files changed
+122
-123
No files matched your search
@@ -46,7 +46,7 @@ bit_array_get_bit32(U32Array bit_array, U64 idx)
|
||||
}
|
||||
|
||||
internal B32
|
||||
bit_array_is_bit_set(U32Array bit_arr, U64 bit_pos)
|
||||
bit_array_is_set32(U32Array bit_arr, U64 bit_pos)
|
||||
{
|
||||
U64 word_idx = bit_pos / 32;
|
||||
Assert(word_idx < bit_arr.count);
|
||||
|
||||
@@ -1147,8 +1147,23 @@ cv_debug_t_from_data(Arena *arena, String8 data, U64 align)
|
||||
{
|
||||
CV_DebugT debug_t = { .data = data };
|
||||
|
||||
U64 parse_start_offset = 0;
|
||||
|
||||
// strip LF_PRECOMP from .debug$T to exclude it from leaf arrays
|
||||
B8 has_pch = 0;
|
||||
CV_PrecompInfo precomp = {0};
|
||||
{
|
||||
CV_Leaf leaf = {0};
|
||||
U64 leaf_size = cv_read_leaf(data, 0, CV_LeafAlign, &leaf);
|
||||
if (leaf.kind == CV_LeafKind_PRECOMP) {
|
||||
debug_t.has_pch = 1;
|
||||
debug_t.precomp = cv_precomp_info_from_leaf(leaf);
|
||||
parse_start_offset = leaf_size;
|
||||
}
|
||||
}
|
||||
|
||||
ProfBegin("Upfront parse for counts");
|
||||
for (U64 cursor = 0, prev_cursor = 0, ti = CV_MinComplexTypeIndex; cursor < data.size; ti += 1) {
|
||||
for (U64 cursor = parse_start_offset, prev_cursor = parse_start_offset, ti = CV_MinComplexTypeIndex; cursor < data.size; ti += 1) {
|
||||
CV_Leaf leaf = {0};
|
||||
TryRead(cv_read_leaf(data, cursor, align, &leaf), cursor, count_stop);
|
||||
debug_t.source_counts[cv_type_index_source_from_leaf_kind(leaf.kind)] += 1;
|
||||
@@ -1160,20 +1175,15 @@ count_stop:
|
||||
|
||||
ProfBegin("store leaf offsets");
|
||||
debug_t.offsets = push_array_no_zero(arena, U32, debug_t.count);
|
||||
for (U64 cursor = 0, idx = 0; cursor < data.size && idx < debug_t.count; idx += 1) {
|
||||
for (U64 cursor = parse_start_offset, idx = 0; cursor < data.size && idx < debug_t.count; idx += 1) {
|
||||
debug_t.offsets[idx] = cursor;
|
||||
TryRead(cv_read_leaf(data, cursor, align, &(CV_Leaf){0}), cursor, store_stop);
|
||||
}
|
||||
store_stop:
|
||||
|
||||
for EachElement(i, debug_t.ti_ranges) { debug_t.ti_ranges[i] = r1u64(CV_MinComplexTypeIndex, CV_MinComplexTypeIndex + debug_t.count); }
|
||||
for EachElement(i, debug_t.ti_ranges) { debug_t.ti_ranges[i] = r1u64(CV_MinComplexTypeIndex, CV_MinComplexTypeIndex + debug_t.count + debug_t.precomp.leaf_count); }
|
||||
|
||||
// shift upper type index bound to include precompiled types
|
||||
CV_Leaf leaf = cv_debug_t_get_leaf(&debug_t, 0);
|
||||
if (leaf.kind == CV_LeafKind_PRECOMP) {
|
||||
CV_PrecompInfo precomp_info = cv_precomp_info_from_leaf(leaf);
|
||||
for EachElement(i, debug_t.ti_ranges) { debug_t.ti_ranges[i].max += precomp_info.leaf_count; }
|
||||
}
|
||||
for (U64 i = 1; i < CV_TypeIndexSource_COUNT; i += 1) { debug_t.pch_ti_range[i] = r1u64s(debug_t.precomp.start_index, debug_t.precomp.leaf_count); }
|
||||
|
||||
ProfEnd();
|
||||
return debug_t;
|
||||
|
||||
@@ -240,8 +240,10 @@ typedef struct CV_DebugT
|
||||
Rng1U64 ti_ranges [CV_TypeIndexSource_COUNT];
|
||||
|
||||
// PCH
|
||||
Rng1U64 pch_ti_range[CV_TypeIndexSource_COUNT];
|
||||
U32 pch_obj_idx;
|
||||
B8 has_pch;
|
||||
CV_PrecompInfo precomp;
|
||||
Rng1U64 pch_ti_range[CV_TypeIndexSource_COUNT];
|
||||
U32 pch_obj_idx;
|
||||
} CV_DebugT;
|
||||
|
||||
////////////////////////////////
|
||||
|
||||
+90
-103
@@ -138,22 +138,22 @@ THREAD_POOL_TASK_FUNC(lnk_strip_debug_t_sig_task)
|
||||
U64 obj_idx = task_id;
|
||||
LNK_ParseCvTypes *task = raw_task;
|
||||
|
||||
for EachIndex(i, task->raw_types[obj_idx].count) {
|
||||
String8 *d = task->raw_types[obj_idx].v + i;
|
||||
if (d->size == 0) { continue; }
|
||||
if (d->size < sizeof(CV_Signature)) { lnk_error_obj(LNK_Error_IllData, task->input->obj_arr[obj_idx], ".debug$T must have at least 4 bytes for CodeView signature"); continue; }
|
||||
String8 *d = &task->raw_types[obj_idx];
|
||||
if (d->size == 0) { goto exit; }
|
||||
if (d->size < sizeof(CV_Signature)) { lnk_error_obj(LNK_Error_IllData, task->input->obj_arr[obj_idx], ".debug$T must have at least 4 bytes for CodeView signature"); goto exit; }
|
||||
|
||||
CV_Signature sig = cv_signature_from_debug_s(*d);
|
||||
switch (sig) {
|
||||
default: {
|
||||
lnk_error_obj(LNK_Warning_IllData, task->input->obj_arr[obj_idx], "unknown CodeView type signature in section (TODO: print section index)");
|
||||
*d = str8(0,0);
|
||||
} break;
|
||||
case CV_Signature_C13: {
|
||||
*d = str8_skip(*d, sizeof(CV_Signature));
|
||||
} break;
|
||||
}
|
||||
CV_Signature sig = cv_signature_from_debug_s(*d);
|
||||
switch (sig) {
|
||||
default: {
|
||||
lnk_error_obj(LNK_Warning_IllData, task->input->obj_arr[obj_idx], "unknown CodeView type signature in section (TODO: print section index)");
|
||||
*d = str8(0,0);
|
||||
} break;
|
||||
case CV_Signature_C13: {
|
||||
*d = str8_skip(*d, sizeof(CV_Signature));
|
||||
} break;
|
||||
}
|
||||
|
||||
exit:;
|
||||
}
|
||||
|
||||
internal
|
||||
@@ -161,11 +161,7 @@ THREAD_POOL_TASK_FUNC(lnk_parse_debug_t_task)
|
||||
{
|
||||
ProfBeginFunction();
|
||||
LNK_ParseCvTypes *task = raw_task;
|
||||
if (task->raw_types[task_id].count > 0) {
|
||||
task->out_types[task_id] = cv_debug_t_from_data(arena, task->raw_types[task_id].v[0], CV_LeafAlign);
|
||||
} else {
|
||||
MemoryZeroStruct(&task->out_types[task_id]);
|
||||
}
|
||||
task->out_types[task_id] = cv_debug_t_from_data(arena, task->raw_types[task_id], CV_LeafAlign);
|
||||
ProfEnd();
|
||||
}
|
||||
|
||||
@@ -662,7 +658,14 @@ lnk_make_code_view_input(TP_Context *tp, TP_Arena *tp_arena, LNK_Config *config,
|
||||
ProfBegin("Extract CodeView");
|
||||
Temp scratch = scratch_begin(0,0);
|
||||
|
||||
LNK_CodeViewInput input = { .config = config, .obj_count = obj_count, .count = obj_count, .obj_arr = obj_arr, .rrt_input = rrt_input, .ts_obj_range = r1u64(0,0) };
|
||||
LNK_CodeViewInput input = {
|
||||
.config = config,
|
||||
.obj_count = obj_count,
|
||||
.count = obj_count,
|
||||
.obj_arr = obj_arr,
|
||||
.rrt_input = rrt_input,
|
||||
.ts_obj_range = r1u64(0,0)
|
||||
};
|
||||
|
||||
HashMap rrt_hm = {0};
|
||||
ProfScope("Make obj path -> RRT hash map")
|
||||
@@ -674,52 +677,51 @@ lnk_make_code_view_input(TP_Context *tp, TP_Arena *tp_arena, LNK_Config *config,
|
||||
}
|
||||
}
|
||||
|
||||
ProfBegin("Apply RRT to Objs");
|
||||
ProfScope("Apply RRT to Objs") {
|
||||
// hash map (obj path, obj idx)
|
||||
HashMap obj_path_hm = {0};
|
||||
for EachIndex(obj_idx, obj_count) {
|
||||
hash_map_push_path_u64(scratch.arena, &obj_path_hm, obj_arr[obj_idx]->path, obj_idx);
|
||||
}
|
||||
|
||||
// hash map (obj path, obj idx)
|
||||
HashMap obj_path_hm = {0};
|
||||
for EachIndex(obj_idx, obj_count) {
|
||||
hash_map_push_path_u64(scratch.arena, &obj_path_hm, obj_arr[obj_idx]->path, obj_idx);
|
||||
}
|
||||
for EachIndex(obj_idx, obj_count) {
|
||||
LNK_Obj *obj = obj_arr[obj_idx];
|
||||
U64 *packed_rrt_idx = hash_map_search_path_u64(&rrt_hm, obj->path);
|
||||
|
||||
for EachIndex(obj_idx, obj_count) {
|
||||
LNK_Obj *obj = obj_arr[obj_idx];
|
||||
U64 *packed_rrt_idx = hash_map_search_path_u64(&rrt_hm, obj->path);
|
||||
// obj is not part of any input RRT
|
||||
if (packed_rrt_idx == 0) { continue; }
|
||||
|
||||
// obj is not part of any input RRT
|
||||
if (packed_rrt_idx == 0) { continue; }
|
||||
// unpack index
|
||||
U32 rrt_idx = *packed_rrt_idx >> 32;
|
||||
U32 rrt_obj_idx = *packed_rrt_idx & max_U32;
|
||||
LNK_RRT *rrt = &rrt_input.v[rrt_idx];
|
||||
|
||||
// unpack index
|
||||
U32 rrt_idx = *packed_rrt_idx >> 32;
|
||||
U32 rrt_obj_idx = *packed_rrt_idx & max_U32;
|
||||
LNK_RRT *rrt = &rrt_input.v[rrt_idx];
|
||||
// obj was recompiled, do not apply RRT indirection
|
||||
FileProperties obj_file_props = properties_from_file_path(obj->path);
|
||||
if (rrt->obj_time_stamps[rrt_obj_idx] != obj_file_props.modified) { continue; }
|
||||
|
||||
// obj was recompiled, do not apply RRT indirection
|
||||
FileProperties obj_file_props = properties_from_file_path(obj->path);
|
||||
if (rrt->obj_time_stamps[rrt_obj_idx] != obj_file_props.modified) { continue; }
|
||||
// invalidate debug section pointers
|
||||
obj->coff.debug_t_section_number = 0;
|
||||
obj->coff.debug_p_section_number = 0;
|
||||
obj->coff.debug_h_section_number = 0;
|
||||
|
||||
// invalidate debug section pointers
|
||||
obj->coff.debug_t_section_number = 0;
|
||||
obj->coff.debug_p_section_number = 0;
|
||||
obj->coff.debug_h_section_number = 0;
|
||||
// apply type index map
|
||||
obj->ti_range = rrt->obj_ti_ranges[rrt_obj_idx];
|
||||
obj->ti_map = rrt->obj_ti_maps [rrt_obj_idx];
|
||||
|
||||
// apply type index map
|
||||
obj->ti_range = rrt->obj_ti_ranges[rrt_obj_idx];
|
||||
obj->ti_map = rrt->obj_ti_maps [rrt_obj_idx];
|
||||
|
||||
// apply PCH info
|
||||
U32 rrt_pch_obj_idx = rrt->obj_pch_indices[rrt_obj_idx];
|
||||
if (rrt_pch_obj_idx < rrt->obj_count) {
|
||||
String8 rrt_pch_obj_path = rrt->obj_paths.v[rrt_pch_obj_idx];
|
||||
U64 pch_obj_idx = *hash_map_search_path_u64(&obj_path_hm, rrt_pch_obj_path);
|
||||
obj->pch_ti_range = rrt->obj_pch_ti_ranges[rrt_obj_idx];
|
||||
obj->pch_obj_idx = pch_obj_idx;
|
||||
} else {
|
||||
obj->pch_ti_range = r1u64(0,0);
|
||||
obj->pch_obj_idx = ~0;
|
||||
// apply PCH info
|
||||
U32 rrt_pch_obj_idx = rrt->obj_pch_indices[rrt_obj_idx];
|
||||
if (rrt_pch_obj_idx < rrt->obj_count) {
|
||||
String8 rrt_pch_obj_path = rrt->obj_paths.v[rrt_pch_obj_idx];
|
||||
U64 pch_obj_idx = *hash_map_search_path_u64(&obj_path_hm, rrt_pch_obj_path);
|
||||
obj->pch_ti_range = rrt->obj_pch_ti_ranges[rrt_obj_idx];
|
||||
obj->pch_obj_idx = pch_obj_idx;
|
||||
} else {
|
||||
obj->pch_ti_range = r1u64(0,0);
|
||||
obj->pch_obj_idx = ~0;
|
||||
}
|
||||
}
|
||||
}
|
||||
ProfEnd();
|
||||
|
||||
ProfBegin("Collect CodeView");
|
||||
input.debug_s_list_arr = lnk_collect_obj_sections(tp, tp_arena, obj_count, obj_arr, str8_lit(".debug$S"), 0);
|
||||
@@ -770,55 +772,44 @@ lnk_make_code_view_input(TP_Context *tp, TP_Arena *tp_arena, LNK_Config *config,
|
||||
}
|
||||
}
|
||||
|
||||
ProfBegin("Parse CodeView");
|
||||
CV_DebugT *debug_p_arr;
|
||||
ProfScope("Parse CodeView")
|
||||
{
|
||||
// parse .debug$S
|
||||
input.debug_s_arr = push_array(tp_arena->v[0], CV_DebugS, input.obj_count);
|
||||
tp_for_parallel_prof(tp, tp_arena, obj_count, lnk_parse_debug_s_task, &input, "Parse .debug$S");
|
||||
|
||||
// collect .debug$P and .debug$T
|
||||
String8Array *raw_debug_p_arr = push_array(scratch.arena, String8Array, obj_count);
|
||||
String8Array *raw_debug_t_arr = push_array(scratch.arena, String8Array, obj_count);
|
||||
String8 *raw_debug_p_arr = push_array(scratch.arena, String8, obj_count);
|
||||
String8 *raw_debug_t_arr = push_array(scratch.arena, String8, obj_count);
|
||||
for EachIndex(obj_idx, obj_count) {
|
||||
LNK_Obj *obj = obj_arr[obj_idx];
|
||||
|
||||
if (obj->coff.debug_t_section_number > 0) {
|
||||
raw_debug_t_arr[obj_idx].count = 1;
|
||||
raw_debug_t_arr[obj_idx].v = push_array(scratch.arena, String8, 1);
|
||||
raw_debug_t_arr[obj_idx].v[0] = lnk_obj_section_data_from_number(obj, obj->coff.debug_t_section_number);
|
||||
}
|
||||
|
||||
if (obj->coff.debug_p_section_number > 0) {
|
||||
raw_debug_p_arr[obj_idx].count = 1;
|
||||
raw_debug_p_arr[obj_idx].v = push_array(scratch.arena, String8, 1);
|
||||
raw_debug_p_arr[obj_idx].v[0] = lnk_obj_section_data_from_number(obj, obj->coff.debug_p_section_number);
|
||||
}
|
||||
if (obj->coff.debug_t_section_number > 0) { raw_debug_t_arr[obj_idx] = lnk_obj_section_data_from_number(obj, obj->coff.debug_t_section_number); }
|
||||
if (obj->coff.debug_p_section_number > 0) { raw_debug_p_arr[obj_idx] = lnk_obj_section_data_from_number(obj, obj->coff.debug_p_section_number); }
|
||||
}
|
||||
|
||||
LNK_ParseCvTypes parse_types = { .input = &input };
|
||||
|
||||
// parse .debug$P
|
||||
// .debug$P
|
||||
debug_p_arr = push_array(tp_arena->v[0], CV_DebugT, obj_count);
|
||||
parse_types.raw_types = raw_debug_p_arr;
|
||||
parse_types.out_types = debug_p_arr;
|
||||
tp_for_parallel_prof(tp, 0, obj_count, lnk_strip_debug_t_sig_task, &parse_types, "Strip .debug$P");
|
||||
tp_for_parallel_prof(tp, 0, obj_count, lnk_strip_debug_t_sig_task, &parse_types, "Strip Signature .debug$P");
|
||||
tp_for_parallel_prof(tp, tp_arena, obj_count, lnk_parse_debug_t_task, &parse_types, "Parse .debug$P");
|
||||
|
||||
// parse .debug$T
|
||||
// .debug$T
|
||||
input.debug_t_arr = push_array(tp_arena->v[0], CV_DebugT, obj_count);
|
||||
parse_types.raw_types = raw_debug_t_arr;
|
||||
parse_types.out_types = input.debug_t_arr;
|
||||
tp_for_parallel_prof(tp, 0, obj_count, lnk_strip_debug_t_sig_task, &parse_types, "Strip .debug$T");
|
||||
tp_for_parallel_prof(tp, tp_arena, obj_count, lnk_parse_debug_t_task, &parse_types, "Parse .debug$T");
|
||||
tp_for_parallel_prof(tp, 0, obj_count, lnk_strip_debug_t_sig_task, &parse_types, "Strip Signature .debug$T");
|
||||
tp_for_parallel_prof(tp, tp_arena, obj_count, lnk_parse_debug_t_task, &parse_types, "Parse .debug$T");
|
||||
|
||||
// parse .debug$H
|
||||
// .debug$H
|
||||
input.debug_h_arr = push_array(tp_arena->v[0], CV_DebugH, input.obj_count);
|
||||
if (config->ghash) {
|
||||
tp_for_parallel_prof(tp, tp_arena, obj_count, lnk_parse_debug_h_task, &input, "Parse .debug$H");
|
||||
}
|
||||
}
|
||||
ProfEnd();
|
||||
|
||||
// sort objs based on type: PCH, /Zi (external), /Z7 (internal)
|
||||
input.debug_p_indices.v = push_array(tp_arena->v[0], U32, obj_count);
|
||||
@@ -1020,31 +1011,31 @@ lnk_make_code_view_input(TP_Context *tp, TP_Arena *tp_arena, LNK_Config *config,
|
||||
}
|
||||
|
||||
for EachIndex(i, input.int_obj_indices.count) {
|
||||
U64 obj_idx = input.int_obj_indices.v[i];
|
||||
CV_DebugT *debug_t = &input.debug_t_arr[obj_idx];
|
||||
U64 obj_idx = input.int_obj_indices.v[i];
|
||||
CV_DebugT *debug_t = &input.debug_t_arr[obj_idx];
|
||||
CV_PrecompInfo *precomp = &debug_t->precomp;
|
||||
|
||||
// skip objs that do not depend on PCH
|
||||
if ( ! cv_debug_t_is_pch(debug_t)) { continue; }
|
||||
if ( ! debug_t->has_pch) { continue; }
|
||||
|
||||
// find PCH obj by file path
|
||||
CV_PrecompInfo precomp = cv_precomp_info_from_leaf(cv_debug_t_get_leaf(debug_t, 0));
|
||||
String8 obj_path = path_absolute_dst_from_relative_dst_src(scratch.arena, precomp.obj_name, config->work_dir);
|
||||
U64 *debug_p_obj_idx_ptr = hash_map_search_path_u64(&debug_p_hm_path, obj_path);
|
||||
U64 debug_p_obj_idx = debug_p_obj_idx_ptr ? *debug_p_obj_idx_ptr : max_U64;
|
||||
String8 obj_path = path_absolute_dst_from_relative_dst_src(scratch.arena, precomp->obj_name, config->work_dir);
|
||||
U64 *debug_p_obj_idx_ptr = hash_map_search_path_u64(&debug_p_hm_path, obj_path);
|
||||
U64 debug_p_obj_idx = debug_p_obj_idx_ptr ? *debug_p_obj_idx_ptr : max_U64;
|
||||
|
||||
// find PCH obj by signature
|
||||
// fallback: find PCH obj by signature
|
||||
if (debug_p_obj_idx_ptr == 0) {
|
||||
for EachIndex(pch_i, input.debug_p_indices.count) {
|
||||
U64 pch_obj_idx = input.debug_p_indices.v[pch_i];
|
||||
CV_DebugT *pch_debug_t = &input.debug_t_arr[pch_obj_idx];
|
||||
if (precomp.leaf_count >= pch_debug_t->count) { continue; }
|
||||
if (precomp->leaf_count >= pch_debug_t->count) { continue; }
|
||||
|
||||
CV_Leaf end_leaf = cv_debug_t_get_leaf(pch_debug_t, precomp.leaf_count);
|
||||
CV_Leaf end_leaf = cv_debug_t_get_leaf(pch_debug_t, precomp->leaf_count);
|
||||
if (end_leaf.kind != CV_LeafKind_ENDPRECOMP) { continue; }
|
||||
if (end_leaf.data.size < sizeof(CV_LeafEndPreComp)) { continue; }
|
||||
|
||||
CV_LeafEndPreComp *end_precomp = str8_deserial_get_raw_ptr(end_leaf.data, 0, sizeof(*end_precomp));
|
||||
if (end_precomp->sig != precomp.sig) { continue; }
|
||||
if (end_precomp->sig != precomp->sig) { continue; }
|
||||
|
||||
debug_p_obj_idx = pch_obj_idx;
|
||||
break;
|
||||
@@ -1061,25 +1052,21 @@ lnk_make_code_view_input(TP_Context *tp, TP_Arena *tp_arena, LNK_Config *config,
|
||||
CV_DebugT *debug_p = &input.debug_t_arr[debug_p_obj_idx];
|
||||
|
||||
// error check LF_PRECOMP
|
||||
if (precomp.start_index > CV_MinComplexTypeIndex) { lnk_error_obj(LNK_Warning_AtypicalStartIndex, obj_arr[obj_idx], "atypical start index 0x%x in LF_PRECOMP", precomp.start_index); }
|
||||
if (precomp.start_index < CV_MinComplexTypeIndex) { lnk_error_obj(LNK_Error_InvalidStartIndex, obj_arr[obj_idx], "invalid start index 0x%x in LF_PRECOMP; must be >= 0x%x", precomp.start_index, CV_MinComplexTypeIndex); continue; }
|
||||
if (precomp.leaf_count >= debug_p->count) { lnk_error_obj(LNK_Error_InvalidPrecompLeafCount, obj_arr[obj_idx], "leaf count %u LF_PRECOMP exceeds leaf count %u in .debug$P in %S", precomp.leaf_count, debug_p->count, obj_arr[debug_p_obj_idx]->path); continue; }
|
||||
if (precomp->start_index > CV_MinComplexTypeIndex) { lnk_error_obj(LNK_Warning_AtypicalStartIndex, obj_arr[obj_idx], "atypical start index 0x%x in LF_PRECOMP", precomp->start_index); }
|
||||
if (precomp->start_index < CV_MinComplexTypeIndex) { lnk_error_obj(LNK_Error_InvalidStartIndex, obj_arr[obj_idx], "invalid start index 0x%x in LF_PRECOMP; must be >= 0x%x", precomp->start_index, CV_MinComplexTypeIndex); continue; }
|
||||
if (precomp->leaf_count >= debug_p->count) { lnk_error_obj(LNK_Error_InvalidPrecompLeafCount, obj_arr[obj_idx], "leaf count %u LF_PRECOMP exceeds leaf count %u in .debug$P in %S", precomp->leaf_count, debug_p->count, obj_arr[debug_p_obj_idx]->path); continue; }
|
||||
|
||||
// get LF_PRECOMP
|
||||
CV_Leaf endprecomp_leaf = cv_debug_t_get_leaf(debug_p, precomp.leaf_count);
|
||||
// get LF_ENDPRECOMP
|
||||
CV_Leaf endprecomp_leaf = cv_debug_t_get_leaf(debug_p, precomp->leaf_count);
|
||||
CV_LeafEndPreComp *endprecomp = str8_deserial_get_raw_ptr(endprecomp_leaf.data, 0, sizeof(*endprecomp));
|
||||
|
||||
// error check LF_ENDPRECOMP
|
||||
if (endprecomp_leaf.kind != CV_LeafKind_ENDPRECOMP) { lnk_error_obj(LNK_Error_EndprecompNotFound, obj_arr[obj_idx], "missing LF_ENDPRECOMP [0x%x] in %S", precomp.leaf_count, obj_arr[debug_p_obj_idx]->path); continue; }
|
||||
if (endprecomp_leaf.kind != CV_LeafKind_ENDPRECOMP) { lnk_error_obj(LNK_Error_EndprecompNotFound, obj_arr[obj_idx], "missing LF_ENDPRECOMP [0x%x] in %S", precomp->leaf_count, obj_arr[debug_p_obj_idx]->path); continue; }
|
||||
if (endprecomp_leaf.data.size != sizeof(CV_LeafEndPreComp)) { lnk_error_obj(LNK_Error_IllData, obj_arr[obj_idx], "invalid size 0x%x for LF_ENDPRECOMP", endprecomp_leaf.data.size); continue; }
|
||||
if (endprecomp->sig != precomp.sig) { lnk_error_obj(LNK_Error_PrecompSigMismatch, obj_arr[obj_idx], "PCH signature mismatch, expected 0x%x got 0x%x; PCH obj %S", precomp.sig, endprecomp->sig, obj_arr[debug_p_obj_idx]->path); continue; }
|
||||
if (endprecomp->sig != precomp->sig) { lnk_error_obj(LNK_Error_PrecompSigMismatch, obj_arr[obj_idx], "PCH signature mismatch, expected 0x%x got 0x%x; PCH obj %S", precomp->sig, endprecomp->sig, obj_arr[debug_p_obj_idx]->path); continue; }
|
||||
|
||||
for (U64 i = 1; i < CV_TypeIndexSource_COUNT; i += 1) { debug_t->pch_ti_range[i] = r1u64(precomp.start_index, precomp.start_index + precomp.leaf_count); }
|
||||
debug_t->pch_obj_idx = debug_p_obj_idx;
|
||||
|
||||
// remove CV_LeafKind_PRECOMP
|
||||
debug_t->count -= 1;
|
||||
debug_t->offsets += 1;
|
||||
// associate .debug$P and .debug$T
|
||||
debug_t->pch_obj_idx = debug_p_obj_idx;
|
||||
}
|
||||
|
||||
// remove LF_ENDPRECOMP from .debug$P
|
||||
|
||||
@@ -113,7 +113,7 @@ typedef struct
|
||||
typedef struct
|
||||
{
|
||||
LNK_CodeViewInput *input;
|
||||
String8Array *raw_types; // [obj_count]
|
||||
String8 *raw_types; // [obj_count]
|
||||
CV_DebugT *out_types; // [obj_count]
|
||||
} LNK_ParseCvTypes;
|
||||
|
||||
|
||||
@@ -98,8 +98,8 @@ pdb_hash_table_from_data(PDB_HashTable *ht,
|
||||
// unpack buckets
|
||||
U64 read_count = 0;
|
||||
for (U64 bucket_idx = 0; bucket_idx < max; bucket_idx += 1) {
|
||||
if (bit_array_is_bit_set(present_bits_new, bucket_idx)) {
|
||||
if (bit_array_is_bit_set(deleted_bits_new, bucket_idx)) {
|
||||
if (bit_array_is_set32(present_bits_new, bucket_idx)) {
|
||||
if (bit_array_is_set32(deleted_bits_new, bucket_idx)) {
|
||||
error = PDB_HashTableParseError_CORRUPTED;
|
||||
break;
|
||||
}
|
||||
@@ -198,7 +198,7 @@ pdb_hash_table_grow(PDB_HashTable *ht, U64 new_capacity)
|
||||
PDB_HashTable new_ht;
|
||||
pdb_hash_table_alloc(&new_ht, new_capacity);
|
||||
for (U32 i = 0; i < ht->max; ++i) {
|
||||
if (bit_array_is_bit_set(ht->present_bits, i)) {
|
||||
if (bit_array_is_set32(ht->present_bits, i)) {
|
||||
PDB_HashTableBucket *bucket = &ht->bucket_arr[i];
|
||||
PDB_HashTableBucket *is_set = pdb_hash_table_try_set(&new_ht, bucket->key, bucket->value);
|
||||
is_set->insert_idx = bucket->insert_idx;
|
||||
@@ -316,14 +316,14 @@ internal B32
|
||||
pdb_hash_table_is_present(PDB_HashTable *ht, U32 k)
|
||||
{
|
||||
Assert(k < ht->max);
|
||||
return bit_array_is_bit_set(ht->present_bits, k);
|
||||
return bit_array_is_set32(ht->present_bits, k);
|
||||
}
|
||||
|
||||
internal B32
|
||||
pdb_hash_table_is_deleted(PDB_HashTable *ht, U32 k)
|
||||
{
|
||||
Assert(k < ht->max);
|
||||
return bit_array_is_bit_set(ht->deleted_bits, k);
|
||||
return bit_array_is_set32(ht->deleted_bits, k);
|
||||
}
|
||||
|
||||
internal PDB_HashTableBucket **
|
||||
@@ -332,7 +332,7 @@ pdb_hash_table_get_present_buckets(Arena *arena, PDB_HashTable *ht)
|
||||
U64 result_count = 0;
|
||||
PDB_HashTableBucket **result = push_array(arena, PDB_HashTableBucket *, ht->count);
|
||||
for EachIndex(bucket_idx, ht->max) {
|
||||
if (bit_array_is_bit_set(ht->present_bits, bucket_idx)) {
|
||||
if (bit_array_is_set32(ht->present_bits, bucket_idx)) {
|
||||
PDB_HashTableBucket *bucket = &ht->bucket_arr[bucket_idx];
|
||||
Assert(result_count < ht->count);
|
||||
result[result_count++] = bucket;
|
||||
@@ -347,7 +347,7 @@ pdb_hash_table_get_present_keys_and_values(Arena *arena, PDB_HashTable *ht, Stri
|
||||
*keys_out = str8_array_reserve(arena, ht->count);
|
||||
*values_out = str8_array_reserve(arena, ht->count);
|
||||
for (U64 bucket_idx = 0; bucket_idx < ht->max; bucket_idx += 1) {
|
||||
if (bit_array_is_bit_set(ht->present_bits, bucket_idx)) {
|
||||
if (bit_array_is_set32(ht->present_bits, bucket_idx)) {
|
||||
PDB_HashTableBucket *bucket = &ht->bucket_arr[bucket_idx];
|
||||
Assert(keys_out->count < ht->count);
|
||||
keys_out->v[keys_out->count++] = bucket->key;
|
||||
|
||||
Reference in new issue
Block a user