1 /*
2 * Copyright (c) 2016, 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 */
46 * If the represented field is static, this is its address. Otherwise, this is 0.
47 */
48 public final long address;
49
50 /**
51 * Value of the field represented as a boxed boolean if its C++ type is bool otherwise as a
52 * boxed long; only valid for non-oop static fields. This value is only captured once, during
53 * JVMCI initialization. If {@link #type} cannot be meaningfully (e.g., a struct) or safely
54 * (e.g., an oop) expressed as a boxed object, this is {@code null}.
55 */
56 public final Object value;
57
58 /**
59 * Determines if the represented field is static.
60 */
61 public boolean isStatic() {
62 return address != 0;
63 }
64
65 /**
66 * Creates a description of a field.
67 */
68 VMField(String name, String type, long address, Object value) {
69 this.name = name;
70 this.type = type;
71 this.offset = 0;
72 this.address = address;
73 this.value = value;
74 }
75
76 @Override
77 public String toString() {
78 String val = value == null ? "null" : String.format("0x%x", value);
79 return String.format("Field[name=%s, type=%s, offset=%d, address=0x%x, value=%s]", name, type, offset, address, val);
80 }
81 }
|
1 /*
2 * Copyright (c) 2016, 2019, 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 */
46 * If the represented field is static, this is its address. Otherwise, this is 0.
47 */
48 public final long address;
49
50 /**
51 * Value of the field represented as a boxed boolean if its C++ type is bool otherwise as a
52 * boxed long; only valid for non-oop static fields. This value is only captured once, during
53 * JVMCI initialization. If {@link #type} cannot be meaningfully (e.g., a struct) or safely
54 * (e.g., an oop) expressed as a boxed object, this is {@code null}.
55 */
56 public final Object value;
57
58 /**
59 * Determines if the represented field is static.
60 */
61 public boolean isStatic() {
62 return address != 0;
63 }
64
65 /**
66 * Creates a description of a non-static field.
67 */
68 @VMEntryPoint
69 VMField(String name, String type, long offset, long address, Object value) {
70 this.name = name;
71 this.type = type;
72 this.offset = offset;
73 this.address = address;
74 this.value = value;
75 }
76
77 @Override
78 public String toString() {
79 String val = value == null ? "null" : (type.contains("*") ? String.format("0x%x", value) : String.format("%s", value));
80 return String.format("Field[name=%s, type=%s, offset=%d, address=0x%x, value=%s]", name, type, offset, address, val);
81 }
82 }
|