Debugging Tools for Windows

Using Source Files

The debugger engine maintains a source path, which is a list of directories and source servers that contain source code files associated with the current targets. The debugger engine can search these directories and source servers for the source files. With the help of symbol files, the debugger engine can match lines in the source files with locations in the target's memory.

For an overview of using source files with debuggers, see Debugging in Source Mode. For an overview of source paths, see Source Path. For an overview of using source servers from the debugger engine, see Using a Source Server. If the SDK option was selected when installing Debugging Tools for Windows, the file sdk\srcsrv\srcsrv.doc contains the documentation on how to administer a source server.

Source Path

To add a directory or source server to the source path, use the method AppendSourcePath. The whole source path is returned by GetSourcePath and can be changed using SetSourcePath. A single directory or source server can be retrieved from the source path using GetSourcePathElement.

To find a source file relative to the source path, use FindSourceFile or, for more advanced options when using source servers, use FindSourceFileAndToken. FindSourceFileAndToken can also be used along with GetSourceFileInformation to retrieve variables related to a file on a source server.

Matching Source Files to Code in Memory

The debugger engine provides three methods for locating the memory locations that correspond to lines in a source file. To map a single line of source code to a memory location, use GetOffsetByLine. To search for memory locations for more than one source line or for nearby source lines, use GetSourceEntriesByLine. The GetSourceFileLineOffsets method will return the memory location of every line in a source file.

To perform the opposite operation and find the line of a source file that matches a location in the target's memory, use GetLineByOffset.

Note: the relationship between memory locations and lines in a source file is not necessarily one-to-one. It is possible for a single line of source code to correspond to multiple memory locations and for a single memory location to correspond to multiple lines of source code.

Build machine: CAPEBUILD