From 3319fa484c0c3012fa8b1763019769cd60bdc41e Mon Sep 17 00:00:00 2001 From: Oleg Hahm Date: Fri, 6 Dec 2013 10:31:20 +0100 Subject: [PATCH] remove profiler from lpc_common The profiling functions (gcc -finstrument_function) should be better defined within the application. --- cpu/lpc_common/profiling.c | 134 ------------------------------------- 1 file changed, 134 deletions(-) delete mode 100644 cpu/lpc_common/profiling.c diff --git a/cpu/lpc_common/profiling.c b/cpu/lpc_common/profiling.c deleted file mode 100644 index ad438f6705..0000000000 --- a/cpu/lpc_common/profiling.c +++ /dev/null @@ -1,134 +0,0 @@ -#include -#include -#include -#include - -#define MAX_TRACED_FUNCTIONS (256) -#define PROFILING_STACK_SIZE (256) - -typedef struct { - uint32_t address; - uint32_t time; - uint32_t start_time; - double consumption; - double consumption_start; - uint16_t counter; -} profiling_info_t; - -static profiling_info_t functions[MAX_TRACED_FUNCTIONS]; -static uint16_t profiling_stack[PROFILING_STACK_SIZE]; -static uint16_t profiling_sp = 0; -static uint8_t function_pending = 0; - -static uint16_t traced_functions = 0; -static uint8_t profiling = 0; - -void __attribute__((__no_instrument_function__)) profiling_init(void) -{ - uint16_t i; - - for (i = 0; i < MAX_TRACED_FUNCTIONS; i++) { - functions[i].address = 0; - functions[i].time = 0; - functions[i].consumption = 0; - functions[i].counter = 0; - } - - for (i = 0; i < PROFILING_STACK_SIZE; i++) { - profiling_stack[i] = 0; - } - - ltc4150_start(); - - profiling = 1; -} - -static int16_t __attribute__((__no_instrument_function__)) get_function_index(uint32_t addr) -{ - uint16_t i; - - for (i = 0; i < MAX_TRACED_FUNCTIONS; i++) { - if (functions[i].address == addr) { - return i; - } - } - - return -1; -} - -void __attribute__((__no_instrument_function__)) __cyg_profile_func_enter(void *func, void *caller) -{ - (void) caller; - - if (!profiling) { - return; - } - - int16_t idx = get_function_index((uint32_t) func); - - /* if function is not yet on traced */ - if ((idx < 0) && (traced_functions < MAX_TRACED_FUNCTIONS)) { - idx = traced_functions++; - functions[idx].address = (uint32_t) func; - } - /* maximu of traceable functions reached */ - else if (idx < 0) { - return; - } - - /* check if a profiled function is pending */ - if (function_pending && (profiling_stack[profiling_sp] != idx)) { - functions[idx].time += T0TC - functions[idx].start_time; - //functions[idx].consumption += ltc4150_get_intcount() - functions[idx].consumption_start; - functions[idx].consumption += ltc4150_get_total_mAh() - functions[idx].consumption_start; - } - - /* push current function on profile stack */ - profiling_sp++; - profiling_stack[profiling_sp] = idx; - - /* save stats for current function */ - functions[idx].start_time = T0TC; - functions[idx].counter++; - functions[idx].consumption_start = ltc4150_get_total_mAh(); - // functions[idx].consumption_start = ltc4150_get_intcount(); -} - -void __attribute__((__no_instrument_function__)) __cyg_profile_func_exit(void *func, void *caller) -{ - (void) caller; - if (!profiling) { - return; - } - - int16_t idx = get_function_index((uint32_t) func); - - if (idx >= 0) { - functions[idx].time += T0TC - functions[idx].start_time; - //functions[idx].consumption += ltc4150_get_intcount() - functions[idx].consumption_start; - functions[idx].consumption += ltc4150_get_total_mAh() - functions[idx].consumption_start; - } - - /* reset pending flag */ - function_pending = 0; - - /* if another function is pending */ - if (profiling_sp) { - if (--profiling_sp) { - functions[profiling_stack[profiling_sp]].start_time = T0TC; - functions[profiling_stack[profiling_sp]].consumption_start = ltc4150_get_total_mAh(); - } - } -} - -void profiling_stats(void) -{ - uint16_t i; - - for (i = 0; i < traced_functions; i++) { - // printf("Function @%04lX was running %u times for %lu ticks, consuming %li ltc-ticks\n", functions[i].address, functions[i].counter, functions[i].time, functions[i].consumption); - printf("Function @%04lX was running %u times for %lu ticks, consuming %lf mAh\n", functions[i].address, functions[i].counter, functions[i].time, functions[i].consumption); - } - - puts("________________________________________________________"); -}