Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Dtrace patched, but still getting "invalid probe specifier" running test scripts

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' !=  ...
like image 913
user1893382 Avatar asked Nov 19 '25 22:11

user1893382


1 Answers

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

  • Python Tracker Issue 4111: Add Systemtap/DTrace probes
  • Python Tracker Issue 13405: Add DTrace Probe
  • Python Tracker Issue 14776: Add SystemTap static markers
  • Systemtap Static Probes: Python
  • Red Hat Bugzilla Issue 545179: RFE: add systemtap static probes to python runtime
  • DTrace and Perl
  • Understanding dtrace ustack helpers
  • Python and dtrace in build 65 (Staring At The C)
  • DTrace patch for Python 2.7.x and 3.x
  • Python dtrace tracker Github repo
like image 129
Paul Sweatte Avatar answered Nov 22 '25 11:11

Paul Sweatte



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!