]>
Commit | Line | Data |
---|---|---|
fce2d171 | 1 | // stapdyn mutatee declarations |
ef36f781 | 2 | // Copyright (C) 2012-2014 Red Hat Inc. |
fce2d171 JS |
3 | // |
4 | // This file is part of systemtap, and is free software. You can | |
5 | // redistribute it and/or modify it under the terms of the GNU General | |
6 | // Public License (GPL); either version 2, or (at your option) any | |
7 | // later version. | |
8 | ||
9 | #ifndef MUTATEE_H | |
10 | #define MUTATEE_H | |
11 | ||
12 | #include <string> | |
13 | #include <vector> | |
14 | ||
b6fc2c14 SC |
15 | #include <dyninst/BPatch_object.h> |
16 | #include <dyninst/BPatch_process.h> | |
17 | #include <dyninst/BPatch_snippet.h> | |
fce2d171 JS |
18 | |
19 | #include "dynprobe.h" | |
20 | #include "dynutil.h" | |
21 | ||
22 | ||
23 | // A mutatee is created for each attached process | |
24 | class mutatee { | |
25 | private: | |
4ef3a23e | 26 | pid_t pid; // The system's process ID. |
fce2d171 JS |
27 | BPatch_process* process; // Dyninst's handle for this process |
28 | BPatch_object* stap_dso; // the injected stap module | |
29 | ||
30 | std::vector<BPatch_snippet*> registers; // PC + DWARF registers | |
31 | ||
f46c7408 JS |
32 | std::vector<BPatchSnippetHandle*> snippets; // handles from insertSnippet |
33 | ||
909ab234 JS |
34 | std::vector<BPatch_variableExpr*> semaphores; // SDT semaphore variables |
35 | ||
f31a77f5 DS |
36 | std::vector<dynprobe_location> attached_probes; |
37 | BPatch_function* utrace_enter_function; | |
38 | ||
90b7e794 JS |
39 | // process.end probes saved to run after exec |
40 | std::vector<dynprobe_location> exec_proc_end_probes; | |
41 | ||
848dec37 JS |
42 | // disable implicit constructors by not implementing these |
43 | mutatee (const mutatee& other); | |
44 | mutatee& operator= (const mutatee& other); | |
45 | ||
909ab234 JS |
46 | void update_semaphores(unsigned short delta, size_t start=0); |
47 | ||
90b7e794 JS |
48 | void call_utrace_dynprobes(const std::vector<dynprobe_location>& probes, |
49 | BPatch_thread* thread=NULL); | |
f31a77f5 DS |
50 | void instrument_utrace_dynprobe(const dynprobe_location& probe); |
51 | void instrument_global_dynprobe_target(const dynprobe_target& target); | |
52 | void instrument_global_dynprobes(const std::vector<dynprobe_target>& targets); | |
53 | ||
fce2d171 | 54 | public: |
a235a8f6 | 55 | mutatee(BPatch_process* process); |
f46c7408 | 56 | ~mutatee(); |
fce2d171 | 57 | |
76fb7222 JS |
58 | pid_t process_id() { return pid; } |
59 | ||
fce2d171 JS |
60 | bool operator==(BPatch_process* other) { return process == other; } |
61 | ||
62 | // Inject the stap module into the target process | |
63 | bool load_stap_dso(const std::string& filename); | |
64 | ||
f46c7408 JS |
65 | // Unload the stap module from the target process |
66 | void unload_stap_dso(); | |
67 | ||
fce2d171 JS |
68 | // Given a target and the matching object, instrument all of the probes |
69 | // with calls to the stap_dso's entry function. | |
70 | void instrument_dynprobe_target(BPatch_object* object, | |
71 | const dynprobe_target& target); | |
72 | ||
73 | // Look for all matches between this object and the targets | |
74 | // we want to probe, then do the instrumentation. | |
75 | void instrument_object_dynprobes(BPatch_object* object, | |
76 | const std::vector<dynprobe_target>& targets); | |
77 | ||
78 | // Look for probe matches in all objects. | |
90b7e794 | 79 | void instrument_dynprobes(const std::vector<dynprobe_target>& targets); |
fce2d171 | 80 | |
72100304 JS |
81 | // Copy data for forked instrumentation |
82 | void copy_forked_instrumentation(mutatee& other); | |
83 | ||
b9babf95 JS |
84 | // Reset instrumentation after an exec |
85 | void exec_reset_instrumentation(); | |
86 | ||
f46c7408 JS |
87 | // Remove all BPatch snippets we've instrumented in the target |
88 | void remove_instrumentation(); | |
89 | ||
f4d70a33 | 90 | // Look up a stap function by name and invoke it, optionally with parameters. |
fce2d171 | 91 | void call_function(const std::string& name); |
f4d70a33 JS |
92 | void call_function(const std::string& name, |
93 | const std::vector<BPatch_snippet *>& args); | |
fce2d171 | 94 | |
4ef3a23e JS |
95 | // Send a signal to the process. |
96 | int kill(int signal); | |
97 | ||
a235a8f6 | 98 | bool stop_execution(); |
f31a77f5 | 99 | void continue_execution(); |
4ef3a23e JS |
100 | void terminate_execution() { process->terminateExecution(); } |
101 | ||
102 | bool is_stopped() { return process->isStopped(); } | |
fce2d171 | 103 | bool is_terminated() { return process->isTerminated(); } |
4ef3a23e | 104 | |
fce2d171 | 105 | bool check_exit() { return check_dyninst_exit(process); } |
f31a77f5 | 106 | |
90b7e794 JS |
107 | void begin_callback(BPatch_thread *thread=NULL); |
108 | void exit_callback(BPatch_thread *thread, bool exec_p=false); | |
f31a77f5 | 109 | void thread_callback(BPatch_thread *thread, bool create_p); |
03399f75 | 110 | |
90b7e794 | 111 | std::vector<dynprobe_location> find_attached_probes(uint64_t flag); |
fce2d171 JS |
112 | }; |
113 | ||
114 | #endif // MUTATEE_H | |
115 | ||
116 | /* vim: set sw=2 ts=8 cino=>4,n-2,{2,^-2,t0,(0,u0,w1,M1 : */ |