diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-01-19 21:06:44 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-01-19 21:06:44 -0800 |
commit | 66a83e111658d9057806355a45b7e3fbcae74bf4 (patch) | |
tree | f9b5d551d98678cc49390dd7ae4a38d31eae97c0 | |
parent | 5c6e9a38d1773c01e6017cbba970a69d93228614 (diff) |
make the autodebugger also note when we enter functions
-rw-r--r-- | tests/runner.py | 1 | ||||
-rw-r--r-- | tools/autodebugger.py | 48 |
2 files changed, 34 insertions, 15 deletions
diff --git a/tests/runner.py b/tests/runner.py index de884d25..626c33fb 100644 --- a/tests/runner.py +++ b/tests/runner.py @@ -4429,6 +4429,7 @@ def process(filename): # Compare to each other, and to expected output self.do_ll_run(path_from_root('tests', filename+'.o.ll.ll')) + assert open('stdout').read().startswith('AD:-1'), 'We must note when we enter functions' # Test using build_ll_hook src = ''' diff --git a/tools/autodebugger.py b/tools/autodebugger.py index 5d152d2c..123a0d20 100644 --- a/tools/autodebugger.py +++ b/tools/autodebugger.py @@ -201,26 +201,44 @@ for.end: ; preds = %for.body, %entry lines_added = 0 lines = data.split('\n') +in_func = False for i in range(len(lines)): if MEMCPY: if not lines[i].startswith('declare void'): lines[i] = lines[i].replace('@llvm.memcpy.p0i8.p0i8.i32', '@emscripten_memcpy') - 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')) + + try: + pre = '' + if lines[i].startswith('define '): + in_func = True + elif lines[i].startswith('}'): + in_func = False + elif in_func and ' = alloca' not in lines[i] and lines[i].startswith(' '): + # This is a good place to mark entry to this function + in_func = False + index = i+1+lines_added + pre = ' call void @emscripten_autodebug_i32(i32 -1, i32 %d)' % index + + 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 + continue + m = re.match(' %(?P<var>[\w_.]+) = load (?P<type>i64|i32|i16|i8|float|double+)\* [^(].*.*', lines[i]) + if m: + index = i+1+lines_added + 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 + finally: + if len(pre) > 0: + lines[i] = pre + '\n' + lines[i] 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 - continue - m = re.match(' %(?P<var>[\w_.]+) = load (?P<type>i64|i32|i16|i8|float|double+)\* [^(].*.*', lines[i]) - if m: - index = i+1+lines_added - 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 f = open(ofilename, 'w') f.write('\n'.join(lines) + '\n' + POSTAMBLE + '\n') |