Path: blob/master/runtime/gc_check/CheckBase.hpp
5985 views
1/*******************************************************************************2* Copyright (c) 1991, 2021 IBM Corp. and others3*4* This program and the accompanying materials are made available under5* the terms of the Eclipse Public License 2.0 which accompanies this6* distribution and is available at https://www.eclipse.org/legal/epl-2.0/7* or the Apache License, Version 2.0 which accompanies this distribution and8* is available at https://www.apache.org/licenses/LICENSE-2.0.9*10* This Source Code may also be made available under the following11* Secondary Licenses when the conditions for such availability set12* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU13* General Public License, version 2 with the GNU Classpath14* Exception [1] and GNU General Public License, version 2 with the15* OpenJDK Assembly Exception [2].16*17* [1] https://www.gnu.org/software/classpath/license.html18* [2] http://openjdk.java.net/legal/assembly-exception.html19*20* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception21*******************************************************************************/2223/**24* @file25* @ingroup GC_Check26*/2728#if !defined(CHECKBASE_HPP_)29#define CHECKBASE_HPP_3031#include "j9.h"32#include "j9cfg.h"33#include "modronopt.h"3435/**36* @name Scan options supported by gcchk37* @anchor scanFlags38* @{39*/4041/* scan flags */42#define J9MODRON_GCCHK_SCAN_ALL_SLOTS ((UDATA)0xFFFFFFF)43#define J9MODRON_GCCHK_SCAN_OBJECT_HEAP ((UDATA)0x00000001)44#define J9MODRON_GCCHK_SCAN_CLASS_HEAP ((UDATA)0x00000002)45#define J9MODRON_GCCHK_SCAN_REMEMBERED_SET ((UDATA)0x00000004)46#define J9MODRON_GCCHK_SCAN_UNFINALIZED ((UDATA)0x00000008)47#define J9MODRON_GCCHK_SCAN_FINALIZABLE ((UDATA)0x00000010)48#define J9MODRON_GCCHK_SCAN_OWNABLE_SYNCHRONIZER ((UDATA)0x00000020)49#define J9MODRON_GCCHK_SCAN_UNUSED1 ((UDATA)0x00000040)50#define J9MODRON_GCCHK_SCAN_UNUSED2 ((UDATA)0x00000080)51#define J9MODRON_GCCHK_SCAN_STRING_TABLE ((UDATA)0x00000100)52#define J9MODRON_GCCHK_SCAN_CLASS_LOADERS ((UDATA)0x00000200)53#define J9MODRON_GCCHK_SCAN_JNI_GLOBAL_REFERENCES ((UDATA)0x00000400)54#define J9MODRON_GCCHK_SCAN_JNI_WEAK_GLOBAL_REFERENCES ((UDATA)0x00000800)55#define J9MODRON_GCCHK_SCAN_DEBUGGER_REFERENCES ((UDATA)0x00001000)56#define J9MODRON_GCCHK_SCAN_DEBUGGER_CLASS_REFERENCES ((UDATA)0x00002000)57#define J9MODRON_GCCHK_SCAN_VM_CLASS_SLOTS ((UDATA)0x00004000)58#define J9MODRON_GCCHK_SCAN_VMTHREADS ((UDATA)0x00008000)59#define J9MODRON_GCCHK_SCAN_THREADSTACKS ((UDATA)0x00010000)60#define J9MODRON_GCCHK_SCAN_JVMTI_OBJECT_TAG_TABLES ((UDATA)0x00020000)61#define J9MODRON_GCCHK_SCAN_MONITOR_TABLE ((UDATA)0x00040000)62#define J9MODRON_GCCHK_SCAN_SCOPES ((UDATA)0x00080000)63/**64* @}65*/6667/**68* @anchor checkFlags69* @name Check options70* @{71*/72#define J9MODRON_GCCHK_VERIFY_ALL ((UDATA)0xFFFFFFFF)73#define J9MODRON_GCCHK_VERIFY_CLASS_SLOT ((UDATA)0x00000001)7475/* Range check only makes sense if the class pointer is verified first. */76#define J9MODRON_GCCHK_VERIFY_RANGE ((UDATA)0x00000002)77#define J9MODRON_GCCHK_VERIFY_SHAPE ((UDATA)0x00000004)78#define J9MODRON_GCCHK_VERIFY_FLAGS ((UDATA)0x00000008)79/** @} */8081/**82* @anchor miscFlags83* @name Misc options84* @{85*/86#define J9MODRON_GCCHK_VERBOSE ((UDATA)0x00000001)87#define J9MODRON_GCCHK_INTERVAL ((UDATA)0x00000002)88#define J9MODRON_GCCHK_GLOBAL_INTERVAL ((UDATA)0x00000004)89#define J9MODRON_GCCHK_LOCAL_INTERVAL ((UDATA)0x00000008)90#define J9MODRON_GCCHK_START_INDEX ((UDATA)0x00000010)91#define J9MODRON_GCCHK_SCAVENGER_BACKOUT ((UDATA)0x00000020)92#define J9MODRON_GCCHK_SUPPRESS_LOCAL ((UDATA)0x00000040)93#define J9MODRON_GCCHK_SUPPRESS_GLOBAL ((UDATA)0x00000080)94#define J9MODRON_GCCHK_REMEMBEREDSET_OVERFLOW ((UDATA)0x00000100)95#define J9MODRON_GCCHK_MISC_SCAN ((UDATA)0x00000200)96#define J9MODRON_GCCHK_MISC_CHECK ((UDATA)0x00000400)97#define J9MODRON_GCCHK_MISC_QUIET ((UDATA)0x00000800)98#define J9MODRON_GCCHK_MISC_ABORT ((UDATA)0x00001000)99#define J9MODRON_GCCHK_MANUAL ((UDATA)0x00002000)100#define J9MODRON_GCCHK_MISC_ALWAYS_DUMP_STACK ((UDATA)0x00004000)101#define J9MODRON_GCCHK_MISC_DARKMATTER ((UDATA)0x00008000)102#define J9MODRON_GCCHK_MISC_MIDSCAVENGE ((UDATA)0x00010000)103#define J9MODRON_GCCHK_MISC_OWNABLESYNCHRONIZER_CONSISTENCY ((UDATA)0x00020000)104#define J9MODRON_GCCHK_VALID_INDEXABLE_DATA_ADDRESS ((UDATA)0x00040000)105/** @} */106107/**108* Return codes for iterator functions.109* Verification continues if an iterator function returns J9MODRON_SLOT_ITERATOR_OK,110* otherwise it terminates.111* @name Iterator return codes112* @{113*/114#define J9MODRON_SLOT_ITERATOR_OK ((UDATA)0x00000000) /**< Indicates success */115#define J9MODRON_SLOT_ITERATOR_UNRECOVERABLE_ERROR ((UDATA)0x00000001) /**< Indicates that an unrecoverable error was detected */116#define J9MODRON_SLOT_ITERATOR_RECOVERABLE_ERROR ((UDATA)0x00000002) /** < Indicates that a recoverable error was detected */117/** @} */118119/**120* Error codes returned to the iterator methods by helper utilities.121* @anchor GCCheckWalkStageErrorCodes122* @name Error Codes123* @{124*/125/* Error codes applicable to all stages */126#define J9MODRON_GCCHK_RC_OK ((UDATA)0)127#define J9MODRON_GCCHK_RC_UNALIGNED ((UDATA)1)128#define J9MODRON_GCCHK_RC_DOUBLE_ARRAY_UNALIGNED ((UDATA)2)129#define J9MODRON_GCCHK_RC_NOT_IN_OBJECT_REGION ((UDATA)3)130#define J9MODRON_GCCHK_RC_NOT_FOUND ((UDATA)4)131#define J9MODRON_GCCHK_RC_INVALID_RANGE ((UDATA)5)132#define J9MODRON_GCCHK_RC_STACK_OBJECT ((UDATA) 6)133#define J9MODRON_GCCHK_RC_DEAD_OBJECT ((UDATA) 25)134#define J9MODRON_GCCHK_RC_J9CLASS_HEADER_INVALID ((UDATA) 26)135#define J9MODRON_GCCHK_RC_OBJECT_SLOT_POINTS_TO_J9CLASS ((UDATA) 41)136137/* Special error codes for when J9MODRON_GCCHK_VERIFY_CLASS_SLOT is set (all stages)*/138#define J9MODRON_GCCHK_RC_NULL_CLASS_POINTER ((UDATA)7)139#define J9MODRON_GCCHK_RC_CLASS_POINTER_UNALIGNED ((UDATA)8)140#define J9MODRON_GCCHK_RC_CLASS_NOT_FOUND ((UDATA)9)141#define J9MODRON_GCCHK_RC_CLASS_INVALID_RANGE ((UDATA)10)142#define J9MODRON_GCCHK_RC_CLASS_POINTER_NOT_JLCLASS ((UDATA)11)143#define J9MODRON_GCCHK_RC_CLASS_STACK_OBJECT ((UDATA) 12)144#define J9MODRON_GCCHK_RC_CLASS_OBJECT_NOT_JLCLASS ((UDATA) 27)145#define J9MODRON_GCCHK_RC_CLASS_IS_UNDEAD ((UDATA) 29)146#define J9MODRON_GCCHK_RC_CLASS_STATICS_FIELD_POINTS_WRONG_OBJECT ((UDATA) 30)147#define J9MODRON_GCCHK_RC_CLASS_HOT_SWAPPED_POINTS_TO_STATICS ((UDATA) 31)148#define J9MODRON_GCCHK_RC_CLASS_STATICS_REFERENCE_IS_NOT_IN_SCANNING_RANGE ((UDATA) 32)149#define J9MODRON_GCCHK_RC_CLASS_STATICS_WRONG_NUMBER_OF_REFERENCES ((UDATA) 33)150/* obsolete code 35 */151/* obsolete code 36 */152/* obsolete code 37 */153#define J9MODRON_GCCHK_RC_CLASS_HOT_SWAPPED_FOR_ARRAY ((UDATA) 39)154#define J9MODRON_GCCHK_RC_REPLACED_CLASS_HAS_NO_HOTSWAP_FLAG ((UDATA) 40)155#define J9MODRON_GCCHK_RC_CLASS_IS_UNLOADED ((UDATA) 48)156157/* Special error codes for indexable data address field dataAddr checks */158#define J9MODRON_GCCHK_RC_INVALID_INDEXABLE_DATA_ADDRESS ((UDATA) 34)159160/* Special error codes for when J9MODRON_GCCHK_VERIFY_FLAGS is set (all stages)*/161#define J9MODRON_GCCHK_RC_INVALID_FLAGS ((UDATA)13)162#define J9MODRON_GCCHK_RC_OLD_SEGMENT_INVALID_FLAGS ((UDATA)14)163#define J9MODRON_GCCHK_RC_NEW_SEGMENT_INVALID_FLAGS ((UDATA)15)164165/* Error codes applicable only to stage_object_heap */166#define J9MODRON_GCCHK_RC_DEAD_OBJECT_SIZE ((UDATA)16)167#define J9MODRON_GCCHK_RC_NEW_POINTER_NOT_REMEMBERED ((UDATA)17)168#define J9MODRON_GCCHK_RC_DEAD_OBJECT_SIZE_NOT_ALIGNED ((UDATA)44)169#define J9MODRON_GCCHK_RC_DEAD_OBJECT_NEXT_IS_NOT_HOLE ((UDATA)45)170#define J9MODRON_GCCHK_RC_DEAD_OBJECT_NEXT_IS_NOT_IN_REGION ((UDATA)46)171#define J9MODRON_GCCHK_RC_DEAD_OBJECT_NEXT_IS_POINTED_INSIDE ((UDATA)47)172173/* Error codes applicable only to stage_remembered_set */174#define J9MODRON_GCCHK_RC_REMEMBERED_SET_WRONG_SEGMENT ((UDATA)18)175#define J9MODRON_GCCHK_RC_REMEMBERED_SET_FLAGS ((UDATA)19)176#define J9MODRON_GCCHK_RC_REMEMBERED_SET_OLD_OBJECT ((UDATA)20)177178/* Deprecated error codes applicable to puddle flags */179#define J9MODRON_GCCHK_RC_UNUSED_21 ((UDATA)21)180#define J9MODRON_GCCHK_RC_UNUSED_22 ((UDATA)22)181182/* Error codes applicable for card-marking remembered set */183#define J9MODRON_GCCHK_RC_HEAP_OBJECT_REMEMBERED ((UDATA)23)184#define J9MODRON_GCCHK_RC_NEW_POINTER_NOT_REMEMBERED_IN_CARD_TABLE ((UDATA)24)185186/* Error codes applicable for scopes */187#define J9MODRON_GCCHK_RC_INTERNAL_POINTER_NOT_IN_SCOPE ((UDATA)28)188189/* Error codes for instances of java.util.concurrent.locks.AbstractOwnableSynchronizer */190#define J9MODRON_GCCHK_RC_OWNABLE_SYNCHRONIZER_INVALID_CLASS ((UDATA)38)191#define J9MODRON_GCCHK_OWNABLE_SYNCHRONIZER_OBJECT_IS_NOT_ATTACHED_TO_THE_LIST ((UDATA)42)192#define J9MODRON_GCCHK_OWNABLE_SYNCHRONIZER_LIST_HAS_CIRCULAR_REFERENCE ((UDATA)43)193194/** @} Error codes */195196/**197* What stage of GC invoked the check.198* @note If you add to this enum, you MUST add a corresponding entry in invokedByStrings[]199*/200typedef enum {201invocation_unknown, /**< Invocation unknown */202invocation_global_start, /**< The check was invoked at the start of a global GC */203invocation_global_end, /**< The check was invoked at the end of a global GC */204invocation_global_sweep_start, /**< The action was invoked at the start of the sweep phase of a global GC */205invocation_global_sweep_end, /**< The action was invoked at the end of the sweep phase of a global GC */206invocation_local_start, /**< The check was invoked at the start of a local GC */207invocation_local_end, /**< The check was invoked at the end of a local GC */208invocation_scavenger_backout, /**< The check was invoked after a scavenger (local GC) backout operation */209invocation_rememberedset_overflow, /**< The check was invoked when remembered set overflow was detected */210invocation_manual, /**< The check was manually invoked using J9HOOK_INVOKE_GC_CHECK (see @ref hookInvokeGCCheck) */211invocation_debugger /**< The check was triggered from the debugger extensions (windbg or gcc) */212} GCCheckInvokedBy;213214/**215* Extensions used by GCCheck hooks.216*/217typedef struct GCCHK_Extensions {218void *checkEngine; /**< The check engine */219void *checkCycle; /**< The command-line check cycle */220UDATA gcInterval;221UDATA globalGcInterval;222UDATA globalGcCount;223UDATA gcStartIndex;224#if defined(J9VM_GC_MODRON_SCAVENGER)225UDATA localGcInterval;226UDATA localGcCount;227#endif /* J9VM_GC_MODRON_SCAVENGER */228} GCCHK_Extensions;229#endif /* CHECKBASE_HPP_ */230231232233