RTEMS 5.2
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
rtems-debugger-target.h
1/*
2 * Copyright (c) 2016-2017 Chris Johns <chrisj@rtems.org>.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27/*
28 * Debugger for RTEMS.
29 */
30
31#ifndef _RTEMS_DEBUGGER_TARGET_h
32#define _RTEMS_DEBUGGER_TARGET_h
33
34#include <setjmp.h>
35
36#include <rtems/rtems-debugger.h>
37
38#include "rtems-debugger-threads.h"
39
40#ifdef __cplusplus
41extern "C" {
42#endif /* __cplusplus */
43
44/*
45 * Software breakpoint block size.
46 */
47#define RTEMS_DEBUGGER_TARGET_SWBREAK_NUM 64
48
52#define RTEMS_DEBUGGER_TARGET_CAP_SWBREAK (1 << 0)
53#define RTEMS_DEBUGGER_TARGET_CAP_HWBREAK (1 << 1)
54#define RTEMS_DEBUGGER_TARGET_CAP_HWWATCH (1 << 2)
55
59typedef enum rtems_debugger_target_watchpoint
60{
61 rtems_debugger_target_hw_read,
62 rtems_debugger_target_hw_write,
63 rtems_debugger_target_hw_read_write,
64 rtems_debugger_target_hw_execute
65} rtems_debugger_target_watchpoint;
66
70typedef enum rtems_debugger_target_exc_action
71{
72 rtems_debugger_target_exc_consumed, /*<< The exception has been consumed. */
73 rtems_debugger_target_exc_cascade, /*<< Cascade to a previous handler. */
74 rtems_debugger_target_exc_step, /*<< Step an instruction. */
75} rtems_debugger_target_exc_action;
76
80#define RTEMS_DEBUGGER_TARGET_SWBREAK_MAX_SIZE (4)
82 void* address;
83 uint8_t contents[RTEMS_DEBUGGER_TARGET_SWBREAK_MAX_SIZE];
85
93typedef struct rtems_debugger_target {
94 int capabilities; /*<< The capabilities to report. */
95 size_t reg_num; /*<< The number of registers. */
96 const size_t* reg_offset; /*<< The reg offsettable, len = reg_num + 1. */
97 const uint8_t* breakpoint; /*<< The breakpoint instruction(s). */
98 size_t breakpoint_size; /*<< The breakpoint size. */
99 rtems_debugger_block swbreaks; /*<< The software breakpoint block. */
100 bool memory_access; /*<< Accessing target memory. */
101 jmp_buf access_return; /*<< Return from an access fault. */
103
107extern int rtems_debugger_target_create(void);
108
112extern int rtems_debugger_target_destroy(void);
113
117extern int rtems_debugger_target_configure(rtems_debugger_target* target);
118
122extern int rtems_debugger_target_enable(void);
123
127extern int rtems_debugger_target_disable(void);
128
132extern uint32_t rtems_debugger_target_capabilities(void);
133
137extern size_t rtems_debugger_target_reg_num(void);
138
142extern size_t rtems_debugger_target_reg_size(size_t reg);
143
147extern size_t rtems_debugger_target_reg_offset(size_t reg);
148
152extern size_t rtems_debugger_target_reg_table_size(void);
153
157extern int rtems_debugger_target_read_regs(rtems_debugger_thread* thread);
158
162extern int rtems_debugger_target_write_regs(rtems_debugger_thread* thread);
163
167extern DB_UINT rtems_debugger_target_reg_pc(rtems_debugger_thread* thread);
168
172extern DB_UINT rtems_debugger_target_frame_pc(CPU_Exception_frame* frame);
173
177extern DB_UINT rtems_debugger_target_reg_sp(rtems_debugger_thread* thread);
178
182extern DB_UINT rtems_debugger_target_tcb_sp(rtems_debugger_thread* thread);
183
187extern int rtems_debugger_target_thread_stepping(rtems_debugger_thread* thread);
188
192extern int rtems_debugger_target_exception_to_signal(CPU_Exception_frame* frame);
193
197extern void rtems_debugger_target_exception_print(CPU_Exception_frame* frame);
198
202extern int rtems_debugger_target_swbreak_control(bool insert,
203 DB_UINT addr,
204 DB_UINT kind);
205
209extern int rtems_debugger_target_swbreak_insert(void);
210
214extern int rtems_debugger_target_swbreak_remove(void);
215
219extern int rtems_debugger_target_hwbreak_insert(void);
220
224extern int rtems_debugger_target_hwbreak_remove(void);
225
229extern int rtems_debugger_target_hwbreak_control(rtems_debugger_target_watchpoint type,
230 bool insert,
231 DB_UINT addr,
232 DB_UINT kind);
233
237extern rtems_debugger_target_exc_action
238rtems_debugger_target_exception(CPU_Exception_frame* frame);
239
243extern void rtems_debugger_target_exception_thread(rtems_debugger_thread* thread);
244
248extern void rtems_debugger_target_exception_thread_resume(rtems_debugger_thread* thread);
249
254extern int rtems_debugger_target_cache_sync(rtems_debugger_target_swbreak* swbreak);
255
260extern int rtems_debugger_target_start_memory_access(void);
261
265extern void rtems_debugger_target_end_memory_access(void);
266
270extern bool rtems_debugger_target_is_memory_access(void);
271
272#ifdef __cplusplus
273}
274#endif /* __cplusplus */
275
276
277#endif
The set of registers that specifies the complete processor state.
Definition: cpu.h:629
Definition: rtems-debugger-block.h:46
Definition: rtems-debugger-target.h:81
Definition: rtems-debugger-target.h:93
Definition: rtems-debugger-threads.h:87