简体   繁体   中英

trace_pipe what are they/ is it file or some kind of channel that I can open and read and write to it | And what are Linux trace

So I have this code

So I like to know what is this trace_fd = open(DEBUGFS "trace_pipe", O_RDONLY, 0); it seems like reading trace but what is trace so begin telling me something about trace, and can I read any trace/ how many traces are there. If I do a write on trace pipe then what other end is in the write system call. so I am awefully confused about word trace and let alone simple code below writing to trace_pipe. Can I create my own trace? How and please telll me this

void read_trace_pipe(void)
{
    int trace_fd;

    trace_fd = open(DEBUGFS "trace_pipe", O_RDONLY, 0);
    if (trace_fd < 0)
        return;

    while (1) {
        static char buf[4096];
        ssize_t sz;

        sz = read(trace_fd, buf, sizeof(buf) - 1);
        if (sz > 0) {
            buf[sz] = 0;
            puts(buf);
        }
    }
}

DEBUGFS here is a macro defined (probably) to be a string literal containing a directory name, so this just opens a file called trace_pipe in that directory and reads it. That might just be a normal file, or it might be some kind of named pipe that someone has created.

This is not any sort of standard thing, and has nothing to do with strace or systrace -- its probably just something this application has set up. "trace_pipe" is just a file name. To understand it, you really need to know what DEBUGFS is defined as, and who creates things in that directory.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM