Skip to content

Commit e2f09d7

Browse files
Fix tests.
1 parent f055874 commit e2f09d7

File tree

6 files changed

+78
-67
lines changed

6 files changed

+78
-67
lines changed

data/toolbox/context.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,25 +175,29 @@ def print_info(self, terminal):
175175
terminal.print("Execution Context:")
176176
terminal.print(f" $ec = ", end='')
177177
terminal.print_type_tag('rb_execution_context_t', int(self.ec), None)
178+
terminal.print()
178179

179180
# VM Stack info
180181
if vm_stack is not None and vm_stack_size is not None:
181182
terminal.print(f" VM Stack: ", end='')
182-
terminal.print_type_tag('VALUE', int(vm_stack), f'size={vm_stack_size}')
183+
terminal.print_type_tag('VALUE', int(vm_stack))
184+
terminal.print()
183185
else:
184186
terminal.print(f" VM Stack: <unavailable>")
185187

186188
# Control Frame info
187189
if cfp is not None:
188190
terminal.print(f" $cfp = ", end='')
189191
terminal.print_type_tag('rb_control_frame_t', int(cfp), None)
192+
terminal.print()
190193
else:
191194
terminal.print(f" $cfp = <unavailable>")
192195

193196
# Storage info
194197
if storage is not None and not value.is_nil(storage):
195198
terminal.print(f" Storage: ", end='')
196199
terminal.print_type_tag('VALUE', int(storage), None)
200+
terminal.print()
197201

198202
# Exception info
199203
if has_exception:

data/toolbox/fiber.py

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,11 @@ def print_info(self, terminal):
193193
"""
194194
# Print fiber VALUE and address
195195
print(f"Fiber VALUE: ", end='')
196-
print(terminal.print_type_tag('T_DATA', int(self.value), None))
196+
terminal.print_type_tag('T_DATA', int(self.value), None)
197+
print()
197198
print(f" Address: ", end='')
198-
print(terminal.print_type_tag('struct rb_fiber_struct', self.address, None))
199+
terminal.print_type_tag('struct rb_fiber_struct', self.address, None)
200+
print()
199201

200202
# Print status
201203
print(f" Status: {self.status}")
@@ -208,16 +210,19 @@ def print_info(self, terminal):
208210
# Print Stack with formatted pointer
209211
stack_type = str(self.stack_base.type)
210212
print(f" Stack: ", end='')
211-
print(terminal.print_type_tag(stack_type, int(self.stack_base), f'size={self.stack_size}'))
213+
terminal.print_type_tag(stack_type, int(self.stack_base))
214+
print()
212215

213216
# Print VM Stack with formatted pointer
214217
vm_stack_type = str(self.vm_stack.type)
215218
print(f" VM Stack: ", end='')
216-
print(terminal.print_type_tag(vm_stack_type, int(self.vm_stack), f'size={self.vm_stack_size}'))
219+
terminal.print_type_tag(vm_stack_type, int(self.vm_stack))
220+
print()
217221

218222
# Print CFP
219223
print(f" CFP: ", end='')
220-
print(terminal.print_type_tag('rb_control_frame_t', int(self.cfp), None))
224+
terminal.print_type_tag('rb_control_frame_t', int(self.cfp), None)
225+
print()
221226

222227

223228
class RubyFiberScanHeapHandler:
@@ -308,14 +313,8 @@ def load_cache(self, filename):
308313
print(f"Warning: Failed to load cache: {e}")
309314
return None
310315

311-
def invoke(self, arg, from_tty):
316+
def invoke(self, arguments, terminal):
312317
global _fiber_cache
313-
314-
# Create terminal for formatting
315-
terminal = format.create_terminal(from_tty)
316-
317-
# Parse arguments using the robust parser
318-
arguments = command.parse_arguments(arg if arg else "")
319318

320319
# Get limit from --limit option
321320
limit = None
@@ -448,9 +447,10 @@ def _print_fiber_info(self, terminal, index, fiber_obj):
448447
"""
449448
# Print fiber index with VALUE and pointer
450449
print(f"Fiber #{index}: ", end='')
451-
print(terminal.print_type_tag('T_DATA', int(fiber_obj.value)), end='')
450+
terminal.print_type_tag('T_DATA', int(fiber_obj.value))
452451
print(' → ', end='')
453-
print(terminal.print_type_tag('struct rb_fiber_struct', fiber_obj.address))
452+
terminal.print_type_tag('struct rb_fiber_struct', fiber_obj.address)
453+
print()
454454

