![]() System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, Directory : /usr/share/emscripten/tools/ |
Upload File : |
''' Processes a C source file, adding debugging information. Similar to autodebugger.py, but runs on .js files. ''' 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 '): 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('^ +([$_\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 >> sys.stderr, 'Success.'