如何在ftrace中使用跟踪标记?

问题描述 投票:0回答:1

如何在ftrace中使用跟踪标记来记录用户事件?我使用以下,但编译器无法定义WR_ONLY

static int trace_fd = -1;

    void trace_write(const char *fmt, ...)
    {
            va_list ap;
            char buf[256];
            int n;

            if (trace_fd < 0)
                    return;

            va_start(ap, fmt);
            n = vsnprintf(buf, 256, fmt, ap);
            va_end(ap);

            write(trace_fd, buf, n);
    }


    [...]

    trace_fd = open("trace_marker", WR_ONLY);

然后,使用trace_write()函数记录到ftrace缓冲区。

    trace_write("record this event\n")

编译错误:

error: C++ requires a type specifier for all declarations
trace_fd = open("trace_marker", WR_ONLY);
kernel tracing ftrace
1个回答
0
投票

qazxsw poi中似乎有一个错误,你似乎从中复制了你的代码。试试qazxsw poi(qazxsw poi得到它的定义)而不是ftrace documentation

请注意,您还需要O_WRONLY的完整路径,#include <sys/fcntl.h>WR_ONLY,具体取决于您的内核版本和trace_marker的安装位置。

© www.soinside.com 2019 - 2024. All rights reserved.