perf auxtrace: Add timestamp to auxtrace errors
The timestamp can use useful to find part of a trace that has an error without outputting all of the trace e.g. using the itrace 's' option to skip initial number of events. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Cc: Jiri Olsa <jolsa@redhat.com> Link: http://lkml.kernel.org/r/20190206103947.15750-6-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:

committed by
Arnaldo Carvalho de Melo

parent
26ee2bcdea
commit
16bd4321c2
@@ -27,6 +27,7 @@
|
||||
#include <linux/bitops.h>
|
||||
#include <linux/log2.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/time64.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <stdlib.h>
|
||||
@@ -858,7 +859,7 @@ void auxtrace_buffer__free(struct auxtrace_buffer *buffer)
|
||||
|
||||
void auxtrace_synth_error(struct auxtrace_error_event *auxtrace_error, int type,
|
||||
int code, int cpu, pid_t pid, pid_t tid, u64 ip,
|
||||
const char *msg)
|
||||
const char *msg, u64 timestamp)
|
||||
{
|
||||
size_t size;
|
||||
|
||||
@@ -870,7 +871,9 @@ void auxtrace_synth_error(struct auxtrace_error_event *auxtrace_error, int type,
|
||||
auxtrace_error->cpu = cpu;
|
||||
auxtrace_error->pid = pid;
|
||||
auxtrace_error->tid = tid;
|
||||
auxtrace_error->fmt = 1;
|
||||
auxtrace_error->ip = ip;
|
||||
auxtrace_error->time = timestamp;
|
||||
strlcpy(auxtrace_error->msg, msg, MAX_AUXTRACE_ERROR_MSG);
|
||||
|
||||
size = (void *)auxtrace_error->msg - (void *)auxtrace_error +
|
||||
@@ -1160,12 +1163,27 @@ static const char *auxtrace_error_name(int type)
|
||||
size_t perf_event__fprintf_auxtrace_error(union perf_event *event, FILE *fp)
|
||||
{
|
||||
struct auxtrace_error_event *e = &event->auxtrace_error;
|
||||
unsigned long long nsecs = e->time;
|
||||
const char *msg = e->msg;
|
||||
int ret;
|
||||
|
||||
ret = fprintf(fp, " %s error type %u",
|
||||
auxtrace_error_name(e->type), e->type);
|
||||
|
||||
if (e->fmt && nsecs) {
|
||||
unsigned long secs = nsecs / NSEC_PER_SEC;
|
||||
|
||||
nsecs -= secs * NSEC_PER_SEC;
|
||||
ret += fprintf(fp, " time %lu.%09llu", secs, nsecs);
|
||||
} else {
|
||||
ret += fprintf(fp, " time 0");
|
||||
}
|
||||
|
||||
if (!e->fmt)
|
||||
msg = (const char *)&e->time;
|
||||
|
||||
ret += fprintf(fp, " cpu %d pid %d tid %d ip %#"PRIx64" code %u: %s\n",
|
||||
e->cpu, e->pid, e->tid, e->ip, e->code, e->msg);
|
||||
e->cpu, e->pid, e->tid, e->ip, e->code, msg);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user