Previous: Remote Stub, Up: Remote Debugging

20.6 Extra support for hardware debuggers

When gdb interacts with a server or stub running on the remote target, the target-side application can perform a number of host-side file I/O operations, see File-I/O Remote Protocol Extension. Remote debugging can also involve a separate server that controls the target via a hardware debug mechanism, for example jtag or BDM. If so, then target-side code may be unable to generate the remote protocol messages directly. Instead, it can send the request by triggering a breakpoint or processor exception at a well-known location named _gdb_hwdebug_break. This functionality is disabled by default, allowing the application to run stand-alone as well as inside a debug session. It can be enabled by a set hwdebug on command, or disabled by set hwdebug off.

Exact usage depends on the application being debugged. Amongst other things, set hwdebug clears a flag _gdb_hwdebug_disabled on the target. If the application is loaded into RAM, then there are no problems. However, if it is programmed into flash and restarted from the reset vector inside the debug session, then typically the target-side initialization code will reset the disabled flag to its default state, undoing the effect of set hwdebug. Instead, it will be necessary to set a hardware breakpoint at a suitably early point in the application startup and invoke set hwdebug when that breakpoint is hit.

The target-side API for accessing the hardware debug file I/O functionality depends on the embedded OS or run-time being used. If the functionality has not yet been ported, then a reference implementation can be found in doc/hwdebug-example.c in the gdb sources.