Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
53 lines (44 loc) · 1.76 KB

File metadata and controls

53 lines (44 loc) · 1.76 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# Copyright 2017 The Emscripten Authors. All rights reserved.
# Emscripten is available under two separate licenses, the MIT license and the
# University of Illinois/NCSA Open Source License. Both these licenses can be
# found in the LICENSE file.
'''
Processes a C source file, adding debugging information.
Similar to autodebugger.py, but runs on .js files.
'''
from __future__ import print_function
import os, sys, re
filename = sys.argv[1]
func = sys.argv[2]
f = open(filename, 'r')
data = f.read()
f.close()
lines = data.split('\n')
in_func = False
for i in range(len(lines)):
if lines[i].startswith('function ') and '}' not in lines[i]:
name = lines[i].split('(')[0].split(' ')[1]
args = lines[i].split('(')[1].split(')')[0]
lines[i] += ' print("call %s(" + [%s] + ")");' % (name, args)
if lines[i].startswith('function ' + func + '('):
in_func = True
continue
elif lines[i].startswith('}'):
in_func = False
continue
if in_func:
m = re.match(r'^ +([$_\w\d \[\]]+) = +([^;]+);$', lines[i])
if m and (' if ' not in lines[i-1] or '{' in lines[i-1]) and \
(' if ' not in lines[i+1] or '{' in lines[i+1]) and \
(' else' not in lines[i-1] or '{' in lines[i-1]) and \
(' else' not in lines[i+1] or '{' in lines[i+1]):
var = m.groups(1)[0].rstrip().split(' ')[-1]
if 'STACKTOP' not in lines[i] and 'sp' not in lines[i]:
#lines[i] += ''' print("[%4d] %s = " + %s);''' % (i+1, var, var)
lines[i] += ''' print("%s = " + %s);''' % (var, var)
m = re.match('^ +HEAP.*$', lines[i])
if m and lines[i].count(' = ') == 1:
left, right = lines[i].split(' = ')
lines[i] += ''' print("%s = " + %s);''' % (left, left)
print('\n'.join(lines))
print('Success.', file=sys.stderr)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.