Skip to content

Commit fbb8747

Browse files
committed
Add releases.
1 parent 1b39a05 commit fbb8747

10 files changed

Lines changed: 333 additions & 293 deletions

bake.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# frozen_string_literal: true
2+
3+
# Released under the MIT License.
4+
# Copyright, 2025, by Samuel Williams.
5+
6+
# Update the project documentation with the new version number.
7+
#
8+
# @parameter version [String] The new version number.
9+
def after_gem_release_version_increment(version)
10+
context["releases:update"].call(version)
11+
context["utopia:project:update"].call
12+
end

context/fiber-debugging.md

Lines changed: 56 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,18 @@ The first step in fiber debugging is finding all fibers in the heap.
2222
Scan the entire Ruby heap for fiber objects:
2323

2424
~~~
25-
(gdb) rb-scan-fibers
26-
Scanning 1250 heap pages...
25+
(gdb) rb-fiber-scan-heap
26+
Scanning heap for Fiber objects...
2727
Checked 45000 objects, found 12 fiber(s)...
28-
Scan complete: checked 67890 objects
2928
3029
Found 12 fiber(s):
3130
32-
Fiber #0: 0x7f8a1c800000
31+
Fiber #0: <VALUE:0x7f8a1c800000>
3332
Status: RESUMED
34-
Stack: base=0x7f8a1d000000, size=1048576
35-
VM Stack: 0x7f8a1c900000, size=4096
36-
CFP: 0x7f8a1c901000
37-
38-
Fiber #1: 0x7f8a1c800100
33+
Stack: 0x7f8a1d000000
34+
35+
Fiber #1: <VALUE:0x7f8a1c800100>
3936
Status: SUSPENDED
40-
Exception: RuntimeError: Connection failed
4137
...
4238
~~~
4339

@@ -46,71 +42,58 @@ Fiber #1: 0x7f8a1c800100
4642
For large applications, limit the scan:
4743

4844
~~~
49-
(gdb) rb-scan-fibers 10 # Find first 10 fibers only
45+
(gdb) rb-fiber-scan-heap 10 # Find first 10 fibers only
5046
~~~
5147

5248
### Caching Results
5349

5450
Cache fiber addresses for faster subsequent access:
5551

5652
~~~
57-
(gdb) rb-scan-fibers --cache # Save to fibers.json
58-
(gdb) rb-scan-fibers --cache my.json # Custom cache file
53+
(gdb) rb-fiber-scan-heap --cache # Save to fibers.json
54+
(gdb) rb-fiber-scan-heap --cache my.json # Custom cache file
5955
~~~
6056

6157
Later, load from cache instantly:
6258

6359
~~~
64-
(gdb) rb-scan-fibers --cache
65-
Loaded 12 fiber address(es) from fibers.json
60+
(gdb) rb-fiber-scan-heap --cache
61+
Loaded 12 fiber(s) from fibers.json
6662
~~~
6763

6864
This is especially useful with core dumps where heap scanning is slow.
6965

7066
## Inspecting Specific Fibers
7167

72-
After scanning, inspect fibers by index:
68+
After scanning, you can switch to a specific fiber's context or view all backtraces.
7369

74-
### Fiber Overview
70+
### View All Fiber Backtraces
7571

76-
~~~
77-
(gdb) rb-fiber 5
78-
Fiber #5: 0x7f8a1c800500
79-
Status: SUSPENDED
80-
Exception: IOError: Connection reset
81-
Stack: base=0x7f8a1e000000, size=1048576
82-
VM Stack: 0x7f8a1c950000, size=4096
83-
CFP: 0x7f8a1c951000
84-
EC: 0x7f8a1c800600
72+
See Ruby-level call stacks for all fibers at once:
8573

