Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 223893
b: refs/heads/master
c: 9c90a61
h: refs/heads/master
i:
  223891: db59d35
v: v3
  • Loading branch information
Arnaldo Carvalho de Melo committed Dec 5, 2010
1 parent 7b94498 commit 40e6361
Show file tree
Hide file tree
Showing 10 changed files with 316 additions and 101 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: 640c03ce837fe8d4b56342aba376ea0da3960459
refs/heads/master: 9c90a61c7e4286aa5a38b314a2d8f5a1e70b5135
5 changes: 5 additions & 0 deletions trunk/tools/perf/Documentation/perf-record.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ OPTIONS
--data::
Sample addresses.

-T::
--timestamp::
Sample timestamps. Use it with 'perf report -D' to see the timestamps,
for instance.

-n::
--no-samples::
Don't sample.
Expand Down
16 changes: 16 additions & 0 deletions trunk/tools/perf/builtin-record.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ static const char *output_name = "perf.data";
static int group = 0;
static int realtime_prio = 0;
static bool raw_samples = false;
static bool sample_id_all_avail = true;
static bool system_wide = false;
static pid_t target_pid = -1;
static pid_t target_tid = -1;
Expand All @@ -61,6 +62,7 @@ static bool call_graph = false;
static bool inherit_stat = false;
static bool no_samples = false;
static bool sample_address = false;
static bool sample_time = false;
static bool no_buildid = false;
static bool no_buildid_cache = false;

Expand Down Expand Up @@ -283,6 +285,9 @@ static void create_counter(int counter, int cpu)
if (system_wide)
attr->sample_type |= PERF_SAMPLE_CPU;

if (sample_time)
attr->sample_type |= PERF_SAMPLE_TIME;

if (raw_samples) {
attr->sample_type |= PERF_SAMPLE_TIME;
attr->sample_type |= PERF_SAMPLE_RAW;
Expand All @@ -299,6 +304,8 @@ static void create_counter(int counter, int cpu)
attr->disabled = 1;
attr->enable_on_exec = 1;
}
retry_sample_id:
attr->sample_id_all = sample_id_all_avail ? 1 : 0;

for (thread_index = 0; thread_index < thread_num; thread_index++) {
try_again:
Expand All @@ -315,6 +322,12 @@ static void create_counter(int counter, int cpu)
else if (err == ENODEV && cpu_list) {
die("No such device - did you specify"
" an out-of-range profile CPU?\n");
} else if (err == EINVAL && sample_id_all_avail) {
/*
* Old kernel, no attr->sample_id_type_all field
*/
sample_id_all_avail = false;
goto retry_sample_id;
}

/*
Expand Down Expand Up @@ -661,6 +674,8 @@ static int __cmd_record(int argc, const char **argv)

post_processing_offset = lseek(output, 0, SEEK_CUR);

perf_session__set_sample_id_all(session, sample_id_all_avail);

if (pipe_output) {
err = event__synthesize_attrs(&session->header,
process_synthesized_event,
Expand Down Expand Up @@ -841,6 +856,7 @@ const struct option record_options[] = {
"per thread counts"),
OPT_BOOLEAN('d', "data", &sample_address,
"Sample addresses"),
OPT_BOOLEAN('T', "timestamp", &sample_time, "Sample timestamps"),
OPT_BOOLEAN('n', "no-samples", &no_samples,
"don't sample"),
OPT_BOOLEAN('N', "no-buildid-cache", &no_buildid_cache,
Expand Down
14 changes: 7 additions & 7 deletions trunk/tools/perf/builtin-top.c
Original file line number Diff line number Diff line change
Expand Up @@ -977,12 +977,12 @@ static int symbol_filter(struct map *map, struct symbol *sym)
}

static void event__process_sample(const event_t *self,
struct perf_session *session, int counter)
struct sample_data *sample,
struct perf_session *session, int counter)
{
u64 ip = self->ip.ip;
struct sym_entry *syme;
struct addr_location al;
struct sample_data data;
struct machine *machine;
u8 origin = self->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;

Expand Down Expand Up @@ -1025,9 +1025,7 @@ static void event__process_sample(const event_t *self,
if (self->header.misc & PERF_RECORD_MISC_EXACT_IP)
exact_samples++;

event__parse_sample(self, session->sample_type, &data);

if (event__preprocess_sample(self, session, &al, &data,
if (event__preprocess_sample(self, session, &al, sample,
symbol_filter) < 0 ||
al.filtered)
return;
Expand Down Expand Up @@ -1107,6 +1105,7 @@ static void perf_session__mmap_read_counter(struct perf_session *self,
unsigned int head = mmap_read_head(md);
unsigned int old = md->prev;
unsigned char *data = md->base + page_size;
struct sample_data sample;
int diff;

/*
Expand Down Expand Up @@ -1154,10 +1153,11 @@ static void perf_session__mmap_read_counter(struct perf_session *self,
event = &event_copy;
}

event__parse_sample(event, self, &sample);
if (event->header.type == PERF_RECORD_SAMPLE)
event__process_sample(event, self, md->counter);
event__process_sample(event, &sample, self, md->counter);
else
event__process(event, NULL, self);
event__process(event, &sample, self);
old += size;
}

Expand Down
Loading

0 comments on commit 40e6361

Please sign in to comment.