gdb_hooks.h
Go to the documentation of this file.
1 /*
2  gdb_hooks.h - Hooks for GDB Stub library
3  Copyright (c) 2018 Ivan Grokhotkov. All right reserved.
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 2.1 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public
16  License along with this library; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19 
20 #pragma once
21 
22 #include <user_config.h>
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
36 void gdb_init(void);
37 
50 void gdb_enable(bool state);
51 
55 #ifdef ENABLE_GDB
56 #ifdef ARCH_HOST
57 #define gdb_do_break() __asm__("int $0x03")
58 #else
59 #define gdb_do_break() __asm__("break 0,0")
60 #endif
61 #else
62 #define gdb_do_break() \
63  do { \
64  } while(0)
65 #endif
66 
67 typedef enum {
71 } GdbState;
72 
76 GdbState gdb_present(void);
77 
82 void gdb_on_attach(bool attached);
83 
88 void gdb_detach();
89 
90 /*
91  * @brief Called by framekwork on unexpected system reset
92  */
93 void debug_crash_callback(const struct rst_info* rst_info, uint32_t stack, uint32_t stack_end);
94 
100 void debug_print_stack(uint32_t start, uint32_t end);
101 
102 #ifdef __cplusplus
103 } // extern "C"
104 #endif
105 
void gdb_detach()
Detach from GDB, if attached.
void gdb_on_attach(bool attached)
Called from task queue when GDB attachment status changes.
Definition: gdb_hooks.h:69
void debug_print_stack(uint32_t start, uint32_t end)
Send a stack dump to debug output.
GdbState
Definition: gdb_hooks.h:67
GdbState gdb_present(void)
Check if GDB stub is present.
Definition: gdb_hooks.h:70
void debug_crash_callback(const struct rst_info *rst_info, uint32_t stack, uint32_t stack_end)
void gdb_init(void)
Initialise GDB stub, if present.
void gdb_enable(bool state)
Dynamically enable/disable GDB stub.
Definition: gdb_hooks.h:68