Warning, /bsps/i386/pc386/console/README.md is written in an unsupported language. File is not indexed.
0001 i386/pc386 GDB Stub
0002 ===================
0003
0004 The i386 GDB stub has been updated to use the libchip drivers for the
0005 NS16550. Make sure you have detect the device and you have added a console
0006 entry. On the PC the legacy and PCI boards are supported.
0007
0008 This GDB stub glue code is specific to the UART protocol defined in libbchip.
0009
0010 The pc386 BSP has boot command line options to manage GDB support.
0011
0012 a) Find the minor number of the console device:
0013
0014 ```c
0015 #include <console_private.h>
0016
0017 rtems_device_minor_number minor = 0;
0018
0019 if (console_find_console_entry("/dev/com1",
0020 strlen("/dev/com1") - 1, &minor) == NULL)
0021 error("driver not found\n");
0022 ```
0023
0024 Note, this call is part of the private console API and may change.
0025
0026 b) To start GDB stub, run this:
0027
0028 ```c
0029 #include <bsp.h>
0030
0031 /* Init GDB glue */
0032 i386_stub_glue_init(minor);
0033
0034 /* Init GDB stub itself */
0035 set_debug_traps();
0036
0037 /*
0038 * Init GDB break in capability,
0039 * has to be called after
0040 * set_debug_traps
0041 */
0042 i386_stub_glue_init_breakin();
0043
0044 /* Put breakpoint in */
0045 breakpoint();
0046
0047 c) To run use GDB:
0048 ```
0049
0050 ```shell
0051 $ i386-rtems4.12-gdb hello.exe
0052 GNU gdb (GDB) 7.11
0053 Copyright (C) 2016 Free Software Foundation, Inc.
0054 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
0055 This is free software: you are free to change and redistribute it.
0056 There is NO WARRANTY, to the extent permitted by law. Type "show copying"
0057 and "show warranty" for details.
0058 This GDB was configured as "--host=x86_64-freebsd10.1 --target=i386-rtems4.12".
0059 Type "show configuration" for configuration details.
0060 For bug reporting instructions, please see:
0061 <http://www.gnu.org/software/gdb/bugs/>.
0062 Find the GDB manual and other documentation resources online at:
0063 <http://www.gnu.org/software/gdb/documentation/>.
0064 For help, type "help".
0065 Type "apropos word" to search for commands related to "word"...
0066 Reading symbols from hello.exe...done.
0067 (gdb) target remote /dev/cuaU5
0068 Remote debugging using /dev/cuaU5
0069 0x00103fda in breakpoint () at i386-stub.c:1004
0070 1004 BREAKPOINT ();
0071 (gdb) b Init
0072 Breakpoint 1 at 0x1001e0: file init.c, line 29.
0073 (gdb) c
0074 Continuing.
0075
0076 Breakpoint 1, Init (ignored=1269800) at init.c:29
0077 29 {
0078 (gdb)
0079 ```
0080
0081 Pressing ^C works and if running the board should halt when GDB connects.
0082
0083 e) Use ser2net to provide reomve access over a network to a board. Install the
0084 ser2net package and add a configuration for the port GDB connects to. For
0085 example:
0086
0087 ```shell
0088 0005:raw:0:/dev/cuaU5:115200
0089 ```
0090
0091 Start ser2net running then connect GDB using:
0092
0093 ```shell
0094 (gdb) target remote myhost:30005
0095 ```