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