--- a/src/hotspot/share/runtime/globals.hpp Fri Jan 25 14:28:43 2019 -0800
+++ b/src/hotspot/share/runtime/globals.hpp Sat Jan 26 10:34:29 2019 +0900
@@ -140,8 +140,8 @@
// notproduct flags are settable / visible only during development and are not declared in the PRODUCT version
// A flag must be declared with one of the following types:
-// bool, int, uint, intx, uintx, size_t, ccstr, double, or uint64_t.
-// The type "ccstr" is an alias for "const char*" and is used
+// bool, int, uint, intx, uintx, size_t, ccstr, ccstrlist, double, or uint64_t.
+// The type "ccstr" and "ccstrlist" are an alias for "const char*" and is used
// only in this file, because the macrology requires single-token type names.
// Note: Diagnostic options not meant for VM tuning or for product modes.
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/VM.java Fri Jan 25 14:28:43 2019 -0800
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/VM.java Sat Jan 26 10:34:29 2019 +0900
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -130,6 +130,7 @@
private static Type intxType;
private static Type uintxType;
private static Type sizetType;
+ private static Type uint64tType;
private static CIntegerType boolType;
private Boolean sharingEnabled;
private Boolean compressedOopsEnabled;
@@ -231,6 +232,50 @@
return addr.getCIntegerAt(0, sizetType.getSize(), true);
}
+ public boolean isCcstr() {
+ return type.equals("ccstr");
+ }
+
+ public String getCcstr() {
+ if (Assert.ASSERTS_ENABLED) {
+ Assert.that(isCcstr(), "not a ccstr flag!");
+ }
+ return CStringUtilities.getString(addr.getAddressAt(0));
+ }
+
+ public boolean isCcstrlist() {
+ return type.equals("ccstrlist");
+ }
+
+ public String getCcstrlist() {
+ if (Assert.ASSERTS_ENABLED) {
+ Assert.that(isCcstrlist(), "not a ccstrlist flag!");
+ }
+ return CStringUtilities.getString(addr.getAddressAt(0));
+ }
+
+ public boolean isDouble() {
+ return type.equals("double");
+ }
+
+ public double getDouble() {
+ if (Assert.ASSERTS_ENABLED) {
+ Assert.that(isDouble(), "not a double flag!");
+ }
+ return addr.getJDoubleAt(0);
+ }
+
+ public boolean isUint64t() {
+ return type.equals("uint64_t");
+ }
+
+ public long getUint64t() {
+ if (Assert.ASSERTS_ENABLED) {
+ Assert.that(isUint64t(), "not an uint64_t flag!");
+ }
+ return addr.getCIntegerAt(0, uint64tType.getSize(), true);
+ }
+
public String getValue() {
if (isBool()) {
return Boolean.toString(getBool());
@@ -241,11 +286,27 @@
} else if (isIntx()) {
return Long.toString(getIntx());
} else if (isUIntx()) {
- return Long.toString(getUIntx());
+ return Long.toUnsignedString(getUIntx());
} else if (isSizet()) {
- return Long.toString(getSizet());
+ return Long.toUnsignedString(getSizet());
+ } else if (isCcstr()) {
+ var str = getCcstr();
+ if (str != null) {
+ str = "\"" + str + "\"";
+ }
+ return str;
+ } else if (isCcstrlist()) {
+ var str = getCcstrlist();
+ if (str != null) {
+ str = "\"" + str + "\"";
+ }
+ return str;
+ } else if (isDouble()) {
+ return Double.toString(getDouble());
+ } else if (isUint64t()) {
+ return Long.toUnsignedString(getUint64t());
} else {
- return null;
+ throw new WrongTypeException("Unknown type: " + type + " (" + name + ")");
}
}
};
@@ -383,6 +444,7 @@
intxType = db.lookupType("intx");
uintxType = db.lookupType("uintx");
sizetType = db.lookupType("size_t");
+ uint64tType = db.lookupType("uint64_t");
boolType = (CIntegerType) db.lookupType("bool");
minObjAlignmentInBytes = getObjectAlignmentInBytes();
--- a/test/hotspot/jtreg/serviceability/sa/ClhsdbFlags.java Fri Jan 25 14:28:43 2019 -0800
+++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbFlags.java Sat Jan 26 10:34:29 2019 +0900
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -33,6 +33,7 @@
/**
* @test
* @bug 8190198
+ * @bug 8217612
* @summary Test clhsdb flags command
* @requires vm.hasSA
* @library /test/lib
@@ -41,8 +42,8 @@
public class ClhsdbFlags {
- public static void main(String[] args) throws Exception {
- System.out.println("Starting ClhsdbFlags test");
+ public static void runBasicTest() throws Exception {
+ System.out.println("Starting ClhsdbFlags basic test");
LingeredApp theApp = null;
try {
@@ -88,4 +89,54 @@
}
System.out.println("Test PASSED");
}
+
+ public static void runAllTypesTest() throws Exception {
+ System.out.println("Starting ClhsdbFlags all types test");
+
+ LingeredApp theApp = null;
+ try {
+ ClhsdbLauncher test = new ClhsdbLauncher();
+ List<String> vmArgs = new ArrayList<String>();
+ vmArgs.add("-XX:+UnlockDiagnosticVMOptions"); // bool
+ vmArgs.add("-XX:ActiveProcessorCount=1"); // int
+ vmArgs.add("-XX:ParallelGCThreads=1"); // uint
+ vmArgs.add("-XX:MaxJavaStackTraceDepth=1024"); // intx
+ vmArgs.add("-XX:LogEventsBufferEntries=10"); // uintx
+ vmArgs.add("-XX:HeapSizePerGCThread=32m"); // size_t
+ vmArgs.add("-XX:NativeMemoryTracking=off"); // ccstr
+ vmArgs.add("-XX:OnError='echo error'"); // ccstrlist
+ vmArgs.add("-XX:CompileThresholdScaling=1.0"); // double
+ vmArgs.add("-XX:ErrorLogTimeout=120"); // uint64_t
+ vmArgs.addAll(Utils.getVmOptions());
+ theApp = LingeredApp.startApp(vmArgs);
+ System.out.println("Started LingeredApp with pid " + theApp.getPid());
+
+ List<String> cmds = List.of("flags");
+
+ Map<String, List<String>> expStrMap = new HashMap<>();
+ expStrMap.put("flags", List.of(
+ "UnlockDiagnosticVMOptions = true",
+ "ActiveProcessorCount = 1",
+ "ParallelGCThreads = 1",
+ "MaxJavaStackTraceDepth = 1024",
+ "LogEventsBufferEntries = 10",
+ "HeapSizePerGCThread = 3",
+ "NativeMemoryTracking = \"off\"",
+ "OnError = \"'echo error'\"",
+ "CompileThresholdScaling = 1.0",
+ "ErrorLogTimeout = 120"));
+
+ test.run(theApp.getPid(), cmds, expStrMap, null);
+ } catch (Exception ex) {
+ throw new RuntimeException("Test ERROR " + ex, ex);
+ } finally {
+ LingeredApp.stopApp(theApp);
+ }
+ System.out.println("Test PASSED");
+ }
+
+ public static void main(String[] args) throws Exception {
+ runBasicTest();
+ runAllTypesTest();
+ }
}