3.4.3 What Do I Need to Do When Compiling to Use a Debugger?
You can use debuggers, such as the PICkit™ 5 in-circuit debugger or the MPLAB ICD 5 in-circuit debugger, to debug code built with the MPLAB XC32 compiler. When a debug Run is requested, a debug executive is automatically downloaded with your program image. This debug executive might use some of the device memory for its own purposes, making this memory off-limits to your program. These resources will not be used if you are not debugging and you perform a regular Run, Build Project, or Clean and Build.
Typically, no memory will be required by the debug executive when the debugger is connected to PIC32C/SAM devices (although this is not necessarily true for PIC32M devices). It is important that no memory used by the debugger is also used by your program.
Any memory locations used by hardware tools when debugging are attributes of MPLAB X IDE, which contains and downloads the debug executive executed on the targte device. The IDE uses the -mreserve
option to reserve any memory required by the debug executive when it builds for debugging. If you move a project to a new version of the IDE, the resources required might change. For this reason, you should not manually reserve memory for the debugger, or make any assumptions in your code as to what memory is used. Check the Reserved Resources information, available in the MPLAB X IDE's Start page, under Learn and Discover, for full information on which resources are used by the debugger.
See also 3.5.14 Why are Some Objects Positioned into Memory that I Reserved?.