jdk/src/jdk.jdwp.agent/share/native/libjdwp/util.h
author bobv
Mon, 19 Oct 2015 13:41:09 -0400
changeset 33653 c1ee09fe3274
parent 25859 3317bb8137f4
child 36511 9d0388c6b336
permissions -rw-r--r--
8136556: Add the ability to perform static builds of MacOSX x64 binaries Reviewed-by: ihse, bdelsart, gadams, lfoltan, rriggs, hseigel, twisti
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
33653
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 25859
diff changeset
     2
 * Copyright (c) 1998, 2015, 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
/* Definition of a CommonRef tracked by the backend for the frontend */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
typedef struct RefNode {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    jlong        seqNum;        /* ID of reference, also key for hash table */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    jobject      ref;           /* could be strong or weak */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    struct RefNode *next;       /* next RefNode* in bucket chain */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    jint         count;         /* count of references */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    unsigned     isStrong : 1;  /* 1 means this is a string reference */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
} RefNode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
/* Value of a NULL ID */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
#define NULL_OBJECT_ID  ((jlong)0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * Globals used throughout the back end
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
typedef jint FrameNumber;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
typedef struct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    jvmtiEnv *jvmti;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    JavaVM   *jvm;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    volatile jboolean vmDead; /* Once VM is dead it stays that way - don't put in init */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    jboolean assertOn;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    jboolean assertFatal;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    jboolean doerrorexit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    jboolean modifiedUtf8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    jboolean quiet;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    /* Debug flags (bit mask) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    int      debugflags;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    /* Possible debug flags */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    #define USE_ITERATE_THROUGH_HEAP 0X001
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    char * options;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    jclass              classClass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    jclass              threadClass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    jclass              threadGroupClass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    jclass              classLoaderClass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    jclass              stringClass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    jclass              systemClass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    jmethodID           threadConstructor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    jmethodID           threadSetDaemon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    jmethodID           threadResume;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    jmethodID           systemGetProperty;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    jmethodID           setProperty;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    jthreadGroup        systemThreadGroup;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    jobject             agent_properties;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    jint                cachedJvmtiVersion;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    jvmtiCapabilities   cachedJvmtiCapabilities;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    jboolean            haveCachedJvmtiCapabilities;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    jvmtiEventCallbacks callbacks;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    /* Various property values we should grab on initialization */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    char* property_java_version;          /* UTF8 java.version */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    char* property_java_vm_name;          /* UTF8 java.vm.name */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    char* property_java_vm_info;          /* UTF8 java.vm.info */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    char* property_java_class_path;       /* UTF8 java.class.path */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    char* property_sun_boot_class_path;   /* UTF8 sun.boot.class.path */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    char* property_sun_boot_library_path; /* UTF8 sun.boot.library.path */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    char* property_path_separator;        /* UTF8 path.separator */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    char* property_user_dir;              /* UTF8 user.dir */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    unsigned log_flags;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    /* Common References static data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    jrawMonitorID refLock;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    jlong         nextSeqNum;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    RefNode     **objectsByID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    int           objectsByIDsize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    int           objectsByIDcount;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     /* Indication that the agent has been loaded */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     jboolean isLoaded;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
} BackendGlobalData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
extern BackendGlobalData * gdata;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
 * Event Index for handlers
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
typedef enum {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        EI_min                  =  1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        EI_SINGLE_STEP          =  1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        EI_BREAKPOINT           =  2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        EI_FRAME_POP            =  3,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        EI_EXCEPTION            =  4,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        EI_THREAD_START         =  5,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        EI_THREAD_END           =  6,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        EI_CLASS_PREPARE        =  7,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        EI_GC_FINISH            =  8,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        EI_CLASS_LOAD           =  9,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        EI_FIELD_ACCESS         = 10,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        EI_FIELD_MODIFICATION   = 11,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        EI_EXCEPTION_CATCH      = 12,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        EI_METHOD_ENTRY         = 13,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        EI_METHOD_EXIT          = 14,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        EI_MONITOR_CONTENDED_ENTER = 15,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        EI_MONITOR_CONTENDED_ENTERED = 16,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        EI_MONITOR_WAIT         = 17,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        EI_MONITOR_WAITED       = 18,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        EI_VM_INIT              = 19,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        EI_VM_DEATH             = 20,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        EI_max                  = 20
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
} EventIndex;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
/* Agent errors that might be in a jvmtiError for JDWP or internal.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
 *    (Done this way so that compiler allows it's use as a jvmtiError)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
#define _AGENT_ERROR(x)                 ((jvmtiError)(JVMTI_ERROR_MAX+64+x))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
#define AGENT_ERROR_INTERNAL                    _AGENT_ERROR(1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
#define AGENT_ERROR_VM_DEAD                     _AGENT_ERROR(2)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
#define AGENT_ERROR_NO_JNI_ENV                  _AGENT_ERROR(3)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
#define AGENT_ERROR_JNI_EXCEPTION               _AGENT_ERROR(4)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
#define AGENT_ERROR_JVMTI_INTERNAL              _AGENT_ERROR(5)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
#define AGENT_ERROR_JDWP_INTERNAL               _AGENT_ERROR(6)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
#define AGENT_ERROR_NOT_CURRENT_FRAME           _AGENT_ERROR(7)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
#define AGENT_ERROR_OUT_OF_MEMORY               _AGENT_ERROR(8)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
#define AGENT_ERROR_INVALID_TAG                 _AGENT_ERROR(9)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
#define AGENT_ERROR_ALREADY_INVOKING            _AGENT_ERROR(10)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
#define AGENT_ERROR_INVALID_INDEX               _AGENT_ERROR(11)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
#define AGENT_ERROR_INVALID_LENGTH              _AGENT_ERROR(12)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
#define AGENT_ERROR_INVALID_STRING              _AGENT_ERROR(13)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
#define AGENT_ERROR_INVALID_CLASS_LOADER        _AGENT_ERROR(14)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
#define AGENT_ERROR_INVALID_ARRAY               _AGENT_ERROR(15)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
#define AGENT_ERROR_TRANSPORT_LOAD              _AGENT_ERROR(16)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
#define AGENT_ERROR_TRANSPORT_INIT              _AGENT_ERROR(17)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
#define AGENT_ERROR_NATIVE_METHOD               _AGENT_ERROR(18)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
#define AGENT_ERROR_INVALID_COUNT               _AGENT_ERROR(19)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
#define AGENT_ERROR_INVALID_FRAMEID             _AGENT_ERROR(20)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
#define AGENT_ERROR_NULL_POINTER                _AGENT_ERROR(21)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
#define AGENT_ERROR_ILLEGAL_ARGUMENT            _AGENT_ERROR(22)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
#define AGENT_ERROR_INVALID_THREAD              _AGENT_ERROR(23)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
#define AGENT_ERROR_INVALID_EVENT_TYPE          _AGENT_ERROR(24)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
#define AGENT_ERROR_INVALID_OBJECT              _AGENT_ERROR(25)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
#define AGENT_ERROR_NO_MORE_FRAMES              _AGENT_ERROR(26)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
/* Combined event information */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
typedef struct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    EventIndex  ei;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    jthread     thread;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    jclass      clazz;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    jmethodID   method;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    jlocation   location;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    jobject     object; /* possibly an exception or user object */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    union {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        /* ei = EI_FIELD_ACCESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        struct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
            jclass      field_clazz;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
            jfieldID    field;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        } field_access;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        /* ei = EI_FIELD_MODIFICATION */
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
            char        signature_type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
            jvalue      new_value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        } field_modification;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        /* ei = EI_EXCEPTION */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        struct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
            jclass      catch_clazz;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
            jmethodID   catch_method;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
            jlocation   catch_location;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        } exception;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        /* ei = EI_METHOD_EXIT */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        struct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
            jvalue      return_value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        } method_exit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        /* For monitor wait events */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        union {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
            /* ei = EI_MONITOR_WAIT */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
            jlong timeout;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
            /* ei = EI_MONITOR_WAITED */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
            jboolean timed_out;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        } monitor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    } u;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
} EventInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
/* Structure to hold dynamic array of objects */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
typedef struct ObjectBatch {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    jobject *objects;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    jint     count;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
} ObjectBatch;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
 * JNI signature constants, beyond those defined in JDWP_TAG(*)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
