Skip to Main Content Skip to Search
Product Documentation

Integrating and Testing Code with the Eclipse IDE

Introducing Eclipse

Eclipse (www.eclipse.org) is an integrated development environment for developing and debugging embedded software. Cygwin (www.cygwin.com) is an environment that is similar to the Linux environment, but runs on Windows and includes the GCC compiler and debugger.

This section contains instructions for using the Eclipse IDE with Cygwin tools to build, run, test, and debug projects that include generated code, as described in Integrate Generated Code into External Environment and Verify Generated Code. There are many other software packages and tools that can work with code generation software to perform similar tasks.

Installing the Eclipse IDE and Cygwin Debugger contains instructions for installing Eclipse and Cygwin. Before proceeding, be sure you have installed Eclipse and Cygwin, as described in that section.

To use Cygwin, your build folder must be on your C drive. The folder path cannot include any spaces.

Project Names and File Names

Integrate Generated Code into External Environment and Verify Generated Code both use the instructions in this section, but the project names and file names differ. Where you see ## in a project name or file name, substitute:

Defining a New C Project

  1. In Eclipse, choose File > New > C Project. A C Project dialog box opens.

  2. In the C Project dialog box:

    1. In the Project name field, type the project name throttlecntrl_## (## is externenv or testcode) .

    2. In the Location field, specify the location of your build folder (for example, C:\EclipseProjects\throttlecntrl\externenv).

    3. In the Project type selection box, select and expand Makefile project.

    4. Click the Empty Project node.

    5. Under Other Toolchains, select Cygwin GCC .

    6. Click Next. A Select Configurations dialog box opens.

  3. In the Select Configurations dialog box, click Advanced settings. The Properties dialog box appears.

  4. In the Properties dialog box:

    1. Select C/C++ Build.

    2. Select Generate Makefiles automatically.

    3. Select the Behavior tab.

    4. Select Build on resource save (Auto build).

    5. Click Apply and OK.

    The Properties box closes.

  5. In the Select Configurations dialog box, click Finish.

Configuring the Debugger

  1. In Eclipse, choose Run > Debug Configurations. The Debug Configurations dialog box opens.

  2. Double-click C/C++ Application. A throttlecntrl_externenv Default entry appears under C/C++ Application. The Main tab of the configuration pane appears on the right side of the dialog box with the following parameter settings:

    ParameterSetting
    Namethrottlecntrl_externenv Default
    C/C++ ApplicationDefault\throttlecntrl_externenv.exe
    Projectthrottlecntrl_externenv
    Build configurationDefault
    Enable auto buildCleared
    Disable auto buildCleared
    Use workspace settingsSelected

  3. Click Close.

Starting the Debugger

To start the debugger:

  1. In the main Eclipse window, select Run > Debug. A Confirm Perspective Switch dialog box opens.

  2. Click Yes. Tabbed debugger panes that display debugging information and controls are displayed in the main Eclipse window.

  3. Specify the location of the project files. The Cygwin debugger creates a virtual drive (for example, main() at /cygdrive/) during the build process. To run the debugger, Eclipse remaps the drive or locates your project files. Once Eclipse locates the first file, it automatically finds the remaining files. In the Eclipse window, click Locate File. The Open dialog box opens.

    For information on using the Edit Source Lookup Path button, see Setting the Cygwin Path.

  4. Navigate to the example_main.c file and click Open. Your program opens in the debugger software.

Setting the Cygwin Path

The first time you run Eclipse, you get an error related to the Cygwin path.

To provide the path information:

  1. Open the Debug Configurations dialog box by selecting Run > Debug Configurations > C/C++ Application.

  2. Click the Source tab.

  3. Click Add. The Add Source dialog box opens.

  4. Select Path Mapping and click OK. The Path Mappings dialog box opens.

  5. Click Add. In the Compilation path field, type \cygdrive\c\.

  6. In the Local file system path field, click the Browse button, navigate to your C:\ drive, and click OK.

  7. Click Apply.

  8. Click Close.

Actions and Commands in the Eclipse Debugger

The following actions and commands are available in the debugger.

ActionCommand
Step intoF5
Step overF6
Step outF7
ResumeF8
Toggle break pointCtrl + Shift + B

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS