summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfche <fche>2005-08-11 16:53:45 +0000
committerfche <fche>2005-08-11 16:53:45 +0000
commit0d155048397c88db09a25989450568e25af8f44c (patch)
tree3fe59a1997c04f4e46839d9b687520fd6419fc82
parent59ff27737b1c61f995ec5975f947d9a51c5667ad (diff)
downloadsystemtap-steved-0d155048397c88db09a25989450568e25af8f44c.tar.gz
systemtap-steved-0d155048397c88db09a25989450568e25af8f44c.tar.xz
systemtap-steved-0d155048397c88db09a25989450568e25af8f44c.zip
2005-08-11 Frank Ch. Eigler <fche@elastic.org>
* translate.cxx (emit_function): Add an extra { } around the function body visitation. * tapset/timestamp_functions.stp: New file. * tapset/builtin_conversions.stp: Aggregated from [hex]string. * tapset/builtin_logging.stp: Aggregated from log/warn/printk.
-rw-r--r--ChangeLog8
-rw-r--r--tapset/builtin_conversions.stp14
-rw-r--r--tapset/builtin_hexstring.stp7
-rw-r--r--tapset/builtin_log.stp7
-rw-r--r--tapset/builtin_logging.stp21
-rw-r--r--tapset/builtin_printk.stp7
-rw-r--r--tapset/builtin_string.stp7
-rw-r--r--tapset/builtin_warn.stp7
-rw-r--r--tapset/timestamp_functions.stp19
-rw-r--r--translate.cxx3
10 files changed, 65 insertions, 35 deletions
diff --git a/ChangeLog b/ChangeLog
index a01ea51e..ceb87964 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2005-08-11 Frank Ch. Eigler <fche@elastic.org>
+ * translate.cxx (emit_function): Add an extra { } around the
+ function body visitation.
+ * tapset/timestamp_functions.stp: New file.
+ * tapset/builtin_conversions.stp: Aggregated from [hex]string.
+ * tapset/builtin_logging.stp: Aggregated from log/warn/printk.
+
+2005-08-11 Frank Ch. Eigler <fche@elastic.org>
+
* tapsets.cxx: Tweak hex/decimal printing for consistency.
(emit_registrations): Remove module-specific code, anticipating
that libelf gives us run-time addresses already.
diff --git a/tapset/builtin_conversions.stp b/tapset/builtin_conversions.stp
new file mode 100644
index 00000000..5c0230d4
--- /dev/null
+++ b/tapset/builtin_conversions.stp
@@ -0,0 +1,14 @@
+function _hexstring (num) %{
+ sprintf (THIS->__retvalue, "0x%llx", (long long) THIS->num);
+%}
+
+function hexstring (num) {
+ return "" . _hexstring (num + 0)
+}
+function _string (num) %{
+ sprintf (THIS->__retvalue, "%lld", (long long) THIS->num);
+%}
+
+function string (num) {
+ return "" . _string (num + 0)
+}
diff --git a/tapset/builtin_hexstring.stp b/tapset/builtin_hexstring.stp
deleted file mode 100644
index c441bbc4..00000000
--- a/tapset/builtin_hexstring.stp
+++ /dev/null
@@ -1,7 +0,0 @@
-function _hexstring (num) %{
- sprintf (THIS->__retvalue, "%llx", (long long) THIS->num);
-%}
-
-function hexstring (num) {
- return "" . _hexstring (num + 0)
-}
diff --git a/tapset/builtin_log.stp b/tapset/builtin_log.stp
deleted file mode 100644
index 3d1a0aaf..00000000
--- a/tapset/builtin_log.stp
+++ /dev/null
@@ -1,7 +0,0 @@
-function _log (msg) %{
- _stp_log (THIS->msg);
-%}
-
-function log (msg) {
- _log (msg . "")
-}
diff --git a/tapset/builtin_logging.stp b/tapset/builtin_logging.stp
new file mode 100644
index 00000000..51fb97e4
--- /dev/null
+++ b/tapset/builtin_logging.stp
@@ -0,0 +1,21 @@
+function _log (msg) %{
+ _stp_log (THIS->msg);
+%}
+
+function log (msg) {
+ _log (msg . "")
+}
+function _printk (msg) %{
+ printk (KERN_INFO "%s\n", THIS->msg);
+%}
+
+function printk (msg) {
+ _printk (msg . "")
+}
+function _warn (msg) %{
+ _stp_warn (THIS->msg);
+%}
+
+function warn (msg) {
+ _warn (msg . "")
+}
diff --git a/tapset/builtin_printk.stp b/tapset/builtin_printk.stp
deleted file mode 100644
index 81826849..00000000
--- a/tapset/builtin_printk.stp
+++ /dev/null
@@ -1,7 +0,0 @@
-function _printk (msg) %{
- printk (KERN_INFO "%s\n", THIS->msg);
-%}
-
-function printk (msg) {
- _printk (msg . "")
-}
diff --git a/tapset/builtin_string.stp b/tapset/builtin_string.stp
deleted file mode 100644
index d068febb..00000000
--- a/tapset/builtin_string.stp
+++ /dev/null
@@ -1,7 +0,0 @@
-function _string (num) %{
- sprintf (THIS->__retvalue, "%lld", (long long) THIS->num);
-%}
-
-function string (num) {
- return "" . _string (num + 0)
-}
diff --git a/tapset/builtin_warn.stp b/tapset/builtin_warn.stp
deleted file mode 100644
index 97289ee0..00000000
--- a/tapset/builtin_warn.stp
+++ /dev/null
@@ -1,7 +0,0 @@
-function _warn (msg) %{
- _stp_warn (THIS->msg);
-%}
-
-function warn (msg) {
- _warn (msg . "")
-}
diff --git a/tapset/timestamp_functions.stp b/tapset/timestamp_functions.stp
new file mode 100644
index 00000000..f8e1ea4e
--- /dev/null
+++ b/tapset/timestamp_functions.stp
@@ -0,0 +1,19 @@
+%{
+#include <linux/time.h>
+%}
+
+// return in milliseconds since epoch
+function gettimeofday_ms () %{
+ struct timeval tm;
+ do_gettimeofday (& tm);
+ THIS->__retvalue = (tm.tv_sec * 1000) + (tm.tv_usec / 1000);
+%}
+
+// return in seconds since epoch
+function gettimeofday_s () %{
+ struct timeval tm;
+ do_gettimeofday (& tm);
+ THIS->__retvalue = tm.tv_sec;
+%}
+
+// likewise jiffies, monotonic_clock ...
diff --git a/translate.cxx b/translate.cxx
index 8806e502..b2a44563 100644
--- a/translate.cxx
+++ b/translate.cxx
@@ -771,7 +771,10 @@ c_unparser::emit_function (functiondecl* v)
o->newline() << retvalue.init();
}
+ o->newline(1) << "{"; // in case body is embeddedcode with decls
v->body->visit (this);
+ o->newline(-1) << "}";
+
this->current_function = 0;
o->newline(-1) << "out:";