mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* debug.c (ruby_set_debug_option): separated from main.c.
* gc.c (ruby_gc_stress), signal.c (ruby_enable_coredump): prefixed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12665 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
e648fc4923
commit
eae8a9143f
5 changed files with 54 additions and 29 deletions
41
debug.c
41
debug.c
|
@ -12,6 +12,7 @@
|
|||
|
||||
#include "ruby/ruby.h"
|
||||
#include "debug.h"
|
||||
#include "yarvcore.h"
|
||||
|
||||
void
|
||||
ruby_debug_print_indent(int level, int debug_level, int indent_level)
|
||||
|
@ -26,7 +27,7 @@ ruby_debug_print_indent(int level, int debug_level, int indent_level)
|
|||
}
|
||||
|
||||
VALUE
|
||||
ruby_debug_print_value(int level, int debug_level, char *header, VALUE obj)
|
||||
ruby_debug_print_value(int level, int debug_level, const char *header, VALUE obj)
|
||||
{
|
||||
if (level < debug_level) {
|
||||
VALUE str;
|
||||
|
@ -45,7 +46,7 @@ ruby_debug_print_v(VALUE v)
|
|||
}
|
||||
|
||||
ID
|
||||
ruby_debug_print_id(int level, int debug_level, char *header, ID id)
|
||||
ruby_debug_print_id(int level, int debug_level, const char *header, ID id)
|
||||
{
|
||||
if (level < debug_level) {
|
||||
fprintf(stderr, "DBG> %s: %s\n", header, rb_id2name(id));
|
||||
|
@ -55,13 +56,13 @@ ruby_debug_print_id(int level, int debug_level, char *header, ID id)
|
|||
}
|
||||
|
||||
NODE *
|
||||
ruby_debug_print_node(int level, int debug_level, char *header, NODE *node)
|
||||
ruby_debug_print_node(int level, int debug_level, const char *header, const NODE *node)
|
||||
{
|
||||
if (level < debug_level) {
|
||||
fprintf(stderr, "DBG> %s: %s (%d)\n", header,
|
||||
fprintf(stderr, "DBG> %s: %s (%lu)\n", header,
|
||||
ruby_node_name(nd_type(node)), nd_line(node));
|
||||
}
|
||||
return node;
|
||||
return (NODE *)node;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -69,3 +70,33 @@ ruby_debug_breakpoint(void)
|
|||
{
|
||||
/* */
|
||||
}
|
||||
|
||||
#ifdef RUBY_DEBUG_ENV
|
||||
#include <ctype.h>
|
||||
|
||||
void
|
||||
ruby_set_debug_option(const char *str)
|
||||
{
|
||||
const char *end;
|
||||
int len;
|
||||
|
||||
if (!str) return;
|
||||
for (; *str; str = end) {
|
||||
while (ISSPACE(*str) || *str == ',') str++;
|
||||
if (!*str) break;
|
||||
end = str;
|
||||
while (*end && !ISSPACE(*end) && *end != ',') end++;
|
||||
len = end - str;
|
||||
#define SET_WHEN(name, var) \
|
||||
if (len == sizeof(name) - 1 && \
|
||||
strncmp(str, name, len) == 0) { \
|
||||
extern int ruby_##var; \
|
||||
ruby_##var = 1; \
|
||||
continue; \
|
||||
}
|
||||
SET_WHEN("gc_stress", gc_stress);
|
||||
SET_WHEN("core", enable_coredump);
|
||||
fprintf(stderr, "unexpected debug option: %.*s\n", len, str);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue