view patches/icedtea-systemtap.patch @ 1581:85ecc550df1f

Add systemtap java method tracing support. 2009-08-05 Mark Wielaard <mjw@redhat.com> * patches/icedtea-systemtap.patch: Remove workaround for nmethod.cpp. * tapset/hotspot.stp.in: Add tapset functions for hotspot.method_entry, hotspot.method_return, hotspot.compiled_method_load and hotspot.compiled_method_unload. * NEWS: Metion new support for java method tracing. * INSTALL: Add that java method tracing support needs systemtap 0.9.9 or higher.
author Mark Wielaard <mark@klomp.org>
date Wed, 05 Aug 2009 20:43:00 +0200
parents 8dd3adfcadf9
children 58b7ae54c4de
line wrap: on
line source

diff -r 945bf7540697 make/linux/makefiles/dtrace.make
--- openjdk/hotspot/make/linux/makefiles/dtrace.make	Thu Jan 22 14:42:01 2009 -0800
+++ openjdk/hotspot/make/linux/makefiles/dtrace.make	Mon Feb 02 13:47:34 2009 +0100
@@ -25,3 +25,7 @@
 # Linux does not build jvm_db
 LIBJVM_DB =
 
+# But it does have a Systemtap dtrace compatible sys/sdt.h
+CFLAGS += -DDTRACE_ENABLED
+
+# It doesn't support HAVE_DTRACE_H though.
diff -r 945bf7540697 src/share/vm/prims/jni.cpp
--- openjdk/hotspot/src/share/vm/prims/jni.cpp	Thu Jan 22 14:42:01 2009 -0800
+++ openjdk/hotspot/src/share/vm/prims/jni.cpp	Mon Feb 02 13:47:34 2009 +0100
@@ -22,6 +22,12 @@
  *
  */
 
+#ifdef __GNUC__
+// Unfortunately the gcc c preprocessor doesn't like some of the
+// FP_SELECT defines below, so for now we make sure to disable them.
+#undef DTRACE_ENABLED
+#endif
+
 # include "incls/_precompiled.incl"
 # include "incls/_jni.cpp.incl"
 
diff -r 945bf7540697 src/share/vm/utilities/dtrace.hpp
--- openjdk/hotspot/src/share/vm/utilities/dtrace.hpp	Thu Jan 22 14:42:01 2009 -0800
+++ openjdk/hotspot/src/share/vm/utilities/dtrace.hpp	Mon Feb 02 13:47:34 2009 +0100
@@ -1,5 +1,6 @@
 /*
  * Copyright 2005-2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 2009 Red Hat, Inc.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,14 +23,14 @@
  *
  */
 
-#if defined(SOLARIS) && defined(DTRACE_ENABLED)
+#if defined(DTRACE_ENABLED)
 
 #include <sys/sdt.h>
 
 #define DTRACE_ONLY(x) x
 #define NOT_DTRACE(x)
 
-#else // ndef SOLARIS || ndef DTRACE_ENABLED
+#else // ndef DTRACE_ENABLED
 
 #define DTRACE_ONLY(x)
 #define NOT_DTRACE(x) x
@@ -40,9 +41,15 @@
 #define DTRACE_PROBE3(a,b,c,d,e) {;}
 #define DTRACE_PROBE4(a,b,c,d,e,f) {;}
 #define DTRACE_PROBE5(a,b,c,d,e,f,g) {;}
+#define DTRACE_PROBE6(a,b,c,d,e,f,g,h) {;}
+#define DTRACE_PROBE7(a,b,c,d,e,f,g,h,i) {;}
+#define DTRACE_PROBE8(a,b,c,d,e,f,g,h,i,j) {;}
+#define DTRACE_PROBE9(a,b,c,d,e,f,g,h,i,j,k) {;}
 
 #endif
 
+#if defined(SOLARIS)
+// Solaris dtrace needs actual extern function decls.
 #define HS_DTRACE_PROBE_FN(provider,name)\
   __dtrace_##provider##___##name
 
@@ -50,6 +57,13 @@
   DTRACE_ONLY(extern "C" void HS_DTRACE_PROBE_FN(provider,name) args)
 #define HS_DTRACE_PROBE_CDECL_N(provider,name,args) \
   DTRACE_ONLY(extern void HS_DTRACE_PROBE_FN(provider,name) args)
+#else
+// Systemtap dtrace compatible probes on GNU/Linux don't.
+#define HS_DTRACE_PROBE_FN(provider,name)
+
+#define HS_DTRACE_PROBE_DECL_N(provider,name,args)
+#define HS_DTRACE_PROBE_CDECL_N(provider,name,args)
+#endif 
 
 /* Dtrace probe declarations */
 #define HS_DTRACE_PROBE_DECL(provider,name) \
