Resources | developer.brewmp.com Resources | developer.brewmp.com

Developer

resources

Debugging - Command Line

This section covers using Brew MP Debugger with the GDB command-line interface.

  1. Use cdblauncher.exe to start Debugger on the target by navigating in a command-prompt to the location of cdblauncher, %BREWMP_TOOLSET%\bin. The following is a sample command. cdblauncher -device 1 -mod c_basicapp -app <ClassID> This starts the Debugger server on the target, sends a request to start the Brew MP application with the provided ClassID, and waits for the application module to load. When the application loads, it stops at the module entry point as a result of hitting a breakpoint auto-inserted by Debugger. For help using cdblauncher.exe, type the following in the location of cdblauncher:

    cdblauncher -help

  2. The next step is to connect to the device with GDB. GDB should be given the ELF file for the module to be debugged as an argument. The following is a sample to enter in the command-prompt, in the c_basicapp folder: arm-none-eabi-gdb.exe RVCT22arm9_Debug\c_basicapp.elf
  3. To connect GDB to the device, type the following in the GDB command-shell: target remote :60891 It make take several seconds for GDB to connect to the device. When GDB connects to the device it shows the application stopped at the module entry point (for example, AEEMod_Load for Brew MP MOD files). After this, regular GDB commands can be used to debug the module, set any breakpoints, and resume execution of the application.

Debugging multiple modules

A Brew MP application and the modules or extensions that the application uses can be debugged together using the Brew MP Debugger from the command-line. Typically, the application module is specified as the primary module to be debugged. GDB treats the primary module like an executable and the additional modules loaded in the process as shared libraries.

Version dependencies: A version of ARM EABI GDB that supports shared libraries is needed for multiple module debugging.

  • Codesourcery Spring 2010 or higher has shared library support.
  • Brew MP SDK 1.0 Rev 7.11.1 or higher is required.

The examples below show usage from the command line with the SDK sample c_basicextapp as the primary application module and c_basicext as the extension it loads.

Before the extension modules get loaded, the location of the ELF files for the modules needs to be specified.

This can be done by setting the solib-search-path, shown in the following example:

10 (gdb) set solib-search-path ../c_basicext/RVCT22arm9_Debug

Pending breakpoints can be set in modules yet to be loaded, such as in the following code example:

16 (gdb) br MyExt_DrawText
   17 Function "MyExt_DrawText" not defined.
   18 Make breakpoint pending on future shared library load? (y or [n]) y

The breakpoints are bound when the module loads.

The list of extensions loaded can be displayed using the info sharedlibrary command, as in the following code example:

29 (gdb) info sharedlibrary
   30 From        To          Syms Read   Shared Object Library
   31             No          sysfonts.elf
   32 0x02d769e0 0x02d76e6c  Yes c:\documents and settings\jojoyk\qualcomm
      \samplecode\c_basicext\rvct22arm9_debug\c_basicext.elf

The complete log session is shown below.

1  cdblauncher -mod c_basicextapp -app 0x0071B014
   2  cdblauncher : Sending cdb launch request ... Success
   3  cdbgwserver : Listening on loopback tcp port 60891
   4  
   5  arm-none-eabi-gdb RVCT22arm9_Debug\c_basicextapp.elf
   6
   7  GNU gdb (Sourcery G++ 4.4-180) 7.0.50.20100218-cvs
   8  Reading symbols from c:\documents and settings\jojoyk\qualcomm
       \samplecode\c_basicextapp\rvct22arm9_debug\c_basicextapp.elf...done.
   9
   10 (gdb) set solib-search-path ../c_basicext/RVCT22arm9_Debug   
   11 (gdb) target remote :60891
   12 Remote debugging using :60891
   13 AEEMod_Load (pIShell=0x413ee80, ph=0x1dea224, ppMod=0x0) 
                      at AEEModGen.c:130
   14 130     {
   15 
   16 (gdb) br MyExt_DrawText
   17 Function "MyExt_DrawText" not defined.
   18 Make breakpoint pending on future shared library load? (y or [n]) y
   19 
   20 Breakpoint 1 (MyExt_DrawText) pending.
   21 (gdb)
   22 Loaded module: sysfonts @ 0xb0807044
   23 Error while mapping shared library sections:
   24 sysfonts.elf: No such file or directory.
   25 Loaded module: c_basicext @ 0x02d769e0
   26 
   27 Breakpoint 1, MyExt_DrawText (po=0x2d7d080) at c_basicext.c:357
   28 357         MyExt * pMe = (MyExt *)po;
   29 (gdb) info sharedlibrary
   30 From        To          Syms Read   Shared Object Library
   31                    No          sysfonts.elf
   32 0x02d769e0 0x02d76e6c  Yes         
          c:\documents and settings\jojoyk\qualcomm\samplecode
            \c_basicext\rvct22arm9_debug\c_basicext.elf

The Debugger server on the device shuts down when the application being debugged ends or when the debug session is terminated from the PC. Before connecting with GDB the next time, the cdblauncher command needs to be run again. Debugger supports most GDB commands. Please see GDB documentation for more information.