{"id":949,"date":"2014-03-10T10:27:31","date_gmt":"2014-03-10T14:27:31","guid":{"rendered":"http:\/\/benjamin.smedbergs.us\/blog\/?p=949"},"modified":"2019-12-19T11:03:39","modified_gmt":"2019-12-19T15:03:39","slug":"use-debugexe-to-debug-apps-in-visual-studio","status":"publish","type":"post","link":"https:\/\/benjamin.smedbergs.us\/blog\/2014-03-10\/use-debugexe-to-debug-apps-in-visual-studio\/","title":{"rendered":"Use -debugexe to debug apps in Visual Studio"},"content":{"rendered":"<p>Many people don&#8217;t know about how awesome the windows debuggers are. I recently got a question from a volunteer mentee: he was experiencing a startup crash in Firefox and he wanted to know how to get the debugger attached to Firefox before the crash.<\/p>\n<p>On other systems, I&#8217;d say to use <tt>mach debug<\/tt>, but that currently doesn&#8217;t do useful things on Windows. But it&#8217;s still pretty simple. You have two options:<\/p>\n<h3>Debug Using Your IDE<\/h3>\n<p>Both Visual Studio and Visual C++ Express have a command-line option for launching the IDE ready for debugging.<\/p>\n<pre>devenv.exe -debugexe <em style=\"color: green\">obj-ff-debug<\/em>\/dist\/bin\/firefox.exe -profile <em style=\"color: green\">\/c\/builds\/test-profile<\/em> -no-remote<\/pre>\n<p>The <tt>-debugexe<\/tt> flag informs the IDE to load your Firefox build with the command lines you specify. Firefox will launch with the &#8220;Go&#8221; command (F5).<\/p>\n<p>For Visual C++ express edition, run <tt>WDExpress.exe<\/tt> instead of <tt>devenv.exe<\/tt>.<\/p>\n<h3>Debug Using Windbg<\/h3>\n<p>windbg is a the Windows command-line debugger. As with any command-line debugger it has an arcane debugging syntax, but it is very powerful.<\/p>\n<p>Launching Firefox with windbg doesn&#8217;t require any flags at all:<\/p>\n<pre>windbg.exe <em style=\"color: green\">obj-ff-debug<\/em>\/dist\/bin\/firefox.exe -profile <em style=\"color: green\">\/c\/builds\/test-profile<\/em> -no-remote<\/pre>\n<h3>Debugging Firefox Release Builds<\/h3>\n<p>You can also debug Firefox release builds on Windows! Mozilla runs a symbol server that allows you to automatically download the debugging symbols for recent prerelease builds (I think we keep 30 days of nightly\/aurora symbols) and all release builds. See <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Using_the_Mozilla_symbol_server\">the Mozilla Developer Network article<\/a> for detailed instructions.<\/p>\n<p>Debugging official builds can be a bit confusing due to inlining, reordering, and other compiler optimizations. I often find myself looking at the disassembly view of a function rather than the source view in order to understand what exactly is going on. Also note that if you are planning on debugging a release build, you probably want to disable automatic crash reporting by setting MOZ_CRASHREPORTER_DISABLE=1 in your environment.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Many people don&#8217;t know about how awesome the windows debuggers are. I recently got a question from a volunteer mentee: he was experiencing a startup crash in Firefox and he wanted to know how to get the debugger attached to Firefox before the crash. On other systems, I&#8217;d say to use mach debug, but that [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[290,69,291],"class_list":["post-949","post","type-post","status-publish","format-standard","hentry","category-mozilla","tag-debugging","tag-visual-studio","tag-windbg"],"_links":{"self":[{"href":"https:\/\/benjamin.smedbergs.us\/blog\/wp-json\/wp\/v2\/posts\/949","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/benjamin.smedbergs.us\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/benjamin.smedbergs.us\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/benjamin.smedbergs.us\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/benjamin.smedbergs.us\/blog\/wp-json\/wp\/v2\/comments?post=949"}],"version-history":[{"count":3,"href":"https:\/\/benjamin.smedbergs.us\/blog\/wp-json\/wp\/v2\/posts\/949\/revisions"}],"predecessor-version":[{"id":952,"href":"https:\/\/benjamin.smedbergs.us\/blog\/wp-json\/wp\/v2\/posts\/949\/revisions\/952"}],"wp:attachment":[{"href":"https:\/\/benjamin.smedbergs.us\/blog\/wp-json\/wp\/v2\/media?parent=949"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/benjamin.smedbergs.us\/blog\/wp-json\/wp\/v2\/categories?post=949"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/benjamin.smedbergs.us\/blog\/wp-json\/wp\/v2\/tags?post=949"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}