Debugging with GDB: Hardware Debug Support

Previous: Remote Stub, Up: Remote Debugging   [Contents][Index]


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.

Note: In the eCosCentric build of GDB, connecting to a remote target with target remote will implicitly invoke the equivalent of set hwdebug on at that point. In practice, this will only have an effect if symbols such as _gdb_hwdebug_break are present in the debugged program, and if they are not, then there will be no change in behavior, and no warning will be printed. Nevertheless, it still remains possible to manually control this feature by use of set hwdebug on and set hwdebug off.

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.


Previous: Remote Stub, Up: Remote Debugging   [Contents][Index]