@@ -65,9 +65,84 @@ class Trepan:
6565 Class for a top-level object.
6666 """
6767
68- def __init__ (self ):
68+ def __init__ (self , opts = None ):
69+ """Create a debugger object. But depending on the value of
70+ key 'start' inside hash 'opts', we may or may not initially
71+ start debugging.
72+
73+ See also ``Debugger.start`` and ``Debugger.stop``.
74+ """
75+
76+ self .mainpyfile = None
77+ self .thread = None
78+ self .eval_string = None
6979 self .settings = {}
7080
81+ def get_option (key : str ) -> Any :
82+ return option_set (opts , key , self .DEFAULT_INIT_OPTS )
83+
84+ def completer (text : str , state ):
85+ return self .complete (text , state )
86+
87+ # set the instance variables that come directly from options.
88+ for opt in ("settings" , "orig_sys_argv" , "from_ipython" ):
89+ setattr (self , opt , get_option (opt ))
90+ pass
91+
92+ core_opts = {}
93+ for opt in (
94+ "ignore_filter" ,
95+ "proc_opts" ,
96+ "processor" ,
97+ "step_ignore" ,
98+ "processor" ,
99+ ):
100+ core_opts [opt ] = get_option (opt )
101+ pass
102+
103+ # How are I/O for this debugger handled? This should
104+ # be set before calling DebuggerCore.
105+ interface_opts = {
106+ "complete" : completer ,
107+ "debugger_name" : "trepan3k" ,
108+ }
109+ # FIXME when I pass in opts=opts things break
110+
111+ inp = opts .get ("input" , None ) if opts else None
112+ interface = get_option ("interface" ) or UserInterface (
113+ inp = inp , opts = interface_opts
114+ )
115+ self .intf = [interface ]
116+
117+ out = get_option ("output" )
118+ if out :
119+ self .intf [- 1 ].output = out
120+ pass
121+
122+ self .core = TrepanCore (self , core_opts )
123+ self .core .add_ignore (self .core .stop )
124+
125+ # When set True, we'll also suspend our debug-hook tracing.
126+ # This gives us a way to prevent or allow self debugging.
127+ self .core .trace_hook_suspend = False
128+
129+ if get_option ("save_sys_argv" ):
130+ # Save the debugged program's sys.argv? We do this so that
131+ # when the debugged script munges these, we have a good
132+ # copy to use for an exec restart
133+ self .program_sys_argv = list (sys .argv )
134+ else :
135+ self .program_sys_argv = None
136+ pass
137+
138+ self .sigmgr = SignalManager (self )
139+
140+ # Were we requested to activate immediately?
141+ if get_option ("activate" ):
142+ self .core .start (get_option ("start_opts" ))
143+ pass
144+ return
145+
71146 # The following functions have to be defined before
72147 # DEFAULT_INIT_OPTS which includes references to these.
73148
@@ -289,83 +364,6 @@ def restart_argv(self):
289364 "from_ipython" : False ,
290365 }
291366
292- def __init__ (self , opts = None ):
293- """Create a debugger object. But depending on the value of
294- key 'start' inside hash 'opts', we may or may not initially
295- start debugging.
296-
297- See also ``Debugger.start`` and ``Debugger.stop``.
298- """
299-
300- self .mainpyfile = None
301- self .thread = None
302- self .eval_string = None
303-
304- def get_option (key : str ) -> Any :
305- return option_set (opts , key , self .DEFAULT_INIT_OPTS )
306-
307- def completer (text : str , state ):
308- return self .complete (text , state )
309-
310- # set the instance variables that come directly from options.
311- for opt in ("settings" , "orig_sys_argv" , "from_ipython" ):
312- setattr (self , opt , get_option (opt ))
313- pass
314-
315- core_opts = {}
316- for opt in (
317- "ignore_filter" ,
318- "proc_opts" ,
319- "processor" ,
320- "step_ignore" ,
321- "processor" ,
322- ):
323- core_opts [opt ] = get_option (opt )
324- pass
325-
326- # How are I/O for this debugger handled? This should
327- # be set before calling DebuggerCore.
328- interface_opts = {
329- "complete" : completer ,
330- "debugger_name" : "trepan3k" ,
331- }
332- # FIXME when I pass in opts=opts things break
333-
334- inp = opts .get ("input" , None ) if opts else None
335- interface = get_option ("interface" ) or UserInterface (
336- inp = inp , opts = interface_opts
337- )
338- self .intf = [interface ]
339-
340- out = get_option ("output" )
341- if out :
342- self .intf [- 1 ].output = out
343- pass
344-
345- self .core = TrepanCore (self , core_opts )
346- self .core .add_ignore (self .core .stop )
347-
348- # When set True, we'll also suspend our debug-hook tracing.
349- # This gives us a way to prevent or allow self debugging.
350- self .core .trace_hook_suspend = False
351-
352- if get_option ("save_sys_argv" ):
353- # Save the debugged program's sys.argv? We do this so that
354- # when the debugged script munges these, we have a good
355- # copy to use for an exec restart
356- self .program_sys_argv = list (sys .argv )
357- else :
358- self .program_sys_argv = None
359- pass
360-
361- self .sigmgr = SignalManager (self )
362-
363- # Were we requested to activate immediately?
364- if get_option ("activate" ):
365- self .core .start (get_option ("start_opts" ))
366- pass
367- return
368-
369367 def complete (self , last_token : str , state : int ):
370368 """
371369 In place expansion of top-level debugger command
0 commit comments