mirror of
https://github.com/FEX-Emu/linux.git
synced 2024-12-14 21:01:29 +00:00
perf trace: Read_tracing_data should die() another day
It better propagate errors, also if we do a simple: [root@doppio linux-2.6-tip]# perf record -R -a -f sleep 3s ; perf trace [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.182 MB perf.data (~7972 samples) ] Fatal: not an trace data file [root@doppio linux-2.6-tip]# That is what is expected, right? I.e. as we didn't specify any tracepoint event via -e, it should gracefully bail out and not SEGFAULT. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Frédéric Weisbecker <fweisbec@gmail.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Paul Mackerras <paulus@samba.org> LKML-Reference: <1258821086-11521-3-git-send-email-acme@infradead.org> [ Fixed the error messages some more ] Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
parent
c12e15e71d
commit
e25613683b
@ -33,11 +33,11 @@
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <stdbool.h>
|
||||
#include <linux/kernel.h>
|
||||
|
||||
#include "../perf.h"
|
||||
#include "trace-event.h"
|
||||
|
||||
|
||||
#define VERSION "0.5"
|
||||
|
||||
#define _STR(x) #x
|
||||
@ -483,23 +483,31 @@ static struct tracepoint_path *
|
||||
get_tracepoints_path(struct perf_event_attr *pattrs, int nb_events)
|
||||
{
|
||||
struct tracepoint_path path, *ppath = &path;
|
||||
int i;
|
||||
int i, nr_tracepoints = 0;
|
||||
|
||||
for (i = 0; i < nb_events; i++) {
|
||||
if (pattrs[i].type != PERF_TYPE_TRACEPOINT)
|
||||
continue;
|
||||
++nr_tracepoints;
|
||||
ppath->next = tracepoint_id_to_path(pattrs[i].config);
|
||||
if (!ppath->next)
|
||||
die("%s\n", "No memory to alloc tracepoints list");
|
||||
ppath = ppath->next;
|
||||
}
|
||||
|
||||
return path.next;
|
||||
return nr_tracepoints > 0 ? path.next : NULL;
|
||||
}
|
||||
void read_tracing_data(int fd, struct perf_event_attr *pattrs, int nb_events)
|
||||
|
||||
int read_tracing_data(int fd, struct perf_event_attr *pattrs, int nb_events)
|
||||
{
|
||||
char buf[BUFSIZ];
|
||||
struct tracepoint_path *tps;
|
||||
struct tracepoint_path *tps = get_tracepoints_path(pattrs, nb_events);
|
||||
|
||||
/*
|
||||
* What? No tracepoints? No sense writing anything here, bail out.
|
||||
*/
|
||||
if (tps == NULL)
|
||||
return -1;
|
||||
|
||||
output_fd = fd;
|
||||
|
||||
@ -528,11 +536,11 @@ void read_tracing_data(int fd, struct perf_event_attr *pattrs, int nb_events)
|
||||
page_size = getpagesize();
|
||||
write_or_die(&page_size, 4);
|
||||
|
||||
tps = get_tracepoints_path(pattrs, nb_events);
|
||||
|
||||
read_header_files();
|
||||
read_ftrace_files(tps);
|
||||
read_event_files(tps);
|
||||
read_proc_kallsyms();
|
||||
read_ftrace_printk();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -471,11 +471,11 @@ void trace_report(int fd)
|
||||
|
||||
read_or_die(buf, 3);
|
||||
if (memcmp(buf, test, 3) != 0)
|
||||
die("not an trace data file");
|
||||
die("no trace data in the file");
|
||||
|
||||
read_or_die(buf, 7);
|
||||
if (memcmp(buf, "tracing", 7) != 0)
|
||||
die("not a trace file (missing tracing)");
|
||||
die("not a trace file (missing 'tracing' tag)");
|
||||
|
||||
version = read_string();
|
||||
if (show_version)
|
||||
|
@ -248,7 +248,7 @@ unsigned long long
|
||||
raw_field_value(struct event *event, const char *name, void *data);
|
||||
void *raw_field_ptr(struct event *event, const char *name, void *data);
|
||||
|
||||
void read_tracing_data(int fd, struct perf_event_attr *pattrs, int nb_events);
|
||||
int read_tracing_data(int fd, struct perf_event_attr *pattrs, int nb_events);
|
||||
|
||||
/* taken from kernel/trace/trace.h */
|
||||
enum trace_flag_type {
|
||||
|
Loading…
Reference in New Issue
Block a user