Ruby: include/ruby/debug.h File Reference

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

Typedefs | Enumerations | Functions
debug.h File Reference
`#include "ruby/internal/dllexport.h"`
`#include "ruby/internal/event.h"`
`#include "ruby/internal/value.h"`

Go to the source code of this file.

## Typedefs
typedef struct rb_debug_inspector_struct | rb_debug_inspector_t
typedef VALUE(* | rb_debug_inspector_func_t) (const rb_debug_inspector_t *, void *)
typedef struct rb_trace_arg_struct | rb_trace_arg_t
typedef void(* | rb_postponed_job_func_t) (void *arg)

## Enumerations
enum | rb_event_hook_flag_t { RUBY_EVENT_HOOK_FLAG_SAFE = 0x01 , RUBY_EVENT_HOOK_FLAG_DELETED = 0x02 , RUBY_EVENT_HOOK_FLAG_RAW_ARG = 0x04 }

## Functions
int | rb_profile_frames (int start, int limit, VALUE *buff, int *lines)
VALUE | rb_profile_frame_path (VALUE frame)
VALUE | rb_profile_frame_absolute_path (VALUE frame)
VALUE | rb_profile_frame_label (VALUE frame)
VALUE | rb_profile_frame_base_label (VALUE frame)
VALUE | rb_profile_frame_full_label (VALUE frame)
VALUE | rb_profile_frame_first_lineno (VALUE frame)
VALUE | rb_profile_frame_classpath (VALUE frame)
VALUE | rb_profile_frame_singleton_method_p (VALUE frame)
VALUE | rb_profile_frame_method_name (VALUE frame)
VALUE | rb_profile_frame_qualified_method_name (VALUE frame)
VALUE | rb_debug_inspector_open (rb_debug_inspector_func_t func, void *data)
VALUE | rb_debug_inspector_frame_self_get (const rb_debug_inspector_t *dc, long index)
VALUE | rb_debug_inspector_frame_class_get (const rb_debug_inspector_t *dc, long index)
VALUE | rb_debug_inspector_frame_binding_get (const rb_debug_inspector_t *dc, long index)
VALUE | rb_debug_inspector_frame_iseq_get (const rb_debug_inspector_t *dc, long index)
VALUE | rb_debug_inspector_backtrace_locations (const rb_debug_inspector_t *dc)
void | rb_add_event_hook (rb_event_hook_func_t func, rb_event_flag_t events, VALUE data)
int | rb_remove_event_hook (rb_event_hook_func_t func)
int | rb_remove_event_hook_with_data (rb_event_hook_func_t func, VALUE data)
void | rb_thread_add_event_hook (VALUE thval, rb_event_hook_func_t func, rb_event_flag_t events, VALUE data)
int | rb_thread_remove_event_hook (VALUE thval, rb_event_hook_func_t func)
int | rb_thread_remove_event_hook_with_data (VALUE thval, rb_event_hook_func_t func, VALUE data)
VALUE | rb_tracepoint_new (VALUE target_thread_not_supported_yet, rb_event_flag_t events, void(*func)(VALUE, void *), void *data)
VALUE | rb_tracepoint_enable (VALUE tpval)
VALUE | rb_tracepoint_disable (VALUE tpval)
VALUE | rb_tracepoint_enabled_p (VALUE tpval)
rb_trace_arg_t * | rb_tracearg_from_tracepoint (VALUE tpval)
rb_event_flag_t | rb_tracearg_event_flag (rb_trace_arg_t *trace_arg)
VALUE | rb_tracearg_event (rb_trace_arg_t *trace_arg)
VALUE | rb_tracearg_lineno (rb_trace_arg_t *trace_arg)
VALUE | rb_tracearg_path (rb_trace_arg_t *trace_arg)
VALUE | rb_tracearg_method_id (rb_trace_arg_t *trace_arg)
VALUE | rb_tracearg_callee_id (rb_trace_arg_t *trace_arg)
VALUE | rb_tracearg_defined_class (rb_trace_arg_t *trace_arg)
VALUE | rb_tracearg_binding (rb_trace_arg_t *trace_arg)
VALUE | rb_tracearg_self (rb_trace_arg_t *trace_arg)
VALUE | rb_tracearg_return_value (rb_trace_arg_t *trace_arg)
VALUE | rb_tracearg_raised_exception (rb_trace_arg_t *trace_arg)
VALUE | rb_tracearg_object (rb_trace_arg_t *trace_arg)
int | rb_postponed_job_register (unsigned int flags, rb_postponed_job_func_t func, void *data)
int | rb_postponed_job_register_one (unsigned int flags, rb_postponed_job_func_t func, void *data)
void | rb_add_event_hook2 (rb_event_hook_func_t func, rb_event_flag_t events, VALUE data, rb_event_hook_flag_t hook_flag)
void | 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)

## Detailed Description

Author

Author
  ko1

Date
  Tue Nov 20 20:35:08 2012

Copyright
  Copyright (C) 2012 Yukihiro Matsumoto
  This file is a part of the programming language Ruby. Permission is hereby granted, to either redistribute and/or modify this file, provided that the conditions mentioned in the file COPYING are met. Consult the file for details.

Definition in file debug.h.

## Typedef Documentation

## ◆ rb_debug_inspector_func_t

typedef VALUE(* rb_debug_inspector_func_t) (const rb_debug_inspector_t *, void *)

Definition at line 38 of file debug.h.

## ◆ rb_debug_inspector_t

typedef struct rb_debug_inspector_struct rb_debug_inspector_t

Definition at line 37 of file debug.h.

## ◆ rb_postponed_job_func_t

typedef void(* rb_postponed_job_func_t) (void *arg)

Definition at line 86 of file debug.h.

## ◆ rb_trace_arg_t

typedef struct rb_trace_arg_struct rb_trace_arg_t

Definition at line 65 of file debug.h.

## Enumeration Type Documentation

## ◆ rb_event_hook_flag_t

enum rb_event_hook_flag_t

Enumerator
RUBY_EVENT_HOOK_FLAG_SAFE |
RUBY_EVENT_HOOK_FLAG_DELETED |
RUBY_EVENT_HOOK_FLAG_RAW_ARG |

Definition at line 92 of file debug.h.

## Function Documentation

## ◆ rb_add_event_hook()

void rb_add_event_hook | ( | rb_event_hook_func_t | func,
|  | rb_event_flag_t | events,
|  | VALUE | data
| ) |  |

Definition at line 161 of file vm_trace.c.

References RUBY_EVENT_HOOK_FLAG_SAFE.

Referenced by ole_initialize().

## ◆ rb_add_event_hook2()

void rb_add_event_hook2 | ( | rb_event_hook_func_t | func,
|  | rb_event_flag_t | events,
|  | VALUE | data,
|  | rb_event_hook_flag_t | hook_flag
| ) |  |

Definition at line 174 of file vm_trace.c.

Referenced by rb_set_coverages(), and rb_tracepoint_enable().

## ◆ rb_debug_inspector_backtrace_locations()

VALUE rb_debug_inspector_backtrace_locations | ( | const rb_debug_inspector_t * | dc | ) |

Definition at line 1506 of file vm_backtrace.c.

References rb_debug_inspector_struct::backtrace.

## ◆ rb_debug_inspector_frame_binding_get()

VALUE rb_debug_inspector_frame_binding_get | ( | const rb_debug_inspector_t * | dc,
|  | long | index
| ) |  |

Definition at line 1490 of file vm_backtrace.c.

References CALLER_BINDING_BINDING, and rb_ary_entry().

## ◆ rb_debug_inspector_frame_class_get()

VALUE rb_debug_inspector_frame_class_get | ( | const rb_debug_inspector_t * | dc,
|  | long | index
| ) |  |

Definition at line 1483 of file vm_backtrace.c.

References CALLER_BINDING_CLASS, and rb_ary_entry().

## ◆ rb_debug_inspector_frame_iseq_get()

VALUE rb_debug_inspector_frame_iseq_get | ( | const rb_debug_inspector_t * | dc,
|  | long | index
| ) |  |

Definition at line 1497 of file vm_backtrace.c.

References CALLER_BINDING_ISEQ, Qnil, rb_ary_entry(), rb_iseqw_new(), and RTEST.

## ◆ rb_debug_inspector_frame_self_get()

VALUE rb_debug_inspector_frame_self_get | ( | const rb_debug_inspector_t * | dc,
|  | long | index
| ) |  |

Definition at line 1476 of file vm_backtrace.c.

References CALLER_BINDING_SELF, and rb_ary_entry().

## ◆ rb_debug_inspector_open()

VALUE rb_debug_inspector_open | ( | rb_debug_inspector_func_t | func,
|  | void * | data
| ) |  |

Definition at line 1435 of file vm_backtrace.c.

References ALL_BACKTRACE_LINES, rb_debug_inspector_struct::backtrace, rb_debug_inspector_struct::backtrace_size, BACKTRACE_START, rb_debug_inspector_struct::cfp, rb_execution_context_struct::cfp, rb_debug_inspector_struct::contexts, rb_debug_inspector_struct::ec, EC_EXEC_TAG, EC_JUMP_TAG, EC_POP_TAG, EC_PUSH_TAG, FALSE, MAYBE_UNUSED, RARRAY_LEN, rb_ec_backtrace_location_ary(), rb_vm_stack_to_heap(), and TAG_NONE.

## ◆ rb_postponed_job_register()

int rb_postponed_job_register | ( | unsigned int | flags,
|  | rb_postponed_job_func_t | func,
|  | void * | data
| ) |  |

Definition at line 1608 of file vm_trace.c.

References MAX_POSTPONED_JOB, PJRR_FULL, PJRR_INTERRUPTED, PJRR_SUCCESS, rb_vm_struct::postponed_job_index, and rb_bug().

## ◆ rb_postponed_job_register_one()

int rb_postponed_job_register_one | ( | unsigned int | flags,
|  | rb_postponed_job_func_t | func,
|  | void * | data
| ) |  |

Definition at line 1627 of file vm_trace.c.

References rb_postponed_job_struct::func, MAX_POSTPONED_JOB, MAX_POSTPONED_JOB_SPECIAL_ADDITION, PJRR_FULL, PJRR_INTERRUPTED, PJRR_SUCCESS, rb_vm_struct::postponed_job_buffer, rb_vm_struct::postponed_job_index, rb_bug(), and RUBY_VM_SET_POSTPONED_JOB_INTERRUPT.

## ◆ rb_profile_frame_absolute_path()

VALUE rb_profile_frame_absolute_path | ( | VALUE | frame | ) |

Definition at line 1612 of file vm_backtrace.c.

References Qfalse, Qnil, rb_gc_register_mark_object(), rb_iseq_realpath(), and rb_str_new_literal.

## ◆ rb_profile_frame_base_label()

VALUE rb_profile_frame_base_label | ( | VALUE | frame | ) |

Definition at line 1634 of file vm_backtrace.c.

References Qnil, and rb_iseq_base_label().

Referenced by rb_profile_frame_full_label().

## ◆ rb_profile_frame_classpath()

VALUE rb_profile_frame_classpath | ( | VALUE | frame | ) |

Definition at line 1663 of file vm_backtrace.c.

References FL_SINGLETON, FL_TEST, NIL_P, Qnil, rb_class2name(), rb_class_path(), rb_ivar_get(), rb_obj_class(), rb_sprintf(), RBASIC, T_CLASS, T_ICLASS, and T_MODULE.

## ◆ rb_profile_frame_first_lineno()

VALUE rb_profile_frame_first_lineno | ( | VALUE | frame | ) |

Definition at line 1641 of file vm_backtrace.c.

References Qnil, and rb_iseq_first_lineno().

## ◆ rb_profile_frame_full_label()

VALUE rb_profile_frame_full_label | ( | VALUE | frame | ) |

Definition at line 1737 of file vm_backtrace.c.

References rb_callable_method_entry_struct::def, NIL_P, rb_method_definition_struct::original_id, PRIsVALUE, rb_long2int, rb_profile_frame_base_label(), rb_profile_frame_label(), rb_profile_frame_qualified_method_name(), rb_sprintf(), RSTRING_LEN, and RSTRING_PTR.

## ◆ rb_profile_frame_label()

VALUE rb_profile_frame_label | ( | VALUE | frame | ) |

Definition at line 1627 of file vm_backtrace.c.

References Qnil, and rb_iseq_label().

Referenced by rb_profile_frame_full_label().

## ◆ rb_profile_frame_method_name()

VALUE rb_profile_frame_method_name | ( | VALUE | frame | ) |

Definition at line 1697 of file vm_backtrace.c.

References rb_callable_method_entry_struct::def, rb_method_definition_struct::original_id, Qnil, and rb_iseq_method_name().

Referenced by rb_profile_frame_qualified_method_name().

