![]() Remember to add the prototypes for the helper functions to kernel/defs.h: // kalloc. Add a function to kernel/proc.c to collect the number of processes.If (p->syscall_trace & (1 pagetable, addr, (char *)&sinfo, sizeof(sinfo)) next to the function that handles the system call. An array mapping syscall numbers from syscall.h Prototypes for the functions that handle system calls. Modify the syscall function in kernel/syscall.c to print the trace output.Safestrcpy(np->name, p->name, sizeof(p->name)) Modify fork in kernel/proc.c to copy the trace mask from the parent to the child process.(While sys_trace can technically be located in any file, placing it in kernel/sysproc.c simplifies its classification.)Ĭhar name // Process name (debugging) Add a sys_trace function in kernel/sysproc.c that implements the new system call by remembering its argument in a new variable in the proc structure in kernel/proc.h.Add a prototype for the system call to user/user.h, a stub to user/, and a syscall number to kernel/syscall.h.The task becomes trivial following the hints: ![]() We can see that the pid of initcode is 1. We proceed by entering n twice so that struct proc *p = myproc() is excuted. What is the value of p->trapframe->a7 and what does that value represent? (Hint: look user/initcode.S, the first user program xv6 starts.) It appears that syscall was called by usertrap, as indicated by the backtrace output. When xv6 starts, it launches a simple shell allowing to execute some basic commands. The code above produces the following result: #0 syscall () at kernel/syscall.c:163 This command starts xv6 in the qemu emulator. Thread 2 hit Breakpoint 1, syscall () at kernel/syscall.c:243 gdbinitīreakpoint 1 at 0x80002142: file kernel/syscall.c, line 243. We begin with launching gdb: $ make qemu-gdbĪnd follow the instructions step by step: $ gdb-multiarch -x. Looking at the backtrace output, which function called syscall?
0 Comments
Leave a Reply. |