1 : // -*- C++ -*-
2 : // Copyright (C) 2005-2007 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 functiondecl;
29 : struct derived_probe;
30 : struct be_derived_probe_group;
31 : struct dwarf_derived_probe_group;
32 : struct uprobe_derived_probe_group;
33 : struct timer_derived_probe_group;
34 : struct profile_derived_probe_group;
35 : struct mark_derived_probe_group;
36 : struct hrtimer_derived_probe_group;
37 : struct perfmon_derived_probe_group;
38 : struct procfs_derived_probe_group;
39 : struct embeddedcode;
40 : struct translator_output;
41 : struct unparser;
42 : struct semantic_error;
43 :
44 :
45 : // XXX: a generalized form of this descriptor could be associated with
46 : // a vardecl instead of out here at the systemtap_session level.
47 : struct statistic_decl
48 : {
49 90608 : statistic_decl()
50 : : type(none),
51 90608 : linear_low(0), linear_high(0), linear_step(0)
52 90608 : {}
53 : enum { none, linear, logarithmic } type;
54 : int64_t linear_low;
55 : int64_t linear_high;
56 : int64_t linear_step;
57 112 : bool operator==(statistic_decl const & other)
58 : {
59 : return type == other.type
60 : && linear_low == other.linear_low
61 : && linear_high == other.linear_high
62 112 : && linear_step == other.linear_step;
63 : }
64 : };
65 :
66 :
67 : struct systemtap_session
68 1082 : {
69 : systemtap_session ();
70 : // NB: new POD members likely need to be explicitly cleared in the ctor.
71 : // See elaborate.cxx.
72 :
73 : // command line args
74 : std::vector<std::string> include_path;
75 : std::vector<std::string> macros;
76 : std::vector<std::string> args;
77 : std::string kernel_release;
78 : std::string kernel_base_release;
79 : std::string architecture;
80 : std::string runtime_path;
81 : std::string data_path;
82 : std::string module_name;
83 : std::string output_file;
84 : std::string cmd;
85 : int target_pid;
86 : int last_pass;
87 : unsigned verbose;
88 : bool timing;
89 : bool keep_tmpdir;
90 : bool guru_mode;
91 : bool bulk_mode;
92 : bool unoptimized;
93 : bool merge;
94 : bool suppress_warnings;
95 : int buffer_size;
96 : unsigned perfmon;
97 : bool symtab; /* true: emit symbol table at translation time; false: let staprun do it. */
98 : bool prologue_searching;
99 : bool tapset_compile_coverage;
100 : bool need_uprobes;
101 :
102 : // Cache data
103 : bool use_cache;
104 : std::string cache_path;
105 : std::string hash_path;
106 :
107 : // temporary directory for module builds etc.
108 : // hazardous - it is "rm -rf"'d at exit
109 : std::string tmpdir;
110 : std::string translated_source; // C source code
111 :
112 : match_node* pattern_root;
113 : void register_library_aliases();
114 :
115 : // parse trees for the various script files
116 : stapfile* user_file;
117 : std::vector<stapfile*> library_files;
118 :
119 : // resolved globals/functions/probes for the run as a whole
120 : std::vector<stapfile*> files;
121 : std::vector<vardecl*> globals;
122 : std::vector<functiondecl*> functions;
123 : std::vector<derived_probe*> probes; // see also *_probes groups below
124 : std::vector<embeddedcode*> embeds;
125 : std::map<std::string, statistic_decl> stat_decls;
126 : // track things that are removed
127 : std::vector<vardecl*> unused_globals;
128 : std::vector<derived_probe*> unused_probes; // see also *_probes groups below
129 : std::vector<functiondecl*> unused_functions;
130 : // XXX: vector<*> instead please?
131 :
132 : // Every probe in these groups must also appear in the
133 : // session.probes vector.
134 : be_derived_probe_group* be_derived_probes;
135 : dwarf_derived_probe_group* dwarf_derived_probes;
136 : uprobe_derived_probe_group* uprobe_derived_probes;
137 : timer_derived_probe_group* timer_derived_probes;
138 : profile_derived_probe_group* profile_derived_probes;
139 : mark_derived_probe_group* mark_derived_probes;
140 : hrtimer_derived_probe_group* hrtimer_derived_probes;
141 : perfmon_derived_probe_group* perfmon_derived_probes;
142 : procfs_derived_probe_group* procfs_derived_probes;
143 :
144 : // unparser data
145 : translator_output* op;
146 : unparser* up;
147 :
148 : // some symbol addresses
149 : // XXX: these belong elsewhere; perhaps the dwflpp instance
150 : Dwarf_Addr sym_kprobes_text_start;
151 : Dwarf_Addr sym_kprobes_text_end;
152 : Dwarf_Addr sym_stext;
153 :
154 : std::set<std::string> seen_errors;
155 2433 : unsigned num_errors () { return seen_errors.size(); }
156 : // void print_error (const parse_error& e);
157 : void print_error (const semantic_error& e);
158 :
159 : // reNB: new POD members likely need to be explicitly cleared in the ctor.
160 : };
161 :
162 :
163 : // global counter of SIGINT/SIGTERM's received
164 : extern int pending_interrupts;
165 :
166 : #endif // SESSION_H
|