NetBurner 3.1
Debugger

In the previous section we created and ran a project in release mode. To use a debugger, the application must be built in debug mode. All debuggers require the code be built in a different manor than a release build:

  • Code optimization is disabled
  • If the platform uses external SDRAM with the internal SRAM acceleration for stacks, buffers and variables, it is disabled

NBEclipse uses a network debugger. This means that an application must be able to at least boot through network initialization so the NBEclipse agent can connect to the GDB stub on the target device.

Starting a Debug Session

We will pick up right where we left off for the SimpleHtml example project in the previous section. First, lets open main.cpp and add a variable. UserMain() is shown below:

void UserMain(void *pd)
{
init(); // Initialize network stack
StartHttp(); // Start web server, default port 80
iprintf("Application: %s\r\nNNDK Revision: %s\r\n", AppName, GetReleaseTag());
while (1)
{
OSTimeDly(TICKS_PER_SECOND);
}
}


Add two lines of code to create an integer and increment it:

int i = 0; and i++;


So UserMain() becomes:

void UserMain(void *pd)
{
init(); // Initialize network stack
StartHttp(); // Start web server, default port 80
iprintf("Application: %s\r\nNNDK Revision: %s\r\n", AppName, GetReleaseTag());
int i = 0; // <--- Declare variable
while (1)
{
OSTimeDly(TICKS_PER_SECOND);
i++; // <--- Increment variable
}
}


Previously for the Run Configuration and download we clicked on the green play button in the upper right corner of NBEclipse. This time we will click on the debug button, which is next to it on the left:

EclipseSelectDebugButton.jpg
Select Debug Configuration


It will take a few seconds for the debugger to connect, and the NBEclipse Perspective will change from the NetBurner perspective to the Debug perspective:

EclipseDebugPerspective.jpg
Debug Perspective


At this point the code is running. To set a breakpoint on our new variable, double click to the left of the line of code. In this example is is just to the left of line 29:

EclipseSelectBreakpoint.jpg
Set Breakpoint


The screen shot below shows the program stopped at line 29. The Variables window in the upper right shows the variable 'i', which has incremented 7 times so far.

EclipseBreakpointStopped.jpg
Stopped at Breakpoint


The debugger operations are controlled with the tool bar at the top of the screen. If you hover the cursor over the icon the tool tip will describe what it does. Common features are:

  • Resume: Available when stopped at a breakpoint. Selecting it will resume the application and stop at the next breakpoint.
  • Terminate: Disconnects the debugger from the target device. The device will resume execution without any breakpoints.
  • Disconnect: Identical to Terminate.
  • Step Into: Single step into a function call.
  • Step Over: Single step to the next line of code in the current function.
  • Step Return: Execute until current function returns.

Notes on debugging:

  • You can switch between the Debug perspective and NetBurner perspective using the NetBurner and Debug icons in the upper right corner of the screen.
  • You can edit and build your application from either perspective.
  • Hovering the cursor over variables, macros and functions in the source code window will display information on that item.
  • The upper left window displays the RTOS task stack.
  • It is recommended to terminate a debug session before starting a new one.
  • The three icons at the top left of the screen: build, debug and stop, are not used by either perspective.