Ruby  2.4.2p198(2017-09-14revision59899)
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
vm_backtrace.c File Reference
#include "internal.h"
#include "ruby/debug.h"
#include "vm_core.h"
#include "eval_intern.h"
#include "iseq.h"
Include dependency graph for vm_backtrace.c:

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  rb_debug_inspector_struct
 
struct  collect_caller_bindings_data
 

Macros

#define rb_id2str(id)   id2str(id)
 

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

static VALUE id2str (ID id)
 
static int calc_lineno (const rb_iseq_t *iseq, const VALUE *pc)
 
int rb_vm_get_sourceline (const rb_control_frame_t *cfp)
 
static void location_mark (void *ptr)
 
static void location_mark_entry (rb_backtrace_location_t *fi)
 
static size_t location_memsize (const void *ptr)
 
static rb_backtrace_location_tlocation_ptr (VALUE locobj)
 
static int location_lineno (rb_backtrace_location_t *loc)
 
static VALUE location_lineno_m (VALUE self)
 
static VALUE location_label (rb_backtrace_location_t *loc)
 
static VALUE location_label_m (VALUE self)
 
static VALUE location_base_label (rb_backtrace_location_t *loc)
 
static VALUE location_base_label_m (VALUE self)
 
static VALUE location_path (rb_backtrace_location_t *loc)
 
static VALUE location_path_m (VALUE self)
 
static VALUE location_absolute_path (rb_backtrace_location_t *loc)
 
static VALUE location_absolute_path_m (VALUE self)
 
static VALUE location_format (VALUE file, int lineno, VALUE name)
 
static VALUE location_to_str (rb_backtrace_location_t *loc)
 
static VALUE location_to_str_m (VALUE self)
 
static VALUE location_inspect_m (VALUE self)
 
static void backtrace_mark (void *ptr)
 
static void backtrace_free (void *ptr)
 
static size_t backtrace_memsize (const void *ptr)
 
int rb_backtrace_p (VALUE obj)
 
static VALUE backtrace_alloc (VALUE klass)
 
static void backtrace_each (rb_thread_t *th, void(*init)(void *arg, size_t size), void(*iter_iseq)(void *arg, const rb_control_frame_t *cfp), void(*iter_cfunc)(void *arg, const rb_control_frame_t *cfp, ID mid), void *arg)
 
static void bt_init (void *ptr, size_t size)
 
static void bt_iter_iseq (void *ptr, const rb_control_frame_t *cfp)
 
static void bt_iter_cfunc (void *ptr, const rb_control_frame_t *cfp, ID mid)
 
static VALUE backtrace_object (rb_thread_t *th)
 
VALUE rb_vm_backtrace_object (void)
 
static VALUE backtrace_collect (rb_backtrace_t *bt, long lev, long n, VALUE(*func)(rb_backtrace_location_t *, void *arg), void *arg)
 
static VALUE location_to_str_dmyarg (rb_backtrace_location_t *loc, void *dmy)
 
static VALUE backtrace_to_str_ary (VALUE self, long lev, long n)
 
VALUE rb_backtrace_to_str_ary (VALUE self)
 
static VALUE location_create (rb_backtrace_location_t *srcloc, void *btobj)
 
static VALUE backtrace_to_location_ary (VALUE self, long lev, long n)
 
VALUE rb_backtrace_to_location_ary (VALUE self)
 
static VALUE backtrace_dump_data (VALUE self)
 
static VALUE backtrace_load_data (VALUE self, VALUE str)
 
VALUE rb_vm_backtrace_str_ary (rb_thread_t *th, long lev, long n)
 
VALUE rb_vm_backtrace_location_ary (rb_thread_t *th, long lev, long n)
 
static void oldbt_init (void *ptr, size_t dmy)
 
static void oldbt_iter_iseq (void *ptr, const rb_control_frame_t *cfp)
 
static void oldbt_iter_cfunc (void *ptr, const rb_control_frame_t *cfp, ID mid)
 
static void oldbt_print (void *data, VALUE file, int lineno, VALUE name)
 
static void vm_backtrace_print (FILE *fp)
 
static void oldbt_bugreport (void *arg, VALUE file, int line, VALUE method)
 
void rb_backtrace_print_as_bugreport (void)
 
void rb_backtrace (void)
 
static void oldbt_print_to (void *data, VALUE file, int lineno, VALUE name)
 
