aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/contrib
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/contrib
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/contrib')
-rwxr-xr-xopenbsc/contrib/bt.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/openbsc/contrib/bt.py b/openbsc/contrib/bt.py
new file mode 100755
index 000000000..1b111efc8
--- /dev/null
+++ b/openbsc/contrib/bt.py
@@ -0,0 +1,33 @@
+#!/usr/bin/env python
+
+import os
+
+f = open("unbalanced")
+lines = []
+for line in f:
+ lines.append(line)
+
+filenames = {}
+
+output = []
+for line in lines:
+ if "[0x" in line:
+ start = line.find("[")
+ end = line.find("]")
+ addr = line[start+1:end]
+ try:
+ file = filenames[addr]
+ except KeyError:
+ r = os.popen("addr2line -fs -e ./bsc_hack %s" % addr)
+ all = r.read().replace("\n", ",")
+ file = all
+ filenames[addr] = file
+
+ line = line.replace(addr, file)
+ output.append(line)
+
+g = open("unbalanced.2", "w")
+g.write("".join(output))
+
+
+