Quantcast
Channel: Python extension for WinDbg
Viewing all articles
Browse latest Browse all 1625

New Post: can I debug python script?

$
0
0
Of course you can.

1) You can use pdb with windbg:
kd> !py pdb C:\\temp\\sample.py "hello"
> c:\temp\sample.py(1)<module>()
-> import sys
(Pdb) s
> c:\temp\sample.py(3)<module>()
-> a = sys.argv[0]
(Pdb) s
> c:\temp\sample.py(5)<module>()
-> print s
(Pdb) pp a
'C:\\\\temp\\\\sample.py'
(Pdb) c
Traceback (most recent call last):
  File "C:\Python26\x64\Lib\pdb.py", line 1296, in main
    pdb._runscript(mainpyfile)
  File "C:\Python26\x64\Lib\pdb.py", line 1215, in _runscript
    self.run(statement)
  File "C:\Python26\x64\Lib\bdb.py", line 372, in run
    exec cmd in globals, locals
  File "<string>", line 1, in <module>
  File "C:\temp\sample.py", line 5, in <module>
    print s
NameError: name 's' is not defined
Uncaught exception. Entering post mortem debugging
Running 'cont' or 'step' will restart the program
> c:\temp\sample.py(5)<module>()
-> print s
(Pdb) 
Here is sample or pdb using inside windbg.
Note:
I use full path to script with escape symbols: C:\temp\sample.py
If you has installed readyline or pyreadyline it can follow to error.
2) You can use interactive console ( !pycmd for 0.2.x version and !py without args for 0.3.x version ) for checking your idea and then copy/paste commands for a stand alone script.
3) You can use any python debugger ( for example VisualStudio + PyTools ).
First of all create memory dump from your live debug session:
.dump /f  dumpname.dmp
Then add one string to begin of your python program:
loadDump(r"dumpname.dmp")
Now you can debug it with any python debugger.

I hope It helps

Viewing all articles
Browse latest Browse all 1625

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>