After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 759813 - Add more SystemTap/DTrace probes for main context and GTask
Add more SystemTap/DTrace probes for main context and GTask
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2015-12-23 16:53 UTC by Philip Withnall
Modified: 2016-06-16 16:25 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
glib: Add more GLib main context SystemTap and DTrace probes (35.17 KB, patch)
2015-12-23 16:53 UTC, Philip Withnall
none Details | Review
gio: Add SystemTap and DTrace probes for GTask (12.84 KB, patch)
2015-12-23 16:53 UTC, Philip Withnall
none Details | Review
glib: Add more GLib main context SystemTap and DTrace probes (35.80 KB, patch)
2015-12-25 08:06 UTC, Philip Withnall
none Details | Review
gio: Add SystemTap and DTrace probes for GTask (12.84 KB, patch)
2015-12-25 08:06 UTC, Philip Withnall
none Details | Review
gio: Add SystemTap and DTrace probes for GTask (12.79 KB, patch)
2016-01-24 14:47 UTC, Philip Withnall
none Details | Review
glib: Add more GLib main context SystemTap and DTrace probes (36.95 KB, patch)
2016-01-28 22:54 UTC, Philip Withnall
committed Details | Review
gio: Add SystemTap and DTrace probes for GTask (12.79 KB, patch)
2016-01-28 22:55 UTC, Philip Withnall
committed Details | Review

Description Philip Withnall 2015-12-23 16:53:00 UTC
Patches coming. One open question is GLib’s stability policy for its tapsets: these patches add some extra parameters to some of the existing GMainContext probes (but don’t modify any of the existing variable names). SystemTap scripts written against the old probes should continue to work, although they would need to be recompiled by the stap-server (though this happens for every run anyway). I don’t know how it would affect DTrace.

If such an API break is not desired, I can split out the (quite useful) extra parameters into new ‘*_full’ probes. It’ll be ugly, but won’t break tapset API.
Comment 1 Philip Withnall 2015-12-23 16:53:05 UTC
Created attachment 317819 [details] [review]
glib: Add more GLib main context SystemTap and DTrace probes

Expand the set of available probes, and add a few more output parameters
to some of the existing ones to make them more useful. I do not know if
this breaks any existing stability guarantees for GLib’s SystemTap
tapset, as it is effectively just adding some more local variables in
the user’s probe.
Comment 2 Philip Withnall 2015-12-23 16:53:13 UTC
Created attachment 317820 [details] [review]
gio: Add SystemTap and DTrace probes for GTask

This adds a basic tapset for GIO, covering various interesting parts of
GTask.
Comment 3 Philip Withnall 2015-12-23 22:03:57 UTC
Although thinking about it, perhaps it would be best to split up the GSourceFuncs parameters for g_source_new() and pass them separately, so that user probes can examine them (since I don’t think user probes have access to the definition of the GSourceFuncs struct).
Comment 4 Philip Withnall 2015-12-25 08:06:19 UTC
Created attachment 317870 [details] [review]
glib: Add more GLib main context SystemTap and DTrace probes

Expand the set of available probes, and add a few more output parameters
to some of the existing ones to make them more useful. I do not know if
this breaks any existing stability guarantees for GLib’s SystemTap
tapset, as it is effectively just adding some more local variables in
the user’s probe.
Comment 5 Philip Withnall 2015-12-25 08:06:28 UTC
Created attachment 317871 [details] [review]
gio: Add SystemTap and DTrace probes for GTask

This adds a basic tapset for GIO, covering various interesting parts of
GTask.
Comment 6 Colin Walters 2016-01-23 02:04:32 UTC
Review of attachment 317870 [details] [review]:

Ah, wow.  Did you generate this somehow?  Did you write any systemtap scripts which consume this?

I thought SystemTap nowadays had decent support for userspace tracing, although I admit I need to try it... but if that's the case, do we really need all of these static probes?
Comment 7 Philip Withnall 2016-01-24 14:47:31 UTC
Created attachment 319605 [details] [review]
gio: Add SystemTap and DTrace probes for GTask

