Show More
@@ -414,6 +414,10 b' python-profiler package from non-free.""")' | |||
|
414 | 414 | the first breakpoint must be set on a line which actually does |
|
415 | 415 | something (not a comment or docstring) for it to stop execution. |
|
416 | 416 | |
|
417 | Or you can specify a breakpoint in a different file:: | |
|
418 | ||
|
419 | %run -d -b myotherfile.py:20 myscript | |
|
420 | ||
|
417 | 421 | When the pdb debugger starts, you will see a (Pdb) prompt. You must |
|
418 | 422 | first enter 'c' (without quotes) to start execution up to the first |
|
419 | 423 | breakpoint. |
@@ -551,11 +555,11 b' python-profiler package from non-free.""")' | |||
|
551 | 555 | bdb.Breakpoint.bpbynumber = [None] |
|
552 | 556 | # Set an initial breakpoint to stop execution |
|
553 | 557 | maxtries = 10 |
|
554 | bp = int(opts.get('b', [1])[0]) | |
|
555 |
checkline = deb.checkline(file |
|
|
558 | bp_file, bp_line = parse_breakpoint(opts.get('b', [1])[0], filename) | |
|
559 | checkline = deb.checkline(bp_file, bp_line) | |
|
556 | 560 | if not checkline: |
|
557 | for bp in range(bp + 1, bp + maxtries + 1): | |
|
558 |
if deb.checkline(file |
|
|
561 | for bp in range(bp_line + 1, bp_line + maxtries + 1): | |
|
562 | if deb.checkline(bp_file, bp): | |
|
559 | 563 | break |
|
560 | 564 | else: |
|
561 | 565 | msg = ("\nI failed to find a valid line to set " |
@@ -566,7 +570,7 b' python-profiler package from non-free.""")' | |||
|
566 | 570 | error(msg) |
|
567 | 571 | return |
|
568 | 572 | # if we find a good linenumber, set the breakpoint |
|
569 |
deb.do_break('%s:%s' % (file |
|
|
573 | deb.do_break('%s:%s' % (bp_file, bp_line)) | |
|
570 | 574 | |
|
571 | 575 | # Mimic Pdb._runscript(...) |
|
572 | 576 | deb._wait_for_mainpyfile = True |
@@ -578,7 +582,7 b' python-profiler package from non-free.""")' | |||
|
578 | 582 | ns = {'execfile': py3compat.execfile, 'prog_ns': prog_ns} |
|
579 | 583 | try: |
|
580 | 584 | #save filename so it can be used by methods on the deb object |
|
581 |
deb._exec_filename = file |
|
|
585 | deb._exec_filename = bp_file | |
|
582 | 586 | deb.run('execfile("%s", prog_ns)' % filename, ns) |
|
583 | 587 | |
|
584 | 588 | except: |
@@ -1079,3 +1083,11 b' python-profiler package from non-free.""")' | |||
|
1079 | 1083 | self.shell.run_cell(cell) |
|
1080 | 1084 | if args.output: |
|
1081 | 1085 | self.shell.user_ns[args.output] = io |
|
1086 | ||
|
1087 | def parse_breakpoint(text, current_file): | |
|
1088 | '''Returns (file, line) for file:line and (current_file, line) for line''' | |
|
1089 | colon = text.find(':') | |
|
1090 | if colon == -1: | |
|
1091 | return current_file, int(text) | |
|
1092 | else: | |
|
1093 | return text[:colon], int(text[colon+1:]) |
General Comments 0
You need to be logged in to leave comments.
Login now