syscall trace finished
This commit is contained in:
@@ -146,6 +146,9 @@ found:
|
||||
p->context.ra = (uint64)forkret;
|
||||
p->context.sp = p->kstack + PGSIZE;
|
||||
|
||||
// 初始化计数器
|
||||
memset(p->syscall_counts, 0, sizeof(p->syscall_counts));
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#include "defs.h"
|
||||
// Saved registers for kernel context switches.
|
||||
struct context {
|
||||
uint64 ra;
|
||||
@@ -105,4 +106,5 @@ struct proc {
|
||||
struct file *ofile[NOFILE]; // Open files
|
||||
struct inode *cwd; // Current directory
|
||||
char name[16]; // Process name (debugging)
|
||||
int syscall_counts[24]; // 每个系统调用的调用次数
|
||||
};
|
||||
|
||||
@@ -147,7 +147,9 @@ syscall(void)
|
||||
// and store its return value in p->trapframe->a0
|
||||
p->trapframe->a0 = syscalls[num]();
|
||||
if (p->tracemask & (1 << num)) {
|
||||
printf("%d: syscall %s -> %d\n",p->pid, syscalls_name[num], p->trapframe->a0);
|
||||
p->syscall_counts[num]++;
|
||||
printf("%d: syscall %s(trace counts: %d) -> %d\n",
|
||||
p->pid, syscalls_name[num], p->syscall_counts[num], p->trapframe->a0);
|
||||
}
|
||||
} else {
|
||||
printf("%d %s: unknown sys call %d\n",
|
||||
|
||||
Reference in New Issue
Block a user