src/share/vm/runtime/vmStructs.hpp

Wed, 16 Jan 2013 16:30:04 +0100

author
sla
date
Wed, 16 Jan 2013 16:30:04 +0100
changeset 4462
e94ed1591b42
parent 4290
7c15faa95ce7
child 4492
8b46b0196eb0
permissions
-rw-r--r--

8006403: Regression: jstack failed due to the FieldInfo regression in SA
Reviewed-by: sla, dholmes
Contributed-by: Aleksey Shipilev <aleksey.shipilev@oracle.com>

duke@435 1 /*
coleenp@4037 2 * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #ifndef SHARE_VM_RUNTIME_VMSTRUCTS_HPP
stefank@2314 26 #define SHARE_VM_RUNTIME_VMSTRUCTS_HPP
stefank@2314 27
stefank@2314 28 #ifndef VM_STRUCTS_KERNEL
stefank@2314 29 #include "utilities/debug.hpp"
stefank@2314 30 #endif
stefank@2314 31 #ifdef COMPILER1
stefank@2314 32 #include "c1/c1_Runtime1.hpp"
stefank@2314 33 #endif
stefank@2314 34
duke@435 35 // This table encapsulates the debugging information required by the
duke@435 36 // serviceability agent in order to run. Specifically, we need to
duke@435 37 // understand the layout of certain C data structures (offsets, in
duke@435 38 // bytes, of their fields.)
duke@435 39 //
duke@435 40 // There are alternatives for the design of this mechanism, including
duke@435 41 // parsing platform-specific debugging symbols from a debug build into
duke@435 42 // a program database. While this current mechanism can be considered
duke@435 43 // to be a workaround for the inability to debug arbitrary C and C++
duke@435 44 // programs at the present time, it does have certain advantages.
duke@435 45 // First, it is platform-independent, which will vastly simplify the
duke@435 46 // initial bringup of the system both now and on future platforms.
duke@435 47 // Second, it is embedded within the VM, as opposed to being in a
duke@435 48 // separate program database; experience has shown that whenever
duke@435 49 // portions of a system are decoupled, version skew is problematic.
duke@435 50 // Third, generating a program database, for example for a product
duke@435 51 // build, would probably require two builds to be done: the desired
duke@435 52 // product build as well as an intermediary build with the PRODUCT
duke@435 53 // flag turned on but also compiled with -g, leading to a doubling of
duke@435 54 // the time required to get a serviceability agent-debuggable product
duke@435 55 // build. Fourth, and very significantly, this table probably
duke@435 56 // preserves more information about field types than stabs do; for
duke@435 57 // example, it preserves the fact that a field is a "jlong" rather
duke@435 58 // than transforming the type according to the typedef in jni_md.h,
duke@435 59 // which allows the Java-side code to identify "Java-sized" fields in
duke@435 60 // C++ data structures. If the symbol parsing mechanism was redone
duke@435 61 // using stabs, it might still be necessary to have a table somewhere
duke@435 62 // containing this information.
duke@435 63 //
duke@435 64 // Do not change the sizes or signedness of the integer values in
duke@435 65 // these data structures; they are fixed over in the serviceability
duke@435 66 // agent's Java code (for bootstrapping).
duke@435 67
duke@435 68 typedef struct {
duke@435 69 const char* typeName; // The type name containing the given field (example: "Klass")
duke@435 70 const char* fieldName; // The field name within the type (example: "_name")
coleenp@2497 71 const char* typeString; // Quoted name of the type of this field (example: "Symbol*";
duke@435 72 // parsed in Java to ensure type correctness
duke@435 73 int32_t isStatic; // Indicates whether following field is an offset or an address
duke@435 74 uint64_t offset; // Offset of field within structure; only used for nonstatic fields
duke@435 75 void* address; // Address of field; only used for static fields
duke@435 76 // ("offset" can not be reused because of apparent SparcWorks compiler bug
duke@435 77 // in generation of initializer data)
duke@435 78 } VMStructEntry;
duke@435 79
duke@435 80 typedef struct {
coleenp@4037 81 const char* typeName; // Type name (example: "Method")
duke@435 82 const char* superclassName; // Superclass name, or null if none (example: "oopDesc")
coleenp@4037 83 int32_t isOopType; // Does this type represent an oop typedef? (i.e., "Method*" or
coleenp@4037 84 // "Klass*", but NOT "Method")
duke@435 85 int32_t isIntegerType; // Does this type represent an integer type (of arbitrary size)?
duke@435 86 int32_t isUnsigned; // If so, is it unsigned?
duke@435 87 uint64_t size; // Size, in bytes, of the type
duke@435 88 } VMTypeEntry;
duke@435 89
duke@435 90 typedef struct {
duke@435 91 const char* name; // Name of constant (example: "_thread_in_native")
duke@435 92 int32_t value; // Value of constant
duke@435 93 } VMIntConstantEntry;
duke@435 94
duke@435 95 typedef struct {
duke@435 96 const char* name; // Name of constant (example: "_thread_in_native")
duke@435 97 uint64_t value; // Value of constant
duke@435 98 } VMLongConstantEntry;
duke@435 99
duke@435 100 // This class is a friend of most classes, to be able to access
duke@435 101 // private fields
duke@435 102 class VMStructs {
duke@435 103 public:
duke@435 104 // The last entry is identified over in the serviceability agent by
duke@435 105 // the fact that it has a NULL fieldName
duke@435 106 static VMStructEntry localHotSpotVMStructs[];
duke@435 107
duke@435 108 // The last entry is identified over in the serviceability agent by
duke@435 109 // the fact that it has a NULL typeName
duke@435 110 static VMTypeEntry localHotSpotVMTypes[];
duke@435 111
duke@435 112 // Table of integer constants required by the serviceability agent.
duke@435 113 // The last entry is identified over in the serviceability agent by
duke@435 114 // the fact that it has a NULL typeName
duke@435 115 static VMIntConstantEntry localHotSpotVMIntConstants[];
duke@435 116
duke@435 117 // Table of long constants required by the serviceability agent.
duke@435 118 // The last entry is identified over in the serviceability agent by
duke@435 119 // the fact that it has a NULL typeName
duke@435 120 static VMLongConstantEntry localHotSpotVMLongConstants[];
duke@435 121
duke@435 122 // This is used to run any checking code necessary for validation of
duke@435 123 // the data structure (debug build only)
duke@435 124 static void init();
duke@435 125
mikael@4290 126 #ifndef PRODUCT
mikael@4290 127 // Execute unit tests
mikael@4290 128 static void test();
mikael@4290 129 #endif
mikael@4290 130
duke@435 131 private:
duke@435 132 // Look up a type in localHotSpotVMTypes using strcmp() (debug build only).
duke@435 133 // Returns 1 if found, 0 if not.
duke@435 134 // debug_only(static int findType(const char* typeName);)
duke@435 135 static int findType(const char* typeName);
duke@435 136 };
stefank@2314 137
stefank@2314 138 #endif // SHARE_VM_RUNTIME_VMSTRUCTS_HPP

mercurial