Skip to content

Commit b5303d4

Browse files
Clean up guides.
1 parent 7e819a1 commit b5303d4

File tree

10 files changed

+0
-790
lines changed

10 files changed

+0
-790
lines changed

context/fiber-debugging.md

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -169,69 +169,3 @@ The fiber switch command sets up several convenience variables:
169169
- `$fiber_ptr` - Pointer to `struct rb_fiber_struct`
170170
- `$ec` - The fiber's execution context
171171
- `$errinfo` - Exception being handled (if any)
172-
173-
## Best Practices
174-
175-
### Scan Once, Use Indices
176-
177-
After scanning fibers, use indices for all operations:
178-
179-
~~~
180-
(gdb) rb-fiber-scan-heap # Scan once
181-
(gdb) rb-fiber-scan-switch 5 # Switch to fiber #5
182-
(gdb) rb-stack-trace # View backtrace
183-
~~~
184-
185-
The cache persists throughout your GDB session.
186-
187-
### Check Fiber Status
188-
189-
CREATED and TERMINATED fibers may not have valid saved contexts. The scan output shows status:
190-
191-
~~~
192-
Fiber #5: <T_DATA@...> → <struct rb_fiber_struct@...>
193-
Status: TERMINATED # Won't have useful context
194-
195-
Fiber #3: <T_DATA@...> → <struct rb_fiber_struct@...>
196-
Status: SUSPENDED # Good candidate for inspection
197-
~~~
198-
199-
Focus on SUSPENDED and RESUMED fibers for debugging.
200-
201-
### Use Convenience Variables
202-
203-
After switching to a fiber, use the set convenience variables:
204-
205-
~~~
206-
(gdb) rb-fiber-switch 5
207-
(gdb) rb-object-print $errinfo # Pre-set to fiber's exception
208-
(gdb) rb-object-print $ec->storage # Fiber-local storage
209-
~~~
210-
211-
## Common Pitfalls
212-
213-
### Fiber Not Suspended
214-
215-
Only SUSPENDED fibers have fully saved context:
216-
217-
~~~
218-
Fiber status: CREATED (0)
219-
Note: CREATED fibers may not have been suspended yet
220-
~~~
221-
222-
CREATED fibers haven't yielded yet, so they don't have saved register state.
223-
224-
### Core Dump Limitations
225-
226-
Core dumps capture memory but not CPU registers. Switching to the current fiber may show incomplete stacks. For complete debugging, use live process debugging when possible.
227-
228-
### macOS Code Signing
229-
230-
On macOS, GDB may not be able to attach to running Ruby processes due to code signing restrictions. Core dump analysis works without issues.
231-
232-
## See Also
233-
234-
- {ruby Ruby::GDB::object-inspection Object inspection} for examining fiber storage and exception objects
235-
- {ruby Ruby::GDB::stack-inspection Stack inspection} for understanding VM frames
236-
- {ruby Ruby::GDB::heap-debugging Heap debugging} for finding fiber objects
237-

context/getting-started.md

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -176,27 +176,3 @@ Ruby hashes and arrays can contain nested structures:
176176
~~~
177177

178178
The `--depth` flag controls how deep to recurse into nested objects.
179-
180-
## Next Steps
181-
182-
- Learn about {ruby Ruby::GDB::object-inspection inspecting Ruby objects} in detail
183-
- Explore {ruby Ruby::GDB::fiber-debugging fiber debugging} capabilities
184-
- Understand {ruby Ruby::GDB::stack-inspection stack analysis} techniques
185-
- Master {ruby Ruby::GDB::heap-debugging heap navigation} for memory issues
186-
187-
## Requirements
188-
189-
- GDB with Python support (GDB 7.0+)
190-
- Ruby 3.0+ recommended (works with 2.x with limitations)
191-
- For best results: Ruby built with debug symbols (`--with-debug-symbols` or install `ruby-debug` package)
192-
193-
## Platform Support
194-
195-
These extensions work on:
196-
197-
- **Linux**: Full support with all features
198-
- **macOS**: Viewing core dumps works; running processes may require code signing or disabling SIP
199-
- **BSD**: Should work similar to Linux (untested)
200-
201-
For production debugging, Linux with Ruby debug symbols provides the best experience.
202-

context/heap-debugging.md

Lines changed: 0 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -349,130 +349,3 @@ end
349349
~~~
350350

