commands [bpnumber] (com) ... (com) end (Pdb) Specify a list of commands for breakpoint number bpnumber. The commands themselves are entered on the following lines. Type a line containing just 'end' to terminate the commands. The commands are
(self, arg)
| 527 | # Return true to exit from the command loop |
| 528 | |
| 529 | def do_commands(self, arg): |
| 530 | """commands [bpnumber] |
| 531 | (com) ... |
| 532 | (com) end |
| 533 | (Pdb) |
| 534 | |
| 535 | Specify a list of commands for breakpoint number bpnumber. |
| 536 | The commands themselves are entered on the following lines. |
| 537 | Type a line containing just 'end' to terminate the commands. |
| 538 | The commands are executed when the breakpoint is hit. |
| 539 | |
| 540 | To remove all commands from a breakpoint, type commands and |
| 541 | follow it immediately with end; that is, give no commands. |
| 542 | |
| 543 | With no bpnumber argument, commands refers to the last |
| 544 | breakpoint set. |
| 545 | |
| 546 | You can use breakpoint commands to start your program up |
| 547 | again. Simply use the continue command, or step, or any other |
| 548 | command that resumes execution. |
| 549 | |
| 550 | Specifying any command resuming execution (currently continue, |
| 551 | step, next, return, jump, quit and their abbreviations) |
| 552 | terminates the command list (as if that command was |
| 553 | immediately followed by end). This is because any time you |
| 554 | resume execution (even with a simple next or step), you may |
| 555 | encounter another breakpoint -- which could have its own |
| 556 | command list, leading to ambiguities about which list to |
| 557 | execute. |
| 558 | |
| 559 | If you use the 'silent' command in the command list, the usual |
| 560 | message about stopping at a breakpoint is not printed. This |
| 561 | may be desirable for breakpoints that are to print a specific |
| 562 | message and then continue. If none of the other commands |
| 563 | print anything, you will see no sign that the breakpoint was |
| 564 | reached. |
| 565 | """ |
| 566 | if not arg: |
| 567 | bnum = len(bdb.Breakpoint.bpbynumber) - 1 |
| 568 | else: |
| 569 | try: |
| 570 | bnum = int(arg) |
| 571 | except: |
| 572 | self.error("Usage: commands [bnum]\n ...\n end") |
| 573 | return |
| 574 | self.commands_bnum = bnum |
| 575 | # Save old definitions for the case of a keyboard interrupt. |
| 576 | if bnum in self.commands: |
| 577 | old_command_defs = (self.commands[bnum], |
| 578 | self.commands_doprompt[bnum], |
| 579 | self.commands_silent[bnum]) |
| 580 | else: |
| 581 | old_command_defs = None |
| 582 | self.commands[bnum] = [] |
| 583 | self.commands_doprompt[bnum] = True |
| 584 | self.commands_silent[bnum] = False |
| 585 | |
| 586 | prompt_back = self.prompt |