1 /*
   2  * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * 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  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 #ifndef JDWP_LOG_MESSAGES_H
  27 #define JDWP_LOG_MESSAGES_H
  28 
  29 /* LOG: Must be called like:  LOG_category(("anything")) or LOG_category((format,args)) */
  30 
  31 void setup_logging(const char *, unsigned);
  32 void finish_logging(int);
  33 
  34 #define LOG_NULL ((void)0)
  35 
  36 /* Use THIS_FILE when it is available. */
  37 #ifndef THIS_FILE
  38     #define THIS_FILE __FILE__
  39 #endif
  40 
  41 #ifdef JDWP_LOGGING
  42 
  43     #define _LOG(flavor,args) \
  44                 (log_message_begin(flavor,THIS_FILE,__LINE__), \
  45                  log_message_end args)
  46 
  47     #define LOG_TEST(flag)  (gdata->log_flags & (flag))
  48 
  49     #define LOG_JVM(args)   \
  50         (LOG_TEST(JDWP_LOG_JVM)  ?_LOG("JVM",  args):LOG_NULL)
  51     #define LOG_JNI(args)   \
  52         (LOG_TEST(JDWP_LOG_JNI)  ?_LOG("JNI",  args):LOG_NULL)
  53     #define LOG_JVMTI(args) \
  54         (LOG_TEST(JDWP_LOG_JVMTI)?_LOG("JVMTI",args):LOG_NULL)
  55     #define LOG_MISC(args)  \
  56         (LOG_TEST(JDWP_LOG_MISC) ?_LOG("MISC", args):LOG_NULL)
  57     #define LOG_STEP(args)  \
  58         (LOG_TEST(JDWP_LOG_STEP) ?_LOG("STEP", args):LOG_NULL)
  59     #define LOG_LOC(args)   \
  60         (LOG_TEST(JDWP_LOG_LOC)  ?_LOG("LOC",  args):LOG_NULL)
  61     #define LOG_CB(args) \
  62         (LOG_TEST(JDWP_LOG_CB)?_LOG("CB",args):LOG_NULL)
  63     #define LOG_ERROR(args) \
  64         (LOG_TEST(JDWP_LOG_ERROR)?_LOG("ERROR",args):LOG_NULL)
  65 
  66 
  67     /* DO NOT USE THESE DIRECTLY */
  68     void log_message_begin(const char *, const char *, int);
  69     void log_message_end(const char *, ...);
  70 
  71 #else
  72 
  73     #define LOG_TEST(flag)      0
  74 
  75     #define LOG_JVM(args)       LOG_NULL
  76     #define LOG_JNI(args)       LOG_NULL
  77     #define LOG_JVMTI(args)     LOG_NULL
  78     #define LOG_MISC(args)      LOG_NULL
  79     #define LOG_STEP(args)      LOG_NULL
  80     #define LOG_LOC(args)       LOG_NULL
  81     #define LOG_CB(args)        LOG_NULL
  82     #define LOG_ERROR(args)     LOG_NULL
  83 
  84 #endif
  85 
  86 #define    JDWP_LOG_JVM         0x00000001
  87 #define    JDWP_LOG_JNI         0x00000002
  88 #define    JDWP_LOG_JVMTI       0x00000004
  89 #define    JDWP_LOG_MISC        0x00000008
  90 #define    JDWP_LOG_STEP        0x00000010
  91 #define    JDWP_LOG_LOC         0x00000020
  92 #define    JDWP_LOG_CB          0x00000040
  93 #define    JDWP_LOG_ERROR       0x00000080
  94 #define    JDWP_LOG_ALL         0xffffffff
  95 
  96 #endif