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 by the specific tool being used. 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, remembering that the IDE can support multiple versions of the same compiler. So, while creating the project in the IDE, make sure you select the correct compiler version.

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.

Figure: Build Icon Menu

BuildIconMenu.gif

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 being called with the name of the debug tool to be used.

This is not an exhaustive list.

© 2017 Microchip Technology, Inc.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.