{"id":1490,"date":"2016-07-14T16:36:19","date_gmt":"2016-07-14T20:36:19","guid":{"rendered":"http:\/\/codinggorilla.domemtech.com\/?p=1490"},"modified":"2016-07-21T07:06:57","modified_gmt":"2016-07-21T11:06:57","slug":"cross-debugging-c-executables","status":"publish","type":"post","link":"http:\/\/165.227.223.229\/index.php\/2016\/07\/14\/cross-debugging-c-executables\/","title":{"rendered":"Cross-Debugging Mono C# Executables Running on Linux"},"content":{"rendered":"<p>Debugging C# programs\u00c2\u00a0that run on a Linux server can be a challenge.\u00c2\u00a0On Ubuntu, a server may not\u00c2\u00a0have the Unity GUI installed, so you can&#8217;t use <a href=\"http:\/\/www.monodevelop.com\/\" target=\"_blank\">MonoDevelop<\/a>. Even if the server had the GUI, <a href=\"http:\/\/www.monodevelop.com\/\" target=\"_blank\">MonoDevelop<\/a>\u00c2\u00a0often does not work with a C# project because it doesn&#8217;t support many <a href=\"https:\/\/www.visualstudio.com\/\" target=\"_blank\">Visual Studio<\/a> 2015 projects.\u00c2\u00a0<a href=\"https:\/\/www.visualstudio.com\/\" target=\"_blank\">Visual Studio<\/a> supposedly can cross-debug a program running on Linux from a Windows box, but I haven&#8217;t been able to get <a href=\"https:\/\/github.com\/techl\/MonoRemoteDebugger\" target=\"_blank\">one solution<\/a> to work. (<a href=\"https:\/\/blogs.msdn.microsoft.com\/vcblog\/2015\/11\/18\/announcing-the-vs-gdb-debugger-extension\/\" target=\"_blank\">It does work for C++.<\/a>)\u00c2\u00a0<a href=\"https:\/\/www.xamarin.com\/studio\" target=\"_blank\">Xamarin Studio<\/a> works, but the steps are somewhat convoluted, and won&#8217;t\u00c2\u00a0work if you naively follow what has been\u00c2\u00a0outlined by others for a Windows box (e.g., in (a), you cannot simply build the app on Linux using xbuild, because the paths for files between server and debugger host differ). Here, I note how one can get Xamarin Studio working on Windows.<\/p>\n<ol>\n<li>Download a copy of Xamarin Studio for Windows, and install it. Xamarin Studio for Windows is, in fact, no longer officially available, but you can still find the download <a href=\"http:\/\/www.monodevelop.com\/download\/\" target=\"_blank\">here<\/a> as of July 2016. I don&#8217;t know how long this link will last; you can&#8217;t download Xamarin Studio for Windows though <a href=\"https:\/\/www.xamarin.com\/\" target=\"_blank\">Xamarin.com<\/a>.<\/li>\n<li>In your Linux server, make sure to have it set up with a firewall, SSH, and Mono.<\/li>\n<li>Create a variable in your environment to enable Xamarin Studio &#8220;Custom Soft Debugging.&#8221; <a href=\"https:\/\/technet.microsoft.com\/en-us\/library\/cc772047(v=ws.11).aspx\" target=\"_blank\">Create<\/a> &#8220;MONODEVELOP_SDB_TEST&#8221; with the value &#8220;1&#8221; (no quotes) through the <a href=\"http:\/\/www.tenuser.com\/spec\/properties.htm#run\" target=\"_blank\">System Properties box<\/a>.<\/li>\n<li>Start Xamarin Studio, and open or create a C# test program, like &#8220;Hello World.&#8221; Set the configuration to Debug and build the program.<\/li>\n<li>Mono does not understand PDB files, so you have to create the equivalent MDB files. Start a command-line Bash shell in the directory &#8216;bin\/Debug\/&#8221;. Type:\u00c2\u00a0for i in *.exe *.dll;do echo $i; pdb2mdb $i; done. If pdb2mdb is not found, make sure Mono\/bin is on the search path.<\/li>\n<li>Open a command-line Bash shell on your Linux box using &#8220;ssh&#8221;, e.g., &#8220;ssh root@192.168.1.10&#8221;.<\/li>\n<li>In the Windows Bash shell, type:\u00c2\u00a0tar -cvf &#8211; Debug | ssh root@192.168.1.10 &#8216;cat &#8211; &gt; Debug.tar&#8217;.<\/li>\n<li>In the Linux Bash shell, type: tar -xvf Debug.tar; cd Debug;\u00c2\u00a0mono &#8211;debug &#8211;debugger-agent=transport=dt_socket,address=0.0.0.0:12345,server=y <em>HelloWorld.exe<\/em>, replacing HelloWorld.exe with the name of the executable you want to debug.<\/li>\n<li>In Xamarin Studio, open <em>Run -&gt; Run with -&gt; Custom Command Mono Soft Debugger<\/em>.\u00c2\u00a0<img loading=\"lazy\" class=\"aligncenter size-large wp-image-1492\" src=\"http:\/\/codinggorilla.domemtech.com\/wordpress\/wp-content\/uploads\/2016\/07\/2016-07-14-1-1024x550.png\" alt=\"2016-07-14 (1)\" width=\"720\" height=\"387\" \/><\/li>\n<li>In the pop up, enter the IP address of the Linux box, then click on &#8220;Connect&#8221;. <img loading=\"lazy\" class=\"aligncenter size-full wp-image-1493\" src=\"http:\/\/codinggorilla.domemtech.com\/wordpress\/wp-content\/uploads\/2016\/07\/2016-07-14-9.png\" alt=\"2016-07-14 (9)\" width=\"580\" height=\"232\" \/><\/li>\n<li>You should now be able to debug your program. Note: you don&#8217;t need to compile the program on Linux. Note: if you can&#8217;t set breakpoints, it&#8217;s because you haven&#8217;t copied the .mdb files from Windows to Linux. Path names in the .mdb files are full paths, and Linux path names do not work.<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<h4>Further Information<\/h4>\n<ol style=\"list-style-type: lower-alpha;\">\n<li><a href=\"http:\/\/www.mono-project.com\/docs\/advanced\/runtime\/docs\/soft-debugger\/\" target=\"_blank\">https:\/\/eladnava.com\/debug-remote-mono-apps-via-xamarin-studio\/<\/a><\/li>\n<li><a href=\"http:\/\/www.mono-project.com\/docs\/advanced\/runtime\/docs\/soft-debugger\/\" target=\"_blank\">http:\/\/www.mono-project.com\/docs\/advanced\/runtime\/docs\/soft-debugger\/<\/a><\/li>\n<li><a href=\"http:\/\/www.jeffongames.com\/2012\/03\/debugging-embedded-mono\/\" target=\"_blank\">http:\/\/www.jeffongames.com\/2012\/03\/debugging-embedded-mono\/<\/a><\/li>\n<li><a href=\"http:\/\/tirania.org\/blog\/archive\/2008\/Sep-04.html\" target=\"_blank\">http:\/\/tirania.org\/blog\/archive\/2008\/Sep-04.html<\/a><\/li>\n<li><a href=\"https:\/\/blogs.msdn.microsoft.com\/vcblog\/2015\/11\/18\/announcing-the-vs-gdb-debugger-extension\/\" target=\"_blank\">https:\/\/blogs.msdn.microsoft.com\/vcblog\/2015\/11\/18\/announcing-the-vs-gdb-debugger-extension\/<\/a><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Debugging C# programs\u00c2\u00a0that run on a Linux server can be a challenge.\u00c2\u00a0On Ubuntu, a server may not\u00c2\u00a0have the Unity GUI installed, so you can&#8217;t use MonoDevelop. Even if the server had the GUI, MonoDevelop\u00c2\u00a0often does not work with a C# project because it doesn&#8217;t support many Visual Studio 2015 projects.\u00c2\u00a0Visual Studio supposedly can cross-debug a &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/165.227.223.229\/index.php\/2016\/07\/14\/cross-debugging-c-executables\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Cross-Debugging Mono C# Executables Running on Linux&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/165.227.223.229\/index.php\/wp-json\/wp\/v2\/posts\/1490"}],"collection":[{"href":"http:\/\/165.227.223.229\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/165.227.223.229\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/165.227.223.229\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/165.227.223.229\/index.php\/wp-json\/wp\/v2\/comments?post=1490"}],"version-history":[{"count":0,"href":"http:\/\/165.227.223.229\/index.php\/wp-json\/wp\/v2\/posts\/1490\/revisions"}],"wp:attachment":[{"href":"http:\/\/165.227.223.229\/index.php\/wp-json\/wp\/v2\/media?parent=1490"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/165.227.223.229\/index.php\/wp-json\/wp\/v2\/categories?post=1490"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/165.227.223.229\/index.php\/wp-json\/wp\/v2\/tags?post=1490"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}