void rb_backtrace_print_to (VALUE output)
 
VALUE rb_make_backtrace (void)
 
static VALUE vm_backtrace_to_ary (rb_thread_t *th, int argc, const VALUE *argv, int lev_default, int lev_plus, int to_str)
 
static VALUE thread_backtrace_to_ary (int argc, const VALUE *argv, VALUE thval, int to_str)
 
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)
 
static VALUE rb_f_caller (int argc, VALUE *argv)
 
static VALUE rb_f_caller_locations (int argc, VALUE *argv)
 
void Init_vm_backtrace (void)
 
static void collect_caller_bindings_init (void *arg, size_t size)
 
static VALUE get_klass (const rb_control_frame_t *cfp)
 
static void collect_caller_bindings_iseq (void *arg, const rb_control_frame_t *cfp)
 
static void collect_caller_bindings_cfunc (void *arg, const rb_control_frame_t *cfp, ID mid)
 
static VALUE collect_caller_bindings (rb_thread_t *th)
 
VALUE rb_debug_inspector_open (rb_debug_inspector_func_t func, void *data)
 
static VALUE frame_get (const rb_debug_inspector_t *dc, long index)
 
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)
 
static const rb_iseq_tframe2iseq (VALUE frame)
 
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)
 
static VALUE frame2klass (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)
 

Variables

static VALUE rb_cBacktrace
 
static VALUE rb_cBacktraceLocation
 
static const rb_data_type_t location_data_type
 
static const rb_data_type_t backtrace_data_type
 

Macro Definition Documentation

◆ rb_id2str

#define rb_id2str (   id)    id2str(id)

Typedef Documentation

◆ rb_backtrace_location_t

◆ 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 1069 of file vm_backtrace.c.

Function Documentation

◆ backtrace_alloc()

static VALUE backtrace_alloc ( VALUE  klass)
static

Definition at line 416 of file vm_backtrace.c.

References TypedData_Make_Struct.

Referenced by bt_init(), and Init_vm_backtrace().

◆ backtrace_collect()

static VALUE backtrace_collect ( rb_backtrace_t bt,
long  lev,
long  n,
VALUE(*)(rb_backtrace_location_t *, void *arg)  func,
void *  arg 
)
static

◆ backtrace_dump_data()

static VALUE backtrace_dump_data ( VALUE  self)
static

Definition at line 643 of file vm_backtrace.c.

References rb_backtrace_to_str_ary().

Referenced by Init_vm_backtrace().

◆ backtrace_each()

static void backtrace_each ( rb_thread_t th,
void(*)(void *arg, size_t size init,
void(*)(void *arg, const rb_control_frame_t *cfp)  iter_iseq,
void(*)(void *arg, const rb_control_frame_t *cfp, ID mid)  iter_cfunc,
void *  arg 
)
static

◆ backtrace_free()

static void backtrace_free ( void *  ptr)
static

◆ backtrace_load_data()

static VALUE backtrace_load_data ( VALUE  self,
VALUE  str 
)
static

Definition at line 650 of file vm_backtrace.c.

References GetCoreDataFromValue, and rb_backtrace_struct::strary.

Referenced by Init_vm_backtrace().

◆ backtrace_mark()

static void backtrace_mark ( void *  ptr)
static

◆ backtrace_memsize()

static size_t backtrace_memsize ( const void *  ptr)
static

Definition at line 397 of file vm_backtrace.c.

References rb_backtrace_struct::backtrace_size.

◆ backtrace_object()

static VALUE backtrace_object ( rb_thread_t th)
static

◆ backtrace_to_location_ary()

static VALUE backtrace_to_location_ary ( VALUE  self,
long  lev,
long  n 
)
static

◆ backtrace_to_str_ary()

static VALUE backtrace_to_str_ary ( VALUE  self,
long  lev,
long  n 
)
static

◆ bt_init()

static void bt_init ( void *  ptr,
size_t  size 
)
static

◆ bt_iter_cfunc()

static void bt_iter_cfunc ( void *  ptr,
const rb_control_frame_t cfp,
ID  mid 
)
static

◆ bt_iter_iseq()

static void bt_iter_iseq ( void *  ptr,
const rb_control_frame_t cfp 
)
static

◆ calc_lineno()

static int calc_lineno ( const rb_iseq_t iseq,
const VALUE pc 
)
inlinestatic

◆ collect_caller_bindings()

static VALUE collect_caller_bindings ( rb_thread_t th)
static

◆ collect_caller_bindings_cfunc()

static void collect_caller_bindings_cfunc ( void *  arg,
const rb_control_frame_t cfp,
ID  mid 
)
static

◆ collect_caller_bindings_init()

static void collect_caller_bindings_init ( void *  arg,
size_t  size 
)
static

Definition at line 1082 of file vm_backtrace.c.

Referenced by collect_caller_bindings().

◆ collect_caller_bindings_iseq()

static void collect_caller_bindings_iseq ( void *  arg,
const rb_control_frame_t cfp 
)
static

◆ frame2iseq()

static const rb_iseq_t* frame2iseq ( VALUE  frame)
static

◆ frame2klass()

static VALUE frame2klass ( VALUE  frame)
static

◆ frame_get()

static VALUE frame_get ( const rb_debug_inspector_t dc,
long  index 
)
static

◆ get_klass()

static VALUE get_klass ( const rb_control_frame_t cfp)
static

◆ id2str()

static VALUE id2str ( ID  id)
static

Definition at line 23 of file vm_backtrace.c.

References Qnil, and rb_id2str.

◆ Init_vm_backtrace()

void Init_vm_backtrace ( void  )

◆ location_absolute_path()

static VALUE location_absolute_path ( rb_backtrace_location_t loc)
static

◆ location_absolute_path_m()

static VALUE location_absolute_path_m ( VALUE  self)
static

Definition at line 287 of file vm_backtrace.c.

References location_absolute_path(), and location_ptr().

Referenced by Init_vm_backtrace().

◆ location_base_label()

static VALUE location_base_label ( rb_backtrace_location_t loc)
static

◆ location_base_label_m()

static VALUE location_base_label_m ( VALUE  self)
static

Definition at line 224 of file vm_backtrace.c.

References location_base_label(), and location_ptr().

Referenced by Init_vm_backtrace().

◆ location_create()

static VALUE location_create ( rb_backtrace_location_t srcloc,
void *  btobj 
)
static

◆ location_format()

static VALUE location_format ( VALUE  file,
int  lineno,
VALUE  name 
)
static

◆ location_inspect_m()

static VALUE location_inspect_m ( VALUE  self)
static

Definition at line 362 of file vm_backtrace.c.

References location_ptr(), location_to_str(), and rb_str_inspect().

Referenced by Init_vm_backtrace().

◆ location_label()

static VALUE location_label ( rb_backtrace_location_t loc)
static

◆ location_label_m()

static VALUE location_label_m ( VALUE  self)
static

Definition at line 197 of file vm_backtrace.c.

References location_label(), and location_ptr().

Referenced by Init_vm_backtrace().

◆ location_lineno()

static int location_lineno ( rb_backtrace_location_t loc)
static

◆ location_lineno_m()

static VALUE location_lineno_m ( VALUE  self)
static

Definition at line 148 of file vm_backtrace.c.

References INT2FIX, location_lineno(), and location_ptr().

Referenced by Init_vm_backtrace().

◆ location_mark()

static void location_mark ( void *  ptr)
static

Definition at line 77 of file vm_backtrace.c.

References valued_frame_info::btobj, and rb_gc_mark().

◆ location_mark_entry()

static void location_mark_entry ( rb_backtrace_location_t fi)
static

◆ location_memsize()

static size_t location_memsize ( const void *  ptr)
static

Definition at line 99 of file vm_backtrace.c.

◆ location_path()

static VALUE location_path ( rb_backtrace_location_t loc)
static

◆ location_path_m()

static VALUE location_path_m ( VALUE  self)
static

Definition at line 257 of file vm_backtrace.c.

References location_path(), and location_ptr().

Referenced by Init_vm_backtrace().

◆ location_ptr()

static rb_backtrace_location_t* location_ptr ( VALUE  locobj)
inlinestatic

◆ location_to_str()

static VALUE location_to_str ( rb_backtrace_location_t loc)
static

◆ location_to_str_dmyarg()

static VALUE location_to_str_dmyarg ( rb_backtrace_location_t loc,
void *  dmy 
)
static

Definition at line 556 of file vm_backtrace.c.

References location_to_str().

Referenced by backtrace_to_str_ary().

◆ location_to_str_m()

static VALUE location_to_str_m ( VALUE  self)
static

Definition at line 352 of file vm_backtrace.c.

References location_ptr(), and location_to_str().

Referenced by Init_vm_backtrace().

◆ oldbt_bugreport()

static void oldbt_bugreport ( void *  arg,
VALUE  file,
int  line,
VALUE  method 
)
static

Definition at line 743 of file vm_backtrace.c.

References oldbt_arg::filename, NIL_P, and RSTRING_PTR.

Referenced by rb_backtrace_print_as_bugreport().

◆ oldbt_init()

static void oldbt_init ( void *  ptr,
size_t  dmy 
)
static

◆ oldbt_iter_cfunc()

static void oldbt_iter_cfunc ( void *  ptr,
const rb_control_frame_t cfp,
ID  mid 
)
static

◆ oldbt_iter_iseq()

static void oldbt_iter_iseq ( void *  ptr,
const rb_control_frame_t cfp 
)
static

◆ oldbt_print()

static void oldbt_print ( void *  data,
VALUE  file,
int  lineno,
VALUE  name 
)
static

Definition at line 714 of file vm_backtrace.c.

References NIL_P, and RSTRING_PTR.

Referenced by vm_backtrace_print().

◆ oldbt_print_to()

static void oldbt_print_to ( void *  data,
VALUE  file,
int  lineno,
VALUE  name 
)
static

Definition at line 782 of file vm_backtrace.c.

References NIL_P, output, PRIsVALUE, rb_io_write(), rb_sprintf(), rb_str_cat2(), and rb_str_catf().

Referenced by rb_backtrace_print_to().

◆ rb_backtrace()

void rb_backtrace ( void  )

Definition at line 776 of file vm_backtrace.c.

References vm_backtrace_print().

Referenced by rescue_callback().

◆ rb_backtrace_p()

int rb_backtrace_p ( VALUE  obj)

Definition at line 410 of file vm_backtrace.c.

References rb_typeddata_is_kind_of().

Referenced by exc_backtrace(), rb_check_backtrace(), and set_backtrace().

◆ rb_backtrace_print_as_bugreport()

void rb_backtrace_print_as_bugreport ( void  )

◆ rb_backtrace_print_to()

void rb_backtrace_print_to ( VALUE  output)

◆ rb_backtrace_to_location_ary()

VALUE rb_backtrace_to_location_ary ( VALUE  self)

◆ rb_backtrace_to_str_ary()

VALUE rb_backtrace_to_str_ary ( VALUE  self)

◆ rb_debug_inspector_backtrace_locations()

VALUE rb_debug_inspector_backtrace_locations ( const rb_debug_inspector_t dc)

Definition at line 1239 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 1223 of file vm_backtrace.c.

References CALLER_BINDING_BINDING, frame_get(), 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 1216 of file vm_backtrace.c.

References CALLER_BINDING_CLASS, frame_get(), 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 
)

