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
213 const char *name) L4_NOTHROW;
214
219l4_debugger_add_image_info_u(l4_cap_idx_t cap, l4_addr_t base, const char *name,
220 l4_utcb_t *utcb) L4_NOTHROW;
221
222enum
223{
224 L4_DEBUGGER_NAME_SET_OP = 0UL,
225 L4_DEBUGGER_GLOBAL_ID_OP = 1UL,
226 L4_DEBUGGER_KOBJ_TO_ID_OP = 2UL,
227 L4_DEBUGGER_QUERY_LOG_TYPEID_OP = 3UL,
228 L4_DEBUGGER_SWITCH_LOG_OP = 4UL,
229 L4_DEBUGGER_NAME_GET_OP = 5UL,
230 L4_DEBUGGER_QUERY_LOG_NAME_OP = 6UL,
231 L4_DEBUGGER_ADD_IMAGE_INFO_OP = 7UL,
232};
233
234enum
235{
236 L4_DEBUGGER_SWITCH_LOG_ON = 1,
237 L4_DEBUGGER_SWITCH_LOG_OFF = 0,
238};
239
240/* IMPLEMENTATION -----------------------------------------------------------*/
241
242#include <l4/sys/kernel_object.h>
243
257L4_INLINE unsigned
258__strcpy_maxlen(char *dst, char const *src, unsigned maxlen)
259{
260 unsigned i;
261 if (!maxlen)
262 return 0;
263
264 for (i = 0; i < maxlen - 1 && src[i]; ++i)
265 dst[i] = src[i];
266 dst[i] = '\0';
267
268 return i + 1;
269}
270
272l4_debugger_set_object_name_u(l4_cap_idx_t cap,
273 const char *name, l4_utcb_t *utcb) L4_NOTHROW
274{
275 unsigned i;
276 l4_utcb_mr_u(utcb)->mr[0] = L4_DEBUGGER_NAME_SET_OP;
277 i = __strcpy_maxlen((char *)&l4_utcb_mr_u(utcb)->mr[1], name,
278 (L4_UTCB_GENERIC_DATA_SIZE - 2) * sizeof(l4_umword_t));
279 i = l4_bytes_to_mwords(i);
280 return l4_invoke_debugger(cap, l4_msgtag(0, 1 + i, 0, 0), utcb);
281}
282
283L4_INLINE unsigned long
284l4_debugger_global_id_u(l4_cap_idx_t cap, l4_utcb_t *utcb) L4_NOTHROW
285{
286 l4_utcb_mr_u(utcb)->mr[0] = L4_DEBUGGER_GLOBAL_ID_OP;
287 if (l4_error_u(l4_invoke_debugger(cap, l4_msgtag(0, 1, 0, 0), utcb), utcb))
288 return ~0UL;
289 return l4_utcb_mr_u(utcb)->mr[0];
290}
291
292L4_INLINE unsigned long
293l4_debugger_kobj_to_id_u(l4_cap_idx_t cap, l4_addr_t kobjp, l4_utcb_t *utcb) L4_NOTHROW
294{
295 l4_utcb_mr_u(utcb)->mr[0] = L4_DEBUGGER_KOBJ_TO_ID_OP;
296 l4_utcb_mr_u(utcb)->mr[1] = kobjp;
297 if (l4_error_u(l4_invoke_debugger(cap, l4_msgtag(0, 2, 0, 0), utcb), utcb))
298 return ~0UL;
299 return l4_utcb_mr_u(utcb)->mr[0];
300}
301
302L4_INLINE long
303l4_debugger_query_log_typeid_u(l4_cap_idx_t cap, const char *name,
304 unsigned idx,
305 l4_utcb_t *utcb) L4_NOTHROW
306{
307 unsigned i;
308 long e;
309 l4_utcb_mr_u(utcb)->mr[0] = L4_DEBUGGER_QUERY_LOG_TYPEID_OP;
310 l4_utcb_mr_u(utcb)->mr[1] = idx;
311 i = __strcpy_maxlen((char *)&l4_utcb_mr_u(utcb)->mr[2], name, 32);
312 i = l4_bytes_to_mwords(i);
313 e = l4_error_u(l4_invoke_debugger(cap, l4_msgtag(0, 2 + i, 0, 0), utcb), utcb);
314 if (e < 0)
315 return e;
316 return l4_utcb_mr_u(utcb)->mr[0];
317}
318
319L4_INLINE long
320l4_debugger_query_log_name_u(l4_cap_idx_t cap, unsigned idx,
321 char *name, unsigned namelen,
322 char *shortname, unsigned shortnamelen,
323 l4_utcb_t *utcb) L4_NOTHROW
324{
325 long e;
326 char const *n;
327 l4_utcb_mr_u(utcb)->mr[0] = L4_DEBUGGER_QUERY_LOG_NAME_OP;
328 l4_utcb_mr_u(utcb)->mr[1] = idx;
329 e = l4_error_u(l4_invoke_debugger(cap, l4_msgtag(0, 2, 0, 0), utcb), utcb);
330 if (e < 0)
331 return e;
332 n = (char const *)&l4_utcb_mr_u(utcb)->mr[0];
333 __strcpy_maxlen(name, n, namelen);
334 __strcpy_maxlen(shortname, n + __builtin_strlen(n) + 1, shortnamelen);
335 return 0;
336}
337
338
340l4_debugger_switch_log_u(l4_cap_idx_t cap, const char *name, int on_off,
341 l4_utcb_t *utcb) L4_NOTHROW
342{
343 unsigned i;
344 l4_utcb_mr_u(utcb)->mr[0] = L4_DEBUGGER_SWITCH_LOG_OP;
345 l4_utcb_mr_u(utcb)->mr[1] = on_off;
346 i = __strcpy_maxlen((char *)&l4_utcb_mr_u(utcb)->mr[2], name, 32);
347 i = l4_bytes_to_mwords(i);
348 return l4_invoke_debugger(cap, l4_msgtag(0, 2 + i, 0, 0), utcb);
349}
350
352l4_debugger_get_object_name_u(l4_cap_idx_t cap, unsigned id,
353 char *name, unsigned size,
354 l4_utcb_t *utcb) L4_NOTHROW
355{
356 l4_msgtag_t t;
357 l4_utcb_mr_u(utcb)->mr[0] = L4_DEBUGGER_NAME_GET_OP;
358 l4_utcb_mr_u(utcb)->mr[1] = id;
359 t = l4_invoke_debugger(cap, l4_msgtag(0, 2, 0, 0), utcb);
360 __strcpy_maxlen(name, (char const *)&l4_utcb_mr_u(utcb)->mr[0], size);
361 return t;
362}
363
365l4_debugger_add_image_info_u(l4_cap_idx_t cap, l4_addr_t base,
366 const char *name, l4_utcb_t *utcb) L4_NOTHROW
367{
368 unsigned i;
369 l4_utcb_mr_u(utcb)->mr[0] = L4_DEBUGGER_ADD_IMAGE_INFO_OP;
370 l4_utcb_mr_u(utcb)->mr[1] = base;
371 i = __strcpy_maxlen((char *)&l4_utcb_mr_u(utcb)->mr[2], name,
372 (L4_UTCB_GENERIC_DATA_SIZE - 3) * sizeof(l4_umword_t));
373 i = l4_bytes_to_mwords(i);
374 return l4_invoke_debugger(cap, l4_msgtag(0, 2 + i, 0, 0), utcb);
375}
376
377
380 const char *name) L4_NOTHROW
381{
382 return l4_debugger_set_object_name_u(cap, name, l4_utcb());
383}
384
385L4_INLINE unsigned long
387{
388 return l4_debugger_global_id_u(cap, l4_utcb());
389}
390
391L4_INLINE unsigned long
393{
394 return l4_debugger_kobj_to_id_u(cap, kobjp, l4_utcb());
395}
396
397L4_INLINE long
399 unsigned idx) L4_NOTHROW
400{
401 return l4_debugger_query_log_typeid_u(cap, name, idx, l4_utcb());
402}
403
404L4_INLINE long
406 char *name, unsigned namelen,
407 char *shortname, unsigned shortnamelen) L4_NOTHROW
408{
409 return l4_debugger_query_log_name_u(cap, idx, name, namelen,
410 shortname, shortnamelen, l4_utcb());
411}
412
415 int on_off) L4_NOTHROW
416{
417 return l4_debugger_switch_log_u(cap, name, on_off, l4_utcb());
418}
419
422 char *name, unsigned size) L4_NOTHROW
423{
424 return l4_debugger_get_object_name_u(cap, id, name, size, l4_utcb());
425}
426
429 const char *name) L4_NOTHROW
430{
431 return l4_debugger_add_image_info_u(cap, base, name, l4_utcb());
432}
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:359
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:421
l4_msgtag_t l4_debugger_add_image_info(l4_cap_idx_t cap, l4_addr_t base, const char *name) L4_NOTHROW
Add loaded image information for a task.
Definition debugger.h:428
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:398
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:392
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:405
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:379
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:386
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:414
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:428
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:164
l4_umword_t mr[L4_UTCB_GENERIC_DATA_SIZE]
Message registers.
Definition utcb.h:80