## Run Mode Debug Example (Application TRK)

This example shows how to create and build an application and debug it on a device using the Application TRK on-device debug agent. The majority of steps are identical to the ones used to create a program and debug in an emulator, with some minor variations.

#### Debugging a Run-mode Project using Application TRK

1. Import the Bld.inf to create a project using the Import wizard

In this example we are importing a project called Music, a complex project that includes several EXEs (MusicPlayer, MusicShop, MusicVisualizer). When we import, we select an ARM target.

2. Go to the project Properties page and in the Carbide Build Configuration panel specify the PKG file in the SIS Builder tab
3. Build the project (Ctrl+B)
4. Verify that all the binaries built by the project appear in the Executables view.

NOTE The symbolics are automatically loaded for the binaries that appear in the Executables view.

5. Set breakpoints in the project source files

In this example we will set one breakpoint in two different EXEs. The first is set in the file called MCEngine.cpp (MCServer.exe) and the second is set in MPlayerAppUI.cpp (MusicPlayer.exe).

6. Click the Debug icon () to launch the New Launch Configuration wizard
   1. Select the Application TRK Launch Configuration from the Launch Types page, then click Next

   Figure 1 - Launch Types page showing selection

   2. If you have more than one executable, select the Main Executable in the Executable Selection page of the wizard, then click Next

   For this example we select the musicplayer.exe as the main executable.

   Figure 2 - Executable Selection page showing selection

   3. Select the remote connection to use in the TRK Connection Settings page, then click Next

   Figure 3 - TRK Connection Settings page showing selection

   4. Select the SIS file to install in the TRK SIS Selection page if not already populated

   > Figure 4 - TRK Connection Settings page showing selection

   1. Click Finish

   The SISX file is downloaded and authenticated, then the binaries are installed automatically on the phone.

7. Once the debug session launches, control returns to the Debugger when one of the breakpoints set earlier is hit.

At this point you can debug the program in the Debug perspective. Look at the Breakpoints view to verify that the breakpoints set earlier are resolved. In this case, the breakpoint in the MCServer.exe.

Figure 5 - Debug perspective showing the resolved breakpoint

8. Click Resume in the Debug view to hit the breakpoint set in the second EXE

Figure 6 - Debug perspective showing the resolved EXE breakpoint

9. In the Debug view
   1. Click Disconnect to leave the application running on the device, OR
   2. Click Terminate to stop the application running on the device

In addition, you can click the Symbian OS Data View to examine the processes running on the devise during the debug session.

##### Related references

- On-device Debugging Troubleshooting
- Symbian OS View