Ruby 3.3.6p108 (2024-11-05 revision 75015d4c1f6965b5e85e96fb309f1f2129f933c0)
debug.c
1/**********************************************************************
2
3 debug.c -
4
5 $Author$
6 created at: 04/08/25 02:31:54 JST
7
8 Copyright (C) 2004-2007 Koichi Sasada
9
10**********************************************************************/
11
12#include "ruby/internal/config.h"
13
14#include <stdio.h>
15
16#include "eval_intern.h"
17#include "encindex.h"
18#include "id.h"
19#include "internal/signal.h"
20#include "ruby/encoding.h"
21#include "ruby/io.h"
22#include "ruby/ruby.h"
23#include "ruby/util.h"
24#include "symbol.h"
25#include "vm_core.h"
26#include "vm_debug.h"
27#include "vm_callinfo.h"
28#include "ruby/thread_native.h"
29#include "ractor_core.h"
30
31/* This is the only place struct RIMemo is actually used */
32struct RIMemo {
33 VALUE flags;
34 VALUE v0;
35 VALUE v1;
36 VALUE v2;
37 VALUE v3;
38};
39
40/* for gdb */
41const union {
42 enum ruby_special_consts special_consts;
43 enum ruby_value_type value_type;
44 enum ruby_tag_type tag_type;
45 enum node_type node_type;
46 enum ruby_method_ids method_ids;
47 enum ruby_id_types id_types;
48 enum ruby_fl_type fl_types;
49 enum ruby_fl_ushift fl_ushift;
50 enum ruby_encoding_consts encoding_consts;
51 enum ruby_coderange_type enc_coderange_types;
52 enum ruby_econv_flag_type econv_flag_types;
53 rb_econv_result_t econv_result;
54 enum ruby_preserved_encindex encoding_index;
55 enum ruby_robject_flags robject_flags;
56 enum ruby_rmodule_flags rmodule_flags;
57 enum ruby_rstring_flags rstring_flags;
58 enum ruby_rarray_flags rarray_flags;
59 enum ruby_rarray_consts rarray_consts;
60 enum {
61 RUBY_FMODE_READABLE = FMODE_READABLE,
62 RUBY_FMODE_WRITABLE = FMODE_WRITABLE,
63 RUBY_FMODE_READWRITE = FMODE_READWRITE,
64 RUBY_FMODE_BINMODE = FMODE_BINMODE,
65 RUBY_FMODE_SYNC = FMODE_SYNC,
66 RUBY_FMODE_TTY = FMODE_TTY,
67 RUBY_FMODE_DUPLEX = FMODE_DUPLEX,
68 RUBY_FMODE_APPEND = FMODE_APPEND,
69 RUBY_FMODE_CREATE = FMODE_CREATE,
70 RUBY_FMODE_NOREVLOOKUP = 0x00000100,
71 RUBY_FMODE_TRUNC = FMODE_TRUNC,
72 RUBY_FMODE_TEXTMODE = FMODE_TEXTMODE,
73 RUBY_FMODE_EXTERNAL = 0x00010000,
74 RUBY_FMODE_SETENC_BY_BOM = FMODE_SETENC_BY_BOM,
75 RUBY_FMODE_UNIX = 0x00200000,
76 RUBY_FMODE_INET = 0x00400000,
77 RUBY_FMODE_INET6 = 0x00800000,
78
79 RUBY_NODE_TYPESHIFT = NODE_TYPESHIFT,
80 RUBY_NODE_TYPEMASK = NODE_TYPEMASK,
81 RUBY_NODE_LSHIFT = NODE_LSHIFT,
82 RUBY_NODE_FL_NEWLINE = NODE_FL_NEWLINE
83 } various;
84 union {
85 enum imemo_type types;
86 enum {RUBY_IMEMO_MASK = IMEMO_MASK} mask;
87 struct RIMemo *ptr;
88 } imemo;
89 struct RSymbol *symbol_ptr;
90 enum vm_call_flag_bits vm_call_flags;
91} ruby_dummy_gdb_enums;
92
93const SIGNED_VALUE RUBY_NODE_LMASK = NODE_LMASK;
94
95int
96ruby_debug_print_indent(int level, int debug_level, int indent_level)
97{
98 if (level < debug_level) {
99 fprintf(stderr, "%*s", indent_level, "");
100 fflush(stderr);
101 return TRUE;
102 }
103 return FALSE;
104}
105
106void
107ruby_debug_printf(const char *format, ...)
108{
109 va_list ap;
110 va_start(ap, format);
111 vfprintf(stderr, format, ap);
112 va_end(ap);
113}
114
115#include "internal/gc.h"
116
117VALUE
118ruby_debug_print_value(int level, int debug_level, const char *header, VALUE obj)
119{
120 if (level < debug_level) {
121 char buff[0x100];
122 rb_raw_obj_info(buff, 0x100, obj);
123
124 fprintf(stderr, "DBG> %s: %s\n", header, buff);
125 fflush(stderr);
126 }
127 return obj;
128}
129
130void
131ruby_debug_print_v(VALUE v)
132{
133 ruby_debug_print_value(0, 1, "", v);
134}
135
136ID
137ruby_debug_print_id(int level, int debug_level, const char *header, ID id)
138{
139 if (level < debug_level) {
140 fprintf(stderr, "DBG> %s: %s\n", header, rb_id2name(id));
141 fflush(stderr);
142 }
143 return id;
144}
145
146NODE *
147ruby_debug_print_node(int level, int debug_level, const char *header, const NODE *node)
148{
149 if (level < debug_level) {
150 fprintf(stderr, "DBG> %s: %s (%u)\n", header,
151 ruby_node_name(nd_type(node)), nd_line(node));
152 }
153 return (NODE *)node;
154}
155
156void
157ruby_debug_breakpoint(void)
158{
159 /* */
160}
161
162#if defined _WIN32
163# if RUBY_MSVCRT_VERSION >= 80
164extern int ruby_w32_rtc_error;
165# endif
166#endif
167#if defined _WIN32 || defined __CYGWIN__
168#include <windows.h>
169UINT ruby_w32_codepage[2];
170#endif
171extern int ruby_rgengc_debug;
172extern int ruby_on_ci;
173
174int
175ruby_env_debug_option(const char *str, int len, void *arg)
176{
177 int ov;
178 size_t retlen;
179 unsigned long n;
180#define SET_WHEN(name, var, val) do { \
181 if (len == sizeof(name) - 1 && \
182 strncmp(str, (name), len) == 0) { \
183 (var) = (val); \
184 return 1; \
185 } \
186 } while (0)
187#define NAME_MATCH_VALUE(name) \
188 ((size_t)len >= sizeof(name)-1 && \
189 strncmp(str, (name), sizeof(name)-1) == 0 && \
190 ((len == sizeof(name)-1 && !(len = 0)) || \
191 (str[sizeof(name)-1] == '=' && \
192 (str += sizeof(name), len -= sizeof(name), 1))))
193#define SET_UINT(val) do { \
194 n = ruby_scan_digits(str, len, 10, &retlen, &ov); \
195 if (!ov && retlen) { \
196 val = (unsigned int)n; \
197 } \
198 str += retlen; \
199 len -= retlen; \
200 } while (0)
201#define SET_UINT_LIST(name, vals, num) do { \
202 int i; \
203 for (i = 0; i < (num); ++i) { \
204 SET_UINT((vals)[i]); \
205 if (!len || *str != ':') break; \
206 ++str; \
207 --len; \
208 } \
209 if (len > 0) { \
210 fprintf(stderr, "ignored "name" option: `%.*s'\n", len, str); \
211 } \
212 } while (0)
213#define SET_WHEN_UINT(name, vals, num, req) \
214 if (NAME_MATCH_VALUE(name)) SET_UINT_LIST(name, vals, num);
215
216 SET_WHEN("gc_stress", *ruby_initial_gc_stress_ptr, Qtrue);
217 SET_WHEN("core", ruby_enable_coredump, 1);
218 SET_WHEN("ci", ruby_on_ci, 1);
219 if (NAME_MATCH_VALUE("rgengc")) {
220 if (!len) ruby_rgengc_debug = 1;
221 else SET_UINT_LIST("rgengc", &ruby_rgengc_debug, 1);
222 return 1;
223 }
224#if defined _WIN32
225# if RUBY_MSVCRT_VERSION >= 80
226 SET_WHEN("rtc_error", ruby_w32_rtc_error, 1);
227# endif
228#endif
229#if defined _WIN32 || defined __CYGWIN__
230 if (NAME_MATCH_VALUE("codepage")) {
231 if (!len) fprintf(stderr, "missing codepage argument");
232 else SET_UINT_LIST("codepage", ruby_w32_codepage, numberof(ruby_w32_codepage));
233 return 1;
234 }
235#endif
236 return 0;
237}
238
239static void
240set_debug_option(const char *str, int len, void *arg)
241{
242 if (!ruby_env_debug_option(str, len, arg)) {
243 fprintf(stderr, "unexpected debug option: %.*s\n", len, str);
244 }
245}
246
247#if USE_RUBY_DEBUG_LOG
248static void setup_debug_log(void);
249#else
250#define setup_debug_log()
251#endif
252
253void
254ruby_set_debug_option(const char *str)
255{
256 ruby_each_words(str, set_debug_option, 0);
257 setup_debug_log();
258}
259
260#if USE_RUBY_DEBUG_LOG
261
262// RUBY_DEBUG_LOG features
263// See vm_debug.h comments for details.
264
265#define MAX_DEBUG_LOG 0x1000
266#define MAX_DEBUG_LOG_MESSAGE_LEN 0x0200
267#define MAX_DEBUG_LOG_FILTER_LEN 0x0020
268#define MAX_DEBUG_LOG_FILTER_NUM 0x0010
269
270enum ruby_debug_log_mode ruby_debug_log_mode;
271
272struct debug_log_filter {
273 enum debug_log_filter_type {
274 dlf_all,
275 dlf_file, // "file:..."
276 dlf_func, // "func:..."
277 } type;
278 bool negative;
279 char str[MAX_DEBUG_LOG_FILTER_LEN];
280};
281
282static const char *dlf_type_names[] = {
283 "all",
284 "file",
285 "func",
286};
287
288#ifdef MAX_PATH
289#define DEBUG_LOG_MAX_PATH (MAX_PATH-1)
290#else
291#define DEBUG_LOG_MAX_PATH 255
292#endif
293
294static struct {
295 char *mem;
296 unsigned int cnt;
297 struct debug_log_filter filters[MAX_DEBUG_LOG_FILTER_NUM];
298 unsigned int filters_num;
299 bool show_pid;
300 rb_nativethread_lock_t lock;
301 char output_file[DEBUG_LOG_MAX_PATH+1];
302 FILE *output;
303} debug_log;
304
305static char *
306RUBY_DEBUG_LOG_MEM_ENTRY(unsigned int index)
307{
308 return &debug_log.mem[MAX_DEBUG_LOG_MESSAGE_LEN * index];
309}
310
311static enum debug_log_filter_type
312filter_type(const char *str, int *skiplen)
313{
314 if (strncmp(str, "file:", 5) == 0) {
315 *skiplen = 5;
316 return dlf_file;
317 }
318 else if(strncmp(str, "func:", 5) == 0) {
319 *skiplen = 5;
320 return dlf_func;
321 }
322 else {
323 *skiplen = 0;
324 return dlf_all;
325 }
326}
327
328static void
329setup_debug_log_filter(void)
330{
331 const char *filter_config = getenv("RUBY_DEBUG_LOG_FILTER");
332
333 if (filter_config && strlen(filter_config) > 0) {
334 unsigned int i;
335 for (i=0; i<MAX_DEBUG_LOG_FILTER_NUM && filter_config; i++) {
336 size_t len;
337 const char *str = filter_config;
338 const char *p;
339
340 if ((p = strchr(str, ',')) == NULL) {
341 len = strlen(str);
342 filter_config = NULL;
343 }
344 else {
345 len = p - str - 1; // 1 is ','
346 filter_config = p + 1;
347 }
348
349 // positive/negative
350 if (*str == '-') {
351 debug_log.filters[i].negative = true;
352 str++;
353 }
354 else if (*str == '+') {
355 // negative is false on default.
356 str++;
357 }
358
359 // type
360 int skiplen;
361 debug_log.filters[i].type = filter_type(str, &skiplen);
362 len -= skiplen;
363
364 if (len >= MAX_DEBUG_LOG_FILTER_LEN) {
365 fprintf(stderr, "too long: %s (max:%d)\n", str, MAX_DEBUG_LOG_FILTER_LEN - 1);
366 exit(1);
367 }
368
369 // body
370 strncpy(debug_log.filters[i].str, str + skiplen, len);
371 debug_log.filters[i].str[len] = 0;
372 }
373 debug_log.filters_num = i;
374
375 for (i=0; i<debug_log.filters_num; i++) {
376 fprintf(stderr, "RUBY_DEBUG_LOG_FILTER[%d]=%s (%s%s)\n", i,
377 debug_log.filters[i].str,
378 debug_log.filters[i].negative ? "-" : "",
379 dlf_type_names[debug_log.filters[i].type]);
380 }
381 }
382}
383
384static void
385setup_debug_log(void)
386{
387 // check RUBY_DEBUG_LOG
388 const char *log_config = getenv("RUBY_DEBUG_LOG");
389 if (log_config && strlen(log_config) > 0) {
390 if (strcmp(log_config, "mem") == 0) {
391 debug_log.mem = (char *)malloc(MAX_DEBUG_LOG * MAX_DEBUG_LOG_MESSAGE_LEN);
392 if (debug_log.mem == NULL) {
393 fprintf(stderr, "setup_debug_log failed (can't allocate memory)\n");
394 exit(1);
395 }
396 ruby_debug_log_mode |= ruby_debug_log_memory;
397 }
398 else if (strcmp(log_config, "stderr") == 0) {
399 ruby_debug_log_mode |= ruby_debug_log_stderr;
400 }
401 else {
402 ruby_debug_log_mode |= ruby_debug_log_file;
403
404 // pid extension with %p
405 unsigned long len = strlen(log_config);
406
407 for (unsigned long i=0, j=0; i<len; i++) {
408 const char c = log_config[i];
409
410 if (c == '%') {
411 i++;
412 switch (log_config[i]) {
413 case '%':
414 debug_log.output_file[j++] = '%';
415 break;
416 case 'p':
417 snprintf(debug_log.output_file + j, DEBUG_LOG_MAX_PATH - j, "%d", getpid());
418 j = strlen(debug_log.output_file);
419 break;
420 default:
421 fprintf(stderr, "can not parse RUBY_DEBUG_LOG filename: %s\n", log_config);
422 exit(1);
423 }
424 }
425 else {
426 debug_log.output_file[j++] = c;
427 }
428
429 if (j >= DEBUG_LOG_MAX_PATH) {
430 fprintf(stderr, "RUBY_DEBUG_LOG=%s is too long\n", log_config);
431 exit(1);
432 }
433 }
434
435 if ((debug_log.output = fopen(debug_log.output_file, "w")) == NULL) {
436 fprintf(stderr, "can not open %s for RUBY_DEBUG_LOG\n", log_config);
437 exit(1);
438 }
439 setvbuf(debug_log.output, NULL, _IONBF, 0);
440 }
441
442 fprintf(stderr, "RUBY_DEBUG_LOG=%s %s%s%s\n", log_config,
443 (ruby_debug_log_mode & ruby_debug_log_memory) ? "[mem]" : "",
444 (ruby_debug_log_mode & ruby_debug_log_stderr) ? "[stderr]" : "",
445 (ruby_debug_log_mode & ruby_debug_log_file) ? "[file]" : "");
446 if (debug_log.output_file[0]) {
447 fprintf(stderr, "RUBY_DEBUG_LOG filename=%s\n", debug_log.output_file);
448 }
449
450 rb_nativethread_lock_initialize(&debug_log.lock);
451
452 setup_debug_log_filter();
453
454 if (getenv("RUBY_DEBUG_LOG_PID")) {
455 debug_log.show_pid = true;
456 }
457 }
458}
459
460static bool
461check_filter(const char *str, const struct debug_log_filter *filter, bool *state)
462{
463 if (filter->negative) {
464 if (strstr(str, filter->str) == NULL) {
465 *state = true;
466 return false;
467 }
468 else {
469 *state = false;
470 return true;
471 }
472 }
473 else {
474 if (strstr(str, filter->str) != NULL) {
475 *state = true;
476 return true;
477 }
478 else {
479 *state = false;
480 return false;
481 }
482 }
483}
484
485//
486// RUBY_DEBUG_LOG_FILTER=-foo,-bar,baz,boo
487// returns true if
488// (func_name or file_name) doesn't contain foo
489// and
490// (func_name or file_name) doesn't contain bar
491// and
492// (func_name or file_name) contains baz or boo
493//
494// RUBY_DEBUG_LOG_FILTER=foo,bar,-baz,-boo
495// returns true if
496// (func_name or file_name) contains foo or bar
497// or
498// (func_name or file_name) doesn't contain baz and
499// (func_name or file_name) doesn't contain boo and
500//
501// You can specify "file:" (ex file:foo) or "func:" (ex func:foo)
502// prefixes to specify the filter for.
503//
504bool
505ruby_debug_log_filter(const char *func_name, const char *file_name)
506{
507 if (debug_log.filters_num > 0) {
508 bool state = false;
509
510 for (unsigned int i = 0; i<debug_log.filters_num; i++) {
511 const struct debug_log_filter *filter = &debug_log.filters[i];
512
513 switch (filter->type) {
514 case dlf_all:
515 if (check_filter(func_name, filter, &state)) return state;
516 if (check_filter(file_name, filter, &state)) return state;
517 break;
518 case dlf_func:
519 if (check_filter(func_name, filter, &state)) return state;
520 break;
521 case dlf_file:
522 if (check_filter(file_name, filter, &state)) return state;
523 break;
524 }
525 }
526 return state;
527 }
528 else {
529 return true;
530 }
531}
532
533static const char *
534pretty_filename(const char *path)
535{
536 // basename is one idea.
537 const char *s;
538 while ((s = strchr(path, '/')) != NULL) {
539 path = s+1;
540 }
541 return path;
542}
543
544#undef ruby_debug_log
545void
546ruby_debug_log(const char *file, int line, const char *func_name, const char *fmt, ...)
547{
548 char buff[MAX_DEBUG_LOG_MESSAGE_LEN] = {0};
549 int len = 0;
550 int r = 0;
551
552 if (debug_log.show_pid) {
553 r = snprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN, "pid:%d\t", getpid());
554 if (r < 0) rb_bug("ruby_debug_log returns %d", r);
555 len += r;
556 }
557
558 // message title
559 if (func_name && len < MAX_DEBUG_LOG_MESSAGE_LEN) {
560 r = snprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN, "%s\t", func_name);
561 if (r < 0) rb_bug("ruby_debug_log returns %d", r);
562 len += r;
563 }
564
565 // message
566 if (fmt && len < MAX_DEBUG_LOG_MESSAGE_LEN) {
567 va_list args;
568 va_start(args, fmt);
569 r = vsnprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN - len, fmt, args);
570 va_end(args);
571 if (r < 0) rb_bug("ruby_debug_log vsnprintf() returns %d", r);
572 len += r;
573 }
574
575 // optional information
576
577 // C location
578 if (file && len < MAX_DEBUG_LOG_MESSAGE_LEN) {
579 r = snprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN, "\t%s:%d", pretty_filename(file), line);
580 if (r < 0) rb_bug("ruby_debug_log returns %d", r);
581 len += r;
582 }
583
584 rb_execution_context_t *ec = rb_current_execution_context(false);
585
586 // Ruby location
587 int ruby_line;
588 const char *ruby_file = ec ? rb_source_location_cstr(&ruby_line) : NULL;
589
590 if (len < MAX_DEBUG_LOG_MESSAGE_LEN) {
591 if (ruby_file) {
592 r = snprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN - len, "\t%s:%d", pretty_filename(ruby_file), ruby_line);
593 }
594 else {
595 r = snprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN - len, "\t");
596 }
597 if (r < 0) rb_bug("ruby_debug_log returns %d", r);
598 len += r;
599 }
600
601#ifdef RUBY_NT_SERIAL
602 // native thread information
603 if (len < MAX_DEBUG_LOG_MESSAGE_LEN) {
604 r = snprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN - len, "\tnt:%d", ruby_nt_serial);
605 if (r < 0) rb_bug("ruby_debug_log returns %d", r);
606 len += r;
607 }
608#endif
609
610 if (ec) {
611 rb_thread_t *th = ec ? rb_ec_thread_ptr(ec) : NULL;
612
613 // ractor information
614 if (ruby_single_main_ractor == NULL) {
615 rb_ractor_t *cr = th ? th->ractor : NULL;
616 rb_vm_t *vm = GET_VM();
617
618 if (r && len < MAX_DEBUG_LOG_MESSAGE_LEN) {
619 r = snprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN - len, "\tr:#%d/%u (%u)",
620 cr ? (int)rb_ractor_id(cr) : -1, vm->ractor.cnt, vm->ractor.sched.running_cnt);
621
622 if (r < 0) rb_bug("ruby_debug_log returns %d", r);
623 len += r;
624 }
625 }
626
627 // thread information
628 if (th && r && len < MAX_DEBUG_LOG_MESSAGE_LEN) {
629 rb_execution_context_t *rec = th->ractor ? th->ractor->threads.running_ec : NULL;
630 const rb_thread_t *rth = rec ? rec->thread_ptr : NULL;
631 const rb_thread_t *sth = th->ractor ? th->ractor->threads.sched.running : NULL;
632
633 if (rth != th || sth != th) {
634 r = snprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN - len, "\tth:%u (rth:%d,sth:%d)",
635 rb_th_serial(th), rth ? (int)rb_th_serial(rth) : -1, sth ? (int)rb_th_serial(sth) : -1);
636 }
637 else {
638 r = snprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN - len, "\tth:%u", rb_th_serial(th));
639 }
640 if (r < 0) rb_bug("ruby_debug_log returns %d", r);
641 len += r;
642 }
643 }
644
645 rb_nativethread_lock_lock(&debug_log.lock);
646 {
647 unsigned int cnt = debug_log.cnt++;
648
649 if (ruby_debug_log_mode & ruby_debug_log_memory) {
650 unsigned int index = cnt % MAX_DEBUG_LOG;
651 char *dst = RUBY_DEBUG_LOG_MEM_ENTRY(index);
652 strncpy(dst, buff, MAX_DEBUG_LOG_MESSAGE_LEN);
653 }
654 if (ruby_debug_log_mode & ruby_debug_log_stderr) {
655 fprintf(stderr, "%4u: %s\n", cnt, buff);
656 }
657 if (ruby_debug_log_mode & ruby_debug_log_file) {
658 fprintf(debug_log.output, "%u\t%s\n", cnt, buff);
659 }
660 }
661 rb_nativethread_lock_unlock(&debug_log.lock);
662}
663
664// for debugger
665static void
666debug_log_dump(FILE *out, unsigned int n)
667{
668 if (ruby_debug_log_mode & ruby_debug_log_memory) {
669 unsigned int size = debug_log.cnt > MAX_DEBUG_LOG ? MAX_DEBUG_LOG : debug_log.cnt;
670 unsigned int current_index = debug_log.cnt % MAX_DEBUG_LOG;
671 if (n == 0) n = size;
672 if (n > size) n = size;
673
674 for (unsigned int i=0; i<n; i++) {
675 int index = current_index - size + i;
676 if (index < 0) index += MAX_DEBUG_LOG;
677 VM_ASSERT(index <= MAX_DEBUG_LOG);
678 const char *mesg = RUBY_DEBUG_LOG_MEM_ENTRY(index);;
679 fprintf(out, "%4u: %s\n", debug_log.cnt - size + i, mesg);
680 }
681 }
682 else {
683 fprintf(stderr, "RUBY_DEBUG_LOG=mem is not specified.");
684 }
685}
686
687// for debuggers
688
689void
690ruby_debug_log_print(unsigned int n)
691{
692 debug_log_dump(stderr, n);
693}
694
695void
696ruby_debug_log_dump(const char *fname, unsigned int n)
697{
698 FILE *fp = fopen(fname, "w");
699 if (fp == NULL) {
700 fprintf(stderr, "can't open %s. give up.\n", fname);
701 }
702 else {
703 debug_log_dump(fp, n);
704 fclose(fp);
705 }
706}
707#endif // #if USE_RUBY_DEBUG_LOG
ruby_coderange_type
What rb_enc_str_coderange() returns.
Definition coderange.h:33
ruby_fl_ushift
This is an enum because GDB wants it (rather than a macro).
Definition fl_type.h:154
ruby_fl_type
The flags.
Definition fl_type.h:185
#define Qtrue
Old name of RUBY_Qtrue.
Encoding relates APIs.
rb_econv_result_t
return value of rb_econv_convert()
Definition transcode.h:30
ruby_econv_flag_type
This enum is kind of omnibus.
Definition transcode.h:452
#define FMODE_READABLE
The IO is opened for reading.
Definition io.h:270
#define FMODE_SETENC_BY_BOM
This flag amends the encoding of the IO so that the BOM of the contents of the IO takes effect.
Definition io.h:368
#define FMODE_READWRITE
The IO is opened for both read/write.
Definition io.h:276
#define FMODE_TTY
The IO is a TTY.
Definition io.h:300
#define FMODE_CREATE
The IO is opened for creating.
Definition io.h:323
#define FMODE_WRITABLE
The IO is opened for writing.
Definition io.h:273
#define FMODE_APPEND
The IO is opened for appending.
Definition io.h:315
#define FMODE_DUPLEX
Ruby eventually detects that the IO is bidirectional.
Definition io.h:308
#define FMODE_BINMODE
The IO is in "binary mode".
Definition io.h:287
#define FMODE_SYNC
The IO is in "sync mode".
Definition io.h:294
#define FMODE_TEXTMODE
The IO is in "text mode".
Definition io.h:351
#define FMODE_TRUNC
This flag amends the effect of FMODE_CREATE, so that if there already is a file at the given path it ...
Definition io.h:337
int len
Length of the buffer.
Definition io.h:8
void ruby_each_words(const char *str, void(*func)(const char *word, int len, void *argv), void *argv)
Scans the passed string, with calling the callback function every time it encounters a "word".
Definition util.c:593
VALUE type(ANYARGS)
ANYARGS-ed function type.
ruby_rarray_consts
This is an enum because GDB wants it (rather than a macro).
Definition rarray.h:122
ruby_special_consts
special constants - i.e.
Definition debug.c:32
void rb_nativethread_lock_lock(rb_nativethread_lock_t *lock)
Blocks until the current thread obtains a lock.
Definition thread.c:298
void rb_nativethread_lock_unlock(rb_nativethread_lock_t *lock)
Releases a lock.
Definition thread.c:304
void rb_nativethread_lock_initialize(rb_nativethread_lock_t *lock)
Fills the passed lock with an initial value.
Definition thread.c:286
intptr_t SIGNED_VALUE
A signed integer type that has the same width with VALUE.
Definition value.h:63
uintptr_t ID
Type that represents a Ruby identifier such as a variable name.
Definition value.h:52
uintptr_t VALUE
Type that represents a Ruby object.
Definition value.h:40
ruby_value_type
C-level type of an object.
Definition value_type.h:112