From f8220a7b945a3be7975fb2610ca1c79119594534 Mon Sep 17 00:00:00 2001 From: graydon Date: Wed, 13 Jul 2005 04:47:54 +0000 Subject: 2005-07-12 Graydon Hoare * 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. --- runtime/builtin_functions.h | 60 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 runtime/builtin_functions.h (limited to 'runtime/builtin_functions.h') diff --git a/runtime/builtin_functions.h b/runtime/builtin_functions.h new file mode 100644 index 00000000..13be00fb --- /dev/null +++ b/runtime/builtin_functions.h @@ -0,0 +1,60 @@ +#ifndef _BUILTIN_FUNCTIONS_ +#define _BUILTIN_FUNCTIONS_ + +/* Builtin function definitions. + * Copyright (C) 2005 Red Hat Inc. + * + * This file is part of systemtap, and is free software. You can + * redistribute it and/or modify it under the terms of the GNU General + * Public License (GPL); either version 2, or (at your option) any + * later version. + */ + +/* + * This file contains definitions for "builtin functions" which are + * registered in the systemtap translator, but given no definition. + * The translator emits calls to builtins exactly the same way it + * emits calls to functions written in the systemtap language; the + * only difference is that this file (or a C tapset) must supply the + * definition. + * + * Every builtin function "foo" called by a systemtap script is + * translated to a C call to a C function named "function_foo". This + * is the function you must provide in this file. In addition, the + * translator emits a + * + * #define _BUILTIN_FUNCTION_foo_ + * + * symbol for each such function called, which you can use to elide + * function definitions which are not used by a given systemtap + * script. + */ + +#ifdef _BUILTIN_FUNCTION_printk_ +static void +function_printk (struct context *c) +{ + printk (KERN_INFO, c->locals[c->nesting].function_printk.message); +} +#endif /* _BUILTIN_FUNCTION_printk_ */ + + +#ifdef _BUILTIN_FUNCTION_log_ +static void +function_log (struct context *c) +{ + _stp_log (c->locals[c->nesting].function_log.message); +} +#endif /* _BUILTIN_FUNCTION_log_ */ + + +#ifdef _BUILTIN_FUNCTION_warn_ +static void +function_warn (struct context *c) +{ + _stp_warn (c->locals[c->nesting].function_warn.message); +} +#endif /* _BUILTIN_FUNCTION_warn_ */ + + +#endif /* _BUILTIN_FUNCTIONS_ */ -- cgit