提交 1be8db63 创建 作者: Silas Boyd-Wickizer's avatar Silas Boyd-Wickizer

Return of the Mtrace.

上级 781658d0
...@@ -19,5 +19,5 @@ mkfs ...@@ -19,5 +19,5 @@ mkfs
/mscan.out /mscan.out
/mscan.sorted /mscan.sorted
/mscan.syms /mscan.syms
/mscan.kern /mscan.kernel
config.mk config.mk
...@@ -2,22 +2,23 @@ ...@@ -2,22 +2,23 @@
# XXX compiling user progs with -mcmodel=kernel # XXX compiling user progs with -mcmodel=kernel
# #
# Custom config file? Set the default below.. # Custom config file? Otherwise use defaults.
-include config.mk -include config.mk
TOOLPREFIX ?= x86_64-jos-elf- TOOLPREFIX ?= x86_64-jos-elf-
QEMU ?= qemu-system-x86_64 QEMU ?= qemu-system-x86_64
CPUS ?= 4 QEMUSMP ?= 4
QEMUSRC ?= ../mtrace
MTRACE ?= $(QEMU)
NM = $(TOOLPREFIX)nm CC = $(TOOLPREFIX)clang
#CC = $(TOOLPREFIX)clang
CC = $(TOOLPREFIX)gcc CC = $(TOOLPREFIX)gcc
AS = $(TOOLPREFIX)gas AS = $(TOOLPREFIX)gas
LD = $(TOOLPREFIX)ld LD = $(TOOLPREFIX)ld
NM = $(TOOLPREFIX)nm
OBJCOPY = $(TOOLPREFIX)objcopy OBJCOPY = $(TOOLPREFIX)objcopy
OBJDUMP = $(TOOLPREFIX)objdump
CFLAGS = -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb -m64 \ CFLAGS = -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb \
-Werror -std=c99 -fms-extensions -mno-sse -mcmodel=kernel -m64 -Werror -std=c99 -fms-extensions -mno-sse -mcmodel=kernel -I$(QEMUSRC)
CFLAGS += $(shell $(CC) -fno-stack-protector -E -x c /dev/null >/dev/null 2>&1 && echo -fno-stack-protector) CFLAGS += $(shell $(CC) -fno-stack-protector -E -x c /dev/null >/dev/null 2>&1 && echo -fno-stack-protector)
ASFLAGS = -m64 -gdwarf-2 ASFLAGS = -m64 -gdwarf-2
LDFLAGS += -m elf_x86_64 LDFLAGS += -m elf_x86_64
...@@ -91,18 +92,29 @@ mkfs: mkfs.c fs.h ...@@ -91,18 +92,29 @@ mkfs: mkfs.c fs.h
fs.img: mkfs README $(UPROGS) fs.img: mkfs README $(UPROGS)
./mkfs fs.img README $(UPROGS) ./mkfs fs.img README $(UPROGS)
mscan.syms: kernel
$(NM) -S $< > $@
mscan.kernel: kernel
cp $< $@
-include *.d -include *.d
.PHONY: clean qemu gdb ud0 .PHONY: clean qemu gdb ud0
clean: QEMUOPTS = -smp $(QEMUSMP) -m 512 -serial mon:stdio -nographic
rm -f *.o *.d *.asm *.sym initcode kernel bootother mkfs fs.img MTRACEOPTS = -rtc clock=vm -mtrace-enable -mtrace-file mtrace.out \
-mtrace-quantum 100
QEMUOPTS = -smp $(CPUS) -m 512 -serial mon:stdio -nographic
qemu: kernel qemu: kernel
$(QEMU) $(QEMUOPTS) -kernel kernel $(QEMU) $(QEMUOPTS) -kernel kernel
gdb: kernel gdb: kernel
$(QEMU) $(QEMUOPTS) -kernel kernel -S -s $(QEMU) $(QEMUOPTS) -kernel kernel -S -s
mtrace: mscan.kernel mscan.syms
$(MTRACE) $(QEMUOPTS) $(MTRACEOPTS) -kernel kernel
ud0: kernel ud0: kernel
rsync -avP kernel amsterdam.csail.mit.edu:/tftpboot/ud0/kernel.xv6 rsync -avP kernel amsterdam.csail.mit.edu:/tftpboot/ud0/kernel.xv6
clean:
rm -f *.o *.d *.asm *.sym initcode kernel bootother mkfs fs.img
#include "types.h" #include "types.h"
#include "stat.h" #include "stat.h"
#include "user.h" #include "user.h"
#include "xv6-mtrace.h" #include "mtrace.h"
#include "amd64.h" #include "amd64.h"
#include "param.h" #include "param.h"
#include "fcntl.h" #include "fcntl.h"
......
#include "types.h" #include "types.h"
#include "stat.h" #include "stat.h"
#include "user.h" #include "user.h"
#include "xv6-mtrace.h" #include "mtrace.h"
#define NCHILD 2 #define NCHILD 2
#define NDEPTH 7 #define NDEPTH 7
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include "types.h" #include "types.h"
#include "stat.h" #include "stat.h"
#include "user.h" #include "user.h"
#include "xv6-mtrace.h" #include "mtrace.h"
#define N 100 #define N 100
#define DEBUG 0 #define DEBUG 0
......
#include "types.h" #include "types.h"
#include "stat.h" #include "stat.h"
#include "user.h" #include "user.h"
#include "xv6-mtrace.h" #include "mtrace.h"
#define NCHILD 2 #define NCHILD 2
#define NDEPTH 5 #define NDEPTH 5
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include "kernel.h" #include "kernel.h"
#include "spinlock.h" #include "spinlock.h"
#include "kalloc.h" #include "kalloc.h"
#include "xv6-mtrace.h" #include "mtrace.h"
#include "cpu.h" #include "cpu.h"
struct kmem kmems[NCPU]; struct kmem kmems[NCPU];
...@@ -55,12 +55,7 @@ kfree_pool(struct kmem *m, char *v) ...@@ -55,12 +55,7 @@ kfree_pool(struct kmem *m, char *v)
m->freelist = r; m->freelist = r;
m->nfree++; m->nfree++;
if (kinited) if (kinited)
mtrace_label_register(mtrace_label_block, mtunlabel(mtrace_label_block, r);
r,
0,
0,
0,
RET_EIP());
release(&m->lock); release(&m->lock);
} }
...@@ -101,12 +96,7 @@ kmemalloc(struct kmem *km) ...@@ -101,12 +96,7 @@ kmemalloc(struct kmem *km)
return 0; return 0;
} }
mtrace_label_register(mtrace_label_block, mtlabel(mtrace_label_block, r, m->size, "kalloc", sizeof("kalloc"));
r,
m->size,
"kalloc",
sizeof("kalloc"),
RET_EIP());
if (kalloc_memset) if (kalloc_memset)
memset(r, 2, m->size); memset(r, 2, m->size);
...@@ -224,12 +214,7 @@ kmfree(void *ap) ...@@ -224,12 +214,7 @@ kmfree(void *ap)
{ {
acquire(&freelists[mycpu()->id].lock); acquire(&freelists[mycpu()->id].lock);
domfree(ap); domfree(ap);
mtrace_label_register(mtrace_label_heap, mtunlabel(mtrace_label_heap, ap);
ap,
0,
0,
0,
RET_EIP());
release(&freelists[mycpu()->id].lock); release(&freelists[mycpu()->id].lock);
} }
...@@ -289,12 +274,7 @@ kmalloc(u64 nbytes) ...@@ -289,12 +274,7 @@ kmalloc(u64 nbytes)
release(&freelists[mycpu()->id].lock); release(&freelists[mycpu()->id].lock);
if (r) if (r)
mtrace_label_register(mtrace_label_heap, mtlabel(mtrace_label_heap, r, nbytes, "kmalloc'ed", sizeof("kmalloc'ed"));
r,
nbytes,
"kmalloc'ed",
sizeof("kmalloc'ed"),
RET_EIP());
return r; return r;
} }
......
#include "xv6-mtrace.h" #include "mtrace.h"
#if MTRACE
// Tell mtrace about switching threads
struct kstack_tag { struct kstack_tag {
int val __attribute__((aligned (CACHELINE))); int val __mpalign__;
}; };
extern struct kstack_tag kstack_tag[NCPU]; extern struct kstack_tag kstack_tag[NCPU];
static inline void mtrace_kstack_start(void *eip, static inline void mtstart(void *ip, struct proc *p)
struct proc *p)
{ {
unsigned long new_tag; unsigned long new_tag;
int i; int i;
pushcli(); pushcli();
xchg((uint *)&i, 0); new_tag = ++(kstack_tag[mycpu()->id].val) | (mycpu()->id<<MTRACE_TAGSHIFT);
new_tag = ++(kstack_tag[cpu->id].val) | (cpu->id << MTRACE_TAGSHIFT);
i = ++p->mtrace_stacks.curr; i = ++p->mtrace_stacks.curr;
if (i >= MTRACE_NSTACKS) if (i >= MTRACE_NSTACKS)
panic("mtrace_kstack_start: ran out of slots"); panic("mtrace_kstack_start: ran out of slots");
p->mtrace_stacks.tag[i] = new_tag; p->mtrace_stacks.tag[i] = new_tag;
mtrace_fcall_register(p->pid, (unsigned long)eip, mtrace_fcall_register(p->pid, (unsigned long)ip,
p->mtrace_stacks.tag[i], i, mtrace_start); p->mtrace_stacks.tag[i], i, mtrace_start);
popcli(); popcli();
} }
static inline void mtrace_kstack_stop(struct proc *p) static inline void mtstop(struct proc *p)
{ {
int i; int i;
pushcli(); pushcli();
...@@ -36,7 +35,7 @@ static inline void mtrace_kstack_stop(struct proc *p) ...@@ -36,7 +35,7 @@ static inline void mtrace_kstack_stop(struct proc *p)
popcli(); popcli();
} }
static inline void mtrace_kstack_pause(struct proc *p) static inline void mtpause(struct proc *p)
{ {
int i; int i;
...@@ -46,7 +45,7 @@ static inline void mtrace_kstack_pause(struct proc *p) ...@@ -46,7 +45,7 @@ static inline void mtrace_kstack_pause(struct proc *p)
mtrace_fcall_register(p->pid, 0, p->mtrace_stacks.tag[i], i, mtrace_pause); mtrace_fcall_register(p->pid, 0, p->mtrace_stacks.tag[i], i, mtrace_pause);
} }
static inline void mtrace_kstack_resume(struct proc *p) static inline void mtresume(struct proc *p)
{ {
int i; int i;
...@@ -55,3 +54,9 @@ static inline void mtrace_kstack_resume(struct proc *p) ...@@ -55,3 +54,9 @@ static inline void mtrace_kstack_resume(struct proc *p)
panic("mtrace_kstack_resume: bad stack"); panic("mtrace_kstack_resume: bad stack");
mtrace_fcall_register(p->pid, 0, p->mtrace_stacks.tag[i], i, mtrace_resume); mtrace_fcall_register(p->pid, 0, p->mtrace_stacks.tag[i], i, mtrace_resume);
} }
#else
#define mtstart(ip, p) do { } while (0)
#define mtstop(p) do { } while (0)
#define mtpause(p) do { } while (0)
#define mtresume(p) do { } while (0)
#endif
#include "types.h" #include "types.h"
#include "stat.h" #include "stat.h"
#include "user.h" #include "user.h"
#include "xv6-mtrace.h" #include "mtrace.h"
#include "amd64.h" #include "amd64.h"
#include "uspinlock.h" #include "uspinlock.h"
......
#include "types.h" #include "types.h"
#include "stat.h" #include "stat.h"
#include "user.h" #include "user.h"
#include "xv6-mtrace.h" #include "mtrace.h"
#include "amd64.h" #include "amd64.h"
#include "uspinlock.h" #include "uspinlock.h"
......
#if MTRACE
typedef __signed char int8_t;
typedef unsigned char uint8_t;
typedef short int16_t;
typedef unsigned short uint16_t;
typedef int int32_t;
typedef unsigned int uint32_t;
typedef long long int64_t;
typedef unsigned long long uint64_t;
typedef __PTRDIFF_TYPE__ intptr_t;
typedef unsigned __PTRDIFF_TYPE__ uintptr_t;
void* memcpy(void *dst, const void *src, u32 n);
char* strncpy(char *s, const char *t, int n);
#define RET_IP() ((unsigned long)__builtin_return_address(0))
#include <mtrace-magic.h>
// Tell mtrace about memory allocation
#define mtlabel(type, addr, bytes, str, n) \
mtrace_label_register(type, addr, bytes, str, n, RET_IP())
#define mtunlabel(type, addr) \
mtrace_label_register(type, addr, 0, NULL, 0, RET_IP())
// Tell mtrace about locking
#define mtlock(ptr) \
mtrace_lock_register(RET_IP(), ptr, lockname(ptr), mtrace_lockop_acquire, 0)
#define mtacquired(ptr) \
mtrace_lock_register(RET_IP(), ptr, lockname(ptr), mtrace_lockop_acquired, 0)
#define mtunlock(ptr) \
mtrace_lock_register(RET_IP(), ptr, lockname(ptr), mtrace_lockop_release, 0)
// Tell mtrace to start/stop recording call and ret
#define mtrec(cpu) mtrace_call_set(1, cpu)
#define mtign(cpu) mtrace_call_set(0, cpu)
#include "mtrace-magic.h"
#else
#define mtlabel(type, addr, bytes, str, n) do { } while (0)
#define mtunlabel(type, addr) do { } while (0)
#define mtlock(ptr) do { } while (0)
#define mtacquired(ptr) do { } while (0)
#define mtunlock(ptr) do { } while (0)
#define mtrec(cpu) do { } while (0)
#define mtign(cpu) do { } while (0)
#endif
...@@ -9,16 +9,18 @@ ...@@ -9,16 +9,18 @@
#include "proc.h" #include "proc.h"
#include "cpu.h" #include "cpu.h"
#include "bits.h" #include "bits.h"
#include "xv6-mtrace.h" #include "kmtrace.h"
#include "vm.h" #include "vm.h"
extern void trapret(void);
int __mpalign__ idle[NCPU]; int __mpalign__ idle[NCPU];
struct ns *nspid __mpalign__; struct ns *nspid __mpalign__;
struct ns *nsrunq __mpalign__; struct ns *nsrunq __mpalign__;
static struct proc *bootproc __mpalign__; static struct proc *bootproc __mpalign__;
#if MTRACE
struct kstack_tag kstack_tag[NCPU];
#endif
enum { sched_debug = 0 }; enum { sched_debug = 0 };
void void
...@@ -39,10 +41,10 @@ sched(void) ...@@ -39,10 +41,10 @@ sched(void)
intena = mycpu()->intena; intena = mycpu()->intena;
myproc()->curcycles += rdtsc() - myproc()->tsc; myproc()->curcycles += rdtsc() - myproc()->tsc;
if (myproc()->state == ZOMBIE) if (myproc()->state == ZOMBIE)
mtrace_kstack_stop(myproc()); mtstop(myproc());
else else
mtrace_kstack_pause(myproc()); mtpause(myproc());
mtrace_call_set(0, mycpu()->id); mtign(mycpu()->id);
swtch(&myproc()->context, mycpu()->scheduler); swtch(&myproc()->context, mycpu()->scheduler);
mycpu()->intena = intena; mycpu()->intena = intena;
...@@ -141,9 +143,9 @@ forkret(void) ...@@ -141,9 +143,9 @@ forkret(void)
// b/c file system code needs a process context // b/c file system code needs a process context
// in which to call cv_sleep(). // in which to call cv_sleep().
if(myproc()->cwd == 0) { if(myproc()->cwd == 0) {
mtrace_kstack_start(forkret, myproc()); mtstart(forkret, myproc());
myproc()->cwd = namei("/"); myproc()->cwd = namei("/");
mtrace_kstack_stop(myproc()); mtstop(myproc());
} }
// Return to "caller", actually trapret (see allocproc). // Return to "caller", actually trapret (see allocproc).
...@@ -209,6 +211,7 @@ exit(void) ...@@ -209,6 +211,7 @@ exit(void)
static struct proc* static struct proc*
allocproc(void) allocproc(void)
{ {
extern void trapret(void);
struct proc *p; struct proc *p;
char *sp; char *sp;
...@@ -394,7 +397,7 @@ scheduler(void) ...@@ -394,7 +397,7 @@ scheduler(void)
// Enabling mtrace calls in scheduler generates many mtrace_call_entrys. // Enabling mtrace calls in scheduler generates many mtrace_call_entrys.
// mtrace_call_set(1, cpu->id); // mtrace_call_set(1, cpu->id);
mtrace_kstack_start(scheduler, schedp); mtstart(scheduler, schedp);
for(;;){ for(;;){
// Enable interrupts on this processor. // Enable interrupts on this processor.
...@@ -417,17 +420,17 @@ scheduler(void) ...@@ -417,17 +420,17 @@ scheduler(void)
p->state = RUNNING; p->state = RUNNING;
p->tsc = rdtsc(); p->tsc = rdtsc();
mtrace_kstack_pause(schedp); mtpause(schedp);
if (p->context->rip != (uptr)forkret && if (p->context->rip != (uptr)forkret &&
p->context->rip != (uptr)rcu_gc_worker) p->context->rip != (uptr)rcu_gc_worker)
{ {
mtrace_kstack_resume(proc); mtresume(p);
} }
mtrace_call_set(1, mycpu()->id); mtrec(mycpu()->id);
swtch(&mycpu()->scheduler, myproc()->context); swtch(&mycpu()->scheduler, myproc()->context);
mtrace_kstack_resume(schedp); mtresume(schedp);
mtrace_call_set(0, mycpu()->id); mtign(mycpu()->id);
switchkvm(); switchkvm();
// Process is done running for now. // Process is done running for now.
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include "queue.h" #include "queue.h"
#include "proc.h" #include "proc.h"
#include "cpu.h" #include "cpu.h"
#include "xv6-mtrace.h" #include "kmtrace.h"
struct rcu { struct rcu {
unsigned long epoch; unsigned long epoch;
...@@ -107,7 +107,7 @@ rcu_gc_worker(void) ...@@ -107,7 +107,7 @@ rcu_gc_worker(void)
{ {
release(&myproc()->lock); // initially held by scheduler release(&myproc()->lock); // initially held by scheduler
mtrace_kstack_start(rcu_gc_worker, myproc()); mtstart(rcu_gc_worker, myproc());
struct spinlock wl; struct spinlock wl;
initlock(&wl, "rcu_gc_worker"); // dummy lock initlock(&wl, "rcu_gc_worker"); // dummy lock
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#include "cpu.h" #include "cpu.h"
#include "bits.h" #include "bits.h"
#include "spinlock.h" #include "spinlock.h"
#include "xv6-mtrace.h" #include "mtrace.h"
void void
initlock(struct spinlock *lk, char *name) initlock(struct spinlock *lk, char *name)
...@@ -35,31 +35,13 @@ acquire(struct spinlock *lk) ...@@ -35,31 +35,13 @@ acquire(struct spinlock *lk)
} }
#endif #endif
mtrace_lock_register(RET_EIP(), mtlock(lk);
lk,
#if SPINLOCK_DEBUG
lk->name ?: "null",
#else
"unknown",
#endif
mtrace_lockop_acquire,
0);
// The xchg is atomic. // The xchg is atomic.
// It also serializes, so that reads after acquire are not // It also serializes, so that reads after acquire are not
// reordered before it. // reordered before it.
while(xchg32(&lk->locked, 1) != 0) while(xchg32(&lk->locked, 1) != 0)
; ;
mtacquired(lk);
mtrace_lock_register(RET_EIP(),
lk,
#if SPINLOCK_DEBUG
lk->name ?: "null",
#else
"unknown",
#endif
mtrace_lockop_acquired,
0);
#if SPINLOCK_DEBUG #if SPINLOCK_DEBUG
// Record info about lock acquisition for debugging. // Record info about lock acquisition for debugging.
...@@ -79,15 +61,7 @@ release(struct spinlock *lk) ...@@ -79,15 +61,7 @@ release(struct spinlock *lk)
} }
#endif #endif
mtrace_lock_register(RET_EIP(), mtunlock(lk);
lk,
#if SPINLOCK_DEBUG
lk->name ?: "null",
#else
"unknown",
#endif
mtrace_lockop_release,
0);
#if SPINLOCK_DEBUG #if SPINLOCK_DEBUG
lk->pcs[0] = 0; lk->pcs[0] = 0;
......
...@@ -15,3 +15,11 @@ struct spinlock { ...@@ -15,3 +15,11 @@ struct spinlock {
#endif #endif
}; };
static inline const char *lockname(struct spinlock *s)
{
#if SPINLOCK_DEBUG
return s->name ?: "null";
#else
return "unknown";
#endif
}
...@@ -8,8 +8,8 @@ ...@@ -8,8 +8,8 @@
#include "proc.h" #include "proc.h"
#include "amd64.h" #include "amd64.h"
#include "syscall.h" #include "syscall.h"
#include "xv6-mtrace.h"
#include "cpu.h" #include "cpu.h"
#include "kmtrace.h"
// User code makes a system call with INT T_SYSCALL. // User code makes a system call with INT T_SYSCALL.
// System call number in %eax. // System call number in %eax.
...@@ -169,11 +169,11 @@ syscall(void) ...@@ -169,11 +169,11 @@ syscall(void)
num = myproc()->tf->rax; num = myproc()->tf->rax;
if(num >= 0 && num < NELEM(syscalls) && syscalls[num]) { if(num >= 0 && num < NELEM(syscalls) && syscalls[num]) {
mtrace_kstack_start(syscalls[num], proc); mtstart(syscalls[num], myproc());
mtrace_call_set(1, cpunum()); mtrec(cpunum());
myproc()->tf->rax = syscalls[num](); myproc()->tf->rax = syscalls[num]();
mtrace_kstack_stop(myproc()); mtstop(myproc());
mtrace_call_set(0, cpunum()); mtign(cpunum());
} else { } else {
cprintf("%d %s: unknown sys call %d\n", cprintf("%d %s: unknown sys call %d\n",
myproc()->pid, myproc()->name, num); myproc()->pid, myproc()->name, num);
......
#include "types.h" #include "types.h"
#include "stat.h" #include "stat.h"
#include "user.h" #include "user.h"
#include "xv6-mtrace.h" #include "mtrace.h"
#include "amd64.h" #include "amd64.h"
#include "uspinlock.h" #include "uspinlock.h"
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#include "spinlock.h" #include "spinlock.h"
#include "condvar.h" #include "condvar.h"
#include "proc.h" #include "proc.h"
#include "xv6-mtrace.h" #include "kmtrace.h"
#include "bits.h" #include "bits.h"
u64 ticks __mpalign__; u64 ticks __mpalign__;
...@@ -51,13 +51,13 @@ trap(struct trapframe *tf) ...@@ -51,13 +51,13 @@ trap(struct trapframe *tf)
// XXX(sbw) sysenter/sysexit // XXX(sbw) sysenter/sysexit
if(tf->trapno == T_SYSCALL){ if(tf->trapno == T_SYSCALL){
if(myproc()->killed) { if(myproc()->killed) {
mtrace_kstack_start(trap, proc); mtstart(trap, myproc());
exit(); exit();
} }
myproc()->tf = tf; myproc()->tf = tf;
syscall(); syscall();
if(myproc()->killed) { if(myproc()->killed) {
mtrace_kstack_start(trap, myproc()); mtstart(trap, myproc());
exit(); exit();
} }
return; return;
...@@ -65,8 +65,8 @@ trap(struct trapframe *tf) ...@@ -65,8 +65,8 @@ trap(struct trapframe *tf)
#if MTRACE #if MTRACE
if (myproc()->mtrace_stacks.curr >= 0) if (myproc()->mtrace_stacks.curr >= 0)
mtrace_kstack_pause(myproc()); mtpause(myproc());
mtrace_kstack_start(trap, myproc()); mtstart(trap, myproc());
#endif #endif
switch(tf->trapno){ switch(tf->trapno){
...@@ -119,9 +119,9 @@ trap(struct trapframe *tf) ...@@ -119,9 +119,9 @@ 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 #if MTRACE
mtrace_kstack_stop(myproc()); mtstop(myproc());
if (myproc()->mtrace_stacks.curr >= 0) if (myproc()->mtrace_stacks.curr >= 0)
mtrace_kstack_resume(myproc()); mtresume(myproc());
#endif #endif
return; return;
} }
...@@ -151,9 +151,9 @@ trap(struct trapframe *tf) ...@@ -151,9 +151,9 @@ trap(struct trapframe *tf)
exit(); exit();
#if MTRACE #if MTRACE
mtrace_kstack_stop(myproc()); mtstop(myproc());
if (myproc()->mtrace_stacks.curr >= 0) if (myproc()->mtrace_stacks.curr >= 0)
mtrace_kstack_resume(myproc()); mtresume(myproc());
#endif #endif
} }
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include "fcntl.h" #include "fcntl.h"
#include "syscall.h" #include "syscall.h"
#include "traps.h" #include "traps.h"
#include "xv6-mtrace.h" #include "mtrace.h"
char buf[2048]; char buf[2048];
char name[3]; char name[3];
......
#if MTRACE
typedef __signed char int8_t;
typedef unsigned char uint8_t;
typedef short int16_t;
typedef unsigned short uint16_t;
typedef int int32_t;
typedef unsigned int uint32_t;
typedef long long int64_t;
typedef unsigned long long uint64_t;
typedef __PTRDIFF_TYPE__ intptr_t;
typedef unsigned __PTRDIFF_TYPE__ uintptr_t;
void* memcpy(void *dst, const void *src, u32 n);
char* strncpy(char *s, const char *t, int n);
#define RET_EIP() ((unsigned long)__builtin_return_address(0))
#include "mtrace-magic.h"
#else
#define mtrace_lock_register(ip, x, name, op, y) do { } while (0)
#define mtrace_label_register(t, r, x, y, z, ip) do { } while (0)
#define mtrace_kstack_start(x, y) do { } while (0)
#define mtrace_kstack_stop(x) do { } while (0)
#define mtrace_kstack_pause(x) do { } while (0)
#define mtrace_kstack_resume(x) do { } while (0)
#define mtrace_call_set(x, y) do { } while (0)
#define RET_EIP() 0
#endif
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论