RTEMS 6.1-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#define RTEMS_DEBUGGER_FLAG_BREAK_WAITER (1 << 7)
107
114
118typedef struct _Condition_Control rtems_rx_cond;
119typedef struct _Mutex_recursive_Control rtems_rx_mutex;
120
124typedef struct
125{
126 int port;
127 int timeout;
128 rtems_task_priority priority;
129 rtems_rx_mutex lock;
130 rtems_debugger_remote* remote;
131 rtems_id server_task;
132 rtems_rx_cond server_cond;
133 volatile bool server_running;
134 volatile bool server_finished;
135 rtems_id events_task;
136 volatile bool events_running;
137 volatile bool events_finished;
138 rtems_printer printer;
139 uint32_t flags;
140 pid_t pid;
141 bool remote_debug;
142 bool ack_pending;
143 size_t output_level;
144 uint8_t input[RTEMS_DEBUGGER_BUFFER_SIZE];
145 uint8_t output[RTEMS_DEBUGGER_BUFFER_SIZE];
146 rtems_debugger_threads* threads;
147 rtems_chain_control exception_threads;
148 int signal;
149 rtems_debugger_target* target;
151
155extern rtems_debugger_server* rtems_debugger;
156
160extern int rtems_debugger_printf(const char* format, ...) RTEMS_PRINTFLIKE(1, 2);
161extern int rtems_debugger_clean_printf(const char* format, ...) RTEMS_PRINTFLIKE(1, 2);
162extern void rtems_debugger_printk_lock(rtems_interrupt_lock_context* lock_context);
163extern void rtems_debugger_printk_unlock(rtems_interrupt_lock_context* lock_context);
164
168extern void rtems_debugger_lock(void);
169
173extern void rtems_debugger_unlock(void);
174
178extern bool rtems_debugger_server_running(void);
179
183extern void rtems_debugger_server_crash(void);
184
188extern rtems_debugger_remote* rtems_debugger_remote_handle(void);
189
193extern bool rtems_debugger_connected(void);
194
198extern bool rtems_debugger_server_events_running(void);
199
203extern void rtems_debugger_server_events_signal(void);
204
208extern bool rtems_debugger_verbose(void);
209
213static inline bool rtems_debugger_server_flag(uint32_t mask)
214{
215 return (rtems_debugger->flags & mask) != 0;
216}
217
218#ifdef __cplusplus
219}
220#endif /* __cplusplus */
221
222
223#endif
#define RTEMS_PRINTFLIKE(_format_pos, _ap_pos)
Tells the compiler in a declaration that this function expects printf()-like arguments.
Definition: basedefs.h:772
uint32_t rtems_task_priority
This integer type represents task priorities of the Classic API.
Definition: types.h:257
Objects_Id rtems_id
This type represents RTEMS object identifiers.
Definition: types.h:94
User print interface to the bspIO print plug in.
This header file defines the RTEMS Classic API.
Local ISR lock context for acquire and release pairs.
Definition: isrlock.h:81
Definition: mknod-pack_dev.c:254
Definition: rtems-debugger-remote.h:45
Definition: rtems-debugger-server.h:125
Definition: rtems-debugger-target.h:101
Definition: rtems-debugger-threads.h:113
Definition: printer.h:76
This union represents a chain control block.
Definition: chain.h:96