Show More
@@ -414,6 +414,10 b' python-profiler package from non-free.""")' | |||||
414 | the first breakpoint must be set on a line which actually does |
|
414 | the first breakpoint must be set on a line which actually does | |
415 | something (not a comment or docstring) for it to stop execution. |
|
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 | When the pdb debugger starts, you will see a (Pdb) prompt. You must |
|
421 | When the pdb debugger starts, you will see a (Pdb) prompt. You must | |
418 | first enter 'c' (without quotes) to start execution up to the first |
|
422 | first enter 'c' (without quotes) to start execution up to the first | |
419 | breakpoint. |
|
423 | breakpoint. | |
@@ -551,11 +555,11 b' python-profiler package from non-free.""")' | |||||
551 | bdb.Breakpoint.bpbynumber = [None] |
|
555 | bdb.Breakpoint.bpbynumber = [None] | |
552 | # Set an initial breakpoint to stop execution |
|
556 | # Set an initial breakpoint to stop execution | |
553 | maxtries = 10 |
|
557 | maxtries = 10 | |
554 | bp = int(opts.get('b', [1])[0]) |
|
558 | bp_file, bp_line = parse_breakpoint(opts.get('b', [1])[0], filename) | |
555 |
checkline = deb.checkline(file |
|
559 | checkline = deb.checkline(bp_file, bp_line) | |
556 | if not checkline: |
|
560 | if not checkline: | |
557 | for bp in range(bp + 1, bp + maxtries + 1): |
|
561 | for bp in range(bp_line + 1, bp_line + maxtries + 1): | |
558 |
if deb.checkline(file |
|
562 | if deb.checkline(bp_file, bp): | |
559 | break |
|
563 | break | |
560 | else: |
|
564 | else: | |
561 | msg = ("\nI failed to find a valid line to set " |
|
565 | msg = ("\nI failed to find a valid line to set " | |
@@ -566,7 +570,7 b' python-profiler package from non-free.""")' | |||||
566 | error(msg) |
|
570 | error(msg) | |
567 | return |
|
571 | return | |
568 | # if we find a good linenumber, set the breakpoint |
|
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 | # Mimic Pdb._runscript(...) |
|
575 | # Mimic Pdb._runscript(...) | |
572 | deb._wait_for_mainpyfile = True |
|
576 | deb._wait_for_mainpyfile = True | |
@@ -578,7 +582,7 b' python-profiler package from non-free.""")' | |||||
578 | ns = {'execfile': py3compat.execfile, 'prog_ns': prog_ns} |
|
582 | ns = {'execfile': py3compat.execfile, 'prog_ns': prog_ns} | |
579 | try: |
|
583 | try: | |
580 | #save filename so it can be used by methods on the deb object |
|
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 | deb.run('execfile("%s", prog_ns)' % filename, ns) |
|
586 | deb.run('execfile("%s", prog_ns)' % filename, ns) | |
583 |
|
587 | |||
584 | except: |
|
588 | except: | |
@@ -1079,3 +1083,11 b' python-profiler package from non-free.""")' | |||||
1079 | self.shell.run_cell(cell) |
|
1083 | self.shell.run_cell(cell) | |
1080 | if args.output: |
|
1084 | if args.output: | |
1081 | self.shell.user_ns[args.output] = io |
|
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