Source code viewer

The source code editing and rebuilding capabilities are not designed for developing programs from scratch. They are designed to fit into existing debugging or profiling sessions that are running on a current executable.

The same capabilities are available for source code whether you are running remotely (using the remote client) or if you are connected directly to your system.

View source code

When you start a session, source code is automatically found from the information compiled in the executable.

Source and header files found in the executable are reconciled with the files present on the front-end server, and displayed in a simple tree view in the Project Files tab of the Project Navigator window. Click on the file name to view the source file.

When a selected process is stopped, the Source Code viewer will automatically move to the correct file and line, if the source is available.

The Source code viewer supports automatic color syntax highlighting for C and Fortran.

You can hide functions or subroutines you are not interested in by clicking the ‘-’ glyph next to the first line of the function. This will collapse the function. Click the ‘+’ glyph to expand the function again.

Edit source code

Source code can be edited in the Source code viewer. The actions Undo, Redo, Cut, Copy, Paste, Select all, Go to line, Find, Find next, Find previous, and Find in files are available from the Edit menu. Files can be opened, saved, reverted, and closed from the File menu.

Note

Information from Linaro DDT will not match edited source files until the changes are saved, the binary is rebuilt, and the session restarted.

If the currently selected file has an associated header or source code file, you can open it by right-clicking in the editor and choosing Open <filename>.<extension>. There is a global shortcut on function key F4, or you can use Edit ‣ Switch Header/Source.

To edit a source file in an external editor, right-click the editor for the file and choose Open in external editor. To change the editor used, or if the file does not open with the default settings, select File ‣ Options to open the Options window (Linaro Forge Preferences on Mac OS X) then enter the path to the preferred editor in Editor, for example /usr/bin/gedit.

If a file is edited, a warning will be displayed at the top of the editor:

File edited warning

This is to warn that the source code shown is not the source that was used to produce the currently executing binary. The source code and line numbers may not match the executing code.

Rebuilding and restarting

If source files are edited, the changes will not take effect until the binary is rebuilt and the session restarted. To configure the build command choose File ‣ Configure Build, enter a build command and a directory in which to run the command, then click Apply.

To issue the build command choose File ‣ Build, or press Ctrl+B (Cmd+B on Mac OS X). When a build is issued the Build Output view is shown. When a rebuild succeeds we recommend that you restart the session with the new build by choosing File ‣ Restart Session.

Committing changes

Changes to source files can be committed using Git, Mercurial, or Subversion. To commit changes, choose File ‣ Commit, enter a commit message in the Commit changes dialog then click Commit.