Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/gc_verbose_old/VerboseTraceOutput.cpp
5985 views
1
2
/*******************************************************************************
3
* Copyright (c) 1991, 2014 IBM Corp. and others
4
*
5
* This program and the accompanying materials are made available under
6
* the terms of the Eclipse Public License 2.0 which accompanies this
7
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
8
* or the Apache License, Version 2.0 which accompanies this distribution and
9
* is available at https://www.apache.org/licenses/LICENSE-2.0.
10
*
11
* This Source Code may also be made available under the following
12
* Secondary Licenses when the conditions for such availability set
13
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
14
* General Public License, version 2 with the GNU Classpath
15
* Exception [1] and GNU General Public License, version 2 with the
16
* OpenJDK Assembly Exception [2].
17
*
18
* [1] https://www.gnu.org/software/classpath/license.html
19
* [2] http://openjdk.java.net/legal/assembly-exception.html
20
*
21
* 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-exception
22
*******************************************************************************/
23
24
#include "j9cfg.h"
25
26
#include "VerboseTraceOutput.hpp"
27
#include "VerboseEvent.hpp"
28
#include "GCExtensions.hpp"
29
#include "VerboseBuffer.hpp"
30
#include "EnvironmentBase.hpp"
31
#include <string.h>
32
33
#define _UTE_STATIC_
34
#include "ut_j9vgc.h"
35
36
#define INPUT_STRING_SIZE 236
37
#define INDENT_SPACER " "
38
39
/**
40
* Formats and output data.
41
* Called by events, formats the data passed into verbose form and outputs it.
42
* @param indent The current level of indentation.
43
* @param format String to format the data into.
44
*/
45
void
46
MM_VerboseTraceOutput::formatAndOutput(J9VMThread *vmThread, UDATA indent, const char *format, ...)
47
{
48
char inputString[INPUT_STRING_SIZE];
49
char localBuf[256];
50
va_list args;
51
52
PORT_ACCESS_FROM_VMC(vmThread);
53
54
localBuf[0] = '\0';
55
for(UDATA i=0; i < indent; i++) {
56
strcat(localBuf, INDENT_SPACER);
57
}
58
59
va_start(args, format);
60
j9str_vprintf(inputString, INPUT_STRING_SIZE, format, args);
61
va_end(args);
62
63
strcat(localBuf, inputString);
64
65
if(!_componentLoaded) {
66
/* If this is the first time in, we have to load the j9vgc trace component.
67
* Can't do it at startup because the trace engine initializes too late */
68
UT_MODULE_LOADED(J9_UTINTERFACE_FROM_VM(vmThread->javaVM));
69
_componentLoaded = true;
70
}
71
72
/* Call the tracepoint that outputs the line of verbosegc */
73
Trc_VGC_Verbosegc(vmThread, localBuf);
74
}
75
76
/**
77
* Create a new MM_VerboseTraceOutput instance.
78
* @return Pointer to the new MM_VerboseTraceOutput.
79
*/
80
MM_VerboseTraceOutput *
81
MM_VerboseTraceOutput::newInstance(MM_EnvironmentBase *env)
82
{
83
MM_GCExtensions *extensions = MM_GCExtensions::getExtensions(env->getOmrVM());
84
85
MM_VerboseTraceOutput *agent = (MM_VerboseTraceOutput *)extensions->getForge()->allocate(sizeof(MM_VerboseTraceOutput), MM_AllocationCategory::DIAGNOSTIC, J9_GET_CALLSITE());
86
if (agent) {
87
new(agent) MM_VerboseTraceOutput(env);
88
if(!agent->initialize(env)){
89
agent->kill(env);
90
agent = NULL;
91
}
92
}
93
return agent;
94
}
95
96
/**
97
* Initializes the MM_VerboseTraceOutput instance.
98
*/
99
bool
100
MM_VerboseTraceOutput::initialize(MM_EnvironmentBase *env)
101
{
102
return true;
103
}
104
105
/**
106
*/
107
void
108
MM_VerboseTraceOutput::endOfCycle(J9VMThread *vmThread)
109
{
110
}
111
112
/**
113
* Closes the agents output stream.
114
*/
115
void
116
MM_VerboseTraceOutput::closeStream(MM_EnvironmentBase *env)
117
{
118
}
119
120