diff options
author | Daisuke Aritomo <osyoyu@osyoyu.com> | 2023-09-29 15:35:36 +0900 |
---|---|---|
committer | Koichi Sasada <ko1@atdot.net> | 2023-10-31 11:16:18 +0900 |
commit | 4adf418be963b3554962b2f27057be81486c57d9 (patch) | |
tree | d43c3006925aaacdf522b58b752b860f6b94875a /include | |
parent | 02ecc3c8550af1aab7916975e7019b2a3ffe8591 (diff) |
[Feature #10602] Add new API rb_profile_thread_frames()
Add a new API rb_profile_thread_frames(), which is essentialy a
per-thread version of rb_profile_frames().
While the original rb_profile_frames() always returns results about the
current active thread obtained by GET_EC(), this new API takes a Thread
to be profiled as an argument.
This should come in handy when profiling I/O-bound programs such as
webapps, since this new API allows us to learn about Threads performing
I/O (which do not have the GVL).
Profiling worker threads (such as Sidekiq workers) may be another
application.
Implements [Feature #10602]
Co-authored-by: Mike Perham <mike@perham.net>
Diffstat (limited to 'include')
-rw-r--r-- | include/ruby/debug.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/include/ruby/debug.h b/include/ruby/debug.h index 1f20e984bb..e173f16e25 100644 --- a/include/ruby/debug.h +++ b/include/ruby/debug.h @@ -51,6 +51,25 @@ RBIMPL_ATTR_NONNULL((3)) int rb_profile_frames(int start, int limit, VALUE *buff, int *lines); /** + * Queries mysterious "frame"s of the given range. + * + * A per-thread version of rb_profile_frames(). + * Arguments and return values are the same with rb_profile_frames() with the + * exception of the first argument _thread_, which accepts the Thread to be + * profiled/queried. + * + * @param[in] thread The Ruby Thread to be profiled. + * @param[in] start Start position (0 means the topmost). + * @param[in] limit Number objects of `buff`. + * @param[out] buff Return buffer. + * @param[out] lines Return buffer. + * @return Number of objects filled into `buff`. + * @post `buff` is filled with backtrace pointers. + * @post `lines` is filled with `__LINE__` of each backtraces. + */ +int rb_profile_thread_frames(VALUE thread, int start, int limit, VALUE *buff, int *lines); + +/** * Queries the path of the passed backtrace. * * @param[in] frame What rb_profile_frames() returned. |