You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -146,7 +146,7 @@ When a Ruby exception occurs, you can inspect it in detail:
146
146
(gdb) break rb_exc_raise
147
147
(gdb) run
148
148
(gdb) rb-context
149
-
(gdb) rb-object-print $errinfo --depth 2
149
+
(gdb) rb-print $errinfo --depth 2
150
150
~~~
151
151
152
152
This shows the exception class, message, and any nested structures. The `rb-context` command displays the current execution context and sets up `$ec`, `$cfp`, and `$errinfo` convenience variables.
@@ -167,7 +167,7 @@ When working with fibers, you often need to see what each fiber is doing:
167
167
Ruby hashes and arrays can contain nested structures:
168
168
169
169
~~~
170
-
(gdb) rb-object-print $some_hash --depth 2
170
+
(gdb) rb-print $some_hash --depth 2
171
171
<T_HASH@...>
172
172
[ 0] K: <T_SYMBOL> :name
173
173
V: <T_STRING@...> "Alice"
@@ -197,4 +197,4 @@ On macOS with LLDB and Ruby <= 3.4.x, some commands including `rb-fiber-scan-hea
197
197
**Workarounds:**
198
198
- Use Ruby head: `ruby-install ruby-head -- CFLAGS="-g -O0"`
199
199
- Use GDB instead of LLDB (works with Ruby 3.4.x)
200
-
- Other commands like `rb-object-print`, `rb-stack-trace`, `rb-context` work fine
200
+
- Other commands like `rb-print`, `rb-stack-trace`, `rb-context` work fine
Copy file name to clipboardExpand all lines: context/object-inspection.md
+25-25Lines changed: 25 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,12 @@
1
1
# Object Inspection
2
2
3
-
This guide explains how to use `rb-object-print` to inspect Ruby objects, hashes, arrays, and structs in GDB.
3
+
This guide explains how to use `rb-print` to inspect Ruby objects, hashes, arrays, and structs in GDB.
4
4
5
5
## Why Object Inspection Matters
6
6
7
7
When debugging Ruby programs or analyzing core dumps, you often need to inspect complex data structures that are difficult to read in their raw memory representation. Standard GDB commands show pointer addresses and raw memory, but not the logical structure of Ruby objects.
8
8
9
-
Use `rb-object-print` when you need:
9
+
Use `rb-print` when you need:
10
10
11
11
-**Understand exception objects**: See the full exception hierarchy, message, and backtrace data
12
12
-**Inspect fiber storage**: View thread-local data and fiber-specific variables
@@ -15,12 +15,12 @@ Use `rb-object-print` when you need:
15
15
16
16
## Basic Usage
17
17
18
-
The `rb-object-print` command recursively prints Ruby objects in a human-readable format.
18
+
The `rb-print` command recursively prints Ruby objects in a human-readable format.
(gdb) rb-object-print (VALUE)0x00007f8a12345678 # Object at specific address
49
+
(gdb) rb-print $ec->errinfo # Exception object
50
+
(gdb) rb-print $ec->cfp->sp[-1] # Top of VM stack
51
+
(gdb) rb-print $ec->storage # Fiber storage hash
52
+
(gdb) rb-print (VALUE)0x00007f8a12345678 # Object at specific address
53
53
~~~
54
54
55
55
## Inspecting Hashes
@@ -61,7 +61,7 @@ Ruby hashes have two internal representations (ST table and AR table). The comma
61
61
For hashes with fewer than 8 entries, Ruby uses an array-based implementation:
62
62
63
63
~~~
64
-
(gdb) rb-object-print $some_hash
64
+
(gdb) rb-print $some_hash
65
65
<T_HASH@...>
66
66
[ 0] K: <T_SYMBOL> :name
67
67
V: <T_STRING@...> "Alice"
@@ -76,7 +76,7 @@ For hashes with fewer than 8 entries, Ruby uses an array-based implementation:
76
76
For larger hashes, Ruby uses a hash table (output format is similar):
77
77
78
78
~~~
79
-
(gdb) rb-object-print $large_hash
79
+
(gdb) rb-print $large_hash
80
80
<T_HASH@...>
81
81
[ 0] K: <T_SYMBOL> :user_id
82
82
V: <T_FIXNUM> 12345
@@ -90,12 +90,12 @@ For larger hashes, Ruby uses a hash table (output format is similar):
90
90
Prevent overwhelming output from deeply nested structures:
91
91
92
92
~~~
93
-
(gdb) rb-object-print $nested_hash --depth 1 # Only top level
93
+
(gdb) rb-print $nested_hash --depth 1 # Only top level
94
94
<T_HASH@...>
95
95
[ 0] K: <T_SYMBOL> :data
96
96
V: <T_HASH@...> # Nested hash not expanded
97
97
98
-
(gdb) rb-object-print $nested_hash --depth 2 # Expand one level
98
+
(gdb) rb-print $nested_hash --depth 2 # Expand one level
99
99
<T_HASH@...>
100
100
[ 0] K: <T_SYMBOL> :data
101
101
V: <T_HASH@...>
@@ -114,7 +114,7 @@ Arrays also have two representations based on size:
114
114
Arrays display their elements with type information:
115
115
116
116
~~~
117
-
(gdb) rb-object-print $array
117
+
(gdb) rb-print $array
118
118
<T_ARRAY@...>
119
119
[ 0] <T_FIXNUM> 1
120
120
[ 1] <T_FIXNUM> 2
@@ -124,7 +124,7 @@ Arrays display their elements with type information:
124
124
For arrays with nested objects:
125
125
126
126
~~~
127
-
(gdb) rb-object-print $array --depth 2
127
+
(gdb) rb-print $array --depth 2
128
128
<T_ARRAY@...>
129
129
[ 0] <T_STRING@...> "first item"
130
130
[ 1] <T_HASH@...>
@@ -138,7 +138,7 @@ For arrays with nested objects:
138
138
Ruby Struct objects work similarly to arrays:
139
139
140
140
~~~
141
-
(gdb) rb-object-print $struct_instance
141
+
(gdb) rb-print $struct_instance
142
142
<T_STRUCT@...>
143
143
[ 0] <T_STRING@...> "John"
144
144
[ 1] <T_FIXNUM> 25
@@ -155,7 +155,7 @@ When a fiber has an exception, inspect it:
155
155
~~~
156
156
(gdb) rb-fiber-scan-heap
157
157
(gdb) rb-fiber-scan-switch 5 # Switch to fiber #5
158
-
(gdb) rb-object-print $errinfo --depth 3
158
+
(gdb) rb-print $errinfo --depth 3
159
159
~~~
160
160
161
161
This reveals the full exception structure including any nested causes. After switching to a fiber, `$errinfo` and `$ec` convenience variables are automatically set.
@@ -167,8 +167,8 @@ Break at a method and examine arguments on the stack:
167
167
~~~
168
168
(gdb) break some_method
169
169
(gdb) run
170
-
(gdb) rb-object-print $ec->cfp->sp[-1] # Last argument
0 commit comments