In this post I’m going to explain how to debug Gaia for Firefox OS.

I will explain how to run Gaia emulator inside the Firefox browser and also how to do a remote debugging on an actual device (The ZTE Open to be specific but it should be the same on every device).



as my previous post you can find most of the information on MDN – Hacking Gaia. But I’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’m going to talk on how to do the same for Gecko and thats where things might be a bit more complicated.

So you’ll we’ll need to start with having the Gaia source. if you followed my previous post about building Firefox OS 1.3 for the ZTE Open you already have all you need just go to your b2g/gaia folder.

if not use git to get Gaia source

$ git clone https://github.com/mozilla-b2g/gaia.git 1 $ git clone https : // github .com / mozilla - b2g / gaia .git

go to Gaia folder and run make with DEBUG enabled

$ DEBUG=1 make 1 $ DEBUG = 1 make

as you can see from the make output the build process creates a profile for you you can use with Firefox nightly to start the emulator.

so if you don’t have it download and install it now.

Debugging On Firefox Nightly

Once you have Firefox nightly just run it with the command you got from the make it should be something like –

$ [NIGHTLY FOLDER]/firefox -profile [GAIA FOLDER]/profile-debug 1 $ [ NIGHTLY FOLDER ] / firefox - profile [ GAIA FOLDER ] / profile - debug

Thats it you should now have Firefox running Gaia.

is thats it ?

We’ll no

There are a few issues with the emulator you’ll need to notice –

first it some times get confused and you’ll need to close and restart Firefox to debug properly.

second if you want to debug an app (which you’ll probably want) because of threading issues with the debugger. so You’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’ll need to open a new tab with the

http://system.gaiamobile.org:8080/ URL

Debugging On Firefox Device

so the build process is the same (make sure you use the DEBUG flag!)

But now we need to make sure our device is connected and while in our Gaia folder run

$ make install-gaia 1 $ make install - gaia

this command will flash our device with the build we just did, and restart the device.

once the device is back on we need to tell adb to forward our remote debugger to the actual device ->

$ adb forward tcp:6000 localfilesystem:/data/local/debugger-socket 1 $ adb forward tcp : 6000 localfilesystem : / data / local / debugger - socket

(we’ll need to repeat this step each time we connect the device)

now we can run Firefox nightly.

in the web inspector settings make sure you have “Enable Remote Debugging” option checked, and go to Tools > Web Developer > Connect…

and click the connect button (if you followed the instructions every thing should work with the default host and port).

Now on your device you’ll be asked to approve the connection.

Once you do so You’ll see available tabs to and processes to debug.

select the “Main Process” and your good to go.

( For debugging apps you’ll only need the Main process, but if you’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).

the only issue I had with debugging on the device was that I couldn’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’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 🙂 when building.