source: rtems/bsps/lm32/shared/gdbstub/README @ fd67814

Last change on this file since fd67814 was fd67814, checked in by Sebastian Huber <sebastian.huber@…>, on Apr 23, 2018 at 10:06:14 AM

bsps: Move GDB stubs to bsps

This patch is a part of the BSP source reorganization.

Update #3285.

  • Property mode set to 100644
File size: 3.0 KB
1This is a thread-aware gdb stub for the lm32 architecture. It has to be
2linked with the application, which should be debugged. The application has
3to call 'lm32_gdb_stub_install' to setup the stub.
4   The stub remaps _all_ h/w exceptions to an own code (lm32-debug.S), which
5saves all the registers, calls the gdb stub and restores the registers again.
6   The interrupt exceptions gets handled in a special way. Because we remapped
7this exception, we need to do
8 - the same as the original one (in cpu_asm.S),
9 - and, as we might use an ISR for breaking into a running application with
10   gdb, we need to save all registers as well. To be backward compatible
11   the missing callee saved registers gets appended to CPU_Interrupt_frame.
12   There is a mapping in 'gdb_handle_break' for that.
14To use this gdb stub, your bsp has to provide the following functions:
15 - void gdb_put_debug_char(char c)
16   Puts the given charater c to the debug console output. The function can
17   block until the character can be written to the output buffer.
19 - char gdb_get_debug_char(void)
20   Returns the character in the input buffer of the debug console. If no one
21   is availabe, the function must block.
23 - void gdb_console_init()
24   This function can be used to initialize the debug console. Additionally,
25   it should set up the ISR for the debug console to call the function
26   'gdb_handle_break', which is provided by the gdb stub and enable the
27   interrupt for a break symbol on the debug serial port. If no ISR is
28   provided, you won't be able to interrupt a running application.
30 - void gdb_ack_irq()
31   If an ISR is used, this function is used to acknowledge the interrupt.
33NOTE: the stub don't skip a hardcoded 'break' in the code. So you have to
34   set the PC an instruction further in the debugger (set $pc += 4).
36NOTE2: make sure you have the following CFLAGS set:
37     -mbarrel-shift-enabled -mmultiply-enabled -mdivide-enabled
38     -msign-extend-enabled
39   Without the hardware support, it is done in software. Unfortunately, the
40   stub also uses some shifts and multiplies. If you step through your code,
41   there will be a chance that a breakpoint is set to one of that functions,
42   which then causes an endless loop.
47  char gdb_get_debug_char(void)
48  {
49    /* Wait until there is a byte in RXTX */
50    while (!(uartread(LM32_UART_LSR) & LM32_UART_LSR_DR));
52    return (char) uartread(LM32_UART_RBR);
53  }
55  void gdb_put_debug_char(char c)
56  {
57    /* Wait until RXTX is empty. */
58    while (!(uartread(LM32_UART_LSR) & LM32_UART_LSR_THRE));
59    uartwrite(LM32_UART_RBR, c);
60  }
62  extern void gdb_handle_break(
63    rtems_vector_number vector,
64    CPU_Interrupt_frame *frame
65  );
66  void gdb_console_init()
67  {
68    rtems_isr_entry old;
70    /* enable interrupts */
71    uartwrite(LM32_UART_IER, 1);
73    rtems_interrupt_catch((rtems_isr_entry) gdb_handle_break, DEBUG_UART_IRQ,
74      &old);
75    lm32_interrupt_unmask(1 << DEBUG_UART_IRQ);
76  }
78  void gdb_ack_irq()
79  {
80    lm32_interrupt_ack(1 << DEBUG_UART_IRQ);
81  }
Note: See TracBrowser for help on using the repository browser.