~ubuntu-branches/ubuntu/intrepid/ruby1.9/intrepid-updates

« back to all changes in this revision

Viewing changes to debug.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2007-09-04 16:01:17 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20070904160117-i15zckg2nhxe9fyw
Tags: 1.9.0+20070830-2ubuntu1
* Sync from Debian; remaining changes:
  - Add -g to CFLAGS.
* Fixes build failure on ia64.
* Fixes build failure with gcc-4.2 on lpia.
* Robustify check for target_os, fixing build failure on lpia.
* Set Ubuntu maintainer address.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
  debug.c -
4
4
 
5
5
  $Author: ko1 $
6
 
  $Date: 2007-05-17 13:00:36 +0900 (木, 17  5月 2007) $
 
6
  $Date: 2007-08-15 13:52:56 +0900 (水, 15  8月 2007) $
7
7
  created at: 04/08/25 02:31:54 JST
8
8
 
9
9
  Copyright (C) 2004-2006 Koichi Sasada
10
10
 
11
11
**********************************************************************/
12
12
 
13
 
#include "ruby.h"
 
13
#include "ruby/ruby.h"
14
14
#include "debug.h"
 
15
#include "vm_core.h"
15
16
 
16
17
void
17
 
ruby_debug_indent(int level, int debug_level, int indent_level)
 
18
ruby_debug_print_indent(int level, int debug_level, int indent_level)
18
19
{
19
20
    if (level < debug_level) {
20
21
        int i;
26
27
}
27
28
 
28
29
VALUE
29
 
ruby_debug_value(int level, int debug_level, char *header, VALUE obj)
 
30
ruby_debug_print_value(int level, int debug_level, const char *header, VALUE obj)
30
31
{
31
32
    if (level < debug_level) {
32
33
        VALUE str;
33
34
        str = rb_inspect(obj);
34
35
        fprintf(stderr, "DBG> %s: %s\n", header,
35
 
               obj == -1 ? "" : StringValueCStr(str));
 
36
                obj == -1 ? "" : StringValueCStr(str));
36
37
        fflush(stderr);
37
38
    }
38
39
    return obj;
39
40
}
40
41
 
41
42
void
42
 
ruby_debug_v(VALUE v)
 
43
ruby_debug_print_v(VALUE v)
43
44
{
44
 
    ruby_debug_value(0, 1, "", v);
 
45
    ruby_debug_print_value(0, 1, "", v);
45
46
}
46
47
 
47
48
ID
48
 
ruby_debug_id(int level, int debug_level, char *header, ID id)
 
49
ruby_debug_print_id(int level, int debug_level, const char *header, ID id)
49
50
{
50
51
    if (level < debug_level) {
51
52
        fprintf(stderr, "DBG> %s: %s\n", header, rb_id2name(id));
55
56
}
56
57
 
57
58
NODE *
58
 
ruby_debug_node(int level, int debug_level, char *header, NODE *node)
 
59
ruby_debug_print_node(int level, int debug_level, const char *header, const NODE *node)
59
60
{
60
61
    if (level < debug_level) {
61
 
        fprintf(stderr, "DBG> %s: %s (%d)\n", header,
 
62
        fprintf(stderr, "DBG> %s: %s (%lu)\n", header,
62
63
                ruby_node_name(nd_type(node)), nd_line(node));
63
64
    }
64
 
    return node;
65
 
}
66
 
 
67
 
 
68
 
void
69
 
ruby_debug_gc_check_func(void)
70
 
{
71
 
    int i;
72
 
#define GCMKMAX 0x10
73
 
    for (i = 0; i < GCMKMAX; i++) {
74
 
        rb_ary_new2(1000);
75
 
    }
76
 
    rb_gc();
 
65
    return (NODE *)node;
77
66
}
78
67
 
79
68
void
81
70
{
82
71
    /* */
83
72
}
 
73
 
 
74
#ifdef RUBY_DEBUG_ENV
 
75
#include <ctype.h>
 
76
 
 
77
void
 
78
ruby_set_debug_option(const char *str)
 
79
{
 
80
    const char *end;
 
81
    int len;
 
82
 
 
83
    if (!str) return;
 
84
    for (; *str; str = end) {
 
85
        while (ISSPACE(*str) || *str == ',') str++;
 
86
        if (!*str) break;
 
87
        end = str;
 
88
        while (*end && !ISSPACE(*end) && *end != ',') end++;
 
89
        len = end - str;
 
90
#define SET_WHEN(name, var)                 \
 
91
        if (len == sizeof(name) - 1 &&      \
 
92
            strncmp(str, name, len) == 0) { \
 
93
            extern int ruby_##var;          \
 
94
            ruby_##var = 1;                 \
 
95
            continue;                       \
 
96
        }
 
97
        SET_WHEN("gc_stress", gc_stress);
 
98
        SET_WHEN("core", enable_coredump);
 
99
        fprintf(stderr, "unexpected debug option: %.*s\n", len, str);
 
100
    }
 
101
}
 
102
#endif