toolbox 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,6 +5,6 @@
5
5
 
6
6
  # @namespace
7
7
  module Toolbox
8
- VERSION = "0.2.0"
8
+ VERSION = "0.3.0"
9
9
  end
10
10
 
data/readme.md CHANGED
@@ -19,7 +19,7 @@ Please see the [project documentation](https://socketry.github.io/toolbox/) for
19
19
 
20
20
  - [Getting Started](https://socketry.github.io/toolbox/guides/getting-started/index) - This guide explains how to install and use Toolbox for debugging Ruby programs and core dumps with GDB or LLDB.
21
21
 
22
- - [Object Inspection](https://socketry.github.io/toolbox/guides/object-inspection/index) - This guide explains how to use `rb-object-print` to inspect Ruby objects, hashes, arrays, and structs in GDB.
22
+ - [Object Inspection](https://socketry.github.io/toolbox/guides/object-inspection/index) - This guide explains how to use `rb-print` to inspect Ruby objects, hashes, arrays, and structs in GDB.
23
23
 
24
24
  - [Stack Inspection](https://socketry.github.io/toolbox/guides/stack-inspection/index) - This guide explains how to inspect both Ruby VM stacks and native C stacks when debugging Ruby programs.
25
25
 
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: toolbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -61,7 +61,7 @@ files:
61
61
  - data/toolbox/format.py
62
62
  - data/toolbox/heap.py
63
63
  - data/toolbox/init.py
64
- - data/toolbox/object.py
64
+ - data/toolbox/print.py
65
65
  - data/toolbox/rarray.py
66
66
  - data/toolbox/rbasic.py
67
67
  - data/toolbox/rbignum.py
@@ -73,8 +73,8 @@ files:
73
73
  - data/toolbox/rstring.py
74
74
  - data/toolbox/rstruct.py
75
75
  - data/toolbox/rsymbol.py
76
+ - data/toolbox/rvalue.py
76
77
  - data/toolbox/stack.py
77
- - data/toolbox/value.py
78
78
  - lib/toolbox.rb
79
79
  - lib/toolbox/gdb.rb
80
80
  - lib/toolbox/lldb.rb
metadata.gz.sig CHANGED
Binary file
@@ -1,84 +0,0 @@
1
- import debugger
2
- import sys
3
-
4
- # Import utilities
5
- import command
6
- import constants
7
- import value
8
- import rstring
9
- import rarray
10
- import rhash
11
- import rsymbol
12
- import rstruct
13
- import rfloat
14
- import rbignum
15
- import rbasic
16
- import format
17
-
18
- class RubyObjectPrintCommand(debugger.Command):
19
- """Recursively print Ruby hash and array structures.
20
- Usage: rb-object-print <expression> [max_depth] [--debug]
21
- Examples:
22
- rb-object-print $errinfo # Print exception object
23
- rb-object-print $ec->storage # Print fiber storage
24
- rb-object-print 0x7f7a12345678 # Print object at address
25
- rb-object-print $var 2 # Print with max depth 2
26
-
27
- Default max_depth is 1 if not specified.
28
- Add --debug flag to enable debug output."""
29
-
30
- def __init__(self):
31
- super(RubyObjectPrintCommand, self).__init__("rb-object-print", debugger.COMMAND_DATA)
32
-
33
- def usage(self):
34
- """Print usage information."""
35
- print("Usage: rb-object-print <expression> [--depth N] [--debug]")
36
- print("Examples:")
37
- print(" rb-object-print $errinfo")
38
- print(" rb-object-print $ec->storage --depth 2")
39
- print(" rb-object-print foo + 10")
40
- print(" rb-object-print $ec->cfp->sp[-1] --depth 3 --debug")
41
-
42
- def invoke(self, argument, from_tty):
43
- # Parse arguments using the robust parser
44
- arguments = command.parse_arguments(argument if argument else "")
45
-
46
- # Validate that we have at least one expression
47
- if not arguments.expressions:
48
- self.usage()
49
- return
50
-
51
- # Apply flags
52
- debug_mode = arguments.has_flag('debug')
53
-
54
- # Apply options
55
- max_depth = arguments.get_option('depth', 1)
56
-
57
- # Validate depth
58
- if max_depth < 1:
59
- print("Error: --depth must be >= 1")
60
- return
61
-
62
- # Create terminal and printer
63
- terminal = format.create_terminal(from_tty)
64
- printer = format.Printer(terminal, max_depth, debug_mode)
65
-
66
- # Process each expression
67
- for expression in arguments.expressions:
68
- try:
69
- # Evaluate the expression
70
- ruby_value = debugger.parse_and_eval(expression)
71
-
72
- # Interpret the value and let it print itself recursively
73
- ruby_object = value.interpret(ruby_value)
74
- ruby_object.print_recursive(printer, max_depth)
75
- except debugger.Error as e:
76
- print(f"Error evaluating expression '{expression}': {e}")
77
- except Exception as e:
78
- print(f"Error processing '{expression}': {type(e).__name__}: {e}")
79
- if debug_mode:
80
- import traceback
81
- traceback.print_exc(file=sys.stderr)
82
-
83
- # Register command
84
- RubyObjectPrintCommand()