{"id":1775,"date":"2006-05-18T09:00:24","date_gmt":"2006-05-18T12:00:24","guid":{"rendered":"http:\/\/brockerhoff.net\/bb\/viewtopic.php?p=1664"},"modified":"2010-05-08T19:56:49","modified_gmt":"2010-05-08T22:56:49","slug":"re-progress-whew","status":"publish","type":"post","link":"https:\/\/brockerhoff.net\/blog\/2006\/05\/18\/re-progress-whew\/","title":{"rendered":"Re: Progress, whew!"},"content":{"rendered":"<p>OK, so here are the details on remote debugging; I&#8217;ve finished this phase of <a href=\"\/xray\">XRay<\/a> 2 development and will in the next few weeks be fully available for pressing on with it.<\/p>\n<p>The basic idea is that I have only PowerPC Macs, and since nobody I know in Brazil has received an Intel Mac (except for a couple of DTKs, which I didn&#8217;t want to use), the solution was to use <a href=\"http:\/\/developer.apple.com\/tools\/xcode\/\">Xcode<\/a>&#8216;s remote debugging capabilites, running my executable at a machine in the <a href=\"http:\/\/developer.apple.com\/labs\/index.html\">ADC Compatibility Labs<\/a>. These are open at no extra charge to paying developers, but most of what I&#8217;ll detail would apply to any other machine.<\/p>\n<p>Most of it is explained in the <a href=\"http:\/\/developer.apple.com\/documentation\/DeveloperTools\/Conceptual\/XcodeUserGuide\/Contents\/Resources\/en.lproj\/index.html\">Xcode User Guide<\/a>. Note that I used Xcode 2.2.1, but I think this facility has been available at least since 2.0. Click on the &#8220;Remote Debugging in Xcode&#8221; section in the left frame. First, however, send e-mail to adc.labs(at)mail.apple.com and ask for machine time, explaining for how long you need the machine; I asked for 3 days (thanks, Joe Holmes!). Basically, they&#8217;ll set up a newly formatted Mac with everything standard installed, including the latest developer tools. You should check that you have the same version, I suppose. They&#8217;ll have ssh and Apple Remote Desktop activated, and will send you the IP address, usercode and password. For illustration, let&#8217;s say the IP number is 10.1.1.1 (NOT an actual IP!), the usercode is &#8220;adclabs&#8221; and the password is &#8220;stevejobs&#8221;; substitute the actual values as appropriate.<\/p>\n<p>In other words, all you&#8217;ll do there will be inside the default home folder &#8220;adclabs&#8221;. This user is also an administrator, so you&#8217;ll be able to use the password whenever needed for that. If you have a second Mac handy, you could rehearse first with that, of course; it&#8217;s what I did, as I&#8217;m normally not that handy with the Terminal. (Thanks, by the way, to John C. Randolph, Mike Ash and several others for helping me with details.)<\/p>\n<p>First step is to generate a public and private key pair; you can skip this if you already have done so in the past. Open Terminal and type:<\/p>\n<pre><code>ls ~\/.ssh\/<\/code><\/pre>\n<p>If it lists a few files, among them one called &#8220;id_rsa.pub&#8221;, you already have a key pair. If not, type:<\/p>\n<pre><code>ssh-keygen -b 2048 -t dsa<\/code><\/pre>\n<p>This will take about a minute and then prompt you for a file path; type &lt;return&gt; to use the default path. It will then prompt you for a passphrase, twice. Don&#8217;t leave this empty and don&#8217;t use too short a phrase. You now should have the id_rsa.pub file in the ~\/.ssh directory.<\/p>\n<p>Second step is to open Terminal and type:<\/p>\n<pre><code>ssh <a href=\"mailto:adclabs@10.1.1.1\">adclabs@10.1.1.1<\/a><\/code><\/pre>\n<p>wait for the Password: prompt and type in &#8220;stevejobs&#8221;, or whatever password they sent you. You should see the normal Terminal prompt now, with a name like &#8220;CE-Lab-ADC-Compatibility-Labs-Intel-iMac&#8221; at the start of the line.<\/p>\n<p>Now you&#8217;d better change the password to the same passphrase you used for the RSA key &#8211; yes, usually it&#8217;s recommended to use different passwords here, but that way you won&#8217;t have to remember which one to use where; it&#8217;s just for a couple of days, anyway. Type<\/p>\n<pre><code>passwd<\/code><\/pre>\n<p>and you&#8217;ll be prompted for the original password, then twice for the new password. Create a .ssh directory with<\/p>\n<pre><code>mkdir ~\/.ssh<\/code><\/pre>\n<p>and log out by typing<\/p>\n<pre><code>exit<\/code><\/pre>\n<p>Next step is to transfer the public key to the remote Mac. To do this, at your local prompt, type<\/p>\n<pre><code>scp ~\/.ssh\/id_rsa.pub <a href=\"mailto:adclabs@10.1.1.1\">adclabs@10.1.1.1<\/a>:~\/.ssh\/authorized_keys<\/code><\/pre>\n<p>it will ask for your password again, and transfer the file over. Now log in again with:<\/p>\n<pre><code>ssh <a href=\"mailto:adclabs@10.1.1.1\">adclabs@10.1.1.1<\/a><\/code><\/pre>\n<p>and if all is well, it won&#8217;t ask for your passphrase or password again, but just log in. Now restrict permissions on your key by typing<\/p>\n<pre><code>chmod go-rwx ~\/.ssh\/authorized_keys<\/code><\/pre>\n<p>Now you need to set up a local build folder. The trick here is that both machines should see your build folder at the same absolute path. There are several ways to achieve that; on a local network, you could have one of the machines serve the entire folder to the other, then use symbolic links to map the same path. However, I found that over a long distance it&#8217;s most efficient to have mirrored folders at both machines, and copy the contents over with an extra build phase. Here&#8217;s what I did.<\/p>\n<p>At the remote machine, type<\/p>\n<pre><code>mkdir ~\/build<\/code><\/pre>\n<p>which will create an empty build folder in the Home folder. Log out and close Terminal.<\/p>\n<p>Now, on your local machine, you need to prep Xcode for what you&#8217;ll do. Double-click on your main project group and go to the &#8220;General&#8221; tab. Click &#8220;Place Build Products In: Custom location&#8221; and type in &#8220;\/Users\/adclabs\/build&#8221; as the location. (Supposing, of course, that you don&#8217;t have a user called &#8220;adclabs&#8221;&#8230;)<\/p>\n<p>Also check &#8220;Place Intermediate Build \u00cfiles In: Default intermediates location&#8221;, which probably will already be checked. Now click on your target and, from the Project menu, select &#8220;New Run Script Build Phase&#8221;. Make sure the new build phase is the last one, and enter this line as the script:<\/p>\n<pre><code>rsync -rz \/Users\/adclabs\/build <a href=\"mailto:adclabs@10.1.1.1\">adclabs@10.1.1.1<\/a>:\/Users\/adclabs<\/code><\/pre>\n<p>Finally, double-click on your executable in Xcode, and in the &#8220;Debugging&#8221; tab, select &#8220;Use Pipe for standard input\/output&#8221;, check &#8220;Debug executable remotely via SSH&#8221;, and in the &#8220;Connect to:&#8221; field, type<\/p>\n<pre><code>adclabs@10.1.1.1<\/code><\/pre>\n<p>Now you&#8217;re ready. You&#8217;ll notice a delay of a few minutes while the last build phase transfers the files over, and on the start of a debugging run there&#8217;ll be several errors logged to the debug console, but eventually you&#8217;ll be debugging and single-stepping as usual, albeit more slowly. For GUI debugging, of course, you&#8217;ll have to use Apple Remote Desktop; I wish Apple would include a 1-user license for this in the Select package, as it&#8217;s rather expensive&#8230;<\/p>\n<p>Have fun! I&#8217;ve tried to double-check most of this as I typed it in, please tell me if something didn&#8217;t work.<\/p>\n<p><strong>Update:<\/strong> fixed a typing error.<\/p>\n<p><a rel=\"tag\" href=\"http:\/\/www.technorati.com\/tag\/Mac\">Mac<\/a> <a rel=\"tag\" href=\"http:\/\/www.technorati.com\/tag\/Xcode\">Xcode<\/a> <a rel=\"tag\" href=\"http:\/\/www.technorati.com\/tag\/Debugging\">Debugging<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>OK, so here are the details on remote debugging; I&#8217;ve finished this phase of XRay 2 development and will in the next few weeks be fully available for pressing on with it. The basic idea is that I have only PowerPC Macs, and since nobody I know in Brazil has received an Intel Mac (except [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4,19],"tags":[23,22,29],"class_list":["post-1775","post","type-post","status-publish","format-standard","hentry","category-dev","category-software","tag-mac","tag-xcode","tag-xray"],"featured_image_src":null,"author_info":{"display_name":"Rainer Brockerhoff","author_link":"https:\/\/brockerhoff.net\/blog\/author\/rbrockerhoff\/"},"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p1q3Zc-sD","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/brockerhoff.net\/blog\/wp-json\/wp\/v2\/posts\/1775","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/brockerhoff.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/brockerhoff.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/brockerhoff.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/brockerhoff.net\/blog\/wp-json\/wp\/v2\/comments?post=1775"}],"version-history":[{"count":0,"href":"https:\/\/brockerhoff.net\/blog\/wp-json\/wp\/v2\/posts\/1775\/revisions"}],"wp:attachment":[{"href":"https:\/\/brockerhoff.net\/blog\/wp-json\/wp\/v2\/media?parent=1775"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/brockerhoff.net\/blog\/wp-json\/wp\/v2\/categories?post=1775"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/brockerhoff.net\/blog\/wp-json\/wp\/v2\/tags?post=1775"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}