source: rtems/cpukit/libdebugger/rtems-debugger-target.h

Last change on this file was 2c09b71, checked in by Chris Johns <chrisj@…>, on Apr 8, 2019 at 3:17:08 AM

libdebugger: Use an offset table to format GDB g packets.

Adding support for a register offset table lets FPU registers
be supported if added to the backend.

Closes #3733.

  • Property mode set to 100644
File size: 7.9 KB
Line 
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
49/**
50 * Target capabilities mask.
51 */
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/**
57 * Types of hardware breakpoints.
58 */
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
67/**
68 * Target exception actions.
69 */
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
77/**
78 * Memory breakpoint. We use thumb mode BKPT which is 2 bytes.
79 */
80#define RTEMS_DEBUGGER_TARGET_SWBREAK_MAX_SIZE (4)
81typedef struct rtems_debugger_target_swbreak {
82  void*   address;
83  uint8_t contents[RTEMS_DEBUGGER_TARGET_SWBREAK_MAX_SIZE];
84} rtems_debugger_target_swbreak;
85
86/**
87 * The target data.
88 *
89 * reg_offset: Table of size_t offset of a register in the register
90 *             table. The table has one more entry than reg_num where
91 *             the last entry is the size of the register table.
92 */
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. */
102} rtems_debugger_target;
103
104/**
105 * Create the target.
106 */
107extern int rtems_debugger_target_create(void);
108
109/**
110 * Destroy the target.
111 */
112extern int rtems_debugger_target_destroy(void);
113
114/**
115 * Configure the target. This is architecture specific.
116 */
117extern int rtems_debugger_target_configure(rtems_debugger_target* target);
118
119/**
120 * Enable the target.
121 */
122extern int rtems_debugger_target_enable(void);
123
124/**
125 * Disable the target.
126 */
127extern int rtems_debugger_target_disable(void);
128
129/**
130 * Return the capabilities mask for the target.
131 */
132extern uint32_t rtems_debugger_target_capabilities(void);
133
134/**
135 * Return the number of regisers.
136 */
137extern size_t rtems_debugger_target_reg_num(void);
138
139/**
140 * Return the offset of a register in the register table.
141 */
142extern size_t rtems_debugger_target_reg_size(size_t reg);
143
144/**
145 * Return the offset of a register in the register table.
146 */
147extern size_t rtems_debugger_target_reg_offset(size_t reg);
148
149/**
150 * Return the size of register table.
151 */
152extern size_t rtems_debugger_target_reg_table_size(void);
153
154/**
155 * Read the regosters.
156 */
157extern int rtems_debugger_target_read_regs(rtems_debugger_thread* thread);
158
159/**
160 * Write the regosters.
161 */
162extern int rtems_debugger_target_write_regs(rtems_debugger_thread* thread);
163
164/**
165 * Return the thread's program counter (PC).
166 */
167extern DB_UINT rtems_debugger_target_reg_pc(rtems_debugger_thread* thread);
168
169/**
170 * Return the frame's program counter (PC).
171 */
172extern DB_UINT rtems_debugger_target_frame_pc(CPU_Exception_frame* frame);
173
174/**
175 * Return the thread's stack pointer (SP).
176 */
177extern DB_UINT rtems_debugger_target_reg_sp(rtems_debugger_thread* thread);
178
179/**
180 * Return the thread's TCB stack pointer (SP).
181 */
182extern DB_UINT rtems_debugger_target_tcb_sp(rtems_debugger_thread* thread);
183
184/**
185 * The thread is stepping. Setup the thread to step an instruction.
186 */
187extern int rtems_debugger_target_thread_stepping(rtems_debugger_thread* thread);
188
189/**
190 * Return the signal for the exception.
191 */
192extern int rtems_debugger_target_exception_to_signal(CPU_Exception_frame* frame);
193
194/**
195 * Print the target exception registers.
196 */
197extern void rtems_debugger_target_exception_print(CPU_Exception_frame* frame);
198
199/**
200 * Software breakpoints. These are also referred to as memory breakpoints.
201 */
202extern int rtems_debugger_target_swbreak_control(bool    insert,
203                                                 DB_UINT addr,
204                                                 DB_UINT kind);
205
206/**
207 * Insert software breakpoints into the memory.
208 */
209extern int rtems_debugger_target_swbreak_insert(void);
210
211/**
212 * Remove software breakpoints from the memory.
213 */
214extern int rtems_debugger_target_swbreak_remove(void);
215
216/**
217 * Insert hardware breakpoints into the hardware.
218 */
219extern int rtems_debugger_target_hwbreak_insert(void);
220
221/**
222 * Remove hardware breakpoints from the hardware.
223 */
224extern int rtems_debugger_target_hwbreak_remove(void);
225
226/**
227 * Hardware breakpoints.
228 */
229extern int rtems_debugger_target_hwbreak_control(rtems_debugger_target_watchpoint type,
230                                                 bool                             insert,
231                                                 DB_UINT                          addr,
232                                                 DB_UINT                          kind);
233
234/**
235 * Target exception processor.
236 */
237extern rtems_debugger_target_exc_action
238rtems_debugger_target_exception(CPU_Exception_frame* frame);
239
240/**
241 * See if the thread is an exception thread.
242 */
243extern void rtems_debugger_target_exception_thread(rtems_debugger_thread* thread);
244
245/**
246 * If the thread is an exception thread, resume it.
247 */
248extern void rtems_debugger_target_exception_thread_resume(rtems_debugger_thread* thread);
249
250/**
251 * Target instruction cache sync. This depends on the target but it normally
252 * means a data cache flush and an instruction cache invalidate.
253 */
254extern int rtems_debugger_target_cache_sync(rtems_debugger_target_swbreak* swbreak);
255
256/**
257 * Start a target memory access. If 0 is return the access can proceed and if
258 * -1 is return the access has failed.
259 */
260extern int rtems_debugger_target_start_memory_access(void);
261
262/**
263 * End a target memory access.
264 */
265extern void rtems_debugger_target_end_memory_access(void);
266
267/**
268 * Is this a target memory access?
269 */
270extern bool rtems_debugger_target_is_memory_access(void);
271
272#ifdef __cplusplus
273}
274#endif /* __cplusplus */
275
276
277#endif
Note: See TracBrowser for help on using the repository browser.