Skip to contentSkip to conversation

xenalyze: add a basic plugin infrastructure

PATCH New David Vrabel 1 participant 1 message Apr 25, 2012 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xenalyze: add a basic plugin infrastructure

Allow xenalyze to be include (at build time) plugins that can do per-record actions and a summary. These plugins can be in C or C++.

The plugins entry points are in struct plugin and pointers to all the plugins linked in xenalyze are placed in a "plugin" section so plugin_init() can find them all.

A new command line option (-p, --plugin=PLUGIN) is added to enable one or more plugins.

A sample plugin (skeleton) is included (mostly because at least one plugin must be present for the build to work).

---
 Makefile            |   10 +++---
 analyze.h           |   55 ++++++++++++++++++++++++++++++++++
 plugin.cc           |   84 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 plugin.h            |   48 +++++++++++++++++++++++++++++
 plugin.hh           |   42 ++++++++++++++++++++++++++
 plugins/skeleton.cc |   31 +++++++++++++++++++
 xenalyze.c          |   72 +++++++++++++-------------------------------
 7 files changed, 287 insertions(+), 55 deletions(-)
Makefile +6 -4
diff -r f4feecb06e49 Makefile
@@ -1,6 +1,6 @@
 CC = gcc
 
-CFLAGS += -g -O2
+CFLAGS += -g -O2 -I.
 CFLAGS += -fno-strict-aliasing
 CFLAGS += -std=gnu99
 CFLAGS += -Wall -Wstrict-prototypes
@@ -11,9 +11,11 @@ CFLAGS  += -D_LARGEFILE_SOURCE -D_LARGEF
 CFLAGS += -mno-tls-direct-seg-refs
 CFLAGS  += -Werror
 
+CXXFLAGS := -g -O2 -I. -Wall -Werror -std=c++0x
+
 BIN      = xenalyze dump-raw
 
-HDRS = trace.h analyze.h mread.h
+HDRS = trace.h analyze.h mread.h plugin.h plugin.hh
 
 all: $(BIN)
 
@@ -24,5 +26,5 @@ clean:
 %: %.c $(HDRS) Makefile
 	$(CC) $(CFLAGS) -o $@ $<
 
-xenalyze: xenalyze.o mread.o
-	$(CC) $(CFLAGS) -o $@ $^
+xenalyze: xenalyze.o mread.o plugin.o plugins/skeleton.o
+	$(CXX) $(CFLAGS) -o $@ $^
analyze.h +55 -0

64 lines not on this page · raw message

plugin.cc new file +84 -0

84 lines not on this page · raw message

plugin.h new file +48 -0

48 lines not on this page · raw message

plugin.hh new file +42 -0

42 lines not on this page · raw message

plugins/skeleton.cc new file +31 -0
diff -r f4feecb06e49 plugins/skeleton.cc
@@ -0,0 +1,31 @@
+/*
+ * Skeleton xenalyze plugin.
+ *
+ * Copyright (C) 2012, Citrix Systems R&D Ltd, UK
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ */
+#include "plugin.hh"
+
+class skeleton_plugin : xenalyze_plugin {
+public:
+    skeleton_plugin() {}
+    ~skeleton_plugin() {}
+
+    void process(const struct record_info *ri);
+    void summary(void);
+};
+
+void skeleton_plugin::process(const struct record_info *ri)
+{
+    /* Put per-trace record stuff here. */
+}
+
+void skeleton_plugin::summary(void)
+{
+    /* Print a summary of the results (if applicable). */
+}
+
+DEFINE_CXX_PLUGIN("skeleton", skeleton_plugin);
xenalyze.c +21 -51

127 lines not on this page · raw message