]> sourceware.org Git - systemtap.git/blob - session.h
Merge branch 'master' of git://sources.redhat.com/git/systemtap
[systemtap.git] / session.h
1 // -*- C++ -*-
2 // Copyright (C) 2005-2009 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 SESSION_H
10 #define SESSION_H
11
12 #include <string>
13 #include <vector>
14 #include <iostream>
15 #include <sstream>
16 #include <map>
17 #include <set>
18
19 extern "C" {
20 #include <elfutils/libdw.h>
21 }
22
23
24 // forward decls for all referenced systemtap types
25 struct match_node;
26 struct stapfile;
27 struct vardecl;
28 struct token;
29 struct functiondecl;
30 struct derived_probe;
31 struct be_derived_probe_group;
32 struct dwarf_derived_probe_group;
33 struct kprobe_derived_probe_group;
34 struct uprobe_derived_probe_group;
35 struct utrace_derived_probe_group;
36 struct itrace_derived_probe_group;
37 struct task_finder_derived_probe_group;
38 struct timer_derived_probe_group;
39 struct profile_derived_probe_group;
40 struct mark_derived_probe_group;
41 struct tracepoint_derived_probe_group;
42 struct hrtimer_derived_probe_group;
43 struct perfmon_derived_probe_group;
44 struct procfs_derived_probe_group;
45 struct embeddedcode;
46 struct translator_output;
47 struct unparser;
48 struct semantic_error;
49 struct module_cache;
50 struct update_visitor;
51
52
53 // XXX: a generalized form of this descriptor could be associated with
54 // a vardecl instead of out here at the systemtap_session level.
55 struct statistic_decl
56 {
57 statistic_decl()
58 : type(none),
59 linear_low(0), linear_high(0), linear_step(0)
60 {}
61 enum { none, linear, logarithmic } type;
62 int64_t linear_low;
63 int64_t linear_high;
64 int64_t linear_step;
65 bool operator==(statistic_decl const & other)
66 {
67 return type == other.type
68 && linear_low == other.linear_low
69 && linear_high == other.linear_high
70 && linear_step == other.linear_step;
71 }
72 };
73
74
75 struct systemtap_session
76 {
77 systemtap_session ();
78 // NB: It is very important for all of the above (and below) fields
79 // to be cleared in the systemtap_session ctor (elaborate.cxx)
80 // and/or main.cxx(main).
81
82 // command line args
83 std::vector<std::string> include_path;
84 std::vector<std::string> macros;
85 std::vector<std::string> args;
86 std::string kernel_release;
87 std::string kernel_base_release;
88 std::string kernel_build_tree;
89 std::string architecture;
90 std::string runtime_path;
91 std::string data_path;
92 std::string cert_db_path;
93 std::string module_name;
94 std::string stapconf_name;
95 std::string output_file;
96 std::string size_option;
97 std::string cmd;
98 int target_pid;
99 int last_pass;
100 unsigned perpass_verbose[5];
101 unsigned verbose;
102 bool timing;
103 bool keep_tmpdir;
104 bool guru_mode;
105 bool listing_mode;
106 bool bulk_mode;
107 bool unoptimized;
108 bool merge;
109 bool suppress_warnings;
110 int buffer_size;
111 unsigned perfmon;
112 bool symtab; /* true: emit symbol table at translation time; false: let staprun do it. */
113 bool prologue_searching;
114 bool tapset_compile_coverage;
115 bool need_uprobes;
116 bool load_only; // flight recorder mode
117 bool unprivileged;
118
119 // NB: It is very important for all of the above (and below) fields
120 // to be cleared in the systemtap_session ctor (elaborate.cxx)
121 // and/or main.cxx(main).
122
123 // Cache data
124 bool use_cache;
125 std::string cache_path;
126 std::string hash_path;
127 std::string stapconf_path;
128 std::string tracequery_path;
129
130 // dwarfless operation
131 bool consult_symtab;
132 std::string kernel_symtab_path;
133 bool ignore_vmlinux;
134 bool ignore_dwarf;
135
136 // Skip bad $ vars
137 bool skip_badvars;
138
139 // NB: It is very important for all of the above (and below) fields
140 // to be cleared in the systemtap_session ctor (elaborate.cxx)
141 // and/or main.cxx(main).
142
143 // temporary directory for module builds etc.
144 // hazardous - it is "rm -rf"'d at exit
145 std::string tmpdir;
146 std::string translated_source; // C source code
147
148 match_node* pattern_root;
149 void register_library_aliases();
150
151 // parse trees for the various script files
152 stapfile* user_file;
153 std::vector<stapfile*> library_files;
154
155 // filters to run over all code before symbol resolution
156 // e.g. @cast expansion
157 std::vector<update_visitor*> code_filters;
158
159 // resolved globals/functions/probes for the run as a whole
160 std::vector<stapfile*> files;
161 std::vector<vardecl*> globals;
162 std::map<std::string,functiondecl*> functions;
163 std::vector<derived_probe*> probes; // see also *_probes groups below
164 std::vector<embeddedcode*> embeds;
165 std::map<std::string, statistic_decl> stat_decls;
166 // track things that are removed
167 std::vector<vardecl*> unused_globals;
168 std::vector<derived_probe*> unused_probes; // see also *_probes groups below
169 std::vector<functiondecl*> unused_functions;
170 // XXX: vector<*> instead please?
171
172 // Every probe in these groups must also appear in the
173 // session.probes vector.
174 be_derived_probe_group* be_derived_probes;
175 dwarf_derived_probe_group* dwarf_derived_probes;
176 kprobe_derived_probe_group* kprobe_derived_probes;
177 uprobe_derived_probe_group* uprobe_derived_probes;
178 utrace_derived_probe_group* utrace_derived_probes;
179 itrace_derived_probe_group* itrace_derived_probes;
180 task_finder_derived_probe_group* task_finder_derived_probes;
181 timer_derived_probe_group* timer_derived_probes;
182 profile_derived_probe_group* profile_derived_probes;
183 mark_derived_probe_group* mark_derived_probes;
184 tracepoint_derived_probe_group* tracepoint_derived_probes;
185 hrtimer_derived_probe_group* hrtimer_derived_probes;
186 perfmon_derived_probe_group* perfmon_derived_probes;
187 procfs_derived_probe_group* procfs_derived_probes;
188
189 // NB: It is very important for all of the above (and below) fields
190 // to be cleared in the systemtap_session ctor (elaborate.cxx)
191 // and/or main.cxx(main).
192
193 // unparser data
194 translator_output* op;
195 unparser* up;
196
197 // some symbol addresses
198 // XXX: these belong elsewhere; perhaps the dwflpp instance
199 Dwarf_Addr sym_kprobes_text_start;
200 Dwarf_Addr sym_kprobes_text_end;
201 Dwarf_Addr sym_stext;
202
203 // List of libdwfl module names to extract symbol/unwind data for.
204 std::set<std::string> unwindsym_modules;
205 struct module_cache* module_cache;
206
207 // NB: It is very important for all of the above (and below) fields
208 // to be cleared in the systemtap_session ctor (elaborate.cxx)
209 // and/or main.cxx(main).
210
211 std::set<std::string> seen_errors;
212 std::set<std::string> seen_warnings;
213 unsigned num_errors () { return seen_errors.size(); }
214
215 // void print_error (const parse_error& e);
216 const token* last_token;
217 void print_token (std::ostream& o, const token* tok);
218 void print_error (const semantic_error& e);
219 void print_error_source (std::ostream&, std::string&, const token* tok);
220 void print_warning (const std::string& w, const token* tok = 0);
221
222 // NB: It is very important for all of the above (and below) fields
223 // to be cleared in the systemtap_session ctor (elaborate.cxx)
224 // and/or main.cxx(main).
225 };
226
227
228 // global counter of SIGINT/SIGTERM's received
229 extern int pending_interrupts;
230
231 #endif // SESSION_H
232
233 /* vim: set sw=2 ts=8 cino=>4,n-2,{2,^-2,t0,(0,u0,w1,M1 : */
This page took 0.04519 seconds and 5 git commands to generate.