◆ rb_debug_inspector_frame_self_get()

VALUE rb_debug_inspector_frame_self_get ( const rb_debug_inspector_t dc,
long  index 
)

Definition at line 1209 of file vm_backtrace.c.

References CALLER_BINDING_SELF, frame_get(), and rb_ary_entry().

◆ rb_debug_inspector_open()

VALUE rb_debug_inspector_open ( rb_debug_inspector_func_t  func,
void *  data 
)

◆ rb_f_caller()

static VALUE rb_f_caller ( int  argc,
VALUE argv 
)
static

Definition at line 950 of file vm_backtrace.c.

References GET_THREAD, and vm_backtrace_to_ary().

Referenced by Init_vm_backtrace().

◆ rb_f_caller_locations()

static VALUE rb_f_caller_locations ( int  argc,
VALUE argv 
)
static

Definition at line 978 of file vm_backtrace.c.

References GET_THREAD, and vm_backtrace_to_ary().

Referenced by Init_vm_backtrace().

◆ rb_make_backtrace()

VALUE rb_make_backtrace ( void  )

Definition at line 811 of file vm_backtrace.c.

References GET_THREAD, and rb_vm_backtrace_str_ary().

Referenced by parser_set_encode().

◆ rb_profile_frame_absolute_path()

VALUE rb_profile_frame_absolute_path ( VALUE  frame)

◆ rb_profile_frame_base_label()

VALUE rb_profile_frame_base_label ( VALUE  frame)

