RTEMS 6.1-rc2
Loading...
Searching...
No Matches
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/*
56 * This target capability indicates that the target implementation uses a pure
57 * software break implementation which must not allow breakpoints to be
58 * inserted before the actual switch to the thread, be it in interrupt context
59 * or otherwise. Such implementations must necessarily implement a thread
60 * switch hook and interrupt hooks to handle these situations.
61 */
62#define RTEMS_DEBUGGER_TARGET_CAP_PURE_SWBREAK (1 << 3)
63
67typedef enum rtems_debugger_target_watchpoint
68{
69 rtems_debugger_target_hw_read,
70 rtems_debugger_target_hw_write,
71 rtems_debugger_target_hw_read_write,
72 rtems_debugger_target_hw_execute
73} rtems_debugger_target_watchpoint;
74
78typedef enum rtems_debugger_target_exc_action
79{
80 rtems_debugger_target_exc_consumed, /*<< The exception has been consumed. */
81 rtems_debugger_target_exc_cascade, /*<< Cascade to a previous handler. */
82 rtems_debugger_target_exc_step, /*<< Step an instruction. */
83} rtems_debugger_target_exc_action;
84
88#define RTEMS_DEBUGGER_TARGET_SWBREAK_MAX_SIZE (4)
90 void* address;
91 uint8_t contents[RTEMS_DEBUGGER_TARGET_SWBREAK_MAX_SIZE];
93
101typedef struct rtems_debugger_target {
102 int capabilities; /*<< The capabilities to report. */
103 size_t reg_num; /*<< The number of registers. */
104 const size_t* reg_offset; /*<< The reg offsettable, len = reg_num + 1. */
105 const uint8_t* breakpoint; /*<< The breakpoint instruction(s). */
106 size_t breakpoint_size; /*<< The breakpoint size. */
107 rtems_debugger_block swbreaks; /*<< The software breakpoint block. */
108 bool memory_access; /*<< Accessing target memory. */
109 jmp_buf access_return; /*<< Return from an access fault. */
111
115extern int rtems_debugger_target_create(void);
116
120extern int rtems_debugger_target_destroy(void);
121
125extern int rtems_debugger_target_configure(rtems_debugger_target* target);
126
130extern int rtems_debugger_target_enable(void);
131
135extern int rtems_debugger_target_disable(void);
136
140extern uint32_t rtems_debugger_target_capabilities(void);
141
145extern size_t rtems_debugger_target_reg_num(void);
146
150extern size_t rtems_debugger_target_reg_size(size_t reg);
151
155extern size_t rtems_debugger_target_reg_offset(size_t reg);
156
160extern size_t rtems_debugger_target_reg_table_size(void);
161
165extern int rtems_debugger_target_read_regs(rtems_debugger_thread* thread);
166
170extern int rtems_debugger_target_write_regs(rtems_debugger_thread* thread);
171
175extern uintptr_t rtems_debugger_target_reg_pc(rtems_debugger_thread* thread);
176
180extern uintptr_t rtems_debugger_target_frame_pc(CPU_Exception_frame* frame);
181
185extern uintptr_t rtems_debugger_target_reg_sp(rtems_debugger_thread* thread);
186
190extern uintptr_t rtems_debugger_target_tcb_sp(rtems_debugger_thread* thread);
191
195extern int rtems_debugger_target_thread_stepping(rtems_debugger_thread* thread);
196
200extern int rtems_debugger_target_exception_to_signal(CPU_Exception_frame* frame);
201
205extern void rtems_debugger_target_exception_print(CPU_Exception_frame* frame);
206
210extern int rtems_debugger_target_swbreak_control(bool insert,
211 uintptr_t addr,
212 DB_UINT kind);
213
217extern int rtems_debugger_target_swbreak_insert(void);
218
222extern int rtems_debugger_target_swbreak_remove(void);
223
227extern bool rtems_debugger_target_swbreak_is_configured( uintptr_t addr );
228
232extern int rtems_debugger_target_hwbreak_insert(void);
233
237extern int rtems_debugger_target_hwbreak_remove(void);
238
242extern int rtems_debugger_target_hwbreak_control(rtems_debugger_target_watchpoint type,
243 bool insert,
244 uintptr_t addr,
245 DB_UINT kind);
246
250extern rtems_debugger_target_exc_action
251rtems_debugger_target_exception(CPU_Exception_frame* frame);
252
256extern void rtems_debugger_target_exception_thread(rtems_debugger_thread* thread);
257
261extern void rtems_debugger_target_exception_thread_resume(rtems_debugger_thread* thread);
262
267extern int rtems_debugger_target_cache_sync(rtems_debugger_target_swbreak* swbreak);
268
273extern int rtems_debugger_target_start_memory_access(void);
274
278extern void rtems_debugger_target_end_memory_access(void);
279
283extern bool rtems_debugger_target_is_memory_access(void);
284
285#ifdef __cplusplus
286}
287#endif /* __cplusplus */
288
289
290#endif
The set of registers that specifies the complete processor state.
Definition: cpu.h:446
Definition: rtems-debugger-block.h:46
Definition: rtems-debugger-target.h:89
Definition: rtems-debugger-target.h:101
Definition: rtems-debugger-threads.h:87