With debug support enabled you can use avr-gdb to debug the code used in the simulator. Use the configuration window to choose between MDB (MPLABX) or GDB to debug AVR microcontrollers.
Use avr-gdb with the .elf file as the parameter:
avr-gdb compiled_file.elfand the command below to connect (1234 is the default port):
target remote localhost:1234
Graphic debug mode can be made using eclipse IDE with Sloeber Arduino plugin.