1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* include/ruby/{node,ruby}.h, ruby.c: added enum constants for gdb

support.  [ruby-dev:31066]

* .gdbinit: some improvements.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12695 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2007-07-05 01:42:09 +00:00
parent 6bbcf6f43d
commit e8b0aa4ca0
5 changed files with 602 additions and 95 deletions

399
.gdbinit
View file

@ -1,19 +1,9 @@
set $fl_ushift = 11
set $fl_user1 = 1 << ($fl_ushift + 0)
set $fl_user1 = 1 << ($fl_ushift + 1)
set $fl_user2 = 1 << ($fl_ushift + 2)
set $fl_user3 = 1 << ($fl_ushift + 3)
set $fl_user4 = 1 << ($fl_ushift + 4)
set $fl_user5 = 1 << ($fl_ushift + 5)
set $fl_user6 = 1 << ($fl_ushift + 6)
set $fl_user7 = 1 << ($fl_ushift + 7)
define rp
if $arg0 & 1
printf "FIXNUM: %d\n", ((long)$arg0) >> 1
if (long)$arg0 & 1
printf "FIXNUM: %d\n", $arg0 >> 1
else
if ($arg0 & 0xff) == 0x0e
printf "SYMBOL(%d)\n", ((long)$arg0) >> 8
if ((long)$arg0 & 0xff) == 0x0e
printf "SYMBOL(%d)\n", $arg0 >> 8
else
if $arg0 == 0
echo false\n
@ -27,84 +17,115 @@ define rp
if $arg0 == 6
echo undef\n
else
if $arg0 & 0x03
if (long)$arg0 & 0x03
echo immediate\n
else
set $flags = ((struct RBasic*)$arg0)->flags
if ($flags & 0x1f) == 0x00
printf "T_NONE(0x%08x)\n", $arg0
printf "T_NONE: "
print (struct RBasic *)$arg0
else
if ($flags & 0x1f) == 0x01
printf "T_NIL(0x%08x)\n", $arg0
printf "T_NIL: "
print (struct RBasic *)$arg0
else
if ($flags & 0x1f) == 0x02
printf "T_OBJECT(0x%08x)\n", $arg0
printf "T_OBJECT: "
print (struct RObject *)$arg0
else
if ($flags & 0x1f) == 0x03
printf "T_CLASS(0x%08x)\n", $arg0
printf "T_CLASS: "
print (struct RClass *)$arg0
else
if ($flags & 0x1f) == 0x04
printf "T_ICLASS(0x%08x)\n", $arg0
printf "T_ICLASS: "
print (struct RClass *)$arg0
else
if ($flags & 0x1f) == 0x05
printf "T_MODULE(0x%08x)\n", $arg0
printf "T_MODULE: "
print (struct RClass *)$arg0
else
if ($flags & 0x1f) == 0x06
printf "T_FLOAT(0x%08x): %.16g\n", $arg0, (((struct RFloat*)$arg0)->value)
printf "T_FLOAT: %.16g ", (((struct RFloat*)$arg0)->value)
print (struct RFloat *)$arg0
else
if ($flags & 0x1f) == 0x07
printf "T_STRING(0x%08x): \"%s\"\n", $arg0, ($flags & $fl_user1) ? ((struct RString*)$arg0)->as.heap.ptr : ((struct RString*)$arg0)->as.ary
printf "T_STRING: \"%s\" ", ($flags & RUBY_FL_USER1) ? ((struct RString*)$arg0)->as.heap.ptr : ((struct RString*)$arg0)->as.ary
print (struct RString *)$arg0
else
if ($flags & 0x1f) == 0x08
printf "T_REGEXP(0x%08x): \"%s\"\n", $arg0, (((struct RRegexp*)$arg0)->str)
printf "T_REGEXP: \"%s\" ", (((struct RRegexp*)$arg0)->str)
print (struct RRegexp *)$arg0
else
if ($flags & 0x1f) == 0x09
printf "T_ARRAY(0x%08x) len=%d\n", $arg0, ((struct RArray*)$arg0)->len
printf "T_ARRAY: len=%d ", ((struct RArray*)$arg0)->len
print (struct RArray *)$arg0
x/xw ((struct RArray*)$arg0)->ptr
else
if ($flags & 0x1f) == 0x0a
printf "T_FIXNUM(0x%08x)\n", $arg0
printf "T_FIXNUM: "
print (struct RBasic *)$arg0
else
if ($flags & 0x1f) == 0x0b
printf "T_HASH(0x%08x)\n", $arg0
printf "T_HASH: len=%d ", ((struct RHash *)$arg0)->tbl ? ((struct RHash *)$arg0)->tbl->num_entries : 0
print (struct RHash *)$arg0
else
if ($flags & 0x1f) == 0x0c
printf "T_STRUCT(0x%08x)\n", $arg0
printf "T_STRUCT: len=%d ", (($flags & (RUBY_FL_USER1|RUBY_FL_USER2)) ? ($flags & (RUBY_FL_USER1|RUBY_FL_USER2)) >> (RUBY_FL_USHIFT+1) : ((struct RStruct *)$arg0)->as.heap.len)
print (struct RStruct *)$arg0
x/xw (($flags & (RUBY_FL_USER1|RUBY_FL_USER2)) ? ((struct RStruct *)$arg0)->as.ary : ((struct RStruct *)$arg0)->as.heap.len)
else
if ($flags & 0x1f) == 0x0d
printf "T_BIGNUM(0x%08x): sign=%d len=%d\n", $arg0, ((struct RBignum*)$arg0)->sign, ((struct RBignum*)$arg0)->len
printf "T_BIGNUM: sign=%d len=%d ", ((struct RBignum*)$arg0)->sign, ((struct RBignum*)$arg0)->len
print (struct RBignum *)$arg0
x/xw ((struct RBignum*)$arg0)->digits
else
if ($flags & 0x1f) == 0x0e
printf "T_FILE(0x%08x)\n", $arg0
printf "T_FILE: "
print (struct RFile *)$arg0
output *((struct RFile *)$arg0)->fptr
printf "\n"
else
if ($flags & 0x1f) == 0x10
printf "T_TRUE(0x%08x)\n", $arg0
printf "T_TRUE: "
print (struct RBasic *)$arg0
else
if ($flags & 0x1f) == 0x11
printf "T_FALSE(0x%08x)\n", $arg0
printf "T_FALSE: "
print (struct RBasic *)$arg0
else
if ($flags & 0x1f) == 0x12
printf "T_DATA(0x%08x)\n", $arg0
printf "T_DATA: "
print (struct RData *)$arg0
else
if ($flags & 0x1f) == 0x13
printf "T_MATCH(0x%08x)\n", $arg0
printf "T_MATCH: "
print (struct RMatch *)$arg0
else
if ($flags & 0x1f) == 0x14
printf "T_SYMBOL(0x%08x)\n", $arg0
printf "T_SYMBOL: "
print (struct RBasic *)$arg0
else
if ($flags & 0x1f) == 0x1a
printf "T_VALUES(0x%08x)\n", $arg0
printf "T_VALUES: "
print (struct RBasic *)$arg0
else
if ($flags & 0x1f) == 0x1b
printf "T_BLOCK(0x%08x)\n", $arg0
printf "T_BLOCK: "
print (struct RBasic *)$arg0
else
if ($flags & 0x1f) == 0x1c
printf "T_UNDEF(0x%08x)\n", $arg0
printf "T_UNDEF: "
print (struct RBasic *)$arg0
else
if ($flags & 0x1f) == 0x1f
printf "T_NODE(0x%08x)\n", $arg0
print (enum node_type)(($flags >> 11) & 0xff)
printf "T_NODE("
output (enum node_type)(($flags&NODE_TYPEMASK)>>NODE_TYPESHIFT)
printf "): "
print *(NODE *)$arg0
else
printf "unknown(0x%08x)\n", $arg0
printf "unknown: "
print (struct RBasic *)$arg0
end
end
end
@ -140,3 +161,299 @@ end
document rp
Print a Ruby's VALUE.
end
define nd_type
print (enum node_type)((((NODE*)$arg0)->flags&NODE_TYPEMASK)>>NODE_TYPESHIFT)
end
document nd_type
Print a Ruby' node type.
end
define nd_file
print ((NODE*)$arg0)->nd_file
end
document nd_file
Print the source file name of a node.
end
define nd_line
print ((unsigned int)((((NODE*)$arg0)->flags>>NODE_LSHIFT)&NODE_LMASK))
end
document nd_line
Print the source line number of a node.
end
# Print members of ruby node.
define nd_head
printf "u1.node: "
rp $arg0.u1.node
end
define nd_alen
printf "u2.argc: "
p $arg0.u2.argc
end
define nd_next
printf "u3.node: "
rp $arg0.u3.node
end
define nd_cond
printf "u1.node: "
rp $arg0.u1.node
end
define nd_body
printf "u2.node: "
rp $arg0.u2.node
end
define nd_else
printf "u3.node: "
rp $arg0.u3.node
end
define nd_orig
printf "u3.value: "
rp $arg0.u3.value
end
define nd_resq
printf "u2.node: "
rp $arg0.u2.node
end
define nd_ensr
printf "u3.node: "
rp $arg0.u3.node
end
define nd_1st
printf "u1.node: "
rp $arg0.u1.node
end
define nd_2nd
printf "u2.node: "
rp $arg0.u2.node
end
define nd_stts
printf "u1.node: "
rp $arg0.u1.node
end
define nd_entry
printf "u3.entry: "
p $arg0.u3.entry
end
define nd_vid
printf "u1.id: "
p $arg0.u1.id
end
define nd_cflag
printf "u2.id: "
p $arg0.u2.id
end
define nd_cval
printf "u3.value: "
rp $arg0.u3.value
end
define nd_cnt
printf "u3.cnt: "
p $arg0.u3.cnt
end
define nd_tbl
printf "u1.tbl: "
p $arg0.u1.tbl
end
define nd_var
printf "u1.node: "
rp $arg0.u1.node
end
define nd_ibdy
printf "u2.node: "
rp $arg0.u2.node
end
define nd_iter
printf "u3.node: "
rp $arg0.u3.node
end
define nd_value
printf "u2.node: "
rp $arg0.u2.node
end
define nd_aid
printf "u3.id: "
p $arg0.u3.id
end
define nd_lit
printf "u1.value: "
rp $arg0.u1.value
end
define nd_frml
printf "u1.node: "
rp $arg0.u1.node
end
define nd_rest
printf "u2.argc: "
p $arg0.u2.argc
end
define nd_opt
printf "u1.node: "
rp $arg0.u1.node
end
define nd_recv
printf "u1.node: "
rp $arg0.u1.node
end
define nd_mid
printf "u2.id: "
p $arg0.u2.id
end
define nd_args
printf "u3.node: "
rp $arg0.u3.node
end
define nd_noex
printf "u1.id: "
p $arg0.u1.id
end
define nd_defn
printf "u3.node: "
rp $arg0.u3.node
end
define nd_old
printf "u1.id: "
p $arg0.u1.id
end
define nd_new
printf "u2.id: "
p $arg0.u2.id
end
define nd_cfnc
printf "u1.cfunc: "
p $arg0.u1.cfunc
end
define nd_argc
printf "u2.argc: "
p $arg0.u2.argc
end
define nd_cname
printf "u1.id: "
p $arg0.u1.id
end
define nd_super
printf "u3.node: "
rp $arg0.u3.node
end
define nd_modl
printf "u1.id: "
p $arg0.u1.id
end
define nd_clss
printf "u1.value: "
rp $arg0.u1.value
end
define nd_beg
printf "u1.node: "
rp $arg0.u1.node
end
define nd_end
printf "u2.node: "
rp $arg0.u2.node
end
define nd_state
printf "u3.state: "
p $arg0.u3.state
end
define nd_rval
printf "u2.value: "
rp $arg0.u2.value
end
define nd_nth
printf "u2.argc: "
p $arg0.u2.argc
end
define nd_tag
printf "u1.id: "
p $arg0.u1.id
end
define nd_tval
printf "u2.value: "
rp $arg0.u2.value
end
define rb_p
call rb_p($arg0)
end
define rb_id2name
call rb_id2name($arg0)
end
define rb_classname
call classname($arg0)
rb_p $
print *(struct RClass*)$arg0
end
define rb_backtrace
call rb_backtrace()
end

