jdk/src/share/demo/jvmti/hprof/hprof_check.c
author goetz
Thu, 21 Nov 2013 18:29:34 -0800
changeset 22852 1063026e8cee
parent 14342 8435a30053c1
permissions -rw-r--r--
8028471: PPC64 (part 215): opto: Extend ImplicitNullCheck optimization. Summary: Fixed Implicit NULL check optimization for AIX, where the page at address '0' is only write-protected. Reviewed-by: kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
14342
8435a30053c1 7197491: update copyright year to match last edit in jdk8 jdk repository
alanb
parents: 10292
diff changeset
     2
 * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 * Redistribution and use in source and binary forms, with or without
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * modification, are permitted provided that the following conditions
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * are met:
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 *   - Redistributions of source code must retain the above copyright
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 *     notice, this list of conditions and the following disclaimer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 *   - Redistributions in binary form must reproduce the above copyright
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 *     notice, this list of conditions and the following disclaimer in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 *     documentation and/or other materials provided with the distribution.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    15
 *   - Neither the name of Oracle nor the names of its
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *     contributors may be used to endorse or promote products derived
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 *     from this software without specific prior written permission.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
10292
ed7db6a12c2a 7067811: Update demo/sample code to state it should not be used for production
nloodin
parents: 5506
diff changeset
    32
/*
ed7db6a12c2a 7067811: Update demo/sample code to state it should not be used for production
nloodin
parents: 5506
diff changeset
    33
 * This source code is provided to illustrate the usage of a given feature
ed7db6a12c2a 7067811: Update demo/sample code to state it should not be used for production
nloodin
parents: 5506
diff changeset
    34
 * or technique and has been deliberately simplified. Additional steps
ed7db6a12c2a 7067811: Update demo/sample code to state it should not be used for production
nloodin
parents: 5506
diff changeset
    35
 * required for a production-quality application, such as security checks,
ed7db6a12c2a 7067811: Update demo/sample code to state it should not be used for production
nloodin
parents: 5506
diff changeset
    36
 * input validation and proper error handling, might not be present in
ed7db6a12c2a 7067811: Update demo/sample code to state it should not be used for production
nloodin
parents: 5506
diff changeset
    37
 * this sample code.
ed7db6a12c2a 7067811: Update demo/sample code to state it should not be used for production
nloodin
parents: 5506
diff changeset
    38
 */
ed7db6a12c2a 7067811: Update demo/sample code to state it should not be used for production
nloodin
parents: 5506
diff changeset
    39
