Firefox OS supports the same remote debugging protocol that Firefox mobile supports on Android. This means you can use the Firefox development tools to debug Gaia applications running on a Firefox OS device or emulator. This article is a guide to how to set up and use the remote debugging tools.
In order to debug Firefox OS into your device or B2G Desktop, you need to use a Firefox Nightly and change a few settings on both Firefox Nightly and Firefox OS.
Get a fresh copy of Firefox Nightly if you don't have one at nightly.mozilla.org, uncompresse it, run the firefox nightly (just remeber to close all others firefox that you might have).
Type about:config and turn devtools.debugger.remote-enabled to true . Then just restart your Firefox Nightly and you will see a Remote Debugger menu item under Web Developer menu.
This option works on recent gaia builds. Go to Settings -> Device Information -> More Information -> Developer and turn on Remote Debugging.
For device debugging, you will need to be with the device pluged in on your usb port, make sure lsusb and adb can see it. And you need to foward the port in adb by doing adb forward tcp:6000 tcp:6000 on terminal.
Now we just need to acess in Firefox Nightly the menu Tools -> Web Developer -> Remote Debugger. It will ask you to put the <IP>:<PORT> where you want to debug, just leave as it is 'localhost:6000'. Press OK and its all done, wait a few seconds, you can start debugging.
Have a nice Debug!!