1

dtrace on non-Linux platforms has long been advertised to be able to dynamically instrument node.js code to do dynamic tracing at the node level, for example to allow debugging of node programs at the level of JavaScript stack frames and variables (together with lower level tracing) from a core dump.

Has eBPF on Linux now reached that level of sophistication? I am interested in Python in particular, but would consider this question answered if it was answered for any similar dynamic language.

If not, what remains to be done to support that?

pchaigno
  • 7,252
  • 2
  • 21
  • 43
Croad Langshan
  • 2,239
  • 2
  • 19
  • 32
  • There doesn't seem to be any support: https://stackoverflow.com/questions/26902991/can-i-get-the-python-call-stack-with-the-linux-perf – brokenfoot Nov 02 '18 at 18:28
  • I'd be interested to know why the downvote? Anticipating: If because thought to be not as specific as it might be: I wanted to know whether this sort of thing has been done at all. That's quite specific, has the benefit of being what I actually wanted to find the answer to, and the answer answers it. – Croad Langshan Nov 25 '18 at 16:04

1 Answers1

3

Yes, you can use BPF and USDT probes to trace Python scripts. You'll have to build your Python runtime with USDT probes though.

bcc includes a few tracing scripts for Python. For example, you can use pythoncalls.sh to print the top 2 methods called:

$ ./pythoncalls.sh -T 2 -p 26914
Tracing calls in process 26914 (language: python)... Ctrl-C to quit.

METHOD                                              # CALLS
<stdin>.<module>                                          1
<stdin>.fibo                                       14190928
^C

Note that several other virtual machines support USDT probes, e.g., those of Java, Perl, PHP, Ruby, and Tcl.

pchaigno
  • 7,252
  • 2
  • 21
  • 43