◆ rb_profile_frame_classpath()

VALUE rb_profile_frame_classpath ( VALUE  frame)

◆ rb_profile_frame_first_lineno()

VALUE rb_profile_frame_first_lineno ( VALUE  frame)

◆ rb_profile_frame_full_label()

VALUE rb_profile_frame_full_label ( VALUE  frame)

◆ rb_profile_frame_label()

VALUE rb_profile_frame_label ( VALUE  frame)

◆ rb_profile_frame_method_name()

VALUE rb_profile_frame_method_name ( VALUE  frame)

◆ rb_profile_frame_path()

VALUE rb_profile_frame_path ( VALUE  frame)

◆ rb_profile_frame_qualified_method_name()

VALUE rb_profile_frame_qualified_method_name ( VALUE  frame)

◆ rb_profile_frame_singleton_method_p()

VALUE rb_profile_frame_singleton_method_p ( VALUE  frame)

Definition at line 1376 of file vm_backtrace.c.

References FL_SINGLETON, FL_TEST, frame2klass(), NIL_P, Qfalse, and Qtrue.

Referenced by rb_profile_frame_qualified_method_name().

◆ rb_profile_frames()

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

◆ rb_vm_backtrace_location_ary()

VALUE rb_vm_backtrace_location_ary ( rb_thread_t th,
long  lev,
long  n 
)

Definition at line 665 of file vm_backtrace.c.

References backtrace_object(), and backtrace_to_location_ary().

Referenced by rb_debug_inspector_open().

◆ rb_vm_backtrace_object()

VALUE rb_vm_backtrace_object ( void  )

Definition at line 530 of file vm_backtrace.c.

References backtrace_object(), and GET_THREAD.

Referenced by raise_argument_error(), and setup_exception().

◆ rb_vm_backtrace_str_ary()

VALUE rb_vm_backtrace_str_ary ( rb_thread_t th,
long  lev,
long  n 
)

◆ rb_vm_get_sourceline()

int rb_vm_get_sourceline ( const rb_control_frame_t cfp)

◆ rb_vm_thread_backtrace()

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

Definition at line 900 of file vm_backtrace.c.

References thread_backtrace_to_ary().

Referenced by rb_thread_backtrace_m().

◆ rb_vm_thread_backtrace_locations()

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

Definition at line 906 of file vm_backtrace.c.

References thread_backtrace_to_ary().

Referenced by rb_thread_backtrace_locations_m().

◆ thread_backtrace_to_ary()

static VALUE thread_backtrace_to_ary ( int  argc,
const VALUE argv,
VALUE  thval,
int  to_str 
)
static

◆ vm_backtrace_print()

static void vm_backtrace_print ( FILE fp)
static

◆ vm_backtrace_to_ary()

static VALUE vm_backtrace_to_ary ( rb_thread_t th,
int  argc,
const VALUE argv,
int  lev_default,
int  lev_plus,
int  to_str 
)
static

Variable Documentation

◆ backtrace_data_type

const rb_data_type_t backtrace_data_type
static
Initial value:
= {
"backtrace",
}
#define RUBY_TYPED_FREE_IMMEDIATELY
Definition: ruby.h:1145
static void backtrace_free(void *ptr)
Definition: vm_backtrace.c:389
static size_t backtrace_memsize(const void *ptr)
Definition: vm_backtrace.c:397
static void backtrace_mark(void *ptr)
Definition: vm_backtrace.c:376

Definition at line 403 of file vm_backtrace.c.

◆ location_data_type

const rb_data_type_t location_data_type
static
Initial value:
= {
"frame_info",
}
#define RUBY_TYPED_FREE_IMMEDIATELY
Definition: ruby.h:1145
static void location_mark(void *ptr)
Definition: vm_backtrace.c:77
#define RUBY_TYPED_DEFAULT_FREE
Definition: ruby.h:1141
static size_t location_memsize(const void *ptr)
Definition: vm_backtrace.c:99

Definition at line 105 of file vm_backtrace.c.

◆ rb_cBacktrace

VALUE rb_cBacktrace
static

Definition at line 19 of file vm_backtrace.c.

Referenced by bt_init(), and Init_vm_backtrace().

◆ rb_cBacktraceLocation

VALUE rb_cBacktraceLocation
static

Definition at line 20 of file vm_backtrace.c.

Referenced by Init_vm_backtrace(), and location_create().