2 // Copyright (C) 2005-2011 Red Hat Inc.
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
26 #include <elfutils/libdw.h>
30 #define _(string) gettext(string)
31 #define _N(string, string_plural, count) \
32 ngettext((string), (string_plural), (count))
34 #define _(string) (string)
35 #define _N(string, string_plural, count) \
36 ( (count) == 1 ? (string) : (string_plural) )
38 #define _F(format, ...) autosprintf(_(format), __VA_ARGS__)
39 #define _NF(format, format_plural, count, ...) \
40 autosprintf(_N((format), (format_plural), (count)), __VA_ARGS__)
42 // forward decls for all referenced systemtap types
50 struct be_derived_probe_group
;
51 struct dwarf_derived_probe_group
;
52 struct kprobe_derived_probe_group
;
53 struct hwbkpt_derived_probe_group
;
54 struct perf_derived_probe_group
;
55 struct uprobe_derived_probe_group
;
56 struct utrace_derived_probe_group
;
57 struct itrace_derived_probe_group
;
58 struct task_finder_derived_probe_group
;
59 struct timer_derived_probe_group
;
60 struct profile_derived_probe_group
;
61 struct mark_derived_probe_group
;
62 struct tracepoint_derived_probe_group
;
63 struct hrtimer_derived_probe_group
;
64 struct procfs_derived_probe_group
;
66 struct translator_output
;
68 struct semantic_error
;
70 struct update_visitor
;
71 struct compile_server_cache
;
73 // XXX: a generalized form of this descriptor could be associated with
74 // a vardecl instead of out here at the systemtap_session level.
79 linear_low(0), linear_high(0), linear_step(0)
81 enum { none
, linear
, logarithmic
} type
;
85 bool operator==(statistic_decl
const & other
)
87 return type
== other
.type
88 && linear_low
== other
.linear_low
89 && linear_high
== other
.linear_high
90 && linear_step
== other
.linear_step
;
94 struct systemtap_session
97 // disable implicit constructors by not implementing these
98 systemtap_session (const systemtap_session
& other
);
99 systemtap_session
& operator= (const systemtap_session
& other
);
101 // copy constructor used by ::clone()
102 systemtap_session (const systemtap_session
& other
,
103 const std::string
& arch
,
104 const std::string
& kern
);
107 systemtap_session ();
108 ~systemtap_session ();
110 // NB: It is very important for all of the above (and below) fields
111 // to be cleared in the systemtap_session ctor (session.cxx).
112 void setup_kernel_release (const char* kstr
);
113 void insert_loaded_modules ();
115 // command line parsing
116 int parse_cmdline (int argc
, char * const argv
[]);
118 void usage (int exitcode
);
119 void check_options (int argc
, char * const argv
[]);
120 static const char* morehelp
;
122 // NB: It is very important for all of the above (and below) fields
123 // to be cleared in the systemtap_session ctor (session.cxx).
126 std::string script_file
; // FILE
127 std::string cmdline_script
; // -e PROGRAM
129 std::vector
<std::string
> include_path
;
130 int include_arg_start
;
131 std::vector
<std::string
> macros
;
132 std::vector
<std::string
> args
;
133 std::vector
<std::string
> kbuildflags
;
134 std::vector
<std::string
> globalopts
; // -G var=val
136 std::string kernel_release
;
137 std::string kernel_base_release
;
138 std::string kernel_build_tree
;
139 std::string kernel_source_tree
;
140 std::map
<std::string
,std::string
> kernel_config
;
141 std::set
<std::string
> kernel_exports
;
143 std::string architecture
;
144 std::string runtime_path
;
145 bool runtime_specified
;
146 std::string data_path
;
147 std::string module_name
;
148 std::string stapconf_name
;
149 std::string output_file
;
150 std::string size_option
;
152 std::string compatible
; // use (strverscmp(s.compatible.c_str(), "N.M") >= 0)
155 unsigned perpass_verbose
[5];
163 bool listing_mode_vars
;
166 bool suppress_warnings
;
169 bool prologue_searching
;
170 bool tapset_compile_coverage
;
174 std::string uprobes_path
;
175 std::string uprobes_hash
;
176 bool load_only
; // flight recorder mode
179 bool systemtap_v_check
;
181 bool dump_probe_types
;
184 // NB: It is very important for all of the above (and below) fields
185 // to be cleared in the systemtap_session ctor (session.cxx).
189 static bool NSPR_Initialized
; // only once for all sessions
193 std::string client_options_disallowed
;
194 std::vector
<std::string
> server_status_strings
;
195 std::vector
<std::string
> specified_servers
;
196 bool automatic_server_mode
;
197 std::string server_trust_spec
;
198 std::vector
<std::string
> server_args
;
199 std::string winning_server
;
200 compile_server_cache
* server_cache
;
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).
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
;
212 enum { try_server_unset
, dont_try_server
, do_try_server
};
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
; }
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).
221 std::vector
<std::string
> remote_uris
;
222 bool use_remote_prefix
;
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
);
227 // NB: It is very important for all of the above (and below) fields
228 // to be cleared in the systemtap_session ctor (session.cxx).
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
239 // dwarfless operation
241 std::string kernel_symtab_path
;
248 // NB: It is very important for all of the above (and below) fields
249 // to be cleared in the systemtap_session ctor (session.cxx).
251 // temporary directory for module builds etc.
252 // hazardous - it is "rm -rf"'d at exit
254 std::string translated_source
; // C source code
256 match_node
* pattern_root
;
257 void register_library_aliases();
259 // parse trees for the various script files
261 std::vector
<stapfile
*> library_files
;
263 // filters to run over all code before symbol resolution
264 // e.g. @cast expansion
265 std::vector
<update_visitor
*> code_filters
;
267 // resolved globals/functions/probes for the run as a whole
268 std::vector
<stapfile
*> files
;
269 std::vector
<vardecl
*> globals
;
270 std::map
<std::string
,functiondecl
*> functions
;
271 std::vector
<derived_probe
*> probes
; // see also *_probes groups below
272 std::vector
<embeddedcode
*> embeds
;
273 std::map
<std::string
, statistic_decl
> stat_decls
;
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
;
278 // XXX: vector<*> instead please?
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
;
284 kprobe_derived_probe_group
* kprobe_derived_probes
;
285 hwbkpt_derived_probe_group
* hwbkpt_derived_probes
;
286 perf_derived_probe_group
* perf_derived_probes
;
287 uprobe_derived_probe_group
* uprobe_derived_probes
;
288 utrace_derived_probe_group
* utrace_derived_probes
;
289 itrace_derived_probe_group
* itrace_derived_probes
;
290 task_finder_derived_probe_group
* task_finder_derived_probes
;
291 timer_derived_probe_group
* timer_derived_probes
;
292 profile_derived_probe_group
* profile_derived_probes
;
293 mark_derived_probe_group
* mark_derived_probes
;
294 tracepoint_derived_probe_group
* tracepoint_derived_probes
;
295 hrtimer_derived_probe_group
* hrtimer_derived_probes
;
296 procfs_derived_probe_group
* procfs_derived_probes
;
298 // NB: It is very important for all of the above (and below) fields
299 // to be cleared in the systemtap_session ctor (session.cxx).
302 translator_output
* op
;
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
;
311 // List of libdwfl module names to extract symbol/unwind data for.
312 std::set
<std::string
> unwindsym_modules
;
314 struct module_cache
* module_cache
;
316 // NB: It is very important for all of the above (and below) fields
317 // to be cleared in the systemtap_session ctor (session.cxx).
319 std::set
<std::string
> seen_errors
;
320 std::set
<std::string
> seen_warnings
;
321 unsigned num_errors () { return seen_errors
.size() + (panic_warnings
? seen_warnings
.size() : 0); }
323 std::set
<std::string
> rpms_to_install
;
325 // void print_error (const parse_error& e);
326 const token
* last_token
;
327 void print_token (std::ostream
& o
, const token
* tok
);
328 void print_error (const semantic_error
& e
);
329 void print_error_source (std::ostream
&, std::string
&, const token
* tok
);
330 void print_warning (const std::string
& w
, const token
* tok
= 0);
331 void printscript(std::ostream
& o
);
333 // NB: It is very important for all of the above (and below) fields
334 // to be cleared in the systemtap_session ctor (session.cxx).
338 // global counter of SIGINT/SIGTERM's received
339 extern int pending_interrupts
;
343 /* vim: set sw=2 ts=8 cino=>4,n-2,{2,^-2,t0,(0,u0,w1,M1 : */