vs2013下的python遠程調試支持(2) :工程調試

當我們按F5啓動python工程調試時,PTVS以下面的參數調用PythonWrapper

visualstudio_py_laucher.py中明確指明瞭此文件可以接受的參數含義:

# Arguments are:

# 1. Working directory.

# 2. VS debugger port to connect to.

# 3. GUID for the debug session.

# 4. Debug options (as integer - see enum PythonDebugOptions).

# 5. '-m' or '-c' to override the default run-as mode. [optional]

# 6. Startup script name.

# 7. Script arguments.

與交互窗口的修改一樣,我們做同樣的處理,所不同的是這裏需要將要調試的Python文件複製到Linux主機上,而後相應修改文件路徑。

經過此處理後,vspython調試功能就可以正常使用了。

但當我們打開一個交互調試的窗口並輸入語句時就悲劇了:

Unhandled exception in thread started by <bound methodDebuggerLoop.connect_to_repl_backend of<visualstudio_py_debugger.DebuggerLoop object at 0xb751d30c>>

Traceback (most recent call last):

  File"/usr/local/lib/python2.7/socket.py", line 228, in meth

    returngetattr(self._sock,name)(*args)

error: [Errno 111] Connection refused

Press Enter to continue . . .

想來除了調試用的端口外,PTVS還打開了一個交互調試用的端口。

查看visualstudio_py_debugger.py文件可以很容易發現此端口的痕跡:

    defcommand_connect_repl(self):

        port_num =read_int(self.conn)

       _start_new_thread(self.connect_to_repl_backend, (port_num,))

同樣在PythonWrapper中將此端口做個轉發,搞定!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章