{"id":1777,"date":"2016-07-11T22:01:40","date_gmt":"2016-07-12T05:01:40","guid":{"rendered":"http:\/\/visualgdb.com\/w\/?p=1777"},"modified":"2016-07-11T22:01:40","modified_gmt":"2016-07-12T05:01:40","slug":"debugging-programs-with-lldb-under-visual-studio","status":"publish","type":"post","link":"https:\/\/visualgdb.com\/tutorials\/lldb\/","title":{"rendered":"Debugging programs with LLDB under Visual Studio"},"content":{"rendered":"<p>This tutorial shows how to configure VisualGDB to use the LLDB debugger instead of gdb to debug your programs.<br \/>\nBefore you begin, install VisualGDB 5.1 or later.<\/p>\n<ol>\n<li>Start Visual Studio and open the VisualGDB MinGW\/Cygwin Project Wizard:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/03\/01-prjname3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1778\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/03\/01-prjname3.png\" alt=\"01-prjname\" width=\"788\" height=\"535\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/03\/01-prjname3.png 788w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/03\/01-prjname3-300x204.png 300w\" sizes=\"(max-width: 788px) 100vw, 788px\" \/><\/a><\/li>\n<li>Proceed with the default settings on the first page (Create new project -&gt; Application):<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/03\/02-app.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1779\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/03\/02-app.png\" alt=\"02-app\" width=\"676\" height=\"610\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/03\/02-app.png 676w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/03\/02-app-300x271.png 300w\" sizes=\"(max-width: 676px) 100vw, 676px\" \/><\/a><\/li>\n<li>On the next page select the toolchain you want to use. VisualGDB comes with a pre-built lldb debugger, so the steps described here will work on any local toolchain, as long as lldb can debug the program it produces:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/03\/03-mingw.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1780\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/03\/03-mingw.png\" alt=\"03-mingw\" width=\"676\" height=\"610\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/03\/03-mingw.png 676w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/03\/03-mingw-300x271.png 300w\" sizes=\"(max-width: 676px) 100vw, 676px\" \/><\/a><\/li>\n<li>Press &#8220;Finish&#8221; to generate your project. Build it with Ctrl-Shift-B:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/03\/04-build1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1785\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/03\/04-build1.png\" alt=\"04-build\" width=\"1002\" height=\"794\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/03\/04-build1.png 1002w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/03\/04-build1-300x238.png 300w\" sizes=\"(max-width: 1002px) 100vw, 1002px\" \/><\/a><\/li>\n<li>If you start debugging by pressing F5 now, VisualGDB will launch the default GDB binary that comes with the toolchain. To use lldb instead, open VisualGDB Project Properties, go to the Debug Settings page and select &#8220;Use LLDB shipped with VisualGDB&#8221;:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/03\/05-uselldb.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1782\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/03\/05-uselldb.png\" alt=\"05-uselldb\" width=\"815\" height=\"594\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/03\/05-uselldb.png 815w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/03\/05-uselldb-300x219.png 300w\" sizes=\"(max-width: 815px) 100vw, 815px\" \/><\/a><\/li>\n<li>Then set a breakpoint in the main source file and press F5 to start debugging. VisualGDB will launch the debugging session:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/03\/06-debug2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1783\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/03\/06-debug2.png\" alt=\"06-debug\" width=\"1002\" height=\"678\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/03\/06-debug2.png 1002w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/03\/06-debug2-300x203.png 300w\" sizes=\"(max-width: 1002px) 100vw, 1002px\" \/><\/a>Note that LLDB won&#8217;t accept many of the gdb-specific commands and VisualGDB will automatically try known workarounds. The error messages in the LLDB Session window will indicate commands, but it should not interfere with most of the debugging functions.<\/li>\n<li>You can run LLDB-specific commands in the LLDB Session window directly. E.g. you can run &#8220;thread backtrace all&#8221; to view the backtrace of all the threads:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/03\/07-lldbout.png\"> <img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1784\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/03\/07-lldbout.png\" alt=\"07-lldbout\" width=\"1002\" height=\"794\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/03\/07-lldbout.png 1002w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/03\/07-lldbout-300x238.png 300w\" sizes=\"(max-width: 1002px) 100vw, 1002px\" \/><\/a><\/li>\n<\/ol>\n<p>Note that if you are using a cross-toolchain to deploy your program to a remote machine and debug it with gdbserver, LLDB may have compatibility issues with it. In that case we recommend installing lldb on that Linux machine directly and configuring VisualGDB to debug with it. As long as the binary name is called <strong>lldb-mi<\/strong>, VisualGDB will automatically adjust the command-line arguments so that LLDB can start correctly.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial shows how to configure VisualGDB to use the LLDB debugger instead of gdb to debug your programs. Before<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[29],"tags":[124,40,36],"_links":{"self":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/1777"}],"collection":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/comments?post=1777"}],"version-history":[{"count":2,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/1777\/revisions"}],"predecessor-version":[{"id":1787,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/1777\/revisions\/1787"}],"wp:attachment":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/media?parent=1777"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/categories?post=1777"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/tags?post=1777"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}