-
-static void push_function(LttvTracefileState *tfs, guint64 funcptr)
-{
- guint64 *new_func;
-
- LttvTraceState *ts = (LttvTraceState*)tfs->parent.t_context;
- guint cpu = tfs->cpu;
- LttvProcessState *process = ts->running_process[cpu];
-
- guint depth = process->user_stack->len;
-
- process->user_stack =
- g_array_set_size(process->user_stack, depth + 1);
-
- new_func = &g_array_index(process->user_stack, guint64, depth);
- *new_func = funcptr;
- process->current_function = funcptr;
-}
-
-static void pop_function(LttvTracefileState *tfs, guint64 funcptr)
-{
- guint cpu = tfs->cpu;
- LttvTraceState *ts = (LttvTraceState*)tfs->parent.t_context;
- LttvProcessState *process = ts->running_process[cpu];
-
- if(process->current_function != funcptr){
- g_info("Different functions (%lu.%09lu): ignore it\n",
- tfs->parent.timestamp.tv_sec, tfs->parent.timestamp.tv_nsec);
- g_info("process state has %" PRIu64 " when pop_function is %" PRIu64 "\n",
- process->current_function, funcptr);
- g_info("{ %u, %u, %s, %s, %s }\n",
- process->pid,
- process->ppid,
- g_quark_to_string(process->name),
- g_quark_to_string(process->brand),
- g_quark_to_string(process->state->s));
- return;
- }
- guint depth = process->user_stack->len;
-
- if(depth == 0){
- g_info("Trying to pop last function on stack (%lu.%09lu): ignore it\n",
- tfs->parent.timestamp.tv_sec, tfs->parent.timestamp.tv_nsec);
- return;
- }
-
- process->user_stack =
- g_array_set_size(process->user_stack, depth - 1);
- process->current_function =
- g_array_index(process->user_stack, guint64, depth - 2);
-}
-
-
-static gboolean function_entry(void *hook_data, void *call_data)
-{
- LttvTracefileState *s = (LttvTracefileState *)call_data;
- LttEvent *e = ltt_tracefile_get_event(s->parent.tf);
- //guint8 ev_id = ltt_event_eventtype_id(e);
- LttvTraceHook *th = (LttvTraceHook *)hook_data;
- struct marker_field *f = lttv_trace_get_hook_field(th, 0);
- guint64 funcptr = ltt_event_get_long_unsigned(e, f);
-
- push_function(s, funcptr);
- return FALSE;
-}
-
-static gboolean function_exit(void *hook_data, void *call_data)
-{
- LttvTracefileState *s = (LttvTracefileState *)call_data;
- LttEvent *e = ltt_tracefile_get_event(s->parent.tf);
- //guint8 ev_id = ltt_event_eventtype_id(e);
- LttvTraceHook *th = (LttvTraceHook *)hook_data;
- struct marker_field *f = lttv_trace_get_hook_field(th, 0);
- guint64 funcptr = ltt_event_get_long_unsigned(e, f);
-
- pop_function(s, funcptr);
- return FALSE;
-}
-