vs2017附加linux进程,使用调试器附加到运行的进程 - Visual Studio | Microsoft Docs

本文介绍了如何使用Visual Studio 2017的调试器附加到本地或远程计算机上正在运行的进程,特别是针对Linux进程的远程调试。详细步骤包括设置连接类型、选择目标计算机、过滤进程列表以及选择要调试的代码类型。
摘要由CSDN通过智能技术生成

使用 Visual Studio 调试器附加到正在运行的进程Attach to running processes with the Visual Studio debugger

06/12/2020

本文内容

可将 Visual Studio 调试器附加到本地或远程计算机上正在运行的进程。You can attach the Visual Studio debugger to a running process on a local or remote computer. 进程运行后,在 Visual Studio 中选择“调试” > “附加到进程”,或按 Ctrl+Alt+P,然后使用“附加到进程”对话框将调试器附加到进程 。After the process is running, select Debug > Attach to Process or press Ctrl+Alt+p in Visual Studio, and use the Attach to Process dialog to attach the debugger to the process.

可以使用“附加到进程” 来调试本地或远程计算机上正在运行的应用、同时调试多个进程、 调试并非在 Visual Studio 中创建的应用或未使用附带调试器从 Visual Studio 启动的任何应用。You can use Attach to Process to debug running apps on local or remote computers, debug multiple processes simultaneously, debug apps that weren't created in Visual Studio, or debug any app you didn't start from Visual Studio with the debugger attached. 例如,如果运行的是不带调试器的应用,并触发异常,则可以将调试器附加到运行应用的进程并开始调试。For example, if you're running an app without the debugger and hit an exception, you can then attach the debugger to the process running the app and begin debugging.

提示

不确定自己的调试方案是否需要使用“附加到进程”?Not sure whether to use Attach to Process for your debugging scenario?

附加到本地计算机上正在运行的进程Attach to a running process on your local machine

若要快速重新附加到以前附加到的进程,请参阅重新附加到进程。To quickly reattach to a process you attached to previously, see Reattach to a process.

若要附加到本地计算机上的进程,请执行以下操作:To attach to a process on your local computer:

在 Visual Studio 中,选择“调试” > “附加到进程”(或按 Ctrl+Alt+P),打开“附加到进程”对话框 。In Visual Studio, select Debug > Attach to Process (or press Ctrl+Alt+P) to open the Attach to Process dialog box.

检查“连接类型”。Check the Connection type.

在大多数方案中,可以使用“默认”。In most scenarios, you can use Default. 某些方案可能需要使用不同的连接类型。Some scenarios may require a different connection type. 有关详细信息,请参阅本文中的其他部分或常见调试方案。For more info, see other sections in this article or Common debugging scenarios.

将“连接目标”设置为本地计算机名。Set the Connection target your local machine name.

c07388860568a630c375c4c91a97b97e.png

在“可用进程”列表中,查找并选择要附加到的一个或多个进程。In the Available processes list, find and select the process or processes you want to attach to.

若要快速选择一个进程,请在“筛选进程”框中键入其名称或首字母。To quickly select a process, type its name or first letter in the Filter processes box.

如果不知道进程名称,请浏览列表或参阅常见调试方案,了解一些常见的进程名称。If you don't know the process name, browse through the list, or see Common debugging scenarios for some common process names.

提示

“附加到进程”对话框处于打开状态时,进程可以在后台启动和停止,因此正在运行的进程列表可能不总是最新内容。Processes can start and stop in the background while the Attach to Process dialog box is open, so the list of running processes may not always be current. 可随时选择“刷新”查看当前列表。You can select Refresh at any time to see the current list.

在“附加到”字段中,确保已列出计划调试的代码类型。In the Attach to field, make sure the type of code you plan to debug is listed. 默认的“自动”设置适用于大多数应用类型。The default Automatic setting works for most app types.

如果使用的是“默认”连接类型,可以手动选择要附加到的代码的类型。If you are using the Default connection type, you can manually select the type of code you want to attach to. 否则,“选择”选项可能会被禁用。Otherwise, the Select option may be disabled.

手动选择代码类型:To select code types manually:

单击“选择”。Click Select.

在“选择代码类型”对话框中,选择“调试这些代码类型” 。In the Select Code Type dialog box, select Debug these code types.

如果在尝试附加到列表中的进程时失败,可以使用“选择代码类型”对话框来帮助排查问题。If you experience a failure when you try to attach to a process in the list, you can use the Select Code Type dialog box to help troubleshoot the issue.

选择要调试的代码类型。Select the code types you want to debug.

选择“确定”。Select OK.

选择“附加”。Select Attach.

备注

可附加到多个应用进行调试,但在调试器中一次只能有一个应用处于活动状态。You can be attached to multiple apps for debugging, but only one app is active in the debugger at a time. 可在 Visual Studio 的“调试位置”工具栏或“进程”窗口中设置活动的应用 。You can set the active app in the Visual Studio Debug Location toolbar or Processes window.

附加到远程计算机上的进程Attach to a process on a remote computer

还可以在“附加到进程”对话框中选择远程计算机,查看该计算机上运行的可用进程列表,并附加到一个或多个进程以进行调试。You can also select a remote computer in the Attach to Process d

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值