Interactive code view in python debugger pdb

Is it possible to watch how code is executed interactively in a python debugger pdb?

For example, gdbyou can press ^ x + ^ a and display a code window.

Gdb screenshots

I know that I see some code using list, but is there an option gdb?

+4
source share
1 answer

Not out of the box, but you can add Cmd.preloop()and Cmd.precmd()the team division pdb.Pdbin the file .pdbrcin your home directory, then enter the text editor to display text.

, PdbSublimeTextSupport PdbTextMateSupport.

Cmd; self.stack[self.curindex] , .

PdbSublimeTextSupport :

def launch(self):
    frame, lineno = self.stack[self.curindex]
    filename = self.canonic(frame.f_code.co_filename)
    if exists(filename):
        command = 'subl -b "%s:%d"' % (filename, lineno)
        os.system(command)

def preloop(self):
    launch(self)

def precmd(self, line):
    launch(self)
    return line

Sublime Text filename lineno.

bdb (, PDB) bdb.py pdb.py, .

+2

Source: https://habr.com/ru/post/1532512/


All Articles