Also, if you're working with C some compiler should be set to use ICD debugging feature, usually this is a check that you've to set into the compiler option. Attached a screen shot example for the Hi-Tech PICC compiler, you've to set the flag in order to debug correctly the code, for production simply remove the flag and rebuild the project.