libpayload: Add remote GDB support
This patch adds the ability to attach a GDB host through the UART to a running payload. Libpayload implements a small stub that can parse and respond to the GDB remote protocol and provide the required primitives (reading/writing registers/memory, etc.) to allow GDB to control execution. The goal of this implementation is to be as small and uninvasive as possible. It implements only the minimum amount of primitives required, and relies on GDB's impressive workaround capabilities (such as emulating breakpoints by temporarily replacing instructions) for the more complicated features. This way, a relatively tiny amount of code on the firmware side opens a vast range of capabilities to the user, not just in debugging but also in remote-controlling the firmware to change its behavior (e.g. through GDBs ability to modify variables and call functions). By default, a system with the REMOTEGDB Kconfig will only trap into GDB when executing halt() (including the calls from die_if(), assert(), and exception handlers). In addition, payloads can manually call gdb_enter() if desired. It will print a final "Ready for GDB connection." on the serial, detach the normal serial output driver and wait for the commands that GDB starts sending on attach. Based on original implementation by Gabe Black <gabeblack@chromium.org>. BUG=chrome-os-partner:18390 TEST=Boot a GDB enabled image in recovery mode (or get it to hit a halt()), close your terminal, execute '<toolchain>-gdb --symbols /build/<board>/firmware/depthcharge_gdb/depthcharge.elf --directory ~/trunk/src/third_party/coreboot/payloads/libpayload --directory ~/trunk/src/platform/depthcharge --directory ~/trunk/src/platform/vboot_reference --ex "target remote <cpu_uart_pty>"' and behold the magic. (You can also SIGSTOP your terminal's parent shell and the terminal itself, and SIGCONT them in reverse order after GDB exits. More convenient wrapper tools to do all this automatically coming soon.) Change-Id: Ib440d1804126cdfdac4a8801f5015b4487e25269 Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/202563 Reviewed-by: Stefan Reinauer <reinauer@chromium.org>
This commit is contained in:
parent
97542110f0
commit
9c4a642c7b
13 changed files with 950 additions and 1 deletions
|
|
@ -202,6 +202,10 @@ void srand(unsigned int seed);
|
|||
void halt(void) __attribute__ ((noreturn));
|
||||
void exit(int status) __attribute__ ((noreturn));
|
||||
#define abort() halt() /**< Alias for the halt() function */
|
||||
#ifdef CONFIG_LP_REMOTEGDB
|
||||
/* Override abort()/halt() to trap into GDB if it is enabled. */
|
||||
#define halt() do { gdb_enter(); halt(); } while (0)
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue