jdk/src/share/back/error_messages.c
author ohair
Tue, 25 May 2010 15:58:33 -0700
changeset 5506 202f599c92aa
parent 1090 c5805b1672a6
child 14698 9294fcf94c46
permissions -rw-r--r--
6943119: Rebrand source copyright notices Reviewed-by: darcy, weijun
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: 1090
diff changeset
     2
 * Copyright (c) 2003, 2008, 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: 1090
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: 1090
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: 1090
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1090
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1090
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
/* Error message and general message handling functions. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
/* NOTE: We assume that most strings passed around this library are
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 *       UTF-8 (modified or standard) and not platform encoding.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 *       Before sending any strings to the "system" (e.g. OS system
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 *       calls, or system input/output functions like fprintf) we need
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 *       to make sure that the strings are transformed from UTF-8 to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 *       the platform encoding accepted by the system.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 *       UTF-8 and most encodings have simple ASCII or ISO-Latin
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 *       characters as a subset, so in most cases the strings really
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 *       don't need to be converted, but we don't know that easily.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 *       Parts of messages can be non-ASCII in some cases, so they may
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 *       include classnames, methodnames, signatures, or other pieces
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 *       that could contain non-ASCII characters, either from JNI or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 *       JVMTI (which both return modified UTF-8 strings).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 *       (It's possible that the platform encoding IS UTF-8, but we
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 *       assume not, just to be safe).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
#include <stdarg.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
#include <errno.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
#include "util.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
#include "proc_md.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
/* Maximim length of a message */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
#define MAX_MESSAGE_LEN MAXPATHLEN*2+512
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
/* Print message in platform encoding (assume all input is UTF-8 safe)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 *    NOTE: This function is at the lowest level of the call tree.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 *          Do not use the ERROR* macros here.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
static void
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
vprint_message(FILE *fp, const char *prefix, const char *suffix,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
               const char *format, va_list ap)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    jbyte  utf8buf[MAX_MESSAGE_LEN+1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    int    len;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    char   pbuf[MAX_MESSAGE_LEN+1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    /* Fill buffer with single UTF-8 string */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    (void)vsnprintf((char*)utf8buf, MAX_MESSAGE_LEN, format, ap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    utf8buf[MAX_MESSAGE_LEN] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    len = (int)strlen((char*)utf8buf);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    /* Convert to platform encoding (ignore errors, dangerous area) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    (void)(gdata->npt->utf8ToPlatform)(gdata->npt->utf,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
           utf8buf, len, pbuf, MAX_MESSAGE_LEN);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    (void)fprintf(fp, "%s%s%s", prefix, pbuf, suffix);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
/* Print message in platform encoding (assume all input is UTF-8 safe)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 *    NOTE: This function is at the lowest level of the call tree.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 *          Do not use the ERROR* macros here.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
print_message(FILE *fp, const char *prefix,  const char *suffix,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
              const char *format, ...)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    va_list ap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    va_start(ap, format);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    vprint_message(fp, prefix, suffix, format, ap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    va_end(ap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
/* Generate error message */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
error_message(const char *format, ...)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    va_list ap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    va_start(ap, format);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    vprint_message(stderr, "ERROR: ", "\n", format, ap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    va_end(ap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    if ( gdata->doerrorexit ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        EXIT_ERROR(AGENT_ERROR_INTERNAL,"Requested errorexit=y exit()");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
/* Print plain message to stdout. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
tty_message(const char *format, ...)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    va_list ap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    va_start(ap, format);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    vprint_message(stdout, "", "\n", format, ap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    va_end(ap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    (void)fflush(stdout);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
/* Print assertion error message to stderr. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
jdiAssertionFailed(char *fileName, int lineNumber, char *msg)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    LOG_MISC(("ASSERT FAILED: %s : %d - %s\n", fileName, lineNumber, msg));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    print_message(stderr, "ASSERT FAILED: ", "\n",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        "%s : %d - %s", fileName, lineNumber, msg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    if (gdata && gdata->assertFatal) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        EXIT_ERROR(AGENT_ERROR_INTERNAL,"Assertion Failed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
/* Macro for case on switch, returns string for name. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
#define CASE_RETURN_TEXT(name) case name: return #name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
/* Mapping of JVMTI errors to their name */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
const char *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
jvmtiErrorText(jvmtiError error)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    switch (error) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        CASE_RETURN_TEXT(JVMTI_ERROR_NONE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        CASE_RETURN_TEXT(JVMTI_ERROR_INVALID_THREAD)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        CASE_RETURN_TEXT(JVMTI_ERROR_INVALID_THREAD_GROUP)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        CASE_RETURN_TEXT(JVMTI_ERROR_INVALID_PRIORITY)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        CASE_RETURN_TEXT(JVMTI_ERROR_THREAD_NOT_SUSPENDED)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        CASE_RETURN_TEXT(JVMTI_ERROR_THREAD_SUSPENDED)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        CASE_RETURN_TEXT(JVMTI_ERROR_THREAD_NOT_ALIVE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        CASE_RETURN_TEXT(JVMTI_ERROR_INVALID_OBJECT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        CASE_RETURN_TEXT(JVMTI_ERROR_INVALID_CLASS)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        CASE_RETURN_TEXT(JVMTI_ERROR_CLASS_NOT_PREPARED)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        CASE_RETURN_TEXT(JVMTI_ERROR_INVALID_METHODID)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        CASE_RETURN_TEXT(JVMTI_ERROR_INVALID_LOCATION)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        CASE_RETURN_TEXT(JVMTI_ERROR_INVALID_FIELDID)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        CASE_RETURN_TEXT(JVMTI_ERROR_NO_MORE_FRAMES)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        CASE_RETURN_TEXT(JVMTI_ERROR_OPAQUE_FRAME)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        CASE_RETURN_TEXT(JVMTI_ERROR_TYPE_MISMATCH)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        CASE_RETURN_TEXT(JVMTI_ERROR_INVALID_SLOT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        CASE_RETURN_TEXT(JVMTI_ERROR_DUPLICATE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        CASE_RETURN_TEXT(JVMTI_ERROR_NOT_FOUND)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        CASE_RETURN_TEXT(JVMTI_ERROR_INVALID_MONITOR)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        CASE_RETURN_TEXT(JVMTI_ERROR_NOT_MONITOR_OWNER)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        CASE_RETURN_TEXT(JVMTI_ERROR_INTERRUPT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        CASE_RETURN_TEXT(JVMTI_ERROR_INVALID_CLASS_FORMAT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        CASE_RETURN_TEXT(JVMTI_ERROR_CIRCULAR_CLASS_DEFINITION)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        CASE_RETURN_TEXT(JVMTI_ERROR_FAILS_VERIFICATION)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        CASE_RETURN_TEXT(JVMTI_ERROR_UNSUPPORTED_REDEFINITION_METHOD_ADDED)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        CASE_RETURN_TEXT(JVMTI_ERROR_UNSUPPORTED_REDEFINITION_SCHEMA_CHANGED)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        CASE_RETURN_TEXT(JVMTI_ERROR_INVALID_TYPESTATE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        CASE_RETURN_TEXT(JVMTI_ERROR_UNSUPPORTED_REDEFINITION_HIERARCHY_CHANGED)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        CASE_RETURN_TEXT(JVMTI_ERROR_UNSUPPORTED_REDEFINITION_METHOD_DELETED)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        CASE_RETURN_TEXT(JVMTI_ERROR_UNSUPPORTED_VERSION)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        CASE_RETURN_TEXT(JVMTI_ERROR_NAMES_DONT_MATCH)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        CASE_RETURN_TEXT(JVMTI_ERROR_UNSUPPORTED_REDEFINITION_CLASS_MODIFIERS_CHANGED)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        CASE_RETURN_TEXT(JVMTI_ERROR_UNSUPPORTED_REDEFINITION_METHOD_MODIFIERS_CHANGED)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        CASE_RETURN_TEXT(JVMTI_ERROR_NOT_AVAILABLE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        CASE_RETURN_TEXT(JVMTI_ERROR_MUST_POSSESS_CAPABILITY)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        CASE_RETURN_TEXT(JVMTI_ERROR_NULL_POINTER)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        CASE_RETURN_TEXT(JVMTI_ERROR_ABSENT_INFORMATION)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        CASE_RETURN_TEXT(JVMTI_ERROR_INVALID_EVENT_TYPE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        CASE_RETURN_TEXT(JVMTI_ERROR_ILLEGAL_ARGUMENT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        CASE_RETURN_TEXT(JVMTI_ERROR_OUT_OF_MEMORY)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        CASE_RETURN_TEXT(JVMTI_ERROR_ACCESS_DENIED)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        CASE_RETURN_TEXT(JVMTI_ERROR_WRONG_PHASE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        CASE_RETURN_TEXT(JVMTI_ERROR_INTERNAL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        CASE_RETURN_TEXT(JVMTI_ERROR_UNATTACHED_THREAD)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        CASE_RETURN_TEXT(JVMTI_ERROR_INVALID_ENVIRONMENT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        CASE_RETURN_TEXT(AGENT_ERROR_INTERNAL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        CASE_RETURN_TEXT(AGENT_ERROR_VM_DEAD)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        CASE_RETURN_TEXT(AGENT_ERROR_NO_JNI_ENV)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        CASE_RETURN_TEXT(AGENT_ERROR_JNI_EXCEPTION)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        CASE_RETURN_TEXT(AGENT_ERROR_JVMTI_INTERNAL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        CASE_RETURN_TEXT(AGENT_ERROR_JDWP_INTERNAL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        CASE_RETURN_TEXT(AGENT_ERROR_NOT_CURRENT_FRAME)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        CASE_RETURN_TEXT(AGENT_ERROR_OUT_OF_MEMORY)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        CASE_RETURN_TEXT(AGENT_ERROR_INVALID_TAG)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        CASE_RETURN_TEXT(AGENT_ERROR_ALREADY_INVOKING)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        CASE_RETURN_TEXT(AGENT_ERROR_INVALID_INDEX)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        CASE_RETURN_TEXT(AGENT_ERROR_INVALID_LENGTH)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        CASE_RETURN_TEXT(AGENT_ERROR_INVALID_STRING)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        CASE_RETURN_TEXT(AGENT_ERROR_INVALID_CLASS_LOADER)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        CASE_RETURN_TEXT(AGENT_ERROR_INVALID_ARRAY)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        CASE_RETURN_TEXT(AGENT_ERROR_TRANSPORT_LOAD)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        CASE_RETURN_TEXT(AGENT_ERROR_TRANSPORT_INIT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        CASE_RETURN_TEXT(AGENT_ERROR_NATIVE_METHOD)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        CASE_RETURN_TEXT(AGENT_ERROR_INVALID_COUNT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        CASE_RETURN_TEXT(AGENT_ERROR_INVALID_FRAMEID)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        CASE_RETURN_TEXT(AGENT_ERROR_NULL_POINTER)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        CASE_RETURN_TEXT(AGENT_ERROR_ILLEGAL_ARGUMENT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        CASE_RETURN_TEXT(AGENT_ERROR_INVALID_THREAD)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        CASE_RETURN_TEXT(AGENT_ERROR_INVALID_EVENT_TYPE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        CASE_RETURN_TEXT(AGENT_ERROR_INVALID_OBJECT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        CASE_RETURN_TEXT(AGENT_ERROR_NO_MORE_FRAMES)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        default: return  "ERROR_unknown";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
const char *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
eventText(int i)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    switch ( i ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        CASE_RETURN_TEXT(EI_SINGLE_STEP)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        CASE_RETURN_TEXT(EI_BREAKPOINT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        CASE_RETURN_TEXT(EI_FRAME_POP)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        CASE_RETURN_TEXT(EI_EXCEPTION)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        CASE_RETURN_TEXT(EI_THREAD_START)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        CASE_RETURN_TEXT(EI_THREAD_END)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        CASE_RETURN_TEXT(EI_CLASS_PREPARE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        CASE_RETURN_TEXT(EI_CLASS_LOAD)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        CASE_RETURN_TEXT(EI_FIELD_ACCESS)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        CASE_RETURN_TEXT(EI_FIELD_MODIFICATION)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        CASE_RETURN_TEXT(EI_EXCEPTION_CATCH)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        CASE_RETURN_TEXT(EI_METHOD_ENTRY)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        CASE_RETURN_TEXT(EI_METHOD_EXIT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        CASE_RETURN_TEXT(EI_VM_INIT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        CASE_RETURN_TEXT(EI_VM_DEATH)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        CASE_RETURN_TEXT(EI_GC_FINISH)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        default: return "EVENT_unknown";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
/* Macro for case on switch, returns string for name. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
#define CASE_RETURN_JDWP_ERROR_TEXT(name) case JDWP_ERROR(name): return #name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
const char *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
jdwpErrorText(jdwpError serror)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    switch ( serror ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        CASE_RETURN_JDWP_ERROR_TEXT(NONE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        CASE_RETURN_JDWP_ERROR_TEXT(INVALID_THREAD)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        CASE_RETURN_JDWP_ERROR_TEXT(INVALID_THREAD_GROUP)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        CASE_RETURN_JDWP_ERROR_TEXT(INVALID_PRIORITY)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        CASE_RETURN_JDWP_ERROR_TEXT(THREAD_NOT_SUSPENDED)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        CASE_RETURN_JDWP_ERROR_TEXT(THREAD_SUSPENDED)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        CASE_RETURN_JDWP_ERROR_TEXT(INVALID_OBJECT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        CASE_RETURN_JDWP_ERROR_TEXT(INVALID_CLASS)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        CASE_RETURN_JDWP_ERROR_TEXT(CLASS_NOT_PREPARED)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        CASE_RETURN_JDWP_ERROR_TEXT(INVALID_METHODID)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
        CASE_RETURN_JDWP_ERROR_TEXT(INVALID_LOCATION)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        CASE_RETURN_JDWP_ERROR_TEXT(INVALID_FIELDID)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
        CASE_RETURN_JDWP_ERROR_TEXT(INVALID_FRAMEID)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        CASE_RETURN_JDWP_ERROR_TEXT(NO_MORE_FRAMES)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
        CASE_RETURN_JDWP_ERROR_TEXT(OPAQUE_FRAME)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
        CASE_RETURN_JDWP_ERROR_TEXT(NOT_CURRENT_FRAME)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
        CASE_RETURN_JDWP_ERROR_TEXT(TYPE_MISMATCH)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        CASE_RETURN_JDWP_ERROR_TEXT(INVALID_SLOT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
        CASE_RETURN_JDWP_ERROR_TEXT(DUPLICATE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
        CASE_RETURN_JDWP_ERROR_TEXT(NOT_FOUND)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
        CASE_RETURN_JDWP_ERROR_TEXT(INVALID_MONITOR)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
        CASE_RETURN_JDWP_ERROR_TEXT(NOT_MONITOR_OWNER)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
        CASE_RETURN_JDWP_ERROR_TEXT(INTERRUPT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
        CASE_RETURN_JDWP_ERROR_TEXT(INVALID_CLASS_FORMAT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
        CASE_RETURN_JDWP_ERROR_TEXT(CIRCULAR_CLASS_DEFINITION)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        CASE_RETURN_JDWP_ERROR_TEXT(FAILS_VERIFICATION)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
        CASE_RETURN_JDWP_ERROR_TEXT(ADD_METHOD_NOT_IMPLEMENTED)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
        CASE_RETURN_JDWP_ERROR_TEXT(SCHEMA_CHANGE_NOT_IMPLEMENTED)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        CASE_RETURN_JDWP_ERROR_TEXT(INVALID_TYPESTATE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        CASE_RETURN_JDWP_ERROR_TEXT(HIERARCHY_CHANGE_NOT_IMPLEMENTED)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        CASE_RETURN_JDWP_ERROR_TEXT(DELETE_METHOD_NOT_IMPLEMENTED)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
        CASE_RETURN_JDWP_ERROR_TEXT(UNSUPPORTED_VERSION)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        CASE_RETURN_JDWP_ERROR_TEXT(NAMES_DONT_MATCH)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        CASE_RETURN_JDWP_ERROR_TEXT(CLASS_MODIFIERS_CHANGE_NOT_IMPLEMENTED)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        CASE_RETURN_JDWP_ERROR_TEXT(METHOD_MODIFIERS_CHANGE_NOT_IMPLEMENTED)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        CASE_RETURN_JDWP_ERROR_TEXT(NOT_IMPLEMENTED)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        CASE_RETURN_JDWP_ERROR_TEXT(NULL_POINTER)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
        CASE_RETURN_JDWP_ERROR_TEXT(ABSENT_INFORMATION)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
        CASE_RETURN_JDWP_ERROR_TEXT(INVALID_EVENT_TYPE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
        CASE_RETURN_JDWP_ERROR_TEXT(ILLEGAL_ARGUMENT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
        CASE_RETURN_JDWP_ERROR_TEXT(OUT_OF_MEMORY)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
        CASE_RETURN_JDWP_ERROR_TEXT(ACCESS_DENIED)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
        CASE_RETURN_JDWP_ERROR_TEXT(VM_DEAD)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        CASE_RETURN_JDWP_ERROR_TEXT(INTERNAL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
        CASE_RETURN_JDWP_ERROR_TEXT(UNATTACHED_THREAD)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
        CASE_RETURN_JDWP_ERROR_TEXT(INVALID_TAG)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
        CASE_RETURN_JDWP_ERROR_TEXT(ALREADY_INVOKING)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
        CASE_RETURN_JDWP_ERROR_TEXT(INVALID_INDEX)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
        CASE_RETURN_JDWP_ERROR_TEXT(INVALID_LENGTH)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
        CASE_RETURN_JDWP_ERROR_TEXT(INVALID_STRING)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
        CASE_RETURN_JDWP_ERROR_TEXT(INVALID_CLASS_LOADER)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
        CASE_RETURN_JDWP_ERROR_TEXT(INVALID_ARRAY)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
        CASE_RETURN_JDWP_ERROR_TEXT(TRANSPORT_LOAD)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
        CASE_RETURN_JDWP_ERROR_TEXT(TRANSPORT_INIT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
        CASE_RETURN_JDWP_ERROR_TEXT(NATIVE_METHOD)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
        CASE_RETURN_JDWP_ERROR_TEXT(INVALID_COUNT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
        default: return "JDWP_ERROR_unknown";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
static int p = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
do_pause(void)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
    THREAD_T tid = GET_THREAD_ID();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
    PID_T pid    = GETPID();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
    int timeleft = 600; /* 10 minutes max */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
    int interval = 10;  /* 10 second message check */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
    /*LINTED*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
    tty_message("DEBUGGING: JDWP pause for PID %d, THREAD %d (0x%x)",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
                    /*LINTED*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
                    (int)(intptr_t)pid, (int)(intptr_t)tid, (int)(intptr_t)tid);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
    while ( p && timeleft > 0 ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
        (void)sleep(interval); /* 'assign p = 0;' to get out of loop */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
        timeleft -= interval;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
    if ( timeleft <= 0 ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
        tty_message("DEBUGGING: JDWP pause got tired of waiting and gave up.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
}