455455
# Print status
456456
print(f" Status: {fiber_obj.status}")
@@ -467,17 +467,20 @@ def _print_fiber_info(self, terminal, index, fiber_obj):
467467
# Print Stack with formatted pointer
468468
stack_type = str(fiber_obj.stack_base.type)
469469
print(f" Stack: ", end='')
470-
print(terminal.print_type_tag(stack_type, int(fiber_obj.stack_base), f'size={fiber_obj.stack_size}'))
470+
terminal.print_type_tag(stack_type, int(fiber_obj.stack_base))
471+
print()
471472

472473
# Print VM Stack with formatted pointer
473474
vm_stack_type = str(fiber_obj.vm_stack.type)
474475
print(f" VM Stack: ", end='')
475-
print(terminal.print_type_tag(vm_stack_type, int(fiber_obj.vm_stack), f'size={fiber_obj.vm_stack_size}'))
476+
terminal.print_type_tag(vm_stack_type, int(fiber_obj.vm_stack))
477+
print()
476478

477479
# Print CFP
478480
cfp_type = str(fiber_obj.cfp.type).replace(' *', '') # Remove pointer marker for display
479481
print(f" CFP: ", end='')
480-
print(terminal.print_type_tag(cfp_type, int(fiber_obj.cfp)))
482+
terminal.print_type_tag(cfp_type, int(fiber_obj.cfp))
483+
print()
481484
print()
482485

483486

@@ -675,15 +678,16 @@ def _ensure_unwinder(self):
675678
_fiber_unwinder = RubyFiberUnwinder()
676679
gdb.unwinder.register_unwinder(None, _fiber_unwinder, replace=True)
677680

678-
def invoke(self, arg, from_tty):
681+
def invoke(self, arguments, terminal):
679682
global _fiber_unwinder
680683

684+
# Check for deactivate
685+
arg = arguments.expressions[0] if arguments.expressions else None
681686
if not arg:
682-
self.usage()
687+
print("Error: fiber parameter required")
683688
return
684689

685-
# Check for deactivate
686-
if arg and arg.lower() in ('off', 'none', 'deactivate'):
690+
if arg.lower() in ('off', 'none', 'deactivate'):
687691
if debugger.DEBUGGER_NAME == 'gdb' and _fiber_unwinder:
688692
_fiber_unwinder.deactivate()
689693
set_current_fiber(None)
@@ -759,9 +763,10 @@ def invoke(self, arg, from_tty):
759763

760764
# Print switch confirmation
761765
print(f"Switched to Fiber: ", end='')
762-
print(terminal.print_type_tag('T_DATA', int(fiber_value), None), end='')
766+
terminal.print_type_tag('T_DATA', int(fiber_value), None)
763767
print(' → ', end='')
764-
print(terminal.print_type_tag('struct rb_fiber_struct', fiber_obj.address, None))
768+
terminal.print_type_tag('struct rb_fiber_struct', fiber_obj.address, None)
769+
print()
765770
print(f" Status: {fiber_obj.status}")
766771

767772
# Print exception if present (catch errors for terminated fibers)

data/toolbox/format.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,22 +62,22 @@ def print(self, *args, end='\n'):
6262
self.output.write(str(arg))
6363
self.output.write(end)
6464

