Skip to content
jwt27 edited this page Feb 9, 2018 · 1 revision

To aid debugging, a full featured gdb remote backend is integrated into jwdpmi. In order to use it, simply run your program with --debug. At startup, jwdpmi will listen for a remote connection on COM1, with serial port settings 115200 baud, 8N1.

If you wish to use some other debugger, you can enable debugging mode without the gdb backend by starting your program with --ext-debug. This only enables breakpoints and watchpoints, and sets a breakpoint at the start of your program.

To disable all debugging features, compile with the NDEBUG preprocessor macro.

Breakpoints

In some cases, you may want to hardcode a breakpoint or watchpoint into your program. The functions in <jw/dpmi/debug.h> provide this functionality.

Querying debug mode: if (jw::dpmi::debug()) { std::cout << "debug mode enabled\n"; }
Setting a hard breakpoint: jw::dpmi::breakpoint();

Watchpoints are provided by class jw::dpmi::watchpoint. Its constructor takes an pointer and a watchpoint type:

template<typename T> watchpoint(T* ptr, watchpoint_type t);

where t can be one of watchpoint::read, watchpoint::read_write, watchpoint::execute.

Be aware that watchpoints are a CPU feature, and only 4 watchpoints may be simultaneously defined. The gdb backend may also use these. When you run out of available watchpoints, the watchpoint constructor will throw a jw::dpmi::dpmi_error exception.

Clone this wiki locally