Ruby: vm_backtrace.c File Reference

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

Data Structures | Macros | Typedefs | Enumerations | Functions
vm_backtrace.c File Reference
`#include "eval_intern.h"`
`#include "internal.h"`
`#include "internal/vm.h"`
`#include "iseq.h"`
`#include "ruby/debug.h"`
`#include "ruby/encoding.h"`
`#include "vm_core.h"`

Go to the source code of this file.

## Data Structures
struct | rb_backtrace_location_struct
struct | valued_frame_info
struct | rb_backtrace_struct
struct | bt_iter_arg
struct | oldbt_arg
struct | print_to_arg
struct | rb_debug_inspector_struct
struct | collect_caller_bindings_data

## Macros
#define | rb_id2str(id) id2str(id)
#define | BACKTRACE_START 0
#define | ALL_BACKTRACE_LINES -1

## Typedefs
typedef struct rb_backtrace_location_struct | rb_backtrace_location_t
typedef struct rb_backtrace_struct | rb_backtrace_t

## Enumerations
enum | { CALLER_BINDING_SELF , CALLER_BINDING_CLASS , CALLER_BINDING_BINDING , CALLER_BINDING_ISEQ , CALLER_BINDING_CFP }

## Functions
int | rb_vm_get_sourceline (const rb_control_frame_t *cfp)
int | rb_backtrace_p (VALUE obj)
VALUE | rb_ec_backtrace_object (const rb_execution_context_t *ec)
VALUE | rb_backtrace_to_str_ary (VALUE self)
void | rb_backtrace_use_iseq_first_lineno_for_last_location (VALUE self)
VALUE | rb_backtrace_to_location_ary (VALUE self)
VALUE | rb_ec_backtrace_str_ary (const rb_execution_context_t *ec, long lev, long n)
VALUE | rb_ec_backtrace_location_ary (const rb_execution_context_t *ec, long lev, long n, bool skip_internal)
void | rb_backtrace_print_as_bugreport (void)
void | rb_backtrace (void)
void | rb_backtrace_each (VALUE(*iter)(VALUE recv, VALUE str), VALUE output)
VALUE | rb_make_backtrace (void)
VALUE | rb_vm_thread_backtrace (int argc, const VALUE *argv, VALUE thval)
VALUE | rb_vm_thread_backtrace_locations (int argc, const VALUE *argv, VALUE thval)
VALUE | rb_vm_backtrace (int argc, const VALUE *argv, struct rb_execution_context_struct *ec)
VALUE | rb_vm_backtrace_locations (int argc, const VALUE *argv, struct rb_execution_context_struct *ec)
void | Init_vm_backtrace (void)
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)
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_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_profile_frame_full_label (VALUE frame)

## Macro Definition Documentation

## ◆ ALL_BACKTRACE_LINES

#define ALL_BACKTRACE_LINES -1

Definition at line 33 of file vm_backtrace.c.

## ◆ BACKTRACE_START

#define BACKTRACE_START 0

Definition at line 32 of file vm_backtrace.c.

## ◆ rb_id2str

#define rb_id2str | ( |  | id | ) | id2str(id)

Definition at line 30 of file vm_backtrace.c.

## Typedef Documentation

## ◆ rb_backtrace_location_t

typedef struct rb_backtrace_location_struct rb_backtrace_location_t

## ◆ rb_backtrace_t

typedef struct rb_backtrace_struct rb_backtrace_t

## Enumeration Type Documentation

## ◆ anonymous enum

anonymous enum

Enumerator
CALLER_BINDING_SELF |
CALLER_BINDING_CLASS |
CALLER_BINDING_BINDING |
CALLER_BINDING_ISEQ |
CALLER_BINDING_CFP |

Definition at line 1330 of file vm_backtrace.c.

## Function Documentation

## ◆ Init_vm_backtrace()

void Init_vm_backtrace | ( | void |  | ) |

Definition at line 1246 of file vm_backtrace.c.

References CLASS_OF, rb_cArray, rb_cObject, rb_cThread, rb_define_alloc_func(), rb_define_class_under(), rb_define_global_function, rb_define_method, rb_marshal_define_compat(), rb_undef_alloc_func(), and rb_undef_method().

Referenced by Init_VM().

## ◆ rb_backtrace()

void rb_backtrace | ( | void |  | ) |

Definition at line 1013 of file vm_backtrace.c.

## ◆ rb_backtrace_each()

void rb_backtrace_each | ( | VALUE(*)(VALUE recv, VALUE str) | iter,
|  | VALUE | output
| ) |  |

