Instrument forktest.c with mtrace calls.

上级 860db2fa
......@@ -4,6 +4,7 @@
#include "types.h"
#include "stat.h"
#include "user.h"
#include "xv6-mtrace.h"
#define N 1000
......@@ -13,9 +14,26 @@ printf(int fd, char *s, ...)
write(fd, s, strlen(s));
}
char*
strncpy(char *s, const char *t, int n)
{
int tlen = strlen((char *)t);
memmove(s, (char *)t, n > tlen ? tlen : n);
if (n > tlen)
s[tlen] = 0;
return s;
}
void*
memcpy(void *dst, const void *src, uint n)
{
return memmove(dst, (void *)src, n);
}
void
forktest(void)
{
struct mtrace_appdata_entry entry;
int n, pid;
printf(1, "fork test\n");
......@@ -45,12 +63,17 @@ forktest(void)
exit();
}
entry.u64 = n;
mtrace_appdata_register(&entry);
printf(1, "fork test OK\n");
}
int
main(void)
{
mtrace_enable_set(1, "xv6-forktest");
forktest();
mtrace_enable_set(0, "xv6-forktest");
exit();
}
#include <stdint.h>
void* memcpy(void *dst, const void *src, uint n);
char* strncpy(char *s, const char *t, int n);
#define RET_EIP() ((unsigned long)__builtin_return_address(0))
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论