diff options
Diffstat (limited to 'tools/autodebugger.py')
-rw-r--r-- | tools/autodebugger.py | 19 |
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') |