title: Generating Raw Intel Processor Trace With Perf
body: <p>I am tasked with generating a <em>raw</em> Intel Processor Trace. By raw, I mean the trace conforms to the file header:</p>
  
  <pre><code>struct pt_logfile_header {
      unsigned int magic;
      unsigned int version;
  };
  </code></pre>
  
  <p>And is then followed by various process, thread, xpage and buffer structures:</p>
  
  <pre><code>/* logitem header */
  struct pt_logitem_header {
      enum pt_logitem_kind kind;
      unsigned int size;
  };
  /* type process */
  struct pt_logitem_process {
      struct pt_logitem_header header;
      unsigned long tgid;                 // process id
      unsigned long cmd_size;             // the size of command string followed to launch this process
  };
  /* type thread */
  struct pt_logitem_thread {
      struct pt_logitem_header header;
      unsigned long tgid;                 // process id
      unsigned long pid;                  // thread id
  };
  /* type xpage */
  struct pt_logitem_xpage {
      struct pt_logitem_header header;
      unsigned long tgid; // process id
      unsigned long base; // the base address where executable pages were mapped
      unsigned long size; // the total size of the executable pages
  };
  /* type buffer */
  struct pt_logitem_buffer {
      struct pt_logitem_header header;
      unsigned long tgid; // process id
      unsigned long pid; // thread id
      unsigned long sequence; // a per-thread sequence number
      unsigned long size; // the total size of PT packets followed
  };
  </code></pre>
  
  <p>Is <code>perf record</code> capable of creating this type of trace, or something very similar?</p>