coreboot-kgpe-d16/payloads/libpayload
Julius Werner 50a81748fd 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.)

Original-Change-Id: Ib440d1804126cdfdac4a8801f5015b4487e25269
Original-Signed-off-by: Julius Werner <jwerner@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/202563
Original-Reviewed-by: Stefan Reinauer <reinauer@chromium.org>
(cherry picked from commit 9c4a642c7be2faf122fef39bdfaddd64aec68b77)
Signed-off-by: Marc Jones <marc.jones@se-eng.com>

Change-Id: I9238b4eb19d3ab2c98e4e1c5946cd7d252ca3c3b
Reviewed-on: http://review.coreboot.org/8119
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2015-01-09 07:06:51 +01:00
..
arch libpayload: Add remote GDB support 2015-01-09 07:06:51 +01:00
bin libpayload: Add support for arm64 in libpayload 2015-01-09 07:04:28 +01:00
configs libpayload: Introduce new Kconfig to explicitly allow GPL code 2015-01-09 07:06:27 +01:00
crypto libpayload: Change CONFIG_* to CONFIG_LP_* in the kconfig. 2014-08-05 18:44:08 +02:00
curses libpayload/PDcurses: avoid NULL deref 2015-01-03 23:58:22 +01:00
drivers libpayload: ipq808x: introduce uart driver 2015-01-06 16:57:30 +01:00
gdb libpayload: Add remote GDB support 2015-01-09 07:06:51 +01:00
include libpayload: Add remote GDB support 2015-01-09 07:06:51 +01:00
libc libpayload: Add ability to unregister output driver 2015-01-09 07:04:58 +01:00
libcbfs libpayload: Fix pointer related casts 2014-12-31 18:57:35 +01:00
liblzma LZMA: Add a version of ulzma which takes the input and output buffer sizes. 2014-08-10 22:29:51 +02:00
libpci
sample libpayload: Fix missed CONFIG_ -> CONFIG_LP_ substitutions 2014-10-17 11:24:15 +02:00
tests libpayload: Change CONFIG_X86_SERIAL_CONSOLE to CONFIG_8250_SERIAL_CONSOLE 2014-08-28 01:40:48 +02:00
util libpayload: Add support for arm64 in libpayload 2015-01-09 07:04:28 +01:00
Config.in libpayload: Add remote GDB support 2015-01-09 07:06:51 +01:00
Doxyfile
LICENSES libpayload: Introduce new Kconfig to explicitly allow GPL code 2015-01-09 07:06:27 +01:00
LICENSE_GPL libpayload: Introduce new Kconfig to explicitly allow GPL code 2015-01-09 07:06:27 +01:00
Makefile libpayload: Add support for arm64 in libpayload 2015-01-09 07:04:28 +01:00
Makefile.inc libpayload: Add remote GDB support 2015-01-09 07:06:51 +01:00
README

README

-------------------------------------------------------------------------------
libpayload README
-------------------------------------------------------------------------------

libpayload is a minimal library to support standalone payloads
that can be booted with firmware like coreboot. It handles the setup
code, and provides common C library symbols such as malloc() and printf().

Note: This is _not_ a standard library for use with an operating system,
rather it's only useful for coreboot payload development!
See http://coreboot.org for details on coreboot.


Installation
------------

 $ git clone http://review.coreboot.org/p/coreboot.git

 $ cd coreboot/payloads/libpayload

 $ make menuconfig

 $ make

 $ sudo make install (optional, will install into /opt per default)

As libpayload is for 32bit x86 systems only, you might have to install the
32bit libgcc version, otherwise your payloads will fail to compile.
On Debian systems you'd do 'apt-get install gcc-multilib' for example.


Usage
-----

Here's an example of a very simple payload (hello.c) and how to build it:

 #include <libpayload.h>

 int main(void)
 {
     printf("Hello, world!\n");
     return 0;
 }

Building the payload using the 'lpgcc' compiler wrapper:

 $ lpgcc -o hello.elf hello.c

Please see the sample/ directory for details.


Website and Mailing List
------------------------

The main website is http://www.coreboot.org/Libpayload.

For additional information, patches, and discussions, please join the
coreboot mailing list at http://coreboot.org/Mailinglist, where most
libpayload developers are subscribed.


Copyright and License
---------------------

See LICENSES.