{"id":28613,"date":"2021-08-11T16:21:30","date_gmt":"2021-08-11T16:21:30","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/cppblog\/?p=28613"},"modified":"2021-11-22T22:19:44","modified_gmt":"2021-11-22T22:19:44","slug":"attach-to-a-remote-process-with-lldb-in-visual-studio-2022-preview-3","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/cppblog\/attach-to-a-remote-process-with-lldb-in-visual-studio-2022-preview-3\/","title":{"rendered":"Attach to a Remote Process with LLDB in Visual Studio 2022 Preview 3"},"content":{"rendered":"<p>You can now use <strong>Attach to Process<\/strong> to remote debug processes with GDB or LLDB in Visual Studio. The ability to attach to a process running on a remote system with GDB was added in Visual Studio 2019. The ability to attach to a process with LLDB is new in Visual Studio 2022 Preview 3.<\/p>\n<p>Remote debugging in Visual Studio is especially valuable for teams who write cross-platform C++ code that runs on Windows and Linux or macOS. For example, if you use Windows + Visual Studio as your primary development environment, then you may need to occasionally debug code running on Linux or macOS. Rather than switching platforms and using GDB or LLDB from the command line, you can use Visual Studio to remote debug processes running on Linux and macOS. Visual Studio\u2019s remote C++ support assumes that your source code is located in the Windows file system.<\/p>\n<p>While a native, command driven workflow may be the best choice for your team, we know that some teams:<\/p>\n<ul>\n<li>Are unfamiliar with platform specific tools, especially if they use Windows + the Visual Studio debugger as their primary development environment.<\/li>\n<li>Prefer Visual Studio&#8217;s graphical interface and feature set over a command line interface.<\/li>\n<li>Find it unproductive to switch between platforms for native debugging.<\/li>\n<li>Rely on a subset of developers who are comfortable with command line tools to debug all non-Windows errors and are looking to democratize that process.<\/li>\n<\/ul>\n<p>Follow the steps below to get started debugging a remote process with LLDB and Visual Studio 2022.<\/p>\n<h4>Getting started instructions<\/h4>\n<p>1. On Windows, <a href=\"https:\/\/visualstudio.microsoft.com\/vs\/preview\/vs2022\/\">Install Visual Studio 2022 Preview 3 or later.<\/a><\/p>\n<p>2. On your remote system, acquire LLDB and LLDB-mi. On macOS you can install LLDB with XCode or the XCode Command Line Tools. You can install a build of LLDB-mi maintained by the C\/C++ Extension for VS Code.<\/p>\n<p><div  class=\"d-flex justify-content-center\"><a class=\"cta_button_link btn-primary mb-24\" href=\"https:\/\/go.microsoft.com\/fwlink\/?linkid=2154927\" target=\"_blank\">Install LLDB-mi for macOS<\/a><\/div><\/p>\n<p>We don\u2019t currently maintain a LLDB-mi binary for Linux. You can install LLDB and LLDB-mi with the instructions in <a href=\"https:\/\/github.com\/microsoft\/vscode-cpptools\/issues\/5415#issuecomment-662603085\">this comment<\/a> from iamWing in the C\/C++ Extension for VS Code repository.<\/p>\n<p>3. On your remote system, start SSH (<a href=\"https:\/\/docs.microsoft.com\/en-us\/cpp\/linux\/connect-to-your-remote-linux-computer?view=msvc-160#set-up-the-ssh-server-on-the-remote-system\">instructions<\/a>) and the process that you want to debug.<\/p>\n<p>4. On Windows, open Visual Studio 2022 and select <strong>Debug &gt; Attach to Process\u2026<\/strong><\/p>\n<ul>\n<li>Set the <strong>Connection type<\/strong> to SSH.<\/li>\n<li>Set the <strong>Connection target. <\/strong>You can select any system that you have added to the Visual Studio <a href=\"https:\/\/docs.microsoft.com\/en-us\/cpp\/linux\/connect-to-your-remote-linux-computer?view=msvc-160\">Connection Manager<\/a>, or you can provide a new address with the format <strong>user@host <\/strong>(e.g., demo@121.121.2.11). You can also add new connections to the Visual Studio Connection Manager with our <a href=\"https:\/\/docs.microsoft.com\/en-us\/cpp\/linux\/connectionmanager-reference?view=msvc-160\">command line tool<\/a>.<\/li>\n<li>Set the <strong>code type <\/strong>to Native (LLDB). If you are remote debugging with GDB, then set the code type to Native (GDB).<\/li>\n<\/ul>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/08\/select-code-type.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-28614\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/08\/select-code-type.png\" alt=\"The Visual Studio dialog is labeled &quot;Select Code Type.&quot; The option &quot;Debug these code types&quot; is selected and followed by two options: Native (GDB) and Native (LLDB). Native (LLDB) is selected.\" width=\"488\" height=\"383\" srcset=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/08\/select-code-type.png 488w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/08\/select-code-type-300x235.png 300w\" sizes=\"(max-width: 488px) 100vw, 488px\" \/><\/a><\/p>\n<ul>\n<li>The <strong>list of available processes<\/strong> will list all processes running on your remote system by process name and ID. Select the process that you want to remote debug and press \u201cAttach\u201d to launch the debugger.<\/li>\n<\/ul>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/08\/attach-to-process-1.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-28625\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/08\/attach-to-process-1.png\" alt=\"The Visual Studio dialog is labeled &quot;Attach to Process.&quot; The connection type is SSH, the connection target is &quot;erika@localhost&quot;, and the code type is &quot;Native (LLDB) code&quot;. A list of 3 processes is displayed under &quot;Available processes&quot;, and process &quot;CMakeProject&quot; is selected.\" width=\"853\" height=\"604\" srcset=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/08\/attach-to-process-1.png 853w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/08\/attach-to-process-1-300x212.png 300w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/08\/attach-to-process-1-768x544.png 768w\" sizes=\"(max-width: 853px) 100vw, 853px\" \/><\/a><\/p>\n<p>5. Visual Studio will attach LLDB to the selected process and start a debugging session. You can pause the debugger to see the current execution point. All the debug windows support by Visual Studio will be populated with data from the remote process.<\/p>\n<h4>Talk to us!<\/h4>\n<p>Attach to Process is the first remote debugging scenario supported by LLDB in Visual Studio. Try it out and give us your feedback, or let us know if there are other remote debugging features that you want to see. The best way to file a bug or suggest a feature is with the <strong>Send Feedback<\/strong> button in the upper right-hand corner of the IDE. See <a href=\"https:\/\/docs.microsoft.com\/en-us\/visualstudio\/ide\/feedback-options?view=vs-2019#:~:text=In%20Visual%20Studio%2C%20choose%20the%20feedback%20icon%20in,information%2C%20see%20Suggest%20a%20feature%20for%20Visual%20Studio.\">Visual Studio feedback options<\/a> for more information.<\/p>\n<p>We\u2019d love to learn how your team is adopting our support for LLDB. If you have feedback or a success story to share, you can contact us at <a href=\"mailto:vcpplinux-support@microsoft.com\">vcpplinux-support@microsoft.com<\/a>. You can also reach us on Twitter (<a href=\"https:\/\/twitter.com\/visualc\">@VisualC<\/a>).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>You can now use Attach to Process to remote debug processes with GDB or LLDB in Visual Studio. The ability to attach to a process running on a remote system with GDB was added in Visual Studio 2019. The ability to attach to a process with LLDB is new in Visual Studio 2022 Preview 3. [&hellip;]<\/p>\n","protected":false},"author":2953,"featured_media":28615,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[270,1,563,279],"tags":[],"class_list":["post-28613","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-announcement","category-cplusplus","category-clang","category-linux"],"acf":[],"blog_post_summary":"<p>You can now use Attach to Process to remote debug processes with GDB or LLDB in Visual Studio. The ability to attach to a process running on a remote system with GDB was added in Visual Studio 2019. The ability to attach to a process with LLDB is new in Visual Studio 2022 Preview 3. [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/28613","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/users\/2953"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/comments?post=28613"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/28613\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media\/28615"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media?parent=28613"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/categories?post=28613"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/tags?post=28613"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}