mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-06-19 18:42:23 -07:00
raddbgi_make & raddbgi_from_pdb: solve multithreaded 'indexing' problem - how do we correllate loose pointer relationships, constructed by various threads, with final indices in the baked file
This commit is contained in:
@@ -445,38 +445,43 @@ rdim_binary_section_list_push(RDIM_Arena *arena, RDIM_BinarySectionList *list)
|
||||
//~ rjf: Unit List Building
|
||||
|
||||
RDI_PROC RDIM_Unit *
|
||||
rdim_unit_chunk_list_push(RDIM_Arena *arena, RDIM_UnitChunkList *list)
|
||||
rdim_unit_chunk_list_push(RDIM_Arena *arena, RDIM_UnitChunkList *list, RDI_U64 cap)
|
||||
{
|
||||
RDIM_UnitChunkNode *n = list->last;
|
||||
if(n == 0 || n->count >= n->cap)
|
||||
{
|
||||
n = rdim_push_array(arena, RDIM_UnitChunkNode, 1);
|
||||
n->cap = 512;
|
||||
n->cap = cap;
|
||||
n->base_idx = list->total_count;
|
||||
n->v = rdim_push_array(arena, RDIM_Unit, n->cap);
|
||||
RDIM_SLLQueuePush(list->first, list->last, n);
|
||||
list->chunk_count += 1;
|
||||
}
|
||||
RDIM_Unit *unit = &n->v[n->count];
|
||||
unit->chunk = n;
|
||||
n->count += 1;
|
||||
list->total_count += 1;
|
||||
return unit;
|
||||
}
|
||||
|
||||
RDI_PROC void
|
||||
rdim_unit_chunk_list_push_array(RDIM_Arena *arena, RDIM_UnitChunkList *list, RDIM_UnitArray *array)
|
||||
RDI_PROC RDI_U64
|
||||
rdim_idx_from_unit(RDIM_Unit *unit)
|
||||
{
|
||||
RDIM_UnitChunkNode *n = rdim_push_array(arena, RDIM_UnitChunkNode, 1);
|
||||
RDIM_SLLQueuePush(list->first, list->last, n);
|
||||
n->count = array->count;
|
||||
n->cap = array->count;
|
||||
n->v = array->v;
|
||||
list->total_count += n->count;
|
||||
list->chunk_count += 1;
|
||||
RDI_U64 idx = 0;
|
||||
if(unit != 0 && unit->chunk != 0)
|
||||
{
|
||||
idx = unit->chunk->base_idx + (unit - unit->chunk->v);
|
||||
}
|
||||
return idx;
|
||||
}
|
||||
|
||||
RDI_PROC void
|
||||
rdim_unit_chunk_list_concat_in_place(RDIM_UnitChunkList *dst, RDIM_UnitChunkList *to_push)
|
||||
{
|
||||
for(RDIM_UnitChunkNode *n = to_push->first; n != 0; n = n->next)
|
||||
{
|
||||
n->base_idx += dst->total_count;
|
||||
}
|
||||
if(dst->last != 0 && to_push->first != 0)
|
||||
{
|
||||
dst->last->next = to_push->first;
|
||||
@@ -500,21 +505,6 @@ rdim_line_sequence_list_push(RDIM_Arena *arena, RDIM_LineSequenceList *list)
|
||||
return &n->v;
|
||||
}
|
||||
|
||||
RDI_PROC RDIM_UnitArray
|
||||
rdim_unit_array_from_chunk_list(RDIM_Arena *arena, RDIM_UnitChunkList *list)
|
||||
{
|
||||
RDIM_UnitArray array = {0};
|
||||
array.count = list->total_count;
|
||||
array.v = rdim_push_array(arena, RDIM_Unit, array.count);
|
||||
U64 idx = 0;
|
||||
for(RDIM_UnitChunkNode *n = list->first; n != 0; n = n->next)
|
||||
{
|
||||
rdim_memcpy(array.v+idx, n->v, sizeof(RDIM_Unit)*n->count);
|
||||
idx += n->count;
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Type Info Building
|
||||
|
||||
@@ -526,31 +516,36 @@ rdim_type_chunk_list_push(RDIM_Arena *arena, RDIM_TypeChunkList *list, RDI_U64 c
|
||||
{
|
||||
n = rdim_push_array(arena, RDIM_TypeChunkNode, 1);
|
||||
n->cap = cap;
|
||||
n->base_idx = list->total_count;
|
||||
n->v = rdim_push_array(arena, RDIM_Type, n->cap);
|
||||
RDIM_SLLQueuePush(list->first, list->last, n);
|
||||
list->chunk_count += 1;
|
||||
}
|
||||
RDIM_Type *result = &n->v[n->count];
|
||||
result->chunk = n;
|
||||
n->count += 1;
|
||||
list->total_count += 1;
|
||||
return result;
|
||||
}
|
||||
|
||||
RDI_PROC void
|
||||
rdim_type_chunk_list_push_array(RDIM_Arena *arena, RDIM_TypeChunkList *list, RDIM_TypeArray *array)
|
||||
RDI_PROC RDI_U64
|
||||
rdim_idx_from_type(RDIM_Type *type)
|
||||
{
|
||||
RDIM_TypeChunkNode *n = rdim_push_array(arena, RDIM_TypeChunkNode, 1);
|
||||
RDIM_SLLQueuePush(list->first, list->last, n);
|
||||
n->count = array->count;
|
||||
n->cap = array->count;
|
||||
n->v = array->v;
|
||||
list->total_count += n->count;
|
||||
list->chunk_count += 1;
|
||||
RDI_U64 idx = 0;
|
||||
if(type != 0 && type->chunk != 0)
|
||||
{
|
||||
idx = type->chunk->base_idx + (type - type->chunk->v);
|
||||
}
|
||||
return idx;
|
||||
}
|
||||
|
||||
RDI_PROC void
|
||||
rdim_type_chunk_list_concat_in_place(RDIM_TypeChunkList *dst, RDIM_TypeChunkList *to_push)
|
||||
{
|
||||
for(RDIM_TypeChunkNode *n = to_push->first; n != 0; n = n->next)
|
||||
{
|
||||
n->base_idx += dst->total_count;
|
||||
}
|
||||
if(dst->last != 0 && to_push->first != 0)
|
||||
{
|
||||
dst->last->next = to_push->first;
|
||||
@@ -573,19 +568,36 @@ rdim_udt_chunk_list_push(RDIM_Arena *arena, RDIM_UDTChunkList *list, RDI_U64 cap
|
||||
{
|
||||
n = rdim_push_array(arena, RDIM_UDTChunkNode, 1);
|
||||
n->cap = cap;
|
||||
n->base_idx = list->total_count;
|
||||
n->v = rdim_push_array(arena, RDIM_UDT, n->cap);
|
||||
RDIM_SLLQueuePush(list->first, list->last, n);
|
||||
list->chunk_count += 1;
|
||||
}
|
||||
RDIM_UDT *result = &n->v[n->count];
|
||||
result->chunk = n;
|
||||
n->count += 1;
|
||||
list->total_count += 1;
|
||||
return result;
|
||||
}
|
||||
|
||||
RDI_PROC RDI_U64
|
||||
rdim_idx_from_udt(RDIM_UDT *udt)
|
||||
{
|
||||
RDI_U64 idx = 0;
|
||||
if(udt != 0 && udt->chunk != 0)
|
||||
{
|
||||
idx = udt->chunk->base_idx + (udt - udt->chunk->v);
|
||||
}
|
||||
return idx;
|
||||
}
|
||||
|
||||
RDI_PROC void
|
||||
rdim_udt_chunk_list_concat_in_place(RDIM_UDTChunkList *dst, RDIM_UDTChunkList *to_push)
|
||||
{
|
||||
for(RDIM_UDTChunkNode *n = to_push->first; n != 0; n = n->next)
|
||||
{
|
||||
n->base_idx += dst->total_count;
|
||||
}
|
||||
if(dst->last != 0 && to_push->first != 0)
|
||||
{
|
||||
dst->last->next = to_push->first;
|
||||
@@ -631,19 +643,36 @@ rdim_symbol_chunk_list_push(RDIM_Arena *arena, RDIM_SymbolChunkList *list, RDI_U
|
||||
{
|
||||
n = rdim_push_array(arena, RDIM_SymbolChunkNode, 1);
|
||||
n->cap = cap;
|
||||
n->base_idx = list->total_count;
|
||||
n->v = rdim_push_array(arena, RDIM_Symbol, n->cap);
|
||||
RDIM_SLLQueuePush(list->first, list->last, n);
|
||||
list->chunk_count += 1;
|
||||
}
|
||||
RDIM_Symbol *result = &n->v[n->count];
|
||||
result->chunk = n;
|
||||
n->count += 1;
|
||||
list->total_count += 1;
|
||||
return result;
|
||||
}
|
||||
|
||||
RDI_PROC RDI_U64
|
||||
rdim_idx_from_symbol(RDIM_Symbol *symbol)
|
||||
{
|
||||
RDI_U64 idx = 0;
|
||||
if(symbol != 0 && symbol->chunk != 0)
|
||||
{
|
||||
idx = symbol->chunk->base_idx + (symbol - symbol->chunk->v);
|
||||
}
|
||||
return idx;
|
||||
}
|
||||
|
||||
RDI_PROC void
|
||||
rdim_symbol_chunk_list_concat_in_place(RDIM_SymbolChunkList *dst, RDIM_SymbolChunkList *to_push)
|
||||
{
|
||||
for(RDIM_SymbolChunkNode *n = to_push->first; n != 0; n = n->next)
|
||||
{
|
||||
n->base_idx += dst->total_count;
|
||||
}
|
||||
if(dst->last != 0 && to_push->first != 0)
|
||||
{
|
||||
dst->last->next = to_push->first;
|
||||
@@ -671,19 +700,36 @@ rdim_scope_chunk_list_push(RDIM_Arena *arena, RDIM_ScopeChunkList *list, RDI_U64
|
||||
{
|
||||
n = rdim_push_array(arena, RDIM_ScopeChunkNode, 1);
|
||||
n->cap = cap;
|
||||
n->base_idx = list->total_count;
|
||||
n->v = rdim_push_array(arena, RDIM_Scope, n->cap);
|
||||
RDIM_SLLQueuePush(list->first, list->last, n);
|
||||
list->chunk_count += 1;
|
||||
}
|
||||
RDIM_Scope *result = &n->v[n->count];
|
||||
result->chunk = n;
|
||||
n->count += 1;
|
||||
list->total_count += 1;
|
||||
return result;
|
||||
}
|
||||
|
||||
RDI_PROC RDI_U64
|
||||
rdim_idx_from_scope(RDIM_Scope *scope)
|
||||
{
|
||||
RDI_U64 idx = 0;
|
||||
if(scope != 0 && scope->chunk != 0)
|
||||
{
|
||||
idx = scope->chunk->base_idx + (scope - scope->chunk->v);
|
||||
}
|
||||
return idx;
|
||||
}
|
||||
|
||||
RDI_PROC void
|
||||
rdim_scope_chunk_list_concat_in_place(RDIM_ScopeChunkList *dst, RDIM_ScopeChunkList *to_push)
|
||||
{
|
||||
for(RDIM_ScopeChunkNode *n = to_push->first; n != 0; n = n->next)
|
||||
{
|
||||
n->base_idx += dst->total_count;
|
||||
}
|
||||
if(dst->last != 0 && to_push->first != 0)
|
||||
{
|
||||
dst->last->next = to_push->first;
|
||||
@@ -906,7 +952,7 @@ rdim_bake_string(RDIM_Arena *arena, RDIM_BakeStringMap *map, RDIM_String8 string
|
||||
// rjf: no node -> make new node
|
||||
if(node == 0)
|
||||
{
|
||||
node = rdim_push_array_no_zero(arena, RDIM_BakeStringNode, 1);
|
||||
node = rdim_push_array(arena, RDIM_BakeStringNode, 1);
|
||||
node->string = rdim_str8_copy(arena, string);
|
||||
node->hash = hash;
|
||||
node->idx = map->count;
|
||||
@@ -1732,7 +1778,7 @@ rdim_bake(RDIM_Arena *arena, RDIM_BakeParams *params)
|
||||
//- rjf: fill constructed type node info
|
||||
else if(RDI_TypeKind_FirstConstructed <= dst->kind && dst->kind <= RDI_TypeKind_LastConstructed)
|
||||
{
|
||||
dst->constructed.direct_type_idx = src->direct_type ? src->direct_type->idx : 0;
|
||||
dst->constructed.direct_type_idx = (RDI_U32)rdim_idx_from_type(src->direct_type); // TODO(rjf): @u64_to_u32
|
||||
dst->constructed.count = src->count;
|
||||
if(dst->kind == RDI_TypeKind_Function || dst->kind == RDI_TypeKind_Method)
|
||||
{
|
||||
@@ -1740,7 +1786,7 @@ rdim_bake(RDIM_Arena *arena, RDIM_BakeParams *params)
|
||||
RDI_U32 *param_idx_run = rdim_push_array_no_zero(arena, RDI_U32, param_idx_run_count);
|
||||
for(RDI_U32 idx = 0; idx < param_idx_run_count; idx += 1)
|
||||
{
|
||||
param_idx_run[idx] = src->param_types[idx]->idx;
|
||||
param_idx_run[idx] = (RDI_U32)rdim_idx_from_type(src->param_types[idx]); // TODO(rjf): @u64_to_u32
|
||||
}
|
||||
dst->constructed.param_idx_run_first = rdim_bake_idx_run(arena, &idx_runs, param_idx_run, param_idx_run_count);
|
||||
}
|
||||
@@ -1754,8 +1800,8 @@ rdim_bake(RDIM_Arena *arena, RDIM_BakeParams *params)
|
||||
else if(RDI_TypeKind_FirstUserDefined <= dst->kind && dst->kind <= RDI_TypeKind_LastUserDefined)
|
||||
{
|
||||
dst->user_defined.name_string_idx = rdim_bake_string(arena, &strings, src->name);
|
||||
dst->user_defined.udt_idx = src->udt ? src->udt->idx : 0;
|
||||
dst->user_defined.direct_type_idx = src->direct_type ? src->direct_type->idx : 0;
|
||||
dst->user_defined.udt_idx = (RDI_U32)rdim_idx_from_udt(src->udt); // TODO(rjf): @u64_to_u32
|
||||
dst->user_defined.direct_type_idx = (RDI_U32)rdim_idx_from_type(src->direct_type); // TODO(rjf): @u64_to_u32
|
||||
}
|
||||
|
||||
//- rjf: fill bitfield info
|
||||
@@ -1787,7 +1833,7 @@ rdim_bake(RDIM_Arena *arena, RDIM_BakeParams *params)
|
||||
RDI_UDT *dst_udt = &udts[dst_udt_idx];
|
||||
|
||||
//- rjf: fill basics
|
||||
dst_udt->self_type_idx = src_udt->self_type ? src_udt->self_type->idx : 0;
|
||||
dst_udt->self_type_idx = (RDI_U32)rdim_idx_from_type(src_udt->self_type); // TODO(rjf): @u64_to_u32
|
||||
if(src_udt->source_path.size != 0)
|
||||
{
|
||||
RDIM_BakePathNode *path_node = rdim_bake_path_node_from_string(arena, &path_tree, src_udt->source_path);
|
||||
@@ -1809,7 +1855,7 @@ rdim_bake(RDIM_Arena *arena, RDIM_BakeParams *params)
|
||||
RDI_Member *dst_member = &members[dst_member_idx];
|
||||
dst_member->kind = src_member->kind;
|
||||
dst_member->name_string_idx = rdim_bake_string(arena, &strings, src_member->name);
|
||||
dst_member->type_idx = src_member->type ? src_member->type->idx : 0;
|
||||
dst_member->type_idx = (RDI_U32)rdim_idx_from_type(src_member->type); // TODO(rjf): @u64_to_u32
|
||||
dst_member->off = src_member->off;
|
||||
}
|
||||
}
|
||||
@@ -1865,7 +1911,7 @@ rdim_bake(RDIM_Arena *arena, RDIM_BakeParams *params)
|
||||
RDI_GlobalVariable *dst = &global_variables[dst_idx];
|
||||
dst->name_string_idx = rdim_bake_string(arena, &strings, src->name);
|
||||
dst->voff = src->offset;
|
||||
dst->type_idx = src->type ? src->type->idx : 0;;
|
||||
dst->type_idx = (RDI_U32)rdim_idx_from_type(src->type); // TODO(rjf): @u64_to_u32
|
||||
if(src->is_extern)
|
||||
{
|
||||
dst->link_flags |= RDI_LinkFlag_External;
|
||||
@@ -1873,12 +1919,12 @@ rdim_bake(RDIM_Arena *arena, RDIM_BakeParams *params)
|
||||
if(src->container_type != 0)
|
||||
{
|
||||
dst->link_flags |= RDI_LinkFlag_TypeScoped;
|
||||
dst->container_idx = src->container_type && src->container_type->udt ? src->container_type->udt->idx : 0;;
|
||||
dst->container_idx = src->container_type ? (RDI_U32)rdim_idx_from_udt(src->container_type->udt) : 0; // TODO(rjf): @u64_to_u32
|
||||
}
|
||||
else if(src->container_symbol != 0)
|
||||
{
|
||||
dst->link_flags |= RDI_LinkFlag_ProcScoped;
|
||||
dst->container_idx = src->container_symbol->idx;
|
||||
dst->container_idx = (RDI_U32)rdim_idx_from_symbol(src->container_symbol); // TODO(rjf): @u64_to_u32
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1899,7 +1945,7 @@ rdim_bake(RDIM_Arena *arena, RDIM_BakeParams *params)
|
||||
RDI_ThreadVariable *dst = &thread_variables[dst_idx];
|
||||
dst->name_string_idx = rdim_bake_string(arena, &strings, src->name);
|
||||
dst->tls_off = (RDI_U32)src->offset; // TODO(rjf): @u64_to_u32
|
||||
dst->type_idx = src->type ? src->type->idx : 0;;
|
||||
dst->type_idx = (RDI_U32)rdim_idx_from_type(src->type);
|
||||
if(src->is_extern)
|
||||
{
|
||||
dst->link_flags |= RDI_LinkFlag_External;
|
||||
@@ -1907,12 +1953,12 @@ rdim_bake(RDIM_Arena *arena, RDIM_BakeParams *params)
|
||||
if(src->container_type != 0)
|
||||
{
|
||||
dst->link_flags |= RDI_LinkFlag_TypeScoped;
|
||||
dst->container_idx = src->container_type && src->container_type->udt ? src->container_type->udt->idx : 0;;
|
||||
dst->container_idx = src->container_type ? (RDI_U32)rdim_idx_from_udt(src->container_type->udt) : 0; // TODO(rjf): @u64_to_u32
|
||||
}
|
||||
else if(src->container_symbol != 0)
|
||||
{
|
||||
dst->link_flags |= RDI_LinkFlag_ProcScoped;
|
||||
dst->container_idx = src->container_symbol->idx;
|
||||
dst->container_idx = (RDI_U32)rdim_idx_from_symbol(src->container_symbol); // TODO(rjf): @u64_to_u32
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1940,15 +1986,15 @@ rdim_bake(RDIM_Arena *arena, RDIM_BakeParams *params)
|
||||
if(src->container_type != 0)
|
||||
{
|
||||
dst->link_flags |= RDI_LinkFlag_TypeScoped;
|
||||
dst->container_idx = src->container_type && src->container_type->udt ? src->container_type->udt->idx : 0;;
|
||||
dst->container_idx = src->container_type ? (RDI_U32)rdim_idx_from_udt(src->container_type->udt) : 0; // TODO(rjf): @u64_to_u32
|
||||
}
|
||||
else if(src->container_symbol != 0)
|
||||
{
|
||||
dst->link_flags |= RDI_LinkFlag_ProcScoped;
|
||||
dst->container_idx = src->container_symbol->idx;
|
||||
dst->container_idx = (RDI_U32)rdim_idx_from_symbol(src->container_symbol); // TODO(rjf): @u64_to_u32
|
||||
}
|
||||
dst->type_idx = src->type ? src->type->idx : 0;
|
||||
dst->root_scope_idx = src->root_scope ? src->root_scope->idx : 0;
|
||||
dst->type_idx = (RDI_U32)rdim_idx_from_type(src->type); // TODO(rjf): @u64_to_u32
|
||||
dst->root_scope_idx = (RDI_U32)rdim_idx_from_scope(src->root_scope); // TODO(rjf): @u64_to_u32
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1977,7 +2023,7 @@ rdim_bake(RDIM_Arena *arena, RDIM_BakeParams *params)
|
||||
for(RDI_U64 chunk_idx = 0; chunk_idx < n->count; chunk_idx += 1)
|
||||
{
|
||||
RDIM_Symbol *global_var = &n->v[chunk_idx];
|
||||
RDI_U32 global_var_idx = global_var->idx;
|
||||
RDI_U32 global_var_idx = (RDI_U32)rdim_idx_from_symbol(global_var); // TODO(rjf): @u64_to_u32
|
||||
|
||||
RDI_U64 first = global_var->offset;
|
||||
RDI_U64 opl = first + global_var->type->byte_size;
|
||||
@@ -2146,17 +2192,17 @@ rdim_bake(RDIM_Arena *arena, RDIM_BakeParams *params)
|
||||
RDI_Local *dst_local = &locals[dst_local_idx];
|
||||
dst_local->kind = src_local->kind;
|
||||
dst_local->name_string_idx = rdim_bake_string(arena, &strings, src_local->name);
|
||||
dst_local->type_idx = src_local->type ? src_local->type->idx : 0;
|
||||
dst_local->type_idx = (RDI_U32)rdim_idx_from_type(src_local->type); // TODO(rjf): @u64_to_u32
|
||||
dst_local->location_first = (RDI_U32)location_block_idx_first; // TODO(rjf): @u64_to_u32
|
||||
dst_local->location_opl = (RDI_U32)location_block_idx_opl; // TODO(rjf): @u64_to_u32
|
||||
}
|
||||
RDI_U64 local_idx_opl = dst_local_idx;
|
||||
|
||||
//- rjf: fill scope
|
||||
dst_scope->proc_idx = src_scope->symbol? src_scope->symbol->idx :0;
|
||||
dst_scope->parent_scope_idx = src_scope->parent_scope? src_scope->parent_scope->idx :0;
|
||||
dst_scope->first_child_scope_idx = src_scope->first_child? src_scope->first_child->idx :0;
|
||||
dst_scope->next_sibling_scope_idx = src_scope->next_sibling? src_scope->next_sibling->idx :0;
|
||||
dst_scope->proc_idx = (RDI_U32)rdim_idx_from_symbol(src_scope->symbol); // TODO(rjf): @u64_to_u32
|
||||
dst_scope->parent_scope_idx = (RDI_U32)rdim_idx_from_scope(src_scope->parent_scope); // TODO(rjf): @u64_to_u32
|
||||
dst_scope->first_child_scope_idx = (RDI_U32)rdim_idx_from_scope(src_scope->first_child); // TODO(rjf): @u64_to_u32
|
||||
dst_scope->next_sibling_scope_idx = (RDI_U32)rdim_idx_from_scope(src_scope->next_sibling); // TODO(rjf): @u64_to_u32
|
||||
dst_scope->voff_range_first = (RDI_U32)voff_idx_first; // TODO(rjf): @u64_to_u32
|
||||
dst_scope->voff_range_opl = (RDI_U32)voff_idx_opl; // TODO(rjf): @u64_to_u32
|
||||
dst_scope->local_first = (RDI_U32)local_idx_first; // TODO(rjf): @u64_to_u32
|
||||
@@ -2196,7 +2242,7 @@ rdim_bake(RDIM_Arena *arena, RDIM_BakeParams *params)
|
||||
for(RDI_U64 chunk_idx = 0; chunk_idx < chunk_n->count; chunk_idx += 1)
|
||||
{
|
||||
RDIM_Scope *src_scope = &chunk_n->v[chunk_idx];
|
||||
RDI_U32 scope_idx = src_scope->idx;
|
||||
RDI_U32 scope_idx = (RDI_U32)rdim_idx_from_scope(src_scope); // TODO(rjf): @u64_to_u32
|
||||
for(RDIM_Rng1U64Node *n = 0; n != 0; n = n->next)
|
||||
{
|
||||
key_ptr->key = n->v.min;
|
||||
|
||||
@@ -479,6 +479,7 @@ struct RDIM_LineSequenceList
|
||||
typedef struct RDIM_Unit RDIM_Unit;
|
||||
struct RDIM_Unit
|
||||
{
|
||||
struct RDIM_UnitChunkNode *chunk;
|
||||
RDIM_String8 unit_name;
|
||||
RDIM_String8 compiler_name;
|
||||
RDIM_String8 source_file;
|
||||
@@ -497,6 +498,7 @@ struct RDIM_UnitChunkNode
|
||||
RDIM_Unit *v;
|
||||
RDI_U64 count;
|
||||
RDI_U64 cap;
|
||||
RDI_U64 base_idx;
|
||||
};
|
||||
|
||||
typedef struct RDIM_UnitChunkList RDIM_UnitChunkList;
|
||||
@@ -508,21 +510,14 @@ struct RDIM_UnitChunkList
|
||||
RDI_U64 total_count;
|
||||
};
|
||||
|
||||
typedef struct RDIM_UnitArray RDIM_UnitArray;
|
||||
struct RDIM_UnitArray
|
||||
{
|
||||
RDIM_Unit *v;
|
||||
RDI_U64 count;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Type System Node Types
|
||||
|
||||
typedef struct RDIM_Type RDIM_Type;
|
||||
struct RDIM_Type
|
||||
{
|
||||
struct RDIM_TypeChunkNode *chunk;
|
||||
RDI_TypeKind kind;
|
||||
RDI_U32 idx;
|
||||
RDI_U32 byte_size;
|
||||
RDI_U32 flags;
|
||||
RDI_U32 off;
|
||||
@@ -540,6 +535,7 @@ struct RDIM_TypeChunkNode
|
||||
RDIM_Type *v;
|
||||
RDI_U64 count;
|
||||
RDI_U64 cap;
|
||||
RDI_U64 base_idx;
|
||||
};
|
||||
|
||||
typedef struct RDIM_TypeChunkList RDIM_TypeChunkList;
|
||||
@@ -582,7 +578,7 @@ struct RDIM_UDTEnumVal
|
||||
typedef struct RDIM_UDT RDIM_UDT;
|
||||
struct RDIM_UDT
|
||||
{
|
||||
RDI_U32 idx;
|
||||
struct RDIM_UDTChunkNode *chunk;
|
||||
RDIM_Type *self_type;
|
||||
RDIM_UDTMember *first_member;
|
||||
RDIM_UDTMember *last_member;
|
||||
@@ -602,6 +598,7 @@ struct RDIM_UDTChunkNode
|
||||
RDIM_UDT *v;
|
||||
RDI_U64 count;
|
||||
RDI_U64 cap;
|
||||
RDI_U64 base_idx;
|
||||
};
|
||||
|
||||
typedef struct RDIM_UDTChunkList RDIM_UDTChunkList;
|
||||
@@ -677,8 +674,8 @@ RDIM_SymbolKind;
|
||||
typedef struct RDIM_Symbol RDIM_Symbol;
|
||||
struct RDIM_Symbol
|
||||
{
|
||||
struct RDIM_SymbolChunkNode *chunk;
|
||||
RDIM_SymbolKind kind;
|
||||
RDI_U32 idx;
|
||||
RDI_S32 is_extern;
|
||||
RDIM_String8 name;
|
||||
RDIM_String8 link_name;
|
||||
@@ -696,6 +693,7 @@ struct RDIM_SymbolChunkNode
|
||||
RDIM_Symbol *v;
|
||||
RDI_U64 count;
|
||||
RDI_U64 cap;
|
||||
RDI_U64 base_idx;
|
||||
};
|
||||
|
||||
typedef struct RDIM_SymbolChunkList RDIM_SymbolChunkList;
|
||||
@@ -723,6 +721,7 @@ struct RDIM_Local
|
||||
typedef struct RDIM_Scope RDIM_Scope;
|
||||
struct RDIM_Scope
|
||||
{
|
||||
struct RDIM_ScopeChunkNode *chunk;
|
||||
RDIM_Symbol *symbol;
|
||||
RDIM_Scope *parent_scope;
|
||||
RDIM_Scope *first_child;
|
||||
@@ -732,7 +731,6 @@ struct RDIM_Scope
|
||||
RDIM_Local *first_local;
|
||||
RDIM_Local *last_local;
|
||||
RDI_U32 local_count;
|
||||
RDI_U32 idx;
|
||||
};
|
||||
|
||||
typedef struct RDIM_ScopeChunkNode RDIM_ScopeChunkNode;
|
||||
@@ -742,6 +740,7 @@ struct RDIM_ScopeChunkNode
|
||||
RDIM_Scope *v;
|
||||
RDI_U64 count;
|
||||
RDI_U64 cap;
|
||||
RDI_U64 base_idx;
|
||||
};
|
||||
|
||||
typedef struct RDIM_ScopeChunkList RDIM_ScopeChunkList;
|
||||
@@ -1365,19 +1364,19 @@ RDI_PROC RDIM_BinarySection *rdim_binary_section_list_push(RDIM_Arena *arena, RD
|
||||
////////////////////////////////
|
||||
//~ rjf: Unit Info Building
|
||||
|
||||
RDI_PROC RDIM_Unit *rdim_unit_chunk_list_push(RDIM_Arena *arena, RDIM_UnitChunkList *list);
|
||||
RDI_PROC void rdim_unit_chunk_list_push_array(RDIM_Arena *arena, RDIM_UnitChunkList *list, RDIM_UnitArray *array);
|
||||
RDI_PROC RDIM_Unit *rdim_unit_chunk_list_push(RDIM_Arena *arena, RDIM_UnitChunkList *list, RDI_U64 cap);
|
||||
RDI_PROC RDI_U64 rdim_idx_from_unit(RDIM_Unit *unit);
|
||||
RDI_PROC void rdim_unit_chunk_list_concat_in_place(RDIM_UnitChunkList *dst, RDIM_UnitChunkList *to_push);
|
||||
RDI_PROC RDIM_LineSequence *rdim_line_sequence_list_push(RDIM_Arena *arena, RDIM_LineSequenceList *list);
|
||||
RDI_PROC RDIM_UnitArray rdim_unit_array_from_chunk_list(RDIM_Arena *arena, RDIM_UnitChunkList *list);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Type Info & UDT Building
|
||||
|
||||
RDI_PROC RDIM_Type *rdim_type_chunk_list_push(RDIM_Arena *arena, RDIM_TypeChunkList *list, RDI_U64 cap);
|
||||
RDI_PROC void rdim_type_chunk_list_push_array(RDIM_Arena *arena, RDIM_TypeChunkList *list, RDIM_TypeArray *array);
|
||||
RDI_PROC RDI_U64 rdim_idx_from_type(RDIM_Type *type);
|
||||
RDI_PROC void rdim_type_chunk_list_concat_in_place(RDIM_TypeChunkList *dst, RDIM_TypeChunkList *to_push);
|
||||
RDI_PROC RDIM_UDT *rdim_udt_chunk_list_push(RDIM_Arena *arena, RDIM_UDTChunkList *list, RDI_U64 cap);
|
||||
RDI_PROC RDI_U64 rdim_idx_from_udt(RDIM_UDT *udt);
|
||||
RDI_PROC void rdim_udt_chunk_list_concat_in_place(RDIM_UDTChunkList *dst, RDIM_UDTChunkList *to_push);
|
||||
RDI_PROC RDIM_UDTMember *rdim_udt_push_member(RDIM_Arena *arena, RDIM_UDTChunkList *list, RDIM_UDT *udt);
|
||||
RDI_PROC RDIM_UDTEnumVal *rdim_udt_push_enum_val(RDIM_Arena *arena, RDIM_UDTChunkList *list, RDIM_UDT *udt);
|
||||
@@ -1386,6 +1385,7 @@ RDI_PROC RDIM_UDTEnumVal *rdim_udt_push_enum_val(RDIM_Arena *arena, RDIM_UDTChun
|
||||
//~ rjf: Symbol Info Building
|
||||
|
||||
RDI_PROC RDIM_Symbol *rdim_symbol_chunk_list_push(RDIM_Arena *arena, RDIM_SymbolChunkList *list, RDI_U64 cap);
|
||||
RDI_PROC RDI_U64 rdim_idx_from_symbol(RDIM_Symbol *symbol);
|
||||
RDI_PROC void rdim_symbol_chunk_list_concat_in_place(RDIM_SymbolChunkList *dst, RDIM_SymbolChunkList *to_push);
|
||||
|
||||
////////////////////////////////
|
||||
@@ -1393,6 +1393,7 @@ RDI_PROC void rdim_symbol_chunk_list_concat_in_place(RDIM_SymbolChunkList *dst,
|
||||
|
||||
//- rjf: scopes
|
||||
RDI_PROC RDIM_Scope *rdim_scope_chunk_list_push(RDIM_Arena *arena, RDIM_ScopeChunkList *list, RDI_U64 cap);
|
||||
RDI_PROC RDI_U64 rdim_idx_from_scope(RDIM_Scope *scope);
|
||||
RDI_PROC void rdim_scope_chunk_list_concat_in_place(RDIM_ScopeChunkList *dst, RDIM_ScopeChunkList *to_push);
|
||||
RDI_PROC void rdim_scope_push_voff_range(RDIM_Arena *arena, RDIM_ScopeChunkList *list, RDIM_Scope *scope, RDIM_Rng1U64 range);
|
||||
RDI_PROC RDIM_Local *rdim_scope_push_local(RDIM_Arena *arena, RDIM_ScopeChunkList *scopes, RDIM_Scope *scope);
|
||||
|
||||
@@ -3744,12 +3744,10 @@ p2r_convert(Arena *arena, P2R_ConvertIn *in)
|
||||
//////////////////////////////////////////////////////////////
|
||||
//- rjf: build unit array
|
||||
//
|
||||
RDIM_UnitArray units = {0};
|
||||
RDIM_UnitChunkList units = {0};
|
||||
ProfScope("build unit array")
|
||||
{
|
||||
//- rjf: allocate
|
||||
units.count = comp_unit_count;
|
||||
units.v = push_array(arena, RDIM_Unit, units.count);
|
||||
U64 units_chunk_cap = comp_unit_count;
|
||||
|
||||
//- rjf: pass 1: fill basic per-unit info & line info
|
||||
for(U64 comp_unit_idx = 0; comp_unit_idx < comp_unit_count; comp_unit_idx += 1)
|
||||
@@ -3777,8 +3775,8 @@ p2r_convert(Arena *arena, P2R_ConvertIn *in)
|
||||
MemoryZeroStruct(&obj_name);
|
||||
}
|
||||
|
||||
//- rjf: fill basic output unit info
|
||||
RDIM_Unit *dst_unit = &units.v[comp_unit_idx];
|
||||
//- rjf: build unit
|
||||
RDIM_Unit *dst_unit = rdim_unit_chunk_list_push(arena, &units, units_chunk_cap);
|
||||
dst_unit->unit_name = unit_name;
|
||||
dst_unit->compiler_name = pdb_unit_sym->info.compiler_name;
|
||||
dst_unit->object_file = obj_name;
|
||||
@@ -3815,7 +3813,7 @@ p2r_convert(Arena *arena, P2R_ConvertIn *in)
|
||||
{
|
||||
if(contrib_ptr->mod < comp_unit_count)
|
||||
{
|
||||
RDIM_Unit *unit = &units.v[contrib_ptr->mod];
|
||||
RDIM_Unit *unit = &units.first->v[contrib_ptr->mod];
|
||||
RDIM_Rng1U64 range = {contrib_ptr->voff_first, contrib_ptr->voff_opl};
|
||||
rdim_rng1u64_list_push(arena, &unit->voff_ranges, range);
|
||||
}
|
||||
@@ -3991,17 +3989,17 @@ p2r_convert(Arena *arena, P2R_ConvertIn *in)
|
||||
};
|
||||
P2R_TypeIdRevisitTask *first_itype_revisit_task = 0;
|
||||
P2R_TypeIdRevisitTask *last_itype_revisit_task = 0;
|
||||
RDIM_TypeArray itype_types = {0}; // root type for per-TPI-itype
|
||||
RDIM_TypeChunkList extra_types = {0}; // extra supplementary types we build, which do not have any itypes
|
||||
RDIM_TypeChunkList itype_types = {0}; // fixed chunk list for itypes
|
||||
RDIM_TypeChunkList extra_types = {0}; // extra constructed types, for types which don't correspond to the PDB
|
||||
ProfScope("types pass 2: construct all root/stub types from TPI")
|
||||
{
|
||||
RDI_U64 itype_types_cap = (U64)(itype_opl-itype_first);
|
||||
RDI_U64 extra_types_chunk_cap = 1024;
|
||||
itype_types.count = (U64)(itype_opl-itype_first);
|
||||
itype_types.v = push_array(arena, RDIM_Type, itype_types.count);
|
||||
#define p2r_type_ptr_from_itype(itype) ((itype_first <= (itype) && (itype) < itype_opl) ? (&itype_types.v[(type_fwd_map[(itype)-itype_first] ? type_fwd_map[(itype)-itype_first] : (itype))-itype_first]) : 0)
|
||||
for(CV_TypeId itype = itype_first; itype < itype_opl; itype += 1)
|
||||
rdim_type_chunk_list_push(arena, &itype_types, itype_types_cap);
|
||||
#define p2r_type_ptr_from_itype(itype) ((itype_first <= (itype) && (itype) < itype_opl) ? (&itype_types.first->v[(type_fwd_map[(itype)-itype_first] ? type_fwd_map[(itype)-itype_first] : (itype))-itype_first]) : 0)
|
||||
for(CV_TypeId itype = itype_first+1; itype < itype_opl; itype += 1)
|
||||
{
|
||||
RDIM_Type *dst_type = &itype_types.v[itype-itype_first];
|
||||
RDIM_Type *dst_type = rdim_type_chunk_list_push(arena, &itype_types, itype_types_cap);
|
||||
B32 itype_is_basic = (itype < 0x1000);
|
||||
|
||||
//////////////////////////
|
||||
@@ -4014,7 +4012,7 @@ p2r_convert(Arena *arena, P2R_ConvertIn *in)
|
||||
CV_BasicType cv_basic_type_code = CV_BasicTypeFromTypeId(itype);
|
||||
|
||||
// rjf: get basic type slot, fill if unfilled
|
||||
RDIM_Type *basic_type = &itype_types.v[cv_basic_type_code-itype_first];
|
||||
RDIM_Type *basic_type = &itype_types.first->v[cv_basic_type_code-itype_first];
|
||||
if(basic_type->kind == RDI_TypeKind_NULL)
|
||||
{
|
||||
RDI_TypeKind type_kind = rdi_type_kind_from_cv_basic_type(cv_basic_type_code);
|
||||
@@ -4032,7 +4030,6 @@ p2r_convert(Arena *arena, P2R_ConvertIn *in)
|
||||
if(cv_basic_ptr_kind != 0)
|
||||
{
|
||||
dst_type->kind = RDI_TypeKind_Ptr;
|
||||
dst_type->idx = (RDI_U32)(itype-itype_first);
|
||||
dst_type->byte_size = arch_addr_size;
|
||||
dst_type->direct_type = basic_type;
|
||||
}
|
||||
@@ -4148,7 +4145,6 @@ p2r_convert(Arena *arena, P2R_ConvertIn *in)
|
||||
// rjf: fill type
|
||||
dst_type->kind = RDI_TypeKind_Function;
|
||||
dst_type->byte_size = arch_addr_size;
|
||||
dst_type->count = procedure->arg_count;
|
||||
dst_type->direct_type = ret_type;
|
||||
|
||||
// rjf: push revisit task for parameters
|
||||
@@ -4171,7 +4167,6 @@ p2r_convert(Arena *arena, P2R_ConvertIn *in)
|
||||
// rjf: fill type
|
||||
dst_type->kind = (mfunction->this_itype != 0) ? RDI_TypeKind_Method : RDI_TypeKind_Function;
|
||||
dst_type->byte_size = arch_addr_size;
|
||||
dst_type->count = mfunction->arg_count;
|
||||
dst_type->direct_type = ret_type;
|
||||
|
||||
// rjf: push revisit task for parameters/this
|
||||
@@ -4389,7 +4384,7 @@ p2r_convert(Arena *arena, P2R_ConvertIn *in)
|
||||
ProfScope("types pass 3: attach cross-itype-relationship data to all types, build UDTs")
|
||||
{
|
||||
RDI_U64 udts_chunk_cap = 1024;
|
||||
#define p2r_type_ptr_from_itype(itype) ((itype_first <= (itype) && (itype) < itype_opl) ? (&itype_types.v[(type_fwd_map[(itype)-itype_first] ? type_fwd_map[(itype)-itype_first] : (itype))-itype_first]) : 0)
|
||||
#define p2r_type_ptr_from_itype(itype) ((itype_first <= (itype) && (itype) < itype_opl) ? (&itype_types.first->v[(type_fwd_map[(itype)-itype_first] ? type_fwd_map[(itype)-itype_first] : (itype))-itype_first]) : 0)
|
||||
for(P2R_TypeIdRevisitTask *task = first_itype_revisit_task; task != 0; task = task->next)
|
||||
{
|
||||
RDIM_Type *dst_type = task->base_type;
|
||||
@@ -5095,7 +5090,7 @@ p2r_convert(Arena *arena, P2R_ConvertIn *in)
|
||||
RDIM_ScopeChunkList all_scopes = {0};
|
||||
ProfScope("produce symbols from all sym streams")
|
||||
{
|
||||
#define p2r_type_ptr_from_itype(itype) ((itype_first <= (itype) && (itype) < itype_opl) ? (&itype_types.v[(type_fwd_map[(itype)-itype_first] ? type_fwd_map[(itype)-itype_first] : (itype))-itype_first]) : 0)
|
||||
#define p2r_type_ptr_from_itype(itype) ((itype_first <= (itype) && (itype) < itype_opl) ? (&itype_types.first->v[(type_fwd_map[(itype)-itype_first] ? type_fwd_map[(itype)-itype_first] : (itype))-itype_first]) : 0)
|
||||
|
||||
////////////////////////////
|
||||
//- rjf: produce array of all symbol streams
|
||||
@@ -5827,8 +5822,8 @@ p2r_convert(Arena *arena, P2R_ConvertIn *in)
|
||||
{
|
||||
out->top_level_info = top_level_info;
|
||||
out->binary_sections = binary_sections;
|
||||
rdim_unit_chunk_list_push_array(arena, &out->units, &units);
|
||||
rdim_type_chunk_list_push_array(arena, &out->types, &itype_types);
|
||||
out->units = units;
|
||||
rdim_type_chunk_list_concat_in_place(&out->types, &itype_types);
|
||||
rdim_type_chunk_list_concat_in_place(&out->types, &extra_types);
|
||||
out->udts = udts;
|
||||
out->global_variables = all_global_variables;
|
||||
|
||||
Reference in New Issue
Block a user