]> sourceware.org Git - systemtap.git/blob - translate.h
tracepoints: Work with the tracequery's .o rather than .ko
[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 <iostream>
15 #include <fstream>
16
17
18 // ------------------------------------------------------------------------
19
20 // Output context for systemtap translation, intended to allow
21 // pretty-printing.
22 class translator_output
23 {
24 char *buf;
25 std::ofstream* o2;
26 std::ostream& o;
27 unsigned tablevel;
28
29 public:
30 translator_output (std::ostream& file);
31 translator_output (const std::string& filename, size_t bufsize = 8192);
32 ~translator_output ();
33
34 std::ostream& newline (int indent = 0);
35 void indent (int indent = 0);
36 void assert_0_indent () { o << std::flush; assert (tablevel == 0); }
37 std::ostream& line();
38
39 std::ostream::pos_type tellp() { return o.tellp(); }
40 std::ostream& seekp(std::ostream::pos_type p) { return o.seekp(p); }
41 };
42
43
44 // An unparser instance is in charge of emitting code for generic
45 // probe bodies, functions, globals.
46 struct unparser
47 {
48 virtual ~unparser () {}
49
50 virtual void emit_common_header () = 0;
51 // #include<...>
52 //
53 // #define MAXNESTING nnn
54 // #define MAXCONCURRENCY mmm
55 // #define MAXSTRINGLEN ooo
56 //
57 // enum session_state_t {
58 // starting, begin, running, suspended, errored, ending, ended
59 // };
60 // static atomic_t session_state;
61 //
62 // struct context {
63 // unsigned errorcount;
64 // unsigned busy;
65 // ...
66 // } context [MAXCONCURRENCY];
67
68 // struct {
69 virtual void emit_global (vardecl* v) = 0;
70 // TYPE s_NAME; // NAME is prefixed with "s_" to avoid kernel id collisions
71 // rwlock_t s_NAME_lock;
72 // } global = {
73 virtual void emit_global_init (vardecl* v) = 0;
74 // };
75
76 virtual void emit_global_param (vardecl* v) = 0;
77 // module_param_... -- at end of file
78
79 virtual void emit_functionsig (functiondecl* v) = 0;
80 // static void function_NAME (context* c);
81
82 virtual void emit_module_init () = 0;
83 virtual void emit_module_refresh () = 0;
84 virtual void emit_module_exit () = 0;
85 // startup, probe refresh/activation, shutdown
86
87 virtual void emit_function (functiondecl* v) = 0;
88 // void function_NAME (struct context* c) {
89 // ....
90 // }
91
92 virtual void emit_probe (derived_probe* v) = 0;
93 // void probe_NUMBER (struct context* c) {
94 // ... lifecycle
95 // ....
96 // }
97 // ... then call over to the derived_probe's emit_probe_entries() fn
98 };
99
100
101 // Preparation done before checking the script cache, especially
102 // anything that might affect the hashed name.
103 int prepare_translate_pass (systemtap_session& s);
104
105 int translate_pass (systemtap_session& s);
106
107
108 #endif // TRANSLATE_H
109
110 /* vim: set sw=2 ts=8 cino=>4,n-2,{2,^-2,t0,(0,u0,w1,M1 : */
This page took 0.041244 seconds and 5 git commands to generate.