Ruby 3.1.3p185 (2022-11-24 revision 1a6b16756e0ba6b95ab71a441357ed5484e33498)
debug.h
Go to the documentation of this file.
1#ifndef RB_DEBUG_H /*-*-C++-*-vi:se ft=cpp:*/
2#define RB_DEBUG_H 1
16#include "ruby/internal/event.h"
17#include "ruby/internal/value.h"
18
20
21/* Note: This file contains experimental APIs. */
22/* APIs can be replaced at Ruby 2.0.1 or later */
23
24
51int rb_profile_frames(int start, int limit, VALUE *buff, int *lines);
52
60VALUE rb_profile_frame_path(VALUE frame);
61
73VALUE rb_profile_frame_absolute_path(VALUE frame);
74
86VALUE rb_profile_frame_label(VALUE frame);
87
112VALUE rb_profile_frame_base_label(VALUE frame);
113
129VALUE rb_profile_frame_full_label(VALUE frame);
130
139VALUE rb_profile_frame_first_lineno(VALUE frame);
140
148VALUE rb_profile_frame_classpath(VALUE frame);
149
157VALUE rb_profile_frame_singleton_method_p(VALUE frame);
158
166VALUE rb_profile_frame_method_name(VALUE frame);
167
177
188
198typedef VALUE (*rb_debug_inspector_func_t)(const rb_debug_inspector_t *dc, void *data);
199
208
218
228
238
251
262
271/* duplicated def of include/ruby/ruby.h */
272#include "ruby/internal/event.h"
273
286
297void rb_thread_add_event_hook(VALUE thval, rb_event_hook_func_t func, rb_event_flag_t events, VALUE data);
298
313
328int rb_thread_remove_event_hook_with_data(VALUE thval, rb_event_hook_func_t func, VALUE data);
329
380VALUE rb_tracepoint_new(VALUE target_thread_not_supported_yet, rb_event_flag_t events, void (*func)(VALUE, void *), void *data);
381
392VALUE rb_tracepoint_enable(VALUE tpval);
393
401VALUE rb_tracepoint_disable(VALUE tpval);
402
410VALUE rb_tracepoint_enabled_p(VALUE tpval);
411
423
438
446rb_event_flag_t rb_tracearg_event_flag(rb_trace_arg_t *trace_arg);
447
456VALUE rb_tracearg_event(rb_trace_arg_t *trace_arg);
457
466VALUE rb_tracearg_lineno(rb_trace_arg_t *trace_arg);
467
476VALUE rb_tracearg_path(rb_trace_arg_t *trace_arg);
477
486VALUE rb_tracearg_method_id(rb_trace_arg_t *trace_arg);
487
497VALUE rb_tracearg_callee_id(rb_trace_arg_t *trace_arg);
498
510
524VALUE rb_tracearg_binding(rb_trace_arg_t *trace_arg);
525
533VALUE rb_tracearg_self(rb_trace_arg_t *trace_arg);
534
544
554
563VALUE rb_tracearg_object(rb_trace_arg_t *trace_arg);
564
565
574/*
575 * Postponed Job API
576 * rb_postponed_job_register and rb_postponed_job_register_one are
577 * async-signal-safe and used via SIGPROF by the "stackprof" RubyGem
578 */
579
585typedef void (*rb_postponed_job_func_t)(void *arg);
586
605int rb_postponed_job_register(unsigned int flags, rb_postponed_job_func_t func, void *data);
606
618int rb_postponed_job_register_one(unsigned int flags, rb_postponed_job_func_t func, void *data);
619
629/* undocumented advanced tracing APIs */
630
631typedef enum {
632 RUBY_EVENT_HOOK_FLAG_SAFE = 0x01,
633 RUBY_EVENT_HOOK_FLAG_DELETED = 0x02,
634 RUBY_EVENT_HOOK_FLAG_RAW_ARG = 0x04
635} rb_event_hook_flag_t;
636
637void rb_add_event_hook2(rb_event_hook_func_t func, rb_event_flag_t events, VALUE data, rb_event_hook_flag_t hook_flag);
638void rb_thread_add_event_hook2(VALUE thval, rb_event_hook_func_t func, rb_event_flag_t events, VALUE data, rb_event_hook_flag_t hook_flag);
639
643
644#endif /* RUBY_DEBUG_H */
int rb_profile_frames(int start, int limit, VALUE *buff, int *lines)
Queries mysterious "frame"s of the given range.
VALUE rb_profile_frame_full_label(VALUE frame)
Identical to rb_profile_frame_label(), except it returns a qualified result.
VALUE rb_tracearg_binding(rb_trace_arg_t *trace_arg)
Creates a binding object of the point where the trace is at.
Definition: vm_trace.c:948
VALUE rb_debug_inspector_frame_iseq_get(const rb_debug_inspector_t *dc, long index)
Queries the instruction sequence of the passed context's upper frame.
VALUE rb_tracepoint_enabled_p(VALUE tpval)
Queries if the passed TracePoint is up and running.
Definition: vm_trace.c:1384
VALUE rb_tracearg_object(rb_trace_arg_t *trace_arg)
Queries the allocated/deallocated object that the trace represents.
Definition: vm_trace.c:1049
VALUE rb_tracearg_callee_id(rb_trace_arg_t *trace_arg)
Identical to rb_tracearg_method_id(), except it returns callee id like rb_frame_callee().
Definition: vm_trace.c:934
VALUE rb_profile_frame_method_name(VALUE frame)
Queries the name of the method of the passed frame.
VALUE rb_tracearg_defined_class(rb_trace_arg_t *trace_arg)
Queries the class that defines the method that the passed trace is at.
Definition: vm_trace.c:941
VALUE rb_tracepoint_new(VALUE target_thread_not_supported_yet, rb_event_flag_t events, void(*func)(VALUE, void *), void *data)
Creates a tracepoint by registering a callback function for one or more tracepoint events.
Definition: vm_trace.c:1414
VALUE rb_tracearg_raised_exception(rb_trace_arg_t *trace_arg)
Queries the raised exception that the trace represents.
Definition: vm_trace.c:983
void rb_thread_add_event_hook(VALUE thval, rb_event_hook_func_t func, rb_event_flag_t events, VALUE data)
Identical to rb_add_event_hook(), except its effect is limited to the passed thread.
Definition: vm_trace.c:178
VALUE rb_profile_frame_qualified_method_name(VALUE frame)
Identical to rb_profile_frame_method_name(), except it "qualifies" the return value with its defining...
VALUE rb_profile_frame_label(VALUE frame)
Queries human-readable "label" string.
VALUE rb_tracepoint_disable(VALUE tpval)
Stops (disables) an already running instance of TracePoint.
Definition: vm_trace.c:1270
VALUE rb_tracearg_self(rb_trace_arg_t *trace_arg)
Queries the receiver of the point trace is at.
Definition: vm_trace.c:962
int rb_thread_remove_event_hook(VALUE thval, rb_event_hook_func_t func)
Identical to rb_remove_event_hook(), except it additionally takes a thread argument.
Definition: vm_trace.c:280
VALUE rb_profile_frame_singleton_method_p(VALUE frame)
Queries if the method of the passed frame is a singleton class.
VALUE rb_debug_inspector_backtrace_locations(const rb_debug_inspector_t *dc)
Queries the backtrace object of the context.
VALUE rb_profile_frame_absolute_path(VALUE frame)
Identical to rb_profile_frame_path(), except it tries to expand the returning path.
int rb_postponed_job_register_one(unsigned int flags, rb_postponed_job_func_t func, void *data)
Identical to rb_postponed_job_register_one(), except it additionally checks for duplicated registrati...
Definition: vm_trace.c:1653
VALUE rb_debug_inspector_open(rb_debug_inspector_func_t func, void *data)
Prepares, executes, then cleans up a debug session.
VALUE rb_tracearg_return_value(rb_trace_arg_t *trace_arg)
Queries the return value that the trace represents.
Definition: vm_trace.c:968
rb_event_flag_t rb_tracearg_event_flag(rb_trace_arg_t *trace_arg)
Queries the event of the passed trace.
Definition: vm_trace.c:833
VALUE rb_debug_inspector_frame_self_get(const rb_debug_inspector_t *dc, long index)
Queries the current receiver of the passed context's upper frame.
VALUE rb_tracearg_path(rb_trace_arg_t *trace_arg)
Queries the file name of the point where the trace is at.
Definition: vm_trace.c:859
int rb_thread_remove_event_hook_with_data(VALUE thval, rb_event_hook_func_t func, VALUE data)
Identical to rb_thread_remove_event_hook(), except it additionally takes the data argument.
Definition: vm_trace.c:286
VALUE rb_tracepoint_enable(VALUE tpval)
Starts (enables) trace(s) defined by the passed object.
Definition: vm_trace.c:1156
VALUE rb_debug_inspector_frame_binding_get(const rb_debug_inspector_t *dc, long index)
Queries the binding of the passed context's upper frame.
int rb_postponed_job_register(unsigned int flags, rb_postponed_job_func_t func, void *data)
Registers a postponed job.
Definition: vm_trace.c:1634
VALUE rb_tracearg_method_id(rb_trace_arg_t *trace_arg)
Queries the method name of the point where the trace is at.
Definition: vm_trace.c:927
VALUE rb_debug_inspector_frame_class_get(const rb_debug_inspector_t *dc, long index)
Queries the current class of the passed context's upper frame.
int rb_remove_event_hook_with_data(rb_event_hook_func_t func, VALUE data)
Identical to rb_remove_event_hook(), except it additionally takes the data argument.
Definition: vm_trace.c:298
VALUE rb_profile_frame_classpath(VALUE frame)
Queries the class path of the method that the passed frame represents.
rb_trace_arg_t * rb_tracearg_from_tracepoint(VALUE tpval)
Queries the current event of the passed tracepoint.
Definition: vm_trace.c:827
VALUE rb_profile_frame_path(VALUE frame)
Queries the path of the passed backtrace.
VALUE rb_profile_frame_first_lineno(VALUE frame)
Queries the first line of the method of the passed frame pointer.
VALUE rb_tracearg_lineno(rb_trace_arg_t *trace_arg)
Queries the line of the point where the trace is at.
Definition: vm_trace.c:853
void(* rb_postponed_job_func_t)(void *arg)
Type of postponed jobs.
Definition: debug.h:585
VALUE(* rb_debug_inspector_func_t)(const rb_debug_inspector_t *dc, void *data)
Type of the callback function passed to rb_debug_inspector_open().
Definition: debug.h:198
VALUE rb_profile_frame_base_label(VALUE frame)
Identical to rb_profile_frame_label(), except it does not "qualify" the result.
VALUE rb_tracearg_event(rb_trace_arg_t *trace_arg)
Identical to rb_tracearg_event_flag(), except it returns the name of the event in Ruby's symbol.
Definition: vm_trace.c:839
Tweaking visibility of C variables/functions.
#define RBIMPL_SYMBOL_EXPORT_END()
Counterpart of RBIMPL_SYMBOL_EXPORT_BEGIN.
Definition: dllexport.h:106
#define RBIMPL_SYMBOL_EXPORT_BEGIN()
Shortcut macro equivalent to RUBY_SYMBOL_EXPORT_BEGIN extern "C" {.
Definition: dllexport.h:97
Debugging and tracing APIs.
void(* rb_event_hook_func_t)(rb_event_flag_t evflag, VALUE data, VALUE self, ID mid, VALUE klass)
Type of event hooks.
Definition: event.h:115
Defines RBIMPL_ATTR_NONNULL.
#define RBIMPL_ATTR_NONNULL(list)
Wraps (or simulates) __attribute__((nonnull))
Definition: nonnull.h:27
Defines RBIMPL_ATTR_RETURNS_NONNULL.
#define RBIMPL_ATTR_RETURNS_NONNULL()
Wraps (or simulates) __attribute__((returns_nonnull))
Defines VALUE and ID.