Debugging a QML app

When you debug your app using the toolbar in the Momentics IDE for BlackBerry, you click the Debug launch mode and a launch target to debug your app on. The Momentics IDE builds your app with the corresponding build configuration (either Device-Debug or Simulator-Debug) and then launches your app with the selected configuration. You don't need to build the app, configure the build configuration, or configure the launch configuration because the Momentics IDE does these tasks for you.

By default, the JavaScript debugger is disabled. To debug QML/JavaScript code, you must enable JavaScript debugging in the Momentics IDE:

  1. In Windows and Linux, on the Window menu, click Preferences. In Mac OS, on the Momentics menu, click Preferences.
  2. Expand BlackBerry, and click QML Debugging and Profiling.
  3. Select the Enable JavaScript Debugging check box.
  4. Click Apply.
  5. Click OK.

By default, the Wait for connection check box is selected. If your app is deployed in debug mode with JavaScript debugging enabled and the Wait for connection check box selected, your app won't start on the device if you try to open it outside of the Momentics IDE. This behavior is expected because the JavaScript debugger waits for a connection to your app. If you try to open your app outside of the Momentics IDE, your app won't start, because there is no connection with the JavaScript debugger.

If the Wait for connection check box is cleared, the JavaScript debugger doesn't wait for the initial connection and your app starts on the device when it's launched in debug mode. When the Wait for connection check box is cleared, a breakpoint that is set in initialization code is never hit. For example, if you set breakpoints in initialization code that runs when the creationCompleted() signal is emitted, these breakpoints won't be hit.

Screen showing the QML Debugging and Profiling preferences in the Momentics IDE.

When you add a new breakpoint in QML/JavaScript code, you are prompted to enable JavaScript debugging.

In Momentics IDE 2.1.1 and later, you can start a JavaScript debugging session without starting the GNU Debugger (GDB). For more information, see Debugging a QML app with the JavaScript debugger only.

To start the debugger:

  1. On the toolbar, in the Launch mode drop-down list, click Debug.
  2. In the Launch configuration drop-down list, click the launch configuration for your app.
  3. In the Launch target drop-down list, click a device or simulator.

    Screen showing the toolbar in Debug launch mode in Momentics IDE 2.1.

  4. Click Momentics launch button. The Momentics IDE changes to the Debug perspective, installs the app on your simulator or device, and starts the app under the control of the GDB.
  5. When you are finished debugging, on the Debug view toolbar, click The Terminate icon. You must terminate the debug session before you rebuild the project, or the build fails.

You can also right-click your project and click Debug As > BlackBerry C/C++ Application.

In the Debug view, you can see an overview of your process, including the call stack. You can control the debugger by using the buttons on the toolbar of the Debug view. In an app that contains both C++ and QML, the debugger is able to pass back and forth between the two types of source code.

By default, the debugger stops on the first line of your application. To change this behavior:

  1. Right-click your project, and then click Debug as > Debug Configurations.
  2. Click the debug configuration that you want to change.
  3. Click the Debugger tab.
  4. Clear the Stop on startup at check box.
Screen showing the Debugger options that can be used to change the behavior of the debugger when it starts.

Debugging a QML app with the JavaScript debugger only

In Momentics IDE 2.1.1 and later, you can start a debugging session that uses the JavaScript debugger only. You can start debugging more quickly because you don't start GDB.

You don't need debug symbols installed on your device to debug an app using the JavaScript debugger.

To start the JavaScript debugger:

  1. On the toolbar, in the Launch mode drop-down list, click QML Debug.
  2. In the Launch configuration drop-down list, click the launch configuration for your app.
  3. In the Launch target drop-down list, click a device or simulator.

    Screen showing the toolbar in QML Debug launch mode in Momentics IDE 2.1.1.

  4. Click Momentics launch button. The Momentics IDE changes to the Debug perspective, installs the app on your simulator or device, and starts the app under the control of the JavaScript debugger.
  5. When you are finished debugging, on the Debug view toolbar, click The Terminate icon. You must terminate the debug session before you rebuild the project, or the build fails.

Last modified: 2015-03-31



Got questions about leaving a comment? Get answers from our Disqus FAQ.

comments powered by Disqus