hotspot/src/share/vm/utilities/dtrace.hpp
changeset 13958 f5598a86c223
parent 10739 91935236600e
child 22520 b9e88eed82d7
equal deleted inserted replaced
13957:0f9d3a89b1c2 13958:f5598a86c223
     1 /*
     1 /*
     2  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
       
     3  * Copyright (c) 2009, 2012 Red Hat, Inc.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     8  * published by the Free Software Foundation.
    30 #include <sys/sdt.h>
    31 #include <sys/sdt.h>
    31 
    32 
    32 #define DTRACE_ONLY(x) x
    33 #define DTRACE_ONLY(x) x
    33 #define NOT_DTRACE(x)
    34 #define NOT_DTRACE(x)
    34 
    35 
       
    36 #if defined(SOLARIS)
    35 // Work around dtrace tail call bug 6672627 until it is fixed in solaris 10.
    37 // Work around dtrace tail call bug 6672627 until it is fixed in solaris 10.
    36 #define HS_DTRACE_WORKAROUND_TAIL_CALL_BUG() \
    38 #define HS_DTRACE_WORKAROUND_TAIL_CALL_BUG() \
    37   do { volatile size_t dtrace_workaround_tail_call_bug = 1; } while (0)
    39   do { volatile size_t dtrace_workaround_tail_call_bug = 1; } while (0)
    38 
    40 
    39 #if defined(SOLARIS)
    41 #define USDT1 1
       
    42 #elif defined(LINUX)
       
    43 #define HS_DTRACE_WORKAROUND_TAIL_CALL_BUG()
    40 #define USDT1 1
    44 #define USDT1 1
    41 #elif defined(__APPLE__)
    45 #elif defined(__APPLE__)
       
    46 #define HS_DTRACE_WORKAROUND_TAIL_CALL_BUG()
    42 #define USDT2 1
    47 #define USDT2 1
    43 #include <sys/types.h>
    48 #include <sys/types.h>
    44 #include "dtracefiles/hotspot.h"
    49 #include "dtracefiles/hotspot.h"
    45 #include "dtracefiles/hotspot_jni.h"
    50 #include "dtracefiles/hotspot_jni.h"
    46 #include "dtracefiles/hs_private.h"
    51 #include "dtracefiles/hs_private.h"
    61 #define DTRACE_PROBE1(a,b,c) {;}
    66 #define DTRACE_PROBE1(a,b,c) {;}
    62 #define DTRACE_PROBE2(a,b,c,d) {;}
    67 #define DTRACE_PROBE2(a,b,c,d) {;}
    63 #define DTRACE_PROBE3(a,b,c,d,e) {;}
    68 #define DTRACE_PROBE3(a,b,c,d,e) {;}
    64 #define DTRACE_PROBE4(a,b,c,d,e,f) {;}
    69 #define DTRACE_PROBE4(a,b,c,d,e,f) {;}
    65 #define DTRACE_PROBE5(a,b,c,d,e,f,g) {;}
    70 #define DTRACE_PROBE5(a,b,c,d,e,f,g) {;}
       
    71 #define DTRACE_PROBE6(a,b,c,d,e,f,g,h) {;}
       
    72 #define DTRACE_PROBE7(a,b,c,d,e,f,g,h,i) {;}
       
    73 #define DTRACE_PROBE8(a,b,c,d,e,f,g,h,i,j) {;}
       
    74 #define DTRACE_PROBE9(a,b,c,d,e,f,g,h,i,j,k) {;}
       
    75 #define DTRACE_PROBE10(a,b,c,d,e,f,g,h,i,j,k,l) {;}
    66 
    76 
    67 #else /* USDT2 */
    77 #else /* USDT2 */
    68 
    78 
    69 #include "dtrace_usdt2_disabled.hpp"
    79 #include "dtrace_usdt2_disabled.hpp"
    70 #endif /* USDT2 */
    80 #endif /* USDT2 */
    74 #ifndef USDT2
    84 #ifndef USDT2
    75 
    85 
    76 #define HS_DTRACE_PROBE_FN(provider,name)\
    86 #define HS_DTRACE_PROBE_FN(provider,name)\
    77   __dtrace_##provider##___##name
    87   __dtrace_##provider##___##name
    78 
    88 
       
    89 #ifdef SOLARIS
       
    90 // Solaris dtrace needs actual extern function decls.
    79 #define HS_DTRACE_PROBE_DECL_N(provider,name,args) \
    91 #define HS_DTRACE_PROBE_DECL_N(provider,name,args) \
    80   DTRACE_ONLY(extern "C" void HS_DTRACE_PROBE_FN(provider,name) args)
    92   DTRACE_ONLY(extern "C" void HS_DTRACE_PROBE_FN(provider,name) args)
    81 #define HS_DTRACE_PROBE_CDECL_N(provider,name,args) \
    93 #define HS_DTRACE_PROBE_CDECL_N(provider,name,args) \
    82   DTRACE_ONLY(extern void HS_DTRACE_PROBE_FN(provider,name) args)
    94   DTRACE_ONLY(extern void HS_DTRACE_PROBE_FN(provider,name) args)
       
    95 #else
       
    96 // Systemtap dtrace compatible probes on GNU/Linux don't.
       
    97 // If dtrace is disabled this macro becomes NULL
       
    98 #define HS_DTRACE_PROBE_DECL_N(provider,name,args)
       
    99 #define HS_DTRACE_PROBE_CDECL_N(provider,name,args)
       
   100 #endif
    83 
   101 
    84 /* Dtrace probe declarations */
   102 /* Dtrace probe declarations */
    85 #define HS_DTRACE_PROBE_DECL(provider,name) \
   103 #define HS_DTRACE_PROBE_DECL(provider,name) \
    86   HS_DTRACE_PROBE_DECL0(provider,name)
   104   HS_DTRACE_PROBE_DECL0(provider,name)
    87 #define HS_DTRACE_PROBE_DECL0(provider,name)\
   105 #define HS_DTRACE_PROBE_DECL0(provider,name)\
   116   HS_DTRACE_PROBE_DECL_N(provider,name,(\
   134   HS_DTRACE_PROBE_DECL_N(provider,name,(\
   117     uintptr_t,uintptr_t,uintptr_t,uintptr_t,uintptr_t,uintptr_t,uintptr_t,\
   135     uintptr_t,uintptr_t,uintptr_t,uintptr_t,uintptr_t,uintptr_t,uintptr_t,\
   118     uintptr_t,uintptr_t,uintptr_t))
   136     uintptr_t,uintptr_t,uintptr_t))
   119 
   137 
   120 /* Dtrace probe definitions */
   138 /* Dtrace probe definitions */
       
   139 #if defined(SOLARIS)
       
   140 // Solaris dtrace uses actual function calls.
   121 #define HS_DTRACE_PROBE_N(provider,name, args) \
   141 #define HS_DTRACE_PROBE_N(provider,name, args) \
   122   DTRACE_ONLY(HS_DTRACE_PROBE_FN(provider,name) args)
   142   DTRACE_ONLY(HS_DTRACE_PROBE_FN(provider,name) args)
   123 
   143 
   124 #define HS_DTRACE_PROBE(provider,name) HS_DTRACE_PROBE0(provider,name)
   144 #define HS_DTRACE_PROBE(provider,name) HS_DTRACE_PROBE0(provider,name)
   125 #define HS_DTRACE_PROBE0(provider,name)\
   145 #define HS_DTRACE_PROBE0(provider,name)\
   151     (uintptr_t)a8))
   171     (uintptr_t)a8))
   152 #define HS_DTRACE_PROBE10(provider,name,a0,a1,a2,a3,a4,a5,a6,a7,a8,a9)\
   172 #define HS_DTRACE_PROBE10(provider,name,a0,a1,a2,a3,a4,a5,a6,a7,a8,a9)\
   153   HS_DTRACE_PROBE_N(provider,name,((uintptr_t)a0,(uintptr_t)a1,(uintptr_t)a2,\
   173   HS_DTRACE_PROBE_N(provider,name,((uintptr_t)a0,(uintptr_t)a1,(uintptr_t)a2,\
   154     (uintptr_t)a3,(uintptr_t)a4,(uintptr_t)a5,(uintptr_t)a6,(uintptr_t)a7,\
   174     (uintptr_t)a3,(uintptr_t)a4,(uintptr_t)a5,(uintptr_t)a6,(uintptr_t)a7,\
   155     (uintptr_t)a8,(uintptr_t)a9))
   175     (uintptr_t)a8,(uintptr_t)a9))
       
   176 #else
       
   177 // Systemtap dtrace compatible probes on GNU/Linux use direct macros.
       
   178 // If dtrace is disabled this macro becomes NULL
       
   179 #define HS_DTRACE_PROBE(provider,name) HS_DTRACE_PROBE0(provider,name)
       
   180 #define HS_DTRACE_PROBE0(provider,name)\
       
   181   DTRACE_PROBE(provider,name)
       
   182 #define HS_DTRACE_PROBE1(provider,name,a0)\
       
   183   DTRACE_PROBE1(provider,name,a0)
       
   184 #define HS_DTRACE_PROBE2(provider,name,a0,a1)\
       
   185   DTRACE_PROBE2(provider,name,a0,a1)
       
   186 #define HS_DTRACE_PROBE3(provider,name,a0,a1,a2)\
       
   187   DTRACE_PROBE3(provider,name,a0,a1,a2)
       
   188 #define HS_DTRACE_PROBE4(provider,name,a0,a1,a2,a3)\
       
   189   DTRACE_PROBE4(provider,name,a0,a1,a2,a3)
       
   190 #define HS_DTRACE_PROBE5(provider,name,a0,a1,a2,a3,a4)\
       
   191   DTRACE_PROBE5(provider,name,a0,a1,a2,a3,a4)
       
   192 #define HS_DTRACE_PROBE6(provider,name,a0,a1,a2,a3,a4,a5)\
       
   193   DTRACE_PROBE6(provider,name,a0,a1,a2,a3,a4,a5)
       
   194 #define HS_DTRACE_PROBE7(provider,name,a0,a1,a2,a3,a4,a5,a6)\
       
   195   DTRACE_PROBE7(provider,name,a0,a1,a2,a3,a4,a5,a6)
       
   196 #define HS_DTRACE_PROBE8(provider,name,a0,a1,a2,a3,a4,a5,a6,a7)\
       
   197   DTRACE_PROBE8(provider,name,a0,a1,a2,a3,a4,a5,a6,a7)
       
   198 #define HS_DTRACE_PROBE9(provider,name,a0,a1,a2,a3,a4,a5,a6,a7,a8)\
       
   199   DTRACE_PROBE9(provider,name,a0,a1,a2,a3,a4,a5,a6,a7,a8)
       
   200 #define HS_DTRACE_PROBE10(provider,name,a0,a1,a2,a3,a4,a5,a6,a7,a8,a9)\
       
   201   DTRACE_PROBE10(provider,name,a0,a1,a2,a3,a4,a5,a6,a7,a8,a9)
       
   202 #endif
   156 
   203 
   157 #endif /* !USDT2 */
   204 #endif /* !USDT2 */
   158 
   205 
   159 #endif // SHARE_VM_UTILITIES_DTRACE_HPP
   206 #endif // SHARE_VM_UTILITIES_DTRACE_HPP