jdk/src/share/back/util.h
author lana
Fri, 23 Dec 2011 16:36:33 -0800
changeset 11304 5d3d2bd1dfd1
parent 5506 202f599c92aa
child 24967 582420f5ab6c
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 1998, 2005, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
#ifndef JDWP_UTIL_H
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
#define JDWP_UTIL_H
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
#include <stddef.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
#include <stdio.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
#include <string.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
#include <stdlib.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
#include <stdarg.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
#ifdef DEBUG
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
    /* Just to make sure these interfaces are not used here. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
    #undef free
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
    #define free(p) Do not use this interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
    #undef malloc
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
    #define malloc(p) Do not use this interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
    #undef calloc
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
    #define calloc(p) Do not use this interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    #undef realloc
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    #define realloc(p) Do not use this interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    #undef strdup
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    #define strdup(p) Do not use this interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
#include "log_messages.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
#include "vm_interface.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
#include "JDWP.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
#include "util_md.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
#include "error_messages.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
#include "debugInit.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
/* Get access to Native Platform Toolkit functions */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
#include "npt.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
/* Definition of a CommonRef tracked by the backend for the frontend */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
typedef struct RefNode {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    jlong        seqNum;        /* ID of reference, also key for hash table */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    jobject      ref;           /* could be strong or weak */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    struct RefNode *next;       /* next RefNode* in bucket chain */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    jint         count;         /* count of references */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    unsigned     isStrong : 1;  /* 1 means this is a string reference */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
} RefNode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
/* Value of a NULL ID */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
#define NULL_OBJECT_ID  ((jlong)0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * Globals used throughout the back end
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
typedef jint FrameNumber;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
typedef struct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    jvmtiEnv *jvmti;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    JavaVM   *jvm;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    volatile jboolean vmDead; /* Once VM is dead it stays that way - don't put in init */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    jboolean assertOn;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    jboolean assertFatal;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    jboolean doerrorexit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    jboolean modifiedUtf8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    jboolean quiet;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    /* Debug flags (bit mask) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    int      debugflags;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    /* Possible debug flags */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    #define USE_ITERATE_THROUGH_HEAP 0X001
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    char * options;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    jclass              classClass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    jclass              threadClass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    jclass              threadGroupClass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    jclass              classLoaderClass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    jclass              stringClass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    jclass              systemClass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    jmethodID           threadConstructor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    jmethodID           threadSetDaemon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    jmethodID           threadResume;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    jmethodID           systemGetProperty;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    jmethodID           setProperty;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    jthreadGroup        systemThreadGroup;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    jobject             agent_properties;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    jint                cachedJvmtiVersion;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    jvmtiCapabilities   cachedJvmtiCapabilities;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    jboolean            haveCachedJvmtiCapabilities;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    jvmtiEventCallbacks callbacks;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    /* Various property values we should grab on initialization */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    char* property_java_version;          /* UTF8 java.version */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    char* property_java_vm_name;          /* UTF8 java.vm.name */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    char* property_java_vm_info;          /* UTF8 java.vm.info */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    char* property_java_class_path;       /* UTF8 java.class.path */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    char* property_sun_boot_class_path;   /* UTF8 sun.boot.class.path */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    char* property_sun_boot_library_path; /* UTF8 sun.boot.library.path */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    char* property_path_separator;        /* UTF8 path.separator */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    char* property_user_dir;              /* UTF8 user.dir */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    unsigned log_flags;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    /* The Native Platform Toolkit access */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    NptEnv *npt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    /* Common References static data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    jrawMonitorID refLock;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    jlong         nextSeqNum;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    RefNode     **objectsByID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    int           objectsByIDsize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    int           objectsByIDcount;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     /* Indication that the agent has been loaded */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     jboolean isLoaded;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
} BackendGlobalData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
extern BackendGlobalData * gdata;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
 * Event Index for handlers
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
typedef enum {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        EI_min                  =  1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        EI_SINGLE_STEP          =  1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        EI_BREAKPOINT           =  2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        EI_FRAME_POP            =  3,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        EI_EXCEPTION            =  4,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        EI_THREAD_START         =  5,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        EI_THREAD_END           =  6,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        EI_CLASS_PREPARE        =  7,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        EI_GC_FINISH            =  8,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        EI_CLASS_LOAD           =  9,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        EI_FIELD_ACCESS         = 10,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        EI_FIELD_MODIFICATION   = 11,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        EI_EXCEPTION_CATCH      = 12,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        EI_METHOD_ENTRY         = 13,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        EI_METHOD_EXIT          = 14,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        EI_MONITOR_CONTENDED_ENTER = 15,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        EI_MONITOR_CONTENDED_ENTERED = 16,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        EI_MONITOR_WAIT         = 17,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        EI_MONITOR_WAITED       = 18,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        EI_VM_INIT              = 19,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        EI_VM_DEATH             = 20,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        EI_max                  = 20
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
} EventIndex;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
/* Agent errors that might be in a jvmtiError for JDWP or internal.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
 *    (Done this way so that compiler allows it's use as a jvmtiError)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
#define _AGENT_ERROR(x)                 ((jvmtiError)(JVMTI_ERROR_MAX+64+x))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
#define AGENT_ERROR_INTERNAL                    _AGENT_ERROR(1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
#define AGENT_ERROR_VM_DEAD                     _AGENT_ERROR(2)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
#define AGENT_ERROR_NO_JNI_ENV                  _AGENT_ERROR(3)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
#define AGENT_ERROR_JNI_EXCEPTION               _AGENT_ERROR(4)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
#define AGENT_ERROR_JVMTI_INTERNAL              _AGENT_ERROR(5)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
#define AGENT_ERROR_JDWP_INTERNAL               _AGENT_ERROR(6)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
#define AGENT_ERROR_NOT_CURRENT_FRAME           _AGENT_ERROR(7)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
#define AGENT_ERROR_OUT_OF_MEMORY               _AGENT_ERROR(8)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
#define AGENT_ERROR_INVALID_TAG                 _AGENT_ERROR(9)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
#define AGENT_ERROR_ALREADY_INVOKING            _AGENT_ERROR(10)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
#define AGENT_ERROR_INVALID_INDEX               _AGENT_ERROR(11)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
#define AGENT_ERROR_INVALID_LENGTH              _AGENT_ERROR(12)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
#define AGENT_ERROR_INVALID_STRING              _AGENT_ERROR(13)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
#define AGENT_ERROR_INVALID_CLASS_LOADER        _AGENT_ERROR(14)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
#define AGENT_ERROR_INVALID_ARRAY               _AGENT_ERROR(15)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
#define AGENT_ERROR_TRANSPORT_LOAD              _AGENT_ERROR(16)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
#define AGENT_ERROR_TRANSPORT_INIT              _AGENT_ERROR(17)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
#define AGENT_ERROR_NATIVE_METHOD               _AGENT_ERROR(18)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
#define AGENT_ERROR_INVALID_COUNT               _AGENT_ERROR(19)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
#define AGENT_ERROR_INVALID_FRAMEID             _AGENT_ERROR(20)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
#define AGENT_ERROR_NULL_POINTER                _AGENT_ERROR(21)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
#define AGENT_ERROR_ILLEGAL_ARGUMENT            _AGENT_ERROR(22)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
#define AGENT_ERROR_INVALID_THREAD              _AGENT_ERROR(23)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
#define AGENT_ERROR_INVALID_EVENT_TYPE          _AGENT_ERROR(24)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
#define AGENT_ERROR_INVALID_OBJECT              _AGENT_ERROR(25)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
#define AGENT_ERROR_NO_MORE_FRAMES              _AGENT_ERROR(26)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
/* Combined event information */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
typedef struct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    EventIndex  ei;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    jthread     thread;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    jclass      clazz;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    jmethodID   method;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
    jlocation   location;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    jobject     object; /* possibly an exception or user object */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    union {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        /* ei = EI_FIELD_ACCESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        struct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
            jclass      field_clazz;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
            jfieldID    field;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        } field_access;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        /* ei = EI_FIELD_MODIFICATION */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        struct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
            jclass      field_clazz;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
            jfieldID    field;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
            char        signature_type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
            jvalue      new_value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        } field_modification;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        /* ei = EI_EXCEPTION */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        struct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
            jclass      catch_clazz;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
            jmethodID   catch_method;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
            jlocation   catch_location;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        } exception;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        /* ei = EI_METHOD_EXIT */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        struct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
            jvalue      return_value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
        } method_exit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        /* For monitor wait events */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        union {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
            /* ei = EI_MONITOR_WAIT */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
            jlong timeout;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
            /* ei = EI_MONITOR_WAITED */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
            jboolean timed_out;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        } monitor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    } u;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
} EventInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
/* Structure to hold dynamic array of objects */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
typedef struct ObjectBatch {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    jobject *objects;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    jint     count;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
} ObjectBatch;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
 * JNI signature constants, beyond those defined in JDWP_TAG(*)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
