]> sourceware.org Git - systemtap.git/blame - translate.h
Fixed systemtap-server.exp
[systemtap.git] / translate.h
CommitLineData
2b066ec1 1// -*- C++ -*-
faf38cd9 2// Copyright (C) 2005, 2009 Red Hat Inc.
69c68955
FCE
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.
2b066ec1
FCE
8
9#ifndef TRANSLATE_H
10#define TRANSLATE_H
11
12#include "staptree.h"
13#include "parse.h"
0386bbcf 14#include <string>
2b066ec1
FCE
15
16
17// ------------------------------------------------------------------------
18
60cf5fae 19#include "translator-output.h" // translator_output moved to separate file
2b066ec1
FCE
20
21// An unparser instance is in charge of emitting code for generic
22// probe bodies, functions, globals.
23struct 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;
2b066ec1
FCE
38 //
39 // struct context {
54dfabe9 40 // unsigned errorcount;
2b066ec1 41 // unsigned busy;
29fdb4e4 42 // ...
2b066ec1
FCE
43 // } context [MAXCONCURRENCY];
44
4a6d3dfa 45 // struct {
2b066ec1 46 virtual void emit_global (vardecl* v) = 0;
4a6d3dfa
FCE
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 // };
2b066ec1 52
bd268288
SM
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
16c1c808
FCE
61 // module_param_... -- at end of file
62
bd268288
SM
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
2b066ec1
FCE
67 virtual void emit_functionsig (functiondecl* v) = 0;
68 // static void function_NAME (context* c);
69
be66b6e1
DS
70 virtual void emit_kernel_module_init () = 0;
71 virtual void emit_kernel_module_exit () = 0;
72 // kernel module startup, shutdown
73
2b066ec1 74 virtual void emit_module_init () = 0;
a60923e9 75 virtual void emit_module_refresh () = 0;
2b066ec1 76 virtual void emit_module_exit () = 0;
a60923e9 77 // startup, probe refresh/activation, shutdown
2b066ec1
FCE
78
79 virtual void emit_function (functiondecl* v) = 0;
80 // void function_NAME (struct context* c) {
81 // ....
82 // }
83
c1d5f3f6 84 virtual void emit_probe (derived_probe* v) = 0;
2b066ec1
FCE
85 // void probe_NUMBER (struct context* c) {
86 // ... lifecycle
87 // ....
88 // }
89 // ... then call over to the derived_probe's emit_probe_entries() fn
0386bbcf
SM
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:
49b68a33 94 virtual std::string c_localname (const std::string& e, bool mangle_oldstyle = false) = 0;
0386bbcf
SM
95 virtual std::string c_globalname (const std::string &e) = 0;
96 virtual std::string c_funcname (const std::string &e) = 0;
2b066ec1
FCE
97};
98
99
d13bcfd8
JS
100// Preparation done before checking the script cache, especially
101// anything that might affect the hashed name.
102int prepare_translate_pass (systemtap_session& s);
103
2b066ec1
FCE
104int translate_pass (systemtap_session& s);
105
2b066ec1 106#endif // TRANSLATE_H
73267b89
JS
107
108/* vim: set sw=2 ts=8 cino=>4,n-2,{2,^-2,t0,(0,u0,w1,M1 : */
This page took 0.173664 seconds and 5 git commands to generate.