MIT S081 Lab 2 System Calls

Lab链接

一 实现trace功能

1 题目要求

In this assignment you will add a system call tracing feature that may help you when debugging later labs. You'll create a new trace system call that will control tracing. It should take one argument, an integer "mask", whose bits specify which system calls to trace. For example, to trace the fork system call, a program calls trace(1 << SYS_fork), where SYS_fork is a syscall number from kernel/syscall.h. You have to modify the xv6 kernel to print out a line when each system call is about to return, if the system call's number is set in the mask. The line should contain the process id, the name of the system call and the return value; you don't need to print the system call arguments. The trace system call should enable tracing for the process that calls it and any children that it subsequently forks, but should not affect other processes.

We provide a trace user-level program that runs another program with tracing enabled (see user/trace.c). When you're done, you should see output like this:

cpp 复制代码
$ trace 32 grep hello README
3: syscall read -> 1023
3: syscall read -> 966
3: syscall read -> 70
3: syscall read -> 0
$
$ trace 2147483647 grep hello README
4: syscall trace -> 0
4: syscall exec -> 3
4: syscall open -> 3
4: syscall read -> 1023
4: syscall read -> 966
4: syscall read -> 70
4: syscall read -> 0
4: syscall close -> 0
$
$ grep hello README
$
$ trace 2 usertests forkforkfork
usertests starting
test forkforkfork: 407: syscall fork -> 408
408: syscall fork -> 409
409: syscall fork -> 410
410: syscall fork -> 411
409: syscall fork -> 412
410: syscall fork -> 413
409: syscall fork -> 414
411: syscall fork -> 415
...
$   

trace是一个运行在用户空间的程序。 你需要实现一个用户空间程序 trace,它将启动另一个程序并启用跟踪功能。

trace调用时,会传入一个int类型的mask值,来指明需要对哪些系统调用trace。

获取argument,获取系统调用号、

相关推荐
itmigrate3 小时前
前端项目里,Object.is 并不是 === 的平替
前端
程序员清风4 小时前
数据处理脚本工程化:日志、配置、命令行与测试
服务器·开发语言·数据库
readhere4 小时前
从ZYNQ7000开发板,学会启动嵌入式Linux系统——入门学习:EBAZ4205篇目录
linux·启动·嵌入式linux·zynq7000·ebaz4205
小大宇4 小时前
Vue知识点6-computed计算属性
前端·javascript·vue.js
程序员海军5 小时前
尤雨溪 : Vue 4 已经在规划中了!
前端·javascript·vue.js
2601_949970695 小时前
HumanizeDuration 跨端三方库仓颉适配全流程
前端·javascript·flutter
打工仔折腾 AI6 小时前
在 Ubuntu ARM64 部署 Q1 V3.0 MuJoCo 模型:加载、单步推理与执行器响应解析
linux·运维·人工智能·python·深度学习·ubuntu·性能优化
yyuuuzz6 小时前
跨境站点日志时区混乱的排查记录
运维·服务器·网络·云计算·aws·1024程序员节
‎ദ്ദിᵔ.˛.ᵔ₎6 小时前
关于Linux 线程局部存储的认识
linux·运维
风骏时光牛马7 小时前
后端服务接口开发与性能优化
前端