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/sys/kdebug.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",
{
{
if (ipc_stat)
enter_kdebug("Should not be 1");
}
else
{
if (!ipc_stat)
enter_kdebug("Should not be 0");
}
ipc_stat = !ipc_stat;
}
}
else
printf("Umm, non-handled request: %ld, %08lx %08lx\n",
{
printf("l4_ipc_call failed\n");
return 5;
}
}
return 0;
}