Provide more info in dtrace probes

While creating a python profiler using dtrace, I found some cases that confuse dtrace-based profiler.

  1. When there are multiple function calls in one line, the line number is not useful.
1  a = 3
2  b = func(func(func(a)))

This will report the entry/return of func() three times.
  1. async functions return and re-entry on every await point.
    While it is useful to be able to measure every block between await points, this confuses the profiler.
1 async def func():
2     a = 1
3     b = await f()
4     c = 2
5     d = await g()
6     return (await h()) if some_flag else (await i())

Note that in the last line, by looking at function-entry:6 it is not possible to know which branch was taken.

It will be useful for profilers if dtrace provides

  • a column number of the function call
  • separate event type for await points / raise, or add a flag argument to function__return to indicate whether it’s await, raise, or return.