From d469a097bd86201dbd0888ac2bb6bdc7b13b9c3c Mon Sep 17 00:00:00 2001 From: Fernando Trias Date: Thu, 18 Jun 2020 08:47:41 -0400 Subject: [PATCH] add debug.isGDBConnected() --- TeensyDebug.h | 2 ++ gdbstub.cpp | 3 +++ 2 files changed, 5 insertions(+) diff --git a/TeensyDebug.h b/TeensyDebug.h index 8a184ed..0641774 100644 --- a/TeensyDebug.h +++ b/TeensyDebug.h @@ -74,6 +74,7 @@ int hcdebug_setBreakpoint(int n); size_t gdb_out_write(const uint8_t *msg, size_t len); int gdb_file_io(const char *msg); extern int file_io_errno; +extern int gdb_active_flag; #define O_CREAT 0x200 #define O_APPEND 8 @@ -117,6 +118,7 @@ public: uint32_t getRegister(const char *reg); int setRegister(const char *reg, uint32_t value); int restoreRunMode(); + int isGDBConnected() { return gdb_active_flag; } virtual size_t write(uint8_t b) { return write(&b, 1); diff --git a/gdbstub.cpp b/gdbstub.cpp index 6f8a3f7..3bf07a6 100644 --- a/gdbstub.cpp +++ b/gdbstub.cpp @@ -953,6 +953,8 @@ int process_k(const char *cmd, char *result) { return 0; } +int gdb_active_flag = 0; + /** * @brief Process a command by calling appropriate delegation function * @@ -961,6 +963,7 @@ int process_k(const char *cmd, char *result) { * @return int 0 */ int processCommand(const char *cmd, char *result) { + gdb_active_flag = 1; switch(cmd[0]) { case 'g': return process_g(cmd, result); case 'G': return process_G(cmd, result);