@@ -350,10 +350,6 @@ def __init__(self, completekey='tab', stdin=None, stdout=None, skip=None,
350350 pass
351351
352352 self .commands = {} # associates a command list to breakpoint numbers
353- self .commands_doprompt = {} # for each bp num, tells if the prompt
354- # must be disp. after execing the cmd list
355- self .commands_silent = {} # for each bp num, tells if the stack trace
356- # must be disp. after execing the cmd list
357353 self .commands_defining = False # True while in the process of defining
358354 # a command list
359355 self .commands_bnum = None # The breakpoint number for which we are
@@ -437,8 +433,8 @@ def user_line(self, frame):
437433 or frame .f_lineno <= 0 ):
438434 return
439435 self ._wait_for_mainpyfile = False
440- if self .bp_commands (frame ):
441- self .interaction (frame , None )
436+ self .bp_commands (frame )
437+ self .interaction (frame , None )
442438
443439 user_opcode = user_line
444440
@@ -453,18 +449,9 @@ def bp_commands(self, frame):
453449 self .currentbp in self .commands :
454450 currentbp = self .currentbp
455451 self .currentbp = 0
456- lastcmd_back = self .lastcmd
457- self .setup (frame , None )
458452 for line in self .commands [currentbp ]:
459- self .onecmd (line )
460- self .lastcmd = lastcmd_back
461- if not self .commands_silent [currentbp ]:
462- self .print_stack_entry (self .stack [self .curindex ])
463- if self .commands_doprompt [currentbp ]:
464- self ._cmdloop ()
465- self .forget ()
466- return
467- return 1
453+ self .cmdqueue .append (line )
454+ self .cmdqueue .append (f'_pdbcmd_restore_lastcmd { self .lastcmd } ' )
468455
469456 def user_return (self , frame , return_value ):
470457 """This function is called when a return trap is set here."""
@@ -863,15 +850,15 @@ def handle_command_def(self, line):
863850 cmd , arg , line = self .parseline (line )
864851 if not cmd :
865852 return False
866- if cmd == 'silent' :
867- self .commands_silent [self .commands_bnum ] = True
868- return False # continue to handle other cmd def in the cmd list
869- elif cmd == 'end' :
853+ if cmd == 'end' :
870854 return True # end of cmd list
871855 elif cmd == 'EOF' :
872856 print ('' )
873857 return True # end of cmd list
874858 cmdlist = self .commands [self .commands_bnum ]
859+ if cmd == 'silent' :
860+ cmdlist .append ('_pdbcmd_silence_frame_status' )
861+ return False # continue to handle other cmd def in the cmd list
875862 if arg :
876863 cmdlist .append (cmd + ' ' + arg )
877864 else :
@@ -883,7 +870,6 @@ def handle_command_def(self, line):
883870 func = self .default
884871 # one of the resuming commands
885872 if func .__name__ in self .commands_resuming :
886- self .commands_doprompt [self .commands_bnum ] = False
887873 return True
888874 return False
889875
@@ -996,6 +982,13 @@ def _pdbcmd_print_frame_status(self, arg):
996982 self .print_stack_trace (0 )
997983 self ._show_display ()
998984
985+ def _pdbcmd_silence_frame_status (self , arg ):
986+ if self .cmdqueue and self .cmdqueue [- 1 ] == '_pdbcmd_print_frame_status' :
987+ self .cmdqueue .pop ()
988+
989+ def _pdbcmd_restore_lastcmd (self , arg ):
990+ self .lastcmd = arg
991+
999992 # Command definitions, called by cmdloop()
1000993 # The argument is the remaining string on the command line
1001994 # Return true to exit from the command loop
@@ -1054,14 +1047,10 @@ def do_commands(self, arg):
10541047 self .commands_bnum = bnum
10551048 # Save old definitions for the case of a keyboard interrupt.
10561049 if bnum in self .commands :
1057- old_command_defs = (self .commands [bnum ],
1058- self .commands_doprompt [bnum ],
1059- self .commands_silent [bnum ])
1050+ old_commands = self .commands [bnum ]
10601051 else :
1061- old_command_defs = None
1052+ old_commands = None
10621053 self .commands [bnum ] = []
1063- self .commands_doprompt [bnum ] = True
1064- self .commands_silent [bnum ] = False
10651054
10661055 prompt_back = self .prompt
10671056 self .prompt = '(com) '
@@ -1070,14 +1059,10 @@ def do_commands(self, arg):
10701059 self .cmdloop ()
10711060 except KeyboardInterrupt :
10721061 # Restore old definitions.
1073- if old_command_defs :
1074- self .commands [bnum ] = old_command_defs [0 ]
1075- self .commands_doprompt [bnum ] = old_command_defs [1 ]
1076- self .commands_silent [bnum ] = old_command_defs [2 ]
1062+ if old_commands :
1063+ self .commands [bnum ] = old_commands
10771064 else :
10781065 del self .commands [bnum ]
1079- del self .commands_doprompt [bnum ]
1080- del self .commands_silent [bnum ]
10811066 self .error ('command definition aborted, old commands restored' )
10821067 finally :
10831068 self .commands_defining = False
@@ -2093,7 +2078,7 @@ def complete_unalias(self, text, line, begidx, endidx):
20932078
20942079 # List of all the commands making the program resume execution.
20952080 commands_resuming = ['do_continue' , 'do_step' , 'do_next' , 'do_return' ,
2096- 'do_quit' , 'do_jump' ]
2081+ 'do_until' , ' do_quit' , 'do_jump' ]
20972082
20982083 # Print a traceback starting at the top stack frame.
20992084 # The most recently entered frame is printed last;
0 commit comments