{"id":185,"date":"2013-11-10T17:03:28","date_gmt":"2013-11-10T17:03:28","guid":{"rendered":"https:\/\/blog.non.co.il\/?p=185"},"modified":"2016-05-22T02:14:23","modified_gmt":"2016-05-22T02:14:23","slug":"hacking-and-debugging-firefoxos-part-1-gaia","status":"publish","type":"post","link":"https:\/\/ca.non.co.il\/index.php\/hacking-and-debugging-firefoxos-part-1-gaia\/","title":{"rendered":"Hacking and Debugging FirefoxOS Part 1 &#8211; Gaia"},"content":{"rendered":"<p>In this post I&#8217;m going to explain how to debug Gaia for Firefox OS.<br \/>\nI will explain how to run Gaia  emulator inside the<a title=\"Debugging On Desktop\" href=\"#nightly\"> Firefox browser<\/a> and also how to do a remote debugging on an actual <a title=\"Debugging On FFOS Device\" href=\"#device\">device<\/a> (The ZTE Open to be specific but it should be the same on every device).<br \/>\n<!--more--><br \/>\nas my previous post you can find most of the information on <a title=\"Hacking gaia\" href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Mozilla\/Firefox_OS\/Platform\/Gaia\/Hacking\">MDN &#8211; Hacking Gaia<\/a>. But I&#8217;ll try to add more info about issues I had. also keep in mind that setting up the environment for debugging Gaia is not too complicated, on my next post I&#8217;m going to talk on how to do the same for Gecko and thats where things might be a bit more complicated.<\/p>\n<p>So you&#8217;ll we&#8217;ll need to start with having the Gaia source. if you followed my previous post about <a title=\"ZTE open phone \u2013 upgrading to firefoxOS 1.1 \/ 1.3 how to\" href=\"https:\/\/blog.non.co.il\/index.php\/zte-open-phone-upgrading-to-firefoxos-1-1-how-to\/\">building Firefox OS 1.3 for the ZTE Open<\/a> you already have all you need just go to your b2g\/gaia folder.<br \/>\nif not use git to get Gaia source<\/p>\n<pre class=\"lang:sh decode:true\">$ git clone https:\/\/github.com\/mozilla-b2g\/gaia.git<\/pre>\n<p>go to Gaia folder and run make with DEBUG enabled<\/p>\n<pre class=\"lang:sh decode:true\">$ DEBUG=1 make<\/pre>\n<p>as you can see from the make output the build process creates a profile for you you can use with <a title=\"Firefox nightly Download\" href=\"http:\/\/nightly.mozilla.org\/\">Firefox nightly<\/a> to start the emulator.<br \/>\nso if you don&#8217;t have it download and install it now.<\/p>\n<h2 id=\"nightly\">Debugging On Firefox Nightly<\/h2>\n<p>Once you have Firefox nightly just run it with the command you got from the make it should be something like &#8211;<\/p>\n<pre class=\"lang:sh decode:true\">$ [NIGHTLY FOLDER]\/firefox  -profile [GAIA FOLDER]\/profile-debug<\/pre>\n<p>Thats it you should now have Firefox running Gaia.<br \/>\nis thats it ?<br \/>\nWe&#8217;ll no<br \/>\nThere are a few issues with the emulator you&#8217;ll need to notice &#8211;<br \/>\nfirst it some times get confused and you&#8217;ll need to close and restart Firefox to debug properly.<br \/>\nsecond if you want to debug an app (which you&#8217;ll probably want) because of threading issues with the debugger. so You&#8217;ll need to open a new tab with the specific app your trying to debug. so if you want to debug the SMS app you&#8217;ll need to open a new tab with the<br \/>\n<a title=\"sms app in gaia emulator\" href=\"http:\/\/system.gaiamobile.org:8080\/\">http:\/\/system.gaiamobile.org:8080\/<\/a> URL<\/p>\n<h2 id=\"device\">Debugging On Firefox Device<\/h2>\n<p>so the build process is the same (<strong>make sure you use the DEBUG flag!<\/strong>)<br \/>\nBut now we need to make sure our device is connected and while in our Gaia folder run<\/p>\n<pre class=\"lang:sh decode:true\">$ make install-gaia<\/pre>\n<p>this command will flash our device with the build we just did, and restart the device.<br \/>\nonce the device is back on we need to tell adb to forward our remote debugger to the actual device -&gt;<\/p>\n<pre class=\"lang:sh decode:true\">$ adb forward tcp:6000 localfilesystem:\/data\/local\/debugger-socket<\/pre>\n<p>(we&#8217;ll need to repeat this step each time we connect the device)<br \/>\nnow we can run Firefox nightly.<br \/>\nin the web inspector settings make sure you have &#8220;Enable Remote Debugging&#8221; option checked, and go to Tools &gt; Web Developer &gt; Connect&#8230;<br \/>\nand click the connect button (if you followed the instructions every thing should work with the default host and port).<br \/>\nNow on your device you&#8217;ll be asked to approve the connection.<br \/>\nOnce you do so You&#8217;ll see available tabs to and processes to debug.<br \/>\nselect the &#8220;Main  Process&#8221; and your good to go.<br \/>\n( For debugging apps you&#8217;ll only need the Main process, but if you&#8217;r debugging a web site you should be able to see its tab in the connection panel once you open it in the device browser).<\/p>\n<p>the only issue I had with debugging on the device was that I couldn&#8217;t log and debug properly the apps (in the debugger I could only see the system app code and it was like the app code wasn&#8217;t even being included). it took me too long to understand that I was building Gaia without The Debug Flag so make sure you use it \ud83d\ude42 when building.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to Debug Gaia for Firefox OS in emulator and on actual Device (like the ZTE Open)<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-185","post","type-post","status-publish","format-standard","hentry","category-bitcoin","last-post"],"_links":{"self":[{"href":"https:\/\/ca.non.co.il\/index.php\/wp-json\/wp\/v2\/posts\/185","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ca.non.co.il\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ca.non.co.il\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ca.non.co.il\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ca.non.co.il\/index.php\/wp-json\/wp\/v2\/comments?post=185"}],"version-history":[{"count":7,"href":"https:\/\/ca.non.co.il\/index.php\/wp-json\/wp\/v2\/posts\/185\/revisions"}],"predecessor-version":[{"id":384,"href":"https:\/\/ca.non.co.il\/index.php\/wp-json\/wp\/v2\/posts\/185\/revisions\/384"}],"wp:attachment":[{"href":"https:\/\/ca.non.co.il\/index.php\/wp-json\/wp\/v2\/media?parent=185"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ca.non.co.il\/index.php\/wp-json\/wp\/v2\/categories?post=185"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ca.non.co.il\/index.php\/wp-json\/wp\/v2\/tags?post=185"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}