/*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
*
* - Neither the name of Oracle nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* This source code is provided to illustrate the usage of a given feature
* or technique and has been deliberately simplified. Additional steps
* required for a production-quality application, such as security checks,
* input validation and proper error handling, might not be present in
* this sample code.
*/
/* Object references table (used in hprof_object.c). */
/*
* This table is used by the object table to store object reference
* and primitive data information obtained from iterations over the
* heap (see hprof_site.c).
*
* Most of these table entries have no Key, but the key is used to store
* the primitive array and primitive field jvalue. None of these entries
* are ever looked up, there will be no hash table, use of the
* LookupTable was just an easy way to handle a unbounded table of
* entries. The object table (see hprof_object.c) will completely
* free this reference table after each heap dump or after processing the
* references and primitive data.
*
* The hprof format required this accumulation of all heap iteration
* references and primitive data from objects in order to compose an
* hprof records for it.
*
* This file contains detailed understandings of how an hprof CLASS
* and INSTANCE dump is constructed, most of this is derived from the
* original hprof code, but some has been derived by reading the HAT
* code that accepts this format.
*
*/
#include "hprof.h"
/* The flavor of data being saved in the RefInfo */
enum {
};
/* Reference information, object reference or primitive data information */
typedef struct RefInfo {
} RefInfo;
/* Private internal functions. */
/* Get the RefInfo structure from an entry */
static RefInfo *
{
return info;
}
/* Get a jvalue that was stored as the key. */
static jvalue
{
void *key;
int len;
} else {
value = empty_value;
}
return value;
}
/* Get size of a primitive type */
static jint
{
switch ( primType ) {
break;
break;
break;
break;
case JVMTI_PRIMITIVE_TYPE_INT:
break;
break;
break;
break;
default:
HPROF_ASSERT(0);
size = 1;
break;
}
return size;
}
/* Get a void* elements array that was stored as the key. */
static void *
{
void *key;
HPROF_ASSERT(byteLen>=0);
return key;
}
/* Dump a RefInfo* structure */
static void
{
debug_message("[%d]: flavor=%d"
", refKind=%d"
", primType=%d"
", object_index=0x%x"
", length=%d"
", next=0x%x"
"\n",
}
/* Dump a RefIndex list */
static void
{
debug_message("\nFOLLOW REFERENCES RETURNED:\n");
while ( index != 0 ) {
}
}
/* Dump information about a field and what ref data we had on it */
static void
{
debug_message("[%d] %s \"%s\" \"%s\"",
debug_message(" (primType=%d(%c)",
debug_message(", got %d(%c)",
}
debug_message(")");
} else {
debug_message("(ty=OBJ)");
}
debug_message(" val=[0x%08x,0x%08x] or [0x%08x,0x%08x]",
}
debug_message("\n");
}
/* Dump all the fields of interest */
static void
{
int i;
debug_message("\nHPROF LIST OF ALL FIELDS:\n");
for ( i = 0 ; i < n_fields ; i++ ) {
if ( fields[i].name_index != 0 ) {
}
}
}
/* Verify field data */
static void
{
HPROF_ASSERT(n_fields > 0);
HPROF_ASSERT(index >= 0 );
debug_message("\nPROBLEM WITH:\n");
debug_message("\n");
}
if ( primType == JVMTI_PRIMITIVE_TYPE_BOOLEAN &&
debug_message("\nPROBLEM WITH:\n");
debug_message("\n");
}
}
/* Fill in a field value, making sure the index is safe */
static void
{
HPROF_ASSERT(n_fields > 0);
HPROF_ASSERT(index >= 0 );
}
}
/* Walk all references for an ObjectIndex and construct the hprof CLASS dump. */
static void
{
char *sig;
HPROF_ASSERT(object_index!=0);
if ( kind != OBJECT_CLASS ) {
return;
}
HPROF_ASSERT(site_index!=0);
HPROF_ASSERT(cnum!=0);
return;
}
super_index = 0;
if ( super_cnum != 0 ) {
if ( super_index != 0 ) {
}
}
HPROF_ASSERT(trace_index!=0);
signers_index = 0;
domain_index = 0;
/* Get field information */
n_fields = 0;
n_fields_set = 0;
/* Problems getting all the fields, can't trust field index values */
/* Class with no references at all? (ok to be unprepared if list==0?) */
if ( list != 0 ) {
/* It is assumed that the reason why we didn't get the fields
* was because the class is not prepared.
*/
debug_message("Unprepared class with references: %s\n",
sig);
}
}
/* Why would an unprepared class contain references? */
}
if ( n_fields > 0 ) {
}
/* We use a Stack just because it will automatically expand as needed */
cpool_count = 0;
while ( index != 0 ) {
case INFO_OBJECT_REF_DATA:
/* Should never be seen on a class dump */
HPROF_ASSERT(0);
break;
if ( skip_fields == JNI_TRUE ) {
break;
}
n_fields_set++;
break;
cpool_count++;
break;
}
break;
break;
default:
/* Ignore, not needed */
break;
}
break;
case INFO_PRIM_FIELD_DATA:
if ( skip_fields == JNI_TRUE ) {
break;
}
n_fields_set++;
break;
case INFO_PRIM_ARRAY_DATA:
default:
/* Should never see these */
HPROF_ASSERT(0);
break;
}
}
/* Get constant pool data if we have any */
if ( cpool_count > 0 ) {
}
}
}
/* Walk all references for an ObjectIndex and construct the hprof INST dump. */
static void
{
char *sig;
void *elements;
HPROF_ASSERT(object_index!=0);
if ( kind == OBJECT_CLASS ) {
return;
}
HPROF_ASSERT(site_index!=0);
HPROF_ASSERT(cnum!=0);
HPROF_ASSERT(trace_index!=0);
num_elements = 0;
num_bytes = 0;
n_fields = 0;
n_fields_set = 0;
if ( sig[0] != JVM_SIGNATURE_ARRAY ) {
/* Trouble getting all the fields, can't trust field index values */
/* It is assumed that the reason why we didn't get the fields
* was because the class is not prepared.
*/
if ( list != 0 ) {
debug_message("Instance of unprepared class with refs: %s\n",
sig);
} else {
debug_message("Instance of unprepared class without refs: %s\n",
sig);
}
}
}
if ( n_fields > 0 ) {
}
} else {
}
}
while ( index != 0 ) {
/* Process reference objects, many not used right now. */
case INFO_OBJECT_REF_DATA:
/* Should never be seen on an instance dump */
HPROF_ASSERT(0);
break;
if ( skip_fields == JNI_TRUE ) {
break;
}
n_fields_set++;
break;
/* We get each object element one at a time. */
int nbytes;
} else {
void *new_values;
int new_size;
int obytes;
values = new_values;
}
}
break;
default:
/* Ignore, not needed */
break;
}
break;
case INFO_PRIM_FIELD_DATA:
if ( skip_fields == JNI_TRUE ) {
break;
}
n_fields_set++;
break;
case INFO_PRIM_ARRAY_DATA:
/* Should only be one, and it's handled below */
/* We assert that nothing else was saved with this array */
&num_elements, &num_bytes);
break;
default:
HPROF_ASSERT(0);
break;
}
}
if ( is_prim_array == JNI_TRUE ) {
} else {
}
} else {
}
}
}
/* Do NOT free elements, it's a key in the table, leave it be */
}
}
/* External interfaces. */
void
reference_init(void)
{
(int)sizeof(RefInfo));
}
/* Save away a reference to an object */
{
info = empty_info;
return entry;
}
/* Save away some primitive field data */
{
info = empty_info;
return entry;
}
/* Save away some primitive array data */
{
HPROF_ASSERT(next == 0);
HPROF_ASSERT(elementCount >= 0);
info = empty_info;
return entry;
}
void
reference_cleanup(void)
{
return;
}
}
void
{
}
void
{
}