aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-record.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/builtin-record.c')
-rw-r--r--tools/perf/builtin-record.c50
1 files changed, 34 insertions, 16 deletions
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 26542532273..771533ced6a 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -5,10 +5,13 @@
5 * (or a CPU, or a PID) into the perf.data output file - for 5 * (or a CPU, or a PID) into the perf.data output file - for
6 * later analysis via perf report. 6 * later analysis via perf report.
7 */ 7 */
8#define _FILE_OFFSET_BITS 64
9
8#include "builtin.h" 10#include "builtin.h"
9 11
10#include "perf.h" 12#include "perf.h"
11 13
14#include "util/build-id.h"
12#include "util/util.h" 15#include "util/util.h"
13#include "util/parse-options.h" 16#include "util/parse-options.h"
14#include "util/parse-events.h" 17#include "util/parse-events.h"
@@ -62,6 +65,7 @@ static int nr_poll = 0;
62static int nr_cpu = 0; 65static int nr_cpu = 0;
63 66
64static int file_new = 1; 67static int file_new = 1;
68static off_t post_processing_offset;
65 69
66static struct perf_session *session; 70static struct perf_session *session;
67 71
@@ -111,22 +115,10 @@ static void write_output(void *buf, size_t size)
111 } 115 }
112} 116}
113 117
114static void write_event(event_t *buf, size_t size)
115{
116 /*
117 * Add it to the list of DSOs, so that when we finish this
118 * record session we can pick the available build-ids.
119 */
120 if (buf->header.type == PERF_RECORD_MMAP)
121 dsos__findnew(buf->mmap.filename);
122
123 write_output(buf, size);
124}
125
126static int process_synthesized_event(event_t *event, 118static int process_synthesized_event(event_t *event,
127 struct perf_session *self __used) 119 struct perf_session *self __used)
128{ 120{
129 write_event(event, event->header.size); 121 write_output(event, event->header.size);
130 return 0; 122 return 0;
131} 123}
132 124
@@ -178,14 +170,14 @@ static void mmap_read(struct mmap_data *md)
178 size = md->mask + 1 - (old & md->mask); 170 size = md->mask + 1 - (old & md->mask);
179 old += size; 171 old += size;
180 172
181 write_event(buf, size); 173 write_output(buf, size);
182 } 174 }
183 175
184 buf = &data[old & md->mask]; 176 buf = &data[old & md->mask];
185 size = head - old; 177 size = head - old;
186 old += size; 178 old += size;
187 179
188 write_event(buf, size); 180 write_output(buf, size);
189 181
190 md->prev = old; 182 md->prev = old;
191 mmap_write_tail(md, old); 183 mmap_write_tail(md, old);
@@ -395,10 +387,21 @@ static void open_counters(int cpu, pid_t pid)
395 nr_cpu++; 387 nr_cpu++;
396} 388}
397 389
390static int process_buildids(void)
391{
392 u64 size = lseek(output, 0, SEEK_CUR);
393
394 session->fd = output;
395 return __perf_session__process_events(session, post_processing_offset,
396 size - post_processing_offset,
397 size, &build_id__mark_dso_hit_ops);
398}
399
398static void atexit_header(void) 400static void atexit_header(void)
399{ 401{
400 session->header.data_size += bytes_written; 402 session->header.data_size += bytes_written;
401 403
404 process_buildids();
402 perf_header__write(&session->header, output, true); 405 perf_header__write(&session->header, output, true);
403} 406}
404 407
@@ -551,8 +554,23 @@ static int __cmd_record(int argc, const char **argv)
551 return err; 554 return err;
552 } 555 }
553 556
557 post_processing_offset = lseek(output, 0, SEEK_CUR);
558
559 err = event__synthesize_kernel_mmap(process_synthesized_event,
560 session, "_text");
561 if (err < 0) {
562 pr_err("Couldn't record kernel reference relocation symbol.\n");
563 return err;
564 }
565
566 err = event__synthesize_modules(process_synthesized_event, session);
567 if (err < 0) {
568 pr_err("Couldn't record kernel reference relocation symbol.\n");
569 return err;
570 }
571
554 if (!system_wide && profile_cpu == -1) 572 if (!system_wide && profile_cpu == -1)
555 event__synthesize_thread(pid, process_synthesized_event, 573 event__synthesize_thread(target_pid, process_synthesized_event,
556 session); 574 session);
557 else 575 else
558 event__synthesize_threads(process_synthesized_event, session); 576 event__synthesize_threads(process_synthesized_event, session);