1 | /*
|
---|
2 | * Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved.
|
---|
3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
---|
4 | *
|
---|
5 | * This code is free software; you can redistribute it and/or modify it
|
---|
6 | * under the terms of the GNU General Public License version 2 only, as
|
---|
7 | * published by the Free Software Foundation. Oracle designates this
|
---|
8 | * particular file as subject to the "Classpath" exception as provided
|
---|
9 | * by Oracle in the LICENSE file that accompanied this code.
|
---|
10 | *
|
---|
11 | * This code is distributed in the hope that it will be useful, but WITHOUT
|
---|
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
---|
13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
---|
14 | * version 2 for more details (a copy is included in the LICENSE file that
|
---|
15 | * accompanied this code).
|
---|
16 | *
|
---|
17 | * You should have received a copy of the GNU General Public License version
|
---|
18 | * 2 along with this work; if not, write to the Free Software Foundation,
|
---|
19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
---|
20 | *
|
---|
21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
---|
22 | * or visit www.oracle.com if you need additional information or have any
|
---|
23 | * questions.
|
---|
24 | */
|
---|
25 |
|
---|
26 | #include "util.h"
|
---|
27 | #include "transport.h"
|
---|
28 | #include "debugDispatch.h"
|
---|
29 | #include "VirtualMachineImpl.h"
|
---|
30 | #include "ReferenceTypeImpl.h"
|
---|
31 | #include "ClassTypeImpl.h"
|
---|
32 | #include "ArrayTypeImpl.h"
|
---|
33 | #include "FieldImpl.h"
|
---|
34 | #include "MethodImpl.h"
|
---|
35 | #include "ObjectReferenceImpl.h"
|
---|
36 | #include "StringReferenceImpl.h"
|
---|
37 | #include "ThreadReferenceImpl.h"
|
---|
38 | #include "ThreadGroupReferenceImpl.h"
|
---|
39 | #include "ClassLoaderReferenceImpl.h"
|
---|
40 | #include "ClassObjectReferenceImpl.h"
|
---|
41 | #include "ArrayReferenceImpl.h"
|
---|
42 | #include "EventRequestImpl.h"
|
---|
43 | #include "StackFrameImpl.h"
|
---|
44 |
|
---|
45 | static void **l1Array;
|
---|
46 |
|
---|
47 | void
|
---|
48 | debugDispatch_initialize(void)
|
---|
49 | {
|
---|
50 | /*
|
---|
51 | * Create the level-one (CommandSet) dispatch table.
|
---|
52 | * Zero the table so that unknown CommandSets do not
|
---|
53 | * cause random errors.
|
---|
54 | */
|
---|
55 | l1Array = jvmtiAllocate((JDWP_HIGHEST_COMMAND_SET+1) * sizeof(void *));
|
---|
56 |
|
---|
57 | if (l1Array == NULL) {
|
---|
58 | EXIT_ERROR(AGENT_ERROR_OUT_OF_MEMORY,"command set array");
|
---|
59 | }
|
---|
60 |
|
---|
61 | (void)memset(l1Array, 0, (JDWP_HIGHEST_COMMAND_SET+1) * sizeof(void *));
|
---|
62 |
|
---|
63 | /*
|
---|
64 | * Create the level-two (Command) dispatch tables to the
|
---|
65 | * corresponding slots in the CommandSet dispatch table..
|
---|
66 | */
|
---|
67 | l1Array[JDWP_COMMAND_SET(VirtualMachine)] = (void *)VirtualMachine_Cmds;
|
---|
68 | l1Array[JDWP_COMMAND_SET(ReferenceType)] = (void *)ReferenceType_Cmds;
|
---|
69 | l1Array[JDWP_COMMAND_SET(ClassType)] = (void *)ClassType_Cmds;
|
---|
70 | l1Array[JDWP_COMMAND_SET(ArrayType)] = (void *)ArrayType_Cmds;
|
---|
71 |
|
---|
72 | l1Array[JDWP_COMMAND_SET(Field)] = (void *)Field_Cmds;
|
---|
73 | l1Array[JDWP_COMMAND_SET(Method)] = (void *)Method_Cmds;
|
---|
74 | l1Array[JDWP_COMMAND_SET(ObjectReference)] = (void *)ObjectReference_Cmds;
|
---|
75 | l1Array[JDWP_COMMAND_SET(StringReference)] = (void *)StringReference_Cmds;
|
---|
76 | l1Array[JDWP_COMMAND_SET(ThreadReference)] = (void *)ThreadReference_Cmds;
|
---|
77 | l1Array[JDWP_COMMAND_SET(ThreadGroupReference)] = (void *)ThreadGroupReference_Cmds;
|
---|
78 | l1Array[JDWP_COMMAND_SET(ClassLoaderReference)] = (void *)ClassLoaderReference_Cmds;
|
---|
79 | l1Array[JDWP_COMMAND_SET(ArrayReference)] = (void *)ArrayReference_Cmds;
|
---|
80 | l1Array[JDWP_COMMAND_SET(EventRequest)] = (void *)EventRequest_Cmds;
|
---|
81 | l1Array[JDWP_COMMAND_SET(StackFrame)] = (void *)StackFrame_Cmds;
|
---|
82 | l1Array[JDWP_COMMAND_SET(ClassObjectReference)] = (void *)ClassObjectReference_Cmds;
|
---|
83 | }
|
---|
84 |
|
---|
85 | void
|
---|
86 | debugDispatch_reset(void)
|
---|
87 | {
|
---|
88 | }
|
---|
89 |
|
---|
90 | CommandHandler
|
---|
91 | debugDispatch_getHandler(int cmdSet, int cmd)
|
---|
92 | {
|
---|
93 | void **l2Array;
|
---|
94 |
|
---|
95 | if (cmdSet > JDWP_HIGHEST_COMMAND_SET) {
|
---|
96 | return NULL;
|
---|
97 | }
|
---|
98 |
|
---|
99 | l2Array = (void **)l1Array[cmdSet];
|
---|
100 |
|
---|
101 | /*
|
---|
102 | * If there is no such CommandSet or the Command
|
---|
103 | * is greater than the nummber of commands (the first
|
---|
104 | * element) in the CommandSet, indicate this is invalid.
|
---|
105 | */
|
---|
106 | /*LINTED*/
|
---|
107 | if (l2Array == NULL || cmd > (int)(intptr_t)(void*)l2Array[0]) {
|
---|
108 | return NULL;
|
---|
109 | }
|
---|
110 |
|
---|
111 | return (CommandHandler)l2Array[cmd];
|
---|
112 | }
|
---|