diff options
author | Namhyung Kim <namhyung@kernel.org> | 2015-01-29 03:06:48 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-01-29 14:58:24 -0500 |
commit | 42aa276f40730211383e9a9923416f1fb9841d68 (patch) | |
tree | c48c5c8f9dd2139e6a8efc2ac365f988b44b9f11 /tools | |
parent | 0b064f43001fc2627ff8c3020647b85db040235f (diff) |
perf tools: Use perf_data_file__fd() consistently
Do not reference file->fd directly since we want hide the
implementation details from outside for possible future changes.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1422518843-25818-8-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/builtin-inject.c | 5 | ||||
-rw-r--r-- | tools/perf/builtin-record.c | 14 |
2 files changed, 10 insertions, 9 deletions
diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c index 84df2deed988..a13641e066f5 100644 --- a/tools/perf/builtin-inject.c +++ b/tools/perf/builtin-inject.c | |||
@@ -343,6 +343,7 @@ static int __cmd_inject(struct perf_inject *inject) | |||
343 | int ret = -EINVAL; | 343 | int ret = -EINVAL; |
344 | struct perf_session *session = inject->session; | 344 | struct perf_session *session = inject->session; |
345 | struct perf_data_file *file_out = &inject->output; | 345 | struct perf_data_file *file_out = &inject->output; |
346 | int fd = perf_data_file__fd(file_out); | ||
346 | 347 | ||
347 | signal(SIGINT, sig_handler); | 348 | signal(SIGINT, sig_handler); |
348 | 349 | ||
@@ -376,7 +377,7 @@ static int __cmd_inject(struct perf_inject *inject) | |||
376 | } | 377 | } |
377 | 378 | ||
378 | if (!file_out->is_pipe) | 379 | if (!file_out->is_pipe) |
379 | lseek(file_out->fd, session->header.data_offset, SEEK_SET); | 380 | lseek(fd, session->header.data_offset, SEEK_SET); |
380 | 381 | ||
381 | ret = perf_session__process_events(session, &inject->tool); | 382 | ret = perf_session__process_events(session, &inject->tool); |
382 | 383 | ||
@@ -385,7 +386,7 @@ static int __cmd_inject(struct perf_inject *inject) | |||
385 | perf_header__set_feat(&session->header, | 386 | perf_header__set_feat(&session->header, |
386 | HEADER_BUILD_ID); | 387 | HEADER_BUILD_ID); |
387 | session->header.data_size = inject->bytes_written; | 388 | session->header.data_size = inject->bytes_written; |
388 | perf_session__write_header(session, session->evlist, file_out->fd, true); | 389 | perf_session__write_header(session, session->evlist, fd, true); |
389 | } | 390 | } |
390 | 391 | ||
391 | return ret; | 392 | return ret; |
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 9900b433e861..404ab3434052 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
@@ -208,7 +208,7 @@ static int process_buildids(struct record *rec) | |||
208 | struct perf_data_file *file = &rec->file; | 208 | struct perf_data_file *file = &rec->file; |
209 | struct perf_session *session = rec->session; | 209 | struct perf_session *session = rec->session; |
210 | 210 | ||
211 | u64 size = lseek(file->fd, 0, SEEK_CUR); | 211 | u64 size = lseek(perf_data_file__fd(file), 0, SEEK_CUR); |
212 | if (size == 0) | 212 | if (size == 0) |
213 | return 0; | 213 | return 0; |
214 | 214 | ||
@@ -334,6 +334,7 @@ static int __cmd_record(struct record *rec, int argc, const char **argv) | |||
334 | struct perf_data_file *file = &rec->file; | 334 | struct perf_data_file *file = &rec->file; |
335 | struct perf_session *session; | 335 | struct perf_session *session; |
336 | bool disabled = false, draining = false; | 336 | bool disabled = false, draining = false; |
337 | int fd; | ||
337 | 338 | ||
338 | rec->progname = argv[0]; | 339 | rec->progname = argv[0]; |
339 | 340 | ||
@@ -348,6 +349,7 @@ static int __cmd_record(struct record *rec, int argc, const char **argv) | |||
348 | return -1; | 349 | return -1; |
349 | } | 350 | } |
350 | 351 | ||
352 | fd = perf_data_file__fd(file); | ||
351 | rec->session = session; | 353 | rec->session = session; |
352 | 354 | ||
353 | record__init_features(rec); | 355 | record__init_features(rec); |
@@ -372,12 +374,11 @@ static int __cmd_record(struct record *rec, int argc, const char **argv) | |||
372 | perf_header__clear_feat(&session->header, HEADER_GROUP_DESC); | 374 | perf_header__clear_feat(&session->header, HEADER_GROUP_DESC); |
373 | 375 | ||
374 | if (file->is_pipe) { | 376 | if (file->is_pipe) { |
375 | err = perf_header__write_pipe(file->fd); | 377 | err = perf_header__write_pipe(fd); |
376 | if (err < 0) | 378 | if (err < 0) |
377 | goto out_child; | 379 | goto out_child; |
378 | } else { | 380 | } else { |
379 | err = perf_session__write_header(session, rec->evlist, | 381 | err = perf_session__write_header(session, rec->evlist, fd, false); |
380 | file->fd, false); | ||
381 | if (err < 0) | 382 | if (err < 0) |
382 | goto out_child; | 383 | goto out_child; |
383 | } | 384 | } |
@@ -409,7 +410,7 @@ static int __cmd_record(struct record *rec, int argc, const char **argv) | |||
409 | * return this more properly and also | 410 | * return this more properly and also |
410 | * propagate errors that now are calling die() | 411 | * propagate errors that now are calling die() |
411 | */ | 412 | */ |
412 | err = perf_event__synthesize_tracing_data(tool, file->fd, rec->evlist, | 413 | err = perf_event__synthesize_tracing_data(tool, fd, rec->evlist, |
413 | process_synthesized_event); | 414 | process_synthesized_event); |
414 | if (err <= 0) { | 415 | if (err <= 0) { |
415 | pr_err("Couldn't record tracing data.\n"); | 416 | pr_err("Couldn't record tracing data.\n"); |
@@ -545,8 +546,7 @@ out_child: | |||
545 | 546 | ||
546 | if (!rec->no_buildid) | 547 | if (!rec->no_buildid) |
547 | process_buildids(rec); | 548 | process_buildids(rec); |
548 | perf_session__write_header(rec->session, rec->evlist, | 549 | perf_session__write_header(rec->session, rec->evlist, fd, true); |
549 | file->fd, true); | ||
550 | } | 550 | } |
551 | 551 | ||
552 | if (!err && !quiet) { | 552 | if (!err && !quiet) { |