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
|
@ -1,3 +1,9 @@
|
||||||
|
Fri Jun 29 16:57:22 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* debug.c (ruby_set_debug_option): separated from main.c.
|
||||||
|
|
||||||
|
* gc.c (ruby_gc_stress), signal.c (ruby_enable_coredump): prefixed.
|
||||||
|
|
||||||
Fri Jun 29 16:39:06 2007 Koichi Sasada <ko1@atdot.net>
|
Fri Jun 29 16:39:06 2007 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
* proc.c (proc_new): fix to return a proc object
|
* proc.c (proc_new): fix to return a proc object
|
||||||
|
|
41
debug.c
41
debug.c
|
@ -12,6 +12,7 @@
|
||||||
|
|
||||||
#include "ruby/ruby.h"
|
#include "ruby/ruby.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
#include "yarvcore.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
ruby_debug_print_indent(int level, int debug_level, int indent_level)
|
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
|
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) {
|
if (level < debug_level) {
|
||||||
VALUE str;
|
VALUE str;
|
||||||
|
@ -45,7 +46,7 @@ ruby_debug_print_v(VALUE v)
|
||||||
}
|
}
|
||||||
|
|
||||||
ID
|
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) {
|
if (level < debug_level) {
|
||||||
fprintf(stderr, "DBG> %s: %s\n", header, rb_id2name(id));
|
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 *
|
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) {
|
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));
|
ruby_node_name(nd_type(node)), nd_line(node));
|
||||||
}
|
}
|
||||||
return node;
|
return (NODE *)node;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
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
|
||||||
|
|
12
gc.c
12
gc.c
|
@ -148,7 +148,7 @@ VALUE *rb_gc_stack_start = 0;
|
||||||
VALUE *rb_gc_register_stack_start = 0;
|
VALUE *rb_gc_register_stack_start = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int gc_stress = 0;
|
int ruby_gc_stress = 0;
|
||||||
|
|
||||||
|
|
||||||
#ifdef DJGPP
|
#ifdef DJGPP
|
||||||
|
@ -201,7 +201,7 @@ rb_memerror(void)
|
||||||
static VALUE
|
static VALUE
|
||||||
gc_stress_get(VALUE self)
|
gc_stress_get(VALUE self)
|
||||||
{
|
{
|
||||||
return gc_stress ? Qtrue : Qfalse;
|
return ruby_gc_stress ? Qtrue : Qfalse;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -220,7 +220,7 @@ static VALUE
|
||||||
gc_stress_set(VALUE self, VALUE bool)
|
gc_stress_set(VALUE self, VALUE bool)
|
||||||
{
|
{
|
||||||
rb_secure(2);
|
rb_secure(2);
|
||||||
gc_stress = RTEST(bool);
|
ruby_gc_stress = RTEST(bool);
|
||||||
return bool;
|
return bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,7 +235,7 @@ ruby_xmalloc(size_t size)
|
||||||
if (size == 0) size = 1;
|
if (size == 0) size = 1;
|
||||||
malloc_increase += size;
|
malloc_increase += size;
|
||||||
|
|
||||||
if (gc_stress || malloc_increase > malloc_limit) {
|
if (ruby_gc_stress || malloc_increase > malloc_limit) {
|
||||||
garbage_collect();
|
garbage_collect();
|
||||||
}
|
}
|
||||||
RUBY_CRITICAL(mem = malloc(size));
|
RUBY_CRITICAL(mem = malloc(size));
|
||||||
|
@ -283,7 +283,7 @@ ruby_xrealloc(void *ptr, size_t size)
|
||||||
if (!ptr) return ruby_xmalloc(size);
|
if (!ptr) return ruby_xmalloc(size);
|
||||||
if (size == 0) size = 1;
|
if (size == 0) size = 1;
|
||||||
malloc_increase += size;
|
malloc_increase += size;
|
||||||
if (gc_stress) garbage_collect();
|
if (ruby_gc_stress) garbage_collect();
|
||||||
RUBY_CRITICAL(mem = realloc(ptr, size));
|
RUBY_CRITICAL(mem = realloc(ptr, size));
|
||||||
if (!mem) {
|
if (!mem) {
|
||||||
if (garbage_collect()) {
|
if (garbage_collect()) {
|
||||||
|
@ -466,7 +466,7 @@ rb_newobj_from_heap(void)
|
||||||
{
|
{
|
||||||
VALUE obj;
|
VALUE obj;
|
||||||
|
|
||||||
if (gc_stress || !freelist) {
|
if (ruby_gc_stress || !freelist) {
|
||||||
if(!garbage_collect()) {
|
if(!garbage_collect()) {
|
||||||
rb_memerror();
|
rb_memerror();
|
||||||
}
|
}
|
||||||
|
|
16
main.c
16
main.c
|
@ -30,20 +30,8 @@ int
|
||||||
main(int argc, char **argv, char **envp)
|
main(int argc, char **argv, char **envp)
|
||||||
{
|
{
|
||||||
#ifdef RUBY_DEBUG_ENV
|
#ifdef RUBY_DEBUG_ENV
|
||||||
RUBY_EXTERN int gc_stress;
|
extern void ruby_set_debug_option(const char *);
|
||||||
RUBY_EXTERN int enable_coredump;
|
ruby_set_debug_option(getenv("RUBY_DEBUG"));
|
||||||
char *str;
|
|
||||||
str = getenv("RUBY_DEBUG");
|
|
||||||
if (str) {
|
|
||||||
for (str = strtok(str, ","); str; str = strtok(NULL, ",")) {
|
|
||||||
if (strcmp(str, "gc_stress") == 0)
|
|
||||||
gc_stress = 1;
|
|
||||||
else if (strcmp(str, "core") == 0)
|
|
||||||
enable_coredump = 1;
|
|
||||||
else
|
|
||||||
fprintf(stderr, "unexpected debug option: %s\n", str);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
NtInitialize(&argc, &argv);
|
NtInitialize(&argc, &argv);
|
||||||
|
|
8
signal.c
8
signal.c
|
@ -529,9 +529,9 @@ sigsegv(int sig)
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
extern int gc_stress;
|
extern int ruby_gc_stress;
|
||||||
segv_received = 1;
|
segv_received = 1;
|
||||||
gc_stress = 0;
|
ruby_gc_stress = 0;
|
||||||
rb_bug("Segmentation fault");
|
rb_bug("Segmentation fault");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -994,7 +994,7 @@ init_sigchld(int sig)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef RUBY_DEBUG_ENV
|
#ifdef RUBY_DEBUG_ENV
|
||||||
int enable_coredump = 0;
|
int ruby_enable_coredump = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1070,7 +1070,7 @@ Init_signal(void)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef RUBY_DEBUG_ENV
|
#ifdef RUBY_DEBUG_ENV
|
||||||
if (!enable_coredump)
|
if (!ruby_enable_coredump)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#ifdef SIGBUS
|
#ifdef SIGBUS
|
||||||
|
|
Loading…
Add table
Reference in a new issue