aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2011-09-03 22:35:16 -0700
committerAlon Zakai <alonzakai@gmail.com>2011-09-03 22:35:16 -0700
commit6c259a53dd4bf1dd621dc102e0fc37a2c8a38773 (patch)
tree920cbde22e4b5e7f1b23dd00cc5f253c293399f8 /tools
parent144f2f17841d3480d851478b9c60ce052abf8057 (diff)
optional pointer printing in autodebugger
Diffstat (limited to 'tools')
-rw-r--r--tools/autodebugger.py19
1 files changed, 12 insertions, 7 deletions
diff --git a/tools/autodebugger.py b/tools/autodebugger.py
index 9b51ebc9..3b10233e 100644
--- a/tools/autodebugger.py
+++ b/tools/autodebugger.py
@@ -7,6 +7,8 @@ compare that to the output when compiled using emscripten.
import os, sys, re
+ALLOW_POINTERS = False
+
POSTAMBLE = '''
@.emscripten.autodebug.str = private constant [10 x i8] c"AD:%d,%d\\0A\\00", align 1 ; [#uses=1]
@@ -138,13 +140,16 @@ if not LLVM_STYLE_OLD:
lines_added = 0
lines = data.split('\n')
for i in range(len(lines)):
- #if i == 5:
- # lines[i] += '\n
-
- m = re.match(' store (?P<type>i64|i32|i16|i8|float|double) %(?P<var>[\w.]+), .*', lines[i])
- if m and m.group('type') in ['i8', 'i16', 'i32', 'i64', 'float', 'double']:
- lines[i] += '\n call void @emscripten_autodebug_%s(i32 %d, %s %%%s)' % (m.group('type'), i+1+lines_added, m.group('type'), m.group('var'))
- lines_added += 1
+ m = re.match(' store (?P<type>i64|i32|i16|i8|float|double|%?[\w\.\*]+) %(?P<var>[\w.]+), .*', lines[i])
+ if m:
+ index = i+1+lines_added
+ if m.group('type') in ['i8', 'i16', 'i32', 'i64', 'float', 'double']:
+ lines[i] += '\n call void @emscripten_autodebug_%s(i32 %d, %s %%%s)' % (m.group('type'), index, m.group('type'), m.group('var'))
+ lines_added += 1
+ elif ALLOW_POINTERS and m.group('type').endswith('*') and m.group('type').count('*') == 1:
+ lines[i] += '\n %%ead.%d = ptrtoint %s %%%s to i32' % (index, m.group('type'), m.group('var'))
+ lines[i] += '\n call void @emscripten_autodebug_i32(i32 %d, i32 %%ead.%d)' % (index, index)
+ lines_added += 2
f = open(ofilename, 'w')
f.write('\n'.join(lines) + '\n' + POSTAMBLE + '\n')