Loading...
Searching...
No Matches
debugger.h
Go to the documentation of this file.
#pragma once
/*
* (c) 2008-2011 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
* Alexander Warg <warg@os.inf.tu-dresden.de>
* economic rights: Technische Universität Dresden (Germany)
*
* License: see LICENSE.spdx (in this directory or the directories above)
*/
#include <l4/sys/compiler.h>
#include <l4/sys/utcb.h>
#include <l4/sys/ipc.h>
L4_INLINE l4_msgtag_t
l4_debugger_set_object_name(l4_cap_idx_t cap, const char *name) L4_NOTHROW;
L4_INLINE l4_msgtag_t
l4_debugger_set_object_name_u(l4_cap_idx_t cap, const char *name, l4_utcb_t *utcb) L4_NOTHROW;
L4_INLINE l4_msgtag_t
l4_debugger_get_object_name(l4_cap_idx_t cap, unsigned id,
char *name, unsigned size) L4_NOTHROW;
L4_INLINE l4_msgtag_t
l4_debugger_get_object_name_u(l4_cap_idx_t cap, unsigned id,
char *name, unsigned size,
l4_utcb_t *utcb) L4_NOTHROW;
L4_INLINE unsigned long
l4_debugger_global_id(l4_cap_idx_t cap) L4_NOTHROW;
L4_INLINE unsigned long
l4_debugger_global_id_u(l4_cap_idx_t cap, l4_utcb_t *utcb) L4_NOTHROW;
L4_INLINE unsigned long
l4_debugger_kobj_to_id(l4_cap_idx_t cap, l4_addr_t kobjp) L4_NOTHROW;
L4_INLINE unsigned long
l4_debugger_kobj_to_id_u(l4_cap_idx_t cap, l4_addr_t kobjp, l4_utcb_t *utcb) L4_NOTHROW;
L4_INLINE long
l4_debugger_query_log_typeid(l4_cap_idx_t cap, const char *name,
unsigned idx) L4_NOTHROW;
L4_INLINE long
l4_debugger_query_log_typeid_u(l4_cap_idx_t cap, const char *name,
unsigned idx, l4_utcb_t *utcb) L4_NOTHROW;
L4_INLINE long
l4_debugger_query_log_name(l4_cap_idx_t cap, unsigned idx,
char *name, unsigned namelen,
char *shortname, unsigned shortnamelen) L4_NOTHROW;
L4_INLINE long
l4_debugger_query_log_name_u(l4_cap_idx_t cap, unsigned idx,
char *name, unsigned namelen,
char *shortname, unsigned shortnamelen,
l4_utcb_t *utcb) L4_NOTHROW;
L4_INLINE l4_msgtag_t
l4_debugger_switch_log(l4_cap_idx_t cap, const char *name,
int on_off) L4_NOTHROW;
L4_INLINE l4_msgtag_t
l4_debugger_switch_log_u(l4_cap_idx_t cap, const char *name, int on_off,
l4_utcb_t *utcb) L4_NOTHROW;
L4_INLINE l4_msgtag_t
l4_debugger_add_image_info(l4_cap_idx_t cap, l4_addr_t base,
const char *name) L4_NOTHROW;
L4_INLINE l4_msgtag_t
l4_debugger_add_image_info_u(l4_cap_idx_t cap, l4_addr_t base, const char *name,
l4_utcb_t *utcb) L4_NOTHROW;
enum
{
L4_DEBUGGER_NAME_SET_OP = 0UL,
L4_DEBUGGER_GLOBAL_ID_OP = 1UL,
L4_DEBUGGER_KOBJ_TO_ID_OP = 2UL,
L4_DEBUGGER_QUERY_LOG_TYPEID_OP = 3UL,
L4_DEBUGGER_SWITCH_LOG_OP = 4UL,
L4_DEBUGGER_NAME_GET_OP = 5UL,
L4_DEBUGGER_QUERY_LOG_NAME_OP = 6UL,
L4_DEBUGGER_ADD_IMAGE_INFO_OP = 7UL,
};
enum
{
L4_DEBUGGER_SWITCH_LOG_ON = 1,
L4_DEBUGGER_SWITCH_LOG_OFF = 0,
};
/* IMPLEMENTATION -----------------------------------------------------------*/
#include <l4/sys/kernel_object.h>
L4_INLINE unsigned
__strcpy_maxlen(char *dst, char const *src, unsigned maxlen)
{
unsigned i;
if (!maxlen)
return 0;
for (i = 0; i < maxlen - 1 && src[i]; ++i)
dst[i] = src[i];
dst[i] = '\0';
return i + 1;
}
L4_INLINE l4_msgtag_t
l4_debugger_set_object_name_u(l4_cap_idx_t cap,
const char *name, l4_utcb_t *utcb) L4_NOTHROW
{
unsigned i;
l4_utcb_mr_u(utcb)->mr[0] = L4_DEBUGGER_NAME_SET_OP;
i = __strcpy_maxlen((char *)&l4_utcb_mr_u(utcb)->mr[1], name,
(L4_UTCB_GENERIC_DATA_SIZE - 2) * sizeof(l4_umword_t));
i = l4_bytes_to_mwords(i);
return l4_invoke_debugger(cap, l4_msgtag(0, 1 + i, 0, 0), utcb);
}
L4_INLINE unsigned long
l4_debugger_global_id_u(l4_cap_idx_t cap, l4_utcb_t *utcb) L4_NOTHROW
{
l4_utcb_mr_u(utcb)->mr[0] = L4_DEBUGGER_GLOBAL_ID_OP;
if (l4_error_u(l4_invoke_debugger(cap, l4_msgtag(0, 1, 0, 0), utcb), utcb))
return ~0UL;
return l4_utcb_mr_u(utcb)->mr[0];
}
L4_INLINE unsigned long
l4_debugger_kobj_to_id_u(l4_cap_idx_t cap, l4_addr_t kobjp, l4_utcb_t *utcb) L4_NOTHROW
{
l4_utcb_mr_u(utcb)->mr[0] = L4_DEBUGGER_KOBJ_TO_ID_OP;
l4_utcb_mr_u(utcb)->mr[1] = kobjp;
if (l4_error_u(l4_invoke_debugger(cap, l4_msgtag(0, 2, 0, 0), utcb), utcb))
return ~0UL;
return l4_utcb_mr_u(utcb)->mr[0];
}
L4_INLINE long
l4_debugger_query_log_typeid_u(l4_cap_idx_t cap, const char *name,
unsigned idx,
l4_utcb_t *utcb) L4_NOTHROW
{
unsigned i;
long e;
l4_utcb_mr_u(utcb)->mr[0] = L4_DEBUGGER_QUERY_LOG_TYPEID_OP;
l4_utcb_mr_u(utcb)->mr[1] = idx;
i = __strcpy_maxlen((char *)&l4_utcb_mr_u(utcb)->mr[2], name, 32);
i = l4_bytes_to_mwords(i);
e = l4_error_u(l4_invoke_debugger(cap, l4_msgtag(0, 2 + i, 0, 0), utcb), utcb);
if (e < 0)
return e;
return l4_utcb_mr_u(utcb)->mr[0];
}
L4_INLINE long
l4_debugger_query_log_name_u(l4_cap_idx_t cap, unsigned idx,
char *name, unsigned namelen,
char *shortname, unsigned shortnamelen,
l4_utcb_t *utcb) L4_NOTHROW
{
long e;
char const *n;
l4_utcb_mr_u(utcb)->mr[0] = L4_DEBUGGER_QUERY_LOG_NAME_OP;
l4_utcb_mr_u(utcb)->mr[1] = idx;
e = l4_error_u(l4_invoke_debugger(cap, l4_msgtag(0, 2, 0, 0), utcb), utcb);
if (e < 0)
return e;
n = (char const *)&l4_utcb_mr_u(utcb)->mr[0];
__strcpy_maxlen(name, n, namelen);
__strcpy_maxlen(shortname, n + __builtin_strlen(n) + 1, shortnamelen);
return 0;
}
L4_INLINE l4_msgtag_t
l4_debugger_switch_log_u(l4_cap_idx_t cap, const char *name, int on_off,
l4_utcb_t *utcb) L4_NOTHROW
{
unsigned i;
l4_utcb_mr_u(utcb)->mr[0] = L4_DEBUGGER_SWITCH_LOG_OP;
l4_utcb_mr_u(utcb)->mr[1] = on_off;
i = __strcpy_maxlen((char *)&l4_utcb_mr_u(utcb)->mr[2], name, 32);
i = l4_bytes_to_mwords(i);
return l4_invoke_debugger(cap, l4_msgtag(0, 2 + i, 0, 0), utcb);
}
L4_INLINE l4_msgtag_t
l4_debugger_get_object_name_u(l4_cap_idx_t cap, unsigned id,
char *name, unsigned size,
l4_utcb_t *utcb) L4_NOTHROW
{
l4_msgtag_t t;
l4_utcb_mr_u(utcb)->mr[0] = L4_DEBUGGER_NAME_GET_OP;
l4_utcb_mr_u(utcb)->mr[1] = id;
t = l4_invoke_debugger(cap, l4_msgtag(0, 2, 0, 0), utcb);
__strcpy_maxlen(name, (char const *)&l4_utcb_mr_u(utcb)->mr[0], size);
return t;
}
L4_INLINE l4_msgtag_t
l4_debugger_add_image_info_u(l4_cap_idx_t cap, l4_addr_t base,
const char *name, l4_utcb_t *utcb) L4_NOTHROW
{
unsigned i;
l4_utcb_mr_u(utcb)->mr[0] = L4_DEBUGGER_ADD_IMAGE_INFO_OP;
l4_utcb_mr_u(utcb)->mr[1] = base;
i = __strcpy_maxlen((char *)&l4_utcb_mr_u(utcb)->mr[2], name,
(L4_UTCB_GENERIC_DATA_SIZE - 3) * sizeof(l4_umword_t));
i = l4_bytes_to_mwords(i);
return l4_invoke_debugger(cap, l4_msgtag(0, 2 + i, 0, 0), utcb);
}
L4_INLINE l4_msgtag_t
l4_debugger_set_object_name(l4_cap_idx_t cap,
const char *name) L4_NOTHROW
{
return l4_debugger_set_object_name_u(cap, name, l4_utcb());
}
L4_INLINE unsigned long
l4_debugger_global_id(l4_cap_idx_t cap) L4_NOTHROW
{
return l4_debugger_global_id_u(cap, l4_utcb());
}
L4_INLINE unsigned long
l4_debugger_kobj_to_id(l4_cap_idx_t cap, l4_addr_t kobjp) L4_NOTHROW
{
return l4_debugger_kobj_to_id_u(cap, kobjp, l4_utcb());
}
L4_INLINE long
l4_debugger_query_log_typeid(l4_cap_idx_t cap, const char *name,
unsigned idx) L4_NOTHROW
{
return l4_debugger_query_log_typeid_u(cap, name, idx, l4_utcb());
}
L4_INLINE long
l4_debugger_query_log_name(l4_cap_idx_t cap, unsigned idx,
char *name, unsigned namelen,
char *shortname, unsigned shortnamelen) L4_NOTHROW
{
return l4_debugger_query_log_name_u(cap, idx, name, namelen,
shortname, shortnamelen, l4_utcb());
}
L4_INLINE l4_msgtag_t
l4_debugger_switch_log(l4_cap_idx_t cap, const char *name,
int on_off) L4_NOTHROW
{
return l4_debugger_switch_log_u(cap, name, on_off, l4_utcb());
}
L4_INLINE l4_msgtag_t
l4_debugger_get_object_name(l4_cap_idx_t cap, unsigned id,
char *name, unsigned size) L4_NOTHROW
{
return l4_debugger_get_object_name_u(cap, id, name, size, l4_utcb());
}
L4_INLINE l4_msgtag_t
l4_debugger_add_image_info(l4_cap_idx_t cap, l4_addr_t base,
const char *name) L4_NOTHROW
{
return l4_debugger_add_image_info_u(cap, base, name, l4_utcb());
}
compiler.h
L4 compiler related defines.
l4_umword_t
unsigned long l4_umword_t
Unsigned machine word.
Definition l4int.h:40
l4_addr_t
unsigned long l4_addr_t
Address type.
Definition l4int.h:34
l4_cap_idx_t
unsigned long l4_cap_idx_t
Capability selector type.
Definition types.h:336
l4_debugger_get_object_name
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_debugger_add_image_info
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
l4_debugger_query_log_typeid
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
l4_debugger_kobj_to_id
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
l4_debugger_query_log_name
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_debugger_set_object_name
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
l4_debugger_global_id
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_debugger_switch_log
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
l4_bytes_to_mwords
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:496
l4_msgtag
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:405
l4_utcb_t
struct l4_utcb_t l4_utcb_t
Opaque type for the UTCB.
Definition utcb.h:56
l4_utcb
l4_utcb_t * l4_utcb(void) L4_NOTHROW L4_PURE
Get the UTCB address.
Definition utcb.h:346
L4_NOTHROW
#define L4_NOTHROW
Mark a function declaration and definition as never throwing an exception.
Definition compiler.h:161
L4_INLINE
#define L4_INLINE
L4 Inline function attribute.
Definition compiler.h:51
kernel_object.h
Kernel object system calls.
ipc.h
Common IPC interface.
utcb.h
UTCB definitions.
l4_msgtag_t
Message tag data structure.
Definition types.h:154