Inspect your code

In the Debug perspective, you can use additional views to inspect your code. You can inspect variables, expressions, registers, memory, and shared-library usage.

To display additional debug views:

  1. On the Window menu, click Show View > Other.
  2. Expand Debug, select the view, and then click OK.

Inspect variables

Use the Variables view to inspect the variables in the selected stack frame. The Variables view updates the variables only when the app stops running. When the app stops, the debugging tool highlights any changed values in yellow.

If multiple variables have the same name, the debugging tool evaluates the one that is most in scope.

Screen showing the Variables view.

Change a variable value

You can change the value of a variable while debugging. You can change the values for simple C/C++ types such as char, int, long, bool, double, float, and pointer. For example, you can change a variable value to speed through a loop or test how your app handles the setting.

In the Variables view, you can change the value in the Values column or in the Details pane at the bottom of the view:

  1. On the Window menu, click Show View > Variables.
  2. Do one of the following:
    • To change the value in the Values column, click the value for the variable that you want to change, and then type a new value.
    • To change the value in the Details pane, click the value, change it, and then save your change.

Change the variable type

  1. On the Window menu, click Show View > Variables.
  2. Click The Show Type Names icon. to show the variable type, such as int. This button is unavailable when the columns are visible.
  3. Right-click the variable, and then select one of the following:
    • Cast To Type: Cast the variable to the type that you specify in the field, such as int.
    • Display As Array: Show the variable as an array with a length and a start index that you specify. This option is available only for pointers.

Disable or enable variables

You can disable variables to prevent the debugging tool from reading the value of variables from the device or simulator. You might use this feature for variables that are either sensitive or specified as volatile. Disabling certain variables can also improve your app's performance.

You can also control whether the Momentics IDE for BlackBerry inspects every variable when you step through your app. Tracking all of the variables can decrease performance. To improve performance, you can disable some or all variables and manually enable individual variables.

  1. On the Window menu, click Show View > Variables.
  2. To disable or enable an individual variable, in the Variables view, right-click the variable, and then select Disable or Enable.
  3. To disable all of the variables in your app:
    1. In the Launch configuration drop-down list on the toolbar, click Momentics IDE edit icon next to your launch configuration.
    2. On the Debugger tab, click Advanced.

      Screen showing the Advanced Options dialog box that is available from the Debugger tab on the Debug Configurations dialog box.

    3. To disable all of the variables, clear the Variables check box, and then click OK.

Inspect global variables

You inspect global variables in the Expressions view. Global variables aren't shown in the Variables view.

  1. On the Window menu, click Show View > Expressions.
  2. Click Add New Expression, and then type the name of the global variable that you want to monitor.

To track a global variable in the C/C++ editor, right-click it and select Add Watch Expression.

View variables in memory

  1. On the Window menu, click Show View > Variables.
  2. Right-click a variable and select View Memory. The Memory view displays the variables and their corresponding values.

Evaluate expressions

You can evaluate the value of expressions in the Expressions view. The Expressions view is similar to the Variables view.

Screen showing the Expressions view.
  1. On the Window menu, click Show View > Expressions.
  2. Right-click the Expressions view, and then select Add Watch Expression.
  3. Type the expression that you want to evaluate, such as (x-5)*3.
  4. Click OK. The expression and its value appear in the Expressions view. When the debugging tool suspends the app, it re-evaluates all expressions and highlights the changed values.

Inspect registers

The Registers view shows information about the registers in the selected stack frame. When the app stops, the changed values are highlighted.

Screen showing the Registers view

You can change the register values and switch their number system.

  1. On the Window menu, click Show View > Registers.
  2. In the Registers view, in the Values column, click the register value.
  3. Type a new value.
  4. To change the number system for register values, on the Register view menu, select Number Format, and then select a number format.

Inspect process memory

Use the Memory view to inspect and change process memory. The Memory view displays process memory as a list of memory monitors. Each monitor represents a section of memory that is specified by its location, called a base address. The Memory view can show each memory monitor in different data formats, called memory renderings. The debugging tool supports these rendering types: hexadecimal (default), ASCII, signed integer, and unsigned integer. The default rendering is displayed automatically on the monitor.

Screen showing the Memory view, which has a Monitors pane and a Renderings pane.

The left pane of the Memory view is the Monitors pane, which lists the memory monitors that you add to the current debugging session. The right pane is the Renderings pane, which consists of tabs that show renderings. The selection in the Monitors pane controls the content in the Renderings pane.

The Memory view supports the same addressing as the C language. You can address memory using expressions such as 0x0847d3c, (&y)+1024, and *ptr.

Changing a process's memory can make your app crash.

  1. On the Window menu, click Show View > Memory. The Memory view is empty until you add an item to monitor and specify the output format.

    In Windows, if the Memory view displays the error, "Target request failed: Unable to read memory," turn off the automatic buffering option that causes the IDE to read memory beyond the accessible area. On the Memory view menu, select Table Renderings Preferences > Manual, and then click OK.

  2. In the Debug view, select a process or a thread. Selecting a thread selects its associated process.
  3. In the Memory view, in the Monitors pane, click The Add Memory Monitor button.
  4. In the Enter address or expression to monitor field, type the address or expression, and then click OK.
  5. To show memory in a different format, in the Renderings pane, click the New Renderings tab. Select a rendering type, and then click The Add Memory Renderings button. For example, you can show memory in hexadecimal or ASCII formats, or as signed or unsigned integers. A new tab appears in the Memory view and displays the new rendering results that you specified.
  6. To change a process's memory, in the Renderings pane, click in a cell, type a new value, and then press Enter. The changed memory appears in red.

Inspect shared library usage

Use the Modules view to inspect the shared library usage for the current debugging session. The Modules view shows the name, base address, and size of each library.

Screen showing the Modules view, where you can inspect your shared library usage and load symbols for a library.
  1. On the Window menu, click Show View > Modules.
  2. Do one of the following:
    • To load the library symbols for a single library, right-click the library, and then select Load Symbols.
    • To load the library symbols for all of the libraries, right-click inside the Modules view, and then select Load Symbols for All.

Last modified: 2014-11-17



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

comments powered by Disqus