Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 205340
b: refs/heads/master
c: 39d17da
h: refs/heads/master
v: v3
  • Loading branch information
Arnaldo Carvalho de Melo committed Jul 29, 2010
1 parent 4d4ad11 commit dc52985
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 8c31a1e049a0c26f78558d7cc5a9ab6956c86694
refs/heads/master: 39d17dacb3c25df878b56aa80a170d6088e041f9
32 changes: 26 additions & 6 deletions trunk/tools/perf/builtin-record.c
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ static void atexit_header(void)

process_buildids();
perf_header__write(&session->header, output, true);
perf_session__delete(session);
}
}

Expand Down Expand Up @@ -558,12 +559,15 @@ static int __cmd_record(int argc, const char **argv)
if (!file_new) {
err = perf_header__read(session, output);
if (err < 0)
return err;
goto out_delete_session;
}

if (have_tracepoints(attrs, nr_counters))
perf_header__set_feat(&session->header, HEADER_TRACE_INFO);

/*
* perf_session__delete(session) will be called at atexit_header()
*/
atexit(atexit_header);

if (forks) {
Expand Down Expand Up @@ -768,6 +772,10 @@ static int __cmd_record(int argc, const char **argv)
bytes_written / 24);

return 0;

out_delete_session:
perf_session__delete(session);
return err;
}

static const char * const record_usage[] = {
Expand Down Expand Up @@ -824,7 +832,7 @@ static const struct option options[] = {

int cmd_record(int argc, const char **argv, const char *prefix __used)
{
int i,j;
int i, j, err = -ENOMEM;

argc = parse_options(argc, argv, options, record_usage,
PARSE_OPT_STOP_AT_NON_OPTION);
Expand Down Expand Up @@ -873,13 +881,13 @@ int cmd_record(int argc, const char **argv, const char *prefix __used)
for (j = 0; j < MAX_COUNTERS; j++) {
fd[i][j] = malloc(sizeof(int)*thread_num);
if (!fd[i][j])
return -ENOMEM;
goto out_free_fd;
}
}
event_array = malloc(
sizeof(struct pollfd)*MAX_NR_CPUS*MAX_COUNTERS*thread_num);
if (!event_array)
return -ENOMEM;
goto out_free_fd;

if (user_interval != ULLONG_MAX)
default_interval = user_interval;
Expand All @@ -895,8 +903,20 @@ int cmd_record(int argc, const char **argv, const char *prefix __used)
default_interval = freq;
} else {
fprintf(stderr, "frequency and count are zero, aborting\n");
exit(EXIT_FAILURE);
err = -EINVAL;
goto out_free_event_array;
}

return __cmd_record(argc, argv);
err = __cmd_record(argc, argv);

out_free_event_array:
free(event_array);
out_free_fd:
for (i = 0; i < MAX_NR_CPUS; i++) {
for (j = 0; j < MAX_COUNTERS; j++)
free(fd[i][j]);
}
free(all_tids);
all_tids = NULL;
return err;
}

0 comments on commit dc52985

Please sign in to comment.