This example shows how a thread can be single stepped on the x86 architecture.
This example shows how a thread can be single stepped on the x86 architecture.
#include <l4/sys/ipc.h>
#include <l4/sys/thread.h>
#include <l4/sys/utcb.h>
#include <l4/util/util.h>
#include <stdlib.h>
#include <stdio.h>
static char thread_stack[8 << 10];
static void thread_func(void)
{
while (1)
{
unsigned long d = 0;
asm volatile("pushf; pop %0; or $256,%0; push %0; popf\n"
: "=r" (d) : "r" (d));
asm volatile("nop");
asm volatile("nop");
asm volatile("nop");
asm volatile("mov $0x12345000, %%edx" : : : "edx");
asm volatile("int $0x30\n");
asm volatile("nop");
asm volatile("nop");
asm volatile("nop");
asm volatile("pushf; pop %0; and $~256,%0; push %0; popf\n"
: "=r" (d) : "r" (d));
asm volatile("nop");
asm volatile("nop");
asm volatile("nop");
}
}
int main(void)
{
int ipc_stat = 0;
printf("Singlestep testing\n");
return 1;
return 1;
L4RE_THIS_TASK_CAP);
return 2;
0);
return 3;
return 4;
{
printf("l4_ipc_receive failed");
return 5;
}
for (;;)
{
{
printf("PC = %08lx Trap = %08lx Err = %08lx, SP = %08lx SC-Nr: %lx\n",
{
{
L4_UTCB_EXCEPTION_REGS_SIZE, 0, 0);
if (ipc_stat)
}
else
{
L4_UTCB_EXCEPTION_REGS_SIZE, 0, 0);
if (!ipc_stat)
}
ipc_stat = !ipc_stat;
}
}
else
printf("Umm, non-handled request: %ld, %08lx %08lx\n",
{
printf("l4_ipc_call failed\n");
return 5;
}
}
return 0;
}
Capability allocator C interface.
Common factory related definitions.
l4_cap_idx_t l4re_util_cap_alloc(void) L4_NOTHROW
Get free capability index at capability allocator.
l4re_env_t * l4re_env(void) L4_NOTHROW
Get L4Re initial environment.
unsigned long l4_umword_t
Unsigned machine word.
unsigned long l4_cap_idx_t
Capability selector type.
unsigned l4_is_invalid_cap(l4_cap_idx_t c) L4_NOTHROW
Test if a capability selector is the invalid capability.
l4_msgtag_t l4_factory_create_thread(l4_cap_idx_t factory, l4_cap_idx_t target_cap) L4_NOTHROW
Create a new thread.
l4_msgtag_t l4_ipc_receive(l4_cap_idx_t object, l4_utcb_t *utcb, l4_timeout_t timeout) L4_NOTHROW
Wait for a message from a specific source.
l4_msgtag_t l4_ipc_call(l4_cap_idx_t object, l4_utcb_t *utcb, l4_msgtag_t tag, l4_timeout_t timeout) L4_NOTHROW
Object call (usual invocation).
long l4_error(l4_msgtag_t tag) L4_NOTHROW
Get IPC error code if any or message tag label otherwise for an IPC call.
unsigned l4_msgtag_is_exception(l4_msgtag_t t) L4_NOTHROW
Test for exception protocol.
unsigned l4_msgtag_has_error(l4_msgtag_t t) L4_NOTHROW
Test for error indicator flag.
l4_msgtag_t l4_msgtag(long label, unsigned words, unsigned items, unsigned flags) L4_NOTHROW
Create a message tag from the specified values.
long l4_msgtag_label(l4_msgtag_t t) L4_NOTHROW
Get the protocol of tag.
@ L4_PROTO_NONE
Default protocol tag to reply to kernel.
@ L4_PROTO_ALLOW_SYSCALL
Allow an alien the system call.
l4_msgtag_t l4_scheduler_run_thread(l4_cap_idx_t scheduler, l4_cap_idx_t thread, l4_sched_param_t const *sp) L4_NOTHROW)
Run a thread on a Scheduler.
l4_sched_param_t l4_sched_param(unsigned prio, l4_umword_t quantum=0) L4_NOTHROW
Construct scheduler parameter.
l4_msgtag_t l4_thread_ex_regs(l4_cap_idx_t thread, l4_addr_t ip, l4_addr_t sp, l4_umword_t flags) L4_NOTHROW
Exchange basic thread registers.
void l4_thread_control_bind(l4_utcb_t *thread_utcb, l4_cap_idx_t task) L4_NOTHROW
Bind the thread to a task.
l4_msgtag_t l4_thread_control_commit(l4_cap_idx_t thread) L4_NOTHROW
Commit the thread control parameters.
void l4_thread_control_alien(int on) L4_NOTHROW
Enable alien mode.
void l4_thread_control_exc_handler(l4_cap_idx_t exc_handler) L4_NOTHROW
Set the exception handler.
void l4_thread_control_start(void) L4_NOTHROW
Start a thread control API sequence.
void l4_thread_control_pager(l4_cap_idx_t pager) L4_NOTHROW
Set the pager.
#define L4_IPC_NEVER
never timeout
l4_msg_regs_t * l4_utcb_mr(void) L4_NOTHROW L4_PURE
Get the message-register block of a UTCB.
struct l4_utcb_t l4_utcb_t
Opaque type for the UTCB.
l4_utcb_t * l4_utcb(void) L4_NOTHROW L4_PURE
Get the UTCB address.
l4_exc_regs_t * l4_utcb_exc(void) L4_NOTHROW L4_PURE
Get the message-register block of a UTCB (for an exception IPC).
l4_umword_t l4_utcb_exc_pc(l4_exc_regs_t const *u) L4_NOTHROW L4_PURE
Access function to get the program counter of the exception state.
void l4_touch_rw(const void *addr, unsigned size) L4_NOTHROW
Touch data areas to force mapping (read-write)
void l4_sleep(l4_uint32_t ms) L4_NOTHROW
Suspend thread for a period of ms milliseconds.
void l4_touch_ro(const void *addr, unsigned size) L4_NOTHROW
Touch data area to force mapping (read-only)
Functionality for invoking the kernel debugger.
void enter_kdebug(char const *text) L4_NOTHROW
Enter the kernel debugger.
UTCB structure for exceptions.
l4_umword_t trapno
trap number
l4_umword_t sp
stack pointer
l4_umword_t err
error code
Message tag data structure.
l4_umword_t mr[L4_UTCB_GENERIC_DATA_SIZE]
Message registers.