Pdb Crashed: Cannot set breakpoint

若如初见. 提交于 2020-01-16 13:17:21

问题


I suddenly cannot set any breakpoint in my python program. Note there are two (Pdb) showing up. I wonder if the Pdb was damaged before. I did try to step into some compiled C++ code in an abc.so file using Pdb before this issue started happening:

-> print('haha')
(Pdb) (Pdb) 
Traceback (most recent call last):
  File "high.py", line 38, in <module>
    print('haha')
  File "high.py", line 38, in <module>
    print('haha')
  File "/Users/ludaming/anaconda2/lib/python2.7/bdb.py", line 49, in trace_dispatch
    return self.dispatch_line(frame)
  File "/Users/ludaming/anaconda2/lib/python2.7/bdb.py", line 68, in dispatch_line
    if self.quitting: raise BdbQuit
bdb.BdbQuit

回答1:


Now I figured it out that the Pdb is not malfunctioning. It is because Python reads from stdin right next to the Pdb, which enters to the Pdb's interactive console and causing a problem. So a bypass is to read from file instead of stdin

fp = open(sys.argv[1], 'r')  
t = int(fp.readline())

instead of

t = int(raw_input())


来源:https://stackoverflow.com/questions/51453619/pdb-crashed-cannot-set-breakpoint

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