~ubuntu-branches/debian/experimental/linux-tools/experimental

« back to all changes in this revision

Viewing changes to tools/perf/builtin-inject.c

  • Committer: Package Import Robot
  • Author(s): Ben Hutchings
  • Date: 2014-02-02 16:57:49 UTC
  • mfrom: (1.1.10) (0.1.21 sid)
  • Revision ID: package-import@ubuntu.com-20140202165749-tw94o9t1t0a8txk6
Tags: 3.13-1~exp2
Merge changes from sid up to 3.12.6-3

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
#include "util/tool.h"
16
16
#include "util/debug.h"
17
17
#include "util/build-id.h"
 
18
#include "util/data.h"
18
19
 
19
20
#include "util/parse-options.h"
20
21
 
71
72
                                   union perf_event *event,
72
73
                                   struct perf_evlist **pevlist)
73
74
{
 
75
        struct perf_inject *inject = container_of(tool, struct perf_inject,
 
76
                                                  tool);
74
77
        int ret;
75
78
 
76
79
        ret = perf_event__process_attr(tool, event, pevlist);
77
80
        if (ret)
78
81
                return ret;
79
82
 
 
83
        if (!inject->pipe_output)
 
84
                return 0;
 
85
 
80
86
        return perf_event__repipe_synth(tool, event);
81
87
}
82
88
 
100
106
                                     struct perf_evsel *evsel,
101
107
                                     struct machine *machine)
102
108
{
103
 
        if (evsel->handler.func) {
104
 
                inject_handler f = evsel->handler.func;
 
109
        if (evsel->handler) {
 
110
                inject_handler f = evsel->handler;
105
111
                return f(tool, event, sample, evsel, machine);
106
112
        }
107
113
 
161
167
        return err;
162
168
}
163
169
 
164
 
static int dso__read_build_id(struct dso *self)
 
170
static int dso__read_build_id(struct dso *dso)
165
171
{
166
 
        if (self->has_build_id)
 
172
        if (dso->has_build_id)
167
173
                return 0;
168
174
 
169
 
        if (filename__read_build_id(self->long_name, self->build_id,
170
 
                                    sizeof(self->build_id)) > 0) {
171
 
                self->has_build_id = true;
 
175
        if (filename__read_build_id(dso->long_name, dso->build_id,
 
176
                                    sizeof(dso->build_id)) > 0) {
 
177
                dso->has_build_id = true;
172
178
                return 0;
173
179
        }
174
180
 
175
181
        return -1;
176
182
}
177
183
 
178
 
static int dso__inject_build_id(struct dso *self, struct perf_tool *tool,
 
184
static int dso__inject_build_id(struct dso *dso, struct perf_tool *tool,
179
185
                                struct machine *machine)
180
186
{
181
187
        u16 misc = PERF_RECORD_MISC_USER;
182
188
        int err;
183
189
 
184
 
        if (dso__read_build_id(self) < 0) {
185
 
                pr_debug("no build_id found for %s\n", self->long_name);
 
190
        if (dso__read_build_id(dso) < 0) {
 
191
                pr_debug("no build_id found for %s\n", dso->long_name);
186
192
                return -1;
187
193
        }
188
194
 
189
 
        if (self->kernel)
 
195
        if (dso->kernel)
190
196
                misc = PERF_RECORD_MISC_KERNEL;
191
197
 
192
 
        err = perf_event__synthesize_build_id(tool, self, misc, perf_event__repipe,
 
198
        err = perf_event__synthesize_build_id(tool, dso, misc, perf_event__repipe,
193
199
                                              machine);
194
200
        if (err) {
195
 
                pr_err("Can't synthesize build_id event for %s\n", self->long_name);
 
201
                pr_err("Can't synthesize build_id event for %s\n", dso->long_name);
196
202
                return -1;
197
203
        }
198
204
 
231
237
                                 * account this as unresolved.
232
238
                                 */
233
239
                        } else {
234
 
#ifdef LIBELF_SUPPORT
 
240
#ifdef HAVE_LIBELF_SUPPORT
235
241
                                pr_warning("no symbols found in %s, maybe "
236
242
                                           "install a debug package?\n",
237
243
                                           al.map->dso->long_name);
345
351
{
346
352
        struct perf_session *session;
347
353
        int ret = -EINVAL;
 
354
        struct perf_data_file file = {
 
355
                .path = inject->input_name,
 
356
                .mode = PERF_DATA_MODE_READ,
 
357
        };
348
358
 
349
359
        signal(SIGINT, sig_handler);
350
360
 
355
365
                inject->tool.tracing_data = perf_event__repipe_tracing_data;
356
366
        }
357
367
 
358
 
        session = perf_session__new(inject->input_name, O_RDONLY, false, true, &inject->tool);
 
368
        session = perf_session__new(&file, true, &inject->tool);
359
369
        if (session == NULL)
360
370
                return -ENOMEM;
361
371
 
373
383
                                if (perf_evsel__check_stype(evsel, PERF_SAMPLE_TID, "TID"))
374
384
                                        return -EINVAL;
375
385
 
376
 
                                evsel->handler.func = perf_inject__sched_switch;
 
386
                                evsel->handler = perf_inject__sched_switch;
377
387
                        } else if (!strcmp(name, "sched:sched_process_exit"))
378
 
                                evsel->handler.func = perf_inject__sched_process_exit;
 
388
                                evsel->handler = perf_inject__sched_process_exit;
379
389
                        else if (!strncmp(name, "sched:sched_stat_", 17))
380
 
                                evsel->handler.func = perf_inject__sched_stat;
 
390
                                evsel->handler = perf_inject__sched_stat;
381
391
                }
382
392
        }
383
393