#include #include #include #include #include #include #include #define TRAP_FLAG 0x100 # define ENTER_KERNEL "int $0x80\n\t" #define STACK_LIMIT 90000 #define HEAP_LIMIT 0x200000 void test_libfunction(const char *ori) { int result; /* set probepoint at strcmp function, when program is * loaded to run, it will load first few page into page, * and then load page on demand */ result = strcmp(ori,"1234"); } void test_stack(){ int i; int p[STACK_LIMIT]; /* set user probepoint here, and default there will * be do_page_fault handler to expand stack */ p[0]=0; i=0; i++; } void test_heap(){ char *pchar; pchar = (char*) malloc(HEAP_LIMIT); pchar += (HEAP_LIMIT - 1); *pchar = 'c'; //set probe point here } int test_dummy(int i) { return i+1; } void test_functioncall() { int i; i=0; /* set probepoint at function call point */ test_dummy(i); } void test_functionreturn() { int i; i=0; /* set probepoint at function return point */ return; } void test_trap3() { /* set probepoint at here */ asm volatile (".byte 0xcc"); } void test_syscall() { /* set probepoint at int 0x80 point */ asm volatile (ENTER_KERNEL : : "a" (20) /* getpid() */); } void my_trap(int sig) { printf("trap1 : PASS\n"); } void test_fork(){ int pid, status; char *pchar; pchar = (char*) malloc(HEAP_LIMIT); pchar += (HEAP_LIMIT - 1); pid= fork(); if (pid == 0){ /* here it will generate COW, and set probepoint here */ *pchar = 'c'; exit(0); } else{ wait(&status); } } int main() { int result,pid; int status; int i; char *pchar; signal(SIGTRAP, my_trap); /* set probepoint at i=i+1 point */ i=i+1; pchar = "12345"; test_libfunction(pchar); test_stack(); test_heap(); test_functioncall(); test_functionreturn(); test_trap3(); test_syscall(); test_fork(); printf("finished\n"); return 0; }