如何在Linux内核中跟踪写系统调用? [英] How to trace the write system call in the Linux kernel?

查看:162
本文介绍了如何在Linux内核中跟踪写系统调用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试这样做: 我正在通过开放源代码工具iperf从一台计算机向另一台计算机发送数据包,我想跟踪写入系统或发送呼叫. 如果有人可以指导Ftrace框架来跟踪系统调用,否则可以通过其他任何跟踪工具进行跟踪.

I am trying to do this: I am sending packet through iperf-an open source tool from one machine to another and I want to trace the write system or send call. Please help me to do that,if someone can guide through Ftrace framework to trace system call that would be great otherwise by any other tracing tool.

推荐答案

困难的部分是确切地知道要追踪的内容,这样您就只能看到所需的结果,但是追踪本身非常容易:

The hard part is to know exactly what to trace so you can see only the results that you want, but the tracing itself is very easy:

  • 首先,您的内核必须配置为CONFIG_FTRACE = y
  • 确定要跟踪的事件

  • First, your kernel must be configured with CONFIG_FTRACE=y
  • Determine what event you want to trace

cat/sys/kernel/debug/tracing/available_events

cat /sys/kernel/debug/tracing/available_events

将您选择的事件写入set_event

Write the event that you have chosen into set_event

echo sys_enter_write>/sys/kernel/debug/tracing/set_event

echo sys_enter_write > /sys/kernel/debug/tracing/set_event

确定要跟踪的跟踪类型

cat/sys/kernel/debug/tracing/available_tracers

cat /sys/kernel/debug/tracing/available_tracers

在current_tracer文件中写入所需的跟踪类型

Write the kind of trace that you want in current_tracer file

echo function_graph>/sys/kernel/debug/tracing/current_tracer

echo function_graph > /sys/kernel/debug/tracing/current_tracer

启用跟踪:

echo 1>/sys/kernel/debug/tracing/tracing_on

echo 1 > /sys/kernel/debug/tracing/tracing_on

现在,您可以根据需要运行"iperf -c ...",并在完成后禁用跟踪.

Now you can run the "iperf -c... " as you wish, and disable tracing when it is done.

echo 0>/sys/kernel/debug/tracing/tracing_on

echo 0 > /sys/kernel/debug/tracing/tracing_on

要查看结果:

vi/sys/kernel/debug/tracing/trace

vi /sys/kernel/debug/tracing/trace

这篇关于如何在Linux内核中跟踪写系统调用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