Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 323812
b: refs/heads/master
c: 5555ded
h: refs/heads/master
v: v3
  • Loading branch information
Arnaldo Carvalho de Melo committed Sep 11, 2012
1 parent 89af9ab commit 1fc56c8
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 0e9b07e574e544c1e840c59dabf39fef120620ae
refs/heads/master: 5555ded44698ed82ffa3d8742ec2994f695127bc
35 changes: 35 additions & 0 deletions trunk/tools/perf/util/evsel.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <byteswap.h>
#include <linux/bitops.h>
#include "asm/bug.h"
#include "event-parse.h"
#include "evsel.h"
#include "evlist.h"
#include "util.h"
Expand Down Expand Up @@ -1000,3 +1001,37 @@ int perf_event__synthesize_sample(union perf_event *event, u64 type,

return 0;
}

char *perf_evsel__strval(struct perf_evsel *evsel, struct perf_sample *sample,
const char *name)
{
struct format_field *field = pevent_find_field(evsel->tp_format, name);
int offset;

if (!field)
return NULL;

offset = field->offset;

if (field->flags & FIELD_IS_DYNAMIC) {
offset = *(int *)(sample->raw_data + field->offset);
offset &= 0xffff;
}

return sample->raw_data + offset;
}

u64 perf_evsel__intval(struct perf_evsel *evsel, struct perf_sample *sample,
const char *name)
{
struct format_field *field = pevent_find_field(evsel->tp_format, name);
u64 val;

if (!field)
return 0;

val = pevent_read_number(evsel->tp_format->pevent,
sample->raw_data + field->offset, field->size);
return val;

}
7 changes: 7 additions & 0 deletions trunk/tools/perf/util/evsel.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,13 @@ int perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus,
struct thread_map *threads);
void perf_evsel__close(struct perf_evsel *evsel, int ncpus, int nthreads);

struct perf_sample;

char *perf_evsel__strval(struct perf_evsel *evsel, struct perf_sample *sample,
const char *name);
u64 perf_evsel__intval(struct perf_evsel *evsel, struct perf_sample *sample,
const char *name);

#define perf_evsel__match(evsel, t, c) \
(evsel->attr.type == PERF_TYPE_##t && \
evsel->attr.config == PERF_COUNT_##c)
Expand Down

0 comments on commit 1fc56c8

Please sign in to comment.