3

I patched Python 2.7.3 with Issue 13405, then compiled python with the --with-dtrace configure option.

When I run the test_dtrace script the tests fail with the error:

invalid probe specifier

as shown below:

======================================================================
FAIL: test_function_entry_return (test_dtrace.DTraceTestsNormal)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test_dtrace.py", line 99, in test_function_entry_return
    self.assertEqual(actual_result, expected_result)
AssertionError: 'dtrace: invalid probe specifier python*$target:::function-entry{    printf("Function entry %d ", timestamp);}python*$target:::function-entry,python*$target:::function-return{    printf("%d\t**%s*%s*%s*%d\\n", timestamp,        probename, copyinstr(arg0),        copyinstr(arg1), arg2);}python*$target:::function-return/(copyinstr(arg0)=="/Users/ramandeep/src/src/Python-2.7.3/dtrace_sample.py") &&(copyinstr(arg1)=="test_entry_return_and_stack")/{    self->trace = 0;}: probe description python*36447:::function-entry does not match any probes' !=  ...
Paul Sweatte
  • 24,148
  • 7
  • 127
  • 265

1 Answers1

1

The probes require a few workarounds:

It's rather annoying that dtrace doesn't honor the PATH variable, and when you run the strings command on /usr/lib/libdtrace.dylib you'll see that it hardcodes the use of gcc (not even cpp or clang).

Did you run autoconf or autoreconf after applying the patch? If not, @DTRACEOBJS@ would not be a substitutable string. It's fairly common (at least in the Python community) to omit modified configure scripts from these sorts of patches because the changes to generated configure scripts between different versions of autoconf are so massive that they dwarf the actual functional changes in the patch, often by a couple orders of magnitude.

Adding this stanza to the top of phelper.d gets past the issues in the headers:

#ifdef __APPLE__
#define _SYS_TIME_H_
#define _SYS_SELECT_H_
#define __MATH_H__
#define _OS__OSBYTEORDER_H
#define _FD_SET
#define __GNUC_VA_LIST
#endif /* __APPLE__ */

There's also a project to add python bindings to libusdt and opendtrace which may help.

References

Paul Sweatte
  • 24,148
  • 7
  • 127
  • 265