About DS-5 Debugger support for overlays
Overlaying is a programming method that allows applications to share execution regions of memory between different pieces of code at runtime. A piece of code can be transferred to the overlay region to be executed when needed. This piece of code is replaced with another when needed.
Code does not need to be stored in memory and could reside in other storage such as off-chip flash memory. Embedded systems, especially systems without support for virtual memory addressing and systems with limited memory, sometimes use overlays.
An overlaid application consists of:
- Several overlays – These are blocks of code that are not resident in memory all the time.
- The overlay manager (must be part of the non-overlaid code) – The overlay manager takes care of loading and unloading different overlays as they are needed.
- Several overlay regions – These are regions in memory that overlays are loaded into as needed. Each overlay region can contain different overlays at different times.
- Some non-overlaid code – This is code that is permanently resident in memory.
- Data (both RO and RW) – Data is never overlaid.
As a developer, you must decide which functions from your application are used in overlays. You must also decide which functions are used in the same overlay.
You can specify the functions to overlay by annotating the function declarations in your source code. The annotation indicates which overlay each function must be in.
During compilation, the linker assigns overlays to a particular region. When overlays are loaded, it can only be loaded into that region. The linker also detects direct calls between overlays, and between overlays and non-overlaid code. The linker then redirects the calls through veneers, which call the overlay manager to automatically load the target overlay.
DS-5 Debugger automatically enables overlay support on the presence of linker generated tables and functions as described by the following symbols:
After loading your overlay-enabled application in DS-5, you can work with overlays from both the command-line console and from the user interface:
To see detailed information about the currently loaded overlays and the functions within each overlay, use the Overlays view. You can also use the info overlays command to view information about the currently loaded overlays and functions within each overlay.
- To enable or disable overlay support, use the set overlays enable command with the on, off, or auto options. The default setting is auto.
See the overlay_manager example that is provided with DS-5 for a reference implementation of overlays.