summaryrefslogtreecommitdiffstats
path: root/.gdbinit
blob: 1eea05d92b3b418f1187824ddfb3b12c413d54f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
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
  else
  if ($arg0 & 0xff) == 0x0e
    printf "SYMBOL(%d)\n", ((long)$arg0) >> 8
  else
  if $arg0 == 0
    echo false\n
  else
  if $arg0 == 2
    echo true\n
  else
  if $arg0 == 4
    echo nil\n
  else
  if $arg0 == 6
    echo undef\n
  else
  if $arg0 & 0x03
    echo immediate\n
  else
  set $flags = ((struct RBasic*)$arg0)->flags
  if ($flags & 0x1f) == 0x00
    printf "T_NONE(0x%08x)\n", $arg0
  else
  if ($flags & 0x1f) == 0x01
    printf "T_NIL(0x%08x)\n", $arg0
  else
  if ($flags & 0x1f) == 0x02
    printf "T_OBJECT(0x%08x)\n", $arg0
  else
  if ($flags & 0x1f) == 0x03
    printf "T_CLASS(0x%08x)\n", $arg0
  else
  if ($flags & 0x1f) == 0x04
    printf "T_ICLASS(0x%08x)\n", $arg0
  else
  if ($flags & 0x1f) == 0x05
    printf "T_MODULE(0x%08x)\n", $arg0
  else
  if ($flags & 0x1f) == 0x06
    printf "T_FLOAT(0x%08x): %.16g\n", $arg0, (((struct RFloat*)$arg0)->value)
  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 
  else
  if ($flags & 0x1f) == 0x08
    printf "T_REGEXP(0x%08x): \"%s\"\n", $arg0, (((struct RRegexp*)$arg0)->str)
  else
  if ($flags & 0x1f) == 0x09
    printf "T_ARRAY(0x%08x) len=%d\n", $arg0, ((struct RArray*)$arg0)->len
  else
  if ($flags & 0x1f) == 0x0a
    printf "T_FIXNUM(0x%08x)\n", $arg0
  else
  if ($flags & 0x1f) == 0x0b
    printf "T_HASH(0x%08x)\n", $arg0
  else
  if ($flags & 0x1f) == 0x0c
    printf "T_STRUCT(0x%08x)\n", $arg0
  else
  if ($flags & 0x1f) == 0x0d
    printf "T_BIGNUM(0x%08x): sign=%d len=%d\n", $arg0, ((struct RBignum*)$arg0)->sign, ((struct RBignum*)$arg0)->len
  else
  if ($flags & 0x1f) == 0x0e
    printf "T_FILE(0x%08x)\n", $arg0
  else
  if ($flags & 0x1f) == 0x10
    printf "T_TRUE(0x%08x)\n", $arg0
  else
  if ($flags & 0x1f) == 0x11
    printf "T_FALSE(0x%08x)\n", $arg0
  else
  if ($flags & 0x1f) == 0x12
    printf "T_DATA(0x%08x)\n", $arg0
  else
  if ($flags & 0x1f) == 0x13
    printf "T_MATCH(0x%08x)\n", $arg0
  else
  if ($flags & 0x1f) == 0x14
    printf "T_SYMBOL(0x%08x)\n", $arg0
  else
  if ($flags & 0x1f) == 0x1a
    printf "T_VALUES(0x%08x)\n", $arg0
  else
  if ($flags & 0x1f) == 0x1b
    printf "T_BLOCK(0x%08x)\n", $arg0
  else
  if ($flags & 0x1f) == 0x1c
    printf "T_UNDEF(0x%08x)\n", $arg0
  else
  if ($flags & 0x1f) == 0x1f
    printf "T_NODE(0x%08x)\n", $arg0
    print (enum node_type)(($flags >> 11) & 0xff)
  else
    printf "unknown(0x%08x)\n", $arg0
  end
  end
  end
  end
  end
  end
  end
  end
  end
  end
  end
  end
  end
  end
  end
  end
  end
  end
  end
  end
  end
  end
  end
  end
  end
  end
  end
  end
  end
  end
  end
end
document rp
  Print a Ruby's VALUE.
end