This adds a basic tapset for GIO, covering various interesting parts of
GTask.
Comment 8 Philip Withnall 2016-01-24 14:50:57 UTC
(In reply to Colin Walters from comment #6)
> Review of attachment 317870 [details] [review] [review]:
> 
> Ah, wow.  Did you generate this somehow?  Did you write any systemtap
> scripts which consume this?

It was written by hand over a period of weeks. Consumed by the (fledgling) https://gitlab.com/pwithnall/dunfell.

> I thought SystemTap nowadays had decent support for userspace tracing,
> although I admit I need to try it... but if that's the case, do we really
> need all of these static probes?

I tried quite hard to get Dunfell to work with userspace tracing, but it either isn’t ready in F23, or I was doing it wrong. As it stands, you still need to be running the stap-server in normal mode to use these probes.

Patch updated after pushing bug #744772.
Comment 9 Colin Walters 2016-01-25 15:55:48 UTC
I only briefly looked at dunfell (it requires a newer version of GLib than I have in RHEL Workstation 7.2), but userspace probing seems to work for me:

#!/usr/bin/env stap

probe begin {
  log("Probe running.")
}

probe process("/usr/lib64/libgio-2.0.so.0").function("g_task_thread_complete")
{
  m = sprintf ("[%d] g_task_thread_complete(%u, object:%u)", pid(), $task, $task->source_object);
  log(m)
}
Comment 10 Colin Walters 2016-01-25 15:56:28 UTC
Also, it's worth mentioning what you're working on is cool, and thanks for proposing these patches!
Comment 11 Philip Withnall 2016-01-27 14:45:15 UTC
(In reply to Colin Walters from comment #9)
> I only briefly looked at dunfell (it requires a newer version of GLib than I
> have in RHEL Workstation 7.2), but userspace probing seems to work for me:

Yeah, userspace probing works fine. Sorry, I misread what you wrote and thought you were referring to unprivileged dyninst probing, which currently doesn’t (for me):

$ stap --unprivileged --dyninst ./test.stap -c "/usr/bin/true"
--FATAL-- #68: Dyninst was unable to create the specified process
--FATAL-- #68: create process failed bootstrap
stapdyn: ERROR: Couldn't create the target process
WARNING: /usr/bin/stapdyn exited with status: 1
Pass 5: run failed.  [man error::pass5]

So as things stand, we can probe userspace processes, but require stap-server to be running to do so. With dyninst, we shouldn’t require stap-server.
Comment 12 Colin Walters 2016-01-27 16:01:00 UTC
Can you attach test.stap so we're on the same page?

Would you agree most of these static probes are just as easy to do via debuginfo?

I don't understand actually why static probes would work without stap-server, but dyninst wouldn't.  Well OK I guess I know why, the're probably totally different code paths as dyninst is attempting to retain some security.

Have you tried filing a systemtap bug?
Comment 13 Philip Withnall 2016-01-27 16:18:49 UTC
(In reply to Colin Walters from comment #12)
> Can you attach test.stap so we're on the same page?

probe begin {
  log("Probe running.")
}

> Would you agree most of these static probes are just as easy to do via
> debuginfo?

I’m not sure what you mean.

> I don't understand actually why static probes would work without
> stap-server, but dyninst wouldn't.  Well OK I guess I know why, the're
> probably totally different code paths as dyninst is attempting to retain
> some security.
> 
> Have you tried filing a systemtap bug?

I haven’t had time to investigate properly and write up the bug, bug I do plan to. For the moment, stap-server works fine for my purposes, so I want to push on with Dunfell — but it would be a whole lot nicer if dyninst worked, so I do plan to investigate and file a bug later.
Comment 14 Philip Withnall 2016-01-28 22:54:57 UTC
Created attachment 319976 [details] [review]
glib: Add more GLib main context SystemTap and DTrace probes

Expand the set of available probes, and add a few more output parameters
to some of the existing ones to make them more useful. I do not know if
this breaks any existing stability guarantees for GLib’s SystemTap
tapset, as it is effectively just adding some more local variables in
the user’s probe.
Comment 15 Philip Withnall 2016-01-28 22:55:12 UTC
Created attachment 319977 [details] [review]
gio: Add SystemTap and DTrace probes for GTask

This adds a basic tapset for GIO, covering various interesting parts of
GTask.
Comment 16 Philip Withnall 2016-01-28 22:56:13 UTC
(Updated to add a missing user_string() call and a new glib_thread_spawned probe.)
Comment 17 Philip Withnall 2016-06-15 14:05:28 UTC
(In reply to Philip Withnall from comment #13)
> > Would you agree most of these static probes are just as easy to do via
> > debuginfo?
> 
> I’m not sure what you mean.

Ah, systemtap has debuginfo probing support:

https://sourceware.org/systemtap/wiki/AddingUserSpaceProbingToApps

Most of them could be done via function probe points using debuginfo, but some of the more important ones (such as GLIB_MAIN_[BEFORE|AFTER]_DISPATCH) would need to use line numbers, and hence would be very specific on the GLib version; and would have to be in-tree. In that case, it would be more maintainable to simple use probe points as in the patch.
Comment 18 Philip Withnall 2016-06-16 16:06:07 UTC
Acked in person yesterday by desrt (while walking to dinner and desperately trying to avoid me), who volunteers to take all the blame if people don't like this.
Comment 19 Philip Withnall 2016-06-16 16:14:51 UTC
Attachment 319976 [details] pushed as cfb6928 - glib: Add more GLib main context SystemTap and DTrace probes
Attachment 319977 [details] pushed as 195a0cb - gio: Add SystemTap and DTrace probes for GTask
Comment 20 Colin Walters 2016-06-16 16:16:47 UTC
(In reply to Philip Withnall from comment #18)
> Acked in person yesterday by desrt (while walking to dinner and desperately
> trying to avoid me)

I like your new strategy for patch review.
Comment 21 Colin Walters 2016-06-16 16:25:27 UTC
(In reply to Philip Withnall from comment #17)
> and hence would be very specific on the GLib
> version; and would have to be in-tree. In that case, it would be more
> maintainable to simple use probe points as in the patch.

That sounds reasonable to me.  I'll hopefully get an excuse to revisit this again personally.