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

5
Last change on this file since a2a71b5 was b2353ed9, checked in by Chris Johns <chrisj@…>, on 07/16/17 at 23:53:11

libdebugger: Fixes to debugging, ARM support, locking, and gcc-7.1 warnings.

  • Add printk support to aid multi-core debugging.
  • Add lock trace to aid lock debugging.
  • Fixes to gcc-7.1 warnings.
  • Fixes from ticket #2879.
  • Add verbose command controls.
  • Change using the RTEMS sys/lock.h API to manage exception threads.
  • ARM hardware breakpoint fixes. Support for SMP stepping is not implemented, this requires use of the context id register.

Closes #2879.

  • Property mode set to 100644
File size: 7.2 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 */
89typedef struct rtems_debugger_target {
90  int                  capabilities;     /*<< The capabilities to report. */
91  size_t               reg_num;          /*<< The number of registers. */
92  size_t               reg_size;         /*<< The size of a register. */
93  const uint8_t*       breakpoint;       /*<< The breakpoint instruction(s). */
94  size_t               breakpoint_size;  /*<< The breakpoint size. */
95  rtems_debugger_block swbreaks;         /*<< The software breakpoint block. */
96  bool                 memory_access;    /*<< Accessing target memory. */
97  jmp_buf              access_return;    /*<< Return from an access fault. */
98} rtems_debugger_target;
99
100/**
101 * Create the target.
102 */
103extern int rtems_debugger_target_create(void);
104
105/**
106 * Destroy the target.
107 */
108extern int rtems_debugger_target_destroy(void);
109
110/**
111 * Configure the target. This is architecture specific.
112 */
113extern int rtems_debugger_target_configure(rtems_debugger_target* target);
114
115/**
116 * Enable the target.
117 */
118extern int rtems_debugger_target_enable(void);
119
120/**
121 * Disable the target.
122 */
123extern int rtems_debugger_target_disable(void);
124
125/**
126 * Return the capabilities mask for the target.
127 */
128extern uint32_t rtems_debugger_target_capabilities(void);
129
130/**
131 * Return the number of regisers.
132 */
133extern size_t rtems_debugger_target_reg_num(void);
134
135/**
136 * Return the size of the regisers in bytes.
137 */
138extern size_t rtems_debugger_target_reg_size(void);
139
140/**
141 * Read the regosters.
142 */
143extern int rtems_debugger_target_read_regs(rtems_debugger_thread* thread);
144
145/**
146 * Write the regosters.
147 */
148extern int rtems_debugger_target_write_regs(rtems_debugger_thread* thread);
149
150/**
151 * Return the thread's program counter (PC).
152 */
153extern DB_UINT rtems_debugger_target_reg_pc(rtems_debugger_thread* thread);
154
155/**
156 * Return the frame's program counter (PC).
157 */
158extern DB_UINT rtems_debugger_target_frame_pc(CPU_Exception_frame* frame);
159
160/**
161 * Return the thread's stack pointer (SP).
162 */
163extern DB_UINT rtems_debugger_target_reg_sp(rtems_debugger_thread* thread);
164
165/**
166 * Return the thread's TCB stack pointer (SP).
167 */
168extern DB_UINT rtems_debugger_target_tcb_sp(rtems_debugger_thread* thread);
169
170/**
171 * The thread is stepping. Setup the thread to step an instruction.
172 */
173extern int rtems_debugger_target_thread_stepping(rtems_debugger_thread* thread);
174
175/**
176 * Return the signal for the exception.
177 */
178extern int rtems_debugger_target_exception_to_signal(CPU_Exception_frame* frame);
179
180/**
181 * Software breakpoints. These are also referred to as memory breakpoints.
182 */
183extern int rtems_debugger_target_swbreak_control(bool    insert,
184                                                 DB_UINT addr,
185                                                 DB_UINT kind);
186
187/**
188 * Insert software breakpoints into the memory.
189 */
190extern int rtems_debugger_target_swbreak_insert(void);
191
192/**
193 * Remove software breakpoints from the memory.
194 */
195extern int rtems_debugger_target_swbreak_remove(void);
196
197/**
198 * Insert hardware breakpoints into the hardware.
199 */
200extern int rtems_debugger_target_hwbreak_insert(void);
201
202/**
203 * Remove hardware breakpoints from the hardware.
204 */
205extern int rtems_debugger_target_hwbreak_remove(void);
206
207/**
208 * Hardware breakpoints.
209 */
210extern int rtems_debugger_target_hwbreak_control(rtems_debugger_target_watchpoint type,
211                                                 bool                             insert,
212                                                 DB_UINT                          addr,
213                                                 DB_UINT                          kind);
214
215/**
216 * Target exception processor.
217 */
218extern rtems_debugger_target_exc_action
219rtems_debugger_target_exception(CPU_Exception_frame* frame);
220
221/**
222 * See if the thread is an exception thread.
223 */
224extern void rtems_debugger_target_exception_thread(rtems_debugger_thread* thread);
225
226/**
227 * If the thread is an exception thread, resume it.
228 */
229extern void rtems_debugger_target_exception_thread_resume(rtems_debugger_thread* thread);
230
231/**
232 * Target instruction cache sync. This depends on the target but it normally
233 * means a data cache flush and an instruction cache invalidate.
234 */
235extern int rtems_debugger_target_cache_sync(rtems_debugger_target_swbreak* swbreak);
236
237/**
238 * Start a target memory access. If 0 is return the access can proceed and if
239 * -1 is return the access has failed.
240 */
241extern int rtems_debugger_target_start_memory_access(void);
242
243/**
244 * End a target memory access.
245 */
246extern void rtems_debugger_target_end_memory_access(void);
247
248#ifdef __cplusplus
249}
250#endif /* __cplusplus */
251
252
253#endif
Note: See TracBrowser for help on using the repository browser.