JdwpEvent.h revision 375fb116bcb817b37509ab579dbd55cdbb765cbf
1/* 2 * Copyright (C) 2008 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16/* 17 * Handle registration of events, and debugger event notification. 18 */ 19#ifndef DALVIK_JDWP_JDWPEVENT_H_ 20#define DALVIK_JDWP_JDWPEVENT_H_ 21 22#include "JdwpConstants.h" 23#include "ExpandBuf.h" 24 25/* 26 * Event modifiers. A JdwpEvent may have zero or more of these. 27 */ 28union JdwpEventMod { 29 u1 modKind; /* JdwpModKind */ 30 struct { 31 u1 modKind; 32 int count; 33 } count; 34 struct { 35 u1 modKind; 36 u4 exprId; 37 } conditional; 38 struct { 39 u1 modKind; 40 ObjectId threadId; 41 } threadOnly; 42 struct { 43 u1 modKind; 44 RefTypeId refTypeId; 45 } classOnly; 46 struct { 47 u1 modKind; 48 char* classPattern; 49 } classMatch; 50 struct { 51 u1 modKind; 52 char* classPattern; 53 } classExclude; 54 struct { 55 u1 modKind; 56 JdwpLocation loc; 57 } locationOnly; 58 struct { 59 u1 modKind; 60 u1 caught; 61 u1 uncaught; 62 RefTypeId refTypeId; 63 } exceptionOnly; 64 struct { 65 u1 modKind; 66 RefTypeId refTypeId; 67 FieldId fieldId; 68 } fieldOnly; 69 struct { 70 u1 modKind; 71 ObjectId threadId; 72 int size; /* JdwpStepSize */ 73 int depth; /* JdwpStepDepth */ 74 } step; 75 struct { 76 u1 modKind; 77 ObjectId objectId; 78 } instanceOnly; 79}; 80 81/* 82 * One of these for every registered event. 83 * 84 * We over-allocate the struct to hold the modifiers. 85 */ 86struct JdwpEvent { 87 JdwpEvent* prev; /* linked list */ 88 JdwpEvent* next; 89 90 JdwpEventKind eventKind; /* what kind of event is this? */ 91 JdwpSuspendPolicy suspendPolicy; /* suspend all, none, or self? */ 92 int modCount; /* #of entries in mods[] */ 93 u4 requestId; /* serial#, reported to debugger */ 94 95 JdwpEventMod mods[1]; /* MUST be last field in struct */ 96}; 97 98/* 99 * Allocate an event structure with enough space. 100 */ 101JdwpEvent* dvmJdwpEventAlloc(int numMods); 102void dvmJdwpEventFree(JdwpEvent* pEvent); 103 104/* 105 * Register an event by adding it to the event list. 106 * 107 * "*pEvent" must be storage allocated with jdwpEventAlloc(). The caller 108 * may discard its pointer after calling this. 109 */ 110JdwpError dvmJdwpRegisterEvent(JdwpState* state, JdwpEvent* pEvent); 111 112/* 113 * Unregister an event, given the requestId. 114 */ 115void dvmJdwpUnregisterEventById(JdwpState* state, u4 requestId); 116 117/* 118 * Unregister all events. 119 */ 120void dvmJdwpUnregisterAll(JdwpState* state); 121 122/* 123 * Send an event, formatted into "pReq", to the debugger. 124 * 125 * (Messages are sent asynchronously, and do not receive a reply.) 126 */ 127bool dvmJdwpSendRequest(JdwpState* state, ExpandBuf* pReq); 128 129#endif // DALVIK_JDWP_JDWPEVENT_H_ 130