/* * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. *
*/
// assertions #ifndef ASSERT #define vmassert(p, ...) #else // Note: message says "assert" rather than "vmassert" for backward // compatibility with tools that parse/match the message text. // Note: The signature is vmassert(p, format, ...), but the solaris // compiler can't handle an empty ellipsis in a macro without a warning. #define vmassert(p, ...) \ do { \ if (!(p)) { \
TOUCH_ASSERT_POISON; \
report_vm_error(__FILE__, __LINE__, "assert("#p") failed", __VA_ARGS__); \
BREAKPOINT; \
} \
} while (0) #endif
// For backward compatibility. #define assert(p, ...) vmassert(p, __VA_ARGS__)
#ifndef ASSERT #define vmassert_status(p, status, msg) #else // This version of vmassert is for use with checking return status from // library calls that return actual error values eg. EINVAL, // ENOMEM etc, rather than returning -1 and setting errno. // When the status is not what is expected it is very useful to know // what status was actually returned, so we pass the status variable as // an extra arg and use strerror to convert it to a meaningful string // like "Invalid argument", "out of memory" etc #define vmassert_status(p, status, msg) \ do { \ if (!(p)) { \
TOUCH_ASSERT_POISON; \
report_vm_status_error(__FILE__, __LINE__, "assert("#p") failed", \
status, msg); \
BREAKPOINT; \
} \
} while (0) #endif
// guarantee is like vmassert except it's always executed -- use it for // cheap tests that catch errors that would otherwise be hard to find. // guarantee is also used for Verify options. #define guarantee(p, ...) \ do { \ if (!(p)) { \
TOUCH_ASSERT_POISON; \
report_vm_error(__FILE__, __LINE__, "guarantee("#p") failed", __VA_ARGS__); \
BREAKPOINT; \
} \
} while (0)
#define fatal(...) \ do { \
TOUCH_ASSERT_POISON; \
report_fatal(INTERNAL_ERROR, __FILE__, __LINE__, __VA_ARGS__); \
BREAKPOINT; \
} while (0)
// out of memory #define vm_exit_out_of_memory(size, vm_err_type, ...) \ do { \
report_vm_out_of_memory(__FILE__, __LINE__, size, vm_err_type, __VA_ARGS__); \
BREAKPOINT; \
} while (0)
#define ShouldNotCallThis() \ do { \
TOUCH_ASSERT_POISON; \
report_should_not_call(__FILE__, __LINE__); \
BREAKPOINT; \
} while (0)
#define ShouldNotReachHere() \ do { \
TOUCH_ASSERT_POISON; \
report_should_not_reach_here(__FILE__, __LINE__); \
BREAKPOINT; \
} while (0)
#define Unimplemented() \ do { \
TOUCH_ASSERT_POISON; \
report_unimplemented(__FILE__, __LINE__); \
BREAKPOINT; \
} while (0)
#define Untested(msg) \ do { \
report_untested(__FILE__, __LINE__, msg); \
BREAKPOINT; \
} while (0);
// types of VM error - originally in vmError.hpp enum VMErrorType {
INTERNAL_ERROR = 0xe0000000,
OOM_MALLOC_ERROR = 0xe0000001,
OOM_MMAP_ERROR = 0xe0000002,
OOM_MPROTECT_ERROR = 0xe0000003,
OOM_JAVA_HEAP_FATAL = 0xe0000004
};
// Set to suppress secondary error reporting. // Really should have a qualified name or something. externbool Debugging;
// error reporting helper functions void report_vm_error(constchar* file, int line, constchar* error_msg); void report_vm_error(constchar* file, int line, constchar* error_msg, constchar* detail_fmt, ...) ATTRIBUTE_PRINTF(4, 5); void report_vm_status_error(constchar* file, int line, constchar* error_msg, int status, constchar* detail); void report_fatal(VMErrorType error_type, constchar* file, int line, constchar* detail_fmt, ...) ATTRIBUTE_PRINTF(4, 5); void report_vm_out_of_memory(constchar* file, int line, size_t size, VMErrorType vm_err_type, constchar* detail_fmt, ...) ATTRIBUTE_PRINTF(5, 6); void report_should_not_call(constchar* file, int line); void report_should_not_reach_here(constchar* file, int line); void report_unimplemented(constchar* file, int line); void report_untested(constchar* file, int line, constchar* message);
void warning(constchar* format, ...) ATTRIBUTE_PRINTF(1, 2);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.