## ◆ rb_profile_frame_path()

VALUE rb_profile_frame_path | ( | VALUE | frame | ) |

Definition at line 1580 of file vm_backtrace.c.

References Qnil, and rb_iseq_path().

## ◆ rb_profile_frame_qualified_method_name()

VALUE rb_profile_frame_qualified_method_name | ( | VALUE | frame | ) |

Definition at line 1729 of file vm_backtrace.c.

References rb_profile_frame_method_name().

Referenced by rb_profile_frame_full_label().

## ◆ rb_profile_frame_singleton_method_p()

VALUE rb_profile_frame_singleton_method_p | ( | VALUE | frame | ) |

Definition at line 1684 of file vm_backtrace.c.

References FL_SINGLETON, FL_TEST, NIL_P, Qfalse, and Qtrue.

## ◆ rb_profile_frames()

int rb_profile_frames | ( | int | start,
|  | int | limit,
|  | VALUE * | buff,
|  | int * | lines
| ) |  |

Definition at line 1512 of file vm_backtrace.c.

References rb_execution_context_struct::cfp, rb_callable_method_entry_struct::def, rb_control_frame_struct::iseq, rb_control_frame_struct::pc, rb_vm_frame_method_entry(), RUBY_VM_PREVIOUS_CONTROL_FRAME, VM_METHOD_TYPE_CFUNC, and VM_METHOD_TYPE_ISEQ.

## ◆ rb_remove_event_hook()

int rb_remove_event_hook | ( | rb_event_hook_func_t | func | ) |

Definition at line 265 of file vm_trace.c.

References NULL, and Qundef.

Referenced by rb_reset_coverages().

## ◆ rb_remove_event_hook_with_data()

int rb_remove_event_hook_with_data | ( | rb_event_hook_func_t | func,
|  | VALUE | data
| ) |  |

Definition at line 271 of file vm_trace.c.

References NULL.

Referenced by rb_tracepoint_disable().

## ◆ rb_thread_add_event_hook()

void rb_thread_add_event_hook | ( | VALUE | thval,
|  | rb_event_hook_func_t | func,
|  | rb_event_flag_t | events,
|  | VALUE | data
| ) |  |

Definition at line 155 of file vm_trace.c.

References RUBY_EVENT_HOOK_FLAG_SAFE.

## ◆ rb_thread_add_event_hook2()

void 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
| ) |  |

Definition at line 168 of file vm_trace.c.

Referenced by rb_tracepoint_enable().

## ◆ rb_thread_remove_event_hook()

int rb_thread_remove_event_hook | ( | VALUE | thval,
|  | rb_event_hook_func_t | func
| ) |  |

Definition at line 253 of file vm_trace.c.

References Qundef.

## ◆ rb_thread_remove_event_hook_with_data()

int rb_thread_remove_event_hook_with_data | ( | VALUE | thval,
|  | rb_event_hook_func_t | func,
|  | VALUE | data
| ) |  |

Definition at line 259 of file vm_trace.c.

Referenced by rb_tracepoint_disable().

## ◆ rb_tracearg_binding()

VALUE rb_tracearg_binding | ( | rb_trace_arg_t * | trace_arg | ) |

Definition at line 917 of file vm_trace.c.

References rb_trace_arg_struct::cfp, rb_trace_arg_struct::ec, Qnil, rb_vm_get_binding_creatable_next_cfp(), and rb_vm_make_binding().

## ◆ rb_tracearg_callee_id()

VALUE rb_tracearg_callee_id | ( | rb_trace_arg_t * | trace_arg | ) |

Definition at line 903 of file vm_trace.c.

References rb_trace_arg_struct::called_id, ID2SYM, and Qnil.

## ◆ rb_tracearg_defined_class()

VALUE rb_tracearg_defined_class | ( | rb_trace_arg_t * | trace_arg | ) |

Definition at line 910 of file vm_trace.c.

References rb_trace_arg_struct::klass.

## ◆ rb_tracearg_event()

VALUE rb_tracearg_event | ( | rb_trace_arg_t * | trace_arg | ) |

Definition at line 808 of file vm_trace.c.

References rb_trace_arg_struct::event, and ID2SYM.

## ◆ rb_tracearg_event_flag()

rb_event_flag_t rb_tracearg_event_flag | ( | rb_trace_arg_t * | trace_arg | ) |

Definition at line 802 of file vm_trace.c.