#define SIGNATURE_BEGIN_ARGS    '('
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
#define SIGNATURE_END_ARGS      ')'
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
#define SIGNATURE_END_CLASS     ';'
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
 * Modifier flags for classes, fields, methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
#define MOD_PUBLIC       0x0001     /* visible to everyone */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
#define MOD_PRIVATE      0x0002     /* visible only to the defining class */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
#define MOD_PROTECTED    0x0004     /* visible to subclasses */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
#define MOD_STATIC       0x0008     /* instance variable is static */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
#define MOD_FINAL        0x0010     /* no further subclassing, overriding */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
#define MOD_SYNCHRONIZED 0x0020     /* wrap method call in monitor lock */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
#define MOD_VOLATILE     0x0040     /* can cache in registers */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
#define MOD_TRANSIENT    0x0080     /* not persistant */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
#define MOD_NATIVE       0x0100     /* implemented in C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
#define MOD_INTERFACE    0x0200     /* class is an interface */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
#define MOD_ABSTRACT     0x0400     /* no definition provided */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
 * Additional modifiers not defined as such in the JVM spec
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
#define MOD_SYNTHETIC    0xf0000000  /* not in source code */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
 * jlong conversion macros
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
#define jlong_zero       ((jlong) 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
#define jlong_one        ((jlong) 1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
#define jlong_to_ptr(a)  ((void*)(intptr_t)(a))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
#define ptr_to_jlong(a)  ((jlong)(intptr_t)(a))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
#define jint_to_jlong(a) ((jlong)(a))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
#define jlong_to_jint(a) ((jint)(a))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
 * util funcs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
