Skip to content
Back to home
Back to blog
Tutorial

Debugging JavaScript on Android: Breakpoints, Stepping and the Call Stack

Debug Node.js code on your Android phone: breakpoints, conditions and logpoints, stepping, variables, the call stack and Hot Reload — and what it does not do yet.

Updated:
3 min
By Pelayo Naredo
Debugging JavaScript on Android: Breakpoints, Stepping and the Call Stack

Debugging JavaScript on Android: Breakpoints, Stepping and the Call Stack

PocketCode includes a debugger that works directly on your Android device, right next to the code you're running. This post says exactly what it does today — and what it doesn't.

Real debugging for Node.js

Open a JavaScript file and choose Debug (Shift + F5). PocketCode starts Node.js with its inspector and connects to it through the Chrome DevTools Protocol — the same one Chrome and VS Code use — so everything below runs against a real Node process on your phone:

  • Pause — the program stops on its first line, at your breakpoints, and when an exception is thrown that nothing catches
  • Continue, Step Over / Into / Out — move through the code one line, one call or one return at a time
  • Pause, Restart, Stop — control the session directly; Restart launches the file again under the debugger
  • Variables — local and global values in the current scope, expandable for nested objects
  • Call stack — the chain of frames that led to the current point, with the active frame highlighted
  • Console — session events alongside your program's own output

Breakpoints, conditions and logpoints

Tap a line number to set a breakpoint: a red dot appears in the gutter, and tapping again removes it. When the program stops there, that line is highlighted. The Breakpoints tab of the debug panel lists them all; you can switch each one off (hollow dot) or edit it with the pencil:

  • Condition — a JavaScript expression such as i > 10; the program only pauses when it is true
  • Log message — turns the breakpoint into a logpoint: instead of pausing, it writes a line to the console. Put expressions in braces to print values: user = {user.name}, total = {total}. With a condition too, it logs only when the condition holds

Breakpoints you add, remove or edit while the program runs take effect straight away, without restarting.

Hot Reload

Turn on Hot Reload (the 🔥 button in the debug toolbar) and every time you save a file of the project, the session restarts with the new code — no need to stop and debug again.

Other languages

The debug panel also opens for Python, Java and the other languages, but there it is a simulation: it says so in a banner (“Simulation — real debugging is only available for Node.js”) and labels the variables and call stack as sample data. We show it so you can learn the panel, never as if it were debugging your program.

An honest note on scope

These aren't there yet, so we won't advertise them as if they were:

  • Attaching to a remote host over the network and performance profiling
  • Breakpoints stay on their line number: if you insert lines above one, it does not move with the code

Breakpoints, logpoints, stepping and variables all run against real Node on your phone today.

PocketCode is heading to Google Play. Join the pre-registration to be among the first to try it on your own device.

The tool behind this article

Terminal & SSH

Ready to try PocketCode?

Download the app and start coding from your mobile.