summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'runtime')
-rw-r--r--runtime/user/README2
-rw-r--r--runtime/user/emul.h49
-rw-r--r--runtime/user/print.c31
-rwxr-xr-xruntime/user/recreate_links8
-rw-r--r--runtime/user/runtime.h9
5 files changed, 97 insertions, 2 deletions
diff --git a/runtime/user/README b/runtime/user/README
index fcbad004..b5f8f81a 100644
--- a/runtime/user/README
+++ b/runtime/user/README
@@ -1 +1,3 @@
These files are for user-space testing of SystemTap code.
+
+You need to run ./recreate_links here before running tests.
diff --git a/runtime/user/emul.h b/runtime/user/emul.h
index 3086a666..b1cc1478 100644
--- a/runtime/user/emul.h
+++ b/runtime/user/emul.h
@@ -1,3 +1,6 @@
+#define kmalloc(size,flags) malloc(size)
+
+#define kfree(ptr) free(ptr)
int vscnprintf(char *buf, size_t size, const char *fmt, va_list args)
{
@@ -8,8 +11,52 @@ int vscnprintf(char *buf, size_t size, const char *fmt, va_list args)
#define _stp_log printf
+/* cpu emulation */
#undef smp_processor_id
-#define smp_processor_id(x) 0
+#undef get_cpu
+#undef put_cpu
+#undef for_each_cpu
+#define for_each_cpu(cpu) \
+ for (cpu = 0; cpu < NR_CPUS; cpu++)
+
+int _processor_number = 0;
+#define smp_processor_id() _processor_number
+#define get_cpu() _processor_number
+#define put_cpu() ;
+
+#include "alloc.c"
+void *__alloc_percpu(size_t size, size_t align)
+{
+ int i;
+ struct percpu_data *pdata = malloc(sizeof (*pdata));
+
+ if (!pdata)
+ return NULL;
+
+ for (i = 0; i < NR_CPUS; i++) {
+ pdata->ptrs[i] = malloc(size);
+
+ if (!pdata->ptrs[i])
+ return NULL;
+
+ memset(pdata->ptrs[i], 0, size);
+ }
+
+ /* Catch derefs w/o wrappers */
+ return (void *) (~(unsigned long) pdata);
+}
+
+void
+free_percpu(const void *objp)
+{
+ int i;
+ struct percpu_data *p = (struct percpu_data *) (~(unsigned long) objp);
+
+ for (i = 0; i < NR_CPUS; i++) {
+ free(p->ptrs[i]);
+ }
+ free(p);
+}
#include <stdarg.h>
unsigned long strtoul(const char *nptr, char **endptr, int base);
diff --git a/runtime/user/print.c b/runtime/user/print.c
index 45c76f5a..ac0b7c49 100644
--- a/runtime/user/print.c
+++ b/runtime/user/print.c
@@ -22,6 +22,8 @@
#define STP_PRINT_BUF_LEN 8000
#endif
+#include "string.h"
+
static int _stp_pbuf_len[NR_CPUS];
#define STP_PRINT_BUF_START 0
@@ -50,6 +52,35 @@ void _stp_print_flush (void)
* @sa _stp_print_cstr _stp_print_string
*/
+
+/* Print stuff until a format specification is found. */
+/* Return pointer to that. */
+static char *next_fmt(char *fmt, int *num)
+{
+ char *f = fmt;
+ int in_fmt = 0;
+ dbug ("next_fmt %s\n", fmt);
+ *num = 0;
+ while (*f) {
+ if (in_fmt) {
+ if (*f == '%') {
+ _stp_string_cat_char(_stp_stdout,'%');
+ in_fmt = 0;
+ } else if (*f > '0' && *f <= '9') {
+ *num = *f - '0';
+ f++;
+ return f;
+ } else
+ return f;
+ } else if (*f == '%')
+ in_fmt = 1;
+ else
+ _stp_string_cat_char(_stp_stdout,*f);
+ f++;
+ }
+ return f;
+}
+
#define _stp_print(str) \
({ \
if (__builtin_types_compatible_p (typeof (str), char[])) { \
diff --git a/runtime/user/recreate_links b/runtime/user/recreate_links
index 7b2f58d7..c29c8e18 100755
--- a/runtime/user/recreate_links
+++ b/runtime/user/recreate_links
@@ -4,6 +4,14 @@ ln -s ../map.h .
ln -s ../map.c .
ln -s ../map-values.c .
ln -s ../map-keys.c .
+ln -s ../map-int.c .
+ln -s ../map-str.c .
+ln -s ../map-stat.c .
ln -s ../list.c .
ln -s ../string.c .
+ln -s ../string.h .
ln -s ../sym.c .
+ln -s ../counter.c .
+ln -s ../stat.c .
+ln -s ../stat.h .
+ln -s ../stat-common.c .
diff --git a/runtime/user/runtime.h b/runtime/user/runtime.h
index d6ec44ce..30491543 100644
--- a/runtime/user/runtime.h
+++ b/runtime/user/runtime.h
@@ -6,6 +6,10 @@
#define __KERNEL__
#include <linux/module.h>
+#undef CONFIG_NR_CPUS
+#undef CONFIG_SMP
+#define CONFIG_NR_CPUS 8
+#define CONFIG_SMP
#include <linux/kernel.h>
#include <linux/miscdevice.h>
#include <linux/init.h>
@@ -17,7 +21,7 @@
#include <linux/spinlock.h>
#include <asm/uaccess.h>
#include <linux/kallsyms.h>
-
+#include <linux/percpu.h>
#ifdef DEBUG
#define dbug(args...) \
@@ -34,6 +38,9 @@
#undef memcpy
#define memcpy __builtin_memcpy
+#define NEED_STAT_LOCKS 0
+#define NEED_COUNTER_LOCKS 0
+
#include "print.c"
#include "string.c"