L4Re Operating System Framework
Interface and Usage Documentation
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 * License: see LICENSE.spdx (in this directory or the directories above)
13 */
14
15#include <l4/sys/compiler.h>
16#include <l4/sys/utcb.h>
17#include <l4/sys/ipc.h>
18
44
49l4_debugger_set_object_name_u(l4_cap_idx_t cap, const char *name, l4_utcb_t *utcb) L4_NOTHROW;
50
65 char *name, unsigned size) L4_NOTHROW;
66
71l4_debugger_get_object_name_u(l4_cap_idx_t cap, unsigned id,
72 char *name, unsigned size,
73 l4_utcb_t *utcb) L4_NOTHROW;
74
86L4_INLINE unsigned long
88
92L4_INLINE unsigned long
93l4_debugger_global_id_u(l4_cap_idx_t cap, l4_utcb_t *utcb) L4_NOTHROW;
94
107L4_INLINE unsigned long
109
113L4_INLINE unsigned long
114l4_debugger_kobj_to_id_u(l4_cap_idx_t cap, l4_addr_t kobjp, l4_utcb_t *utcb) L4_NOTHROW;
115
128L4_INLINE long
129l4_debugger_query_log_typeid(l4_cap_idx_t cap, const char *name,
130 unsigned idx) L4_NOTHROW;
131
135L4_INLINE long
136l4_debugger_query_log_typeid_u(l4_cap_idx_t cap, const char *name,
137 unsigned idx, l4_utcb_t *utcb) L4_NOTHROW;
138
155L4_INLINE long
157 char *name, unsigned namelen,
158 char *shortname, unsigned shortnamelen) L4_NOTHROW;
159
163L4_INLINE long
164l4_debugger_query_log_name_u(l4_cap_idx_t cap, unsigned idx,
165 char *name, unsigned namelen,
166 char *shortname, unsigned shortnamelen,
167 l4_utcb_t *utcb) L4_NOTHROW;
168
180l4_debugger_switch_log(l4_cap_idx_t cap, const char *name,
181 int on_off) L4_NOTHROW;
182
187l4_debugger_switch_log_u(l4_cap_idx_t cap, const char *name, int on_off,
188 l4_utcb_t *utcb) L4_NOTHROW;
189
202 const char *name) L4_NOTHROW;
203
208l4_debugger_add_image_info_u(l4_cap_idx_t cap, l4_addr_t base, const char *name,
209 l4_utcb_t *utcb) L4_NOTHROW;
210
211enum
212{
213 L4_DEBUGGER_NAME_SET_OP = 0UL,
214 L4_DEBUGGER_GLOBAL_ID_OP = 1UL,
215 L4_DEBUGGER_KOBJ_TO_ID_OP = 2UL,
216 L4_DEBUGGER_QUERY_LOG_TYPEID_OP = 3UL,
217 L4_DEBUGGER_SWITCH_LOG_OP = 4UL,
218 L4_DEBUGGER_NAME_GET_OP = 5UL,
219 L4_DEBUGGER_QUERY_LOG_NAME_OP = 6UL,
220 L4_DEBUGGER_ADD_IMAGE_INFO_OP = 7UL,
221};
222
223enum
224{
225 L4_DEBUGGER_SWITCH_LOG_ON = 1,
226 L4_DEBUGGER_SWITCH_LOG_OFF = 0,
227};
228
229/* IMPLEMENTATION -----------------------------------------------------------*/
230
231#include <l4/sys/kernel_object.h>
232
246L4_INLINE unsigned
247__strcpy_maxlen(char *dst, char const *src, unsigned maxlen)
248{
249 unsigned i;
250 if (!maxlen)
251 return 0;
252
253 for (i = 0; i < maxlen - 1 && src[i]; ++i)
254 dst[i] = src[i];
255 dst[i] = '\0';
256
257 return i + 1;
258}
259
261l4_debugger_set_object_name_u(l4_cap_idx_t cap,
262 const char *name, l4_utcb_t *utcb) L4_NOTHROW
263{
264 unsigned i;
265 l4_utcb_mr_u(utcb)->mr[0] = L4_DEBUGGER_NAME_SET_OP;
266 i = __strcpy_maxlen((char *)&l4_utcb_mr_u(utcb)->mr[1], name,
267 (L4_UTCB_GENERIC_DATA_SIZE - 2) * sizeof(l4_umword_t));
268 i = l4_bytes_to_mwords(i);
269 return l4_invoke_debugger(cap, l4_msgtag(0, 1 + i, 0, 0), utcb);
270}
271
272L4_INLINE unsigned long
273l4_debugger_global_id_u(l4_cap_idx_t cap, l4_utcb_t *utcb) L4_NOTHROW
274{
275 l4_utcb_mr_u(utcb)->mr[0] = L4_DEBUGGER_GLOBAL_ID_OP;
276 if (l4_error_u(l4_invoke_debugger(cap, l4_msgtag(0, 1, 0, 0), utcb), utcb))
277 return ~0UL;
278 return l4_utcb_mr_u(utcb)->mr[0];
279}
280
281L4_INLINE unsigned long
282l4_debugger_kobj_to_id_u(l4_cap_idx_t cap, l4_addr_t kobjp, l4_utcb_t *utcb) L4_NOTHROW
283{
284 l4_utcb_mr_u(utcb)->mr[0] = L4_DEBUGGER_KOBJ_TO_ID_OP;
285 l4_utcb_mr_u(utcb)->mr[1] = kobjp;
286 if (l4_error_u(l4_invoke_debugger(cap, l4_msgtag(0, 2, 0, 0), utcb), utcb))
287 return ~0UL;
288 return l4_utcb_mr_u(utcb)->mr[0];
289}
290
291L4_INLINE long
292l4_debugger_query_log_typeid_u(l4_cap_idx_t cap, const char *name,
293 unsigned idx,
294 l4_utcb_t *utcb) L4_NOTHROW
295{
296 unsigned i;
297 long e;
298 l4_utcb_mr_u(utcb)->mr[0] = L4_DEBUGGER_QUERY_LOG_TYPEID_OP;
299 l4_utcb_mr_u(utcb)->mr[1] = idx;
300 i = __strcpy_maxlen((char *)&l4_utcb_mr_u(utcb)->mr[2], name, 32);
301 i = l4_bytes_to_mwords(i);
302 e = l4_error_u(l4_invoke_debugger(cap, l4_msgtag(0, 2 + i, 0, 0), utcb), utcb);
303 if (e < 0)
304 return e;
305 return l4_utcb_mr_u(utcb)->mr[0];
306}
307
308L4_INLINE long
309l4_debugger_query_log_name_u(l4_cap_idx_t cap, unsigned idx,
310 char *name, unsigned namelen,
311 char *shortname, unsigned shortnamelen,
312 l4_utcb_t *utcb) L4_NOTHROW
313{
314 long e;
315 char const *n;
316 l4_utcb_mr_u(utcb)->mr[0] = L4_DEBUGGER_QUERY_LOG_NAME_OP;
317 l4_utcb_mr_u(utcb)->mr[1] = idx;
318 e = l4_error_u(l4_invoke_debugger(cap, l4_msgtag(0, 2, 0, 0), utcb), utcb);
319 if (e < 0)
320 return e;
321 n = (char const *)&l4_utcb_mr_u(utcb)->mr[0];
322 __strcpy_maxlen(name, n, namelen);
323 __strcpy_maxlen(shortname, n + __builtin_strlen(n) + 1, shortnamelen);
324 return 0;
325}
326
327
329l4_debugger_switch_log_u(l4_cap_idx_t cap, const char *name, int on_off,
330 l4_utcb_t *utcb) L4_NOTHROW
331{
332 unsigned i;
333 l4_utcb_mr_u(utcb)->mr[0] = L4_DEBUGGER_SWITCH_LOG_OP;
334 l4_utcb_mr_u(utcb)->mr[1] = on_off;
335 i = __strcpy_maxlen((char *)&l4_utcb_mr_u(utcb)->mr[2], name, 32);
336 i = l4_bytes_to_mwords(i);
337 return l4_invoke_debugger(cap, l4_msgtag(0, 2 + i, 0, 0), utcb);
338}
339
341l4_debugger_get_object_name_u(l4_cap_idx_t cap, unsigned id,
342 char *name, unsigned size,
343 l4_utcb_t *utcb) L4_NOTHROW
344{
345 l4_msgtag_t t;
346 l4_utcb_mr_u(utcb)->mr[0] = L4_DEBUGGER_NAME_GET_OP;
347 l4_utcb_mr_u(utcb)->mr[1] = id;
348 t = l4_invoke_debugger(cap, l4_msgtag(0, 2, 0, 0), utcb);
349 __strcpy_maxlen(name, (char const *)&l4_utcb_mr_u(utcb)->mr[0], size);
350 return t;
351}
352
354l4_debugger_add_image_info_u(l4_cap_idx_t cap, l4_addr_t base,
355 const char *name, l4_utcb_t *utcb) L4_NOTHROW
356{
357 unsigned i;
358 l4_utcb_mr_u(utcb)->mr[0] = L4_DEBUGGER_ADD_IMAGE_INFO_OP;
359 l4_utcb_mr_u(utcb)->mr[1] = base;
360 i = __strcpy_maxlen((char *)&l4_utcb_mr_u(utcb)->mr[2], name,
361 (L4_UTCB_GENERIC_DATA_SIZE - 3) * sizeof(l4_umword_t));
362 i = l4_bytes_to_mwords(i);
363 return l4_invoke_debugger(cap, l4_msgtag(0, 2 + i, 0, 0), utcb);
364}
365
366
369 const char *name) L4_NOTHROW
370{
371 return l4_debugger_set_object_name_u(cap, name, l4_utcb());
372}
373
374L4_INLINE unsigned long
376{
377 return l4_debugger_global_id_u(cap, l4_utcb());
378}
379
380L4_INLINE unsigned long
382{
383 return l4_debugger_kobj_to_id_u(cap, kobjp, l4_utcb());
384}
385
386L4_INLINE long
388 unsigned idx) L4_NOTHROW
389{
390 return l4_debugger_query_log_typeid_u(cap, name, idx, l4_utcb());
391}
392
393L4_INLINE long
395 char *name, unsigned namelen,
396 char *shortname, unsigned shortnamelen) L4_NOTHROW
397{
398 return l4_debugger_query_log_name_u(cap, idx, name, namelen,
399 shortname, shortnamelen, l4_utcb());
400}
401
404 int on_off) L4_NOTHROW
405{
406 return l4_debugger_switch_log_u(cap, name, on_off, l4_utcb());
407}
408
411 char *name, unsigned size) L4_NOTHROW
412{
413 return l4_debugger_get_object_name_u(cap, id, name, size, l4_utcb());
414}
415
418 const char *name) L4_NOTHROW
419{
420 return l4_debugger_add_image_info_u(cap, base, name, l4_utcb());
421}
L4 compiler related defines.
unsigned long l4_umword_t
Unsigned machine word.
Definition l4int.h:40
unsigned long l4_addr_t
Address type.
Definition l4int.h:34
unsigned long l4_cap_idx_t
Capability selector type.
Definition types.h:335
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:410
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:417
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:387
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:381
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:394
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:368
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:375
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:403
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:500
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:404
struct l4_utcb_t l4_utcb_t
Opaque type for the UTCB.
Definition utcb.h:56
l4_utcb_t * l4_utcb(void) L4_NOTHROW L4_PURE
Get the UTCB address.
Definition utcb.h:346
#define L4_NOTHROW
Mark a function declaration and definition as never throwing an exception.
Definition compiler.h:159
#define L4_INLINE
L4 Inline function attribute.
Definition compiler.h:51
Kernel object system calls.
Message tag data structure.
Definition types.h:153
l4_umword_t mr[L4_UTCB_GENERIC_DATA_SIZE]
Message registers.
Definition utcb.h:69