]> sourceware.org Git - systemtap.git/blob - translate.h
Fixed PR18577 by making 'stap -l **' faster.
[systemtap.git] / translate.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 TRANSLATE_H
10 #define TRANSLATE_H
11
12 #include "staptree.h"
13 #include "parse.h"
14 #include <string>
15
16
17 // ------------------------------------------------------------------------
18
19 #include "translator-output.h" // translator_output moved to separate file
20
21 // An unparser instance is in charge of emitting code for generic
22 // probe bodies, functions, globals.
23 struct unparser
24 {
25 virtual ~unparser () {}
26
27 virtual void emit_common_header () = 0;
28 // #include<...>
29 //
30 // #define MAXNESTING nnn
31 // #define MAXCONCURRENCY mmm
32 // #define MAXSTRINGLEN ooo
33 //
34 // enum session_state_t {
35 // starting, begin, running, suspended, errored, ending, ended
36 // };
37 // static atomic_t session_state;
38 //
39 // struct context {
40 // unsigned errorcount;
41 // unsigned busy;
42 // ...
43 // } context [MAXCONCURRENCY];
44
45 // struct {
46 virtual void emit_global (vardecl* v) = 0;
47 // TYPE s_NAME; // NAME is prefixed with "s_" to avoid kernel id collisions
48 // rwlock_t s_NAME_lock;
49 // } global = {
50 virtual void emit_global_init (vardecl* v) = 0;
51 // };
52
53 // struct {
54 virtual void emit_global_init_type (vardecl* v) = 0;
55 // TYPE s_NAME;
56 // } global_init = {
57 // ...
58 // }; // variation of the above for dyninst static-initialization
59
60 virtual void emit_global_param (vardecl* v) = 0; // for kernel
61 // module_param_... -- at end of file
62
63 virtual void emit_global_init_setters () = 0; // for dyninst
64 // int stp_global_setter (const char *name, const char *value);
65 // -- at end of file; returns -EINVAL on error
66
67 virtual void emit_functionsig (functiondecl* v) = 0;
68 // static void function_NAME (context* c);
69
70 virtual void emit_kernel_module_init () = 0;
71 virtual void emit_kernel_module_exit () = 0;
72 // kernel module startup, shutdown
73
74 virtual void emit_module_init () = 0;
75 virtual void emit_module_refresh () = 0;
76 virtual void emit_module_exit () = 0;
77 // startup, probe refresh/activation, shutdown
78
79 virtual void emit_function (functiondecl* v) = 0;
80 // void function_NAME (struct context* c) {
81 // ....
82 // }
83
84 virtual void emit_probe (derived_probe* v) = 0;
85 // void probe_NUMBER (struct context* c) {
86 // ... lifecycle
87 // ....
88 // }
89 // ... then call over to the derived_probe's emit_probe_entries() fn
90
91 // The following helper functions must be used by any code-generation
92 // infrastructure outside this file to properly mangle identifiers
93 // appearing in the final code:
94 virtual std::string c_localname (const std::string& e, bool mangle_oldstyle = false) = 0;
95 virtual std::string c_globalname (const std::string &e) = 0;
96 virtual std::string c_funcname (const std::string &e) = 0;
97 };
98
99
100 // Preparation done before checking the script cache, especially
101 // anything that might affect the hashed name.
102 int prepare_translate_pass (systemtap_session& s);
103
104 int translate_pass (systemtap_session& s);
105
106 #endif // TRANSLATE_H
107
108 /* vim: set sw=2 ts=8 cino=>4,n-2,{2,^-2,t0,(0,u0,w1,M1 : */
This page took 0.039673 seconds and 5 git commands to generate.