References rb_trace_arg_struct::event.

## ◆ rb_tracearg_from_tracepoint()

rb_trace_arg_t * rb_tracearg_from_tracepoint | ( | VALUE | tpval | ) |

Definition at line 796 of file vm_trace.c.

## ◆ rb_tracearg_lineno()

VALUE rb_tracearg_lineno | ( | rb_trace_arg_t * | trace_arg | ) |

Definition at line 822 of file vm_trace.c.

References INT2FIX, and rb_trace_arg_struct::lineno.

## ◆ rb_tracearg_method_id()

VALUE rb_tracearg_method_id | ( | rb_trace_arg_t * | trace_arg | ) |

Definition at line 896 of file vm_trace.c.

References rb_trace_arg_struct::id, ID2SYM, and Qnil.

## ◆ rb_tracearg_object()

VALUE rb_tracearg_object | ( | rb_trace_arg_t * | trace_arg | ) |

Definition at line 1018 of file vm_trace.c.

References rb_trace_arg_struct::data, rb_trace_arg_struct::event, Qundef, rb_bug(), rb_eRuntimeError, rb_raise(), RUBY_INTERNAL_EVENT_FREEOBJ, and RUBY_INTERNAL_EVENT_NEWOBJ.

## ◆ rb_tracearg_path()

VALUE rb_tracearg_path | ( | rb_trace_arg_t * | trace_arg | ) |

Definition at line 828 of file vm_trace.c.

References rb_trace_arg_struct::path.

## ◆ rb_tracearg_raised_exception()

VALUE rb_tracearg_raised_exception | ( | rb_trace_arg_t * | trace_arg | ) |

Definition at line 952 of file vm_trace.c.

References rb_trace_arg_struct::data, rb_trace_arg_struct::event, Qundef, rb_bug(), rb_eRuntimeError, rb_raise(), and RUBY_EVENT_RAISE.

## ◆ rb_tracearg_return_value()

VALUE rb_tracearg_return_value | ( | rb_trace_arg_t * | trace_arg | ) |

Definition at line 937 of file vm_trace.c.

References rb_trace_arg_struct::data, rb_trace_arg_struct::event, Qundef, rb_bug(), rb_eRuntimeError, rb_raise(), RUBY_EVENT_B_RETURN, RUBY_EVENT_C_RETURN, and RUBY_EVENT_RETURN.

## ◆ rb_tracearg_self()

VALUE rb_tracearg_self | ( | rb_trace_arg_t * | trace_arg | ) |

Definition at line 931 of file vm_trace.c.

References rb_trace_arg_struct::self.

## ◆ rb_tracepoint_disable()

VALUE rb_tracepoint_disable | ( | VALUE | tpval | ) |

Definition at line 1233 of file vm_trace.c.

References rb_tp_struct::local_target_set, NULL, Qfalse, Qundef, rb_hash_foreach(), rb_remove_event_hook_with_data(), rb_thread_remove_event_hook_with_data(), ruby_vm_event_local_num, rb_thread_struct::self, rb_tp_struct::target_th, and rb_tp_struct::tracing.

## ◆ rb_tracepoint_enable()

VALUE rb_tracepoint_enable | ( | VALUE | tpval | ) |

Definition at line 1125 of file vm_trace.c.

References rb_tp_struct::events, rb_tp_struct::local_target_set, Qfalse, Qundef, rb_add_event_hook2(), rb_eArgError, rb_raise(), rb_thread_add_event_hook2(), RUBY_EVENT_HOOK_FLAG_RAW_ARG, RUBY_EVENT_HOOK_FLAG_SAFE, rb_thread_struct::self, rb_tp_struct::target_th, and rb_tp_struct::tracing.

## ◆ rb_tracepoint_enabled_p()

VALUE rb_tracepoint_enabled_p | ( | VALUE | tpval | ) |

Definition at line 1347 of file vm_trace.c.

References Qfalse, Qtrue, and rb_tp_struct::tracing.

## ◆ rb_tracepoint_new()

VALUE rb_tracepoint_new | ( | VALUE | target_thread_not_supported_yet,
|  | rb_event_flag_t | events,
|  | void(*)(VALUE, void *) | func,
|  | void * | data
| ) |  |

Definition at line 1407 of file vm_trace.c.

References rb_trace_arg_struct::data, NULL, Qundef, and RTEST.