Author: fijal Branch: dtrace-support Changeset: r76408:57942acfb5de Date: 2015-03-16 17:45 +0200 http://bitbucket.org/pypy/pypy/changeset/57942acfb5de/
Log: progress diff --git a/rpython/translator/c/funcgen.py b/rpython/translator/c/funcgen.py --- a/rpython/translator/c/funcgen.py +++ b/rpython/translator/c/funcgen.py @@ -784,8 +784,18 @@ def _op_debug(self, opname, arg): if isinstance(arg, Constant): - string_literal = c_string_constant(''.join(arg.value.chars)) - return "%s(%s);" % (opname, string_literal) + val = ''.join(arg.value.chars) + if self.db.translator.config.translation.dtrace: + if opname == 'PYPY_DEBUG_START': + name_for_op = 'START' + else: + name_for_op = 'END' + prefix = 'PYPY_PROBES_%s_%s();' % ( + val.replace('-', '_').upper(), name_for_op) + else: + prefix = '' + string_literal = c_string_constant(val) + return prefix + "%s(%s);" % (opname, string_literal) else: x = "%s(RPyString_AsCharP(%s));\n" % (opname, self.expr(arg)) x += "RPyString_FreeCache();" diff --git a/rpython/translator/c/genc.py b/rpython/translator/c/genc.py --- a/rpython/translator/c/genc.py +++ b/rpython/translator/c/genc.py @@ -15,6 +15,7 @@ from rpython.translator.gensupp import uniquemodulename, NameManager from rpython.translator.tool.cbuild import ExternalCompilationInfo + _CYGWIN = sys.platform == 'cygwin' _CPYTHON_RE = py.std.re.compile('^Python 2.[567]') @@ -241,7 +242,8 @@ defines['PYPY_MAIN_FUNCTION'] = "pypy_main_startup" self.eci, cfile, extra, headers_to_precompile = \ gen_source(db, modulename, targetdir, - self.eci, defines=defines, split=self.split) + self.eci, defines=defines, split=self.split, + dtrace=self.config.translation.dtrace) self.c_source_filename = py.path.local(cfile) self.extrafiles = self.eventually_copy(extra) self.gen_makefile(targetdir, exe_name=exe_name, @@ -251,16 +253,20 @@ return cfile def _generate_dtrace_probe_file(self, debug_nodes): - name = self.targetdir.join('pypy.p') + name = self.targetdir.join('pypy.d') f = name.open('w') f.write('provider pypy_probes {\n') for debug_node in debug_nodes: debug_node = debug_node.replace('-', '_') - f.write(' probe %s__start(void);' % debug_node) - f.write(' probe %s__done(void);' % debug_node) - f.write('};') + f.write(' probe %s__start();\n' % debug_node) + f.write(' probe %s__end();\n' % debug_node) + f.write('};\n') f.close() - # XXX run dtrace + returncode, stdout, stderr = runsubprocess.run_subprocess( + 'dtrace', ['-o', str(self.targetdir.join('pypy_probes.h')), + '-h', '-s', str(name)]) + if returncode: + raise Exception("Dtrace exploded: %s" % stderr) def eventually_copy(self, cfiles): extrafiles = [] @@ -818,7 +824,7 @@ def gen_source(database, modulename, targetdir, - eci, defines={}, split=False): + eci, defines={}, split=False, dtrace=False): if isinstance(targetdir, str): targetdir = py.path.local(targetdir) @@ -839,6 +845,8 @@ eci.write_c_header(fi) print >> fi, '#include "src/g_prerequisite.h"' + if dtrace: + print >> fi, '#include "pypy_probes.h"' fi.write('#endif /* _PY_COMMON_HEADER_H*/\n') fi.close() _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit