gdbstub-internal.h
Go to the documentation of this file.
1 /****
2  * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development.
3  * Created 2015 by Skurydin Alexey
4  * http://github.com/SmingHub/Sming
5  * All files of the Sming Core are provided under the LGPL v3 license.
6  *
7  * @author: 2019 - Mikee47 <mike@sillyhouse.net>
8  *
9  * Standard definitions for gdbstub code modules, both C++ and assembler (.S only).
10  *
11  ****/
12 
13 #pragma once
14 
15 #define XCHAL_CP0_SA_SIZE 0
16 #define XCHAL_CP0_SA_ALIGN 1
17 #define XCHAL_CP1_SA_SIZE 0
18 #define XCHAL_CP1_SA_ALIGN 1
19 #define XCHAL_CP2_SA_SIZE 0
20 #define XCHAL_CP2_SA_ALIGN 1
21 #define XCHAL_CP3_SA_SIZE 0
22 #define XCHAL_CP3_SA_ALIGN 1
23 #define XCHAL_CP4_SA_SIZE 0
24 #define XCHAL_CP4_SA_ALIGN 1
25 #define XCHAL_CP5_SA_SIZE 0
26 #define XCHAL_CP5_SA_ALIGN 1
27 #define XCHAL_CP6_SA_SIZE 0
28 #define XCHAL_CP6_SA_ALIGN 1
29 #define XCHAL_CP7_SA_SIZE 0
30 #define XCHAL_CP7_SA_ALIGN 1
31 #include "xtensa/xtruntime-frames.h"
32 #include "gdbstub-cfg.h"
33 
34 #define UINT32_T unsigned int
35 
36 /*
37  * Defines our debugging exception frame which is provided to GDB when paused.
38  * Our exception handlers save register values here, restoring them on continuation.
39  * Any register changes made by GDB are stored here.
40  *
41  * System exceptions are initially handled by the Xtensa HAL, which saves some (but not all)
42  * registers into a `UserFrame` structure (see xtensa/xtruntime-frames.h).
43  * Control passes to gdbstub_exception_handler, which copies those values plus some extra ones.
44  *
45  * Debug exceptions are handled entirely by gdbstub_debug_exception_entry, which saves
46  * registers, calls gdbstub_handle_debug_exception, then restores them.
47  *
48  * Using the macros provided by xtensa allow changes to this structure to be reflected into
49  * both C and assembler code.
50  */
51 STRUCT_BEGIN
52 STRUCT_FIELD(UINT32_T, 4, GDBSR_, pc)
53 STRUCT_FIELD(UINT32_T, 4, GDBSR_, ps)
54 STRUCT_FIELD(UINT32_T, 4, GDBSR_, sar)
55 STRUCT_FIELD(UINT32_T, 4, GDBSR_, vpri)
56 STRUCT_AFIELD(UINT32_T, 4, GDBSR_, a, 16) // a0..a15
57 #define GDBSR_A(n) GDBSR_a + ((n)*4)
58 // These are added manually by the exception code; the HAL doesn't set these on an exception.
59 STRUCT_FIELD(UINT32_T, 4, GDBSR_, litbase)
60 STRUCT_FIELD(UINT32_T, 4, GDBSR_, sr176)
61 STRUCT_FIELD(UINT32_T, 4, GDBSR_, sr208)
62 STRUCT_FIELD(UINT32_T, 4, GDBSR_, cause)
63 STRUCT_FIELD(UINT32_T, 4, GDBSR_, excvaddr)
64 STRUCT_END(GdbstubSavedRegisters)
65 
66 #undef UINT32_T
67 
68 // Don't include debug output for this module unless excplitly requested
69 #if GDBSTUB_ENABLE_DEBUG == 0
70 #undef DEBUG_BUILD
71 #define DEBUG_BUILD 0
72 #endif
73 
74 #if(defined(ENABLE_GDB) && GDBSTUB_BREAK_ON_EXCEPTION) || ENABLE_EXCEPTION_DUMP
75 #define HOOK_SYSTEM_EXCEPTIONS
76 #endif
77 
78 /*
79  * Code memory allocation attributes
80  */
81 #define ATTR_GDBINIT ICACHE_FLASH_ATTR
82 
83 #if GDBSTUB_FORCE_IRAM
84 #define ATTR_GDBEXTERNFN IRAM_ATTR
85 #else
86 #define ATTR_GDBEXTERNFN ICACHE_FLASH_ATTR
87 #endif
88 
89 // Section definitions for assembler
90 #define ASATTR_GDBINIT .section .irom0.text
91 #define ASATTR_GDBFN .section .iram.text
STRUCT_BEGIN STRUCT_AFIELD(UINT32_T, 4, GDBSR_, a, 16) STRUCT_FIELD(UINT32_T
STRUCT_BEGIN GDBSR_
Definition: gdbstub-internal.h:62
#define UINT32_T
Definition: gdbstub-internal.h:34