Path: blob/master/runtime/gc_verbose_old/VerboseTraceOutput.cpp
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#include "j9cfg.h"2425#include "VerboseTraceOutput.hpp"26#include "VerboseEvent.hpp"27#include "GCExtensions.hpp"28#include "VerboseBuffer.hpp"29#include "EnvironmentBase.hpp"30#include <string.h>3132#define _UTE_STATIC_33#include "ut_j9vgc.h"3435#define INPUT_STRING_SIZE 23636#define INDENT_SPACER " "3738/**39* Formats and output data.40* Called by events, formats the data passed into verbose form and outputs it.41* @param indent The current level of indentation.42* @param format String to format the data into.43*/44void45MM_VerboseTraceOutput::formatAndOutput(J9VMThread *vmThread, UDATA indent, const char *format, ...)46{47char inputString[INPUT_STRING_SIZE];48char localBuf[256];49va_list args;5051PORT_ACCESS_FROM_VMC(vmThread);5253localBuf[0] = '\0';54for(UDATA i=0; i < indent; i++) {55strcat(localBuf, INDENT_SPACER);56}5758va_start(args, format);59j9str_vprintf(inputString, INPUT_STRING_SIZE, format, args);60va_end(args);6162strcat(localBuf, inputString);6364if(!_componentLoaded) {65/* If this is the first time in, we have to load the j9vgc trace component.66* Can't do it at startup because the trace engine initializes too late */67UT_MODULE_LOADED(J9_UTINTERFACE_FROM_VM(vmThread->javaVM));68_componentLoaded = true;69}7071/* Call the tracepoint that outputs the line of verbosegc */72Trc_VGC_Verbosegc(vmThread, localBuf);73}7475/**76* Create a new MM_VerboseTraceOutput instance.77* @return Pointer to the new MM_VerboseTraceOutput.78*/79MM_VerboseTraceOutput *80MM_VerboseTraceOutput::newInstance(MM_EnvironmentBase *env)81{82MM_GCExtensions *extensions = MM_GCExtensions::getExtensions(env->getOmrVM());8384MM_VerboseTraceOutput *agent = (MM_VerboseTraceOutput *)extensions->getForge()->allocate(sizeof(MM_VerboseTraceOutput), MM_AllocationCategory::DIAGNOSTIC, J9_GET_CALLSITE());85if (agent) {86new(agent) MM_VerboseTraceOutput(env);87if(!agent->initialize(env)){88agent->kill(env);89agent = NULL;90}91}92return agent;93}9495/**96* Initializes the MM_VerboseTraceOutput instance.97*/98bool99MM_VerboseTraceOutput::initialize(MM_EnvironmentBase *env)100{101return true;102}103104/**105*/106void107MM_VerboseTraceOutput::endOfCycle(J9VMThread *vmThread)108{109}110111/**112* Closes the agents output stream.113*/114void115MM_VerboseTraceOutput::closeStream(MM_EnvironmentBase *env)116{117}118119120