@@ -55,4 +55,53 @@ def invoke(self, args: str, from_tty: bool) -> None:
55
55
gdb .parse_and_eval (f"(void)free({ int (res )} )" )
56
56
57
57
58
+ class IntArrayRefRepr (gdb .Command ): # type: ignore[misc, no-any-unimported]
59
+ """
60
+ Print human readable representation of c10::IntArrayRef
61
+ """
62
+
63
+ def __init__ (self ) -> None :
64
+ gdb .Command .__init__ (
65
+ self , "torch-int-array-ref-repr" , gdb .COMMAND_USER , gdb .COMPLETE_EXPRESSION
66
+ )
67
+
68
+ def invoke (self , args : str , from_tty : bool ) -> None :
69
+ args = gdb .string_to_argv (args )
70
+ if len (args ) != 1 :
71
+ print ("Usage: torch-int-array-ref-repr EXP" )
72
+ return
73
+ name = args [0 ]
74
+ with DisableBreakpoints ():
75
+ res = gdb .parse_and_eval (f"torch::gdb::int_array_ref_string({ name } )" )
76
+ res = str (res )
77
+ print (res [res .find ('"' ) + 1 : - 1 ])
78
+
79
+
80
+ class DispatchKeysetRepr (gdb .Command ): # type: ignore[misc, no-any-unimported]
81
+ """
82
+ Print human readable representation of c10::DispatchKeyset
83
+ """
84
+
85
+ def __init__ (self ) -> None :
86
+ gdb .Command .__init__ (
87
+ self ,
88
+ "torch-dispatch-keyset-repr" ,
89
+ gdb .COMMAND_USER ,
90
+ gdb .COMPLETE_EXPRESSION ,
91
+ )
92
+
93
+ def invoke (self , args : str , from_tty : bool ) -> None :
94
+ args = gdb .string_to_argv (args )
95
+ if len (args ) != 1 :
96
+ print ("Usage: torch-dispatch-keyset-repr EXP" )
97
+ return
98
+ keyset = args [0 ]
99
+ with DisableBreakpoints ():
100
+ res = gdb .parse_and_eval (f"torch::gdb::dispatch_keyset_string({ keyset } )" )
101
+ res = str (res )
102
+ print (res [res .find ('"' ) + 1 : - 1 ])
103
+
104
+
58
105
TensorRepr ()
106
+ IntArrayRefRepr ()
107
+ DispatchKeysetRepr ()
0 commit comments