86-
Available commands:
87-
rb-fiber-bt 5 - Show backtrace
88-
rb-fiber-vm-stack 5 - Show VM stack
89-
rb-fiber-c-stack 5 - Show C/machine stack info
9074
~~~
75+
(gdb) rb-fiber-scan-stack-trace-all
76+
Found 12 fiber(s)
9177
92-
This shows at a glance whether the fiber has an exception and what its state is.
93-
94-
### Fiber Backtraces
78+
Fiber #0: <VALUE:0x7f8a1c800000>
79+
Status: RESUMED
80+
[No backtrace - fiber is running]
9581
96-
See the Ruby-level call stack:
82+
Fiber #1: <VALUE:0x7f8a1c800100>
83+
Status: SUSPENDED
84+
/app/lib/connection.rb:123:in `read'
85+
/app/lib/connection.rb:89:in `receive'
86+
/app/lib/server.rb:56:in `handle_client'
87+
...
9788
98-
~~~
99-
(gdb) rb-fiber-bt 5
100-
Backtrace for fiber 0x7f8a1c800500:
101-
45: /app/lib/connection.rb:123:in `read'
102-
44: /app/lib/connection.rb:89:in `receive'
103-
43: /app/lib/server.rb:56:in `handle_client'
104-
42: /app/lib/server.rb:34:in `block in run'
105-
41: /gems/async-2.0/lib/async/task.rb:45:in `run'
89+
Fiber #5: <VALUE:0x7f8a1c800500>
90+
Status: SUSPENDED
91+
Exception: IOError: Connection reset
92+
/app/lib/connection.rb:45:in `write'
10693
...
10794
~~~
10895

109-
Show backtraces for all non-terminated fibers:
110-
111-
~~~
112-
(gdb) rb-all-fiber-bt
113-
~~~
96+
This gives you a complete overview of what every fiber is doing.
11497

11598
## Switching Fiber Context
11699

@@ -119,27 +102,21 @@ The most powerful feature: switch GDB's view to a fiber's stack (even in core du
119102
### Basic Usage
120103

121104
~~~
122-
(gdb) rb-scan-fibers
123-
(gdb) rb-fiber-switch 5
124-
Switched to Fiber #5: 0x7f8a1c800500
105+
(gdb) rb-fiber-scan-heap
106+
(gdb) rb-fiber-scan-switch 5
107+
Switched to Fiber #5
125108
Status: SUSPENDED
126-
Exception: IOError: Connection reset
127-
128-
Convenience variables set:
129-
$fiber = Current fiber (struct rb_fiber_struct *)
130-
$ec = Execution context (rb_execution_context_t *)
131-
$errinfo = Exception being handled (VALUE)
132-
133-
Now try:
134-
bt # Show C backtrace of fiber
135-
frame <n> # Switch to frame N
136-
info locals # Show local variables
137-
rp $errinfo # Pretty print exception
109+
110+
Now you can use standard GDB commands with this fiber's context:
111+
rb-stack-trace # Show combined backtrace
112+
bt # Show C backtrace
113+
info locals # Show C local variables
138114
~~~
139115

140116
After switching, all standard GDB commands work with the fiber's context:
141117

142118
~~~
119+
(gdb) rb-stack-trace # Combined Ruby/C backtrace
143120
(gdb) bt # C backtrace of fiber
144121
#0 0x00007f8a1c567890 in fiber_setcontext
145122
#1 0x00007f8a1c567900 in rb_fiber_yield
@@ -148,16 +125,22 @@ After switching, all standard GDB commands work with the fiber's context:
148125
149126
(gdb) frame 2
150127
(gdb) info locals # Local C variables in that frame
151-
(gdb) rb-object-print $ec->cfp->sp[-1] # Ruby values on VM stack
128+
~~~
129+
130+
### Switching by VALUE
131+
132+
You can also switch to a specific fiber by its VALUE or address:
133+
134+
~~~
135+
(gdb) rb-fiber-switch 0x7f8a1c800500
152136
~~~
153137

154138
### Switching Back
155139

156140
Return to normal stack view:
157141

158142
~~~
159-
(gdb) rb-fiber-switch off
160-
Fiber unwinder deactivated. Switched back to normal stack view.
143+
(gdb) rb-fiber-scan-switch off
161144
~~~
162145

163146
## Analyzing Fiber State
@@ -311,27 +294,26 @@ Validation:
311294
After scanning fibers, use indices for all operations:
312295

313296
~~~
314-
(gdb) rb-scan-fibers # Scan once
315-
(gdb) rb-fiber 5 # Use index thereafter
316-
(gdb) rb-fiber-bt 5
317-
(gdb) rb-fiber-switch 5
297+
(gdb) rb-fiber-scan-heap # Scan once
298+
(gdb) rb-fiber-scan-switch 5 # Switch to fiber #5
299+
(gdb) rb-stack-trace # View backtrace
318300
~~~
319301

320302
The cache persists throughout your GDB session.
321303

322-
### Check Fiber Status First
304+
### Check Fiber Status
323305

324-
Before inspecting, check the fiber's status:
306+
CREATED and TERMINATED fibers may not have valid saved contexts. The scan output shows status:
325307

326308
~~~
327-
(gdb) rb-fiber 5
309+
Fiber #5: <VALUE:0x7f8a1c800500>
328310
Status: TERMINATED # Won't have useful context
329311
330-
(gdb) rb-fiber 3
312+
Fiber #3: <VALUE:0x7f8a1c800300>
331313
Status: SUSPENDED # Good candidate for inspection
332314
~~~
333315

334-
CREATED and TERMINATED fibers may not have valid saved contexts.
316+
Focus on SUSPENDED and RESUMED fibers for debugging.
335317

336318
### Use Convenience Variables
337319

context/getting-started.md

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ This removes the source line from your `~/.gdbinit`.
5757

5858
Ruby GDB provides specialized commands for debugging Ruby at multiple levels:
5959

60-
- **Object Inspection** - View Ruby objects, hashes, arrays, and structs with {ruby Ruby::GDB::object-inspection proper formatting}
61-
- **Fiber Debugging** - Navigate and inspect fiber state, backtraces, and exceptions
62-
- **Stack Analysis** - Examine both VM (Ruby) and C (native) stack frames
63-
- **Heap Navigation** - Scan the Ruby heap to find objects and understand memory usage
60+
- **Object Inspection** (`rb-object-print`) - View Ruby objects, hashes, arrays, and structs with proper formatting
61+
- **Fiber Debugging** (`rb-fiber-*`) - Scan heap for fibers, inspect state, and switch contexts
62+
- **Stack Analysis** (`rb-stack-trace`) - Examine combined VM (Ruby) and C (native) stack frames
63+
- **Heap Navigation** (`rb-heap-scan`) - Scan the Ruby heap to find objects by type
6464

6565
## Quick Start
6666

@@ -83,8 +83,8 @@ Once stopped, use Ruby debugging commands:
8383

8484
~~~
8585
(gdb) rb-object-print $ec->cfp->sp[-1] # Print top of VM stack
86-
(gdb) rb-scan-fibers # List all fibers
87-
(gdb) rb-fiber-bt 0 # Show fiber backtrace
86+
(gdb) rb-fiber-scan-heap # Scan heap for fibers
87+
(gdb) rb-stack-trace # Show combined Ruby/C backtrace
8888
~~~
8989

9090
### Debugging a Core Dump
@@ -95,14 +95,13 @@ When your Ruby program crashes, you can analyze the core dump:
9595
$ gdb ruby core.dump
9696
~~~
9797

98-
Load the Ruby extensions and diagnose the issue:
98+
Diagnose the issue (extensions load automatically if installed):
9999

100100
~~~
101-
(gdb) source ~/.local/share/gdb/ruby/init.gdb
102-
(gdb) rb-diagnose-exit # Check for exceptions and signals
103-
(gdb) rb-scan-fibers # List all fibers
104-
(gdb) rb-fiber-bt 0 # Show fiber backtraces
105-
(gdb) rb-object-print $errinfo # Print exception objects
101+
(gdb) rb-fiber-scan-heap # Scan heap for all fibers
102+
(gdb) rb-fiber-scan-stack-trace-all # Show backtraces for all fibers
103+
(gdb) rb-object-print $ec->errinfo # Print exception objects
104+
(gdb) rb-heap-scan --type RUBY_T_HASH # Find all hashes
106105
~~~
107106

108107
## Common Workflows
@@ -124,20 +123,23 @@ This shows the exception class, message, and any nested structures.
124123
When working with fibers, you often need to see what each fiber is doing:
125124

126125
~~~
127-
(gdb) rb-scan-fibers # Scan heap for all fibers
128-
(gdb) rb-all-fiber-bt # Show backtraces for all fibers
129-
(gdb) rb-fiber 5 # Inspect specific fiber
130-
(gdb) rb-fiber-switch 5 # Switch GDB to fiber's stack
131-
(gdb) bt # Now shows fiber's C backtrace
126+
(gdb) rb-fiber-scan-heap # Scan heap for all fibers
127+
(gdb) rb-fiber-scan-stack-trace-all # Show backtraces for all fibers
128+
(gdb) rb-fiber-scan-switch 5 # Switch GDB to fiber #5's context
129+
(gdb) rb-stack-trace # Now shows fiber's combined backtrace
132130
~~~
133131

134132
### Examining Complex Data Structures
135133

136134
Ruby hashes and arrays can contain nested structures:
137135

138136
~~~
139-
(gdb) rb-object-print $some_hash --depth 3
140-
(gdb) rb-object-print $ec->storage --depth 2
137+
(gdb) rb-object-print $some_hash --depth 2
138+
<T_HASH@0x7f8a1c999999>
139+
[ 0] K: <T_SYMBOL> :name
140+
V: <T_STRING@0x7f8a1c888888> 'Alice'
141+
[ 1] K: <T_SYMBOL> :age
142+
V: <T_FIXNUM> 30
141143
~~~
142144

143145
The `--depth` flag controls how deep to recurse into nested objects.

0 commit comments

Comments
 (0)