Skip to content

Commit 5007868

Browse files
authored
修改描述中与代码中不一致的方法名 (eunomia-bpf#128)
代码中使用的是bpf_printk函数,而下面的说明文字中则是bpf_trace_printk函数,按照代码修改描述,防止导致新手的误解。
1 parent 7cfa5db commit 5007868

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/1-helloworld/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ int handle_tp(void *ctx)
9999
100100
这段程序通过定义一个 handle_tp 函数并使用 SEC 宏把它附加到 sys_enter_write tracepoint(即在进入 write 系统调用时执行)。该函数通过使用 bpf_get_current_pid_tgid 和 bpf_printk 函数获取调用 write 系统调用的进程 ID,并在内核日志中打印出来。
101101
102-
- `bpf_trace_printk()`: 一种将信息输出到trace_pipe(/sys/kernel/debug/tracing/trace_pipe)简单机制。 在一些简单用例中这样使用没有问题, but它也有一些限制:最多3 参数; 第一个参数必须是%s(即字符串);同时trace_pipe在内核中全局共享,其他并行使用trace_pipe的程序有可能会将 trace_pipe 的输出扰乱。 一个更好的方式是通过 BPF_PERF_OUTPUT(), 稍后将会讲到。
102+
- `bpf_printk()`: 一种将信息输出到trace_pipe(/sys/kernel/debug/tracing/trace_pipe)简单机制。 在一些简单用例中这样使用没有问题, but它也有一些限制:最多3 参数; 第一个参数必须是%s(即字符串);同时trace_pipe在内核中全局共享,其他并行使用trace_pipe的程序有可能会将 trace_pipe 的输出扰乱。 一个更好的方式是通过 BPF_PERF_OUTPUT(), 稍后将会讲到。
103103
- `void *ctx`:ctx本来是具体类型的参数, 但是由于我们这里没有使用这个参数,因此就将其写成void *类型。
104104
- `return 0`;:必须这样,返回0 (如果要知道why, 参考 #139 <https://github.com/iovisor/bcc/issues/139>)。
105105

0 commit comments

Comments
 (0)