12.10.1. Example of setting a breakpoint on a C++ class

The source in Example 12.2 is used to show how to set a breakpoint for an instance of a C++ class.

Example 12.2. Example C++ source

#include <iostream>
using namespace std;

class Integer {
  Integer(int initVal) : intValue(initVal) {}
  int getValue() { return intValue; }
  void setValue(int newValue) { intValue = newValue; }

  int intValue;

int main() {
  Integer valOne(0);
  Integer valTwo(0);
  Integer valThree(0);
  cout << "value = " << valOne.getValue() << "\n";
  cout << "value = " << valTwo.getValue() << "\n";
  cout << "value = " << valThree.getValue() << "\n";

Do the following:

  1. Copy the source in Example 12.2 to a file called integers.cpp.

  2. Build the image, for example:

    armcc -g -O3 --no_inline --no_multifile integers.cpp -o integers.axf
  3. Connect to an ARM architecture-based target.

  4. Load the integers.axf image.

  5. Right-click on the line valOne.setValue(1) to display the context menu.

  6. Select Run to Here from the context menu. The image runs to this line and stops.

  7. Enter the following command to set a software instruction breakpoint:

    binstr,obj:valTwo \INTEGERS\#8:32
  8. Click Run on the Debug toolbar. Execution stops for the valTwo object, shown in Figure 12.17.

    Figure 12.17. Execution stopped on an instance of a C++ object

    Execution stopped on an instance of a C++ object

    Also, the following messages are displayed in the Cmd tab:

    Stopped at 0x0000E1DC due to SW Instruction Breakpoint
    Stopped at 0x0000E1DC: INTEGERS\Integer::setValue Line 8:32
  9. Click Run again. Execution continues to the end.

Copyright © 2002-2009 ARM Limited. All rights reserved.ARM DUI 0153K