## Launching and debugging an executable

In this example we show how to create a new project using one of the built-in Carbide templates, how to build it into an executable, and how to launch the debugger to verify program accuracy. The steps to do this include:

1. Creating a project from a project template
2. Building the object code based on the project sources
3. Defining a launch configuration for running or debugging the application
4. Launching and debugging an executable using the Carbide debugger

NOTE You can only debug compiled programs. Use the Build Project command to compile project sources into a binary file if you do not already have an executable in the project. A symbolics (.sym) file is also required for debugging on a target device. Ensure that a .sym file has been created. If you are importing an existing application, you may have to rebuild the application and create a related .sym file. Make sure a .sym file has been created in the output directory.

#### Launching and debugging an executable

1. Select the project to debug in the Project Explorer view.

   For this example you should choose the HelloWorld project created in Step 1 of this tutorial.

2. Set a breakpoint in the project.

   Open the \src\HelloWorldAppUi.cpp file and set a breakpoint in the HandleCommandL routine on Line 103.

3. Launch the debug session.

   To run the project on the chosen target and start a debug session use one of the following actions. Clicking Debug is the most common choice as it enables you to assume control of the executable should you encounter a problem.

   - Right-click the project and choose Debug As > Debug on Emulator or Device.
   - Click the Run > Debug (F11) menu item.
   - Click the Debug () icon in the toolbar.

   The emulator is launched and the Debug perspective appears to manage the debug session.

4. Click the Options soft-menu and select any menu option to hit the breakpoint set in Step 2.

   Which returns control to the Debug perspective in Carbide. Use the various views to examine the program as it runs. Examine variables, set more breakpoints, etc.

5. Use any of the step commands in the Debug view to step through the program source code.
   - Click Step Into (F5) to execute the current line and enter a function or method.
   - Click Step Over (F6) to execute the current line.
   - Click Step Return (F7) to execute lines until exiting the function or method.
6. Click the Resume icon in the Debug view to return control to the program.
7. Click the Exit soft-key in the emulator to exit the debug session.

   The HelloWorld program stops, the emulator exits, and control returns to Carbide.

That's it. Congratulations on creating, building, and debugging a Carbide project.

#### Other references

- Emulator Application Projects