Skip to content

Commit 7e819a1

Browse files
Prefer rb-fiber-scan-heap --limit N.
1 parent 65760a2 commit 7e819a1

10 files changed

Lines changed: 16 additions & 13 deletions

File tree

context/fiber-debugging.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Fiber #1: <T_DATA@...> → <struct rb_fiber_struct@...>
4444
For large applications, limit the scan:
4545

4646
~~~
47-
(gdb) rb-fiber-scan-heap 10 # Find first 10 fibers only
47+
(gdb) rb-fiber-scan-heap --limit 10 # Find first 10 fibers only
4848
~~~
4949

5050
### Caching Results

context/getting-started.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ This removes the source line from your `~/.gdbinit`.
8787

8888
Ruby GDB provides specialized commands for debugging Ruby at multiple levels:
8989

90+
- **Context Setup** (`rb-context`) - Get current execution context and set up convenience variables
9091
- **Object Inspection** (`rb-object-print`) - View Ruby objects, hashes, arrays, and structs with proper formatting
9192
- **Fiber Debugging** (`rb-fiber-*`) - Scan heap for fibers, inspect state, and switch contexts
9293
- **Stack Analysis** (`rb-stack-trace`) - Examine combined VM (Ruby) and C (native) stack frames

context/heap-debugging.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ Later in the same session, just load the cache:
373373
For production core dumps with millions of objects:
374374

375375
~~~
376-
(gdb) rb-fiber-scan-heap 20 # Find first 20 fibers only
376+
(gdb) rb-fiber-scan-heap --limit 20 # Find first 20 fibers only
377377
(gdb) rb-heap-scan --limit 100 # Find first 100 objects of any type
378378
~~~
379379

data/toolbox/fiber.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,10 @@ def __init__(self):
228228

229229
def usage(self):
230230
"""Print usage information."""
231-
print("Usage: rb-fiber-scan-heap [limit] [--cache [filename]] [--terminated]")
231+
print("Usage: rb-fiber-scan-heap [--limit N] [--cache [filename]] [--terminated]")
232232
print("Examples:")
233233
print(" rb-fiber-scan-heap # Find all non-terminated fibers")
234-
print(" rb-fiber-scan-heap 10 # Find first 10 non-terminated fibers")
234+
print(" rb-fiber-scan-heap --limit 10 # Find first 10 non-terminated fibers")
235235
print(" rb-fiber-scan-heap --terminated # Include terminated fibers")
236236
print(" rb-fiber-scan-heap --cache # Use fibers.json cache")
237237
print(" rb-fiber-scan-heap --cache my.json # Use custom cache file")
@@ -309,17 +309,18 @@ def invoke(self, arg, from_tty):
309309
# Parse arguments using the robust parser
310310
arguments = command.parse_arguments(arg if arg else "")
311311

312-
# Get limit from first expression (positional argument)
312+
# Get limit from --limit option
313313
limit = None
314-
if arguments.expressions:
314+
limit_str = arguments.get_option('limit')
315+
if limit_str:
315316
try:
316-
limit = int(arguments.expressions[0])
317+
limit = int(limit_str)
317318
if limit <= 0:
318319
print("Error: limit must be positive")
319320
self.usage()
320321
return
321322
except ValueError:
322-
print(f"Error: invalid limit '{arguments.expressions[0]}'")
323+
print(f"Error: invalid limit '{limit_str}'")
323324
self.usage()
324325
return
325326

fixtures/toolbox/gdb/fiber/can_scan_heap.gdb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ set $fiber_value = argv[0]
2121
# Now scan the heap for fibers
2222
# We should find at least 1 fiber (the one we created)
2323
echo ===TOOLBOX-OUTPUT-START===\n
24-
rb-fiber-scan-heap 1
24+
rb-fiber-scan-heap --limit 1
2525
echo ===TOOLBOX-OUTPUT-END===\n
2626

2727
quit

fixtures/toolbox/gdb/fiber/can_switch_by_index.gdb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ run
1818

1919
# Scan for fibers first
2020
echo ===TOOLBOX-OUTPUT-START===\n
21-
rb-fiber-scan-heap 1
21+
rb-fiber-scan-heap --limit 1
2222
echo \n
2323
rb-fiber-scan-switch 0
2424
echo ===TOOLBOX-OUTPUT-END===\n

fixtures/toolbox/lldb/fiber/can_scan_heap.lldb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ run
99
# Now scan the heap for fibers
1010
# We should find at least 1 fiber (the one we created)
1111
script print("===TOOLBOX-OUTPUT-START===")
12-
rb-fiber-scan-heap 1
12+
rb-fiber-scan-heap --limit 1
1313
script print("===TOOLBOX-OUTPUT-END===")
1414

1515
quit

guides/fiber-debugging/readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Fiber #1: <T_DATA@...> → <struct rb_fiber_struct@...>
4444
For large applications, limit the scan:
4545

4646
~~~
47-
(gdb) rb-fiber-scan-heap 10 # Find first 10 fibers only
47+
(gdb) rb-fiber-scan-heap --limit 10 # Find first 10 fibers only
4848
~~~
4949

5050
### Caching Results

guides/getting-started/readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ This removes the source line from your `~/.gdbinit`.
8787

8888
Ruby GDB provides specialized commands for debugging Ruby at multiple levels:
8989

90+
- **Context Setup** (`rb-context`) - Get current execution context and set up convenience variables
9091
- **Object Inspection** (`rb-object-print`) - View Ruby objects, hashes, arrays, and structs with proper formatting
9192
- **Fiber Debugging** (`rb-fiber-*`) - Scan heap for fibers, inspect state, and switch contexts
9293
- **Stack Analysis** (`rb-stack-trace`) - Examine combined VM (Ruby) and C (native) stack frames

guides/heap-debugging/readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ Later in the same session, just load the cache:
373373
For production core dumps with millions of objects:
374374

375375
~~~
376-
(gdb) rb-fiber-scan-heap 20 # Find first 20 fibers only
376+
(gdb) rb-fiber-scan-heap --limit 20 # Find first 20 fibers only
377377
(gdb) rb-heap-scan --limit 100 # Find first 100 objects of any type
378378
~~~
379379

0 commit comments

Comments
 (0)