JdwpEvent.h revision 2d63bc57d5fcbcd54f0bd3e9491e1704b98ec0bf
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
20#define _DALVIK_JDWP_JDWPEVENT
21
22#include "JdwpConstants.h"
23#include "ExpandBuf.h"
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
29/*
30 * Event modifiers.  A JdwpEvent may have zero or more of these.
31 */
32typedef union JdwpEventMod {
33    u1      modKind;                /* JdwpModKind */
34    struct {
35        u1          modKind;
36        int         count;
37    } count;
38    struct {
39        u1          modKind;
40        u4          exprId;
41    } conditional;
42    struct {
43        u1          modKind;
44        ObjectId    threadId;
45    } threadOnly;
46    struct {
47        u1          modKind;
48        RefTypeId   refTypeId;
49    } classOnly;
50    struct {
51        u1          modKind;
52        char*       classPattern;
53    } classMatch;
54    struct {
55        u1          modKind;
56        char*       classPattern;
57    } classExclude;
58    struct {
59        u1          modKind;
60        JdwpLocation loc;
61    } locationOnly;
62    struct {
63        u1          modKind;
64        u1          caught;
65        u1          uncaught;
66        RefTypeId   refTypeId;
67    } exceptionOnly;
68    struct {
69        u1          modKind;
70        RefTypeId   refTypeId;
71        FieldId     fieldId;
72    } fieldOnly;
73    struct {
74        u1          modKind;
75        ObjectId    threadId;
76        int         size;           /* JdwpStepSize */
77        int         depth;          /* JdwpStepDepth */
78    } step;
79    struct {
80        u1          modKind;
81        ObjectId    objectId;
82    } instanceOnly;
83} JdwpEventMod;
84
85/*
86 * One of these for every registered event.
87 *
88 * We over-allocate the struct to hold the modifiers.
89 */
90typedef struct JdwpEvent {
91    struct JdwpEvent*       prev;           /* linked list */
92    struct JdwpEvent*       next;
93
94    enum JdwpEventKind      eventKind;      /* what kind of event is this? */
95    enum JdwpSuspendPolicy  suspendPolicy;  /* suspend all, none, or self? */
96    int                     modCount;       /* #of entries in mods[] */
97    u4                      requestId;      /* serial#, reported to debugger */
98
99    JdwpEventMod            mods[1];        /* MUST be last field in struct */
100} JdwpEvent;
101
102/*
103 * Allocate an event structure with enough space.
104 */
105JdwpEvent* dvmJdwpEventAlloc(int numMods);
106void dvmJdwpEventFree(JdwpEvent* pEvent);
107
108/*
109 * Register an event by adding it to the event list.
110 *
111 * "*pEvent" must be storage allocated with jdwpEventAlloc().  The caller
112 * may discard its pointer after calling this.
113 */
114JdwpError dvmJdwpRegisterEvent(JdwpState* state, JdwpEvent* pEvent);
115
116/*
117 * Unregister an event, given the requestId.
118 */
119void dvmJdwpUnregisterEventById(JdwpState* state, u4 requestId);
120
121/*
122 * Unregister all events.
123 */
124void dvmJdwpUnregisterAll(JdwpState* state);
125
126/*
127 * Send an event, formatted into "pReq", to the debugger.
128 *
129 * (Messages are sent asynchronously, and do not receive a reply.)
130 */
131bool dvmJdwpSendRequest(JdwpState* state, ExpandBuf* pReq);
132
133#ifdef __cplusplus
134}
135#endif
136
137#endif /*_DALVIK_JDWP_JDWPEVENT*/
138