mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-27 18:02:17 +03:00
GDB support w/new toolchain and UART driver (#5559)
* Add full gdb support with uart/Serial integration * Fix GDB merge errors * Update to unpatched GDB protocol specification It appears that Espressif patched the open source xtensa GDB port in order to build their old GDB executable and their old gdbstub (basically removing any register in a generic xtensa and only leaving those present in the chip they synthesized). Their GDBStub also assumed this behavior. Unpatched upstream GNU GDB now expects all the registers in xtensa-config.c to be sent/read on a 'g' command. Change the GDB stub to send "xxxxxxxx"s (legal per the spec) for unimplemented registers. This makes the 'g' response much longer, but it's results are cached and in an interactive debugger it isn't noticeable. * Fix .iram.literal to come before .iram.text for GDB * Move functions to flash, call using wrappers All functions which are not interrupt or exception called are now in flash. A small IRAM wrapper enables flash when processing main GDB ops by calling Cache_Read_Enable_New() and then jumping to the main flash code. This seems to work for catching exceptions, data and code breaks, and Ctrl-C. The UART ISR handler and exception handler register-saving bits of code in ASM are still in IRAM. GDB IRAM usage is now about 670 bytes. * Remove LWIP2 builder commit * Add documentation and gdbstub_init header Add some simple GDB documentation to the main tree showing a worked example. Adds the definition of `void gdbstub_init()` to <GDBStub.h> * Clean up GDB include and library dir Replace GDBstub.h with the version in the internal/ directory, and adjust stub code accordingly. This way, only one copy of a file called "GDBstub.h" will exist. Update the gdbcommands and replace the obsolete ESPRESSIF readme with @kylefleming's version since we're mainly doing serial, not TCP, connected debugging. Bump the library rev. number since this is a pretty big functionality change. Minor documentation tweak. * Undo much of UART refactoring, set fifo IRQ to 16 Remove the refactoring of pin control and other little things not directly related to GDB processing. Should greatly reduce the diff size in uart.c. Should also remove any register value changes (intended or otherwise) introduced in the original PR from @kylefleming. Set the FIFO interrupt to 16 chars when in GDB mode, matching the latest UART configuration for highest speed. * Add architecture comments, cleanup uart.c code Comments added to UART.c trying to explain (as best as I understand it) the changes done to support GDB and how they interact with standard operation. Fix the uart_uninit to stop the ISR and then free appropriately. Fix uart_isr_handle_data (GDB's shim for sending chars to the 8266 app) to do the exact same thing as the standard UART handler including set the overflow properly and either discard or overwrite in that case. Fix serial reception when GDB enabled by enabling the user recv ISR. Remove commented attributes from gdbstub, leftover from the move to flash. General logic cleanup per comments in the PR. * Also set the UART flags for HW error in GDB Ensure we also check the UART flags and set the uart status appropriately when in GDB mode.
This commit is contained in:
committed by
Develo
parent
4657666319
commit
bff3a6d963
@ -1,5 +1,5 @@
|
||||
#ifndef GDBSTUB_CFG_H
|
||||
#define GDBSTUB_CFG_H
|
||||
#define GDBSTUB_CFG_H
|
||||
|
||||
/*
|
||||
Enable this define if you're using the RTOS SDK. It will use a custom exception handler instead of the HAL
|
||||
@ -19,6 +19,14 @@ stops when you run into an error in your code, try enabling this.
|
||||
#define GDBSTUB_USE_OWN_STACK 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
Enable this to cause the program to pause and wait for gdb to be connected when an exception is
|
||||
encountered.
|
||||
*/
|
||||
#ifndef GDBSTUB_BREAK_ON_EXCEPTION
|
||||
#define GDBSTUB_BREAK_ON_EXCEPTION 1
|
||||
#endif
|
||||
|
||||
/*
|
||||
If this is defined, gdbstub will break the program when you press Ctrl-C in gdb. it does this by
|
||||
hooking the UART interrupt. Unfortunately, this means receiving stuff over the serial port won't
|
||||
@ -26,7 +34,7 @@ work for your program anymore. This will fail if your program sets an UART inter
|
||||
the gdbstub_init call.
|
||||
*/
|
||||
#ifndef GDBSTUB_CTRLC_BREAK
|
||||
#define GDBSTUB_CTRLC_BREAK 0
|
||||
#define GDBSTUB_CTRLC_BREAK 1
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -35,7 +43,7 @@ will show up in your gdb session, which is useful if you use gdb to do stuff. It
|
||||
you use a normal terminal, you can't read the printfs anymore.
|
||||
*/
|
||||
#ifndef GDBSTUB_REDIRECT_CONSOLE_OUTPUT
|
||||
#define GDBSTUB_REDIRECT_CONSOLE_OUTPUT 0
|
||||
#define GDBSTUB_REDIRECT_CONSOLE_OUTPUT 1
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -55,7 +63,25 @@ flash somehow is disabled (eg during SPI operations or flash write/erase operati
|
||||
are called when the flash is disabled (eg due to a Ctrl-C at the wrong time), the ESP8266 will most
|
||||
likely crash.
|
||||
*/
|
||||
#define ATTR_GDBINIT ICACHE_FLASH_ATTR
|
||||
#define ATTR_GDBFN ICACHE_RAM_ATTR
|
||||
#ifndef ATTR_GDBINIT
|
||||
#define ATTR_GDBINIT ICACHE_FLASH_ATTR
|
||||
#endif
|
||||
#ifndef ATTR_GDBFN
|
||||
#define ATTR_GDBFN ICACHE_RAM_ATTR
|
||||
#endif
|
||||
#ifndef ATTR_GDBEXTERNFN
|
||||
#define ATTR_GDBEXTERNFN ICACHE_FLASH_ATTR
|
||||
#endif
|
||||
|
||||
#ifndef ASATTR_GDBINIT
|
||||
#define ASATTR_GDBINIT .section .irom0.text
|
||||
#endif
|
||||
#ifndef ASATTR_GDBFN
|
||||
#define ASATTR_GDBFN .section .iram.text
|
||||
#endif
|
||||
#ifndef ASATTR_GDBEXTERNFN
|
||||
#define ASATTR_GDBEXTERNFN .section .irom0.text
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user