summaryrefslogtreecommitdiffstats
path: root/translate.h
diff options
context:
space:
mode:
authorfche <fche>2005-05-21 01:35:34 +0000
committerfche <fche>2005-05-21 01:35:34 +0000
commit2b066ec1b8801b08052a68282ce34ef9c425ae8f (patch)
treed0b8aadc2521e2fbf1adde2d330bd7a941587087 /translate.h
parenta199030a268b007580b57a83b511f97bbb65996f (diff)
downloadsystemtap-steved-2b066ec1b8801b08052a68282ce34ef9c425ae8f.tar.gz
systemtap-steved-2b066ec1b8801b08052a68282ce34ef9c425ae8f.tar.xz
systemtap-steved-2b066ec1b8801b08052a68282ce34ef9c425ae8f.zip
* at long last, a more full-bodied snapshot
2005-05-20 Frank Ch. Eigler <fche@redhat.com> Many changes throughout. Partial sketch of translation output. * elaborate.*: Elaboration pass. * translate.*: Translation pass. * staptree.*: Simplified for visitor concept. * main.cxx: Translator mainline. * *test.cxx: Removed. * testsuite/*: Some new tests, some changed for newer syntax.
Diffstat (limited to 'translate.h')
-rw-r--r--translate.h93
1 files changed, 93 insertions, 0 deletions
diff --git a/translate.h b/translate.h
new file mode 100644
index 00000000..f0bd973c
--- /dev/null
+++ b/translate.h
@@ -0,0 +1,93 @@
+// -*- C++ -*-
+// Copyright 2005 Red Hat Inc.
+// GPL
+
+
+#ifndef TRANSLATE_H
+#define TRANSLATE_H
+
+#include "staptree.h"
+#include "parse.h"
+#include <iostream>
+#include <fstream>
+
+
+// ------------------------------------------------------------------------
+
+// Output context for systemtap translation, intended to allow
+// pretty-printing.
+class translator_output
+{
+ std::ofstream* o2;
+ std::ostream& o;
+ unsigned tablevel;
+
+public:
+ translator_output (std::ostream& file);
+ translator_output (const std::string& filename);
+ ~translator_output ();
+
+ std::ostream& newline (int indent = 0);
+ void indent (int indent = 0);
+ std::ostream& line();
+};
+
+
+// An unparser instance is in charge of emitting code for generic
+// probe bodies, functions, globals.
+struct unparser
+{
+ virtual ~unparser () {}
+
+ virtual void emit_common_header () = 0;
+ // #include<...>
+ //
+ // #define MAXNESTING nnn
+ // #define MAXCONCURRENCY mmm
+ // #define MAXSTRINGLEN ooo
+ //
+ // enum session_state_t {
+ // starting, begin, running, suspended, errored, ending, ended
+ // };
+ // static atomic_t session_state;
+ // static atomic_t errorcount; /* subcategorize? */
+ //
+ // struct context {
+ // unsigned busy;
+ // unsigned actioncount;
+ // unsigned nesting;
+ // union {
+ // struct { .... } probe_NUM_locals;
+ // struct { .... } function_NAME_locals;
+ // } locals [MAXNESTING];
+ // } context [MAXCONCURRENCY];
+
+ virtual void emit_global (vardecl* v) = 0;
+ // static TYPE global_NAME;
+ // static DEFINE_RWLOCK(global_NAME_lock);
+
+ virtual void emit_functionsig (functiondecl* v) = 0;
+ // static void function_NAME (context* c);
+
+ virtual void emit_module_init () = 0;
+ virtual void emit_module_exit () = 0;
+ // XXX
+
+ virtual void emit_function (functiondecl* v) = 0;
+ // void function_NAME (struct context* c) {
+ // ....
+ // }
+
+ virtual void emit_probe (derived_probe* v, unsigned i) = 0;
+ // void probe_NUMBER (struct context* c) {
+ // ... lifecycle
+ // ....
+ // }
+ // ... then call over to the derived_probe's emit_probe_entries() fn
+};
+
+
+int translate_pass (systemtap_session& s);
+
+
+#endif // TRANSLATE_H