18.1 Compiling for Debug Outside of MPLAB® X IDE
To compile code for debugging outside of MPLAB® X IDE, you must ensure you pass the correct parameters to the compiler and/or the linker to reserve the areas required. The parameter values depend on the debug tool being used and on the compiler being used. Furthermore, the version of the compiler might determine the specific mechanism used to reserve these areas.
MPLAB X IDE has the knowledge to determine what needs to be passed to the compiler/assembler/linker. So, the best way to find out how to reserve areas for debugging is to create a small project in the IDE using the desired device, debug tool, and compiler. Since the IDE can support multiple versions of the same compiler, make sure you select the compiler version you want for your project.
After you have created the small project, build the project for debugging. Save the text in the output window showing the build steps for debugging. Then build the project again (not for debugging) and save the text in the output window showing the build steps for production. Compare the two sets of instructions being passed to the compiler/assembler/linker.
Some examples of the differences in the output window are:
- Compiler/assembler/linker being called with the __DEBUG macro.
- Compiler/assembler/linker being called with the __MPLAB_DEBUG macro.
- Linker being called with __ICD2_RAM or
-mreserves
. These two are mutually exclusive, i.e., the linker is called with one of them but not the other. - Compiler/assembler/linker is called with the name of the debug tool to be used.
This is not an exhaustive list.