Definition at line 1039 of file vm_backtrace.c.

References ALL_BACKTRACE_LINES, BACKTRACE_START, oldbt_arg::data, oldbt_arg::func, print_to_arg::iter, NULL, and print_to_arg::output.

## ◆ rb_backtrace_p()

int rb_backtrace_p | ( | VALUE | obj | ) |

Definition at line 471 of file vm_backtrace.c.

References rb_typeddata_is_kind_of().

## ◆ rb_backtrace_print_as_bugreport()

void rb_backtrace_print_as_bugreport | ( | void |  | ) |

Definition at line 994 of file vm_backtrace.c.

References ALL_BACKTRACE_LINES, BACKTRACE_START, oldbt_arg::data, oldbt_arg::func, and NULL.

Referenced by rb_vm_bugreport().

## ◆ rb_backtrace_to_location_ary()

VALUE rb_backtrace_to_location_ary | ( | VALUE | self | ) |

Definition at line 864 of file vm_backtrace.c.

References GetCoreDataFromValue, and rb_backtrace_struct::locary.

## ◆ rb_backtrace_to_str_ary()

VALUE rb_backtrace_to_str_ary | ( | VALUE | self | ) |

Definition at line 809 of file vm_backtrace.c.

References bt_iter_arg::bt, GetCoreDataFromValue, and rb_backtrace_struct::strary.

## ◆ rb_backtrace_use_iseq_first_lineno_for_last_location()

void rb_backtrace_use_iseq_first_lineno_for_last_location | ( | VALUE | self | ) |

Definition at line 821 of file vm_backtrace.c.

References rb_backtrace_struct::backtrace, rb_backtrace_struct::backtrace_size, rb_backtrace_location_struct::body, rb_iseq_struct::body, bt_iter_arg::bt, rb_iseq_location_struct::first_lineno, FIX2INT, GetCoreDataFromValue, rb_backtrace_location_struct::iseq, rb_iseq_constant_body::location, rb_backtrace_location_struct::type, and VM_ASSERT.

## ◆ 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_ec_backtrace_object()

VALUE rb_ec_backtrace_object | ( | const rb_execution_context_t * | ec | ) |

Definition at line 770 of file vm_backtrace.c.

References ALL_BACKTRACE_LINES, BACKTRACE_START, FALSE, and NULL.

## ◆ rb_ec_backtrace_str_ary()

VALUE rb_ec_backtrace_str_ary | ( | const rb_execution_context_t * | ec,
|  | long | lev,
|  | long | n
| ) |  |

Definition at line 892 of file vm_backtrace.c.

References FALSE, and NULL.

Referenced by rb_make_backtrace().

## ◆ rb_make_backtrace()

VALUE rb_make_backtrace | ( | void |  | ) |

Definition at line 1059 of file vm_backtrace.c.

References ALL_BACKTRACE_LINES, BACKTRACE_START, and rb_ec_backtrace_str_ary().

## ◆ 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_vm_backtrace()

VALUE rb_vm_backtrace | ( | int | argc,
|  | const VALUE * | argv,
|  | struct rb_execution_context_struct * | ec
| ) |  |

Definition at line 1162 of file vm_backtrace.c.

References argc, and argv.

## ◆ rb_vm_backtrace_locations()

VALUE rb_vm_backtrace_locations | ( | int | argc,
|  | const VALUE * | argv,
|  | struct rb_execution_context_struct * | ec
| ) |  |

Definition at line 1167 of file vm_backtrace.c.

References argc, and argv.

## ◆ rb_vm_get_sourceline()

int rb_vm_get_sourceline | ( | const rb_control_frame_t * | cfp | ) |

Definition at line 71 of file vm_backtrace.c.

References FIX2INT, rb_control_frame_struct::iseq, rb_control_frame_struct::pc, and rb_iseq_first_lineno().

Referenced by rb_method_definition_set(), rb_source_location(), rb_sourceline(), and rb_vm_make_binding().

## ◆ rb_vm_thread_backtrace()

VALUE rb_vm_thread_backtrace | ( | int | argc,
|  | const VALUE * | argv,
|  | VALUE | thval
| ) |  |

Definition at line 1151 of file vm_backtrace.c.

References argc, and argv.

## ◆ rb_vm_thread_backtrace_locations()

VALUE rb_vm_thread_backtrace_locations | ( | int | argc,
|  | const VALUE * | argv,
|  | VALUE | thval
| ) |  |

Definition at line 1157 of file vm_backtrace.c.

References argc, and argv.