提交 93bde1e9 创建 作者: Silas Boyd-Wickizer's avatar Silas Boyd-Wickizer

Don't do mtrace stuff if not MTRACE.

上级 e2fb4373
...@@ -222,7 +222,9 @@ allocproc(void) ...@@ -222,7 +222,9 @@ allocproc(void)
p->cpuid = mycpu()->id; p->cpuid = mycpu()->id;
p->on_runq = -1; p->on_runq = -1;
p->cpu_pin = 0; p->cpu_pin = 0;
#if MTRACE
p->mtrace_stacks.curr = -1; p->mtrace_stacks.curr = -1;
#endif
snprintf(p->lockname, sizeof(p->lockname), "cv:proc:%d", p->pid); snprintf(p->lockname, sizeof(p->lockname), "cv:proc:%d", p->pid);
initlock(&p->lock, p->lockname+3); initlock(&p->lock, p->lockname+3);
......
...@@ -52,16 +52,17 @@ struct context { ...@@ -52,16 +52,17 @@ struct context {
} __attribute__((packed)); } __attribute__((packed));
// Per-process, per-stack meta data for mtrace // Per-process, per-stack meta data for mtrace
#if MTRACE
#define MTRACE_NSTACKS 16 #define MTRACE_NSTACKS 16
#define MTRACE_TAGSHIFT 28 #define MTRACE_TAGSHIFT 28
#if NCPU > 16 #if NCPU > 16
#error Oops -- decrease MTRACE_TAGSHIFT #error Oops -- decrease MTRACE_TAGSHIFT
#endif #endif
struct mtrace_stacks { struct mtrace_stacks {
int curr; int curr;
unsigned long tag[MTRACE_NSTACKS]; unsigned long tag[MTRACE_NSTACKS];
}; };
#endif
enum procstate { UNUSED, EMBRYO, SLEEPING, RUNNABLE, RUNNING, ZOMBIE }; enum procstate { UNUSED, EMBRYO, SLEEPING, RUNNABLE, RUNNING, ZOMBIE };
...@@ -93,7 +94,9 @@ struct proc { ...@@ -93,7 +94,9 @@ struct proc {
char lockname[16]; char lockname[16];
int on_runq; int on_runq;
int cpu_pin; int cpu_pin;
#if MTRACE
struct mtrace_stacks mtrace_stacks; struct mtrace_stacks mtrace_stacks;
#endif
}; };
extern struct ns *nspid; extern struct ns *nspid;
...@@ -63,9 +63,11 @@ trap(struct trapframe *tf) ...@@ -63,9 +63,11 @@ trap(struct trapframe *tf)
return; return;
} }
#if MTRACE
if (myproc()->mtrace_stacks.curr >= 0) if (myproc()->mtrace_stacks.curr >= 0)
mtrace_kstack_pause(myproc()); mtrace_kstack_pause(myproc());
mtrace_kstack_start(trap, myproc()); mtrace_kstack_start(trap, myproc());
#endif
switch(tf->trapno){ switch(tf->trapno){
case T_IRQ0 + IRQ_TIMER: case T_IRQ0 + IRQ_TIMER:
...@@ -113,9 +115,11 @@ trap(struct trapframe *tf) ...@@ -113,9 +115,11 @@ trap(struct trapframe *tf)
if(tf->trapno == T_PGFLT){ if(tf->trapno == T_PGFLT){
if(pagefault(myproc()->vmap, rcr2(), tf->err) >= 0){ if(pagefault(myproc()->vmap, rcr2(), tf->err) >= 0){
#if MTRACE
mtrace_kstack_stop(myproc()); mtrace_kstack_stop(myproc());
if (myproc()->mtrace_stacks.curr >= 0) if (myproc()->mtrace_stacks.curr >= 0)
mtrace_kstack_resume(myproc()); mtrace_kstack_resume(myproc());
#endif
return; return;
} }
} }
...@@ -143,9 +147,11 @@ trap(struct trapframe *tf) ...@@ -143,9 +147,11 @@ trap(struct trapframe *tf)
if(myproc() && myproc()->killed && (tf->cs&3) == 0x3) if(myproc() && myproc()->killed && (tf->cs&3) == 0x3)
exit(); exit();
#if MTRACE
mtrace_kstack_stop(myproc()); mtrace_kstack_stop(myproc());
if (myproc()->mtrace_stacks.curr >= 0) if (myproc()->mtrace_stacks.curr >= 0)
mtrace_kstack_resume(myproc()); mtrace_kstack_resume(myproc());
#endif
} }
void void
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论