351351
Low utilization indicates fragmentation.
352-
353-
## Best Practices
354-
355-
### Cache Fiber Results
356-
357-
Don't scan repeatedly in the same session:
358-
359-
~~~
360-
(gdb) rb-fiber-scan-heap --cache fibers.json # Scan once
361-
(gdb) rb-fiber-scan-switch 5 # Use cached results
362-
~~~
363-
364-
Later in the same session, just load the cache:
365-
366-
~~~
367-
(gdb) rb-fiber-scan-heap --cache # Instant load
368-
(gdb) rb-fiber-scan-stack-trace-all # View all backtraces
369-
~~~
370-
371-
### Limit Scans in Production
372-
373-
For production core dumps with millions of objects:
374-
375-
~~~
376-
(gdb) rb-fiber-scan-heap --limit 20 # Find first 20 fibers only
377-
(gdb) rb-heap-scan --limit 100 # Find first 100 objects of any type
378-
~~~
379-
380-
Often you only need a few objects to diagnose issues.
381-
382-
### Use Object Inspection Together
383-
384-
Combine heap scanning with object inspection:
385-
386-
~~~
387-
(gdb) rb-heap-scan --type RUBY_T_HASH --limit 5
388-
Scanning heap for type 0x08, limit=5...
389-
390-
Found 5 object(s):
391-
392-
[0] $heap0 = <T_HASH@...>
393-
[1] $heap1 = <T_HASH@...>
394-
...
395-
396-
(gdb) rb-object-print $heap0 --depth 2
397-
<T_HASH@...>
398-
[ 0] K: <T_SYMBOL> :key
399-
V: <T_FIXNUM> 123
400-
...
401-
~~~
402-
403-
## Common Pitfalls
404-
405-
### Stale Cache Files
406-
407-
If you load a cache from a different core dump:
408-
409-
~~~
410-
(gdb) rb-fiber-scan-heap --cache
411-
Loaded fiber addresses from fibers.json
412-
Warning: Could not access fiber at 0x7f8a1c800500
413-
...
414-
~~~
415-
416-
Delete the cache and rescan:
417-
418-
~~~ bash
419-
$ rm fibers.json
420-
~~~
421-
422-
### Scanning Uninitialized VM
423-
424-
If you scan too early during Ruby initialization:
425-
426-
~~~
427-
(gdb) rb-fiber-scan-heap
428-
Error: ruby_current_vm_ptr is NULL
429-
Make sure Ruby is fully initialized and the process is running.
430-
~~~
431-
432-
Set a breakpoint after VM initialization:
433-
434-
~~~
435-
(gdb) break rb_vm_exec
436-
(gdb) run
437-
(gdb) rb-fiber-scan-heap # Now works
438-
~~~
439-
440-
### Memory Errors in Core Dumps
441-
442-
Some heap pages may be unmapped in core dumps:
443-
444-
~~~
445-
Scanning 5000 heap pages...
446-
Error reading page 1234: Cannot access memory at address 0x...
447-
~~~
448-
449-
This is normal - continue with accessible pages.
450-
451-
## Performance Optimization
452-
453-
### Targeted Scanning
454-
455-
Instead of scanning the entire heap, use known addresses:
456-
457-
~~~
458-
(gdb) rb-fiber-from-stack 0x7f8a1e000000
459-
Searching for fiber with stack base 0x7f8a1e000000...
460-
Found fiber: 0x7f8a1c800300
461-
~~~
462-
463-
### Heap Iteration Caching
464-
465-
The scanner caches GDB type lookups for performance:
466-
467-
- `struct RBasic`
468-
- `struct RTypedData`
469-
- `struct rb_fiber_struct`
470-
471-
This makes subsequent iterations much faster.
472-
473-
## See Also
474-
475-
- {ruby Ruby::GDB::fiber-debugging Fiber debugging} for working with found fibers
476-
- {ruby Ruby::GDB::object-inspection Object inspection} for examining heap objects
477-
- {ruby Ruby::GDB::stack-inspection Stack inspection} for understanding object references
478-

context/object-inspection.md

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -206,74 +206,3 @@ Use this to troubleshoot:
206206
- Missing nested structures
207207
- Type detection issues
208208
- Access errors
209-
210-
## Best Practices
211-
212-
### Choose Appropriate Depth
213-
214-
- **Depth 1**: Quick overview, minimal output (default)
215-
- **Depth 2-3**: Common for most debugging tasks
216-
- **Depth 5+**: Only for deep investigation, can be verbose
217-
218-
### Work with Core Dumps
219-
220-
The command works perfectly with core dumps since it only reads memory:
221-
222-
~~~
223-
$ gdb ruby core.12345
224-
(gdb) source ~/.local/share/gdb/ruby/init.gdb
225-
(gdb) rb-object-print $ec->errinfo
226-
~~~
227-
228-
No running process needed!
229-
230-
### Combine with Standard GDB
231-
232-
Use standard GDB commands alongside Ruby extensions:
233-
234-
~~~
235-
(gdb) info locals # See C variables
236-
(gdb) rb-object-print $val # Interpret as Ruby object
237-
(gdb) x/10gx $ec->cfp->sp # Raw memory view
238-
~~~
239-
240-
## Common Pitfalls
241-
242-
### Accessing Deallocated Objects
243-
244-
If an object address is invalid, you'll see an error:
245-
246-
~~~
247-
(gdb) rb-object-print (VALUE)0xdeadbeef
248-
[Error printing object: Cannot access memory at address 0xdeadbeef]
249-
~~~
250-
251-
Always verify the address is valid before inspecting.
252-
253-
### Depth Too Low
254-
255-
If you see `<T_HASH@...>` or `<T_ARRAY@...>` without expanded content at depth 1:
256-
257-
~~~
258-
(gdb) rb-object-print $hash # Shows: <T_HASH@0x...>
259-
(gdb) rb-object-print $hash --depth 2 # Shows actual content with keys/values
260-
~~~
261-
262-
Increase `--depth` to see nested structures.
263-
264-
### Missing Debug Symbols
265-
266-
Without debug symbols, some type information may be unavailable:
267-
268-
~~~
269-
Python Exception <class 'gdb.error'>: No type named RBasic
270-
~~~
271-
272-
Solution: Install Ruby with debug symbols or use a debug build.
273-
274-
## See Also
275-
276-
- {ruby Ruby::GDB::fiber-debugging Fiber debugging} for inspecting fiber-specific data
277-
- {ruby Ruby::GDB::stack-inspection Stack inspection} for examining call frames
278-
- {ruby Ruby::GDB::heap-debugging Heap debugging} for scanning objects
279-

0 commit comments

Comments
 (0)