@@ -91,6 +105,8 @@
 #define HS_DTRACE_PROBE_N(provider,name, args) \
   DTRACE_ONLY(HS_DTRACE_PROBE_FN(provider,name) args)
 
+#if defined(SOLARIS)
+// Solaris dtrace uses actual function calls.
 #define HS_DTRACE_PROBE(provider,name) HS_DTRACE_PROBE0(provider,name)
 #define HS_DTRACE_PROBE0(provider,name)\
   HS_DTRACE_PROBE_N(provider,name,())
@@ -123,3 +139,27 @@
   HS_DTRACE_PROBE_N(provider,name,((uintptr_t)a0,(uintptr_t)a1,(uintptr_t)a2,\
     (uintptr_t)a3,(uintptr_t)a4,(uintptr_t)a5,(uintptr_t)a6,(uintptr_t)a7,\
     (uintptr_t)a8,(uintptr_t)a9))
+#else
+// Systemtap dtrace compatible probes on GNU/Linux use direct macros.
+#define HS_DTRACE_PROBE(provider,name) HS_DTRACE_PROBE0(provider,name)
+#define HS_DTRACE_PROBE0(provider,name)\
+  DTRACE_PROBE(provider,name)
+#define HS_DTRACE_PROBE1(provider,name,a0)\
+  DTRACE_PROBE1(provider,name,a0)
+#define HS_DTRACE_PROBE2(provider,name,a0,a1)\
+  DTRACE_PROBE2(provider,name,a0,a1)
+#define HS_DTRACE_PROBE3(provider,name,a0,a1,a2)\
+  DTRACE_PROBE3(provider,name,a0,a1,a2)
+#define HS_DTRACE_PROBE4(provider,name,a0,a1,a2,a3)\
+  DTRACE_PROBE4(provider,name,a0,a1,a2,a3)
+#define HS_DTRACE_PROBE5(provider,name,a0,a1,a2,a3,a4)\
+  DTRACE_PROBE5(provider,name,a0,a1,a2,a3,a4)
+#define HS_DTRACE_PROBE6(provider,name,a0,a1,a2,a3,a4,a5)\
+  DTRACE_PROBE6(provider,name,a0,a1,a2,a3,a4,a5)
+#define HS_DTRACE_PROBE7(provider,name,a0,a1,a2,a3,a4,a5,a6)\
+  DTRACE_PROBE7(provider,name,a0,a1,a2,a3,a4,a5,a6)
+#define HS_DTRACE_PROBE8(provider,name,a0,a1,a2,a3,a4,a5,a6,a7)\
+  DTRACE_PROBE8(provider,name,a0,a1,a2,a3,a4,a5,a6,a7)
+#define HS_DTRACE_PROBE9(provider,name,a0,a1,a2,a3,a4,a5,a6,a7,a8)\
+  DTRACE_PROBE9(provider,name,a0,a1,a2,a3,a4,a5,a6,a7,a8)
+#endif
--- openjdk/hotspot/src/share/vm/runtime/arguments.cpp	2009-03-04 14:39:43.000000000 +0100
+++ openjdk/hotspot/src/share/vm/runtime/arguments.cpp	2009-03-04 22:11:37.000000000 +0100
@@ -2272,16 +2272,16 @@
       FLAG_SET_CMDLINE(bool, DisplayVMOutputToStderr, false);
       FLAG_SET_CMDLINE(bool, DisplayVMOutputToStdout, true);
     } else if (match_option(option, "-XX:+ExtendedDTraceProbes", &tail)) {
-#ifdef SOLARIS
+#ifdef DTRACE_ENABLED
       FLAG_SET_CMDLINE(bool, ExtendedDTraceProbes, true);
       FLAG_SET_CMDLINE(bool, DTraceMethodProbes, true);
       FLAG_SET_CMDLINE(bool, DTraceAllocProbes, true);
       FLAG_SET_CMDLINE(bool, DTraceMonitorProbes, true);
-#else // ndef SOLARIS
+#else // ndef DTRACE_ENABLED
       jio_fprintf(defaultStream::error_stream(),
-                  "ExtendedDTraceProbes flag is only applicable on Solaris\n");
+                  "ExtendedDTraceProbes flag is only applicable on dtrace enabled builds\n");
       return JNI_EINVAL;
-#endif // ndef SOLARIS
+#endif // ndef DTRACE_ENABLED
     } else
 #ifdef ASSERT
     if (match_option(option, "-XX:+FullGCALot", &tail)) {