RTEMS 6.1-rc6
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 int (*rtems_debugger_target_code_writer)(void* address,
102 const void* data,
103 size_t size);
104
112typedef struct rtems_debugger_target {
113 int capabilities; /*<< The capabilities to report. */
114 size_t reg_num; /*<< The number of registers. */
115 const size_t* reg_offset; /*<< The reg offsettable, len = reg_num + 1. */
116 const uint8_t* breakpoint; /*<< The breakpoint instruction(s). */
117 size_t breakpoint_size; /*<< The breakpoint size. */
118 rtems_debugger_block swbreaks; /*<< The software breakpoint block. */
119 rtems_debugger_target_code_writer code_writer; /*<< If set use to write to code memory */
120 bool memory_access; /*<< Accessing target memory. */
121 jmp_buf access_return; /*<< Return from an access fault. */
122 uintptr_t step_bp_address; /*<< Stepping break point address */
123 rtems_id step_tid; /*<< Stepping task id */
124
126
130extern int rtems_debugger_target_create(void);
131
135extern int rtems_debugger_target_destroy(void);
136
140extern int rtems_debugger_target_configure(rtems_debugger_target* target);
141
145extern int rtems_debugger_target_enable(void);
146
150extern int rtems_debugger_target_disable(void);
151
155extern uint32_t rtems_debugger_target_capabilities(void);
156
160extern size_t rtems_debugger_target_reg_num(void);
161
165extern size_t rtems_debugger_target_reg_size(size_t reg);
166
170extern size_t rtems_debugger_target_reg_offset(size_t reg);
171
175extern size_t rtems_debugger_target_reg_table_size(void);
176
180extern int rtems_debugger_target_read_regs(rtems_debugger_thread* thread);
181
185extern int rtems_debugger_target_write_regs(rtems_debugger_thread* thread);
186
190extern uintptr_t rtems_debugger_target_reg_pc(rtems_debugger_thread* thread);
191
195extern uintptr_t rtems_debugger_target_frame_pc(CPU_Exception_frame* frame);
196
200extern uintptr_t rtems_debugger_target_reg_sp(rtems_debugger_thread* thread);
201
205extern uintptr_t rtems_debugger_target_tcb_sp(rtems_debugger_thread* thread);
206
210extern int rtems_debugger_target_thread_stepping(rtems_debugger_thread* thread);
211
215extern int rtems_debugger_target_exception_to_signal(CPU_Exception_frame* frame);
216
220extern void rtems_debugger_target_exception_print(CPU_Exception_frame* frame);
221
225extern int rtems_debugger_target_swbreak_control(bool insert,
226 uintptr_t addr,
227 DB_UINT kind);
228
232extern int rtems_debugger_target_swbreak_insert(void);
233
237extern int rtems_debugger_target_swbreak_remove(void);
238
242extern bool rtems_debugger_target_swbreak_is_configured( uintptr_t addr );
243
247extern int rtems_debugger_target_hwbreak_insert(void);
248
252extern int rtems_debugger_target_hwbreak_remove(void);
253
257extern int rtems_debugger_target_hwbreak_control(rtems_debugger_target_watchpoint type,
258 bool insert,
259 uintptr_t addr,
260 DB_UINT kind);
261
265extern rtems_debugger_target_exc_action
266rtems_debugger_target_exception(CPU_Exception_frame* frame);
267
271extern void rtems_debugger_target_exception_thread(rtems_debugger_thread* thread);
272
276extern void rtems_debugger_target_exception_thread_resume(rtems_debugger_thread* thread);
277
282extern int rtems_debugger_target_cache_sync(rtems_debugger_target_swbreak* swbreak);
283
288extern int rtems_debugger_target_start_memory_access(void);
289
293extern void rtems_debugger_target_end_memory_access(void);
294
298extern bool rtems_debugger_target_is_memory_access(void);
299
300#ifdef __cplusplus
301}
302#endif /* __cplusplus */
303
304
305#endif
Objects_Id rtems_id
This type represents RTEMS object identifiers.
Definition: types.h:94
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:112
Definition: rtems-debugger-threads.h:87