1 /**********************************************************************
6 created at: 04/08/25 02:31:54 JST
8 Copyright (C) 2004-2007 Koichi Sasada
10 **********************************************************************/
12 #include "ruby/ruby.h"
13 #include "ruby/encoding.h"
14 #include "ruby/util.h"
16 #include "eval_intern.h"
21 enum ruby_special_consts special_consts
;
22 enum ruby_value_type value_type
;
23 enum ruby_tag_type tag_type
;
24 enum node_type node_type
;
26 RUBY_ENCODING_INLINE_MAX
= ENCODING_INLINE_MAX
,
27 RUBY_ENCODING_SHIFT
= ENCODING_SHIFT
,
28 RUBY_ENCODING_MASK
= ENCODING_MASK
,
29 RUBY_ENC_CODERANGE_MASK
= ENC_CODERANGE_MASK
,
30 RUBY_ENC_CODERANGE_UNKNOWN
= ENC_CODERANGE_UNKNOWN
,
31 RUBY_ENC_CODERANGE_7BIT
= ENC_CODERANGE_7BIT
,
32 RUBY_ENC_CODERANGE_VALID
= ENC_CODERANGE_VALID
,
33 RUBY_ENC_CODERANGE_BROKEN
= ENC_CODERANGE_BROKEN
,
34 RUBY_FL_MARK
= FL_MARK
,
35 RUBY_FL_RESERVED
= FL_RESERVED
,
36 RUBY_FL_FINALIZE
= FL_FINALIZE
,
37 RUBY_FL_TAINT
= FL_TAINT
,
38 RUBY_FL_EXIVAR
= FL_EXIVAR
,
39 RUBY_FL_FREEZE
= FL_FREEZE
,
40 RUBY_FL_SINGLETON
= FL_SINGLETON
,
41 RUBY_FL_USER0
= FL_USER0
,
42 RUBY_FL_USER1
= FL_USER1
,
43 RUBY_FL_USER2
= FL_USER2
,
44 RUBY_FL_USER3
= FL_USER3
,
45 RUBY_FL_USER4
= FL_USER4
,
46 RUBY_FL_USER5
= FL_USER5
,
47 RUBY_FL_USER6
= FL_USER6
,
48 RUBY_FL_USER7
= FL_USER7
,
49 RUBY_FL_USER8
= FL_USER8
,
50 RUBY_FL_USER9
= FL_USER9
,
51 RUBY_FL_USER10
= FL_USER10
,
52 RUBY_FL_USER11
= FL_USER11
,
53 RUBY_FL_USER12
= FL_USER12
,
54 RUBY_FL_USER13
= FL_USER13
,
55 RUBY_FL_USER14
= FL_USER14
,
56 RUBY_FL_USER15
= FL_USER15
,
57 RUBY_FL_USER16
= FL_USER16
,
58 RUBY_FL_USER17
= FL_USER17
,
59 RUBY_FL_USER18
= FL_USER18
,
60 RUBY_FL_USER19
= FL_USER19
,
61 RUBY_FL_USHIFT
= FL_USHIFT
,
62 RUBY_NODE_TYPESHIFT
= NODE_TYPESHIFT
,
63 RUBY_NODE_TYPEMASK
= NODE_TYPEMASK
,
64 RUBY_NODE_LSHIFT
= NODE_LSHIFT
,
65 RUBY_NODE_LMASK
= NODE_LMASK
,
66 RUBY_NODE_FL_NEWLINE
= NODE_FL_NEWLINE
70 const VALUE RUBY_FL_USER20
= FL_USER20
;
73 ruby_debug_print_indent(int level
, int debug_level
, int indent_level
)
75 if (level
< debug_level
) {
76 fprintf(stderr
, "%*s", indent_level
, "");
84 ruby_debug_printf(const char *format
, ...)
88 vfprintf(stderr
, format
, ap
);
93 ruby_debug_print_value(int level
, int debug_level
, const char *header
, VALUE obj
)
95 if (level
< debug_level
) {
97 str
= rb_inspect(obj
);
98 fprintf(stderr
, "DBG> %s: %s\n", header
,
99 obj
== -1 ? "" : StringValueCStr(str
));
106 ruby_debug_print_v(VALUE v
)
108 ruby_debug_print_value(0, 1, "", v
);
112 ruby_debug_print_id(int level
, int debug_level
, const char *header
, ID id
)
114 if (level
< debug_level
) {
115 fprintf(stderr
, "DBG> %s: %s\n", header
, rb_id2name(id
));
122 ruby_debug_print_node(int level
, int debug_level
, const char *header
, const NODE
*node
)
124 if (level
< debug_level
) {
125 fprintf(stderr
, "DBG> %s: %s (%lu)\n", header
,
126 ruby_node_name(nd_type(node
)), nd_line(node
));
132 ruby_debug_breakpoint(void)
137 #ifdef RUBY_DEBUG_ENV
139 set_debug_option(const char *str
, int len
, void *arg
)
141 #define SET_WHEN(name, var) do { \
142 if (len == sizeof(name) - 1 && \
143 strncmp(str, name, len) == 0) { \
149 SET_WHEN("gc_stress", *ruby_initial_gc_stress_ptr
);
150 SET_WHEN("core", ruby_enable_coredump
);
151 fprintf(stderr
, "unexpected debug option: %.*s\n", len
, str
);
155 ruby_set_debug_option(const char *str
)
157 ruby_each_words(str
, set_debug_option
, 0);