L4Re Operating System Framework – Interface and Usage Documentation
Loading...
Searching...
No Matches
debugger.h
Go to the documentation of this file.
1#pragma once
7/*
8 * (c) 2008-2011 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
9 * Alexander Warg <warg@os.inf.tu-dresden.de>
10 * economic rights: Technische Universität Dresden (Germany)
11 *
12 * This file is part of TUD:OS and distributed under the terms of the
13 * GNU General Public License 2.
14 * Please see the COPYING-GPL-2 file for details.
15 *
16 * As a special exception, you may use this file as part of a free software
17 * library without restriction. Specifically, if other files instantiate
18 * templates or use macros or inline functions from this file, or you compile
19 * this file and link it with other files to produce an executable, this
20 * file does not by itself cause the resulting executable to be covered by
21 * the GNU General Public License. This exception does not however
22 * invalidate any other reasons why the executable file might be covered by
23 * the GNU General Public License.
24 */
25
26#include <l4/sys/compiler.h>
27#include <l4/sys/utcb.h>
28#include <l4/sys/ipc.h>
29
55
60l4_debugger_set_object_name_u(l4_cap_idx_t cap, const char *name, l4_utcb_t *utcb) L4_NOTHROW;
61
76 char *name, unsigned size) L4_NOTHROW;
77
82l4_debugger_get_object_name_u(l4_cap_idx_t cap, unsigned id,
83 char *name, unsigned size,
84 l4_utcb_t *utcb) L4_NOTHROW;
85
97L4_INLINE unsigned long
99
103L4_INLINE unsigned long
104l4_debugger_global_id_u(l4_cap_idx_t cap, l4_utcb_t *utcb) L4_NOTHROW;
105
118L4_INLINE unsigned long
120
124L4_INLINE unsigned long
125l4_debugger_kobj_to_id_u(l4_cap_idx_t cap, l4_addr_t kobjp, l4_utcb_t *utcb) L4_NOTHROW;
126
139L4_INLINE long
140l4_debugger_query_log_typeid(l4_cap_idx_t cap, const char *name,
141 unsigned idx) L4_NOTHROW;
142
146L4_INLINE long
147l4_debugger_query_log_typeid_u(l4_cap_idx_t cap, const char *name,
148 unsigned idx, l4_utcb_t *utcb) L4_NOTHROW;
149
166L4_INLINE long
168 char *name, unsigned namelen,
169 char *shortname, unsigned shortnamelen) L4_NOTHROW;
170
174L4_INLINE long
175l4_debugger_query_log_name_u(l4_cap_idx_t cap, unsigned idx,
176 char *name, unsigned namelen,
177 char *shortname, unsigned shortnamelen,
178 l4_utcb_t *utcb) L4_NOTHROW;
179
191l4_debugger_switch_log(l4_cap_idx_t cap, const char *name,
192 int on_off) L4_NOTHROW;
193
198l4_debugger_switch_log_u(l4_cap_idx_t cap, const char *name, int on_off,
199 l4_utcb_t *utcb) L4_NOTHROW;
200
201enum
202{
203 L4_DEBUGGER_NAME_SET_OP = 0UL,
204 L4_DEBUGGER_GLOBAL_ID_OP = 1UL,
205 L4_DEBUGGER_KOBJ_TO_ID_OP = 2UL,
206 L4_DEBUGGER_QUERY_LOG_TYPEID_OP = 3UL,
207 L4_DEBUGGER_SWITCH_LOG_OP = 4UL,
208 L4_DEBUGGER_NAME_GET_OP = 5UL,
209 L4_DEBUGGER_QUERY_LOG_NAME_OP = 6UL,
210};
211
212enum
213{
214 L4_DEBUGGER_SWITCH_LOG_ON = 1,
215 L4_DEBUGGER_SWITCH_LOG_OFF = 0,
216};
217
218/* IMPLEMENTATION -----------------------------------------------------------*/
219
220#include <l4/sys/kernel_object.h>
221
235L4_INLINE unsigned
236__strcpy_maxlen(char *dst, char const *src, unsigned maxlen)
237{
238 unsigned i;
239 if (!maxlen)
240 return 0;
241
242 for (i = 0; i < maxlen - 1 && src[i]; ++i)
243 dst[i] = src[i];
244 dst[i] = '\0';
245
246 return i + 1;
247}
248
250l4_debugger_set_object_name_u(l4_cap_idx_t cap,
251 const char *name, l4_utcb_t *utcb) L4_NOTHROW
252{
253 unsigned i;
254 l4_utcb_mr_u(utcb)->mr[0] = L4_DEBUGGER_NAME_SET_OP;
255 i = __strcpy_maxlen((char *)&l4_utcb_mr_u(utcb)->mr[1], name,
256 (L4_UTCB_GENERIC_DATA_SIZE - 2) * sizeof(l4_umword_t));
257 i = l4_bytes_to_mwords(i);
258 return l4_invoke_debugger(cap, l4_msgtag(0, 1 + i, 0, 0), utcb);
259}
260
261L4_INLINE unsigned long
262l4_debugger_global_id_u(l4_cap_idx_t cap, l4_utcb_t *utcb) L4_NOTHROW
263{
264 l4_utcb_mr_u(utcb)->mr[0] = L4_DEBUGGER_GLOBAL_ID_OP;
265 if (l4_error_u(l4_invoke_debugger(cap, l4_msgtag(0, 1, 0, 0), utcb), utcb))
266 return ~0UL;
267 return l4_utcb_mr_u(utcb)->mr[0];
268}
269
270L4_INLINE unsigned long
271l4_debugger_kobj_to_id_u(l4_cap_idx_t cap, l4_addr_t kobjp, l4_utcb_t *utcb) L4_NOTHROW
272{
273 l4_utcb_mr_u(utcb)->mr[0] = L4_DEBUGGER_KOBJ_TO_ID_OP;
274 l4_utcb_mr_u(utcb)->mr[1] = kobjp;
275 if (l4_error_u(l4_invoke_debugger(cap, l4_msgtag(0, 2, 0, 0), utcb), utcb))
276 return ~0UL;
277 return l4_utcb_mr_u(utcb)->mr[0];
278}
279
280L4_INLINE long
281l4_debugger_query_log_typeid_u(l4_cap_idx_t cap, const char *name,
282 unsigned idx,
283 l4_utcb_t *utcb) L4_NOTHROW
284{
285 unsigned i;
286 long e;
287 l4_utcb_mr_u(utcb)->mr[0] = L4_DEBUGGER_QUERY_LOG_TYPEID_OP;
288 l4_utcb_mr_u(utcb)->mr[1] = idx;
289 i = __strcpy_maxlen((char *)&l4_utcb_mr_u(utcb)->mr[2], name, 32);
290 i = l4_bytes_to_mwords(i);
291 e = l4_error_u(l4_invoke_debugger(cap, l4_msgtag(0, 2 + i, 0, 0), utcb), utcb);
292 if (e < 0)
293 return e;
294 return l4_utcb_mr_u(utcb)->mr[0];
295}
296
297L4_INLINE long
298l4_debugger_query_log_name_u(l4_cap_idx_t cap, unsigned idx,
299 char *name, unsigned namelen,
300 char *shortname, unsigned shortnamelen,
301 l4_utcb_t *utcb) L4_NOTHROW
302{
303 long e;
304 char const *n;
305 l4_utcb_mr_u(utcb)->mr[0] = L4_DEBUGGER_QUERY_LOG_NAME_OP;
306 l4_utcb_mr_u(utcb)->mr[1] = idx;
307 e = l4_error_u(l4_invoke_debugger(cap, l4_msgtag(0, 2, 0, 0), utcb), utcb);
308 if (e < 0)
309 return e;
310 n = (char const *)&l4_utcb_mr_u(utcb)->mr[0];
311 __strcpy_maxlen(name, n, namelen);
312 __strcpy_maxlen(shortname, n + __builtin_strlen(n) + 1, shortnamelen);
313 return 0;
314}
315
316
318l4_debugger_switch_log_u(l4_cap_idx_t cap, const char *name, int on_off,
319 l4_utcb_t *utcb) L4_NOTHROW
320{
321 unsigned i;
322 l4_utcb_mr_u(utcb)->mr[0] = L4_DEBUGGER_SWITCH_LOG_OP;
323 l4_utcb_mr_u(utcb)->mr[1] = on_off;
324 i = __strcpy_maxlen((char *)&l4_utcb_mr_u(utcb)->mr[2], name, 32);
325 i = l4_bytes_to_mwords(i);
326 return l4_invoke_debugger(cap, l4_msgtag(0, 2 + i, 0, 0), utcb);
327}
328
330l4_debugger_get_object_name_u(l4_cap_idx_t cap, unsigned id,
331 char *name, unsigned size,
332 l4_utcb_t *utcb) L4_NOTHROW
333{
334 l4_msgtag_t t;
335 l4_utcb_mr_u(utcb)->mr[0] = L4_DEBUGGER_NAME_GET_OP;
336 l4_utcb_mr_u(utcb)->mr[1] = id;
337 t = l4_invoke_debugger(cap, l4_msgtag(0, 2, 0, 0), utcb);
338 __strcpy_maxlen(name, (char const *)&l4_utcb_mr_u(utcb)->mr[0], size);
339 return t;
340}
341
342
345 const char *name) L4_NOTHROW
346{
347 return l4_debugger_set_object_name_u(cap, name, l4_utcb());
348}
349
350L4_INLINE unsigned long
352{
353 return l4_debugger_global_id_u(cap, l4_utcb());
354}
355
356L4_INLINE unsigned long
358{
359 return l4_debugger_kobj_to_id_u(cap, kobjp, l4_utcb());
360}
361
362L4_INLINE long
364 unsigned idx) L4_NOTHROW
365{
366 return l4_debugger_query_log_typeid_u(cap, name, idx, l4_utcb());
367}
368
369L4_INLINE long
371 char *name, unsigned namelen,
372 char *shortname, unsigned shortnamelen) L4_NOTHROW
373{
374 return l4_debugger_query_log_name_u(cap, idx, name, namelen,
375 shortname, shortnamelen, l4_utcb());
376}
377
380 int on_off) L4_NOTHROW
381{
382 return l4_debugger_switch_log_u(cap, name, on_off, l4_utcb());
383}
384
387 char *name, unsigned size) L4_NOTHROW
388{
389 return l4_debugger_get_object_name_u(cap, id, name, size, l4_utcb());
390}
L4 compiler related defines.
unsigned long l4_umword_t
Unsigned machine word.
Definition l4int.h:51
unsigned long l4_addr_t
Address type.
Definition l4int.h:45
unsigned long l4_cap_idx_t
Capability selector type.
Definition types.h:358
l4_msgtag_t l4_debugger_get_object_name(l4_cap_idx_t cap, unsigned id, char *name, unsigned size) L4_NOTHROW
Get name of the kernel object with Id id.
Definition debugger.h:386
long l4_debugger_query_log_typeid(l4_cap_idx_t cap, const char *name, unsigned idx) L4_NOTHROW
Query the log-id for a log type.
Definition debugger.h:363
unsigned long l4_debugger_kobj_to_id(l4_cap_idx_t cap, l4_addr_t kobjp) L4_NOTHROW
Get the globally unique ID of the object behind the kobject pointer.
Definition debugger.h:357
long l4_debugger_query_log_name(l4_cap_idx_t cap, unsigned idx, char *name, unsigned namelen, char *shortname, unsigned shortnamelen) L4_NOTHROW
Query the name of a log type given the ID.
Definition debugger.h:370
l4_msgtag_t l4_debugger_set_object_name(l4_cap_idx_t cap, const char *name) L4_NOTHROW
Set the name of a kernel object.
Definition debugger.h:344
unsigned long l4_debugger_global_id(l4_cap_idx_t cap) L4_NOTHROW
Get the globally unique ID of the object behind a capability.
Definition debugger.h:351
l4_msgtag_t l4_debugger_switch_log(l4_cap_idx_t cap, const char *name, int on_off) L4_NOTHROW
Set or unset log.
Definition debugger.h:379
unsigned l4_bytes_to_mwords(unsigned size) L4_NOTHROW
Determine how many machine words (l4_umword_t) are required to store a buffer of 'size' bytes.
Definition consts.h:485
l4_msgtag_t l4_msgtag(long label, unsigned words, unsigned items, unsigned flags) L4_NOTHROW
Create a message tag from the specified values.
Definition types.h:427
struct l4_utcb_t l4_utcb_t
Opaque type for the UTCB.
Definition utcb.h:67
l4_utcb_t * l4_utcb(void) L4_NOTHROW L4_PURE
Get the UTCB address.
Definition utcb.h:340
#define L4_NOTHROW
Mark a function declaration and definition as never throwing an exception.
Definition compiler.h:188
#define L4_INLINE
L4 Inline function attribute.
Definition compiler.h:62
Kernel object system calls.
Message tag data structure.
Definition types.h:163
l4_umword_t mr[L4_UTCB_GENERIC_DATA_SIZE]
Message registers.
Definition utcb.h:80