如何让前端以交互方式调用pdb方法?

时间:2016-12-28 22:20:18

标签: python python-3.x debugging pdb

我试图创建一个GUI,在没有终端的情况下调用pdb方法。我的代码如下所示:

class Debugger(pdb.Pdb):

  def user_call(self, frame, args):
    name = frame.f_code.co_name or "<unknown>"
    print("call", name, args, frame)
    print('local:', frame.f_locals)
    print('global:', frame.f_globals)

  def user_line(self, frame):
    name = frame.f_code.co_name or "<unknown>"
    filename = self.canonic(frame.f_code.co_filename)
    print("break at", filename, frame.f_lineno, "in", name)
    print("continue...")

  def user_return(self, frame, value):
    name = frame.f_code.co_name or "<unknown>"
    print("return from", name, value)
    print("continue...")

  def user_exception(self, frame, exception):
    name = frame.f_code.co_name or "<unknown>"
    print("exception in", name, exception)
    print("continue...")

def debug():
  debugger = Debugger()

  # invoke the interactive debugging commands here 

if __name__=='__main__':
  debug()

如何从指向文件的代码启动调试会话并调用步骤继续等命令?

0 个答案:

没有答案