diff options
author | graydon <graydon> | 2005-07-13 04:47:54 +0000 |
---|---|---|
committer | graydon <graydon> | 2005-07-13 04:47:54 +0000 |
commit | f8220a7b945a3be7975fb2610ca1c79119594534 (patch) | |
tree | d733adba9033184c8250971ce096e51b3dade156 /tapsets.cxx | |
parent | 6f0257ecf703373555ef06044cc25c8083859616 (diff) | |
download | systemtap-steved-f8220a7b945a3be7975fb2610ca1c79119594534.tar.gz systemtap-steved-f8220a7b945a3be7975fb2610ca1c79119594534.tar.xz systemtap-steved-f8220a7b945a3be7975fb2610ca1c79119594534.zip |
2005-07-12 Graydon Hoare <graydon@redhat.com>
* elaborate.cxx
(semantic_pass_symbols): Only enter body if non-null.
(semantic_pass_types): Likewise.
(semantic_pass): Pass session to register_standard_tapsets.
* translate.cxx
(builtin_collector): New struct.
(hookup_builtins): New function.
(translate_pass): Only translate functions with bodies.
(c_unparser::emit_common_header): Likewise, and call hookup_builtins.
* tapsets.hh (builtin_function): New class.
(register_standard_tapsets): Change parameter to session.
* tapsets.cc (bultin_function::*): Implement class.
(register_standard_tapsets): Register printk, log, warn.
* testsuite/transok/six.stp: New test.
Diffstat (limited to 'tapsets.cxx')
-rw-r--r-- | tapsets.cxx | 57 |
1 files changed, 53 insertions, 4 deletions
diff --git a/tapsets.cxx b/tapsets.cxx index 3dbbfa81..97c538ee 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -1166,19 +1166,68 @@ dwarf_builder::build(systemtap_session & sess, #endif /* HAVE_ELFUTILS_LIBDWFL_H */ +// ------------------------------------------------------------------------ +// Built-in function support class +// ------------------------------------------------------------------------ + +token * +builtin_function::id(string const & name) +{ + token *t = new token; + t->type = tok_identifier; + t->content = name; + t->location.file = "<builtin>"; + return t; +} + +builtin_function::builtin_function(exp_type ty, string const & name) +{ + f = new functiondecl; + f->tok = id(name); + f->name = name; + f->type = ty; + f->body = NULL; +} + +builtin_function & +builtin_function::arg(exp_type e, string const & name) +{ + vardecl *arg = new vardecl; + arg->name = name; + arg->tok = id(name); + arg->type = e; + f->formal_args.push_back(arg); + return *this; +} + +void +builtin_function::bind(systemtap_session & s) +{ + for (unsigned i = 0; i < s.functions.size(); ++i) + { + if (s.functions[i]->name == f->name) + throw semantic_error("builtin function " + f->name + " registered twice"); + } + s.functions.push_back(f); +} // ------------------------------------------------------------------------ // Standard tapset registry. // ------------------------------------------------------------------------ void -register_standard_tapsets(match_node * root) +register_standard_tapsets(systemtap_session & s) { // Rudimentary binders for begin and end targets - root->bind("begin")->bind(new be_builder(true)); - root->bind("end")->bind(new be_builder(false)); + s.pattern_root->bind("begin")->bind(new be_builder(true)); + s.pattern_root->bind("end")->bind(new be_builder(false)); #ifdef HAVE_ELFUTILS_LIBDWFL_H - dwarf_derived_probe::register_patterns(root); + dwarf_derived_probe::register_patterns(s.pattern_root); #endif /* HAVE_ELFUTILS_LIBDWFL_H */ + + // Some standard builtins + builtin_function(pe_long, "printk").arg(pe_string, "message").bind(s); + builtin_function(pe_long, "log").arg(pe_string, "message").bind(s); + builtin_function(pe_long, "warn").arg(pe_string, "message").bind(s); } |