|
1 /* |
|
2 * Copyright 1998-2005 Sun Microsystems, Inc. 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. Sun designates this |
|
8 * particular file as subject to the "Classpath" exception as provided |
|
9 * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
|
22 * CA 95054 USA or visit www.sun.com if you need additional information or |
|
23 * have any 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 #include "typedefs.h" |
|
45 |
|
46 static void **l1Array; |
|
47 |
|
48 void |
|
49 debugDispatch_initialize(void) |
|
50 { |
|
51 /* |
|
52 * Create the level-one (CommandSet) dispatch table. |
|
53 * Zero the table so that unknown CommandSets do not |
|
54 * cause random errors. |
|
55 */ |
|
56 l1Array = jvmtiAllocate((JDWP_HIGHEST_COMMAND_SET+1) * sizeof(void *)); |
|
57 |
|
58 if (l1Array == NULL) { |
|
59 EXIT_ERROR(AGENT_ERROR_OUT_OF_MEMORY,"command set array"); |
|
60 } |
|
61 |
|
62 (void)memset(l1Array, 0, (JDWP_HIGHEST_COMMAND_SET+1) * sizeof(void *)); |
|
63 |
|
64 /* |
|
65 * Create the level-two (Command) dispatch tables to the |
|
66 * corresponding slots in the CommandSet dispatch table.. |
|
67 */ |
|
68 l1Array[JDWP_COMMAND_SET(VirtualMachine)] = (void *)VirtualMachine_Cmds; |
|
69 l1Array[JDWP_COMMAND_SET(ReferenceType)] = (void *)ReferenceType_Cmds; |
|
70 l1Array[JDWP_COMMAND_SET(ClassType)] = (void *)ClassType_Cmds; |
|
71 l1Array[JDWP_COMMAND_SET(ArrayType)] = (void *)ArrayType_Cmds; |
|
72 |
|
73 l1Array[JDWP_COMMAND_SET(Field)] = (void *)Field_Cmds; |
|
74 l1Array[JDWP_COMMAND_SET(Method)] = (void *)Method_Cmds; |
|
75 l1Array[JDWP_COMMAND_SET(ObjectReference)] = (void *)ObjectReference_Cmds; |
|
76 l1Array[JDWP_COMMAND_SET(StringReference)] = (void *)StringReference_Cmds; |
|
77 l1Array[JDWP_COMMAND_SET(ThreadReference)] = (void *)ThreadReference_Cmds; |
|
78 l1Array[JDWP_COMMAND_SET(ThreadGroupReference)] = (void *)ThreadGroupReference_Cmds; |
|
79 l1Array[JDWP_COMMAND_SET(ClassLoaderReference)] = (void *)ClassLoaderReference_Cmds; |
|
80 l1Array[JDWP_COMMAND_SET(ArrayReference)] = (void *)ArrayReference_Cmds; |
|
81 l1Array[JDWP_COMMAND_SET(EventRequest)] = (void *)EventRequest_Cmds; |
|
82 l1Array[JDWP_COMMAND_SET(StackFrame)] = (void *)StackFrame_Cmds; |
|
83 l1Array[JDWP_COMMAND_SET(ClassObjectReference)] = (void *)ClassObjectReference_Cmds; |
|
84 } |
|
85 |
|
86 void |
|
87 debugDispatch_reset(void) |
|
88 { |
|
89 } |
|
90 |
|
91 CommandHandler |
|
92 debugDispatch_getHandler(int cmdSet, int cmd) |
|
93 { |
|
94 void **l2Array; |
|
95 |
|
96 if (cmdSet > JDWP_HIGHEST_COMMAND_SET) { |
|
97 return NULL; |
|
98 } |
|
99 |
|
100 l2Array = (void **)l1Array[cmdSet]; |
|
101 |
|
102 /* |
|
103 * If there is no such CommandSet or the Command |
|
104 * is greater than the nummber of commands (the first |
|
105 * element) in the CommandSet, indicate this is invalid. |
|
106 */ |
|
107 /*LINTED*/ |
|
108 if (l2Array == NULL || cmd > (int)(intptr_t)(void*)l2Array[0]) { |
|
109 return NULL; |
|
110 } |
|
111 |
|
112 return (CommandHandler)l2Array[cmd]; |
|
113 } |