RTEMS: cpukit/include/rtems/debugger/rtems-debugger-server.h Source File

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
rtems-debugger-server.h
1/*
2 * Copyright (c) 2016-2019 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
46#define RTEMS_DEBUGGER_NUMOF(_d) (sizeof(_d) / sizeof(_d[0]))
47
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
79#define RTEMS_DEBUGGER_TIMEOUT_STOP (5 * 1000 * 1000)
80
84#define RTEMS_DEBUGGER_POLL_WAIT (10000)
85
89#define RTEMS_DEBUGGER_STACKSIZE (16 * 1024)
90
94#define RTEMS_DEBUGGER_BUFFER_SIZE (4 * 1024)
95
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
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
117typedef struct _Condition_Control rtems_rx_cond;
118typedef struct _Mutex_recursive_Control rtems_rx_mutex;
119
123 typedef 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
154extern rtems_debugger_server* rtems_debugger;
155
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
167extern void rtems_debugger_lock(void);
168
172extern void rtems_debugger_unlock(void);
173
177extern bool rtems_debugger_server_running(void);
178
182extern void rtems_debugger_server_crash(void);
183
187extern rtems_debugger_remote* rtems_debugger_remote_handle(void);
188
192extern bool rtems_debugger_connected(void);
193
197extern bool rtems_debugger_server_events_running(void);
198
202extern void rtems_debugger_server_events_signal(void);
203
207extern bool rtems_debugger_verbose(void);
208
212static inline bool rtems_debugger_server_flag(uint32_t mask)
213{
214 return (rtems_debugger->flags & mask) != 0;
215}
216
217#ifdef __cplusplus
218}
219#endif /* __cplusplus */
220
221
222#endif
rtems_task_priority
uint32_t rtems_task_priority
Definition: tasks.h:55
rtems_id
Objects_Id rtems_id
Used to manage and manipulate RTEMS object identifiers.
Definition: types.h:83
RTEMS_PRINTFLIKE
#define RTEMS_PRINTFLIKE(_format_pos, _ap_pos)
Tells the compiler that this function expects printf()-like arguments.
Definition: basedefs.h:249
printer.h
User print interface to the bspIO print plug in.
rtems.h
ISR_lock_Context
Local ISR lock context for acquire and release pairs.
Definition: isrlock.h:65
format
Definition: mknod-pack_dev.c:254
rtems_debugger_remote
Definition: rtems-debugger-remote.h:45
rtems_debugger_server
Definition: rtems-debugger-server.h:124
rtems_debugger_target
Definition: rtems-debugger-target.h:93
rtems_debugger_threads
Definition: rtems-debugger-threads.h:113
rtems_printer
Definition: printer.h:55
Chain_Control
Definition: chain.h:86