blob: 3181b74f55705114365199142c14bd6fa48a7f3c [file] [log] [blame]
Jon Medhurst15ce78d2014-04-10 09:02:02 +01001/**
2 * Copyright (C) ARM Limited 2013-2014. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
8
9#ifndef PERFDRIVER_H
10#define PERFDRIVER_H
11
12#include "Driver.h"
13
14// If debugfs is not mounted at /sys/kernel/debug, update DEBUGFS_PATH
15#define DEBUGFS_PATH "/sys/kernel/debug"
16#define EVENTS_PATH DEBUGFS_PATH "/tracing/events"
17
18#define SCHED_SWITCH "sched/sched_switch"
19
20class Buffer;
21class DynBuf;
22class PerfCounter;
23class PerfGroup;
24
25class PerfDriver : public Driver {
26public:
27 PerfDriver();
28 ~PerfDriver();
29
30 bool setup();
31 bool summary(Buffer *const buffer);
32 bool isSetup() const { return mIsSetup; }
33
34 bool claimCounter(const Counter &counter) const;
35 void resetCounters();
36 void setupCounter(Counter &counter);
37
38 int writeCounters(mxml_node_t *root) const;
39
40 bool enable(PerfGroup *group, Buffer *const buffer) const;
41
42 static long long getTracepointId(const char *const name, DynBuf *const printb);
43
44private:
45 PerfCounter *findCounter(const Counter &counter) const;
46 void addCpuCounters(const char *const counterName, const int type, const int numCounters);
47
48 PerfCounter *mCounters;
49 bool mIsSetup;
50
51 // Intentionally undefined
52 PerfDriver(const PerfDriver &);
53 PerfDriver &operator=(const PerfDriver &);
54};
55
56#endif // PERFDRIVER_H