forked from rwanyoike/cputhrottle
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmanip.h
61 lines (46 loc) · 1.65 KB
/
manip.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef __LIBPROC_MANIP_H_
#define __LIBPROC_MANIP_H_
#include <boost/shared_ptr.hpp>
#include <exception>
#include <map>
#include <string>
#include <mach/task.h>
//#include "regs.h"
namespace Process
{
class ManipulatorException : public std::exception
{
public:
ManipulatorException(const std::string &msg_) : _msg(msg_) {}
virtual ~ManipulatorException() throw() {}
virtual const char* what() const throw()
{
return _msg.c_str();
}
private:
std::string _msg;
};
class Manipulator
{
public:
Manipulator();
~Manipulator();
void attach(pid_t pid_); // throw ManipulatorException
void detach(pid_t pid_); // throw ManipulatorException
void singleStep(pid_t pid_); // throw ManipulatorException
void continueRunning(pid_t pid_); // throw ManipulatorException
void suspend(pid_t pid_); // throw ManipulatorException
void resume(pid_t pid_); // throw ManipulatorException
void sample(pid_t pid_,
double *user_time, double *system_time,
double *percent); // throw ManipulatorException
// boost::shared_ptr<Registers> getRegs(); // throw ManipulatorException, RegistersException
private:
typedef std::map<pid_t, task_t> pidSetType;
pidSetType _attachedPids;
pidSetType::iterator detachIter(const pidSetType::iterator &iter_); // throw ManipulatorException
void suspendIter(const pidSetType::iterator &iter_); // throw ManipulatorException
void resumeIter(const pidSetType::iterator &iter_); // throw ManipulatorException
};
}
#endif