1 /*
2 * Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 package sun.jvm.hotspot.runtime;
26
27 import java.util.*;
28 import sun.jvm.hotspot.debugger.*;
29 import sun.jvm.hotspot.oops.*;
30 import sun.jvm.hotspot.types.*;
31 import sun.jvm.hotspot.utilities.*;
32
33 public class PerfDataEntry extends VMObject {
34 private static JIntField entryLengthField;
35 private static JIntField nameOffsetField;
36 private static JIntField vectorLengthField;
37 private static JByteField dataTypeField;
38 private static JByteField flagsField;
39 private static JByteField dataUnitsField;
40 private static JByteField dataVariabilityField;
41 private static JIntField dataOffsetField;
42
43 static {
44 VM.registerVMInitializedObserver(new Observer() {
45 public void update(Observable o, Object data) {
46 initialize(VM.getVM().getTypeDataBase());
345 str = Double.toString(doubleValue());
346 } else {
347 str = "<unknown scalar value>";
348 }
349 } else { // vector
350 if (dataType == BasicType.getTBoolean()) {
351 boolean[] res = booleanArrayValue();
352 StringBuffer buf = new StringBuffer();
353 buf.append('[');
354 for (int i = 0; i < res.length; i++) {
355 buf.append(Boolean.toString(res[i]));
356 buf.append(", ");
357 }
358 buf.append(']');
359 str = buf.toString();
360 } else if (dataType == BasicType.getTChar()) {
361 // char[] is returned as a String
362 str = new String(charArrayValue());
363 } else if (dataType == BasicType.getTByte()) {
364 // byte[] is returned as a String
365 try {
366 str = new String(byteArrayValue(), "US-ASCII");
367 } catch (java.io.UnsupportedEncodingException e) {
368 str = "can't decode string : " + e.getMessage();
369 }
370 } else if (dataType == BasicType.getTShort()) {
371 short[] res = shortArrayValue();
372 StringBuffer buf = new StringBuffer();
373 buf.append('[');
374 for (int i = 0; i < res.length; i++) {
375 buf.append(Short.toString(res[i]));
376 buf.append(", ");
377 }
378 buf.append(']');
379 str = buf.toString();
380 } else if (dataType == BasicType.getTInt()) {
381 int[] res = intArrayValue();
382 StringBuffer buf = new StringBuffer();
383 buf.append('[');
384 for (int i = 0; i < res.length; i++) {
385 buf.append(Integer.toString(res[i]));
386 buf.append(", ");
387 }
388 buf.append(']');
389 str = buf.toString();
|
1 /*
2 * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 package sun.jvm.hotspot.runtime;
26
27 import java.nio.charset.StandardCharsets;
28 import java.util.*;
29 import sun.jvm.hotspot.debugger.*;
30 import sun.jvm.hotspot.oops.*;
31 import sun.jvm.hotspot.types.*;
32 import sun.jvm.hotspot.utilities.*;
33
34 public class PerfDataEntry extends VMObject {
35 private static JIntField entryLengthField;
36 private static JIntField nameOffsetField;
37 private static JIntField vectorLengthField;
38 private static JByteField dataTypeField;
39 private static JByteField flagsField;
40 private static JByteField dataUnitsField;
41 private static JByteField dataVariabilityField;
42 private static JIntField dataOffsetField;
43
44 static {
45 VM.registerVMInitializedObserver(new Observer() {
46 public void update(Observable o, Object data) {
47 initialize(VM.getVM().getTypeDataBase());
346 str = Double.toString(doubleValue());
347 } else {
348 str = "<unknown scalar value>";
349 }
350 } else { // vector
351 if (dataType == BasicType.getTBoolean()) {
352 boolean[] res = booleanArrayValue();
353 StringBuffer buf = new StringBuffer();
354 buf.append('[');
355 for (int i = 0; i < res.length; i++) {
356 buf.append(Boolean.toString(res[i]));
357 buf.append(", ");
358 }
359 buf.append(']');
360 str = buf.toString();
361 } else if (dataType == BasicType.getTChar()) {
362 // char[] is returned as a String
363 str = new String(charArrayValue());
364 } else if (dataType == BasicType.getTByte()) {
365 // byte[] is returned as a String
366 str = CStringUtilities.getString(addr.addOffsetTo(dataOffset()),
367 StandardCharsets.US_ASCII);
368 } else if (dataType == BasicType.getTShort()) {
369 short[] res = shortArrayValue();
370 StringBuffer buf = new StringBuffer();
371 buf.append('[');
372 for (int i = 0; i < res.length; i++) {
373 buf.append(Short.toString(res[i]));
374 buf.append(", ");
375 }
376 buf.append(']');
377 str = buf.toString();
378 } else if (dataType == BasicType.getTInt()) {
379 int[] res = intArrayValue();
380 StringBuffer buf = new StringBuffer();
381 buf.append('[');
382 for (int i = 0; i < res.length; i++) {
383 buf.append(Integer.toString(res[i]));
384 buf.append(", ");
385 }
386 buf.append(']');
387 str = buf.toString();
|