1212# Import command parser
1313import command
1414import constants
15- import value
15+ import value as rvalue
1616import format
1717import heap
1818import rexception
@@ -162,7 +162,7 @@ def exception(self):
162162 errinfo_val = self .ec ['errinfo' ]
163163
164164 # Only process if it's a real object (not nil or other immediate value)
165- if value .is_object (errinfo_val ) and not value .is_nil (errinfo_val ):
165+ if rvalue .is_object (errinfo_val ) and not rvalue .is_nil (errinfo_val ):
166166 try :
167167 self ._exception = rexception .RException (errinfo_val )
168168 except Exception :
@@ -501,8 +501,8 @@ class RubyFiberScanSwitchHandler:
501501 def invoke (self , arguments , terminal ):
502502 global _fiber_cache
503503
504- if not arg or not arg .strip ():
505- self . usage ( )
504+ if not arguments . expressions or not arguments . expressions [ 0 ] .strip ():
505+ command . print_usage ( RubyFiberScanSwitchHandler . USAGE , terminal )
506506 return
507507
508508 # Check if cache is populated
@@ -512,10 +512,10 @@ def invoke(self, arguments, terminal):
512512
513513 # Parse index
514514 try :
515- index = int (arg .strip ())
515+ index = int (arguments . expressions [ 0 ] .strip ())
516516 except ValueError :
517- print (f"Error: Invalid index '{ arg } '. Must be an integer." )
518- self . usage ( )
517+ print (f"Error: Invalid index '{ arguments . expressions [ 0 ] } '. Must be an integer." )
518+ command . print_usage ( RubyFiberScanSwitchHandler . USAGE , terminal )
519519 return
520520
521521 # Validate index
@@ -532,7 +532,7 @@ def invoke(self, arguments, terminal):
532532 # Delegate to rb-fiber-switch command
533533 # This command manages the global _current_fiber state
534534 try :
535- debugger . execute ( f"rb-fiber-switch 0x{ int (fiber_value ):x} ", from_tty = from_tty )
535+ RubyFiberSwitchHandler (). invoke ( command . Arguments ([ f" 0x{ int (fiber_value ):x} "], {}, []), terminal )
536536 except debugger .Error as e :
537537 print (f"Error switching to fiber: { e } " )
538538 import traceback
@@ -758,18 +758,13 @@ def invoke(self, arguments, terminal):
758758 if not is_special :
759759 debugger .set_convenience_variable ('errinfo' , errinfo_val )
760760
761- # Create terminal for formatting
762- terminal = format .create_terminal (from_tty )
763-
764761 # Print switch confirmation
765762 print (f"Switched to Fiber: " , end = '' )
766763 terminal .print_type_tag ('T_DATA' , int (fiber_value ), None )
767764 print (' → ' , end = '' )
768765 terminal .print_type_tag ('struct rb_fiber_struct' , fiber_obj .address , None )
769766 print ()
770- print (f" Status: { fiber_obj .status } " )
771-
772- # Print exception if present (catch errors for terminated fibers)
767+ print (f" Status: { fiber_obj .status } " ) # Print exception if present (catch errors for terminated fibers)
773768 try :
774769 exc_info = fiber_obj .exception_info
775770 if exc_info :
@@ -863,7 +858,7 @@ def invoke(self, arguments, terminal):
863858 print ("-" * 80 )
864859
865860 # Use stack.print_fiber_backtrace with the fiber pointer
866- stack .print_fiber_backtrace (fiber_obj .pointer , from_tty = from_tty )
861+ stack .print_fiber_backtrace (fiber_obj .pointer )
867862
868863 except Exception as e :
869864 print (f"\n Fiber #{ i } : VALUE 0x{ int (fiber_value ):x} " )
0 commit comments