diff options
-rw-r--r-- | elaborate.cxx | 30 | ||||
-rw-r--r-- | parse.cxx | 13 | ||||
-rw-r--r-- | staptree.cxx | 66 | ||||
-rw-r--r-- | staptree.h | 14 | ||||
-rw-r--r-- | tapset-mark.cxx | 8 | ||||
-rw-r--r-- | tapset-utrace.cxx | 8 | ||||
-rw-r--r-- | tapsets.cxx | 17 |
7 files changed, 58 insertions, 98 deletions
diff --git a/elaborate.cxx b/elaborate.cxx index 1d7f1e0b..2446e4f8 100644 --- a/elaborate.cxx +++ b/elaborate.cxx @@ -1283,19 +1283,16 @@ void add_global_var_display (systemtap_session& s) if (tapset_global) continue; - print_format* pf = new print_format; - probe* p = new probe; - probe_point* pl = new probe_point; probe_point::component* c = new probe_point::component("end"); - token* print_tok = new token; + probe_point* pl = new probe_point; + pl->components.push_back (c); + vector<derived_probe*> dps; block *b = new block; - pl->components.push_back (c); + probe* p = new probe; p->tok = l->tok; p->locations.push_back (pl); - print_tok->type = tok_identifier; - print_tok->content = "printf"; // Create a symbol symbol* g_sym = new symbol; @@ -1304,13 +1301,12 @@ void add_global_var_display (systemtap_session& s) g_sym->type = l->type; g_sym->referent = l; - pf->print_to_stream = true; - pf->print_with_format = true; - pf->print_with_delim = false; - pf->print_with_newline = false; - pf->print_char = false; + token* print_tok = new token; + print_tok->type = tok_identifier; + print_tok->content = "printf"; + + print_format* pf = print_format::create(print_tok); pf->raw_components += l->name; - pf->tok = print_tok; if (l->index_types.size() == 0) // Scalar { @@ -1358,15 +1354,9 @@ void add_global_var_display (systemtap_session& s) be->right = new literal_number(0); /* Create printf @count=0x0 in else block */ - print_format* pf_0 = new print_format; - pf_0->print_to_stream = true; - pf_0->print_with_format = true; - pf_0->print_with_delim = false; - pf_0->print_with_newline = false; - pf_0->print_char = false; + print_format* pf_0 = print_format::create(print_tok); pf_0->raw_components += l->name; pf_0->raw_components += " @count=0x0\\n"; - pf_0->tok = print_tok; pf_0->components = print_format::string_to_components(pf_0->raw_components); expr_statement* feb_else = new expr_statement; feb_else->value = pf_0; @@ -2352,8 +2352,6 @@ parser::parse_symbol () // now scrutinize this identifier for the various magic forms of identifier // (printf, @stat_op, and $var...) - bool pf_stream, pf_format, pf_delim, pf_newline, pf_char; - if (name == "@cast") { // type-punning time @@ -2410,17 +2408,8 @@ parser::parse_symbol () return sop; } - else if (print_format::parse_print(name, - pf_stream, pf_format, pf_delim, pf_newline, pf_char)) + else if (print_format *fmt = print_format::create(t)) { - print_format *fmt = new print_format; - fmt->tok = t; - fmt->print_to_stream = pf_stream; - fmt->print_with_format = pf_format; - fmt->print_with_delim = pf_delim; - fmt->print_with_newline = pf_newline; - fmt->print_char = pf_char; - expect_op("("); if ((name == "print" || name == "println" || name == "sprint" || name == "sprintln") && diff --git a/staptree.cxx b/staptree.cxx index 090f0bd3..bc552454 100644 --- a/staptree.cxx +++ b/staptree.cxx @@ -405,52 +405,56 @@ void functioncall::print (ostream& o) const } -bool -print_format::parse_print(const std::string &name, - bool &stream, bool &format, bool &delim, bool &newline, bool &_char) +print_format* +print_format::create(const token *t) { - const char *n = name.c_str(); + bool stream, format, delim, newline, _char; + const char *n = t->content.c_str(); stream = true; format = delim = newline = _char = false; if (strcmp(n, "print_char") == 0) + _char = true; + else { - _char = true; - return true; - } - - if (*n == 's') - { - stream = false; - ++n; - } + if (*n == 's') + { + stream = false; + ++n; + } - if (0 != strncmp(n, "print", 5)) - return false; - n += 5; + if (0 != strncmp(n, "print", 5)) + return NULL; + n += 5; - if (*n == 'f') - { - format = true; - ++n; - } - else - { - if (*n == 'd') - { - delim = true; + if (*n == 'f') + { + format = true; ++n; } + else + { + if (*n == 'd') + { + delim = true; + ++n; + } - if (*n == 'l' && *(n+1) == 'n') - { - newline = true; - n += 2; + if (*n == 'l' && *(n+1) == 'n') + { + newline = true; + n += 2; + } } + + if (*n != '\0') + return NULL; } - return (*n == '\0'); + print_format *pf = new print_format(stream, format, delim, newline, _char); + pf->tok = t; + return pf; } @@ -373,10 +373,6 @@ struct print_format: public expression } }; - print_format() - : hist(NULL) - {} - std::string raw_components; std::vector<format_component> components; format_component delimiter; @@ -385,11 +381,17 @@ struct print_format: public expression static std::string components_to_string(std::vector<format_component> const & components); static std::vector<format_component> string_to_components(std::string const & str); - static bool parse_print(const std::string &name, bool &stream, - bool &format, bool &delim, bool &newline, bool &_char); + static print_format* create(const token *t); void print (std::ostream& o) const; void visit (visitor* u); + +private: + print_format(bool stream, bool format, bool delim, bool newline, bool _char): + print_to_stream(stream), print_with_format(format), + print_with_delim(delim), print_with_newline(newline), + print_char(_char), hist(NULL) + {} }; diff --git a/tapset-mark.cxx b/tapset-mark.cxx index b70098e3..fc9cb274 100644 --- a/tapset-mark.cxx +++ b/tapset-mark.cxx @@ -142,15 +142,9 @@ mark_var_expanding_visitor::visit_target_symbol_context (target_symbol* e) else if (e->base_name == "$$vars" || e->base_name == "$$parms") { //copy from tracepoint - print_format* pf = new print_format; token* pf_tok = new token(*e->tok); pf_tok->content = "sprintf"; - pf->tok = pf_tok; - pf->print_to_stream = false; - pf->print_with_format = true; - pf->print_with_delim = false; - pf->print_with_newline = false; - pf->print_char = false; + print_format* pf = print_format::create(pf_tok); for (unsigned i = 0; i < mark_args.size(); ++i) { diff --git a/tapset-utrace.cxx b/tapset-utrace.cxx index b731293c..abc9759f 100644 --- a/tapset-utrace.cxx +++ b/tapset-utrace.cxx @@ -448,15 +448,9 @@ utrace_var_expanding_visitor::visit_target_symbol_arg (target_symbol* e) if (e->base_name == "$$parms") { // copy from tracepoint - print_format* pf = new print_format; token* pf_tok = new token(*e->tok); pf_tok->content = "sprintf"; - pf->tok = pf_tok; - pf->print_to_stream = false; - pf->print_with_format = true; - pf->print_with_delim = false; - pf->print_with_newline = false; - pf->print_char = false; + print_format* pf = print_format::create(pf_tok); target_symbol_seen = true; diff --git a/tapsets.cxx b/tapsets.cxx index 5182bdd4..ba6f4ee4 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -2135,7 +2135,6 @@ dwarf_var_expanding_visitor::visit_target_symbol_context (target_symbol* e) return; target_symbol *tsym = new target_symbol; - print_format* pf = new print_format; // Convert $$parms to sprintf of a list of parms and active local vars // which we recursively evaluate @@ -2148,12 +2147,7 @@ dwarf_var_expanding_visitor::visit_target_symbol_context (target_symbol* e) pf_tok->type = tok_identifier; pf_tok->content = "sprint"; - pf->tok = pf_tok; - pf->print_to_stream = false; - pf->print_with_format = true; - pf->print_with_delim = false; - pf->print_with_newline = false; - pf->print_char = false; + print_format* pf = print_format::create(pf_tok); if (q.has_return && (e->base_name == "$$return")) { @@ -5618,8 +5612,6 @@ tracepoint_var_expanding_visitor::visit_target_symbol_context (target_symbol* e) } else if (e->base_name == "$$vars" || e->base_name == "$$parms") { - print_format* pf = new print_format; - // Convert $$vars to sprintf of a list of vars which we recursively evaluate // NB: we synthesize a new token here rather than reusing // e->tok, because print_format::print likes to use @@ -5627,12 +5619,7 @@ tracepoint_var_expanding_visitor::visit_target_symbol_context (target_symbol* e) token* pf_tok = new token(*e->tok); pf_tok->content = "sprintf"; - pf->tok = pf_tok; - pf->print_to_stream = false; - pf->print_with_format = true; - pf->print_with_delim = false; - pf->print_with_newline = false; - pf->print_char = false; + print_format* pf = print_format::create(pf_tok); for (unsigned i = 0; i < args.size(); ++i) { |