Overview

This describes how to debug an application that is already running continuously, by attaching a debugger to the target using STWorkbench.

STLinux userspace applications have no intrinsic links to specific target boards, therefore this is applicable to any supported board. However, the following host and target features must be available.

  • The Linux kernel must be booting and running on the target board.
  • When building for an ST40, sh4-linux-gcc and sh4-linux-gdb must be accessable through the host's path.
  • When building for an ST200, st231-linux-gcc and st231-linux-gdb must be accessable through the host's path.
  • gdbserver must be present on the target filesystem.
  • The root user must be able to log in to the target using SSH with an empty password or without being prompted at all. This the default, provided the root user has remotely logged in at least once previously.

Create and build

  1. Click File > New > Project.... The New Project window appears.

  2. Select C > C Project from the Wizards tree/list and click Next. The C Project dialog appears.

  3. Enter 'HelloWorld' into the Project name text box

  4. Select Executable from the Project types list

  5. Select ST40 Linux GCC from the Toolchain list.

  6. Click Finish. If a confirmation appears, click Yes.

  7. Select HelloWorld from the STWorkbench Navigator window.

  8. Click File > New > File. The New File window appears.

  9. Enter 'hello1.c' into the File name text box and click Finish.

  10. Copy the following into the editor.

    #include <stdio.h>
     
    int main()
    {
        while (1) {
            printf("Hello world\n");
        }
     
        return 0;
    }

  11. Select File > Save.

  12. Select Project > Build Project. The application is built.

    If the console output is not displayed automatically, select HelloWorld from the STWorkbench Navigator window.

  13. Run the application.

Debug

  1. Select HelloWorld from the STWorkbench Navigator window.

  2. Click Run > Debug.... The Create, manage, and run configurations window appears.

  3. Screenshot of the Debug
        configuration dialog

  4. From the Configurations list, select STLinux Attach to Target Application and click New. A HelloWorld configuration is automatically created from the selected project.

  5. Select the Debugger tab.

  6. Check that ST40 Linux GDB Debugger or ST200 Linux GDB Debugger is selected in the Debugger list.

  7. Enter the name or IP address of the target board into the Target name or IP address text box.

  8. Click Debug.

  9. Select a process (PID) to attach to. A process is highlighted if it has the same name as the executable.

    The debugger attaches to the application and suspends execution. The Debug view points where the target has stopped.

  10. To quickly return execution to main(), set a breakpoint on the printf line, then select Run > Resume.