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 ART_RUNTIME_JDWP_JDWP_EVENT_H_
20 #define ART_RUNTIME_JDWP_JDWP_EVENT_H_
21 
22 #include "jdwp/jdwp.h"
23 #include "jdwp/jdwp_constants.h"
24 #include "jdwp/jdwp_expand_buf.h"
25 
26 namespace art {
27 
28 namespace JDWP {
29 
30 /*
31  * Event modifiers.  A JdwpEvent may have zero or more of these.
32  */
33 union JdwpEventMod {
34   JdwpModKind modKind;
35   struct {
36     JdwpModKind modKind;
37     int         count;
38   } count;
39   struct {
40     JdwpModKind modKind;
41     uint32_t          exprId;
42   } conditional;
43   struct {
44     JdwpModKind modKind;
45     ObjectId    threadId;
46   } threadOnly;
47   struct {
48     JdwpModKind modKind;
49     RefTypeId   refTypeId;
50   } classOnly;
51   struct {
52     JdwpModKind modKind;
53     char*       classPattern;
54   } classMatch;
55   struct {
56     JdwpModKind modKind;
57     char*       classPattern;
58   } classExclude;
59   struct {
60     JdwpModKind modKind;
61     JdwpLocation loc;
62   } locationOnly;
63   struct {
64     JdwpModKind modKind;
65     uint8_t          caught;
66     uint8_t          uncaught;
67     RefTypeId   refTypeId;
68   } exceptionOnly;
69   struct {
70     JdwpModKind modKind;
71     RefTypeId   refTypeId;
72     FieldId     fieldId;
73   } fieldOnly;
74   struct {
75     JdwpModKind modKind;
76     ObjectId    threadId;
77     int         size;           /* JdwpStepSize */
78     int         depth;          /* JdwpStepDepth */
79   } step;
80   struct {
81     JdwpModKind modKind;
82     ObjectId    objectId;
83   } instanceOnly;
84 };
85 
86 /*
87  * One of these for every registered event.
88  *
89  * We over-allocate the struct to hold the modifiers.
90  */
91 struct JdwpEvent {
92   JdwpEvent* prev;           /* linked list */
93   JdwpEvent* next;
94 
95   JdwpEventKind eventKind;      /* what kind of event is this? */
96   JdwpSuspendPolicy suspend_policy;  /* suspend all, none, or self? */
97   int modCount;       /* #of entries in mods[] */
98   uint32_t requestId;      /* serial#, reported to debugger */
99 
100   JdwpEventMod mods[1];        /* MUST be last field in struct */
101 };
102 
103 /*
104  * Allocate an event structure with enough space.
105  */
106 JdwpEvent* EventAlloc(int numMods);
107 void EventFree(JdwpEvent* pEvent);
108 
109 }  // namespace JDWP
110 
111 }  // namespace art
112 
113 #endif  // ART_RUNTIME_JDWP_JDWP_EVENT_H_
114