@@ -230,47 +230,23 @@ def print_info(self, terminal):
230230 pass
231231
232232
233- class RubyContextCommand ( debugger . Command ) :
234- """Show current execution context and set convenience variables.
233+ class RubyContextHandler :
234+ """Show current execution context and set convenience variables."""
235235
236- This command automatically discovers the current thread's execution context
237- and displays detailed information about it, while also setting up convenience
238- variables for easy inspection.
236+ USAGE = command .Usage (
237+ summary = "Show current execution context and set convenience variables" ,
238+ parameters = [],
239+ options = {},
240+ flags = [],
241+ examples = [
242+ ("rb-context" , "Display execution context info" ),
243+ ("rb-context; rb-print $errinfo" , "Show context then print exception" )
244+ ]
245+ )
239246
240- Usage:
241- rb-context
242-
243- Displays:
244- - Execution context pointer and details
245- - VM stack information
246- - Control frame pointer
247- - Exception information (if any)
248-
249- Sets these convenience variables:
250- $ec - Current execution context (rb_execution_context_t *)
251- $cfp - Current control frame pointer
252- $errinfo - Current exception (if any)
253-
254- Example:
255- (gdb) rb-context
256- Execution Context:
257- $ec = <rb_execution_context_t *@0x...>
258- VM Stack: <VALUE *@0x...> size=1024
259- $cfp = <rb_control_frame_t *@0x...>
260- Exception: None
261-
262- (gdb) rb-object-print $errinfo
263- (gdb) rb-object-print $ec->cfp->sp[-1]
264- """
265-
266- def __init__ (self ):
267- super (RubyContextCommand , self ).__init__ ("rb-context" , debugger .COMMAND_USER )
268-
269- def invoke (self , arg , from_tty ):
247+ def invoke (self , arguments , terminal ):
270248 """Execute the rb-context command."""
271249 try :
272- terminal = format .create_terminal (from_tty )
273-
274250 # Get current execution context
275251 ctx = RubyContext .current ()
276252
@@ -314,30 +290,21 @@ def invoke(self, arg, from_tty):
314290 traceback .print_exc ()
315291
316292
317- class RubyContextStorageCommand (debugger .Command ):
318- """Print the fiber storage from the current execution context.
319-
320- This command is a convenience wrapper around rb-object-print that
321- specifically prints $ec->storage (the inheritable fiber storage).
322-
323- Usage:
324- rb-context-storage [--depth N] [--debug]
325-
326- All flags are passed through to rb-object-print.
327-
328- Example:
329- (gdb) rb-context
330- (gdb) rb-context-storage --depth 3
331-
332- This is equivalent to:
333- (gdb) rb-context
334- (gdb) rb-object-print $ec->storage --depth 3
335- """
293+ class RubyContextStorageHandler :
294+ """Print the fiber storage from the current execution context."""
336295
337- def __init__ (self ):
338- super (RubyContextStorageCommand , self ).__init__ ("rb-context-storage" , debugger .COMMAND_USER )
296+ USAGE = command .Usage (
297+ summary = "Print fiber storage from current execution context" ,
298+ parameters = [],
299+ options = {'depth' : (int , 1 , 'Recursion depth for nested objects' )},
300+ flags = [('debug' , 'Show debug information' )],
301+ examples = [
302+ ("rb-context-storage" , "Print storage with default depth" ),
303+ ("rb-context-storage --depth 3" , "Print storage with depth 3" )
304+ ]
305+ )
339306
340- def invoke (self , arg , from_tty ):
307+ def invoke (self , arguments , terminal ):
341308 """Execute the rb-context-storage command."""
342309 try :
343310 # Get current execution context
@@ -396,6 +363,6 @@ def invoke(self, arg, from_tty):
396363
397364
398365# Register commands
399- RubyContextCommand ( )
400- RubyContextStorageCommand ( )
366+ debugger . register ( "rb-context" , RubyContextHandler , usage = RubyContextHandler . USAGE )
367+ debugger . register ( "rb-context-storage" , RubyContextStorageHandler , usage = RubyContextStorageHandler . USAGE )
401368
0 commit comments