0

I would like to run a set of python commands from a file in the PDB debugger. Related to this, can I set up a file that is automatically run when PDB starts?

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
justintime
  • 3,601
  • 4
  • 22
  • 37

1 Answers1

1

make a subclass of pdb.Pdb and put a call to your extra stuff in the __init__

alternatively

pdb.Pdb() looks for a .pdbrc file, so you may be able to put your stuff in there

    # Read $HOME/.pdbrc and ./.pdbrc
    self.rcLines = []
    if 'HOME' in os.environ:
        envHome = os.environ['HOME']
        try:
            rcFile = open(os.path.join(envHome, ".pdbrc"))
        except IOError:
            pass
        else:
            for line in rcFile.readlines():
                self.rcLines.append(line)
            rcFile.close()
    try:
        rcFile = open(".pdbrc")
    except IOError:
        pass
    else:
        for line in rcFile.readlines():
            self.rcLines.append(line)
        rcFile.close()
John La Rooy
  • 295,403
  • 53
  • 369
  • 502