#define SIGNATURE_BEGIN_ARGS    '('
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
#define SIGNATURE_END_ARGS      ')'
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
#define SIGNATURE_END_CLASS     ';'
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
 * Modifier flags for classes, fields, methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
#define MOD_PUBLIC       0x0001     /* visible to everyone */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
#define MOD_PRIVATE      0x0002     /* visible only to the defining class */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
#define MOD_PROTECTED    0x0004     /* visible to subclasses */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
#define MOD_STATIC       0x0008     /* instance variable is static */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
#define MOD_FINAL        0x0010     /* no further subclassing, overriding */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
#define MOD_SYNCHRONIZED 0x0020     /* wrap method call in monitor lock */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
#define MOD_VOLATILE     0x0040     /* can cache in registers */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
#define MOD_TRANSIENT    0x0080     /* not persistant */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
#define MOD_NATIVE       0x0100     /* implemented in C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
#define MOD_INTERFACE    0x0200     /* class is an interface */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
#define MOD_ABSTRACT     0x0400     /* no definition provided */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
 * Additional modifiers not defined as such in the JVM spec
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
#define MOD_SYNTHETIC    0xf0000000  /* not in source code */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
 * util funcs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
void util_initialize(JNIEnv *env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
void util_reset(void);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
struct PacketInputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
struct PacketOutputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
jint uniqueID(void);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
jbyte referenceTypeTag(jclass clazz);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
jbyte specificTypeKey(JNIEnv *env, jobject object);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
jboolean isObjectTag(jbyte tag);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
jvmtiError spawnNewThread(jvmtiStartFunction func, void *arg, char *name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
void convertSignatureToClassname(char *convert);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
void writeCodeLocation(struct PacketOutputStream *out, jclass clazz,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
                       jmethodID method, jlocation location);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
jvmtiError classInstances(jclass klass, ObjectBatch *instances, int maxInstances);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
jvmtiError classInstanceCounts(jint classCount, jclass *classes, jlong *counts);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
jvmtiError objectReferrers(jobject obj, ObjectBatch *referrers, int maxObjects);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
 * Command handling helpers shared among multiple command sets
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
int filterDebugThreads(jthread *threads, int count);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
void sharedGetFieldValues(struct PacketInputStream *in,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
                          struct PacketOutputStream *out,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
                          jboolean isStatic);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
jboolean sharedInvoke(struct PacketInputStream *in,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
                      struct PacketOutputStream *out);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
jvmtiError fieldSignature(jclass, jfieldID, char **, char **, char **);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
jvmtiError fieldModifiers(jclass, jfieldID, jint *);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
jvmtiError methodSignature(jmethodID, char **, char **, char **);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
jvmtiError methodReturnType(jmethodID, char *);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
jvmtiError methodModifiers(jmethodID, jint *);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
jvmtiError methodClass(jmethodID, jclass *);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
jvmtiError methodLocation(jmethodID, jlocation*, jlocation*);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
jvmtiError classLoader(jclass, jobject *);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
 * Thin wrappers on top of JNI
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
JNIEnv *getEnv(void);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
jboolean isClass(jobject object);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
jboolean isThread(jobject object);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
jboolean isThreadGroup(jobject object);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
jboolean isString(jobject object);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
jboolean isClassLoader(jobject object);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
jboolean isArray(jobject object);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
 * Thin wrappers on top of JVMTI
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
jvmtiError jvmtiGetCapabilities(jvmtiCapabilities *caps);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
jint jvmtiMajorVersion(void);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
jint jvmtiMinorVersion(void);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
jint jvmtiMicroVersion(void);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
jvmtiError getSourceDebugExtension(jclass clazz, char **extensionPtr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
jboolean canSuspendResumeThreadLists(void);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
jrawMonitorID debugMonitorCreate(char *name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
void debugMonitorEnter(jrawMonitorID theLock);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
void debugMonitorExit(jrawMonitorID theLock);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
void debugMonitorWait(jrawMonitorID theLock);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
void debugMonitorTimedWait(jrawMonitorID theLock, jlong millis);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
void debugMonitorNotify(jrawMonitorID theLock);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
void debugMonitorNotifyAll(jrawMonitorID theLock);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
void debugMonitorDestroy(jrawMonitorID theLock);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
jthread *allThreads(jint *count);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
void threadGroupInfo(jthreadGroup, jvmtiThreadGroupInfo *info);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
char *getClassname(jclass);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
jvmtiError classSignature(jclass, char**, char**);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
jint classStatus(jclass);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
void writeGenericSignature(struct PacketOutputStream *, char *);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
jboolean isMethodNative(jmethodID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
jboolean isMethodObsolete(jmethodID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
jvmtiError isMethodSynthetic(jmethodID, jboolean*);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
jvmtiError isFieldSynthetic(jclass, jfieldID, jboolean*);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
jboolean isSameObject(JNIEnv *env, jobject o1, jobject o2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
jint objectHashCode(jobject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
jvmtiError allInterfaces(jclass clazz, jclass **ppinterfaces, jint *count);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
jvmtiError allLoadedClasses(jclass **ppclasses, jint *count);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
jvmtiError allClassLoaderClasses(jobject loader, jclass **ppclasses, jint *count);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
jvmtiError allNestedClasses(jclass clazz, jclass **ppnested, jint *pcount);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
void setAgentPropertyValue(JNIEnv *env, char *propertyName, char* propertyValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
void *jvmtiAllocate(jint numBytes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
void jvmtiDeallocate(void *buffer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
void             eventIndexInit(void);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
jdwpEvent        eventIndex2jdwp(EventIndex i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
jvmtiEvent       eventIndex2jvmti(EventIndex i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
EventIndex       jdwp2EventIndex(jdwpEvent eventType);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
EventIndex       jvmti2EventIndex(jvmtiEvent kind);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
jvmtiError       map2jvmtiError(jdwpError);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
jdwpError        map2jdwpError(jvmtiError);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
jdwpThreadStatus map2jdwpThreadStatus(jint state);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
jint             map2jdwpSuspendStatus(jint state);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
jint             map2jdwpClassStatus(jint);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
void log_debugee_location(const char *func,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
                jthread thread, jmethodID method, jlocation location);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
 * Local Reference management. The two macros below are used
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
 * throughout the back end whenever space for JNI local references
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
 * is needed in the current frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
void createLocalRefSpace(JNIEnv *env, jint capacity);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
#define WITH_LOCAL_REFS(env, number) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
    createLocalRefSpace(env, number); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
    { /* BEGINNING OF WITH SCOPE */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
#define END_WITH_LOCAL_REFS(env) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
        JNI_FUNC_PTR(env,PopLocalFrame)(env, NULL); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
    } /* END OF WITH SCOPE */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
void saveGlobalRef(JNIEnv *env, jobject obj, jobject *pobj);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
void tossGlobalRef(JNIEnv *env, jobject *pobj);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
#endif