1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/vm/runtime/vmStructs.hpp Sat Dec 01 00:00:00 2007 +0000 1.3 @@ -0,0 +1,121 @@ 1.4 +/* 1.5 + * Copyright 2000-2001 Sun Microsystems, Inc. All Rights Reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 1.24 + * have any questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +// This table encapsulates the debugging information required by the 1.29 +// serviceability agent in order to run. Specifically, we need to 1.30 +// understand the layout of certain C data structures (offsets, in 1.31 +// bytes, of their fields.) 1.32 +// 1.33 +// There are alternatives for the design of this mechanism, including 1.34 +// parsing platform-specific debugging symbols from a debug build into 1.35 +// a program database. While this current mechanism can be considered 1.36 +// to be a workaround for the inability to debug arbitrary C and C++ 1.37 +// programs at the present time, it does have certain advantages. 1.38 +// First, it is platform-independent, which will vastly simplify the 1.39 +// initial bringup of the system both now and on future platforms. 1.40 +// Second, it is embedded within the VM, as opposed to being in a 1.41 +// separate program database; experience has shown that whenever 1.42 +// portions of a system are decoupled, version skew is problematic. 1.43 +// Third, generating a program database, for example for a product 1.44 +// build, would probably require two builds to be done: the desired 1.45 +// product build as well as an intermediary build with the PRODUCT 1.46 +// flag turned on but also compiled with -g, leading to a doubling of 1.47 +// the time required to get a serviceability agent-debuggable product 1.48 +// build. Fourth, and very significantly, this table probably 1.49 +// preserves more information about field types than stabs do; for 1.50 +// example, it preserves the fact that a field is a "jlong" rather 1.51 +// than transforming the type according to the typedef in jni_md.h, 1.52 +// which allows the Java-side code to identify "Java-sized" fields in 1.53 +// C++ data structures. If the symbol parsing mechanism was redone 1.54 +// using stabs, it might still be necessary to have a table somewhere 1.55 +// containing this information. 1.56 +// 1.57 +// Do not change the sizes or signedness of the integer values in 1.58 +// these data structures; they are fixed over in the serviceability 1.59 +// agent's Java code (for bootstrapping). 1.60 + 1.61 +typedef struct { 1.62 + const char* typeName; // The type name containing the given field (example: "Klass") 1.63 + const char* fieldName; // The field name within the type (example: "_name") 1.64 + const char* typeString; // Quoted name of the type of this field (example: "symbolOopDesc*"; 1.65 + // parsed in Java to ensure type correctness 1.66 + int32_t isStatic; // Indicates whether following field is an offset or an address 1.67 + uint64_t offset; // Offset of field within structure; only used for nonstatic fields 1.68 + void* address; // Address of field; only used for static fields 1.69 + // ("offset" can not be reused because of apparent SparcWorks compiler bug 1.70 + // in generation of initializer data) 1.71 +} VMStructEntry; 1.72 + 1.73 +typedef struct { 1.74 + const char* typeName; // Type name (example: "methodOopDesc") 1.75 + const char* superclassName; // Superclass name, or null if none (example: "oopDesc") 1.76 + int32_t isOopType; // Does this type represent an oop typedef? (i.e., "methodOop" or 1.77 + // "klassOop", but NOT "methodOopDesc") 1.78 + int32_t isIntegerType; // Does this type represent an integer type (of arbitrary size)? 1.79 + int32_t isUnsigned; // If so, is it unsigned? 1.80 + uint64_t size; // Size, in bytes, of the type 1.81 +} VMTypeEntry; 1.82 + 1.83 +typedef struct { 1.84 + const char* name; // Name of constant (example: "_thread_in_native") 1.85 + int32_t value; // Value of constant 1.86 +} VMIntConstantEntry; 1.87 + 1.88 +typedef struct { 1.89 + const char* name; // Name of constant (example: "_thread_in_native") 1.90 + uint64_t value; // Value of constant 1.91 +} VMLongConstantEntry; 1.92 + 1.93 +// This class is a friend of most classes, to be able to access 1.94 +// private fields 1.95 +class VMStructs { 1.96 +public: 1.97 + // The last entry is identified over in the serviceability agent by 1.98 + // the fact that it has a NULL fieldName 1.99 + static VMStructEntry localHotSpotVMStructs[]; 1.100 + 1.101 + // The last entry is identified over in the serviceability agent by 1.102 + // the fact that it has a NULL typeName 1.103 + static VMTypeEntry localHotSpotVMTypes[]; 1.104 + 1.105 + // Table of integer constants required by the serviceability agent. 1.106 + // The last entry is identified over in the serviceability agent by 1.107 + // the fact that it has a NULL typeName 1.108 + static VMIntConstantEntry localHotSpotVMIntConstants[]; 1.109 + 1.110 + // Table of long constants required by the serviceability agent. 1.111 + // The last entry is identified over in the serviceability agent by 1.112 + // the fact that it has a NULL typeName 1.113 + static VMLongConstantEntry localHotSpotVMLongConstants[]; 1.114 + 1.115 + // This is used to run any checking code necessary for validation of 1.116 + // the data structure (debug build only) 1.117 + static void init(); 1.118 + 1.119 +private: 1.120 + // Look up a type in localHotSpotVMTypes using strcmp() (debug build only). 1.121 + // Returns 1 if found, 0 if not. 1.122 + // debug_only(static int findType(const char* typeName);) 1.123 + static int findType(const char* typeName); 1.124 +};