Skip to content

Commit 4b0aec7

Browse files
olpawadinn
authored andcommitted
Support hierarchical logging
1 parent 259171c commit 4b0aec7

31 files changed

+1292
-988
lines changed

substratevm/mx.substratevm/suite.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,9 @@
604604
"com.oracle.objectfile" : {
605605
"subDir": "src",
606606
"sourceDirs" : ["src"],
607-
"dependencies" : [],
607+
"dependencies" : [
608+
"compiler:GRAAL"
609+
],
608610
"checkstyle" : "com.oracle.svm.hosted",
609611
"javaCompliance" : "8+",
610612
"annotationProcessors" : ["compiler:GRAAL_PROCESSOR"],
@@ -920,7 +922,9 @@
920922
"dependencies": [
921923
"com.oracle.objectfile"
922924
],
923-
},
925+
"distDependencies": [
926+
"compiler:GRAAL",
927+
], },
924928

925929
"GRAAL_HOTSPOT_LIBRARY": {
926930
"subDir": "src",
Lines changed: 233 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,233 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN" "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
3+
4+
<!--
5+
This configuration file was written by the eclipse-cs plugin configuration editor
6+
-->
7+
<!--
8+
Checkstyle-Configuration: Checks
9+
Description: none
10+
-->
11+
<module name="Checker">
12+
<property name="severity" value="error"/>
13+
<module name="TreeWalker">
14+
<module name="AvoidStarImport">
15+
<property name="allowClassImports" value="false"/>
16+
<property name="allowStaticMemberImports" value="false"/>
17+
</module>
18+
<property name="tabWidth" value="4"/>
19+
<module name="JavadocStyle">
20+
<property name="checkHtml" value="false"/>
21+
</module>
22+
<module name="LocalFinalVariableName"/>
23+
<module name="LocalVariableName"/>
24+
<module name="MemberName">
25+
<property name="format" value="^(([a-z][a-zA-Z0-9]*$)|(_[A-Z][a-zA-Z0-9]*_[a-z][a-zA-Z0-9]*$))"/>
26+
</module>
27+
<module name="MethodName"/>
28+
<module name="PackageName"/>
29+
<module name="ParameterName"/>
30+
<module name="TypeName">
31+
<property name="format" value="^[A-Z][_a-zA-Z0-9]*$"/>
32+
</module>
33+
<module name="RedundantImport"/>
34+
<module name="UnusedImports"/>
35+
<module name="LineLength">
36+
<property name="max" value="250"/>
37+
</module>
38+
<module name="MethodParamPad"/>
39+
<module name="NoWhitespaceAfter">
40+
<property name="tokens" value="ARRAY_INIT,BNOT,DEC,DOT,INC,LNOT,UNARY_MINUS,UNARY_PLUS"/>
41+
</module>
42+
<module name="NoWhitespaceBefore">
43+
<property name="tokens" value="SEMI,POST_DEC,POST_INC"/>
44+
</module>
45+
<module name="NoWhitespaceBefore">
46+
<property name="tokens" value="DOT"/>
47+
<property name="allowLineBreaks" value="true"/>
48+
</module>
49+
<module name="ParenPad"/>
50+
<module name="TypecastParenPad">
51+
<property name="tokens" value="RPAREN,TYPECAST"/>
52+
</module>
53+
<module name="WhitespaceAfter"/>
54+
<module name="WhitespaceAround">
55+
<property name="tokens" value="ASSIGN,BAND,BAND_ASSIGN,BOR,BOR_ASSIGN,BSR,BSR_ASSIGN,BXOR,BXOR_ASSIGN,COLON,DIV,DIV_ASSIGN,EQUAL,GE,GT,LAND,LE,LITERAL_ASSERT,LITERAL_CATCH,LITERAL_DO,LITERAL_ELSE,LITERAL_FINALLY,LITERAL_FOR,LITERAL_IF,LITERAL_RETURN,LITERAL_SYNCHRONIZED,LITERAL_TRY,LITERAL_WHILE,LOR,LT,MINUS,MINUS_ASSIGN,MOD,MOD_ASSIGN,NOT_EQUAL,PLUS,PLUS_ASSIGN,QUESTION,SL,SLIST,SL_ASSIGN,SR,SR_ASSIGN,STAR,STAR_ASSIGN,LITERAL_ASSERT,TYPE_EXTENSION_AND"/>
56+
</module>
57+
<module name="RedundantModifier"/>
58+
<module name="AvoidNestedBlocks">
59+
<property name="allowInSwitchCase" value="true"/>
60+
</module>
61+
<module name="EmptyBlock">
62+
<property name="option" value="text"/>
63+
<property name="tokens" value="LITERAL_DO,LITERAL_ELSE,LITERAL_FINALLY,LITERAL_IF,LITERAL_TRY,LITERAL_WHILE,STATIC_INIT"/>
64+
</module>
65+
<module name="LeftCurly"/>
66+
<module name="NeedBraces"/>
67+
<module name="RightCurly"/>
68+
<module name="EmptyStatement"/>
69+
<module name="HiddenField">
70+
<property name="severity" value="ignore"/>
71+
<property name="ignoreConstructorParameter" value="true"/>
72+
<metadata name="net.sf.eclipsecs.core.lastEnabledSeverity" value="inherit"/>
73+
</module>
74+
<module name="FinalClass"/>
75+
<module name="HideUtilityClassConstructor">
76+
<property name="severity" value="ignore"/>
77+
<metadata name="net.sf.eclipsecs.core.lastEnabledSeverity" value="inherit"/>
78+
</module>
79+
<module name="ArrayTypeStyle"/>
80+
<module name="UpperEll"/>
81+
<module name="FallThrough"/>
82+
<module name="FinalLocalVariable">
83+
<property name="severity" value="ignore"/>
84+
<metadata name="net.sf.eclipsecs.core.lastEnabledSeverity" value="inherit"/>
85+
</module>
86+
<module name="MultipleVariableDeclarations"/>
87+
<module name="StringLiteralEquality">
88+
<property name="severity" value="error"/>
89+
</module>
90+
<module name="SuperFinalize"/>
91+
<module name="UnnecessaryParentheses">
92+
<property name="severity" value="ignore"/>
93+
<metadata name="net.sf.eclipsecs.core.lastEnabledSeverity" value="inherit"/>
94+
</module>
95+
<module name="Indentation">
96+
<property name="severity" value="ignore"/>
97+
<metadata name="net.sf.eclipsecs.core.lastEnabledSeverity" value="inherit"/>
98+
</module>
99+
<module name="StaticVariableName">
100+
<property name="format" value="^[A-Za-z][a-zA-Z0-9]*$"/>
101+
</module>
102+
<module name="EmptyForInitializerPad"/>
103+
<module name="EmptyForIteratorPad"/>
104+
<module name="ModifierOrder"/>
105+
<module name="DefaultComesLast"/>
106+
<module name="InnerAssignment">
107+
<property name="severity" value="ignore"/>
108+
<metadata name="net.sf.eclipsecs.core.lastEnabledSeverity" value="inherit"/>
109+
</module>
110+
<module name="ModifiedControlVariable"/>
111+
<module name="MutableException">
112+
<property name="severity" value="ignore"/>
113+
<metadata name="net.sf.eclipsecs.core.lastEnabledSeverity" value="inherit"/>
114+
</module>
115+
<module name="ParameterAssignment">
116+
<property name="severity" value="ignore"/>
117+
<metadata name="net.sf.eclipsecs.core.lastEnabledSeverity" value="inherit"/>
118+
</module>
119+
<module name="RegexpSinglelineJava">
120+
<metadata name="net.sf.eclipsecs.core.comment" value="Illegal trailing whitespace(s) at the end of the line."/>
121+
<property name="format" value="\s$"/>
122+
<property name="message" value="Illegal trailing whitespace(s) at the end of the line."/>
123+
<property name="ignoreComments" value="true"/>
124+
<metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="Checks for trailing spaces at the end of a line"/>
125+
</module>
126+
<module name="RegexpSinglelineJava">
127+
<metadata name="net.sf.eclipsecs.core.comment" value="illegal space before a comma"/>
128+
<property name="format" value=" ,"/>
129+
<property name="message" value="illegal space before a comma"/>
130+
<property name="ignoreComments" value="true"/>
131+
<metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="Checks for whitespace before a comma."/>
132+
<metadata name="com.atlassw.tools.eclipse.checkstyle.customMessage" value="Illegal whitespace before a comma."/>
133+
</module>
134+
<module name="RegexpSinglelineJava">
135+
<property name="format" value="[^\x00-\x7F]"/>
136+
<property name="message" value="Only use ASCII characters."/>
137+
</module>
138+
<module name="RegexpSinglelineJava">
139+
<property name="format" value="new (Hashtable|Vector|Stack|StringBuffer)[^\w]"/>
140+
<property name="message" value="Don't use old synchronized collection classes"/>
141+
</module>
142+
<module name="SuppressionCommentFilter">
143+
<property name="offCommentFormat" value="Checkstyle: stop constant name check"/>
144+
<property name="onCommentFormat" value="Checkstyle: resume constant name check"/>
145+
<property name="checkFormat" value="ConstantNameCheck"/>
146+
<metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="Allow non-conforming constant names"/>
147+
</module>
148+
<module name="SuppressionCommentFilter">
149+
<property name="offCommentFormat" value="Checkstyle: stop method name check"/>
150+
<property name="onCommentFormat" value="Checkstyle: resume method name check"/>
151+
<property name="checkFormat" value="MethodName"/>
152+
<property name="checkC" value="false"/>
153+
<metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="Disable method name checks"/>
154+
</module>
155+
<module name="SuppressionCommentFilter">
156+
<property name="offCommentFormat" value="CheckStyle: stop parameter assignment check"/>
157+
<property name="onCommentFormat" value="CheckStyle: resume parameter assignment check"/>
158+
<property name="checkFormat" value="ParameterAssignment"/>
159+
<property name="checkC" value="false"/>
160+
<metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="Disable Parameter Assignment"/>
161+
</module>
162+
<module name="SuppressionCommentFilter">
163+
<property name="offCommentFormat" value="Checkstyle: stop final variable check"/>
164+
<property name="onCommentFormat" value="Checkstyle: resume final variable check"/>
165+
<property name="checkFormat" value="FinalLocalVariable"/>
166+
<metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="Disable final variable checks"/>
167+
</module>
168+
<module name="SuppressionCommentFilter">
169+
<property name="offCommentFormat" value="CheckStyle: stop inner assignment check"/>
170+
<property name="onCommentFormat" value="CheckStyle: resume inner assignment check"/>
171+
<property name="checkFormat" value="InnerAssignment"/>
172+
<metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="Disable inner assignment checks"/>
173+
</module>
174+
<module name="SuppressionCommentFilter">
175+
<property name="offCommentFormat" value="Checkstyle: stop field name check"/>
176+
<property name="onCommentFormat" value="Checkstyle: resume field name check"/>
177+
<property name="checkFormat" value="MemberName"/>
178+
<property name="checkC" value="false"/>
179+
<metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="Disable field name checks"/>
180+
</module>
181+
<module name="SuppressionCommentFilter">
182+
<property name="offCommentFormat" value="CheckStyle: stop header check"/>
183+
<property name="onCommentFormat" value="CheckStyle: resume header check"/>
184+
<property name="checkFormat" value=".*Header"/>
185+
<metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="Disable header checks"/>
186+
</module>
187+
<module name="SuppressionCommentFilter">
188+
<property name="offCommentFormat" value="CheckStyle: stop line length check"/>
189+
<property name="onCommentFormat" value="CheckStyle: resume line length check"/>
190+
<property name="checkFormat" value="LineLength"/>
191+
</module>
192+
<module name="SuppressionCommentFilter">
193+
<property name="offCommentFormat" value="CheckStyle: start generated"/>
194+
<property name="onCommentFormat" value="CheckStyle: stop generated"/>
195+
<property name="checkFormat" value=".*Name|.*LineLength"/>
196+
</module>
197+
<module name="SuppressionCommentFilter">
198+
<metadata name="net.sf.eclipsecs.core.comment" value="allow / disallow reflection usage"/>
199+
<property name="offCommentFormat" value="Checkstyle: allow reflection"/>
200+
<property name="onCommentFormat" value="Checkstyle: disallow reflection"/>
201+
<property name="checkFormat" value="IllegalImport"/>
202+
</module>
203+
<module name="SuppressionCommentFilter">
204+
<metadata name="net.sf.eclipsecs.core.comment" value="allow / disallow synchronization"/>
205+
<property name="offCommentFormat" value="Checkstyle: allow synchronization"/>
206+
<property name="onCommentFormat" value="Checkstyle: disallow synchronization"/>
207+
<property name="checkFormat" value="IllegalToken"/>
208+
</module>
209+
</module>
210+
<module name="RegexpHeader">
211+
<property name="header" value="/\*\n \* Copyright \(c\) (20[0-9][0-9], )?20[0-9][0-9], Oracle and/or its affiliates\. All rights reserved\.\n \* Copyright \(c\) (20[0-9][0-9], )?20[0-9][0-9], .*\. All rights reserved\.\n \* Intel Math Library \(LIBM\) Source Code\n \* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER\.\n \*\n \* This code is free software; you can redistribute it and/or modify it\n \* under the terms of the GNU General Public License version 2 only, as\n \* published by the Free Software Foundation\. Oracle designates this\n \* particular file as subject to the &quot;Classpath&quot; exception as provided\n \* by Oracle in the LICENSE file that accompanied this code.\n \*\n \* This code is distributed in the hope that it will be useful, but WITHOUT\n \* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\n \* FITNESS FOR A PARTICULAR PURPOSE\. See the GNU General Public License\n \* version 2 for more details \(a copy is included in the LICENSE file that\n \* accompanied this code\)\.\n \*\n \* You should have received a copy of the GNU General Public License version\n \* 2 along with this work; if not, write to the Free Software Foundation,\n \* Inc\., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA\.\n \*\n \* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA\n \* or visit www\.oracle\.com if you need additional information or have any\n \* questions\.\n \*/\n"/>
212+
<property name="multiLines" value="3,4"/>
213+
<property name="fileExtensions" value="java"/>
214+
</module>
215+
<module name="FileTabCharacter">
216+
<property name="severity" value="error"/>
217+
<property name="fileExtensions" value="java"/>
218+
</module>
219+
<module name="NewlineAtEndOfFile">
220+
<property name="lineSeparator" value="lf"/>
221+
</module>
222+
<module name="Translation"/>
223+
<module name="RegexpMultiline">
224+
<metadata name="net.sf.eclipsecs.core.comment" value="illegal Windows line ending"/>
225+
<property name="format" value="\r\n"/>
226+
<property name="message" value="illegal Windows line ending"/>
227+
</module>
228+
<module name="SuppressWithPlainTextCommentFilter">
229+
<property name="offCommentFormat" value="Checkstyle: stop"/>
230+
<property name="onCommentFormat" value="Checkstyle: resume"/>
231+
<metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="Disable all checks"/>
232+
</module>
233+
</module>

substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/ObjectFile.java

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import java.util.Map;
4444
import java.util.Set;
4545
import java.util.TreeSet;
46+
import java.util.function.Consumer;
4647
import java.util.stream.StreamSupport;
4748

4849
import com.oracle.objectfile.debuginfo.DebugInfoProvider;
@@ -51,6 +52,7 @@
5152
import com.oracle.objectfile.pecoff.PECoffObjectFile;
5253

5354
import sun.nio.ch.DirectBuffer;
55+
import org.graalvm.compiler.debug.DebugContext;
5456

5557
/**
5658
* Abstract superclass for object files. An object file is a binary container for sections,
@@ -1737,4 +1739,50 @@ public final SymbolTable getOrCreateSymbolTable() {
17371739
return createSymbolTable();
17381740
}
17391741
}
1742+
1743+
/**
1744+
* Temporary storage for a debug context installed in a nested scope under a call. to
1745+
* {@link #withDebugContext}
1746+
*/
1747+
private DebugContext debugContext = null;
1748+
1749+
/**
1750+
* Allows a task to be executed with a debug context in a named subscope bound to the object
1751+
* file and accessible to code executed during the lifetime of the task. Invoked code may obtain
1752+
* access to the debug context using method {@link #debugContext}.
1753+
*
1754+
* @param context a context to be bound to the object file for the duration of the task
1755+
* execution.
1756+
* @param scopeName a name to be used to define a subscope current while the task is being
1757+
* executed.
1758+
* @param task a task to be executed while the context is bound to the object file.
1759+
*/
1760+
@SuppressWarnings("try")
1761+
public void withDebugContext(DebugContext context, String scopeName, Runnable task) {
1762+
try (DebugContext.Scope s = context.scope(scopeName)) {
1763+
this.debugContext = context;
1764+
task.run();
1765+
} catch (Throwable e) {
1766+
throw debugContext.handle(e);
1767+
} finally {
1768+
debugContext = null;
1769+
}
1770+
}
1771+
1772+
/**
1773+
* Allows a consumer to retrieve the debug context currently bound to this object file. This
1774+
* method must only called underneath an invocation of method {@link #withDebugContext}.
1775+
*
1776+
* @param scopeName a name to be used to define a subscope current while the consumer is active.
1777+
* @param action an action parameterised by the debug context.
1778+
*/
1779+
@SuppressWarnings("try")
1780+
public void debugContext(String scopeName, Consumer<DebugContext> action) {
1781+
assert debugContext != null;
1782+
try (DebugContext.Scope s = debugContext.scope(scopeName)) {
1783+
action.accept(debugContext);
1784+
} catch (Throwable e) {
1785+
throw debugContext.handle(e);
1786+
}
1787+
}
17401788
}

substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/debugentry/ClassEntry.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright (c) 2020, 2020, Oracle and/or its affiliates. All rights reserved.
3-
* Copyright (c) 2020, Red Hat Inc. All rights reserved.
3+
* Copyright (c) 2020, 2020, Red Hat Inc. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
66
* This code is free software; you can redistribute it and/or modify it
@@ -44,7 +44,7 @@ public class ClassEntry {
4444
/**
4545
* details of the associated file.
4646
*/
47-
FileEntry fileEntry;
47+
private FileEntry fileEntry;
4848
/**
4949
* a list recording details of all primary ranges included in this class sorted by ascending
5050
* address range.
@@ -111,14 +111,12 @@ public ClassEntry(String className, FileEntry fileEntry) {
111111
this.totalSize = -1;
112112
}
113113

114-
public PrimaryEntry addPrimary(Range primary, List<DebugFrameSizeChange> frameSizeInfos, int frameSize) {
114+
public void addPrimary(Range primary, List<DebugFrameSizeChange> frameSizeInfos, int frameSize) {
115115
if (primaryIndex.get(primary) == null) {
116116
PrimaryEntry primaryEntry = new PrimaryEntry(primary, frameSizeInfos, frameSize, this);
117117
primaryEntries.add(primaryEntry);
118118
primaryIndex.put(primary, primaryEntry);
119-
return primaryEntry;
120119
}
121-
return null;
122120
}
123121

124122
public void addSubRange(Range subrange, FileEntry subFileEntry) {
@@ -167,6 +165,7 @@ public String getFileName() {
167165
}
168166
}
169167

168+
@SuppressWarnings("unused")
170169
String getFullFileName() {
171170
if (fileEntry != null) {
172171
return fileEntry.getFullName();
@@ -175,6 +174,7 @@ String getFullFileName() {
175174
}
176175
}
177176

177+
@SuppressWarnings("unused")
178178
String getDirName() {
179179
if (fileEntry != null) {
180180
return fileEntry.getPathName();
@@ -184,14 +184,14 @@ String getDirName() {
184184
}
185185

186186
public void setCUIndex(int cuIndex) {
187-
// should only get set once to a non-negative value
187+
// Should only get set once to a non-negative value.
188188
assert cuIndex >= 0;
189189
assert this.cuIndex == -1;
190190
this.cuIndex = cuIndex;
191191
}
192192

193193
public int getCUIndex() {
194-
// should have been set before being read
194+
// Should have been set before being read.
195195
assert cuIndex >= 0;
196196
return cuIndex;
197197
}

substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/debugentry/DirEntry.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright (c) 2020, 2020, Oracle and/or its affiliates. All rights reserved.
3-
* Copyright (c) 2020, Red Hat Inc. All rights reserved.
3+
* Copyright (c) 2020, 2020, Red Hat Inc. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
66
* This code is free software; you can redistribute it and/or modify it

0 commit comments

Comments
 (0)