[前][次][番号順一覧][スレッド一覧]

ruby-changes:30907

From: nobu <ko1@a...>
Date: Fri, 20 Sep 2013 13:53:30 +0900 (JST)
Subject: [ruby-changes:30907] nobu:r42985 (trunk): .gdbinit: show ID type

nobu	2013-09-20 13:53:08 +0900 (Fri, 20 Sep 2013)

  New Revision: 42985

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=42985

  Log:
    .gdbinit: show ID type
    
    * .gdbinit (rp_id): show ID type.
    
    * template/id.h.tmpl (ruby_id_types): make enum for debugger.

  Modified files:
    trunk/.gdbinit
    trunk/debug.c
    trunk/template/id.h.tmpl
Index: .gdbinit
===================================================================
--- .gdbinit	(revision 42984)
+++ .gdbinit	(revision 42985)
@@ -316,6 +316,36 @@ define rp_id https://github.com/ruby/ruby/blob/trunk/.gdbinit#L316
   if $id == idASET
     printf "(:[]=)\n"
   else
+    if $id <= tLAST_OP_ID
+      printf "O"
+    else
+      set $id_type = $id & RUBY_ID_SCOPE_MASK
+      if $id_type == RUBY_ID_LOCAL
+        printf "l"
+      else
+      if $id_type == RUBY_ID_INSTANCE
+        printf "i"
+      else
+      if $id_type == RUBY_ID_GLOBAL
+        printf "G"
+      else
+      if $id_type == RUBY_ID_ATTRSET
+        printf "a"
+      else
+      if $id_type == RUBY_ID_CONST
+        printf "C"
+      else
+      if $id_type == RUBY_ID_CLASS
+        printf "c"
+      else
+        printf "j"
+      end
+      end
+      end
+      end
+      end
+      end
+    end
     printf "(%ld): ", $id
     rb_numtable_entry global_symbols.id_str $id
     if $rb_numtable_rec
Index: debug.c
===================================================================
--- debug.c	(revision 42984)
+++ debug.c	(revision 42985)
@@ -24,6 +24,7 @@ const union { https://github.com/ruby/ruby/blob/trunk/debug.c#L24
     enum ruby_tag_type          tag_type;
     enum node_type              node_type;
     enum ruby_method_ids        method_ids;
+    enum ruby_id_types          id_types;
     enum {
         RUBY_ENCODING_INLINE_MAX = ENCODING_INLINE_MAX,
         RUBY_ENCODING_SHIFT = ENCODING_SHIFT,
Index: template/id.h.tmpl
===================================================================
--- template/id.h.tmpl	(revision 42984)
+++ template/id.h.tmpl	(revision 42985)
@@ -28,16 +28,29 @@ types = ids.keys.grep(/^[A-Z]/) https://github.com/ruby/ruby/blob/trunk/template/id.h.tmpl#L28
 #ifndef RUBY_ID_H
 #define RUBY_ID_H
 
-#define ID_SCOPE_SHIFT 3
-#define ID_SCOPE_MASK 0x07
-#define ID_LOCAL      0x00
-#define ID_INSTANCE   0x01
-#define ID_GLOBAL     0x03
-#define ID_ATTRSET    0x04
-#define ID_CONST      0x05
-#define ID_CLASS      0x06
-#define ID_JUNK       0x07
-#define ID_INTERNAL   ID_JUNK
+enum ruby_id_types {
+    RUBY_ID_LOCAL       = 0x00,
+    RUBY_ID_INSTANCE    = 0x01,
+    RUBY_ID_GLOBAL      = 0x03,
+    RUBY_ID_ATTRSET     = 0x04,
+    RUBY_ID_CONST       = 0x05,
+    RUBY_ID_CLASS       = 0x06,
+    RUBY_ID_JUNK        = 0x07,
+    RUBY_ID_INTERNAL    = RUBY_ID_JUNK,
+    RUBY_ID_SCOPE_SHIFT = 3,
+    RUBY_ID_SCOPE_MASK  = ~(~0U<<RUBY_ID_SCOPE_SHIFT)
+};
+
+#define ID_SCOPE_SHIFT RUBY_ID_SCOPE_SHIFT
+#define ID_SCOPE_MASK  RUBY_ID_SCOPE_MASK
+#define ID_LOCAL       RUBY_ID_LOCAL
+#define ID_INSTANCE    RUBY_ID_INSTANCE
+#define ID_GLOBAL      RUBY_ID_GLOBAL
+#define ID_ATTRSET     RUBY_ID_ATTRSET
+#define ID_CONST       RUBY_ID_CONST
+#define ID_CLASS       RUBY_ID_CLASS
+#define ID_JUNK        RUBY_ID_JUNK
+#define ID_INTERNAL    RUBY_ID_INTERNAL
 
 #define ID2ATTRSET(id) (((id)&~ID_SCOPE_MASK)|ID_ATTRSET)
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]