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

5
Last change on this file since a0d4e99 was a0d4e99, checked in by Chris Johns <chrisj@…>, on 11/25/16 at 04:13:36

cpukit: Add libdebugger, a remote debugger agent for GDB.

  • Property mode set to 100644
File size: 5.8 KB
Line 
1/*
2 * Copyright (c) 2016 Chris Johns <chrisj@rtems.org>.  All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 *    notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 *    notice, this list of conditions and the following disclaimer in the
11 *    documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 * SUCH DAMAGE.
24 */
25
26/*
27 * Debugger for RTEMS.
28 */
29
30#ifndef _RTEMS_DEBUGGER_SERVER_h
31#define _RTEMS_DEBUGGER_SERVER_h
32
33#include <rtems.h>
34#include <rtems/printer.h>
35
36#include <rtems/rtems-debugger.h>
37
38#ifdef __cplusplus
39extern "C" {
40#endif /* __cplusplus */
41
42/**
43 * Debugger NUMOF macro.
44 */
45#define RTEMS_DEBUGGER_NUMOF(_d) (sizeof(_d) / sizeof(_d[0]))
46
47/**
48 * Machine specific size. Here for 64bit support.
49 */
50#define DB_UINT uint32_t
51
52/*
53 * Debugger signals.
54 */
55#define RTEMS_DEBUGGER_SIGNAL_HUP   1     /* Hangup */
56#define RTEMS_DEBUGGER_SIGNAL_INT   2     /* Interrupt */
57#define RTEMS_DEBUGGER_SIGNAL_QUIT  3     /* Quit */
58#define RTEMS_DEBUGGER_SIGNAL_ILL   4     /* Illegal instruction */
59#define RTEMS_DEBUGGER_SIGNAL_TRAP  5     /* Trace/breakpoint trap */
60#define RTEMS_DEBUGGER_SIGNAL_ABRT  6     /* Aborted */
61#define RTEMS_DEBUGGER_SIGNAL_EMT   7     /* Emulation trap */
62#define RTEMS_DEBUGGER_SIGNAL_FPE   8     /* Arithmetic exception */
63#define RTEMS_DEBUGGER_SIGNAL_KILL  9     /* Killed */
64#define RTEMS_DEBUGGER_SIGNAL_BUS   10    /* Bus error */
65#define RTEMS_DEBUGGER_SIGNAL_SEGV  11    /* Segmentation fault */
66#define RTEMS_DEBUGGER_SIGNAL_SYS   12    /* Bad system call */
67#define RTEMS_DEBUGGER_SIGNAL_PIPE  13    /* Broken pipe */
68#define RTEMS_DEBUGGER_SIGNAL_ALRM  14    /* Alarm clock */
69#define RTEMS_DEBUGGER_SIGNAL_TERM  15    /* Terminated */
70#define RTEMS_DEBUGGER_SIGNAL_URG   16    /* Urgent I/O condition */
71#define RTEMS_DEBUGGER_SIGNAL_STOP  17    /* Stopped (signal) */
72#define RTEMS_DEBUGGER_SIGNAL_TSTP  18    /* Stopped (user) */
73#define RTEMS_DEBUGGER_SIGNAL_CONT  19    /* Continued */
74
75/**
76 * Timeout period for the Debugger task to stop in usecs.
77 */
78#define RTEMS_DEBUGGER_TIMEOUT_STOP (5 * 1000 * 1000)
79
80/**
81 * Debugger poll wait timeout in usecs.
82 */
83#define RTEMS_DEBUGGER_POLL_WAIT (10000)
84
85/**
86 * Debugger task stack size.
87 */
88#define RTEMS_DEBUGGER_STACKSIZE (16 * 1024)
89
90/**
91 * Debugger output buffer size.
92 */
93#define RTEMS_DEBUGGER_BUFFER_SIZE (4 * 1024)
94
95/**
96 * Debugger flags.
97 */
98#define RTEMS_DEBUGGER_FLAG_VERBOSE      (1 << 0)
99#define RTEMS_DEBUGGER_FLAG_RESET        (1 << 1)
100#define RTEMS_DEBUGGER_FLAG_NON_STOP     (1 << 2)
101#define RTEMS_DEBUGGER_FLAG_VCONT        (1 << 3)
102#define RTEMS_DEBUGGER_FLAG_MULTIPROCESS (1 << 4)
103
104/**
105 * Forward decl for the threads and targets.
106 */
107typedef struct rtems_debugger_remote  rtems_debugger_remote;
108typedef struct rtems_debugger_threads rtems_debugger_threads;
109typedef struct rtems_debugger_target  rtems_debugger_target;
110
111/**
112 * Debugger data.
113 */
114typedef struct
115{
116  int                     port;
117  int                     timeout;
118  rtems_task_priority     priority;
119  rtems_id                lock;
120  rtems_id                lock_output;
121  rtems_debugger_remote*  remote;
122  rtems_id                server_task;
123  volatile bool           server_running;
124  volatile bool           server_finished;
125  rtems_id                events_task;
126  volatile bool           events_running;
127  volatile bool           events_finished;
128  rtems_printer           printer;
129  uint32_t                flags;
130  pid_t                   pid;
131  bool                    remote_debug;
132  bool                    ack_pending;
133  size_t                  output_level;
134  uint8_t                 input[RTEMS_DEBUGGER_BUFFER_SIZE];
135  uint8_t                 output[RTEMS_DEBUGGER_BUFFER_SIZE];
136  rtems_debugger_threads* threads;
137  int                     signal;
138  rtems_debugger_target*  target;
139} rtems_debugger_server;
140
141/**
142 * Debugger global variable.
143 */
144extern rtems_debugger_server* rtems_debugger;
145
146/**
147 * Debug server printer.
148 */
149extern int rtems_debugger_printf(const char* format, ...) RTEMS_PRINTFLIKE(1, 2);
150
151/**
152 * Lock the Debugger.
153 */
154extern int rtems_debugger_lock(void);
155
156/**
157 * Unlock the Debugger.
158 */
159extern int rtems_debugger_unlock(void);
160
161/**
162 * Is the server still running?
163 */
164bool rtems_debugger_server_running(void);
165
166/**
167 * Get the remote handle from the debugger.
168 */
169rtems_debugger_remote* rtems_debugger_remote_handle(void);
170
171/**
172 * Is the debugger connected?
173 */
174bool rtems_debugger_connected(void);
175
176/**
177 * Is the debugger events thread runnins?
178 */
179bool rtems_debugger_server_events_running(void);
180
181/**
182 * Wake events thread in the debug server.
183 */
184extern int rtems_debugger_server_events_wake(void);
185
186/**
187 * Check if verbose is on.
188 */
189extern bool rtems_debugger_verbose(void);
190
191/**
192 * Check a flag.
193 */
194static inline bool rtems_debugger_server_flag(uint32_t mask)
195{
196  return (rtems_debugger->flags & mask) != 0;
197}
198
199#ifdef __cplusplus
200}
201#endif /* __cplusplus */
202
203
204#endif
Note: See TracBrowser for help on using the repository browser.