Skip to main content

IAR Embedded Workbench for RISC-V 3.40

Resolving source files for externally built executable files

In this section:

Being able to add an externally built executable file to a project is very useful for debugging purposes. However, some core debugging tasks, like opening a specific source file and setting a breakpoint, or viewing the functions in the ELF file in the C-SPY Symbols window, are only possible or significantly easier to perform if the source files that the binary file was compiled from are available in the Workspace window.

To make it possible for the IDE to find and display all source files referred to from the externally built binary file, a source file resolution system exists, based on aliases. An alias replaces a specified segment of a file path, allowing the system to resolve source files for a binary file that was built on, for example, another computer or another operating system. For source file resolution to work, the file must have been built with debug information.

The IAR Embedded Workbench IDE tries to resolve the source files if you:

  • add a file to the project as an external binary file

  • set a binary file as the debug target

  • choose the Resolve Sources command.

All these commands can be found on the context menu in the Workspace window.

Aliases with an IDE-wide scope are called global aliases. They are valid for all projects in the IDE, existing and future. Changes to global aliases, for example, updating a path or adding a new path, will automatically update all projects in the IDE with the new information. Aliases that are valid only for the active project are project aliases. Changes to project aliases will only update the active project. Toggling the Resolve source for active debug target in current project option in the Configure Aliases dialog box will either remove or add source files to the active debug target in the active project—see Configure Aliases dialog box. This is useful if you want to disable automatic source file resolution completely.

There are two ways to set up this source file resolution:

  • Supply a mix of global aliases and project aliases in the Configure Aliases dialog box, so that files that are unavailable to the IDE can be located and displayed.

  • Enter (or skip) folders dynamically, prompted by the IDE, when you resolve source files manually using the context menu in the Workspace window. Any aliases supplied this way will be listed under Project aliases in the Configure Aliases dialog box.

The alias system has the following rules:

  • Project aliases have higher priority than global aliases.

  • Aliases with more derived paths (that are "closer to the source") have higher priority.

The derived aliases for the externally built binary file are automatically propagated to the C-SPY Debugger to be used during the debug session. The debugger can still prompt for files that are not listed in the provided set of aliases, for example, when downloading a second debug image to the target board.

Automatic resolution of source files can be controlled in two ways:

  • Using the Resolve source for active debug target in current project option on the Tools>Options>Project settings page. This setting is used when you create a new project—existing projects will not be affected by any changes.

  • Using the Resolve source for active debug target in current project option in the Configure Aliases dialog box. This setting determines the behavior of the current project.

Note

No check is made to make sure that a resolved source file is identical to the one that the binary file was compiled from—only that it has the same name.

See also Loading executable files built outside of the IDE.