mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-07-17 23:01:25 -07:00
first pass at call stack tree evaluation
This commit is contained in:
@@ -188,6 +188,22 @@ ctrl_handle_list_copy(Arena *arena, CTRL_HandleList *src)
|
||||
return dst;
|
||||
}
|
||||
|
||||
internal CTRL_HandleArray
|
||||
ctrl_handle_array_from_list(Arena *arena, CTRL_HandleList *src)
|
||||
{
|
||||
CTRL_HandleArray array = {0};
|
||||
array.count = src->count;
|
||||
array.v = push_array_no_zero(arena, CTRL_Handle, array.count);
|
||||
{
|
||||
U64 idx = 0;
|
||||
for(CTRL_HandleNode *n = src->first; n != 0; n = n->next, idx += 1)
|
||||
{
|
||||
array.v[idx] = n->v;
|
||||
}
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
internal String8
|
||||
ctrl_string_from_handle(Arena *arena, CTRL_Handle handle)
|
||||
{
|
||||
@@ -1543,6 +1559,9 @@ ctrl_init(void)
|
||||
ctrl_state->module_image_info_cache.stripes[idx].arena = arena_alloc();
|
||||
ctrl_state->module_image_info_cache.stripes[idx].rw_mutex = os_rw_mutex_alloc();
|
||||
}
|
||||
ctrl_state->call_stack_tree_cache.tree.root = &ctrl_call_stack_tree_node_nil;
|
||||
ctrl_state->call_stack_tree_cache.cv = os_condition_variable_alloc();
|
||||
ctrl_state->call_stack_tree_cache.rw_mutex = os_rw_mutex_alloc();
|
||||
ctrl_state->u2c_ring_size = KB(64);
|
||||
ctrl_state->u2c_ring_base = push_array_no_zero(arena, U8, ctrl_state->u2c_ring_size);
|
||||
ctrl_state->u2c_ring_mutex = os_mutex_alloc();
|
||||
@@ -7358,9 +7377,14 @@ ASYNC_WORK_DEF(ctrl_call_stack_tree_build_work)
|
||||
if(pre_mem_gen == post_mem_gen &&
|
||||
pre_reg_gen == post_reg_gen)
|
||||
{
|
||||
U64 id_gen = 0;
|
||||
arena = arena_alloc();
|
||||
tree.root = push_array(arena, CTRL_CallStackTreeNode, 1);
|
||||
MemoryCopyStruct(tree.root, &ctrl_call_stack_tree_node_nil);
|
||||
tree.root->id = id_gen;
|
||||
tree.slots_count = Max(1, threads_count);
|
||||
tree.slots = push_array(arena, CTRL_CallStackTreeNode *, tree.slots_count);
|
||||
id_gen += 1;
|
||||
for EachIndex(thread_idx, threads_count)
|
||||
{
|
||||
CTRL_Handle thread = threads[thread_idx];
|
||||
@@ -7385,6 +7409,9 @@ ASYNC_WORK_DEF(ctrl_call_stack_tree_build_work)
|
||||
{
|
||||
next_node = push_array(arena, CTRL_CallStackTreeNode, 1);
|
||||
MemoryCopyStruct(next_node, &ctrl_call_stack_tree_node_nil);
|
||||
next_node->id = id_gen;
|
||||
SLLStackPush_N(tree.slots[next_node->id%tree.slots_count], next_node, hash_next);
|
||||
id_gen += 1;
|
||||
SLLQueuePush_NZ(&ctrl_call_stack_tree_node_nil, thread_node->first, thread_node->last, next_node, next);
|
||||
next_node->parent = thread_node;
|
||||
thread_node->child_count += 1;
|
||||
|
||||
@@ -84,6 +84,13 @@ struct CTRL_HandleList
|
||||
U64 count;
|
||||
};
|
||||
|
||||
typedef struct CTRL_HandleArray CTRL_HandleArray;
|
||||
struct CTRL_HandleArray
|
||||
{
|
||||
CTRL_Handle *v;
|
||||
U64 count;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Generated Code
|
||||
|
||||
@@ -277,11 +284,13 @@ struct CTRL_CallStack
|
||||
typedef struct CTRL_CallStackTreeNode CTRL_CallStackTreeNode;
|
||||
struct CTRL_CallStackTreeNode
|
||||
{
|
||||
CTRL_CallStackTreeNode *hash_next;
|
||||
CTRL_CallStackTreeNode *first;
|
||||
CTRL_CallStackTreeNode *last;
|
||||
CTRL_CallStackTreeNode *next;
|
||||
CTRL_CallStackTreeNode *parent;
|
||||
U64 child_count;
|
||||
U64 id;
|
||||
CTRL_Handle process;
|
||||
U64 vaddr;
|
||||
U64 depth;
|
||||
@@ -293,6 +302,8 @@ typedef struct CTRL_CallStackTree CTRL_CallStackTree;
|
||||
struct CTRL_CallStackTree
|
||||
{
|
||||
CTRL_CallStackTreeNode *root;
|
||||
U64 slots_count;
|
||||
CTRL_CallStackTreeNode **slots;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
@@ -911,6 +922,7 @@ read_only global CTRL_Entity ctrl_entity_nil =
|
||||
};
|
||||
read_only global CTRL_CallStackTreeNode ctrl_call_stack_tree_node_nil =
|
||||
{
|
||||
0,
|
||||
&ctrl_call_stack_tree_node_nil,
|
||||
&ctrl_call_stack_tree_node_nil,
|
||||
&ctrl_call_stack_tree_node_nil,
|
||||
@@ -945,6 +957,7 @@ internal CTRL_Handle ctrl_handle_make(CTRL_MachineID machine_id, DMN_Handle dmn_
|
||||
internal B32 ctrl_handle_match(CTRL_Handle a, CTRL_Handle b);
|
||||
internal void ctrl_handle_list_push(Arena *arena, CTRL_HandleList *list, CTRL_Handle *pair);
|
||||
internal CTRL_HandleList ctrl_handle_list_copy(Arena *arena, CTRL_HandleList *src);
|
||||
internal CTRL_HandleArray ctrl_handle_array_from_list(Arena *arena, CTRL_HandleList *src);
|
||||
internal String8 ctrl_string_from_handle(Arena *arena, CTRL_Handle handle);
|
||||
internal CTRL_Handle ctrl_handle_from_string(String8 string);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user