When an application is compiled with debug flags (for example, -O0 -g), the compiler stores references to the source paths in the debug sections of the ELFs. This information is used by the debugger to map the PC address of the target processor to the source line in the code. Path mapping allows users to debug an application when its sources are not available at the location where it was compiled. For example, users can compile an application on Windows and debug it on Linux, or debug a pre-built Linux kernel image, without having to recompile the sources. In both cases, users can download and run the images through XSCT (reference to commandline debug using XSCT), and then attach the debugger (described in Debug an Application Already Running On a Target Device).
Once this is done, debugger would complain about the missing source files when the processor is stopped. Users can then enable path mapping in one of the following ways, so that debugger can find the sources from a different location. Please note that the source files at the new location should exactly match the source files at the original location
- Click Edit source lookup path.
- Right-click Debug Configuration, and then select Path Mapping.
- Select Add Path Mapping.
- Enter compilation path as source path and the new location where the sources are available, as destination path. For example, if the application was compiled at C:\testapp, and the same sources are available at /scratch/source, then source path would be C:\testapp, and destination path would be /scratch/source.
- Save the settings by clicking OK. Debugger will now show the source files from the new path.