ed7db6a12c2a 7067811: Update demo/sample code to state it should not be used for production
nloodin
parents: 5506
diff changeset
    40
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
/* Functionality for checking hprof format=b output. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
/* ONLY used with logflags=4. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
/* Verifies and write a verbose textual version of a format=b file.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 *   Textual output file is gdata->checkfilename, fd is gdata->check_fd.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 *   Buffer is in gdata too, see gdata->check* variables.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 *   Could probably be isolated to a separate library or utility.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
#include "hprof.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
typedef TableIndex HprofId;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
#include "hprof_b_spec.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
static int type_size[ /*HprofType*/ ] =  HPROF_TYPE_SIZES;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
/* For map from HPROF_UTF8 to a string */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
typedef struct UmapInfo {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    char *str;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
} UmapInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
/* Field information */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
typedef struct Finfo {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    HprofId   id;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    HprofType ty;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
} Finfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
/* Class information map from class ID (ClassIndex) to class information */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
typedef struct CmapInfo {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    int      max_finfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    int      n_finfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    Finfo   *finfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    int      inst_size;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    HprofId  sup;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
} CmapInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
/* Read raw bytes from the file image, update the pointer */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
static void
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
read_raw(unsigned char **pp, unsigned char *buf, int len)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    while ( len > 0 ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        *buf = **pp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        buf++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        (*pp)++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        len--;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
/* Read various sized elements, properly converted from big to right endian.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
 *    File will contain big endian format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
static unsigned
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
read_u1(unsigned char **pp)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    unsigned char b;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    read_raw(pp, &b, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    return b;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
static unsigned
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
read_u2(unsigned char **pp)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    unsigned short s;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    read_raw(pp, (void*)&s, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    return md_htons(s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
static unsigned
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
read_u4(unsigned char **pp)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    unsigned int u;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    read_raw(pp, (void*)&u, 4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    return md_htonl(u);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
static jlong
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
read_u8(unsigned char **pp)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    unsigned int high;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    unsigned int low;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    jlong        x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    high = read_u4(pp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    low  = read_u4(pp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    x = high;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    x = (x << 32) | low;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    return x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
static HprofId
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
read_id(unsigned char **pp)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    return (HprofId)read_u4(pp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
/* System error routine */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
static void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
system_error(const char *system_call, int rc, int errnum)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    char buf[256];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    char details[256];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    details[0] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    if ( errnum != 0 ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        md_system_error(details, (int)sizeof(details));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    } else if ( rc >= 0 ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        (void)strcpy(details,"Only part of buffer processed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    if ( details[0] == 0 ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        (void)strcpy(details,"Unknown system error condition");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    (void)md_snprintf(buf, sizeof(buf), "System %s failed: %s\n",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
                            system_call, details);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    HPROF_ERROR(JNI_TRUE, buf);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
/* Write to a fd */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
static void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
system_write(int fd, void *buf, int len)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    int res;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    HPROF_ASSERT(fd>=0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    res = md_write(fd, buf, len);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    if (res < 0 || res!=len) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        system_error("write", res, errno);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
/* Flush check buffer */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
static void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
check_flush(void)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    if ( gdata->check_fd < 0 ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    if (gdata->check_buffer_index) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        system_write(gdata->check_fd, gdata->check_buffer, gdata->check_buffer_index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        gdata->check_buffer_index = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
/* Read out a given typed element */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
static jvalue
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
read_val(unsigned char **pp, HprofType ty)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    jvalue        val;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    static jvalue empty_val;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    val = empty_val;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    switch ( ty ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        case 0:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        case HPROF_ARRAY_OBJECT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        case HPROF_NORMAL_OBJECT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
            val.i = read_id(pp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        case HPROF_BYTE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        case HPROF_BOOLEAN:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
            val.b = read_u1(pp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        case HPROF_CHAR:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        case HPROF_SHORT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
            val.s = read_u2(pp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        case HPROF_FLOAT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        case HPROF_INT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
            val.i = read_u4(pp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        case HPROF_DOUBLE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        case HPROF_LONG:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
            val.j = read_u8(pp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
            HPROF_ERROR(JNI_TRUE, "bad type number");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    return val;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
/* Move arbitrary byte stream into gdata->check_fd */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
static void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
check_raw(void *buf, int len)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
    if ( gdata->check_fd < 0 ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    if ( len <= 0 ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    if (gdata->check_buffer_index + len > gdata->check_buffer_size) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        check_flush();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        if (len > gdata->check_buffer_size) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
            system_write(gdata->check_fd, buf, len);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    (void)memcpy(gdata->check_buffer + gdata->check_buffer_index, buf, len);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    gdata->check_buffer_index += len;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
/* Printf for gdata->check_fd */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
static void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
check_printf(char *fmt, ...)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    char    buf[1024];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    va_list args;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    if ( gdata->check_fd < 0 ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    va_start(args, fmt);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    (void)md_vsnprintf(buf, sizeof(buf), fmt, args);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    buf[sizeof(buf)-1] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    check_raw(buf, (int)strlen(buf));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
    va_end(args);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
/* Printf of an element for gdata->check_fd */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
static void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
check_printf_val(HprofType ty, jvalue val, int long_form)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
    jint low;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
    jint high;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
    switch ( ty ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
        case HPROF_ARRAY_OBJECT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
            check_printf("0x%08x", val.i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        case HPROF_NORMAL_OBJECT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
            check_printf("0x%08x", val.i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        case HPROF_BOOLEAN:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
            check_printf("0x%02x", val.b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
        case HPROF_CHAR:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
            if ( long_form ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
                if ( val.s < 0 || val.s > 0x7f || !isprint(val.s) ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
                    check_printf("0x%04x", val.s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
                    check_printf("0x%04x(%c)", val.s, val.s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
                if ( val.s < 0 || val.s > 0x7f || !isprint(val.s) ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
                    check_printf("\\u%04x", val.s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
                    check_printf("%c", val.s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
        case HPROF_FLOAT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
            low  = jlong_low(val.j);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
            check_printf("0x%08x(%f)", low, (double)val.f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
        case HPROF_DOUBLE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
            high = jlong_high(val.j);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
            low  = jlong_low(val.j);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
            check_printf("0x%08x%08x(%f)", high, low, val.d);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
        case HPROF_BYTE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
            check_printf("0x%02x", val.b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
        case HPROF_SHORT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
            check_printf("0x%04x", val.s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
        case HPROF_INT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
            check_printf("0x%08x", val.i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
        case HPROF_LONG:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
            high = jlong_high(val.j);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
            low  = jlong_low(val.j);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
            check_printf("0x%08x%08x", high, low);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
/* Printf of a string for gdata->check_fd */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
static void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
check_printf_str(char *str)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
    int len;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
    int i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
    if ( str == NULL ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
        check_printf("<null>");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
    check_printf("\"");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
    len = (int)strlen(str);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
    for (i = 0; i < len; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
        unsigned char c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
        c = str[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
        if ( isprint(c) ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
            check_printf("%c", c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
            check_printf("\\x%02x", c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
    check_printf("\"");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
/* Printf of a utf8 id for gdata->check_fd */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
static void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
check_print_utf8(struct LookupTable *utab, char *prefix, HprofId id)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
    TableIndex uindex;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
    if ( id == 0 ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
        check_printf("%s0x%x", prefix, id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
        uindex = table_find_entry(utab, &id, sizeof(id));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
        if ( uindex == 0 ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
            check_printf("%s0x%x", prefix, id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
            UmapInfo *umap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
            umap = (UmapInfo*)table_get_info(utab, uindex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
            HPROF_ASSERT(umap!=NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
            HPROF_ASSERT(umap->str!=NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
            check_printf("%s0x%x->", prefix, id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
            check_printf_str(umap->str);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
/* Add a instance field information to this cmap. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
static void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
add_inst_field_to_cmap(CmapInfo *cmap, HprofId id, HprofType ty)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
   int i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
   HPROF_ASSERT(cmap!=NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
   i = cmap->n_finfo++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
   if ( i+1 >= cmap->max_finfo ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
       int    osize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
       Finfo *new_finfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
       osize            = cmap->max_finfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
       cmap->max_finfo += 12;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
       new_finfo = (Finfo*)HPROF_MALLOC(cmap->max_finfo*(int)sizeof(Finfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
       (void)memset(new_finfo,0,cmap->max_finfo*(int)sizeof(Finfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
       if ( i == 0 ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
           cmap->finfo = new_finfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
       } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
           (void)memcpy(new_finfo,cmap->finfo,osize*(int)sizeof(Finfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
           HPROF_FREE(cmap->finfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
           cmap->finfo = new_finfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
       }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
   }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
   cmap->finfo[i].id = id;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
   cmap->finfo[i].ty = ty;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
/* LookupTable callback for cmap entry cleanup */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
static void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
cmap_cleanup(TableIndex i, void *key_ptr, int key_len, void*info, void*data)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
    CmapInfo *cmap = info;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
    if ( cmap == NULL ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
    if ( cmap->finfo != NULL ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
        HPROF_FREE(cmap->finfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
        cmap->finfo = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
/* Case label for a switch on hprof heap dump elements */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
#define CASE_HEAP(name) case name: label = #name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
/* Given the heap dump data and the utf8 map, check/write the heap dump. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
check_heap_tags(struct LookupTable *utab, unsigned char *pstart, int nbytes)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
    int                 nrecords;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
    unsigned char      *p;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
    unsigned char      *psave;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
    struct LookupTable *ctab;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
    CmapInfo            cmap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
    char               *label;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
    unsigned            tag;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
    HprofType           ty;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
    HprofId             id, id2, fr, sup;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
    int                 num_elements;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
    int                 num_bytes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
    SerialNumber        trace_serial_num;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
    SerialNumber        thread_serial_num;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
    int                 npos;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
    int                 i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
    int                 inst_size;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
    ctab     = table_initialize("temp ctab", 64, 64, 512, sizeof(CmapInfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
    /* First pass over heap records just fills in the CmapInfo table */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
    nrecords = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
    p        = pstart;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
    while ( p < (pstart+nbytes) ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
        nrecords++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
        /*LINTED*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
        npos = (int)(p - pstart);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
        tag  = read_u1(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
        switch ( tag ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
            CASE_HEAP(HPROF_GC_ROOT_UNKNOWN)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
                id = read_id(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
            CASE_HEAP(HPROF_GC_ROOT_JNI_GLOBAL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
                id  = read_id(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
                id2 = read_id(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
            CASE_HEAP(HPROF_GC_ROOT_JNI_LOCAL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
                id = read_id(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
                thread_serial_num = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
                fr = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
            CASE_HEAP(HPROF_GC_ROOT_JAVA_FRAME)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
                id = read_id(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
                thread_serial_num = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
                fr = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
            CASE_HEAP(HPROF_GC_ROOT_NATIVE_STACK)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
                id = read_id(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
                thread_serial_num = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
            CASE_HEAP(HPROF_GC_ROOT_STICKY_CLASS)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
                id = read_id(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
            CASE_HEAP(HPROF_GC_ROOT_THREAD_BLOCK)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
                id = read_id(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
                thread_serial_num = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
            CASE_HEAP(HPROF_GC_ROOT_MONITOR_USED)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
                id = read_id(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
            CASE_HEAP(HPROF_GC_ROOT_THREAD_OBJ)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
                id = read_id(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
                thread_serial_num = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
                trace_serial_num = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
            CASE_HEAP(HPROF_GC_CLASS_DUMP)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
                (void)memset((void*)&cmap, 0, sizeof(cmap));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
                id = read_id(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
                trace_serial_num = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
                {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
                    HprofId ld, si, pr, re1, re2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
                    sup      = read_id(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
                    ld       = read_id(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
                    si       = read_id(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
                    pr       = read_id(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
                    re1      = read_id(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
                    re2      = read_id(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
                    cmap.sup = sup;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
                inst_size = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
                cmap.inst_size = inst_size;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
                num_elements = read_u2(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
                for(i=0; i<num_elements; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
                    (void)read_u2(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
                    ty = read_u1(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
                    (void)read_val(&p, ty);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
                num_elements = read_u2(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
                for(i=0; i<num_elements; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
                    (void)read_id(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
                    ty = read_u1(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
                    (void)read_val(&p, ty);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
                num_elements = read_u2(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
                for(i=0; i<num_elements; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
                    HprofType ty;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
                    HprofId   id;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
                    id = read_id(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
                    ty = read_u1(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
                    add_inst_field_to_cmap(&cmap, id, ty);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
                (void)table_create_entry(ctab, &id, sizeof(id), &cmap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
            CASE_HEAP(HPROF_GC_INSTANCE_DUMP)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
                id = read_id(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
                trace_serial_num = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
                id2 = read_id(&p); /* class id */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
                num_bytes = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
                p += num_bytes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
            CASE_HEAP(HPROF_GC_OBJ_ARRAY_DUMP)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
                id = read_id(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
                trace_serial_num = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
                num_elements = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
                id2 = read_id(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
                p += num_elements*(int)sizeof(HprofId);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
            CASE_HEAP(HPROF_GC_PRIM_ARRAY_DUMP)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
                id = read_id(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
                trace_serial_num = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
                num_elements = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
                ty = read_u1(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
                p += type_size[ty]*num_elements;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
            default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
                label = "UNKNOWN";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
                check_printf("H#%d@%d %s: ERROR!\n",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
                                nrecords, npos, label);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
                HPROF_ERROR(JNI_TRUE, "unknown heap record type");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
    CHECK_FOR_ERROR(p==pstart+nbytes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
    /* Scan again once we have our cmap */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
    nrecords = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
    p        = pstart;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
    while ( p < (pstart+nbytes) ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
        nrecords++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
        /*LINTED*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
        npos = (int)(p - pstart);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
        tag  = read_u1(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
        switch ( tag ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
            CASE_HEAP(HPROF_GC_ROOT_UNKNOWN)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
                id = read_id(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
                check_printf("H#%d@%d %s: id=0x%x\n",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
                        nrecords, npos, label, id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
            CASE_HEAP(HPROF_GC_ROOT_JNI_GLOBAL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
                id = read_id(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
                id2 = read_id(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
                check_printf("H#%d@%d %s: id=0x%x, id2=0x%x\n",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
                        nrecords, npos, label, id, id2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
            CASE_HEAP(HPROF_GC_ROOT_JNI_LOCAL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
                id = read_id(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
                thread_serial_num = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
                fr = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
                check_printf("H#%d@%d %s: id=0x%x, thread_serial_num=%u, fr=0x%x\n",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
                        nrecords, npos, label, id, thread_serial_num, fr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
            CASE_HEAP(HPROF_GC_ROOT_JAVA_FRAME)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
                id = read_id(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
                thread_serial_num = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
                fr = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
                check_printf("H#%d@%d %s: id=0x%x, thread_serial_num=%u, fr=0x%x\n",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
                        nrecords, npos, label, id, thread_serial_num, fr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
            CASE_HEAP(HPROF_GC_ROOT_NATIVE_STACK)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
                id = read_id(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
                thread_serial_num = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
                check_printf("H#%d@%d %s: id=0x%x, thread_serial_num=%u\n",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
                        nrecords, npos, label, id, thread_serial_num);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
            CASE_HEAP(HPROF_GC_ROOT_STICKY_CLASS)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
                id = read_id(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
                check_printf("H#%d@%d %s: id=0x%x\n",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
                        nrecords, npos, label, id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
            CASE_HEAP(HPROF_GC_ROOT_THREAD_BLOCK)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
                id = read_id(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
                thread_serial_num = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
                check_printf("H#%d@%d %s: id=0x%x, thread_serial_num=%u\n",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
                        nrecords, npos, label, id, thread_serial_num);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
            CASE_HEAP(HPROF_GC_ROOT_MONITOR_USED)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
                id = read_id(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
                check_printf("H#%d@%d %s: id=0x%x\n",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
                        nrecords, npos, label, id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
            CASE_HEAP(HPROF_GC_ROOT_THREAD_OBJ)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
                id = read_id(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
                thread_serial_num = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
                trace_serial_num = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
                CHECK_TRACE_SERIAL_NO(trace_serial_num);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
                check_printf("H#%d@%d %s: id=0x%x, thread_serial_num=%u,"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
                             " trace_serial_num=%u\n",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
                        nrecords, npos, label, id, thread_serial_num,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
                        trace_serial_num);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
            CASE_HEAP(HPROF_GC_CLASS_DUMP)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
                id = read_id(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
                trace_serial_num = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
                CHECK_TRACE_SERIAL_NO(trace_serial_num);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
                check_printf("H#%d@%d %s: id=0x%x, trace_serial_num=%u\n",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
                        nrecords, npos, label, id, trace_serial_num);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
                {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
                    HprofId ld, si, pr, re1, re2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
                    sup = read_id(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
                    ld  = read_id(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
                    si  = read_id(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
                    pr  = read_id(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
                    re1 = read_id(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
                    re2 = read_id(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
                    check_printf("  su=0x%x, ld=0x%x, si=0x%x,"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
                                 " pr=0x%x, re1=0x%x, re2=0x%x\n",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
                        sup, ld, si, pr, re1, re2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
                inst_size = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
                check_printf("  instance_size=%d\n", inst_size);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
                num_elements = read_u2(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
                for(i=0; i<num_elements; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
                    HprofType ty;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
                    unsigned  cpi;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
                    jvalue    val;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
                    cpi = read_u2(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
                    ty  = read_u1(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
                    val = read_val(&p, ty);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
                    check_printf("  constant_pool %d: cpi=%d, ty=%d, val=",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
                                i, cpi, ty);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
                    check_printf_val(ty, val, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
                    check_printf("\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
                num_elements = read_u2(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
                check_printf("  static_field_count=%d\n", num_elements);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
                for(i=0; i<num_elements; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
                    HprofType ty;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
                    HprofId   id;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
                    jvalue    val;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
                    id  = read_id(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
                    ty  = read_u1(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
                    val = read_val(&p, ty);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
                    check_printf("  static field %d: ", i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
                    check_print_utf8(utab, "id=", id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
                    check_printf(", ty=%d, val=", ty);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
                    check_printf_val(ty, val, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
                    check_printf("\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
                num_elements = read_u2(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
                check_printf("  instance_field_count=%d\n", num_elements);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
                for(i=0; i<num_elements; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
                    HprofType ty;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
                    HprofId   id;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
                    id = read_id(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
                    ty = read_u1(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
                    check_printf("  instance_field %d: ", i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
                    check_print_utf8(utab, "id=", id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
                    check_printf(", ty=%d\n", ty);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
            CASE_HEAP(HPROF_GC_INSTANCE_DUMP)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
                id = read_id(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
                trace_serial_num = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
                CHECK_TRACE_SERIAL_NO(trace_serial_num);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
                id2 = read_id(&p); /* class id */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
                num_bytes = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
                check_printf("H#%d@%d %s: id=0x%x, trace_serial_num=%u,"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
                             " cid=0x%x, nbytes=%d\n",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
                            nrecords, npos, label, id, trace_serial_num,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
                            id2, num_bytes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
                /* This is a packed set of bytes for the instance fields */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
                if ( num_bytes > 0 ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
                    TableIndex cindex;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
                    int        ifield;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
                    CmapInfo  *map;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
                    cindex = table_find_entry(ctab, &id2, sizeof(id2));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
                    HPROF_ASSERT(cindex!=0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
                    map = (CmapInfo*)table_get_info(ctab, cindex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
                    HPROF_ASSERT(map!=NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
                    HPROF_ASSERT(num_bytes==map->inst_size);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
                    psave  = p;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
                    ifield = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
                    do {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
                        for(i=0;i<map->n_finfo;i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
                            HprofType ty;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
                            HprofId   id;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
                            jvalue    val;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
                            ty = map->finfo[i].ty;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
                            id = map->finfo[i].id;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
                            HPROF_ASSERT(ty!=0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
                            HPROF_ASSERT(id!=0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
                            val = read_val(&p, ty);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
                            check_printf("  field %d: ", ifield);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
                            check_print_utf8(utab, "id=", id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
                            check_printf(", ty=%d, val=", ty);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
                            check_printf_val(ty, val, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
                            check_printf("\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
                            ifield++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
                        id2    = map->sup;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
                        map    = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
                        cindex = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
                        if ( id2 != 0 ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
                            cindex = table_find_entry(ctab, &id2, sizeof(id2));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
                            HPROF_ASSERT(cindex!=0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
                            map = (CmapInfo*)table_get_info(ctab, cindex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
                            HPROF_ASSERT(map!=NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
                    } while ( map != NULL );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
                    HPROF_ASSERT(num_bytes==(p-psave));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
            CASE_HEAP(HPROF_GC_OBJ_ARRAY_DUMP)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
                id = read_id(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
                trace_serial_num = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
                CHECK_TRACE_SERIAL_NO(trace_serial_num);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
                num_elements = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
                id2 = read_id(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
                check_printf("H#%d@%d %s: id=0x%x, trace_serial_num=%u, nelems=%d, eid=0x%x\n",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
                                nrecords, npos, label, id, trace_serial_num, num_elements, id2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
                for(i=0; i<num_elements; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
                    HprofId id;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
                    id = read_id(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
                    check_printf("  [%d]: id=0x%x\n", i, id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
            CASE_HEAP(HPROF_GC_PRIM_ARRAY_DUMP)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
                id = read_id(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
                trace_serial_num = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
                CHECK_TRACE_SERIAL_NO(trace_serial_num);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
                num_elements = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
                ty = read_u1(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
                psave = p;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
                check_printf("H#%d@%d %s: id=0x%x, trace_serial_num=%u, "
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
                             "nelems=%d, ty=%d\n",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
                                nrecords, npos, label, id, trace_serial_num, num_elements, ty);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
                HPROF_ASSERT(HPROF_TYPE_IS_PRIMITIVE(ty));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
                if ( num_elements > 0 ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
                    int   count;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
                    int   long_form;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
                    int   max_count;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
                    char *quote;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
                    quote     = "";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
                    long_form = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
                    max_count = 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
                    count     = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
                    switch ( ty ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
                        case HPROF_CHAR:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
                            long_form = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
                            max_count = 72;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
                            quote     = "\"";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
                            /*FALLTHRU*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
                        case HPROF_INT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
                        case HPROF_DOUBLE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
                        case HPROF_LONG:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
                        case HPROF_BYTE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
                        case HPROF_BOOLEAN:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
                        case HPROF_SHORT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
                        case HPROF_FLOAT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
                            check_printf("  val=%s", quote);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
                            for(i=0; i<num_elements; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
                                jvalue val;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
                                if ( i > 0 && count == 0 ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
                                    check_printf("  %s", quote);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
                                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
                                val = read_val(&p, ty);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
                                check_printf_val(ty, val, long_form);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
                                count += 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
                                if ( count >= max_count ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
                                    check_printf("\"\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
                                    count = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
                                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
                            if ( count != 0 ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
                                check_printf("%s\n", quote);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
                            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
                HPROF_ASSERT(type_size[ty]*num_elements==(p-psave));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
            default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
                label = "UNKNOWN";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
                check_printf("H#%d@%d %s: ERROR!\n",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
                                nrecords, npos, label);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
                HPROF_ERROR(JNI_TRUE, "unknown heap record type");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
    CHECK_FOR_ERROR(p==pstart+nbytes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
    table_cleanup(ctab, &cmap_cleanup, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
    return nrecords;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
/* LookupTable cleanup callback for utab */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
static void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
utab_cleanup(TableIndex i, void *key_ptr, int key_len, void*info, void*data)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
    UmapInfo *umap = info;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
    if ( umap == NULL ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
    if ( umap->str != NULL ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
        HPROF_FREE(umap->str);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
        umap->str = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
/* Check all the heap tags in a heap dump */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
check_tags(unsigned char *pstart, int nbytes)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
    unsigned char      *p;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
    int                 nrecord;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
    struct LookupTable *utab;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
    UmapInfo            umap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
    check_printf("\nCHECK TAGS: starting\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
    utab    = table_initialize("temp utf8 map", 64, 64, 512, sizeof(UmapInfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
    /* Walk the tags, assumes UTF8 tags are defined before used */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
    p       = pstart;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
    nrecord = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
    while ( p < (pstart+nbytes) ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
        unsigned     tag;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
        unsigned     size;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
        int          nheap_records;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
        int          npos;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
        char        *label;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
        HprofId      id, nm, sg, so, gr, gn;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
        int          i, li, num_elements;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
        HprofType    ty;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
        SerialNumber trace_serial_num;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
        SerialNumber thread_serial_num;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
        SerialNumber class_serial_num;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
        unsigned     flags;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
        unsigned     depth;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
        float        cutoff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
        unsigned     temp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
        jint         nblive;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
        jint         nilive;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
        jlong        tbytes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
        jlong        tinsts;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
        jint         total_samples;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
        jint         trace_count;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
        nrecord++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
        /*LINTED*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
        npos = (int)(p - pstart);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
        tag = read_u1(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
        (void)read_u4(&p); /* microsecs */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
        size = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
        #define CASE_TAG(name) case name: label = #name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
        switch ( tag ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
            CASE_TAG(HPROF_UTF8)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
                CHECK_FOR_ERROR(size>=(int)sizeof(HprofId));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
                id = read_id(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
                check_printf("#%d@%d: %s, sz=%d, name_id=0x%x, \"",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
                                nrecord, npos, label, size, id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
                num_elements = size-(int)sizeof(HprofId);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
                check_raw(p, num_elements);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
                check_printf("\"\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
                /* Create entry in umap */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
                umap.str = HPROF_MALLOC(num_elements+1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
                (void)strncpy(umap.str, (char*)p, (size_t)num_elements);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
                umap.str[num_elements] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
                (void)table_create_entry(utab, &id, sizeof(id), &umap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
                p += num_elements;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
            CASE_TAG(HPROF_LOAD_CLASS)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
                CHECK_FOR_ERROR(size==2*4+2*(int)sizeof(HprofId));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
                class_serial_num = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
                CHECK_CLASS_SERIAL_NO(class_serial_num);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
                id = read_id(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
                trace_serial_num = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
                CHECK_TRACE_SERIAL_NO(trace_serial_num);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
                nm = read_id(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
                check_printf("#%d@%d: %s, sz=%d, class_serial_num=%u,"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
                             " id=0x%x, trace_serial_num=%u, name_id=0x%x\n",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
                                nrecord, npos, label, size, class_serial_num,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
                                id, trace_serial_num, nm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
            CASE_TAG(HPROF_UNLOAD_CLASS)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
                CHECK_FOR_ERROR(size==4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
                class_serial_num = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
                CHECK_CLASS_SERIAL_NO(class_serial_num);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
                check_printf("#%d@%d: %s, sz=%d, class_serial_num=%u\n",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
                                nrecord, npos, label, size, class_serial_num);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
            CASE_TAG(HPROF_FRAME)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
                CHECK_FOR_ERROR(size==2*4+4*(int)sizeof(HprofId));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
                id = read_id(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
                nm = read_id(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
                sg = read_id(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
                so = read_id(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
                class_serial_num = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
                CHECK_CLASS_SERIAL_NO(class_serial_num);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
                li = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
                check_printf("#%d@%d: %s, sz=%d, ", nrecord, npos, label, size);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
                check_print_utf8(utab, "id=", id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
                check_printf(" name_id=0x%x, sig_id=0x%x, source_id=0x%x,"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
                             " class_serial_num=%u, lineno=%d\n",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
                                nm, sg, so, class_serial_num, li);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
            CASE_TAG(HPROF_TRACE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
                CHECK_FOR_ERROR(size>=3*4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
                trace_serial_num = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
                CHECK_TRACE_SERIAL_NO(trace_serial_num);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
                thread_serial_num = read_u4(&p); /* Can be 0 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
                num_elements = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
                check_printf("#%d@%d: %s, sz=%d, trace_serial_num=%u,"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
                             " thread_serial_num=%u, nelems=%d [",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
                                nrecord, npos, label, size,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
                                trace_serial_num, thread_serial_num, num_elements);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
                for(i=0; i< num_elements; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
                    check_printf("0x%x,", read_id(&p));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
                check_printf("]\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
            CASE_TAG(HPROF_ALLOC_SITES)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
                CHECK_FOR_ERROR(size>=2+4*4+2*8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
                flags = read_u2(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
                temp  = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
                cutoff = *((float*)&temp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
                nblive = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
                nilive = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
                tbytes = read_u8(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
                tinsts = read_u8(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
                num_elements     = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
                check_printf("#%d@%d: %s, sz=%d, flags=0x%x, cutoff=%g,"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
                             " nblive=%d, nilive=%d, tbytes=(%d,%d),"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
                             " tinsts=(%d,%d), num_elements=%d\n",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
                                nrecord, npos, label, size,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
                                flags, cutoff, nblive, nilive,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
                                jlong_high(tbytes), jlong_low(tbytes),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
                                jlong_high(tinsts), jlong_low(tinsts),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
                                num_elements);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
                for(i=0; i< num_elements; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
                    ty = read_u1(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
                    class_serial_num = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
                    CHECK_CLASS_SERIAL_NO(class_serial_num);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
                    trace_serial_num = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
                    CHECK_TRACE_SERIAL_NO(trace_serial_num);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
                    nblive = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
                    nilive = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
                    tbytes = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
                    tinsts = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
                    check_printf("\t %d: ty=%d, class_serial_num=%u,"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
                                 " trace_serial_num=%u, nblive=%d, nilive=%d,"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
                                 " tbytes=%d, tinsts=%d\n",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
                                 i, ty, class_serial_num, trace_serial_num,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
                                 nblive, nilive, (jint)tbytes, (jint)tinsts);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
            CASE_TAG(HPROF_HEAP_SUMMARY)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
                CHECK_FOR_ERROR(size==2*4+2*8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
                nblive = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
                nilive = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
                tbytes = read_u8(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
                tinsts = read_u8(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
                check_printf("#%d@%d: %s, sz=%d,"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
                             " nblive=%d, nilive=%d, tbytes=(%d,%d),"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
                             " tinsts=(%d,%d)\n",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
                                nrecord, npos, label, size,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
                                nblive, nilive,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
                                jlong_high(tbytes), jlong_low(tbytes),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
                                jlong_high(tinsts), jlong_low(tinsts));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
            CASE_TAG(HPROF_START_THREAD)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
                CHECK_FOR_ERROR(size==2*4+4*(int)sizeof(HprofId));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
                thread_serial_num = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
                CHECK_THREAD_SERIAL_NO(thread_serial_num);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
                id = read_id(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
                trace_serial_num = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
                CHECK_TRACE_SERIAL_NO(trace_serial_num);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
                nm = read_id(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
                gr = read_id(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
                gn = read_id(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
                check_printf("#%d@%d: %s, sz=%d, thread_serial_num=%u,"
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
                             " id=0x%x, trace_serial_num=%u, ",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
                                nrecord, npos, label, size,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
                                thread_serial_num, id, trace_serial_num);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
                check_print_utf8(utab, "nm=", id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
                check_printf(" trace_serial_num=%u, nm=0x%x,"
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
                             " gr=0x%x, gn=0x%x\n",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
                                trace_serial_num, nm, gr, gn);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
            CASE_TAG(HPROF_END_THREAD)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
                CHECK_FOR_ERROR(size==4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
                thread_serial_num = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
                CHECK_THREAD_SERIAL_NO(thread_serial_num);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
                check_printf("#%d@%d: %s, sz=%d, thread_serial_num=%u\n",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
                                nrecord, npos, label, size, thread_serial_num);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
            CASE_TAG(HPROF_HEAP_DUMP)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1032
                check_printf("#%d@%d: BEGIN: %s, sz=%d\n",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
                                nrecord, npos, label, size);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1034
                nheap_records = check_heap_tags(utab, p, size);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1035
                check_printf("#%d@%d: END: %s, sz=%d, nheap_recs=%d\n",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
                                nrecord, npos, label, size, nheap_records);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
                p += size;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1039
            CASE_TAG(HPROF_HEAP_DUMP_SEGMENT) /* 1.0.2 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
                check_printf("#%d@%d: BEGIN SEGMENT: %s, sz=%d\n",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
                                nrecord, npos, label, size);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
                nheap_records = check_heap_tags(utab, p, size);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1043
                check_printf("#%d@%d: END SEGMENT: %s, sz=%d, nheap_recs=%d\n",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
                                nrecord, npos, label, size, nheap_records);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
                p += size;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
            CASE_TAG(HPROF_HEAP_DUMP_END) /* 1.0.2 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
                check_printf("#%d@%d: SEGMENT END: %s, sz=%d\n",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
                                nrecord, npos, label, size);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
            CASE_TAG(HPROF_CPU_SAMPLES)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
                CHECK_FOR_ERROR(size>=2*4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
                total_samples = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
                trace_count = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
                check_printf("#%d@%d: %s, sz=%d, total_samples=%d,"
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
                             " trace_count=%d\n",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1057
                                nrecord, npos, label, size,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
                                total_samples, trace_count);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
                for(i=0; i< trace_count; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
                    num_elements = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1061
                    trace_serial_num = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
                    CHECK_TRACE_SERIAL_NO(trace_serial_num);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1063
                    check_printf("\t %d: samples=%d, trace_serial_num=%u\n",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1064
                                 trace_serial_num, num_elements);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1065
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1066
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1067
            CASE_TAG(HPROF_CONTROL_SETTINGS)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1068
                CHECK_FOR_ERROR(size==4+2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1069
                flags = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1070
                depth = read_u2(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1071
                check_printf("#%d@%d: %s, sz=%d, flags=0x%x, depth=%d\n",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1072
                                nrecord, npos, label, size, flags, depth);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1073
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1074
            default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
                label = "UNKNOWN";
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
                check_printf("#%d@%d: %s, sz=%d\n",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1077
                                nrecord, npos, label, size);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1078
                HPROF_ERROR(JNI_TRUE, "unknown record type");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1079
                p += size;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1080
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1081
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1082
        CHECK_FOR_ERROR(p<=(pstart+nbytes));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1083
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1084
    check_flush();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1085
    CHECK_FOR_ERROR(p==(pstart+nbytes));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1086
    table_cleanup(utab, &utab_cleanup, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1087
    return nrecord;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1088
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1089
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1090
/* Read the entire file into memory */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1091
static void *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1092
get_binary_file_image(char *filename, int *pnbytes)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1093
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1094
    unsigned char *image;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1095
    int            fd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1096
    jlong          nbytes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1097
    int            nread;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1098
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1099
    *pnbytes = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1100
    fd = md_open_binary(filename);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1101
    CHECK_FOR_ERROR(fd>=0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1102
    if ( (nbytes = md_seek(fd, (jlong)-1)) == (jlong)-1 ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1103
        HPROF_ERROR(JNI_TRUE, "Cannot md_seek() to end of file");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1104
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1105
    CHECK_FOR_ERROR(((jint)nbytes)>512);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1106
    if ( md_seek(fd, (jlong)0) != (jlong)0 ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1107
        HPROF_ERROR(JNI_TRUE, "Cannot md_seek() to start of file");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1108
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1109
    image = HPROF_MALLOC(((jint)nbytes)+1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1110
    CHECK_FOR_ERROR(image!=NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1111
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1112
    /* Read the entire file image into memory */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1113
    nread = md_read(fd, image, (jint)nbytes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1114
    if ( nread <= 0 ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1115
        HPROF_ERROR(JNI_TRUE, "System read failed.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1116
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1117
    CHECK_FOR_ERROR(((jint)nbytes)==nread);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1118
    md_close(fd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1119
    *pnbytes = (jint)nbytes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1120
    return image;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1121
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1122
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1123
/* ------------------------------------------------------------------ */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1124
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1125
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1126
check_binary_file(char *filename)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1127
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1128
    unsigned char *image;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1129
    unsigned char *p;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1130
    unsigned       idsize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1131
    int            nbytes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1132
    int            nrecords;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1133
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1134
    image = get_binary_file_image(filename, &nbytes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1135
    if ( image == NULL ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1136
        check_printf("No file image: %s\n", filename);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1137
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1138
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1139
    p = image;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1140
    CHECK_FOR_ERROR(strcmp((char*)p, gdata->header)==0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1141
    check_printf("Filename=%s, nbytes=%d, header=\"%s\"\n",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1142
                        filename, nbytes, p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1143
    p+=((int)strlen((char*)p)+1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1144
    idsize = read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1145
    CHECK_FOR_ERROR(idsize==sizeof(HprofId));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1146
    (void)read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1147
    (void)read_u4(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1148
    /* LINTED */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1149
    nrecords = check_tags(p, nbytes - (int)( p - image ) );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1150
    check_printf("#%d total records found in %d bytes\n", nrecords, nbytes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1151
    HPROF_FREE(image);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1152
}