{"id":83,"date":"2014-02-04T17:39:32","date_gmt":"2014-02-04T17:39:32","guid":{"rendered":"http:\/\/visualgdb.com\/w\/?p=83"},"modified":"2014-02-04T17:39:32","modified_gmt":"2014-02-04T17:39:32","slug":"android-bp-diag","status":"publish","type":"post","link":"https:\/\/visualgdb.com\/tutorials\/android\/bp-diag\/","title":{"rendered":"Diagnosing breakpoint problems on Android"},"content":{"rendered":"\n<p>This tutorial shows how to solve breakpoint problems by using VisualGDB&#8217;s breakpoint diagnostics tool. Note that breakpoint diagnostics will work for all VisualGDB project types, not only Android projects.<\/p>\n<p>Before you begin, please install <a href=\"\/download\"> VisualGDB 2.8<\/a> or later (ensure that &#8220;Android Edition&#8221; is checked in the installer).<\/p>\n<ol>\n<li>First follow the <a href=\"\/tutorials\/android\">Android Quickstart tutorial<\/a> to make a basic project. Make sure the project builds and runs, and that it stops at a breakpoint as described in the tutorial.<\/li>\n<li>In order to introduce a breakpoint problem, we use the <strong>subst<\/strong> command. Hence, close Visual Studio, open cmd.exe and enter there the substitute command to map the solution directory as follows\n<pre>subst P: C:\\Projects<\/pre>\n<p><a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/bp-diag\/01-Subst.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/bp-diag\/01-Subst.png\" alt=\"01-Subst\" width=\"613\" height=\"191\" \/><\/a><\/li>\n<li>Go to the newly created drive P: and open the Visual Studio solution from there.<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/bp-diag\/02-mappeddrive.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/bp-diag\/02-mappeddrive.png\" alt=\"02-mappeddrive\" width=\"645\" height=\"458\" \/><\/a><\/li>\n<li> Start debugging. <strong>Do not rebuild the project, otherwise the paths will be fixed.<\/strong><a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/bp-diag\/03-startdebugging.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/bp-diag\/03-startdebugging.png\" alt=\"03-startdebugging\" width=\"700\" height=\"455\" \/><\/a><\/li>\n<li>Note that the breakpoint is now marked with a warning that the breakpoint location is unknown. This happens because you have built the project from <strong>c:\\projects<\/strong> and GDB does not know that <strong>p:\\AndroidApp1\\jni\\AndroidApp1.c<\/strong> (where you set the breakpoint) and <strong> c:\\projects\\AndroidApp1\\jni\\AndroidApp1.c<\/strong> (that is referred to in the symbols) is the same file.<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/bp-diag\/04-pendingbreakpoint.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/bp-diag\/04-pendingbreakpoint.png\" alt=\"04-pendingbreakpoint\" width=\"700\" height=\"455\" \/><\/a><\/li>\n<li>Open the breakpoint diagnostics window from the GDB Session tool window.<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/bp-diag\/05-diagnosebreakpoints.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/bp-diag\/05-diagnosebreakpoints.png\" alt=\"05-diagnosebreakpoints\" width=\"700\" height=\"455\" \/><\/a><\/li>\n<li>Select the source file with the problem. Note that the file is located in <strong>P:\\<\/strong> as you have opened the solution there.<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/bp-diag\/06-wrongmapping.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/bp-diag\/06-wrongmapping.png\" alt=\"06-wrongmapping\" width=\"600\" height=\"384\" \/><\/a><\/li>\n<li>Click at the &#8216;corrected file path&#8217; combo box. VisualGDB will automatically suggest to use the file from <strong> c:\\projects<\/strong> instead. Select it.<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/bp-diag\/07-choosepath.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/bp-diag\/07-choosepath.png\" alt=\"07-choosepath\" width=\"600\" height=\"384\" \/><\/a><\/li>\n<li>Once the correct substitution is selected, VisualGDB can create a path mapping rule to automatically translate all other file names in this directory. Please select the appropriate rule from the suggestion list.<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/bp-diag\/08-newrule.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-8\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/bp-diag\/08-newrule.png\" alt=\"08-newrule\" width=\"600\" height=\"165\" \/><\/a><a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/bp-diag\/10-addsubstrule.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-9\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/bp-diag\/10-addsubstrule.png\" alt=\"10-addsubstrule\" width=\"600\" height=\"165\" \/><\/a><\/li>\n<li>Note that the breakpoint is now marked as fixed in both the diagnostics tool and Visual Studio.<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/bp-diag\/11-bpfixed.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-10\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/bp-diag\/11-bpfixed.png\" alt=\"11-bpfixed\" width=\"700\" height=\"455\" \/><\/a><\/li>\n<li>Close the diagnostics window and try to trigger the breakpoint. Hence click on the large button on the Android device screen. The breakpoint will now be triggered successfully.<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/bp-diag\/12-bpworks.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-11\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/bp-diag\/12-bpworks.png\" alt=\"12-bpworks\" width=\"698\" height=\"453\" \/><\/a><\/li>\n<li>You can always see the active path mappings by clicking at the corresponding icon in the VisualGDB session window. Note that the mappings are saved in the project settings and will be reestablished next time you start debugging.<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/bp-diag\/13-pathmapping.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-12\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/bp-diag\/13-pathmapping.png\" alt=\"13-pathmapping\" width=\"670\" height=\"405\" \/><\/a><\/li>\n<\/ol>\n<p><\/root><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial shows how to solve breakpoint problems by using VisualGDB&#8217;s breakpoint diagnostics tool. Note that breakpoint diagnostics will work<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[31],"_links":{"self":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/83"}],"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=83"}],"version-history":[{"count":0,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/83\/revisions"}],"wp:attachment":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/media?parent=83"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/categories?post=83"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/tags?post=83"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}