source: rtems/cpukit/libdebugger/rtems-debugger-server.h @ b2353ed9

Last change on this file since b2353ed9 was b2353ed9, checked in by Chris Johns <chrisj@…>, on Jul 16, 2017 at 11:53:11 PM

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: 6.4 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_SERVER_h
32#define _RTEMS_DEBUGGER_SERVER_h
33
34#include <rtems.h>
35#include <rtems/printer.h>
36
37#include <rtems/rtems-debugger.h>
38
39#ifdef __cplusplus
40extern "C" {
41#endif /* __cplusplus */
42
43/**
44 * Debugger NUMOF macro.
45 */
46#define RTEMS_DEBUGGER_NUMOF(_d) (sizeof(_d) / sizeof(_d[0]))
47
48/**
49 * Machine specific size. Here for 64bit support.
50 */
51#define DB_UINT uint32_t
52
53/*
54 * Debugger signals.
55 */
56#define RTEMS_DEBUGGER_SIGNAL_HUP   1     /* Hangup */
57#define RTEMS_DEBUGGER_SIGNAL_INT   2     /* Interrupt */
58#define RTEMS_DEBUGGER_SIGNAL_QUIT  3     /* Quit */
59#define RTEMS_DEBUGGER_SIGNAL_ILL   4     /* Illegal instruction */
60#define RTEMS_DEBUGGER_SIGNAL_TRAP  5     /* Trace/breakpoint trap */
61#define RTEMS_DEBUGGER_SIGNAL_ABRT  6     /* Aborted */
62#define RTEMS_DEBUGGER_SIGNAL_EMT   7     /* Emulation trap */
63#define RTEMS_DEBUGGER_SIGNAL_FPE   8     /* Arithmetic exception */
64#define RTEMS_DEBUGGER_SIGNAL_KILL  9     /* Killed */
65#define RTEMS_DEBUGGER_SIGNAL_BUS   10    /* Bus error */
66#define RTEMS_DEBUGGER_SIGNAL_SEGV  11    /* Segmentation fault */
67#define RTEMS_DEBUGGER_SIGNAL_SYS   12    /* Bad system call */
68#define RTEMS_DEBUGGER_SIGNAL_PIPE  13    /* Broken pipe */
69#define RTEMS_DEBUGGER_SIGNAL_ALRM  14    /* Alarm clock */
70#define RTEMS_DEBUGGER_SIGNAL_TERM  15    /* Terminated */
71#define RTEMS_DEBUGGER_SIGNAL_URG   16    /* Urgent I/O condition */
72#define RTEMS_DEBUGGER_SIGNAL_STOP  17    /* Stopped (signal) */
73#define RTEMS_DEBUGGER_SIGNAL_TSTP  18    /* Stopped (user) */
74#define RTEMS_DEBUGGER_SIGNAL_CONT  19    /* Continued */
75
76/**
77 * Timeout period for the Debugger task to stop in usecs.
78 */
79#define RTEMS_DEBUGGER_TIMEOUT_STOP (5 * 1000 * 1000)
80
81/**
82 * Debugger poll wait timeout in usecs.
83 */
84#define RTEMS_DEBUGGER_POLL_WAIT (10000)
85
86/**
87 * Debugger task stack size.
88 */
89#define RTEMS_DEBUGGER_STACKSIZE (16 * 1024)
90
91/**
92 * Debugger output buffer size.
93 */
94#define RTEMS_DEBUGGER_BUFFER_SIZE (4 * 1024)
95
96/**
97 * Debugger flags.
98 */
99#define RTEMS_DEBUGGER_FLAG_VERBOSE      (1 << 0)
100#define RTEMS_DEBUGGER_FLAG_RESET        (1 << 1)
101#define RTEMS_DEBUGGER_FLAG_NON_STOP     (1 << 2)
102#define RTEMS_DEBUGGER_FLAG_VCONT        (1 << 3)
103#define RTEMS_DEBUGGER_FLAG_MULTIPROCESS (1 << 4)
104#define RTEMS_DEBUGGER_FLAG_VERBOSE_LOCK (1 << 5)
105#define RTEMS_DEBUGGER_FLAG_VERBOSE_CMDS (1 << 6)
106
107/**
108 * Forward decl for the threads and targets.
109 */
110typedef struct rtems_debugger_remote  rtems_debugger_remote;
111typedef struct rtems_debugger_threads rtems_debugger_threads;
112typedef struct rtems_debugger_target  rtems_debugger_target;
113
114/**
115 * Local types for the RTEMS-X interface.
116 */
117typedef struct _Condition_Control       rtems_rx_cond;
118typedef struct _Mutex_recursive_Control rtems_rx_mutex;
119
120/**
121 * Debugger data.
122 */
123typedef struct
124{
125  int                     port;
126  int                     timeout;
127  rtems_task_priority     priority;
128  rtems_rx_mutex          lock;
129  rtems_debugger_remote*  remote;
130  rtems_id                server_task;
131  rtems_rx_cond           server_cond;
132  volatile bool           server_running;
133  volatile bool           server_finished;
134  rtems_id                events_task;
135  volatile bool           events_running;
136  volatile bool           events_finished;
137  rtems_printer           printer;
138  uint32_t                flags;
139  pid_t                   pid;
140  bool                    remote_debug;
141  bool                    ack_pending;
142  size_t                  output_level;
143  uint8_t                 input[RTEMS_DEBUGGER_BUFFER_SIZE];
144  uint8_t                 output[RTEMS_DEBUGGER_BUFFER_SIZE];
145  rtems_debugger_threads* threads;
146  rtems_chain_control     exception_threads;
147  int                     signal;
148  rtems_debugger_target*  target;
149} rtems_debugger_server;
150
151/**
152 * Debugger global variable.
153 */
154extern rtems_debugger_server* rtems_debugger;
155
156/**
157 * Debug server printer.
158 */
159extern int rtems_debugger_printf(const char* format, ...) RTEMS_PRINTFLIKE(1, 2);
160extern int rtems_debugger_clean_printf(const char* format, ...) RTEMS_PRINTFLIKE(1, 2);
161extern void rtems_debugger_printk_lock(rtems_interrupt_lock_context* lock_context);
162extern void rtems_debugger_printk_unlock(rtems_interrupt_lock_context* lock_context);
163
164/**
165 * Lock the Debugger.
166 */
167extern void rtems_debugger_lock(void);
168
169/**
170 * Unlock the Debugger.
171 */
172extern void rtems_debugger_unlock(void);
173
174/**
175 * Is the server still running?
176 */
177extern bool rtems_debugger_server_running(void);
178
179/**
180 * Get the remote handle from the debugger.
181 */
182extern rtems_debugger_remote* rtems_debugger_remote_handle(void);
183
184/**
185 * Is the debugger connected?
186 */
187extern bool rtems_debugger_connected(void);
188
189/**
190 * Is the debugger events thread runnins?
191 */
192extern bool rtems_debugger_server_events_running(void);
193
194/**
195 * Signal events thread in the debug server to run.
196 */
197extern void rtems_debugger_server_events_signal(void);
198
199/**
200 * Check if verbose is on.
201 */
202extern bool rtems_debugger_verbose(void);
203
204/**
205 * Check a flag.
206 */
207static inline bool rtems_debugger_server_flag(uint32_t mask)
208{
209  return (rtems_debugger->flags & mask) != 0;
210}
211
212#ifdef __cplusplus
213}
214#endif /* __cplusplus */
215
216
217#endif
Note: See TracBrowser for help on using the repository browser.