1 | i386/pc386 GDB Stub |
---|
2 | |
---|
3 | The i386 GDB stub has been updated to use the libchip drivers for the |
---|
4 | NS16550. Make sure you have detect the device and you have added a console |
---|
5 | entry. On the PC the legacy and PCI boards are supported. |
---|
6 | |
---|
7 | This GDB stub glue code is specific to the UART protocol defined in libbchip. |
---|
8 | |
---|
9 | The pc386 BSP has boot command line options to manage GDB support. |
---|
10 | |
---|
11 | a) Find the minor number of the console device: |
---|
12 | |
---|
13 | #include <console_private.h> |
---|
14 | |
---|
15 | rtems_device_minor_number minor = 0; |
---|
16 | |
---|
17 | if (console_find_console_entry("/dev/com1", |
---|
18 | strlen("/dev/com1") - 1, &minor) == NULL) |
---|
19 | error("driver not found\n"); |
---|
20 | |
---|
21 | Note, this call is part of the private console API and may change. |
---|
22 | |
---|
23 | b) To start GDB stub, run this: |
---|
24 | |
---|
25 | #include <bsp.h> |
---|
26 | |
---|
27 | /* Init GDB glue */ |
---|
28 | i386_stub_glue_init(minor); |
---|
29 | |
---|
30 | /* Init GDB stub itself */ |
---|
31 | set_debug_traps(); |
---|
32 | |
---|
33 | /* |
---|
34 | * Init GDB break in capability, |
---|
35 | * has to be called after |
---|
36 | * set_debug_traps |
---|
37 | */ |
---|
38 | i386_stub_glue_init_breakin(); |
---|
39 | |
---|
40 | /* Put breakpoint in */ |
---|
41 | breakpoint(); |
---|
42 | |
---|
43 | c) To run use GDB: |
---|
44 | |
---|
45 | $ i386-rtems4.12-gdb hello.exe |
---|
46 | GNU gdb (GDB) 7.11 |
---|
47 | Copyright (C) 2016 Free Software Foundation, Inc. |
---|
48 | License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> |
---|
49 | This is free software: you are free to change and redistribute it. |
---|
50 | There is NO WARRANTY, to the extent permitted by law. Type "show copying" |
---|
51 | and "show warranty" for details. |
---|
52 | This GDB was configured as "--host=x86_64-freebsd10.1 --target=i386-rtems4.12". |
---|
53 | Type "show configuration" for configuration details. |
---|
54 | For bug reporting instructions, please see: |
---|
55 | <http://www.gnu.org/software/gdb/bugs/>. |
---|
56 | Find the GDB manual and other documentation resources online at: |
---|
57 | <http://www.gnu.org/software/gdb/documentation/>. |
---|
58 | For help, type "help". |
---|
59 | Type "apropos word" to search for commands related to "word"... |
---|
60 | Reading symbols from hello.exe...done. |
---|
61 | (gdb) target remote /dev/cuaU5 |
---|
62 | Remote debugging using /dev/cuaU5 |
---|
63 | 0x00103fda in breakpoint () at i386-stub.c:1004 |
---|
64 | 1004 BREAKPOINT (); |
---|
65 | (gdb) b Init |
---|
66 | Breakpoint 1 at 0x1001e0: file init.c, line 29. |
---|
67 | (gdb) c |
---|
68 | Continuing. |
---|
69 | |
---|
70 | Breakpoint 1, Init (ignored=1269800) at init.c:29 |
---|
71 | 29 { |
---|
72 | (gdb) |
---|
73 | |
---|
74 | Pressing ^C works and if running the board should halt when GDB connects. |
---|
75 | |
---|
76 | e) Use ser2net to provide reomve access over a network to a board. Install the |
---|
77 | ser2net package and add a configuration for the port GDB connects to. For |
---|
78 | example: |
---|
79 | |
---|
80 | 0005:raw:0:/dev/cuaU5:115200 |
---|
81 | |
---|
82 | Start ser2net running then connect GDB using: |
---|
83 | |
---|
84 | (gdb) target remote myhost:30005 |
---|