mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-23 23:32:14 +00:00
perf util: Save pid-cmdline mapping into tracing header
Current trace info data lacks the saved cmdline mapping which is needed for pevent to find out the comm of a task. Add this and bump up the version number so that perf can determine its presence when reading. This is mostly corresponding to trace.dat file version 6, but still lacks 4 byte of number of cpus, and 10 bytes of type string - and I think we don't need those anyway. Signed-off-by: Namhyung Kim <namhyung@kernel.org> Tested-by: Masami Hiramatsu <mhiramat@kernel.org> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jeremy Eder <jeder@redhat.com> Cc: Jiri Olsa <jolsa@redhat.com>, Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Stephane Eranian <eranian@google.com> Cc: Steven Rostedt <rostedt@goodmis.org> [ Change version test from == to >= ] Link: http://lkml.kernel.org/n/tip-vaooqpxsikxbb3359p0corcb@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
0a87e7bc6c
commit
cd4ceb6343
4 changed files with 84 additions and 3 deletions
|
@ -341,6 +341,31 @@ static int read_event_files(struct pevent *pevent)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int read_saved_cmdline(struct pevent *pevent)
|
||||
{
|
||||
unsigned long long size;
|
||||
char *buf;
|
||||
|
||||
/* it can have 0 size */
|
||||
size = read8(pevent);
|
||||
if (!size)
|
||||
return 0;
|
||||
|
||||
buf = malloc(size + 1);
|
||||
if (buf == NULL)
|
||||
return -1;
|
||||
|
||||
if (do_read(buf, size) < 0) {
|
||||
free(buf);
|
||||
return -1;
|
||||
}
|
||||
|
||||
parse_saved_cmdline(pevent, buf, size);
|
||||
|
||||
free(buf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ssize_t trace_report(int fd, struct trace_event *tevent, bool __repipe)
|
||||
{
|
||||
char buf[BUFSIZ];
|
||||
|
@ -379,10 +404,11 @@ ssize_t trace_report(int fd, struct trace_event *tevent, bool __repipe)
|
|||
return -1;
|
||||
if (show_version)
|
||||
printf("version = %s\n", version);
|
||||
free(version);
|
||||
|
||||
if (do_read(buf, 1) < 0)
|
||||
if (do_read(buf, 1) < 0) {
|
||||
free(version);
|
||||
return -1;
|
||||
}
|
||||
file_bigendian = buf[0];
|
||||
host_bigendian = bigendian();
|
||||
|
||||
|
@ -423,6 +449,11 @@ ssize_t trace_report(int fd, struct trace_event *tevent, bool __repipe)
|
|||
err = read_ftrace_printk(pevent);
|
||||
if (err)
|
||||
goto out;
|
||||
if (atof(version) >= 0.6) {
|
||||
err = read_saved_cmdline(pevent);
|
||||
if (err)
|
||||
goto out;
|
||||
}
|
||||
|
||||
size = trace_data_size;
|
||||
repipe = false;
|
||||
|
@ -438,5 +469,6 @@ ssize_t trace_report(int fd, struct trace_event *tevent, bool __repipe)
|
|||
out:
|
||||
if (pevent)
|
||||
trace_event__cleanup(tevent);
|
||||
free(version);
|
||||
return size;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue