1. Debugging webOS
Applications
Steve Lemke
webOS Tools Engineering
April 23, 2010
2. About Me
• Tools Engineer at Palm
• Palm (webOS) Emulator
• Internal and external SDK/PDK tools
• Previously
• Palm Computing (acquired by US Robotics)
• US Robotics (acquired by 3Com)
• 3Com (spun out Palm Inc.)
• Palm Inc. (spun out PalmSource)
• PalmSource (acquired by Access Systems)
3. Overview
• General Connectivity
• JavaScript Logging
• Palm Inspector and WORM
• Host Mode for WebKit Inspector
• Command Line Debugging
• Ares Debugger
• Emulator Tips and Tricks
• Command Line Tips
• Helpful Resources
• Q&A
4. General Connectivity
• IP vs. USB
• IP over USB is tricky
• novacom and novaterm
• Default target is most recently connected target
• Helpful if you realize it; confusing if not
• Leave emulator running
• Tip: connect device only when needed, then disconnect
• ssh
• Built-in to emulator (localhost:5522)
• Can be added to device (“pdk-device-install”)
• Useful on Windows (Putty)
• Can tunnel other ports (but novacom will too)
6. JavaScript Logging
• To enable logging in framework_config.json:
• “loglevel”:99 (enable Mojo.Log.info/warn)
• “logEvents”:true (log framework/mouse events)
• “timingEnabled”:true (log scene transition timing)
• Restore default settings before shipping!
• “loglevel”:0 (disable Mojo.Log.info/warn)
• “logEvents”:false (no framework/mouse events)
• “timingEnabled”:false (no scene transition timing)
• MUST change system log level to see info/warn on device!
• Default is “error” only
• Type: palm-log --system-log-level info
7. Palm Inspector
• Launch application with “palm-launch -i <appname>”
• Launch “Palm Inspector” app
• Type “palm-inspector” on Linux
• Emulator only
8.
9. Palm WORM
• Launch “palm-worm” app
• Live graphs of:
• Total DOM nodes
• Open service handles
• JavaScript heap usage
• Emulator only
10.
11. Host Mode for WebKit Inspector
• Web server running inside Palm Emulator
• Set up a tunnel from host port 5581
• ssh -p 5522 -L 5581:localhost:8080 root@localhost
• See hints for Windows tunnel on developer.palm.com
• Use Safari (or Chrome) to inspect your app
• http://localhost:5581/Apps
• http://localhost:5581/PalmApps
• Enable “Develop Menu” in Safari: Prefs: Advanced
• Right-click and select “Inspect Element”
12.
13. Command Line Debugging
• novaterm or ssh to device
• Type “debug” to run JavaScript debugger (like gdb)
• Hit “enter” to stop/re-start
• Common commands:
• “help” and “scripts filename.js”
• “break /path/to/file.js:<lineno>”, “en exc all” (catch exceptions)
• “info break” and “clear <#>”
• “c” (continue), “fin” (step out), “next” (step over), “step” (into)
• “bt”, “down”, “up”, “frame <#>”, “scope”
• “list, “list -” or “list 5,10”
• “info args” or “info locals”
• “print <expr>” or “set <var> = <expr>”
15. Command Line Debugging
• Demo (cont’d)
• scripts first-assistant.js (list script path)
• b file:///media/…/first-assistant.js:25 (set brkpt)
• en exc all (enable exceptions all)
• c (continue, trigger brkpt)
• bt (backtrace)
• l (list)
• n (step over, hit exception)
• print Mojo.Controller.stageController
• set window.scene = Mojo.Controller.stageController.topScene()
• p scene
• p scene.sceneElement.querySelector('.palm-header').innerHTML
• p scene.sceneElement.querySelector('.palm-header').innerHTML=“foo”
• c (continue; observe header change)
• clear 1 (clear breakpoint; exit debugger)
16. Ares (IDE) Debugger
• Better than command-line debugger
• Source-level debugging
• Integrated log viewer
• Interactive console
• Don’t have to develop in Ares to debug with it
• http://ares.palm.com
• Import your project, run, and debug
• Use svn (or hg) to avoid re-importing to update
17. Ares (Standalone) Debugger
• Stand-alone Ares Debugger (NEW!)
• Separate from IDE; no sources needed
• Just attach and debug
• http://ares.palm.com/AresDebug
• Stand-alone Ares Log Viewer
• http://ares.palm.com/AresLog
• Ares will also be able to debug devices over USB