提交 6a371af4 创建 作者: Austin Clements's avatar Austin Clements 提交者: Silas Boyd-Wickizer

Use uerr in lots of places in trap/vm

So we can hush up spurious errors.
上级 e0824a1c
...@@ -68,6 +68,9 @@ struct vma ...@@ -68,6 +68,9 @@ struct vma
NEW_DELETE_OPS(vma) NEW_DELETE_OPS(vma)
}; };
class print_stream;
void to_stream(print_stream *s, vma *v);
// An address space: a set of vmas plus h/w page table. // An address space: a set of vmas plus h/w page table.
// The elements of e[] are not ordered by address. // The elements of e[] are not ordered by address.
struct vmap { struct vmap {
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "bits.hh" #include "bits.hh"
#include "kalloc.hh" #include "kalloc.hh"
#include "apic.hh" #include "apic.hh"
#include "kstream.hh"
extern "C" void __uaccess_end(void); extern "C" void __uaccess_end(void);
...@@ -73,7 +74,7 @@ do_pagefault(struct trapframe *tf) ...@@ -73,7 +74,7 @@ do_pagefault(struct trapframe *tf)
#endif #endif
return 0; return 0;
} }
cprintf("pagefault: failed in user\n"); uerr.println("pagefault: failed in user");
cli(); cli();
} }
return -1; return -1;
...@@ -171,10 +172,11 @@ trap(struct trapframe *tf) ...@@ -171,10 +172,11 @@ trap(struct trapframe *tf)
kerneltrap(tf); kerneltrap(tf);
// In user space, assume process misbehaved. // In user space, assume process misbehaved.
cprintf("pid %d %s: trap %lu err %d on cpu %d " uerr.println("pid ", myproc()->pid, ' ', myproc()->name,
"rip 0x%lx rsp 0x%lx addr 0x%lx--kill proc\n", ": trap ", (u64)tf->trapno, " err ", (u32)tf->err,
myproc()->pid, myproc()->name, tf->trapno, tf->err, " on cpu ", mycpuid(), " rip ", shex(tf->rip),
mycpu()->id, tf->rip, tf->rsp, rcr2()); " rsp ", shex(tf->rsp), " addr ", shex(rcr2()),
"--kill proc");
myproc()->killed = 1; myproc()->killed = 1;
} }
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "sperf.hh" #include "sperf.hh"
#include "uwq.hh" #include "uwq.hh"
#include "kmtrace.hh" #include "kmtrace.hh"
#include "kstream.hh"
enum { vm_debug = 0 }; enum { vm_debug = 0 };
enum { tlb_shootdown = 1 }; enum { tlb_shootdown = 1 };
...@@ -188,6 +189,13 @@ vma::~vma() ...@@ -188,6 +189,13 @@ vma::~vma()
n->decref(); n->decref();
} }
void
to_stream(print_stream *s, vma *v)
{
s->print("vma@[", shex(v->vma_start), ',', shex(v->vma_end), ')',
v->va_type == COW ? "/COW" : "");
}
/* /*
* vmap * vmap
*/ */
...@@ -425,8 +433,7 @@ again: ...@@ -425,8 +433,7 @@ again:
goto again; goto again;
vma *rvma = (vma*) r; vma *rvma = (vma*) r;
cprintf("vmap::insert: overlap with %p: 0x%lx--0x%lx\n", uerr.println("vmap::insert: overlap with ", rvma);
rvma, rvma->vma_start, rvma->vma_end);
return -1; return -1;
} }
#endif #endif
...@@ -509,8 +516,9 @@ vmap::remove(uptr vma_start, uptr len) ...@@ -509,8 +516,9 @@ vmap::remove(uptr vma_start, uptr len)
for (auto r: span) { for (auto r: span) {
vma *rvma = (vma*) r; vma *rvma = (vma*) r;
if (rvma->vma_start < vma_start || rvma->vma_end > vma_end) { if (rvma->vma_start < vma_start || rvma->vma_end > vma_end) {
cprintf("vmap::remove: partial unmap not supported; unmapping [%#lx,%#lx) from [%#lx,%#lx)\n", uerr.println("vmap::remove: partial unmap not supported; "
vma_start, vma_start+len, rvma->vma_start, rvma->vma_end); "unmapping [", shex(vma_start),",",shex(vma_start+len), ")"
" from ", rvma);
return -1; return -1;
} }
} }
...@@ -821,8 +829,8 @@ vmap::sbrk(ssize_t n, uptr *addr) ...@@ -821,8 +829,8 @@ vmap::sbrk(ssize_t n, uptr *addr)
prev = e; prev = e;
#endif #endif
} else { } else {
cprintf("growproc: overlap with existing mapping; brk %lx n %ld\n", uerr.println("growproc: overlap with existing mapping; "
curbrk, n); "brk ", shex(curbrk), " n ", n);
return -1; return -1;
} }
} }
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论