Save breakpoints to file

北城以北 提交于 2019-12-01 04:57:28

You can save the breakpoints to .pdbrc file in a working path or globally to your home dir. File should have something like this:

# breakpoint 1
break /path/to/file:lineno

# breakpoint 2
break /path/to/file:lineno

You can define breakpoints various ways, just like in the interactive mode. So just break 4 or break method will work too.

This file works for both, pdb and ipdb, since later has everything pdb has and more.

Bonus:

You could use alias to more easily save breakpoints. For example:

# append breakpoint to .pdbrc in current working directory
# usage: bs lineno
alias bs with open(".pdbrc", "a") as pdbrc: pdbrc.write("break " + __file__ + ":%1\n")

Put above to your global .pdbrc and use it like this:

> bs 15

This will append a breakpoint statement to a local .pdbrc file for a line 15 of current file.

It is not perfect solution, but close enough for me. Tune the command to your needs.

Read more about aliases here.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!