Path: blob/master/runtime/gc_check/CheckError.hpp
5985 views
1/*******************************************************************************2* Copyright (c) 1991, 2014 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(CHECKERROR_HPP_)29#define CHECKERROR_HPP_3031#include "j9.h"32#include "j9cfg.h"3334#include "Base.hpp"35#include "CheckBase.hpp"36#include "CheckCycle.hpp"3738class GC_CheckReporter;39class MM_SublistPuddle;40class MM_UnfinalizedObjectList;41class MM_OwnableSynchronizerObjectList;42class GC_FinalizeListManager;4344enum {45check_type_other = 0,46check_type_object,47check_type_class,48check_type_thread,49check_type_puddle,50check_type_unfinalized,51check_type_finalizable,52check_type_ownable_synchronizer53};545556/**57* Capture information related to an error.58*59* While walking the heap various errors can be detected. This object60* gathers the relevant error information and is passed to61* GC_CheckReporter for displaying.62*63* @todo _object and _slot are not always J9Objects, so we should do the right64* thing for different types, and stop casting everything to J9Object when65* we call this constructor66*67* @see GC_CheckReporter68*69* @ingroup GC_Check70*/71class GC_CheckError : public MM_Base72{73public:74void *_object; /**< The object or structure that is reporting the error */75void *_slot; /**< The slot that is reporting the error */76const void *_stackLocaition; /**< The original location on the stack that reports the error */77GC_Check *_check; /**< The check which triggered the error */78GC_CheckCycle *_cycle; /**< Description of the cycle that triggered the error */79const char *_elementName; /**< String describing the element reporting the error */80UDATA _errorCode; /**< The error to be recorded, see @ref GCCheckWalkStageErrorCodes. */81UDATA _errorNumber; /**< Number of the error encountered */82UDATA _objectType; /**< The type of object */8384private:8586void87initialize(void *object, void *slot, const void *stackLocation, GC_CheckCycle *cycle, GC_Check *check, const char *elementName, UDATA errorCode, UDATA errorNumber, UDATA objectType)88{89_object = object;90_slot = slot;91_stackLocaition = stackLocation;92_cycle = cycle;93_check = check;94_elementName = elementName;95_errorCode = errorCode;96_errorNumber = errorNumber;97_objectType = objectType;98}99100void101initialize(void *object, void *slot, GC_CheckCycle *cycle, GC_Check *check, const char *elementName, UDATA errorCode, UDATA errorNumber, UDATA objectType)102{103initialize(object, slot, NULL, cycle, check, elementName, errorCode, errorNumber, objectType);104}105106void107initialize(void *object, void *slot, GC_CheckCycle *cycle, GC_Check *check, UDATA errorCode, UDATA errorNumber, UDATA objectType)108{109initialize(object, slot, NULL, cycle, check, "", errorCode, errorNumber, objectType);110}111112void113initialize(void *object, void *slot, const void *stackLocation, GC_CheckCycle *cycle, GC_Check *check, UDATA errorCode, UDATA errorNumber, UDATA objectType)114{115initialize(object, slot, stackLocation, cycle, check, "", errorCode, errorNumber, objectType);116}117118void119initialize(void *object, GC_CheckCycle *cycle, GC_Check *check, const char *elementName, UDATA errorCode, UDATA errorNumber, UDATA objectType)120{121initialize(object, NULL, NULL, cycle, check, elementName, errorCode, errorNumber, objectType);122}123124void125initialize(void *object, GC_CheckCycle *cycle, GC_Check *check, UDATA errorCode, UDATA errorNumber, UDATA objectType)126{127initialize(object, NULL, NULL, cycle, check, "", errorCode, errorNumber, objectType);128}129130public:131132/**133* Create a new CheckError object.134*135* @param object the object (not necessarily a java.lang.Object) containing the bad slot136* @param slot the slot where the error was found, or the slot pointing to the object137* where the error was found138* @param invokedBy code indicating how the check was invoked (see @ref GCCheckInvokedBy)139* @param stage the current stage of the check, where the error was found140* @param manualCheckInvocation GCCheckInvokedBy#invocation_manual, if the check was invoked141* manually, and 0 otherwise142* @param elementName a string by which to refer to <code>object</code>, e.g. "Object ", "IObject ", etc.143* @param errorCode what kind of problem was detected (see @ref GCCheckWalkStageErrorCodes)144* @param errorNumber the current number of errors that have occurred, including this one145* @param objectType the type of the object param146*/147GC_CheckError(void *object, void *slot, GC_CheckCycle *cycle, GC_Check *check, const char *elementName, UDATA errorCode, UDATA errorNumber, UDATA objectType)148{149initialize(object, slot, cycle, check, elementName, errorCode, errorNumber, objectType);150}151152/**153* Create a new CheckError object, with a blank elementName.154*/155GC_CheckError(void *object, void *slot, GC_CheckCycle *cycle, GC_Check *check, UDATA errorCode, UDATA errorNumber, UDATA objectType)156{157initialize(object, slot, cycle, check, errorCode, errorNumber, objectType);158}159160/**161* Create a new CheckError object, when the error occurred while referencing162* an object directly on the heap (not through a slot).163*/164GC_CheckError(void *object, GC_CheckCycle *cycle, GC_Check *check, const char *elementName, UDATA errorCode, UDATA errorNumber, UDATA objectType)165{166initialize(object, cycle, check, elementName, errorCode, errorNumber, objectType);167}168169170/**171* Create a new CheckError object, with a blank element name, when the error172* occurred while referencing an object directly on the heap (not through a slot).173*/174GC_CheckError(void *object, GC_CheckCycle *cycle, GC_Check *check, UDATA errorCode, UDATA errorNumber, UDATA objectType)175{176initialize(object, cycle, check, errorCode, errorNumber, objectType);177}178179//////// Constructors for J9Class ////////180181/**182* Full constructor for errors in J9Class183*/184GC_CheckError(J9Class *object, void *slot, GC_CheckCycle *cycle, GC_Check *check, const char *elementName, UDATA errorCode, UDATA errorNumber)185{186initialize((void*)object, slot, cycle, check, elementName, errorCode, errorNumber, check_type_class);187}188189/**190* Create a new CheckError object, with a blank elementName.191*/192GC_CheckError(J9Class *object, void *slot, GC_CheckCycle *cycle, GC_Check *check, UDATA errorCode, UDATA errorNumber)193{194initialize((void*)object, slot, cycle, check, errorCode, errorNumber, check_type_class);195}196197/**198* Create a new CheckError object, when the error occurred while referencing199* an object directly on the heap (not through a slot).200*/201GC_CheckError(J9Class *object, GC_CheckCycle *cycle, GC_Check *check, const char *elementName, UDATA errorCode, UDATA errorNumber)202{203initialize((void*)object, cycle, check, elementName, errorCode, errorNumber, check_type_class);204}205206/**207* Create a new CheckError object, with a blank element name, when the error208* occurred while referencing an object directly on the heap (not through a slot).209*/210GC_CheckError(J9Class *object, GC_CheckCycle *cycle, GC_Check *check, UDATA errorCode, UDATA errorNumber)211{212initialize((void*)object, cycle, check, errorCode, errorNumber, check_type_class);213}214215//////// Constructors for J9VMThread ////////216/**217* Create a new CheckError object, with a blank elementName.218*/219GC_CheckError(J9VMThread *object, J9Object **slot, const void *stackLocation, GC_CheckCycle *cycle, GC_Check *check, UDATA errorCode, UDATA errorNumber)220{221initialize((void*)object, (void*)slot, stackLocation, cycle, check, errorCode, errorNumber, check_type_thread);222}223//////// Constructors for J9Object ////////224225/**226* Full constructor for errors in J9VMThread227*/228GC_CheckError(J9Object *object, fj9object_t *slot, GC_CheckCycle *cycle, GC_Check *check, const char *elementName, UDATA errorCode, UDATA errorNumber)229{230initialize((void*)object, (void*)slot, cycle, check, elementName, errorCode, errorNumber, check_type_object);231}232233/**234* Create a new CheckError object, with a blank elementName.235*/236GC_CheckError(J9Object *object, fj9object_t *slot, GC_CheckCycle *cycle, GC_Check *check, UDATA errorCode, UDATA errorNumber)237{238initialize((void*)object, (void*)slot, cycle, check, errorCode, errorNumber, check_type_object);239}240241/**242* Create a new CheckError object, when the error occurred while referencing243* an object directly on the heap (not through a slot).244*/245GC_CheckError(J9Object *object, GC_CheckCycle *cycle, GC_Check *check, const char *elementName, UDATA errorCode, UDATA errorNumber)246{247initialize((void*)object, cycle, check, elementName, errorCode, errorNumber, check_type_object);248}249250/**251* Create a new CheckError object, with a blank element name, when the error252* occurred while referencing an object directly on the heap (not through a slot).253*/254GC_CheckError(J9Object *object, GC_CheckCycle *cycle, GC_Check *check, UDATA errorCode, UDATA errorNumber)255{256initialize((void*)object, cycle, check, errorCode, errorNumber, check_type_object);257}258259//////// Constructors for MM_SublistPuddle ////////260261/**262* Full constructor for errors in MM_SublistPuddle263*/264GC_CheckError(MM_SublistPuddle *object, J9Object **slot, GC_CheckCycle *cycle, GC_Check *check, const char *elementName, UDATA errorCode, UDATA errorNumber)265{266initialize((void*)object, (void*)slot, cycle, check, elementName, errorCode, errorNumber, check_type_puddle);267}268269/**270* Create a new CheckError object, with a blank elementName.271*/272GC_CheckError(MM_SublistPuddle *object, J9Object **slot, GC_CheckCycle *cycle, GC_Check *check, UDATA errorCode, UDATA errorNumber)273{274initialize((void*)object, (void*)slot, cycle, check, errorCode, errorNumber, check_type_puddle);275}276277/**278* Create a new CheckError object, when the error occurred while referencing279* an object directly on the heap (not through a slot).280*/281GC_CheckError(MM_SublistPuddle *object, GC_CheckCycle *cycle, GC_Check *check, const char *elementName, UDATA errorCode, UDATA errorNumber)282{283initialize((void*)object, cycle, check, elementName, errorCode, errorNumber, check_type_puddle);284}285286/**287* Create a new CheckError object, with a blank element name, when the error288* occurred while referencing an object directly on the heap (not through a slot).289*/290GC_CheckError(MM_SublistPuddle *object, GC_CheckCycle *cycle, GC_Check *check, UDATA errorCode, UDATA errorNumber)291{292initialize((void*)object, cycle, check, errorCode, errorNumber, check_type_puddle);293}294295//////// Constructors for MM_UnfinalizedObjectList ////////296297/**298* Create a new CheckError object, with a blank elementName.299*/300GC_CheckError(MM_UnfinalizedObjectList *object, J9Object **slot, GC_CheckCycle *cycle, GC_Check *check, UDATA errorCode, UDATA errorNumber)301{302initialize((void*)object, (void*)slot, cycle, check, errorCode, errorNumber, check_type_unfinalized);303}304305//////// Constructors for MM_FinalizeListManager ////////306307/**308* Create a new CheckError object, with a blank elementName.309*/310GC_CheckError(GC_FinalizeListManager *object, J9Object **slot, GC_CheckCycle *cycle, GC_Check *check, UDATA errorCode, UDATA errorNumber)311{312initialize((void*)object, (void*)slot, cycle, check, errorCode, errorNumber, check_type_finalizable);313}314315//////// Constructors for MM_OwnableSynchronizerObjectList ////////316317/**318* Create a new CheckError object, with a blank elementName.319*/320GC_CheckError(MM_OwnableSynchronizerObjectList *object, J9Object **slot, GC_CheckCycle *cycle, GC_Check *check, UDATA errorCode, UDATA errorNumber)321{322initialize((void*)object, (void*)slot, cycle, check, errorCode, errorNumber, check_type_ownable_synchronizer);323}324};325326#endif /* CHECKERROR_HPP_ */327328329