@@ -211,21 +211,43 @@ def debug(
211211 `dbg_opts' is an optional "options" dictionary that gets fed
212212 trepan.Debugger(); `start_opts' are the optional "options"
213213 dictionary that gets fed to trepan.Debugger.core.start()."""
214+
215+ # We have a global debugger_obj that we reuse
214216 global debugger_obj
217+
218+ # A list of debugger profiles we might run
219+ dbg_initfiles = []
220+
215221 if debugger_obj is None :
222+ # If debugger_obj has not been set this is the first time
223+ # we are entering the debugger.
224+ # create the object, and set to run the user's
225+ # debugger initialization profile
226+
216227 debugger_obj = Trepan (dbg_opts )
217228 debugger_obj .core .add_ignore (debug , stop )
229+
230+ # Run user profile if first time and we haven't
231+ # explicit set to ignore profile loading.
232+ if not start_opts or start_opts .get ("startup-profile" , True ):
233+ from trepan .options import add_startup_file
234+
235+ add_startup_file (dbg_initfiles )
236+
218237 pass
238+
219239 core = debugger_obj .core
220240 frame = sys ._getframe (0 + level )
221241 core .set_next (frame )
222- if start_opts and "startup-profile" in start_opts and start_opts ["startup-profile" ]:
223- dbg_initfiles = start_opts ["startup-profile" ]
224- from trepan import options
225242
226- options .add_startup_file (dbg_initfiles )
227- for init_cmdfile in dbg_initfiles :
228- core .processor .queue_startfile (init_cmdfile )
243+ # If we've specified profile loading, add that
244+ if start_opts and start_opts .get ("startup-profile" , False ):
245+ from trepan .options import add_startup_file
246+
247+ add_startup_file (dbg_initfiles )
248+
249+ for init_cmdfile in dbg_initfiles :
250+ core .processor .queue_startfile (init_cmdfile )
229251
230252 if not core .is_started ():
231253 core .start (start_opts )
0 commit comments