Skip to content

[Needs testing] Add full gdb support with uart/Serial integration #4386

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions cores/esp8266/gdb_hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,18 @@
value is in register, it doesn't hurt to return a bool, so that the
same stub can be used for gdb_present. */

bool ICACHE_RAM_ATTR __gdb_no_op()
static bool ICACHE_RAM_ATTR __gdb_no_op()
{
return false;
}

extern void gdb_init(void) __attribute__ ((weak, alias("__gdb_no_op")));
extern void gdb_do_break(void) __attribute__ ((weak, alias("__gdb_no_op")));
extern bool gdb_present(void) __attribute__ ((weak, alias("__gdb_no_op")));
void gdb_init(void) __attribute__ ((weak, alias("__gdb_no_op")));
void gdb_do_break(void) __attribute__ ((weak, alias("__gdb_no_op")));
bool gdb_present(void) __attribute__ ((weak, alias("__gdb_no_op")));
bool gdbstub_has_putc1_control(void) __attribute__ ((weak, alias("__gdb_no_op")));
void gdbstub_set_putc1_callback(void (*func)(char)) __attribute__ ((weak, alias("__gdb_no_op")));
bool gdbstub_has_uart_isr_control(void) __attribute__ ((weak, alias("__gdb_no_op")));
void gdbstub_set_uart_isr_callback(void (*func)(void*, uint8_t), void* arg) __attribute__ ((weak, alias("__gdb_no_op")));
void gdbstub_write_char(char c) __attribute__ ((weak, alias("__gdb_no_op")));
void gdbstub_write(const char* buf, size_t size) __attribute__ ((weak, alias("__gdb_no_op")));

65 changes: 65 additions & 0 deletions cores/esp8266/gdb_hooks.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,71 @@ void gdb_do_break(void);
*/
bool gdb_present(void);

// If gdbstub has these set true, then we will disable our own
// usage of them, but use gdbstub's callbacks for them instead
/**
* @brief Check if GDB is installing a putc1 callback.
*
* By default, this function returns false. When GDBStub library is linked,
* this function is overriden and returns true.
*
* @return true if GDB is installing a putc1 callback
*/
bool gdbstub_has_putc1_control(void);

/**
* @brief Register a putc1 callback with GDB.
* @param func function GDB will proxy putc1 data to
*
* By default, this function is a no-op. When GDBStub library is linked,
* this function is overriden and sets GDB stub's secondary putc1 callback to
* func. When GDB stub is linked, but a GDB session is not current attached,
* then GDB stub will pass putc1 chars directly to this function.
*/
void gdbstub_set_putc1_callback(void (*func)(char));

/**
* @brief Check if GDB is installing a uart0 isr callback.
*
* By default, this function returns false. When GDBStub library is linked,
* this function is overriden and returns true.
*
* @return true if GDB is installing a uart0 isr callback
*/
bool gdbstub_has_uart_isr_control(void);

/**
* @brief Register a uart0 isr callback with GDB.
* @param func function GDB will proxy uart0 isr data to
*
* By default, this function is a no-op. When GDBStub library is linked,
* this function is overriden and sets GDB stub's secondary uart0 isr callback
* to func. When GDB stub is linked, but a GDB session is not current attached,
* then GDB stub will pass uart0 isr data back to this function.
*/
void gdbstub_set_uart_isr_callback(void (*func)(void*, uint8_t), void* arg);

/**
* @brief Write a character for output to a GDB session on uart0.
* @param c character to write
*
* By default, this function is a no-op. When GDBStub library is linked,
* this function is overriden and writes a char to either the GDB session on
* uart0 or directly to uart0 if not GDB session is attached.
*/
void gdbstub_write_char(char c);

/**
* @brief Write a char buffer for output to a GDB session on uart0.
* @param buf buffer of data to write
* @param size length of buffer
*
* By default, this function is a no-op. When GDBStub library is linked,
* this function is overriden and writes a buffer to either the GDB session on
* uart0 or directly to uart0 if not GDB session is attached.
*/
void gdbstub_write(const char* buf, size_t size);

#ifdef __cplusplus
}
#endif
Loading