]>
Commit | Line | Data |
---|---|---|
177a8ead | 1 | // -*- C++ -*- |
d389518f | 2 | // Copyright (C) 2005-2011 Red Hat Inc. |
177a8ead FCE |
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 SESSION_H | |
10 | #define SESSION_H | |
11 | ||
9456e4c1 JS |
12 | #include "config.h" |
13 | ||
aa4d21c0 | 14 | #include <list> |
177a8ead FCE |
15 | #include <string> |
16 | #include <vector> | |
17 | #include <iostream> | |
18 | #include <sstream> | |
19 | #include <map> | |
7e41d3dc | 20 | #include <set> |
177a8ead | 21 | |
1d3a40b6 | 22 | extern "C" { |
2dce8c42 | 23 | #include <signal.h> |
1d3a40b6 DS |
24 | #include <elfutils/libdw.h> |
25 | } | |
26 | ||
177a8ead FCE |
27 | |
28 | // forward decls for all referenced systemtap types | |
9b3c54b2 | 29 | struct hash; |
177a8ead FCE |
30 | struct match_node; |
31 | struct stapfile; | |
32 | struct vardecl; | |
cfd621bc | 33 | struct token; |
177a8ead | 34 | struct functiondecl; |
b20febf3 FCE |
35 | struct derived_probe; |
36 | struct be_derived_probe_group; | |
37 | struct dwarf_derived_probe_group; | |
e6fe60e7 | 38 | struct kprobe_derived_probe_group; |
dd225250 | 39 | struct hwbkpt_derived_probe_group; |
83ea76b1 | 40 | struct perf_derived_probe_group; |
888af770 | 41 | struct uprobe_derived_probe_group; |
935447c8 | 42 | struct utrace_derived_probe_group; |
a96d1db0 | 43 | struct itrace_derived_probe_group; |
935447c8 | 44 | struct task_finder_derived_probe_group; |
b20febf3 FCE |
45 | struct timer_derived_probe_group; |
46 | struct profile_derived_probe_group; | |
47 | struct mark_derived_probe_group; | |
0a6f5a3f | 48 | struct tracepoint_derived_probe_group; |
b20febf3 | 49 | struct hrtimer_derived_probe_group; |
604eef3b | 50 | struct procfs_derived_probe_group; |
177a8ead FCE |
51 | struct embeddedcode; |
52 | struct translator_output; | |
53 | struct unparser; | |
54 | struct semantic_error; | |
405b71b8 | 55 | struct module_cache; |
f80d9004 | 56 | struct update_visitor; |
177a8ead | 57 | |
177a8ead FCE |
58 | // XXX: a generalized form of this descriptor could be associated with |
59 | // a vardecl instead of out here at the systemtap_session level. | |
60 | struct statistic_decl | |
61 | { | |
62 | statistic_decl() | |
dff50e09 | 63 | : type(none), |
177a8ead | 64 | linear_low(0), linear_high(0), linear_step(0) |
dff50e09 | 65 | {} |
177a8ead | 66 | enum { none, linear, logarithmic } type; |
177a8ead FCE |
67 | int64_t linear_low; |
68 | int64_t linear_high; | |
69 | int64_t linear_step; | |
07c17d67 GH |
70 | bool operator==(statistic_decl const & other) |
71 | { | |
dff50e09 | 72 | return type == other.type |
07c17d67 GH |
73 | && linear_low == other.linear_low |
74 | && linear_high == other.linear_high | |
75 | && linear_step == other.linear_step; | |
76 | } | |
177a8ead FCE |
77 | }; |
78 | ||
177a8ead FCE |
79 | struct systemtap_session |
80 | { | |
81 | systemtap_session (); | |
b0e5fa85 | 82 | ~systemtap_session (); |
aa4d21c0 | 83 | |
28f569c2 | 84 | // NB: It is very important for all of the above (and below) fields |
85007c04 | 85 | // to be cleared in the systemtap_session ctor (session.cxx). |
e2012a7a | 86 | void setup_kernel_release (const char* kstr); |
bb153adb | 87 | void insert_loaded_modules (); |
e2012a7a DB |
88 | |
89 | // command line parsing | |
90 | int parse_cmdline (int argc, char * const argv []); | |
91 | void version (); | |
92 | void usage (int exitcode); | |
93 | void check_options (int argc, char * const argv []); | |
94 | static const char* morehelp; | |
177a8ead | 95 | |
aa4d21c0 | 96 | // NB: It is very important for all of the above (and below) fields |
85007c04 | 97 | // to be cleared in the systemtap_session ctor (session.cxx). |
aa4d21c0 | 98 | |
177a8ead | 99 | // command line args |
e2012a7a DB |
100 | std::string script_file; // FILE |
101 | std::string cmdline_script; // -e PROGRAM | |
102 | bool have_script; | |
177a8ead | 103 | std::vector<std::string> include_path; |
2fad97fd | 104 | int include_arg_start; |
177a8ead FCE |
105 | std::vector<std::string> macros; |
106 | std::vector<std::string> args; | |
1392896d | 107 | std::vector<std::string> kbuildflags; |
bb25d08f | 108 | std::vector<std::string> globalopts; // -G var=val |
e2012a7a | 109 | std::string release; |
177a8ead | 110 | std::string kernel_release; |
197a4d62 | 111 | std::string kernel_base_release; |
7471ea1f | 112 | std::string kernel_build_tree; |
d4393459 | 113 | std::string kernel_source_tree; |
561079c8 | 114 | std::map<std::string,std::string> kernel_config; |
70e6d6c9 | 115 | std::set<std::string> kernel_exports; |
e2012a7a | 116 | std::string machine; |
44ce8ed5 | 117 | std::string architecture; |
177a8ead | 118 | std::string runtime_path; |
2fad97fd | 119 | bool runtime_specified; |
1b78aef5 | 120 | std::string data_path; |
177a8ead | 121 | std::string module_name; |
de0db58a | 122 | std::string stapconf_name; |
177a8ead | 123 | std::string output_file; |
701c41be | 124 | std::string size_option; |
177a8ead | 125 | std::string cmd; |
db135493 | 126 | std::string compatible; // use (strverscmp(s.compatible.c_str(), "N.M") >= 0) |
177a8ead FCE |
127 | int target_pid; |
128 | int last_pass; | |
e0b4e89d | 129 | unsigned perpass_verbose[5]; |
b0ee93c4 | 130 | unsigned verbose; |
a9e8f7e0 | 131 | bool timing; |
e2012a7a | 132 | bool save_module; |
177a8ead FCE |
133 | bool keep_tmpdir; |
134 | bool guru_mode; | |
16442b90 | 135 | bool listing_mode; |
8c39844b | 136 | bool listing_mode_vars; |
177a8ead | 137 | bool bulk_mode; |
cbfbbf69 | 138 | bool unoptimized; |
a9e8f7e0 | 139 | bool suppress_warnings; |
57a56e00 | 140 | bool panic_warnings; |
177a8ead | 141 | int buffer_size; |
44f75386 | 142 | bool prologue_searching; |
c3a3c0c9 | 143 | bool tapset_compile_coverage; |
6274464e | 144 | bool need_uprobes; |
474d17ad | 145 | std::string uprobes_path; |
2fa2a091 | 146 | bool load_only; // flight recorder mode |
2dce8c42 DB |
147 | bool omit_werror; |
148 | bool unprivileged; | |
a07a2c28 | 149 | bool systemtap_v_check; |
2dce8c42 DB |
150 | |
151 | // NB: It is very important for all of the above (and below) fields | |
85007c04 | 152 | // to be cleared in the systemtap_session ctor (session.cxx). |
2dce8c42 DB |
153 | |
154 | // Client/server | |
d389518f | 155 | static bool NSPR_Initialized; // only once for all sessions |
3d9dfde6 | 156 | void NSPR_init (); |
e2012a7a DB |
157 | bool client_options; |
158 | std::string client_options_disallowed; | |
2dce8c42 DB |
159 | std::vector<std::string> server_status_strings; |
160 | std::vector<std::string> specified_servers; | |
c77af0d0 | 161 | std::string server_trust_spec; |
2fad97fd | 162 | std::vector<std::string> server_args; |
920be590 | 163 | std::string winning_server; |
ce286ff0 DB |
164 | |
165 | // NB: It is very important for all of the above (and below) fields | |
166 | // to be cleared in the systemtap_session ctor (session.cxx). | |
167 | ||
168 | // Mechanism for retrying compilation with a compile server should it fail due | |
169 | // to lack of resources on the local host. | |
170 | // Once it has been decided not to try the server (e.g. syntax error), | |
171 | // that decision cannot be changed. | |
172 | int try_server_status; | |
173 | bool use_server_on_error; | |
174 | ||
175 | enum { dont_try_server = -1, try_server_unset = 0, do_try_server = 1 }; | |
176 | void init_try_server (); | |
177 | void set_try_server (int t = do_try_server); | |
178 | bool try_server () const { return try_server_status == do_try_server; } | |
179 | ||
180 | // NB: It is very important for all of the above (and below) fields | |
181 | // to be cleared in the systemtap_session ctor (session.cxx). | |
2dce8c42 | 182 | |
daa75206 JS |
183 | // Remote execution |
184 | std::vector<std::string> remote_uris; | |
ebff2ed0 JS |
185 | typedef std::map<std::pair<std::string, std::string>, systemtap_session*> session_map_t; |
186 | session_map_t subsessions; | |
187 | systemtap_session* clone(const std::string& arch, const std::string& release); | |
daa75206 | 188 | |
28f569c2 | 189 | // NB: It is very important for all of the above (and below) fields |
85007c04 | 190 | // to be cleared in the systemtap_session ctor (session.cxx). |
28f569c2 | 191 | |
1b78aef5 | 192 | // Cache data |
d105f664 JS |
193 | bool use_cache; // control all caching |
194 | bool use_script_cache; // control caching of pass-3/4 output | |
195 | bool poison_cache; // consider the cache to be write-only | |
196 | std::string cache_path; // usually ~/.systemtap/cache | |
197 | std::string hash_path; // path to the cached script module | |
198 | std::string stapconf_path; // path to the cached stapconf | |
199 | hash *base_hash; // hash common to all caching | |
1b78aef5 | 200 | |
5f0a03a6 JK |
201 | // dwarfless operation |
202 | bool consult_symtab; | |
203 | std::string kernel_symtab_path; | |
204 | bool ignore_vmlinux; | |
205 | bool ignore_dwarf; | |
206 | ||
3bd0d4df RA |
207 | // Skip bad $ vars |
208 | bool skip_badvars; | |
209 | ||
28f569c2 | 210 | // NB: It is very important for all of the above (and below) fields |
85007c04 | 211 | // to be cleared in the systemtap_session ctor (session.cxx). |
28f569c2 | 212 | |
177a8ead FCE |
213 | // temporary directory for module builds etc. |
214 | // hazardous - it is "rm -rf"'d at exit | |
215 | std::string tmpdir; | |
216 | std::string translated_source; // C source code | |
217 | ||
218 | match_node* pattern_root; | |
219 | void register_library_aliases(); | |
220 | ||
221 | // parse trees for the various script files | |
222 | stapfile* user_file; | |
223 | std::vector<stapfile*> library_files; | |
224 | ||
f80d9004 JS |
225 | // filters to run over all code before symbol resolution |
226 | // e.g. @cast expansion | |
227 | std::vector<update_visitor*> code_filters; | |
228 | ||
177a8ead FCE |
229 | // resolved globals/functions/probes for the run as a whole |
230 | std::vector<stapfile*> files; | |
231 | std::vector<vardecl*> globals; | |
f76427a2 | 232 | std::map<std::string,functiondecl*> functions; |
b20febf3 | 233 | std::vector<derived_probe*> probes; // see also *_probes groups below |
177a8ead FCE |
234 | std::vector<embeddedcode*> embeds; |
235 | std::map<std::string, statistic_decl> stat_decls; | |
c3a3c0c9 WC |
236 | // track things that are removed |
237 | std::vector<vardecl*> unused_globals; | |
238 | std::vector<derived_probe*> unused_probes; // see also *_probes groups below | |
239 | std::vector<functiondecl*> unused_functions; | |
177a8ead FCE |
240 | // XXX: vector<*> instead please? |
241 | ||
b20febf3 FCE |
242 | // Every probe in these groups must also appear in the |
243 | // session.probes vector. | |
244 | be_derived_probe_group* be_derived_probes; | |
245 | dwarf_derived_probe_group* dwarf_derived_probes; | |
e6fe60e7 | 246 | kprobe_derived_probe_group* kprobe_derived_probes; |
dd225250 | 247 | hwbkpt_derived_probe_group* hwbkpt_derived_probes; |
83ea76b1 | 248 | perf_derived_probe_group* perf_derived_probes; |
888af770 | 249 | uprobe_derived_probe_group* uprobe_derived_probes; |
935447c8 | 250 | utrace_derived_probe_group* utrace_derived_probes; |
a96d1db0 | 251 | itrace_derived_probe_group* itrace_derived_probes; |
935447c8 | 252 | task_finder_derived_probe_group* task_finder_derived_probes; |
b20febf3 FCE |
253 | timer_derived_probe_group* timer_derived_probes; |
254 | profile_derived_probe_group* profile_derived_probes; | |
255 | mark_derived_probe_group* mark_derived_probes; | |
0a6f5a3f | 256 | tracepoint_derived_probe_group* tracepoint_derived_probes; |
b20febf3 | 257 | hrtimer_derived_probe_group* hrtimer_derived_probes; |
604eef3b | 258 | procfs_derived_probe_group* procfs_derived_probes; |
28f569c2 | 259 | |
f9355a6c | 260 | // NB: It is very important for all of the above (and below) fields |
85007c04 | 261 | // to be cleared in the systemtap_session ctor (session.cxx). |
177a8ead FCE |
262 | |
263 | // unparser data | |
264 | translator_output* op; | |
265 | unparser* up; | |
266 | ||
84048984 FCE |
267 | // some symbol addresses |
268 | // XXX: these belong elsewhere; perhaps the dwflpp instance | |
269 | Dwarf_Addr sym_kprobes_text_start; | |
270 | Dwarf_Addr sym_kprobes_text_end; | |
271 | Dwarf_Addr sym_stext; | |
1d3a40b6 | 272 | |
a8368458 | 273 | // List of libdwfl module names to extract symbol/unwind data for. |
1a0dbc5a | 274 | std::set<std::string> unwindsym_modules; |
ef06c938 | 275 | bool unwindsym_ldd; |
cbf5ebe1 | 276 | struct module_cache* module_cache; |
a8368458 | 277 | |
28f569c2 | 278 | // NB: It is very important for all of the above (and below) fields |
85007c04 | 279 | // to be cleared in the systemtap_session ctor (session.cxx). |
28f569c2 | 280 | |
7e41d3dc | 281 | std::set<std::string> seen_errors; |
ab54fa85 | 282 | std::set<std::string> seen_warnings; |
57a56e00 | 283 | unsigned num_errors () { return seen_errors.size() + (panic_warnings ? seen_warnings.size() : 0); } |
cfd621bc | 284 | |
2ed04863 WC |
285 | std::set<std::string> rpms_to_install; |
286 | ||
177a8ead | 287 | // void print_error (const parse_error& e); |
cfd621bc FCE |
288 | const token* last_token; |
289 | void print_token (std::ostream& o, const token* tok); | |
177a8ead | 290 | void print_error (const semantic_error& e); |
1b1b4ceb | 291 | void print_error_source (std::ostream&, std::string&, const token* tok); |
cfd621bc | 292 | void print_warning (const std::string& w, const token* tok = 0); |
aa4d21c0 | 293 | void printscript(std::ostream& o); |
b20febf3 | 294 | |
28f569c2 | 295 | // NB: It is very important for all of the above (and below) fields |
85007c04 DB |
296 | // to be cleared in the systemtap_session ctor (session.cxx). |
297 | }; | |
298 | ||
177a8ead | 299 | |
49abf162 | 300 | // global counter of SIGINT/SIGTERM's received |
85007c04 DB |
301 | extern int pending_interrupts; |
302 | ||
177a8ead | 303 | #endif // SESSION_H |
73267b89 JS |
304 | |
305 | /* vim: set sw=2 ts=8 cino=>4,n-2,{2,^-2,t0,(0,u0,w1,M1 : */ |