]>
Commit | Line | Data |
---|---|---|
1 | // stapdyn mutatee declarations | |
2 | // Copyright (C) 2012-2014 Red Hat Inc. | |
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 | ||
15 | #include <dyninst/BPatch_object.h> | |
16 | #include <dyninst/BPatch_process.h> | |
17 | #include <dyninst/BPatch_snippet.h> | |
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: | |
26 | pid_t pid; // The system's process ID. | |
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 | ||
32 | std::vector<BPatchSnippetHandle*> snippets; // handles from insertSnippet | |
33 | ||
34 | std::vector<BPatch_variableExpr*> semaphores; // SDT semaphore variables | |
35 | ||
36 | std::vector<dynprobe_location> attached_probes; | |
37 | BPatch_function* utrace_enter_function; | |
38 | ||
39 | // process.end probes saved to run after exec | |
40 | std::vector<dynprobe_location> exec_proc_end_probes; | |
41 | ||
42 | // disable implicit constructors by not implementing these | |
43 | mutatee (const mutatee& other); | |
44 | mutatee& operator= (const mutatee& other); | |
45 | ||
46 | void update_semaphores(unsigned short delta, size_t start=0); | |
47 | ||
48 | void call_utrace_dynprobes(const std::vector<dynprobe_location>& probes, | |
49 | BPatch_thread* thread=NULL); | |
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 | ||
54 | public: | |
55 | mutatee(BPatch_process* process); | |
56 | ~mutatee(); | |
57 | ||
58 | pid_t process_id() { return pid; } | |
59 | ||
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 | ||
65 | // Unload the stap module from the target process | |
66 | void unload_stap_dso(); | |
67 | ||
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. | |
79 | void instrument_dynprobes(const std::vector<dynprobe_target>& targets); | |
80 | ||
81 | // Copy data for forked instrumentation | |
82 | void copy_forked_instrumentation(mutatee& other); | |
83 | ||
84 | // Reset instrumentation after an exec | |
85 | void exec_reset_instrumentation(); | |
86 | ||
87 | // Remove all BPatch snippets we've instrumented in the target | |
88 | void remove_instrumentation(); | |
89 | ||
90 | // Look up a stap function by name and invoke it, optionally with parameters. | |
91 | void call_function(const std::string& name); | |
92 | void call_function(const std::string& name, | |
93 | const std::vector<BPatch_snippet *>& args); | |
94 | ||
95 | // Send a signal to the process. | |
96 | int kill(int signal); | |
97 | ||
98 | bool stop_execution(); | |
99 | void continue_execution(); | |
100 | void terminate_execution() { process->terminateExecution(); } | |
101 | ||
102 | bool is_stopped() { return process->isStopped(); } | |
103 | bool is_terminated() { return process->isTerminated(); } | |
104 | ||
105 | bool check_exit() { return check_dyninst_exit(process); } | |
106 | ||
107 | void begin_callback(BPatch_thread *thread=NULL); | |
108 | void exit_callback(BPatch_thread *thread, bool exec_p=false); | |
109 | void thread_callback(BPatch_thread *thread, bool create_p); | |
110 | ||
111 | std::vector<dynprobe_location> find_attached_probes(uint64_t flag); | |
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 : */ |