aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/gsm_utils.c
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2009-10-28 09:12:43 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2009-11-19 09:40:03 +0100
commit25f30ba00ae7a5be50724a77bdf7484886726b9b (patch)
tree415550c118a242f7fad8f7b21bda7144eb3093cd /openbsc/src/gsm_utils.c
parenta8dffc512b0595d23c11af7e93bc9346ad136bc7 (diff)
misc: Add routine to generate backtrace from within the application
E.g. to analyze the subscr_get/subscr_put behavior one can place the generate_backtrace into the functions, recompile and then filter the output with contrib/bt.py to get the function name, file and line.
Diffstat (limited to 'openbsc/src/gsm_utils.c')
-rw-r--r--openbsc/src/gsm_utils.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/openbsc/src/gsm_utils.c b/openbsc/src/gsm_utils.c
index de18dba26..ddfd7f3de 100644
--- a/openbsc/src/gsm_utils.c
+++ b/openbsc/src/gsm_utils.c
@@ -23,8 +23,10 @@
#include <openbsc/gsm_data.h>
#include <openbsc/gsm_utils.h>
+#include <execinfo.h>
#include <stdlib.h>
#include <string.h>
+#include <stdio.h>
#include <errno.h>
/* GSM 03.38 6.2.1 Charachter packing */
@@ -148,4 +150,21 @@ int ms_pwr_dbm(enum gsm_band band, u_int8_t lvl)
return -EINVAL;
}
+void generate_backtrace()
+{
+ int i, nptrs;
+ void *buffer[100];
+ char **strings;
+
+ nptrs = backtrace(buffer, ARRAY_SIZE(buffer));
+ printf("backtrace() returned %d addresses\n", nptrs);
+
+ strings = backtrace_symbols(buffer, nptrs);
+ if (!strings)
+ return;
+ for (i = 1; i < nptrs; i++)
+ printf("%s\n", strings[i]);
+
+ free(strings);
+}