void util_initialize(JNIEnv *env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
void util_reset(void);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
struct PacketInputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
struct PacketOutputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
jint uniqueID(void);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
jbyte referenceTypeTag(jclass clazz);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
jbyte specificTypeKey(JNIEnv *env, jobject object);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
jboolean isObjectTag(jbyte tag);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
jvmtiError spawnNewThread(jvmtiStartFunction func, void *arg, char *name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
void convertSignatureToClassname(char *convert);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
void writeCodeLocation(struct PacketOutputStream *out, jclass clazz,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
                       jmethodID method, jlocation location);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
jvmtiError classInstances(jclass klass, ObjectBatch *instances, int maxInstances);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
jvmtiError classInstanceCounts(jint classCount, jclass *classes, jlong *counts);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
jvmtiError objectReferrers(jobject obj, ObjectBatch *referrers, int maxObjects);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
 * Command handling helpers shared among multiple command sets
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
int filterDebugThreads(jthread *threads, int count);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
void sharedGetFieldValues(struct PacketInputStream *in,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
                          struct PacketOutputStream *out,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
                          jboolean isStatic);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
jboolean sharedInvoke(struct PacketInputStream *in,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
                      struct PacketOutputStream *out);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
jvmtiError fieldSignature(jclass, jfieldID, char **, char **, char **);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
jvmtiError fieldModifiers(jclass, jfieldID, jint *);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
jvmtiError methodSignature(jmethodID, char **, char **, char **);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
jvmtiError methodReturnType(jmethodID, char *);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
jvmtiError methodModifiers(jmethodID, jint *);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
jvmtiError methodClass(jmethodID, jclass *);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
jvmtiError methodLocation(jmethodID, jlocation*, jlocation*);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
jvmtiError classLoader(jclass, jobject *);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
 * Thin wrappers on top of JNI
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
JNIEnv *getEnv(void);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
jboolean isClass(jobject object);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
jboolean isThread(jobject object);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
jboolean isThreadGroup(jobject object);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
jboolean isString(jobject object);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
jboolean isClassLoader(jobject object);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
jboolean isArray(jobject object);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
 * Thin wrappers on top of JVMTI
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
jvmtiError jvmtiGetCapabilities(jvmtiCapabilities *caps);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
jint jvmtiMajorVersion(void);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
jint jvmtiMinorVersion(void);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
jint jvmtiMicroVersion(void);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
jvmtiError getSourceDebugExtension(jclass clazz, char **extensionPtr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
jboolean canSuspendResumeThreadLists(void);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
jrawMonitorID debugMonitorCreate(char *name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
void debugMonitorEnter(jrawMonitorID theLock);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
void debugMonitorExit(jrawMonitorID theLock);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
void debugMonitorWait(jrawMonitorID theLock);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
void debugMonitorTimedWait(jrawMonitorID theLock, jlong millis);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
void debugMonitorNotify(jrawMonitorID theLock);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
void debugMonitorNotifyAll(jrawMonitorID theLock);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
void debugMonitorDestroy(jrawMonitorID theLock);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
jthread *allThreads(jint *count);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
void threadGroupInfo(jthreadGroup, jvmtiThreadGroupInfo *info);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
char *getClassname(jclass);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
jvmtiError classSignature(jclass, char**, char**);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
jint classStatus(jclass);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
void writeGenericSignature(struct PacketOutputStream *, char *);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
jboolean isMethodNative(jmethodID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
jboolean isMethodObsolete(jmethodID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
jvmtiError isMethodSynthetic(jmethodID, jboolean*);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
jvmtiError isFieldSynthetic(jclass, jfieldID, jboolean*);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
jboolean isSameObject(JNIEnv *env, jobject o1, jobject o2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
jint objectHashCode(jobject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
jvmtiError allInterfaces(jclass clazz, jclass **ppinterfaces, jint *count);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
jvmtiError allLoadedClasses(jclass **ppclasses, jint *count);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
jvmtiError allClassLoaderClasses(jobject loader, jclass **ppclasses, jint *count);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
jvmtiError allNestedClasses(jclass clazz, jclass **ppnested, jint *pcount);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
void setAgentPropertyValue(JNIEnv *env, char *propertyName, char* propertyValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
void *jvmtiAllocate(jint numBytes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
void jvmtiDeallocate(void *buffer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
void             eventIndexInit(void);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
jdwpEvent        eventIndex2jdwp(EventIndex i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
jvmtiEvent       eventIndex2jvmti(EventIndex i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
EventIndex       jdwp2EventIndex(jdwpEvent eventType);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
EventIndex       jvmti2EventIndex(jvmtiEvent kind);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
jvmtiError       map2jvmtiError(jdwpError);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
jdwpError        map2jdwpError(jvmtiError);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
jdwpThreadStatus map2jdwpThreadStatus(jint state);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
jint             map2jdwpSuspendStatus(jint state);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
jint             map2jdwpClassStatus(jint);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
void log_debugee_location(const char *func,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
                jthread thread, jmethodID method, jlocation location);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
 * Local Reference management. The two macros below are used
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
 * throughout the back end whenever space for JNI local references
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
 * is needed in the current frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
void createLocalRefSpace(JNIEnv *env, jint capacity);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
#define WITH_LOCAL_REFS(env, number) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
    createLocalRefSpace(env, number); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
    { /* BEGINNING OF WITH SCOPE */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
#define END_WITH_LOCAL_REFS(env) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
        JNI_FUNC_PTR(env,PopLocalFrame)(env, NULL); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
    } /* END OF WITH SCOPE */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
void saveGlobalRef(JNIEnv *env, jobject obj, jobject *pobj);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
void tossGlobalRef(JNIEnv *env, jobject *pobj);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
#endif