jdk/src/share/back/debugDispatch.c
author jbachorik
Tue, 29 Apr 2014 14:37:02 +0200
changeset 24127 5d05d4c0de7f
parent 24125 b85eeaae56c7
child 24195 705325a63a58
permissions -rw-r--r--
8042096: Backout JDK-8042091 Reviewed-by: sla
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) 1998, 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
#include "util.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
#include "transport.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
#include "debugDispatch.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
#include "VirtualMachineImpl.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
#include "ReferenceTypeImpl.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
#include "ClassTypeImpl.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
#include "ArrayTypeImpl.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
#include "FieldImpl.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
#include "MethodImpl.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
#include "ObjectReferenceImpl.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
#include "StringReferenceImpl.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
#include "ThreadReferenceImpl.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
#include "ThreadGroupReferenceImpl.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
#include "ClassLoaderReferenceImpl.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
#include "ClassObjectReferenceImpl.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
#include "ArrayReferenceImpl.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
#include "EventRequestImpl.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
#include "StackFrameImpl.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
static void **l1Array;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
debugDispatch_initialize(void)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
     * Create the level-one (CommandSet) dispatch table.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
     * Zero the table so that unknown CommandSets do not
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
     * cause random errors.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    l1Array = jvmtiAllocate((JDWP_HIGHEST_COMMAND_SET+1) * sizeof(void *));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    if (l1Array == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
        EXIT_ERROR(AGENT_ERROR_OUT_OF_MEMORY,"command set array");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    (void)memset(l1Array, 0, (JDWP_HIGHEST_COMMAND_SET+1) * sizeof(void *));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     * Create the level-two (Command) dispatch tables to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     * corresponding slots in the CommandSet dispatch table..
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    l1Array[JDWP_COMMAND_SET(VirtualMachine)] = (void *)VirtualMachine_Cmds;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    l1Array[JDWP_COMMAND_SET(ReferenceType)] = (void *)ReferenceType_Cmds;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    l1Array[JDWP_COMMAND_SET(ClassType)] = (void *)ClassType_Cmds;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    l1Array[JDWP_COMMAND_SET(ArrayType)] = (void *)ArrayType_Cmds;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    l1Array[JDWP_COMMAND_SET(Field)] = (void *)Field_Cmds;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    l1Array[JDWP_COMMAND_SET(Method)] = (void *)Method_Cmds;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    l1Array[JDWP_COMMAND_SET(ObjectReference)] = (void *)ObjectReference_Cmds;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    l1Array[JDWP_COMMAND_SET(StringReference)] = (void *)StringReference_Cmds;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    l1Array[JDWP_COMMAND_SET(ThreadReference)] = (void *)ThreadReference_Cmds;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    l1Array[JDWP_COMMAND_SET(ThreadGroupReference)] = (void *)ThreadGroupReference_Cmds;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    l1Array[JDWP_COMMAND_SET(ClassLoaderReference)] = (void *)ClassLoaderReference_Cmds;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    l1Array[JDWP_COMMAND_SET(ArrayReference)] = (void *)ArrayReference_Cmds;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    l1Array[JDWP_COMMAND_SET(EventRequest)] = (void *)EventRequest_Cmds;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    l1Array[JDWP_COMMAND_SET(StackFrame)] = (void *)StackFrame_Cmds;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    l1Array[JDWP_COMMAND_SET(ClassObjectReference)] = (void *)ClassObjectReference_Cmds;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
debugDispatch_reset(void)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
CommandHandler
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
debugDispatch_getHandler(int cmdSet, int cmd)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    void **l2Array;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    if (cmdSet > JDWP_HIGHEST_COMMAND_SET) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    l2Array = (void **)l1Array[cmdSet];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * If there is no such CommandSet or the Command
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * is greater than the nummber of commands (the first
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * element) in the CommandSet, indicate this is invalid.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    /*LINTED*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    if (l2Array == NULL || cmd > (int)(intptr_t)(void*)l2Array[0]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    return (CommandHandler)l2Array[cmd];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
}