In System programming and On Chip Debugging are two different things.
To do on chip debugging you have to use a JTAG Interface and the In System debugging Flag JTAGEN has to be set ( Fuses! ). It's set in default configuration on a new ATMEGA32.
It uses some Ports of PORTC. It is possible to program a controller via JTAG of course.
The used Ports of Port C could not be used otherwise!
To do ISP you need a ISP Programmer. On Chip debugging isn't possible with this thing!
At most! Controllers there be used MISO MOSI SCK and Reset Pin to connect such a programmer to the Controller. ATMEGA64 and 128 are one of that exceptions.
The used Ports can be used otherwise in your Application, when the load is higher than 4.7 kOhms. That appends from the used ISP Programmer additionally.