[PATCH 18/22] perf tools: Add udis86 disassembler feature check

From: Jiri Olsa
Date: Thu Nov 21 2013 - 06:03:32 EST


Adding udis86 disassembler feature check which support
is needed for kvm:kvm_emulate_insn tracepoint.

The diff of 'perf script' output generated by old and new code:
(data was generated by 'perf record -e kvm:kvm_emulate_insn -a')

--- script.kvm.old
+++ script.kvm.new
- qemu-system-x86 15519 [003] 5332.470049: kvm:kvm_emulate_insn: 0:ffffffff8103c596:89 b7 00 80 5f ff (prot64)
+ qemu-system-x86 15519 [003] 5332.470049: kvm:kvm_emulate_insn: 0:ffffffff8103c596: mov %esi, -0xa08000(%rdi)

Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>
Cc: Corey Ashford <cjashfor@xxxxxxxxxxxxxxxxxx>
Cc: Frederic Weisbecker <fweisbec@xxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxx>
Cc: Namhyung Kim <namhyung@xxxxxxxxxx>
Cc: Paul Mackerras <paulus@xxxxxxxxx>
Cc: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx>
Cc: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
Cc: Steven Rostedt <rostedt@xxxxxxxxxxx>
Cc: David Ahern <dsahern@xxxxxxxxx>
---
tools/perf/Makefile.perf | 2 +-
tools/perf/config/Makefile | 8 ++++++++
tools/perf/config/feature-checks/Makefile | 6 +++++-
tools/perf/config/feature-checks/test-all.c | 5 +++++
tools/perf/config/feature-checks/test-udis86.c | 11 +++++++++++
5 files changed, 30 insertions(+), 2 deletions(-)
create mode 100644 tools/perf/config/feature-checks/test-udis86.c

diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index b4f8910..d465540 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -710,7 +710,7 @@ $(LIB_FILE): $(LIB_OBJS)
# libtraceevent.a
TE_SOURCES = $(wildcard $(TRACE_EVENT_DIR)*.[ch])

-LIBTRACEEVENT_FLAGS=$(QUIET_SUBDIR1) O=$(OUTPUT) CFLAGS="-g -Wall $(EXTRA_CFLAGS)" plugin_dir=$(plugindir_SQ)
+LIBTRACEEVENT_FLAGS=$(QUIET_SUBDIR1) O=$(OUTPUT) CFLAGS="-g -Wall $(EXTRA_CFLAGS) $(LIBTRACEEVENT_CFLAGS)" plugin_dir=$(plugindir_SQ)

$(LIBTRACEEVENT): $(TE_SOURCES) $(OUTPUT)PERF-CFLAGS
$(QUIET_SUBDIR0)$(TRACE_EVENT_DIR) $(LIBTRACEEVENT_FLAGS) libtraceevent.a plugins
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 8c8a205..3f9c6b4 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -418,6 +418,14 @@ else
msg := $(warning No timerfd support. Disables 'perf kvm stat live');
endif

+$(call feature_check,udis86)
+ifeq ($(feature-udis86), 1)
+ LIBTRACEEVENT_CFLAGS += -DHAVE_UDIS86
+ EXTLIBS += -ludis86
+else
+ msg := $(warning No udis86 support.);
+endif
+
disable-python = $(eval $(disable-python_code))
define disable-python_code
CFLAGS += -DNO_LIBPYTHON
diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
index 87e7900..b0df0f2 100644
--- a/tools/perf/config/feature-checks/Makefile
+++ b/tools/perf/config/feature-checks/Makefile
@@ -27,7 +27,8 @@ FILES= \
test-on-exit \
test-stackprotector-all \
test-stackprotector \
- test-timerfd
+ test-timerfd \
+ test-udis86

CC := $(CC) -MD

@@ -144,6 +145,9 @@ test-backtrace:
test-timerfd:
$(BUILD)

+test-udis86:
+ $(BUILD) -DHAVE_UDIS86 -ludis86
+
-include *.d

###############################
diff --git a/tools/perf/config/feature-checks/test-all.c b/tools/perf/config/feature-checks/test-all.c
index 59e7a70..0896ae0 100644
--- a/tools/perf/config/feature-checks/test-all.c
+++ b/tools/perf/config/feature-checks/test-all.c
@@ -85,6 +85,10 @@
# include "test-timerfd.c"
#undef main

+#define main main_test_udis86
+# include "test-udis86.c"
+#undef main
+
int main(int argc, char *argv[])
{
main_test_libpython();
@@ -106,6 +110,7 @@ int main(int argc, char *argv[])
main_test_backtrace();
main_test_libnuma();
main_test_timerfd();
+ main_test_udis86();

return 0;
}
diff --git a/tools/perf/config/feature-checks/test-udis86.c b/tools/perf/config/feature-checks/test-udis86.c
new file mode 100644
index 0000000..dbc2c26
--- /dev/null
+++ b/tools/perf/config/feature-checks/test-udis86.c
@@ -0,0 +1,11 @@
+
+/*
+ * test for udis86 functions used by plugin_kvm.c
+ */
+
+#include <udis86.h>
+
+int main(void)
+{
+ return puts("hi");
+}
--
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/