summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhunt <hunt>2005-07-28 18:46:16 +0000
committerhunt <hunt>2005-07-28 18:46:16 +0000
commit1c2aeef9fee160bf4d6ec9fe6d4cc8d31788f0df (patch)
tree334ea79b84fb84423b0521c8d0d7a8f99d8a4e2b
parent2445f52e036c87eea6471167cb8b89fb492e2eae (diff)
downloadsystemtap-steved-1c2aeef9fee160bf4d6ec9fe6d4cc8d31788f0df.tar.gz
systemtap-steved-1c2aeef9fee160bf4d6ec9fe6d4cc8d31788f0df.tar.xz
systemtap-steved-1c2aeef9fee160bf4d6ec9fe6d4cc8d31788f0df.zip
Add io.c
-rw-r--r--runtime/user/emul.h2
-rw-r--r--runtime/user/io.c79
-rw-r--r--runtime/user/print.c1
3 files changed, 81 insertions, 1 deletions
diff --git a/runtime/user/emul.h b/runtime/user/emul.h
index b1cc1478..4b029b39 100644
--- a/runtime/user/emul.h
+++ b/runtime/user/emul.h
@@ -9,7 +9,7 @@ int vscnprintf(char *buf, size_t size, const char *fmt, va_list args)
return (i >= size) ? (size - 1) : i;
}
-#define _stp_log printf
+//#define _stp_log printf
/* cpu emulation */
#undef smp_processor_id
diff --git a/runtime/user/io.c b/runtime/user/io.c
new file mode 100644
index 00000000..2da0de82
--- /dev/null
+++ b/runtime/user/io.c
@@ -0,0 +1,79 @@
+/* I/O for printing warnings, errors and debug messages
+ * Copyright (C) 2005 Red Hat Inc.
+ *
+ * This file is part of systemtap, and is free software. You can
+ * redistribute it and/or modify it under the terms of the GNU General
+ * Public License (GPL); either version 2, or (at your option) any
+ * later version.
+ */
+
+#ifndef _IO_C_
+#define _IO_C_
+
+/** Logs Data.
+ * This function sends the message immediately to stpd. It
+ * will also be sent over the bulk transport (relayfs) if it is
+ * being used. If the last character is not a newline, then one
+ * is added. This function is not as efficient as _stp_printf()
+ * and should only be used for urgent messages. You probably want
+ * dbug(), or _stp_warn().
+ * @param fmt A variable number of args.
+ * @todo Evaluate if this function is necessary.
+ */
+void _stp_log (const char *fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ vprintf (fmt, args);
+ va_end(args);
+}
+
+/** Prints warning.
+ * This function sends a warning message immediately to stpd. It
+ * will also be sent over the bulk transport (relayfs) if it is
+ * being used. If the last character is not a newline, then one
+ * is added.
+ * @param fmt A variable number of args.
+ */
+void _stp_warn (const char *fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ vprintf (fmt, args);
+ va_end(args);
+}
+
+/** Exits and unloads the module.
+ * This function sends a signal to stpd to tell it to
+ * unload the module and exit. The module will not be
+ * unloaded until after the current probe returns.
+ * @note Be careful to not treat this like the Linux exit()
+ * call. You should probably call return immediately after
+ * calling _stp_exit().
+ */
+void _stp_exit (void)
+{
+ exit (-1);
+}
+
+/** Prints error message and exits.
+ * This function sends an error message immediately to stpd. It
+ * will also be sent over the bulk transport (relayfs) if it is
+ * being used. If the last character is not a newline, then one
+ * is added.
+ *
+ * After the error message is displayed, the module will be unloaded.
+ * @param fmt A variable number of args.
+ * @sa _stp_exit().
+ */
+void _stp_error (const char *fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ vprintf (fmt, args);
+ va_end(args);
+ _stp_exit();
+}
+
+/** @} */
+#endif /* _IO_C_ */
diff --git a/runtime/user/print.c b/runtime/user/print.c
index ac0b7c49..dddb3d7e 100644
--- a/runtime/user/print.c
+++ b/runtime/user/print.c
@@ -23,6 +23,7 @@
#endif
#include "string.h"
+#include "io.c"
static int _stp_pbuf_len[NR_CPUS];