View file

@ -1,3 +1,10 @@
Thu Jul 5 10:42:07 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* include/ruby/{node,ruby}.h, ruby.c: added enum constants for gdb
support. [ruby-dev:31066]
* .gdbinit: some improvements.
Thu Jul 5 10:13:08 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* parse.y (global_symbols.last_id): reduce unused ID numbers.

View file

@ -22,115 +22,225 @@ extern "C" {
enum node_type {
NODE_METHOD,
#define NODE_METHOD NODE_METHOD
NODE_FBODY,
#define NODE_FBODY NODE_FBODY
NODE_CFUNC,
#define NODE_CFUNC NODE_CFUNC
NODE_SCOPE,
#define NODE_SCOPE NODE_SCOPE
NODE_BLOCK,
#define NODE_BLOCK NODE_BLOCK
NODE_IF,
#define NODE_IF NODE_IF
NODE_CASE,
#define NODE_CASE NODE_CASE
NODE_WHEN,
#define NODE_WHEN NODE_WHEN
NODE_OPT_N,
#define NODE_OPT_N NODE_OPT_N
NODE_WHILE,
#define NODE_WHILE NODE_WHILE
NODE_UNTIL,
#define NODE_UNTIL NODE_UNTIL
NODE_ITER,
#define NODE_ITER NODE_ITER
NODE_FOR,
#define NODE_FOR NODE_FOR
NODE_BREAK,
#define NODE_BREAK NODE_BREAK
NODE_NEXT,
#define NODE_NEXT NODE_NEXT
NODE_REDO,
#define NODE_REDO NODE_REDO
NODE_RETRY,
#define NODE_RETRY NODE_RETRY
NODE_BEGIN,
#define NODE_BEGIN NODE_BEGIN
NODE_RESCUE,
#define NODE_RESCUE NODE_RESCUE
NODE_RESBODY,
#define NODE_RESBODY NODE_RESBODY
NODE_ENSURE,
#define NODE_ENSURE NODE_ENSURE
NODE_AND,
#define NODE_AND NODE_AND
NODE_OR,
#define NODE_OR NODE_OR
NODE_NOT,
#define NODE_NOT NODE_NOT
NODE_MASGN,
#define NODE_MASGN NODE_MASGN
NODE_LASGN,
#define NODE_LASGN NODE_LASGN
NODE_DASGN,
#define NODE_DASGN NODE_DASGN
NODE_DASGN_CURR,
#define NODE_DASGN_CURR NODE_DASGN_CURR
NODE_GASGN,
#define NODE_GASGN NODE_GASGN
NODE_IASGN,
#define NODE_IASGN NODE_IASGN
NODE_IASGN2,
#define NODE_IASGN2 NODE_IASGN2
NODE_CDECL,
#define NODE_CDECL NODE_CDECL
NODE_CVASGN,
#define NODE_CVASGN NODE_CVASGN
NODE_CVDECL,
#define NODE_CVDECL NODE_CVDECL
NODE_OP_ASGN1,
#define NODE_OP_ASGN1 NODE_OP_ASGN1
NODE_OP_ASGN2,
#define NODE_OP_ASGN2 NODE_OP_ASGN2
NODE_OP_ASGN_AND,
#define NODE_OP_ASGN_AND NODE_OP_ASGN_AND
NODE_OP_ASGN_OR,
#define NODE_OP_ASGN_OR NODE_OP_ASGN_OR
NODE_CALL,
#define NODE_CALL NODE_CALL
NODE_FCALL,
#define NODE_FCALL NODE_FCALL
NODE_VCALL,
#define NODE_VCALL NODE_VCALL
NODE_SUPER,
#define NODE_SUPER NODE_SUPER
NODE_ZSUPER,
#define NODE_ZSUPER NODE_ZSUPER
NODE_ARRAY,
#define NODE_ARRAY NODE_ARRAY
NODE_ZARRAY,
#define NODE_ZARRAY NODE_ZARRAY
NODE_VALUES,
#define NODE_VALUES NODE_VALUES
NODE_HASH,
#define NODE_HASH NODE_HASH
NODE_RETURN,
#define NODE_RETURN NODE_RETURN
NODE_YIELD,
#define NODE_YIELD NODE_YIELD
NODE_LVAR,
#define NODE_LVAR NODE_LVAR
NODE_DVAR,
#define NODE_DVAR NODE_DVAR
NODE_GVAR,
#define NODE_GVAR NODE_GVAR
NODE_IVAR,
#define NODE_IVAR NODE_IVAR
NODE_CONST,
#define NODE_CONST NODE_CONST
NODE_CVAR,
#define NODE_CVAR NODE_CVAR
NODE_NTH_REF,
#define NODE_NTH_REF NODE_NTH_REF
NODE_BACK_REF,
#define NODE_BACK_REF NODE_BACK_REF
NODE_MATCH,
#define NODE_MATCH NODE_MATCH
NODE_MATCH2,
#define NODE_MATCH2 NODE_MATCH2
NODE_MATCH3,
#define NODE_MATCH3 NODE_MATCH3
NODE_LIT,
#define NODE_LIT NODE_LIT
NODE_STR,
#define NODE_STR NODE_STR
NODE_DSTR,
#define NODE_DSTR NODE_DSTR
NODE_XSTR,
#define NODE_XSTR NODE_XSTR
NODE_DXSTR,
#define NODE_DXSTR NODE_DXSTR
NODE_EVSTR,
#define NODE_EVSTR NODE_EVSTR
NODE_DREGX,
#define NODE_DREGX NODE_DREGX
NODE_DREGX_ONCE,
#define NODE_DREGX_ONCE NODE_DREGX_ONCE
NODE_ARGS,
#define NODE_ARGS NODE_ARGS
NODE_ARGS_AUX,
#define NODE_ARGS_AUX NODE_ARGS_AUX
NODE_OPT_ARG,
#define NODE_OPT_ARG NODE_OPT_ARG
NODE_POSTARG,
#define NODE_POSTARG NODE_POSTARG
NODE_ARGSCAT,
#define NODE_ARGSCAT NODE_ARGSCAT
NODE_ARGSPUSH,
#define NODE_ARGSPUSH NODE_ARGSPUSH
NODE_SPLAT,
#define NODE_SPLAT NODE_SPLAT
NODE_TO_ARY,
#define NODE_TO_ARY NODE_TO_ARY
NODE_BLOCK_ARG,
#define NODE_BLOCK_ARG NODE_BLOCK_ARG
NODE_BLOCK_PASS,
#define NODE_BLOCK_PASS NODE_BLOCK_PASS
NODE_DEFN,
#define NODE_DEFN NODE_DEFN
NODE_DEFS,
#define NODE_DEFS NODE_DEFS
NODE_ALIAS,
#define NODE_ALIAS NODE_ALIAS
NODE_VALIAS,
#define NODE_VALIAS NODE_VALIAS
NODE_UNDEF,
#define NODE_UNDEF NODE_UNDEF
NODE_CLASS,
#define NODE_CLASS NODE_CLASS
NODE_MODULE,
#define NODE_MODULE NODE_MODULE
NODE_SCLASS,
#define NODE_SCLASS NODE_SCLASS
NODE_COLON2,
#define NODE_COLON2 NODE_COLON2
NODE_COLON3,
#define NODE_COLON3 NODE_COLON3
NODE_DOT2,
#define NODE_DOT2 NODE_DOT2
NODE_DOT3,
#define NODE_DOT3 NODE_DOT3
NODE_FLIP2,
#define NODE_FLIP2 NODE_FLIP2
NODE_FLIP3,
#define NODE_FLIP3 NODE_FLIP3
NODE_ATTRSET,
#define NODE_ATTRSET NODE_ATTRSET
NODE_SELF,
#define NODE_SELF NODE_SELF
NODE_NIL,
#define NODE_NIL NODE_NIL
NODE_TRUE,
#define NODE_TRUE NODE_TRUE
NODE_FALSE,
#define NODE_FALSE NODE_FALSE
NODE_ERRINFO,
#define NODE_ERRINFO NODE_ERRINFO
NODE_DEFINED,
#define NODE_DEFINED NODE_DEFINED
NODE_POSTEXE,
#define NODE_POSTEXE NODE_POSTEXE
NODE_ALLOCA,
#define NODE_ALLOCA NODE_ALLOCA
NODE_BMETHOD,
#define NODE_BMETHOD NODE_BMETHOD
NODE_MEMO,
#define NODE_MEMO NODE_MEMO
NODE_IFUNC,
#define NODE_IFUNC NODE_IFUNC
NODE_DSYM,
#define NODE_DSYM NODE_DSYM
NODE_ATTRASGN,
#define NODE_ATTRASGN NODE_ATTRASGN
NODE_PRELUDE,
#define NODE_PRELUDE NODE_PRELUDE
NODE_LAMBDA,
#define NODE_LAMBDA NODE_LAMBDA
NODE_OPTBLOCK,
#define NODE_OPTBLOCK NODE_OPTBLOCK
NODE_LAST
#define NODE_LAST NODE_LAST
};
typedef struct RNode {
@ -161,18 +271,26 @@ typedef struct RNode {
#define RNODE(obj) (R_CAST(RNode)(obj))
/* 0..4:T_TYPES, 5:FL_MARK, 6:reserved, 7:NODE_NEWLINE */
#define NODE_NEWLINE (1<<7)
#define NODE_TYPESHIFT 8
#define NODE_TYPEMASK (0x7f<<NODE_TYPESHIFT)
/* 0..4:T_TYPES, 5:FL_MARK, 6:reserved, 7:NODE_NEWLINE */
enum ruby_node_flags {
NODE_NEWLINE = (1<<7),
#define NODE_NEWLINE NODE_NEWLINE
NODE_TYPESHIFT = 8,
#define NODE_TYPESHIFT NODE_TYPESHIFT
NODE_TYPEMASK = (0x7f<<NODE_TYPESHIFT),
#define NODE_TYPEMASK NODE_TYPEMASK
NODE_LSHIFT = (NODE_TYPESHIFT+7),
#define NODE_LSHIFT NODE_LSHIFT
NODE_LMASK = (((SIGNED_VALUE)1<<(sizeof(VALUE)*CHAR_BIT-NODE_LSHIFT))-1),
#define NODE_LMASK NODE_LMASK
};
#define nd_type(n) ((int) (((RNODE(n))->flags & NODE_TYPEMASK)>>NODE_TYPESHIFT))
#define nd_set_type(n,t) \
RNODE(n)->flags=((RNODE(n)->flags&~NODE_TYPEMASK)|(((t)<<NODE_TYPESHIFT)&NODE_TYPEMASK))
#define NODE_LSHIFT (NODE_TYPESHIFT+7)
#define NODE_LMASK (((SIGNED_VALUE)1<<(sizeof(NODE*)*CHAR_BIT-NODE_LSHIFT))-1)
#define nd_line(n) ((VALUE)(((RNODE(n))->flags>>NODE_LSHIFT)&NODE_LMASK))
#define nd_set_line(n,l) \
RNODE(n)->flags=((RNODE(n)->flags&~(-1<<NODE_LSHIFT))|(((l)&NODE_LMASK)<<NODE_LSHIFT))

View file

@ -154,7 +154,6 @@ typedef unsigned LONG_LONG ID;
#define FIXNUM_MAX (LONG_MAX>>1)
#define FIXNUM_MIN RSHIFT((long)LONG_MIN,1)
#define FIXNUM_FLAG 0x01
#define INT2FIX(i) ((VALUE)(((SIGNED_VALUE)(i))<<1 | FIXNUM_FLAG))
#define LONG2FIX(i) INT2FIX(i)
#define rb_fix_new(v) INT2FIX(v)
@ -208,54 +207,93 @@ VALUE rb_ull2inum(unsigned LONG_LONG);
#define NEGFIXABLE(f) ((f) >= FIXNUM_MIN)
#define FIXABLE(f) (POSFIXABLE(f) && NEGFIXABLE(f))
#define IMMEDIATE_MASK 0x03
#define IMMEDIATE_P(x) ((VALUE)(x) & IMMEDIATE_MASK)
#define SYMBOL_FLAG 0x0e
#define SYMBOL_P(x) (((VALUE)(x)&0xff)==SYMBOL_FLAG)
#define ID2SYM(x) ((VALUE)(((long)(x))<<8|SYMBOL_FLAG))
#define SYM2ID(x) RSHIFT((unsigned long)x,8)
/* special contants - i.e. non-zero and non-fixnum constants */
#define Qfalse ((VALUE)0)
#define Qtrue ((VALUE)2)
#define Qnil ((VALUE)4)
#define Qundef ((VALUE)6) /* undefined value for placeholder */
enum ruby_special_consts {
RUBY_Qfalse = 0,
RUBY_Qtrue = 2,
RUBY_Qnil = 4,
RUBY_Qundef = 6,
RUBY_IMMEDIATE_MASK = 0x03,
RUBY_FIXNUM_FLAG = 0x01,
RUBY_SYMBOL_FLAG = 0x0e,
};
#define Qfalse ((VALUE)RUBY_Qfalse)
#define Qtrue ((VALUE)RUBY_Qtrue)
#define Qnil ((VALUE)RUBY_Qnil)
#define Qundef ((VALUE)RUBY_Qundef) /* undefined value for placeholder */
#define IMMEDIATE_MASK RUBY_IMMEDIATE_MASK
#define FIXNUM_FLAG RUBY_FIXNUM_FLAG
#define SYMBOL_FLAG RUBY_SYMBOL_FLAG
#define RTEST(v) (((VALUE)(v) & ~Qnil) != 0)
#define NIL_P(v) ((VALUE)(v) == Qnil)
#define CLASS_OF(v) rb_class_of((VALUE)(v))
#define T_NONE 0x00
enum ruby_value_type {
RUBY_T_NONE = 0x00,
#define T_NONE RUBY_T_NONE
#define T_NIL 0x01
#define T_OBJECT 0x02
#define T_CLASS 0x03
#define T_ICLASS 0x04
#define T_MODULE 0x05
#define T_FLOAT 0x06
#define T_STRING 0x07
#define T_REGEXP 0x08
#define T_ARRAY 0x09
#define T_FIXNUM 0x0a
#define T_HASH 0x0b
#define T_STRUCT 0x0c
#define T_BIGNUM 0x0d
#define T_FILE 0x0e
RUBY_T_NIL = 0x01,
#define T_NIL RUBY_T_NIL
RUBY_T_OBJECT = 0x02,
#define T_OBJECT RUBY_T_OBJECT
RUBY_T_CLASS = 0x03,
#define T_CLASS RUBY_T_CLASS
RUBY_T_ICLASS = 0x04,
#define T_ICLASS RUBY_T_ICLASS
RUBY_T_MODULE = 0x05,
#define T_MODULE RUBY_T_MODULE
RUBY_T_FLOAT = 0x06,
#define T_FLOAT RUBY_T_FLOAT
RUBY_T_STRING = 0x07,
#define T_STRING RUBY_T_STRING
RUBY_T_REGEXP = 0x08,
#define T_REGEXP RUBY_T_REGEXP
RUBY_T_ARRAY = 0x09,
#define T_ARRAY RUBY_T_ARRAY
RUBY_T_FIXNUM = 0x0a,
#define T_FIXNUM RUBY_T_FIXNUM
RUBY_T_HASH = 0x0b,
#define T_HASH RUBY_T_HASH
RUBY_T_STRUCT = 0x0c,
#define T_STRUCT RUBY_T_STRUCT
RUBY_T_BIGNUM = 0x0d,
#define T_BIGNUM RUBY_T_BIGNUM
RUBY_T_FILE = 0x0e,
#define T_FILE RUBY_T_FILE
#define T_TRUE 0x10
#define T_FALSE 0x11
#define T_DATA 0x12
#define T_MATCH 0x13
#define T_SYMBOL 0x14
RUBY_T_TRUE = 0x10,
#define T_TRUE RUBY_T_TRUE
RUBY_T_FALSE = 0x11,
#define T_FALSE RUBY_T_FALSE
RUBY_T_DATA = 0x12,
#define T_DATA RUBY_T_DATA
RUBY_T_MATCH = 0x13,
#define T_MATCH RUBY_T_MATCH
RUBY_T_SYMBOL = 0x14,
#define T_SYMBOL RUBY_T_SYMBOL
#define T_VALUES 0x1a
#define T_BLOCK 0x1b
#define T_UNDEF 0x1c
#define T_NODE 0x1f
RUBY_T_VALUES = 0x1a,
#define T_VALUES RUBY_T_VALUES
RUBY_T_BLOCK = 0x1b,
#define T_BLOCK RUBY_T_BLOCK
RUBY_T_UNDEF = 0x1c,
#define T_UNDEF RUBY_T_UNDEF
RUBY_T_NODE = 0x1f,
#define T_NODE RUBY_T_NODE
#define T_MASK 0x1f
RUBY_T_MASK = 0x1f,
#define T_MASK RUBY_T_MASK
};
#define BUILTIN_TYPE(x) (((struct RBasic*)(x))->flags & T_MASK)
@ -522,24 +560,42 @@ struct RBignum {
#define RFILE(obj) (R_CAST(RFile)(obj))
#define RVALUES(obj) (R_CAST(RValues)(obj))
#define FL_SINGLETON FL_USER0
#define FL_MARK (1<<5)
#define FL_RESERVED (1<<6) /* will be used in the future GC */
#define FL_FINALIZE (1<<7)
#define FL_TAINT (1<<8)
#define FL_EXIVAR (1<<9)
#define FL_FREEZE (1<<10)
enum ruby_value_flags {
RUBY_FL_MARK = (1<<5),
#define FL_MARK RUBY_FL_MARK
RUBY_FL_RESERVED = (1<<6) /* will be used in the future GC */,
#define FL_RESERVED RUBY_FL_RESERVED
RUBY_FL_FINALIZE = (1<<7),
#define FL_FINALIZE RUBY_FL_FINALIZE
RUBY_FL_TAINT = (1<<8),
#define FL_TAINT RUBY_FL_TAINT
RUBY_FL_EXIVAR = (1<<9),
#define FL_EXIVAR RUBY_FL_EXIVAR
RUBY_FL_FREEZE = (1<<10),
#define FL_FREEZE RUBY_FL_FREEZE
RUBY_FL_SINGLETON = (1<<11),
#define FL_SINGLETON RUBY_FL_SINGLETON
#define FL_USHIFT 11
RUBY_FL_USHIFT = 11,
#define FL_USHIFT RUBY_FL_USHIFT
#define FL_USER0 (1<<(FL_USHIFT+0))
#define FL_USER1 (1<<(FL_USHIFT+1))
#define FL_USER2 (1<<(FL_USHIFT+2))
#define FL_USER3 (1<<(FL_USHIFT+3))
#define FL_USER4 (1<<(FL_USHIFT+4))
#define FL_USER5 (1<<(FL_USHIFT+5))
#define FL_USER6 (1<<(FL_USHIFT+6))
#define FL_USER7 (1<<(FL_USHIFT+7))
RUBY_FL_USER0 = (1<<(FL_USHIFT+0)),
#define FL_USER0 RUBY_FL_USER0
RUBY_FL_USER1 = (1<<(FL_USHIFT+1)),
#define FL_USER1 RUBY_FL_USER1
RUBY_FL_USER2 = (1<<(FL_USHIFT+2)),
#define FL_USER2 RUBY_FL_USER2
RUBY_FL_USER3 = (1<<(FL_USHIFT+3)),
#define FL_USER3 RUBY_FL_USER3
RUBY_FL_USER4 = (1<<(FL_USHIFT+4)),
#define FL_USER4 RUBY_FL_USER4
RUBY_FL_USER5 = (1<<(FL_USHIFT+5)),
#define FL_USER5 RUBY_FL_USER5
RUBY_FL_USER6 = (1<<(FL_USHIFT+6)),
#define FL_USER6 RUBY_FL_USER6
RUBY_FL_USER7 = (1<<(FL_USHIFT+7)),
#define FL_USER7 RUBY_FL_USER7
};
#define SPECIAL_CONST_P(x) (IMMEDIATE_P(x) || !RTEST(x))

9
ruby.c
View file

@ -42,6 +42,15 @@
#include "ruby/util.h"
/* for gdb */
static const union {
enum ruby_special_consts special_consts;
enum ruby_value_type value_type;
enum ruby_value_flags value_flags;
enum node_type node_type;
enum ruby_node_flags node_flags;
} dummy_gdb_enums;
#ifndef HAVE_STDLIB_H
char *getenv();
#endif