diff --git a/src/rvprof_stats.c b/src/rvprof_stats.c new file mode 100644 index 0000000..9126f40 --- /dev/null +++ b/src/rvprof_stats.c @@ -0,0 +1,73 @@ +#include "rvprof_internal.h" + +// get function id for given name / caller combination or create new one +int rvprof_stats_find_or_create_function( const char* name, const char* caller){ + if(g_rvprof.config.merge_regions){ + // ignore caller when merging stacks + for (int i=0; iname, name, MAX_NAME_LEN-1); + stats->name[MAX_NAME_LEN-1] = '\0'; + if(!g_rvprof.config.merge_regions){ + strncpy(stats->caller, caller, MAX_NAME_LEN-1); + stats->caller[MAX_NAME_LEN-1] = '\0'; + } + + return idx; +} + +// get call stack or create it +int rvprof_stats_get_or_create_stack_id(void) { + static char call_stack[4096]; + call_stack [0] = '\0'; + + for (int i=0; i<=g_rvprof.stack_ptr; i++){ + if (i>0){ + strcat(call_stack, "<"); + } + strcat(call_stack, g_rvprof.regions.data[i].name); + } + + // check if this stack exists already + for (int i=0; i