Skip to content
Snippets Groups Projects
Commit 9fa59ae9 authored by Pekka Enberg's avatar Pekka Enberg
Browse files

mman: Fix mmap() tracepoint

Exit tracepoints are useful to record errors, and also for timing the
mmap operation.

Signed-off-by Pekka Enberg <penberg@cloudius-systems.com>
parent cd4c5434
No related branches found
No related tags found
No related merge requests found
...@@ -12,7 +12,8 @@ ...@@ -12,7 +12,8 @@
#include "osv/trace.hh" #include "osv/trace.hh"
#include "libc/libc.hh" #include "libc/libc.hh"
TRACEPOINT(trace_memory_mmap, "ret=%p, addr=%p, length=%d, prot=%d, flags=%d, fd=%d, offset=%d", void *, void *, size_t, int, int, int, off_t); TRACEPOINT(trace_memory_mmap, "addr=%p, length=%d, prot=%d, flags=%d, fd=%d, offset=%d", void *, size_t, int, int, int, off_t);
TRACEPOINT(trace_memory_mmap_ret, "%p", void *);
TRACEPOINT(trace_memory_munmap, "addr=%p, length=%d", void *, size_t); TRACEPOINT(trace_memory_munmap, "addr=%p, length=%d", void *, size_t);
unsigned libc_prot_to_perm(int prot) unsigned libc_prot_to_perm(int prot)
...@@ -54,6 +55,8 @@ int mprotect(void *addr, size_t len, int prot) ...@@ -54,6 +55,8 @@ int mprotect(void *addr, size_t len, int prot)
void *mmap(void *addr, size_t length, int prot, int flags, void *mmap(void *addr, size_t length, int prot, int flags,
int fd, off_t offset) int fd, off_t offset)
{ {
trace_memory_mmap(addr, length, prot, flags, fd, offset);
// TODO: should fail with EINVAL in some cases of addr, length, offset. // TODO: should fail with EINVAL in some cases of addr, length, offset.
// make use the payload isn't remapping physical memory // make use the payload isn't remapping physical memory
...@@ -68,7 +71,7 @@ void *mmap(void *addr, size_t length, int prot, int flags, ...@@ -68,7 +71,7 @@ void *mmap(void *addr, size_t length, int prot, int flags,
ret = mmu::map_file(addr, length, !(flags & MAP_FIXED), ret = mmu::map_file(addr, length, !(flags & MAP_FIXED),
libc_prot_to_perm(prot), f, offset, flags & MAP_SHARED); libc_prot_to_perm(prot), f, offset, flags & MAP_SHARED);
} }
trace_memory_mmap(ret, addr, length, prot, flags, fd, offset); trace_memory_mmap_ret(ret);
return ret; return ret;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment