Consts for gdb support

[email protected]$G$9!#e(B

e$B%W%j%W%m%;%C%5$N%^%/%m$Oe(B-g3e$B$r$D$1$J$$$He(Bgdbe$B$+$i8+$($J$$$N$G!“e(B
enume$B$GDj5A$9$k$H$$$&$N$O$I$&$G$7$g$&$+!#0JA0;n$7$?$3$H$,$”$C$?e(B
e$B$N$G$9$,!"$I$&$d$ie(B(e$BEDCf$5$s$K$h$k$He(B)e$B!VJQ?t$rDj5A$7$F$*$/!W$H$$e(B
e$B$&$N$,80$N$h$&$G$9!#e(B

Index: include/ruby/node.h

— include/ruby/node.h (revision 12632)
+++ include/ruby/node.h (working copy)
@@ -23,114 +23,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_CREF,
+#define NODE_CREF NODE_CREF
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
};

@@ -163,9 +274,19 @@ 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))
@@ -173,6 +294,4 @@ typedef struct RNode {
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)
Index: include/ruby/ruby.h

— include/ruby/ruby.h (revision 12632)
+++ include/ruby/ruby.h (working copy)
@@ -155,5 +155,4 @@ typedef unsigned LONG_LONG ID;
#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)
@@ -209,8 +208,6 @@ VALUE rb_ull2inum(unsigned LONG_LONG);
#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))
@@ -218,8 +215,22 @@ VALUE rb_ull2inum(unsigned LONG_LONG);

/* 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)
@@ -228,33 +239,60 @@ VALUE rb_ull2inum(unsigned LONG_LONG);
#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
  • 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
  • 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
  • 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_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

-#define T_TRUE 0x10
-#define T_FALSE 0x11
-#define T_DATA 0x12
-#define T_MATCH 0x13
-#define T_SYMBOL 0x14

-#define T_VALUES 0x1a
-#define T_BLOCK 0x1b
-#define T_UNDEF 0x1c
-#define T_NODE 0x1f

-#define T_MASK 0x1f

  • RUBY_T_MASK = 0x1f,
    +#define T_MASK RUBY_T_MASK
    +};

#define BUILTIN_TYPE(x) (((struct RBasic*)(x))->flags & T_MASK)
@@ -523,22 +561,40 @@ struct RBignum {
#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)

-#define FL_USHIFT 11

-#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))
+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
  • RUBY_FL_USHIFT = 11,
    +#define FL_USHIFT RUBY_FL_USHIFT
  • 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))
Index: ruby.c

— ruby.c (revision 12632)
+++ ruby.c (working copy)
@@ -43,4 +43,13 @@
#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();

In article
[email protected],
Nobuyoshi N. [email protected] writes:

e$B%W%j%W%m%;%C%5$N%^%/%m$Oe(B-g3e$B$r$D$1$J$$$He(Bgdbe$B$+$i8+$($J$$$N$G!“e(B
enume$B$GDj5A$9$k$H$$$&$N$O$I$&$G$7$g$&$+!#0JA0;n$7$?$3$H$,$”$C$?e(B

e$B%G%P%C%0$,3Z$K$J$k$N$G!"$<$R!#e(B

In article
[email protected],
Nobuyoshi N. [email protected] writes:

e$B%W%j%W%m%;%C%5$N%^%/%m$Oe(B-g3e$B$r$D$1$J$$$He(Bgdbe$B$+$i8+$($J$$$N$G!“e(B
enume$B$GDj5A$9$k$H$$$&$N$O$I$&$G$7$g$&$+!#0JA0;n$7$?$3$H$,$”$C$?e(B

1e$B=54V$[$I7P$A$^$7$?$,H?BP$9$k$R$H$OC/$b$$$J$$$h$&$J$N$G!"F~e(B
e$B$l$k$N$O$I$&$G$7$g$&$+!#e(B

In article
[email protected],
Nobuyoshi N. [email protected] writes:

e$BEDCf$5$s$,L4Km$KN)$C$F$&$C$?$($F$-$=$&$J5$$,$7$?$N$G!"F~$l$F$7e(B
e$B$^$$$^$7$?!#e(B

e$B$"$j$,$H$&$4$6$$$^$9!#e(B

e$B<!$Oe(B NODE e$B$Ne(B union e$B2=$H$+$I$&[email protected]$m$&$+e(B…

[email protected]$G$9!#e(B

At Wed, 4 Jul 2007 16:30:35 +0900,
Tanaka A. wrote in [ruby-dev:31133]:

e$B%W%j%W%m%;%C%5$N%^%/%m$Oe(B-g3e$B$r$D$1$J$$$He(Bgdbe$B$+$i8+$($J$$$N$G!“e(B
enume$B$GDj5A$9$k$H$$$&$N$O$I$&$G$7$g$&$+!#0JA0;n$7$?$3$H$,$”$C$?e(B

1e$B=54V$[$I7P$A$^$7$?$,H?BP$9$k$R$H$OC/$b$$$J$$$h$&$J$N$G!"F~e(B
e$B$l$k$N$O$I$&$G$7$g$&$+!#e(B

e$BEDCf$5$s$,L4Km$KN)$C$F$&$C$?$($F$-$=$&$J5$$,$7$?$N$G!"F~$l$F$7e(B
e$B$^$$$^$7$?!#e(B

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs