Path: blob/master/runtime/gc_verbose_java/VerboseHandlerJava.cpp
5985 views
/*******************************************************************************1* Copyright (c) 1991, 2020 IBM Corp. and others2*3* This program and the accompanying materials are made available under4* the terms of the Eclipse Public License 2.0 which accompanies this5* distribution and is available at https://www.eclipse.org/legal/epl-2.0/6* or the Apache License, Version 2.0 which accompanies this distribution and7* is available at https://www.apache.org/licenses/LICENSE-2.0.8*9* This Source Code may also be made available under the following10* Secondary Licenses when the conditions for such availability set11* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU12* General Public License, version 2 with the GNU Classpath13* Exception [1] and GNU General Public License, version 2 with the14* OpenJDK Assembly Exception [2].15*16* [1] https://www.gnu.org/software/classpath/license.html17* [2] http://openjdk.java.net/legal/assembly-exception.html18*19* 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-exception20*******************************************************************************/2122/* Temporary file to make compilers happy */2324#include "j9.h"25#include "j9cfg.h"26#include "mmhook.h"2728#include "VerboseHandlerJava.hpp"29#include "EnvironmentBase.hpp"30#include "VerboseManager.hpp"31#include "VerboseHandlerOutput.hpp"32#include "VerboseWriterChain.hpp"33#include "GCExtensions.hpp"34#include "FinalizeListManager.hpp"35#include "VerboseBuffer.hpp"3637void38MM_VerboseHandlerJava::outputFinalizableInfo(MM_VerboseManager *manager, MM_EnvironmentBase *env, UDATA indent)39{40MM_GCExtensions *extensions = MM_GCExtensions::getExtensions(env);41GC_FinalizeListManager *finalizeListManager = extensions->finalizeListManager;4243UDATA systemCount = finalizeListManager->getSystemCount();44UDATA defaultCount = finalizeListManager->getDefaultCount();45UDATA referenceCount = finalizeListManager->getReferenceCount();46UDATA classloaderCount = finalizeListManager->getClassloaderCount();4748if((0 != systemCount) || (0 != defaultCount) || (0 != referenceCount) || (0 != classloaderCount)) {49manager->getWriterChain()->formatAndOutput(env, indent, "<pending-finalizers system=\"%zu\" default=\"%zu\" reference=\"%zu\" classloader=\"%zu\" />", systemCount, defaultCount, referenceCount, classloaderCount);50}51}5253bool54MM_VerboseHandlerJava::getThreadName(char *buf, UDATA bufLen, OMR_VMThread *omrThread)55{56PORT_ACCESS_FROM_JAVAVM(((J9VMThread*)omrThread->_language_vmthread)->javaVM);57char* threadName = getOMRVMThreadName(omrThread);58UDATA threadNameLength = strlen(threadName);59UDATA escapeConsumed = escapeXMLString(OMRPORT_FROM_J9PORT(PORTLIB), buf, bufLen, threadName, strlen(threadName));60bool consumedEntireString = (escapeConsumed >= threadNameLength);61releaseOMRVMThreadName(omrThread);62return consumedEntireString;63}6465void66MM_VerboseHandlerJava::writeVmArgs(MM_EnvironmentBase* env, MM_VerboseBuffer* buffer, J9JavaVM *vm)67{68PORT_ACCESS_FROM_JAVAVM(vm);69JavaVMInitArgs* vmArgs = vm->vmArgsArray->actualVMArgs;70buffer->formatAndOutput(env, 1, "<vmargs>");71for (jint i = 0; i < vmArgs->nOptions; ++i) {72char escapedXMLString[128];73UDATA optLen = strlen(vmArgs->options[i].optionString);74UDATA escapeConsumed = escapeXMLString(OMRPORT_FROM_J9PORT(PORTLIB), escapedXMLString, sizeof(escapedXMLString), vmArgs->options[i].optionString, optLen);75const char* dots = (escapeConsumed < optLen) ? "..." : "";76if (NULL == vmArgs->options[i].extraInfo) {77buffer->formatAndOutput(env, 2, "<vmarg name=\"%s%s\" />", escapedXMLString, dots);78} else {79buffer->formatAndOutput(env, 2, "<vmarg name=\"%s%s\" value=\"%p\" />", escapedXMLString, dots, vmArgs->options[i].extraInfo);80}81}82buffer->formatAndOutput(env, 1, "</vmargs>");83}848586