65-
def print_type_tag(self, type_name, address=None, details=None):
65+
def print_type_tag(self, type_name, addr=None, details=None):
6666
"""Print a type tag like <T_ARRAY@0xABCD embedded length=3>.
6767
6868
Arguments:
6969
type_name: Type name (e.g., "T_ARRAY", "void *")
70-
address_val: Optional hex address (as integer or hex string without 0x)
70+
addr: Optional hex address (as integer or hex string without 0x)
7171
details: Optional details string (e.g., "embedded length=3")
7272
"""
73-
if isinstance(address, int):
74-
address = f"{address:x}"
73+
if isinstance(addr, int):
74+
addr = f"{addr:x}"
7575

7676
self.print(metadata, '<', reset, type, type_name, reset, end='')
7777

78-
if address:
78+
if addr:
7979
# @ symbol in dim, address in magenta
80-
self.print(metadata, '@', reset, address, f'0x{address}', reset, end='')
80+
self.print(metadata, '@', reset, address, f'0x{addr}', reset, end='')
8181

8282
if details:
8383
self.print(metadata, f' {details}', reset, end='')

data/toolbox/heap.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -636,48 +636,48 @@ def invoke(self, arg, from_tty):
636636
try:
637637
interpreted = value_module.interpret(obj)
638638

639-
print(terminal.print(
639+
terminal.print(
640640
format.metadata, f" [{i}] ",
641641
format.dim, f"${var_name} = ",
642642
format.reset, interpreted
643-
))
643+
)
644644
except Exception as e:
645-
print(terminal.print(
645+
terminal.print(
646646
format.metadata, f" [{i}] ",
647647
format.dim, f"${var_name} = ",
648648
format.error, f"<error: {e}>"
649-
))
649+
)
650650

651651
print()
652-
print(terminal.print(
652+
terminal.print(
653653
format.dim,
654654
f"Objects saved in $heap0 through $heap{len(objects)-1}",
655655
format.reset
656-
))
656+
)
657657

658658
# Save next address to $heap for pagination
659659
if next_address is not None:
660660
# Save the next address to continue from
661661
void_ptr_type = constants.type_struct('void').pointer()
662662
debugger.set_convenience_variable('heap', debugger.create_value(next_address, void_ptr_type))
663-
print(terminal.print(
663+
terminal.print(
664664
format.dim,
665665
f"Next scan address saved to $heap: 0x{next_address:016x}",
666666
format.reset
667-
))
668-
print(terminal.print(
667+
)
668+
terminal.print(
669669
format.dim,
670670
f"Run 'rb-heap-scan --type {type_option if type_option else '...'} --from $heap' for next page",
671671
format.reset
672-
))
672+
)
673673
else:
674674
# Reached the end of the heap - unset $heap so next scan starts fresh
675675
debugger.set_convenience_variable('heap', None)
676-
print(terminal.print(
676+
terminal.print(
677677
format.dim,
678678
f"Reached end of heap (no more objects to scan)",
679679
format.reset
680-
))
680+
)
681681

682682
except Exception as e:
683683
print(f"Error: {e}")

data/toolbox/rsymbol.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,12 @@ def __str__(self):
139139
def print_to(self, terminal):
140140
"""Return formatted symbol representation."""
141141
terminal.print_type_tag('T_SYMBOL')
142+
terminal.print(' ', end='')
142143
name = self.to_str()
143144
if name:
144-
terminal.print(format.symbol, f':{name}', format.reset)
145+
terminal.print(format.symbol, f':{name}', format.reset, end='')
145146
else:
146-
terminal.print(format.symbol, f':id_0x{self.id():x}', format.reset)
147+
terminal.print(format.symbol, f':id_0x{self.id():x}', format.reset, end='')
147148

148149
def print_recursive(self, printer, depth):
149150
"""Print this symbol (no recursion needed)."""

0 commit comments

Comments
 (0)