Configuration problem with pic16F877A
For hardware debugging an extra piece of code called the 'Debug Executive' is loaded into program memory from 0x1F00-1FFF. For some reason your programmer is not able to write to this area. Three possible causes I can think of:-


The Flash is Write protected. 


Ensure that all program memory is writable by adding #pragma config WRT = OFF to your code.


You actually have a PIC16F877 (no 'A'), which has different configuration bits.


The 16F877 can be configured to write protect 0x1F00-1FFF while leaving other areas alone. Solution is to select the correct MCU and set the appropriate configuration bits for it.  


The chip is faulty, or it's actually some other PIC that only has 4k words of program memory.


Try padding the program until it fills more than half the memory, then if programming fails above 0x1000 you know it only has 4k of working Flash!