Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/demo/jvmti/hprof/hprof_error.h
38829 views
/*1* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.2*3* Redistribution and use in source and binary forms, with or without4* modification, are permitted provided that the following conditions5* are met:6*7* - Redistributions of source code must retain the above copyright8* notice, this list of conditions and the following disclaimer.9*10* - Redistributions in binary form must reproduce the above copyright11* notice, this list of conditions and the following disclaimer in the12* documentation and/or other materials provided with the distribution.13*14* - Neither the name of Oracle nor the names of its15* contributors may be used to endorse or promote products derived16* from this software without specific prior written permission.17*18* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS19* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,20* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR21* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR22* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,23* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,24* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR25* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF26* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING27* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS28* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.29*/3031/*32* This source code is provided to illustrate the usage of a given feature33* or technique and has been deliberately simplified. Additional steps34* required for a production-quality application, such as security checks,35* input validation and proper error handling, might not be present in36* this sample code.37*/383940#ifndef HPROF_ERROR_H41#define HPROF_ERROR_H4243/* Use THIS_FILE when it is available. */44#ifndef THIS_FILE45#define THIS_FILE __FILE__46#endif4748/* Macros over assert and error functions so we can capture the source loc. */4950#define HPROF_BOOL(x) ((jboolean)((x)==0?JNI_FALSE:JNI_TRUE))5152#define HPROF_ERROR(fatal,msg) \53error_handler(HPROF_BOOL(fatal), JVMTI_ERROR_NONE, msg, THIS_FILE, __LINE__)5455#define HPROF_JVMTI_ERROR(error,msg) \56error_handler(HPROF_BOOL(error!=JVMTI_ERROR_NONE), \57error, msg, THIS_FILE, __LINE__)5859#if defined(DEBUG) || !defined(NDEBUG)60#define HPROF_ASSERT(cond) \61(((int)(cond))?(void)0:error_assert(#cond, THIS_FILE, __LINE__))62#else63#define HPROF_ASSERT(cond)64#endif6566#define LOG_DUMP_MISC 0x1 /* Misc. logging info */67#define LOG_DUMP_LISTS 0x2 /* Dump tables at vm init and death */68#define LOG_CHECK_BINARY 0x4 /* If format=b, verify binary format */6970#ifdef HPROF_LOGGING71#define LOG_STDERR(args) \72{ \73if ( gdata != NULL && (gdata->logflags & LOG_DUMP_MISC) ) { \74(void)fprintf args ; \75} \76}77#else78#define LOG_STDERR(args)79#endif8081#define LOG_FORMAT(format) "HPROF LOG: " format " [%s:%d]\n"8283#define LOG1(str1) LOG_STDERR((stderr, LOG_FORMAT("%s"), \84str1, THIS_FILE, __LINE__ ))85#define LOG2(str1,str2) LOG_STDERR((stderr, LOG_FORMAT("%s %s"), \86str1, str2, THIS_FILE, __LINE__ ))87#define LOG3(str1,str2,num) LOG_STDERR((stderr, LOG_FORMAT("%s %s 0x%x"), \88str1, str2, num, THIS_FILE, __LINE__ ))8990#define LOG(str) LOG1(str)9192void error_handler(jboolean fatal, jvmtiError error,93const char *message, const char *file, int line);94void error_assert(const char *condition, const char *file, int line);95void error_exit_process(int exit_code);96void error_do_pause(void);97void error_setup(void);98void debug_message(const char * format, ...);99void verbose_message(const char * format, ...);100101#endif102103104