Skip to content

Commit d39ce2d

Browse files
committed
Add test
1 parent 051436e commit d39ce2d

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/debug/test/DebugContextTest.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,4 +337,27 @@ public void testDebugConfig() {
337337
Assert.assertTrue(options2.toString().contains("MethodFilter=test"));
338338
Assert.assertTrue(options2.toString().contains("DumpOnError=true"));
339339
}
340+
341+
@Test
342+
public void testIsCountEnabled1() {
343+
EconomicMap<OptionKey<?>, Object> map = EconomicMap.create();
344+
map.put(DebugOptions.Count, "");
345+
OptionValues options = new OptionValues(map);
346+
DebugContext debug = new Builder(options).build();
347+
try (Scope s1 = debug.scope("Scope")) {
348+
Assert.assertTrue(debug.isCountEnabled());
349+
}
350+
}
351+
352+
@Test
353+
public void testIsCountEnabled2() {
354+
EconomicMap<OptionKey<?>, Object> map = EconomicMap.create();
355+
map.put(DebugOptions.Counters, "");
356+
OptionValues options = new OptionValues(map);
357+
DebugContext debug = new Builder(options).build();
358+
try (Scope s1 = debug.scope("Scope")) {
359+
Assert.assertTrue(debug.isCountEnabled());
360+
}
361+
}
362+
340363
}

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/debug/DebugConfigImpl.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,17 +160,15 @@ public PrintStream output() {
160160
}
161161

162162
private boolean isEnabled(DebugContext.Scope scope, DebugFilter filter) {
163-
return getLevel(scope, filter) >= 0;
163+
return getLevel(scope, filter) >= 1;
164164
}
165165

166166
private int getLevel(DebugContext.Scope scope, DebugFilter filter) {
167-
int level;
168167
if (filter == null) {
169168
// null means the value has not been set
170-
level = -1;
171-
} else {
172-
level = filter.matchLevel(scope);
169+
return -1;
173170
}
171+
int level = filter.matchLevel(scope);
174172
if (level >= 0 && !checkMethodFilter(scope)) {
175173
level = -1;
176174
}

0 commit comments

Comments
 (0)