source: rtems/cpukit/libdebugger/rtems-debugger-threads.h @ 8ad4d93

5
Last change on this file since 8ad4d93 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.3 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_THREADS_h
32#define _RTEMS_DEBUGGER_THREADS_h
33
34#include <rtems/debugger/rtems-debugger-server.h>
35
36#include "rtems-debugger-block.h"
37
38#ifdef __cplusplus
39extern "C" {
40#endif /* __cplusplus */
41
42/**
43 * Debugger thread name size, fixed size. ASCIIZ format.
44 */
45#define RTEMS_DEBUGGER_THREAD_NAME_SIZE (5)
46
47/**
48 * Debugger thread allocation block size.
49 */
50#define RTEMS_DEBUGGER_THREAD_BLOCK_SIZE (32)
51
52/**
53 * Debugger thread flags.
54 */
55#define RTEMS_DEBUGGER_THREAD_FLAG_EXCEPTION      (1 << 0)
56#define RTEMS_DEBUGGER_THREAD_FLAG_REG_VALID      (1 << 1)
57#define RTEMS_DEBUGGER_THREAD_FLAG_REG_DIRTY      (1 << 2)
58#define RTEMS_DEBUGGER_THREAD_FLAG_CONTINUE       (1 << 3)
59#define RTEMS_DEBUGGER_THREAD_FLAG_STEP           (1 << 4)
60#define RTEMS_DEBUGGER_THREAD_FLAG_STEPPING       (1 << 5)
61#define RTEMS_DEBUGGER_THREAD_FLAG_INTS_DISABLED  (1 << 6)
62/* Target specific flags for use by the target backend. */
63#define RTEMS_DEBUGGER_THREAD_FLAG_TARGET_BASE    (24)
64#define RTEMS_DEBUGGER_THREAD_FLAG_TARGET_MASK    (0xff << RTEMS_DEBUGGER_THREAD_FLAG_TARGET_BASE)
65
66/**
67 * Resume this thread.
68 */
69#define RTEMS_DEBUGGER_THREAD_FLAG_RESUME \
70  (RTEMS_DEBUGGER_THREAD_FLAG_CONTINUE | \
71   RTEMS_DEBUGGER_THREAD_FLAG_STEP | \
72   RTEMS_DEBUGGER_THREAD_FLAG_STEPPING)
73
74/**
75 * Step an instruction.
76 */
77#define RTEMS_DEBUGGER_THREAD_FLAG_STEP_INSTR \
78  (RTEMS_DEBUGGER_THREAD_FLAG_STEP | \
79   RTEMS_DEBUGGER_THREAD_FLAG_STEPPING)
80
81/**
82 * Debugger thread.
83 */
84typedef struct rtems_debugger_thread
85{
86  uint32_t        flags;
87  const char      name[RTEMS_DEBUGGER_THREAD_NAME_SIZE];
88  Thread_Control* tcb;
89  rtems_id        id;
90  int             cpu;
91  DB_UINT*        registers;
92  int             signal;
93  void*           frame;
94} rtems_debugger_thread;
95
96/**
97 * Debugger stepping thread. This is a thread that steps while inside an
98 * address range.
99 */
100typedef struct rtems_debugger_thread_stepper
101{
102  rtems_debugger_thread* thread;
103  DB_UINT                start;
104  DB_UINT                end;
105} rtems_debugger_thread_stepper;
106
107/**
108 * Debugger thread control.
109 */
110struct rtems_debugger_threads
111{
112  rtems_debugger_block current;       /**< The threads currently available. */
113  rtems_debugger_block registers;     /**< The threads that have stopped. */
114  rtems_debugger_block excludes;      /**< The threads we cannot touch. */
115  rtems_debugger_block stopped;       /**< The threads that have stopped. */
116  rtems_debugger_block steppers;      /**< The threads that are stepping. */
117  size_t               next;          /**< An iterator. */
118  int                  selector_gen;  /**< General thread selector. */
119  int                  selector_cont; /**< Continue thread selector. */
120};
121
122/**
123 * Create the thread support.
124 */
125extern int rtems_debugger_thread_create(void);
126
127/**
128 * Destroy the thread support.
129 */
130extern int rtems_debugger_thread_destroy(void);
131
132/**
133 * Find the index in the thread table for the ID.
134 */
135extern int rtems_debugger_thread_find_index(rtems_id id);
136
137/**
138 * Suspend the system.
139 */
140extern int rtems_debugger_thread_system_suspend(void);
141
142/**
143 * Resume the system.
144 */
145extern int rtems_debugger_thread_system_resume(bool detaching);
146
147/**
148 * Continue all threads.
149 */
150extern int rtems_debugger_thread_continue_all(void);
151
152/**
153 * Continue a thread.
154 */
155extern int rtems_debugger_thread_continue(rtems_debugger_thread* thread);
156
157/**
158 * Step a thread.
159 */
160extern int rtems_debugger_thread_step(rtems_debugger_thread* thread);
161
162/**
163 * Thread is stepping so record the details.
164 */
165extern int rtems_debugger_thread_stepping(rtems_debugger_thread* thread,
166                                          DB_UINT                start,
167                                          DB_UINT                end);
168
169/**
170 * Thread's PC in the stepping range? Returns the stepper is in range else
171 * NULL.
172 */
173extern const rtems_debugger_thread_stepper*
174rtems_debugger_thread_is_stepping(rtems_id id, DB_UINT pc);
175
176/**
177 * Return the thread's current priority/
178 */
179extern int rtems_debugger_thread_current_priority(rtems_debugger_thread* thread);
180
181/**
182 * Return the thread's real priority.
183 */
184extern int rtems_debugger_thread_real_priority(rtems_debugger_thread* thread);
185
186/**
187 * Return the thread's state.
188 */
189extern int rtems_debugger_thread_state(rtems_debugger_thread* thread);
190
191/**
192 * Return the thread's state.
193 */
194//extern bool rtems_debugger_thread_state_debugger(rtems_debugger_thread* thread);
195
196/**
197 * Return a string of the thread's state.
198 */
199extern int rtems_debugger_thread_state_str(rtems_debugger_thread* thread,
200                                           char*                  buffer,
201                                           size_t                 size);
202
203/**
204 * Return the thread's stack size.
205 */
206extern unsigned long rtems_debugger_thread_stack_size(rtems_debugger_thread* thread);
207
208/**
209 * Return the thread's stack area address.
210 */
211extern void* rtems_debugger_thread_stack_area(rtems_debugger_thread* thread);
212
213/**
214 * Check a thread's flag and return true if any of the bits in the mask are
215 * set.
216 */
217static inline bool
218rtems_debugger_thread_flag(rtems_debugger_thread* thread, uint32_t mask)
219{
220  return (thread->flags & mask) != 0;
221}
222
223/**
224 * Get the current threads.
225 */
226static inline rtems_debugger_thread*
227rtems_debugger_thread_current(rtems_debugger_threads* threads)
228{
229  return threads->current.block;
230}
231
232/**
233 * Get the registers.
234 */
235static inline DB_UINT*
236rtems_debugger_thread_registers(rtems_debugger_threads* threads)
237{
238  return threads->registers.block;
239}
240
241/**
242 * Get the excludes.
243 */
244static inline rtems_id*
245rtems_debugger_thread_excludes(rtems_debugger_threads* threads)
246{
247  return threads->excludes.block;
248}
249
250/**
251 * Get the stopped.
252 */
253static inline rtems_id*
254rtems_debugger_thread_stopped(rtems_debugger_threads* threads)
255{
256  return threads->stopped.block;
257}
258
259/**
260 * Get the steppers.
261 */
262static inline rtems_debugger_thread_stepper*
263rtems_debugger_thread_steppers(rtems_debugger_threads* threads)
264{
265  return threads->steppers.block;
266}
267
268#ifdef __cplusplus
269}
270#endif /* __cplusplus */
271
272#endif
Note: See TracBrowser for help on using the repository browser.