Debug the chipKIT Boards with MDB

This section requires embedXcode+ and a chipKIT board with the optional chipKIT PGM programmer-debugger.

This section applies to the chipKIT boards with the optional chipKIT PGM programmer-debugger.

The debugger is called MDB and is part of the official Microchip MPLABX  IDE

  • To launch a debugging session, just select the Debug target and press Run.

embedXcode builds and links the project, and then opens one Terminal window.

Identify One Terminal Window

The Terminal window hosts the programmer-debugger. The tool first connects to the board, then uploads the executable and all the breakpoints defined previously, and finally runs the project.

Run and Stop the Sketch Execution

Here are the most common commands to run, stop and continue the execution of the sketch in a debugging session:

  • Enter the commands after the > prompt and validate it by pressing the Enter ⏎ key.
>
  • When the debugger stops, type continue or simply c to continue till the next breakpoint.
> continue
> c
  • To run the sketch one step to the next line of code to be executed, including the sub-functions called by the current function, type step or simply s.
> step
> s
  • To run the sketch to the next line of the current function, without stopping at the sub-functions, type next or simply n.
> next
> n
  • To stop the sketch, type halt.
> halt
  • To list the breakpoints defined and loaded, type info break.
>info break
 Num    Enb Address What
 0  y   0x9D0013A8  at LocalLibrary.cpp:25

For more information,

Display the Value of a Variable

To get the value of a variable,

  • Type the command print and the name of the variable.
>print pin
pin=
0x0D

Display the Call Stack

To display the stack of the calls,

  • Type the command backtrace.
>backtrace
#0  blink (pin=0x0D, times=0x03, ms=0x20B2) at /Users/ReiVilo/Documents/Projets/Xcode/embed1/embed1/LocalLibrary.cpp:26
#1  0x9D0013CC in loop () at /Users/ReiVilo/Documents/Projets/Xcode/embed1/embed1/embed1.ino:106
#2  0x9D001404 in main () at /Users/ReiVilo/Documents/Projets/Xcode/embed1/embed1/main.cpp:93

The blink() function is called by the function loop(), and loop() is called by the main function main().

The backtrace command also provides the details of the parameters and values passed by loop() on to blink().

Here, values are pin=0x0D, times=0x03, ms=0x20B2.

Value 0x0D corresponds to variable myLED.

End and Quit a Debugging Session

To end the debugging session,

  • Type halt.
>halt

Halting...
Target Halted

>Stop at
    address:0x9d001f1c

To quit the debugging session,

  • Type quit.
>quit
Stop at
    address:0x9d001370
    file:/Users/ReiVilo/Documents/Projets/Xcode/embed1/embed1/LocalLibrary.cpp
    source line:26
  • Always quit and close the Terminal window.