< Previous PageNext Page >

Debugging BlackDog Applications

Debugging Applications with GDB

The BlackDog SDK includes the GDB (GNU Project Debugger). This debugger is an extremely useful tool that displays messages to a console or log file to help you see inside a running program.

Note: To use the debugger, you need to compile the code with the -g flag, and you should not use the -O flag. See Compiling Applications for more information.

For example to use the debugger:

  1. Open a command window or shell.
  2. Navigate to the directory containing the application you want to debug.
  3. Execute the following command:

    gdb applicationName

  4. The GNU Debugger shows the (gdb) prompt. From this prompt, you can enter the debugger commands. To run the debugger, type run:

    (gdb) run

    GDB runs the program and displays debugging messages.

See the GDB manual or go to http://www.gnu.org/software/gdb/gdb.html for more information about GDB.

Profiling Applications

Because embedded applications often have to run in a resource-constrained environment, it is a good idea to optimize your applications for performance. Profiling allows you to learn where your program spent its time and which functions called other functions while it was executing. This information can show you which pieces of your program are slower than you expected, and might be candidates for rewriting to make your program execute faster. It can also tell you which functions are being called more or less often than you expected. This may help you spot bugs that had otherwise gone unnoticed. The BlackDog SDK includes the GNU compiler's gprof program to profile your applications.

Note: To use the profiler, you need to compile the code with the -pg flag and run the application. See Compiling Applications for more information.

To use the profiler:

  1. Open a command window or shell.
  2. Navigate to the directory containing the application executable.
  3. Execute the following command:

    gprof applicationName > applicationName.out

    Note: The above command redirects the profiler's output to a file called applicationName.out.

  4. Open the applicationName.out file with a text editor to view the profiler output.

Click here for more information about gprof.

 

< Previous PageNext Page >
Copyright © Realm Systems, Inc. 2003-2005.
All rights reserved.