-
Notifications
You must be signed in to change notification settings - Fork 7.9k
dtrace add prev method and prev class #10580
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: tombokombo <[email protected]>
I don't know dtrace, so somebody else should review this 🙂 |
Zend/zend_dtrace.c
Outdated
@@ -68,20 +68,22 @@ ZEND_API void dtrace_execute_ex(zend_execute_data *execute_data) | |||
if (DTRACE_FUNCTION_ENTRY_ENABLED() || DTRACE_FUNCTION_RETURN_ENABLED()) { | |||
classname = get_active_class_name(&scope); | |||
funcname = get_active_function_name(); | |||
prev_funcname = get_prev_active_function_name(); | |||
prev_classname = get_prev_active_class_name(&scope); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: would not it be better if it had its own scope
data ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are so right, I was overriding it. Haven't noticed that, as scope is basically useless. Fixed.
Fair point 🙂 the Dtrace part looks ok if we want all in one probe that's the simplest way but less sure for the zend part. |
In linear execution the probe provides enough info ( caller is known from previous probe call). With co-routines and context switching, you need some hints about caller. I would expect it in same probe, because it's one event (fn entry or return). |
f416894
to
e72bf0f
Compare
how does a typical line looks line with your change ? |
@devnexen what do you mean, output from tracing tool? |
yes before and after the changes for example. |
depend on tracing tool eg with stap https://www.php.net/manual/en/features.dtrace.systemtap.php , it depends on your chosen formatting, basically your are just extracting args
I'm tracing this probes with bpf, and trying to build callgrind, but for sake of example
This is linear case, time spend is calculated as time between ENTRY and RETURN. You can clearly see call chain
Little more complicated example with coroutine, one courutine is calling the same as before
the problem is which Bar.get() entry belongs to which return from Bar.get(). But even with information about caller, the problem persist when you call main()->Bar.get() from n-coutroutines, this would need some kind of ID. But I'm creating callgrind and knowing that main called bar-get() n times, should be enough.
|
Thanks we can have an idea of the added value here indeed. |
ZEND_API const char *get_prev_active_class_name(const char **space); | ||
ZEND_API const char *get_active_function_name(void); | ||
ZEND_API const char *get_prev_active_function_name(void); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't like to add these new function to public API.
I won't object of you move their implementation into zend_dtrace.c
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, it seems we missed this PR. Only few notes:
- I wouldn't object if
get_prev_active_class_name()
andget_prev_active_function_name()
implementation would be moved intozend_dtrace.c
. - can we test this in some way?
Hi, we are playing around with coroutines etc.. we are using dtrace for debugging and we need to know the caller, so this PR extends existing dtrace probes.