Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 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 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 17 | #ifndef ART_RUNTIME_JDWP_JDWP_H_ |
| 18 | #define ART_RUNTIME_JDWP_JDWP_H_ |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 19 | |
David Sehr | c431b9d | 2018-03-02 12:01:51 -0800 | [diff] [blame] | 20 | #include "base/atomic.h" |
Andreas Gampe | 5794381 | 2017-12-06 21:39:13 -0800 | [diff] [blame] | 21 | #include "base/logging.h" // For VLOG. |
Elliott Hughes | 76b6167 | 2012-12-12 17:47:30 -0800 | [diff] [blame] | 22 | #include "base/mutex.h" |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 23 | #include "jdwp/jdwp_bits.h" |
| 24 | #include "jdwp/jdwp_constants.h" |
| 25 | #include "jdwp/jdwp_expand_buf.h" |
Alex Light | 5643caf | 2017-02-08 11:39:07 -0800 | [diff] [blame] | 26 | #include "obj_ptr.h" |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 27 | |
| 28 | #include <pthread.h> |
| 29 | #include <stddef.h> |
| 30 | #include <stdint.h> |
| 31 | #include <string.h> |
Sebastien Hertz | 7d95565 | 2014-10-22 10:57:10 +0200 | [diff] [blame] | 32 | #include <vector> |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 33 | |
| 34 | struct iovec; |
| 35 | |
| 36 | namespace art { |
Ian Rogers | 719d1a3 | 2014-03-06 12:13:39 -0800 | [diff] [blame] | 37 | |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 38 | class ArtField; |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 39 | class ArtMethod; |
Ian Rogers | 719d1a3 | 2014-03-06 12:13:39 -0800 | [diff] [blame] | 40 | union JValue; |
| 41 | class Thread; |
| 42 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 43 | namespace mirror { |
Igor Murashkin | 2ffb703 | 2017-11-08 13:35:21 -0800 | [diff] [blame] | 44 | class Class; |
| 45 | class Object; |
| 46 | class Throwable; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 47 | } // namespace mirror |
Sebastien Hertz | 6995c60 | 2014-09-09 12:10:13 +0200 | [diff] [blame] | 48 | class Thread; |
Elliott Hughes | 475fc23 | 2011-10-25 15:00:35 -0700 | [diff] [blame] | 49 | |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 50 | namespace JDWP { |
| 51 | |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 52 | /* |
| 53 | * Fundamental types. |
| 54 | * |
| 55 | * ObjectId and RefTypeId must be the same size. |
Mathieu Chartier | d3ed9a3 | 2015-04-10 14:23:35 -0700 | [diff] [blame] | 56 | * Its OK to change MethodId and FieldId sizes as long as the size is <= 8 bytes. |
| 57 | * Note that ArtFields are 64 bit pointers on 64 bit targets. So this one must remain 8 bytes. |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 58 | */ |
Mathieu Chartier | d3ed9a3 | 2015-04-10 14:23:35 -0700 | [diff] [blame] | 59 | typedef uint64_t FieldId; /* static or instance field */ |
| 60 | typedef uint64_t MethodId; /* any kind of method, including constructors */ |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 61 | typedef uint64_t ObjectId; /* any object (threadID, stringID, arrayID, etc) */ |
| 62 | typedef uint64_t RefTypeId; /* like ObjectID, but unique for Class objects */ |
| 63 | typedef uint64_t FrameId; /* short-lived stack frame ID */ |
| 64 | |
Elliott Hughes | a96836a | 2013-01-17 12:27:49 -0800 | [diff] [blame] | 65 | ObjectId ReadObjectId(const uint8_t** pBuf); |
| 66 | |
Mathieu Chartier | d3ed9a3 | 2015-04-10 14:23:35 -0700 | [diff] [blame] | 67 | static inline void SetFieldId(uint8_t* buf, FieldId val) { return Set8BE(buf, val); } |
| 68 | static inline void SetMethodId(uint8_t* buf, MethodId val) { return Set8BE(buf, val); } |
Elliott Hughes | f7c3b66 | 2011-10-27 12:04:56 -0700 | [diff] [blame] | 69 | static inline void SetObjectId(uint8_t* buf, ObjectId val) { return Set8BE(buf, val); } |
| 70 | static inline void SetRefTypeId(uint8_t* buf, RefTypeId val) { return Set8BE(buf, val); } |
| 71 | static inline void SetFrameId(uint8_t* buf, FrameId val) { return Set8BE(buf, val); } |
Mathieu Chartier | d3ed9a3 | 2015-04-10 14:23:35 -0700 | [diff] [blame] | 72 | static inline void expandBufAddFieldId(ExpandBuf* pReply, FieldId id) { expandBufAdd8BE(pReply, id); } |
| 73 | static inline void expandBufAddMethodId(ExpandBuf* pReply, MethodId id) { expandBufAdd8BE(pReply, id); } |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 74 | static inline void expandBufAddObjectId(ExpandBuf* pReply, ObjectId id) { expandBufAdd8BE(pReply, id); } |
| 75 | static inline void expandBufAddRefTypeId(ExpandBuf* pReply, RefTypeId id) { expandBufAdd8BE(pReply, id); } |
| 76 | static inline void expandBufAddFrameId(ExpandBuf* pReply, FrameId id) { expandBufAdd8BE(pReply, id); } |
| 77 | |
Sebastien Hertz | 6995c60 | 2014-09-09 12:10:13 +0200 | [diff] [blame] | 78 | struct EventLocation { |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 79 | ArtMethod* method; |
Sebastien Hertz | 6995c60 | 2014-09-09 12:10:13 +0200 | [diff] [blame] | 80 | uint32_t dex_pc; |
| 81 | }; |
| 82 | |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 83 | /* |
| 84 | * Holds a JDWP "location". |
| 85 | */ |
| 86 | struct JdwpLocation { |
Elliott Hughes | 7484741 | 2012-06-20 18:10:21 -0700 | [diff] [blame] | 87 | JdwpTypeTag type_tag; |
| 88 | RefTypeId class_id; |
| 89 | MethodId method_id; |
Elliott Hughes | 972a47b | 2012-02-21 18:16:06 -0800 | [diff] [blame] | 90 | uint64_t dex_pc; |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 91 | }; |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 92 | std::ostream& operator<<(std::ostream& os, const JdwpLocation& rhs) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 93 | REQUIRES_SHARED(Locks::mutator_lock_); |
Elliott Hughes | 2aa2e39 | 2012-02-17 17:15:43 -0800 | [diff] [blame] | 94 | bool operator==(const JdwpLocation& lhs, const JdwpLocation& rhs); |
| 95 | bool operator!=(const JdwpLocation& lhs, const JdwpLocation& rhs); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 96 | |
| 97 | /* |
| 98 | * How we talk to the debugger. |
| 99 | */ |
| 100 | enum JdwpTransportType { |
Alex Light | 4032071 | 2017-12-14 11:52:04 -0800 | [diff] [blame] | 101 | kJdwpTransportNone = 0, |
| 102 | kJdwpTransportUnknown, // Unknown tranpsort |
Elliott Hughes | 0e57ccb | 2012-04-03 16:04:52 -0700 | [diff] [blame] | 103 | kJdwpTransportSocket, // transport=dt_socket |
| 104 | kJdwpTransportAndroidAdb, // transport=dt_android_adb |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 105 | }; |
| 106 | std::ostream& operator<<(std::ostream& os, const JdwpTransportType& rhs); |
| 107 | |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 108 | struct JdwpOptions { |
Alex Light | 4032071 | 2017-12-14 11:52:04 -0800 | [diff] [blame] | 109 | JdwpTransportType transport = kJdwpTransportNone; |
Sebastien Hertz | 3be6e9d | 2015-02-05 16:30:58 +0100 | [diff] [blame] | 110 | bool server = false; |
| 111 | bool suspend = false; |
| 112 | std::string host = ""; |
| 113 | uint16_t port = static_cast<uint16_t>(-1); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 114 | }; |
| 115 | |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 116 | bool operator==(const JdwpOptions& lhs, const JdwpOptions& rhs); |
| 117 | |
Alex Light | 4032071 | 2017-12-14 11:52:04 -0800 | [diff] [blame] | 118 | bool ParseJdwpOptions(const std::string& options, JdwpOptions* jdwp_options); |
| 119 | |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 120 | struct JdwpEvent; |
Ian Rogers | b48b9eb | 2014-02-28 16:20:21 -0800 | [diff] [blame] | 121 | class JdwpNetStateBase; |
Elliott Hughes | 761928d | 2011-11-16 18:33:03 -0800 | [diff] [blame] | 122 | struct ModBasket; |
Ian Rogers | b48b9eb | 2014-02-28 16:20:21 -0800 | [diff] [blame] | 123 | class Request; |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 124 | |
| 125 | /* |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 126 | * State for JDWP functions. |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 127 | */ |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 128 | struct JdwpState { |
| 129 | /* |
| 130 | * Perform one-time initialization. |
| 131 | * |
| 132 | * Among other things, this binds to a port to listen for a connection from |
| 133 | * the debugger. |
| 134 | * |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 135 | * Returns a newly-allocated JdwpState struct on success, or nullptr on failure. |
Mathieu Chartier | 90ef3db | 2015-08-04 15:19:41 -0700 | [diff] [blame] | 136 | * |
| 137 | * NO_THREAD_SAFETY_ANALYSIS since we can't annotate that we do not have |
| 138 | * state->thread_start_lock_ held. |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 139 | */ |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 140 | static JdwpState* Create(const JdwpOptions* options) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 141 | REQUIRES(!Locks::mutator_lock_) NO_THREAD_SAFETY_ANALYSIS; |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 142 | |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 143 | ~JdwpState(); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 144 | |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 145 | /* |
| 146 | * Returns "true" if a debugger or DDM is connected. |
| 147 | */ |
| 148 | bool IsActive(); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 149 | |
Elliott Hughes | 475fc23 | 2011-10-25 15:00:35 -0700 | [diff] [blame] | 150 | /** |
| 151 | * Returns the Thread* for the JDWP daemon thread. |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 152 | */ |
Elliott Hughes | 475fc23 | 2011-10-25 15:00:35 -0700 | [diff] [blame] | 153 | Thread* GetDebugThread(); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 154 | |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 155 | /* |
| 156 | * Get time, in milliseconds, since the last debugger activity. |
| 157 | */ |
| 158 | int64_t LastDebuggerActivity(); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 159 | |
Elliott Hughes | 64f574f | 2013-02-20 14:57:12 -0800 | [diff] [blame] | 160 | void ExitAfterReplying(int exit_status); |
| 161 | |
Sebastien Hertz | 2bf93f4 | 2015-01-09 18:44:05 +0100 | [diff] [blame] | 162 | // Acquires/releases the JDWP synchronization token for the debugger |
| 163 | // thread (command handler) so no event thread posts an event while |
| 164 | // it processes a command. This must be called only from the debugger |
| 165 | // thread. |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 166 | void AcquireJdwpTokenForCommand() REQUIRES(!jdwp_token_lock_); |
| 167 | void ReleaseJdwpTokenForCommand() REQUIRES(!jdwp_token_lock_); |
Sebastien Hertz | 2bf93f4 | 2015-01-09 18:44:05 +0100 | [diff] [blame] | 168 | |
| 169 | // Acquires/releases the JDWP synchronization token for the event thread |
| 170 | // so no other thread (debugger thread or event thread) interleaves with |
| 171 | // it when posting an event. This must NOT be called from the debugger |
| 172 | // thread, only event thread. |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 173 | void AcquireJdwpTokenForEvent(ObjectId threadId) REQUIRES(!jdwp_token_lock_); |
| 174 | void ReleaseJdwpTokenForEvent() REQUIRES(!jdwp_token_lock_); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 175 | |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 176 | /* |
| 177 | * These notify the debug code that something interesting has happened. This |
| 178 | * could be a thread starting or ending, an exception, or an opportunity |
| 179 | * for a breakpoint. These calls do not mean that an event the debugger |
| 180 | * is interested has happened, just that something has happened that the |
| 181 | * debugger *might* be interested in. |
| 182 | * |
| 183 | * The item of interest may trigger multiple events, some or all of which |
| 184 | * are grouped together in a single response. |
| 185 | * |
| 186 | * The event may cause the current thread or all threads (except the |
| 187 | * JDWP support thread) to be suspended. |
| 188 | */ |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 189 | |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 190 | /* |
| 191 | * The VM has finished initializing. Only called when the debugger is |
| 192 | * connected at the time initialization completes. |
| 193 | */ |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 194 | void PostVMStart() REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!jdwp_token_lock_); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 195 | |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 196 | /* |
| 197 | * A location of interest has been reached. This is used for breakpoints, |
| 198 | * single-stepping, and method entry/exit. (JDWP requires that these four |
| 199 | * events are grouped together in a single response.) |
| 200 | * |
| 201 | * In some cases "*pLoc" will just have a method and class name, e.g. when |
| 202 | * issuing a MethodEntry on a native method. |
| 203 | * |
| 204 | * "eventFlags" indicates the types of events that have occurred. |
Jeff Hao | 579b024 | 2013-11-18 13:16:49 -0800 | [diff] [blame] | 205 | * |
| 206 | * "returnValue" is non-null for MethodExit events only. |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 207 | */ |
Vladimir Marko | 8311489 | 2019-04-11 13:05:50 +0100 | [diff] [blame] | 208 | void PostLocationEvent(const EventLocation* pLoc, |
| 209 | ObjPtr<mirror::Object> thisPtr, |
| 210 | int eventFlags, |
Jeff Hao | 579b024 | 2013-11-18 13:16:49 -0800 | [diff] [blame] | 211 | const JValue* returnValue) |
Hiroshi Yamauchi | b139b6d | 2017-02-28 15:01:23 -0800 | [diff] [blame] | 212 | REQUIRES(!event_list_lock_, !jdwp_token_lock_) REQUIRES_SHARED(Locks::mutator_lock_); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 213 | |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 214 | /* |
Sebastien Hertz | 3f52eaf | 2014-04-04 17:50:18 +0200 | [diff] [blame] | 215 | * A field of interest has been accessed or modified. This is used for field access and field |
| 216 | * modification events. |
| 217 | * |
| 218 | * "fieldValue" is non-null for field modification events only. |
| 219 | * "is_modification" is true for field modification, false for field access. |
| 220 | */ |
Vladimir Marko | 8311489 | 2019-04-11 13:05:50 +0100 | [diff] [blame] | 221 | void PostFieldEvent(const EventLocation* pLoc, |
| 222 | ArtField* field, |
| 223 | ObjPtr<mirror::Object> thisPtr, |
| 224 | const JValue* fieldValue, |
| 225 | bool is_modification) |
Hiroshi Yamauchi | b139b6d | 2017-02-28 15:01:23 -0800 | [diff] [blame] | 226 | REQUIRES(!event_list_lock_, !jdwp_token_lock_) REQUIRES_SHARED(Locks::mutator_lock_); |
Sebastien Hertz | 3f52eaf | 2014-04-04 17:50:18 +0200 | [diff] [blame] | 227 | |
| 228 | /* |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 229 | * An exception has been thrown. |
| 230 | * |
| 231 | * Pass in a zeroed-out "*pCatchLoc" if the exception wasn't caught. |
| 232 | */ |
Vladimir Marko | 8311489 | 2019-04-11 13:05:50 +0100 | [diff] [blame] | 233 | void PostException(const EventLocation* pThrowLoc, |
| 234 | ObjPtr<mirror::Throwable> exception_object, |
| 235 | const EventLocation* pCatchLoc, |
| 236 | ObjPtr<mirror::Object> thisPtr) |
Hiroshi Yamauchi | b139b6d | 2017-02-28 15:01:23 -0800 | [diff] [blame] | 237 | REQUIRES(!event_list_lock_, !jdwp_token_lock_) REQUIRES_SHARED(Locks::mutator_lock_); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 238 | |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 239 | /* |
| 240 | * A thread has started or stopped. |
| 241 | */ |
Sebastien Hertz | 7d95565 | 2014-10-22 10:57:10 +0200 | [diff] [blame] | 242 | void PostThreadChange(Thread* thread, bool start) |
Hiroshi Yamauchi | b139b6d | 2017-02-28 15:01:23 -0800 | [diff] [blame] | 243 | REQUIRES(!event_list_lock_, !jdwp_token_lock_) REQUIRES_SHARED(Locks::mutator_lock_); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 244 | |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 245 | /* |
| 246 | * Class has been prepared. |
| 247 | */ |
Vladimir Marko | 8311489 | 2019-04-11 13:05:50 +0100 | [diff] [blame] | 248 | void PostClassPrepare(ObjPtr<mirror::Class> klass) |
Hiroshi Yamauchi | b139b6d | 2017-02-28 15:01:23 -0800 | [diff] [blame] | 249 | REQUIRES(!event_list_lock_, !jdwp_token_lock_) REQUIRES_SHARED(Locks::mutator_lock_); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 250 | |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 251 | /* |
| 252 | * The VM is about to stop. |
| 253 | */ |
| 254 | bool PostVMDeath(); |
| 255 | |
Elliott Hughes | a21039c | 2012-06-21 12:09:25 -0700 | [diff] [blame] | 256 | // Called if/when we realize we're talking to DDMS. |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 257 | void NotifyDdmsActive() REQUIRES_SHARED(Locks::mutator_lock_); |
Elliott Hughes | a21039c | 2012-06-21 12:09:25 -0700 | [diff] [blame] | 258 | |
Mathieu Chartier | ad466ad | 2015-01-08 16:28:08 -0800 | [diff] [blame] | 259 | |
| 260 | void SetupChunkHeader(uint32_t type, size_t data_len, size_t header_size, uint8_t* out_header); |
| 261 | |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 262 | /* |
| 263 | * Send up a chunk of DDM data. |
| 264 | */ |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 265 | void DdmSendChunkV(uint32_t type, const iovec* iov, int iov_count) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 266 | REQUIRES_SHARED(Locks::mutator_lock_); |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 267 | |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 268 | bool HandlePacket() REQUIRES(!shutdown_lock_, !jdwp_token_lock_); |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 269 | |
Elliott Hughes | 68a5e3c | 2013-04-17 17:13:35 -0700 | [diff] [blame] | 270 | void SendRequest(ExpandBuf* pReq); |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 271 | |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 272 | void ResetState() |
Hiroshi Yamauchi | b139b6d | 2017-02-28 15:01:23 -0800 | [diff] [blame] | 273 | REQUIRES(!event_list_lock_) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 274 | REQUIRES_SHARED(Locks::mutator_lock_); |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 275 | |
| 276 | /* atomic ops to get next serial number */ |
| 277 | uint32_t NextRequestSerial(); |
| 278 | uint32_t NextEventSerial(); |
| 279 | |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 280 | void Run() |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 281 | REQUIRES(!Locks::mutator_lock_, !Locks::thread_suspend_count_lock_, !thread_start_lock_, |
Hiroshi Yamauchi | b139b6d | 2017-02-28 15:01:23 -0800 | [diff] [blame] | 282 | !attach_lock_, !event_list_lock_); |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 283 | |
Elliott Hughes | 761928d | 2011-11-16 18:33:03 -0800 | [diff] [blame] | 284 | /* |
| 285 | * Register an event by adding it to the event list. |
| 286 | * |
| 287 | * "*pEvent" must be storage allocated with jdwpEventAlloc(). The caller |
| 288 | * may discard its pointer after calling this. |
| 289 | */ |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 290 | JdwpError RegisterEvent(JdwpEvent* pEvent) |
Hiroshi Yamauchi | b139b6d | 2017-02-28 15:01:23 -0800 | [diff] [blame] | 291 | REQUIRES(!event_list_lock_) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 292 | REQUIRES_SHARED(Locks::mutator_lock_); |
Elliott Hughes | 761928d | 2011-11-16 18:33:03 -0800 | [diff] [blame] | 293 | |
| 294 | /* |
| 295 | * Unregister an event, given the requestId. |
| 296 | */ |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 297 | void UnregisterEventById(uint32_t requestId) |
Hiroshi Yamauchi | b139b6d | 2017-02-28 15:01:23 -0800 | [diff] [blame] | 298 | REQUIRES(!event_list_lock_) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 299 | REQUIRES_SHARED(Locks::mutator_lock_); |
Elliott Hughes | 761928d | 2011-11-16 18:33:03 -0800 | [diff] [blame] | 300 | |
Alex Light | 5643caf | 2017-02-08 11:39:07 -0800 | [diff] [blame] | 301 | void UnregisterLocationEventsOnClass(ObjPtr<mirror::Class> klass) |
Hiroshi Yamauchi | b139b6d | 2017-02-28 15:01:23 -0800 | [diff] [blame] | 302 | REQUIRES(!event_list_lock_) |
Alex Light | 5643caf | 2017-02-08 11:39:07 -0800 | [diff] [blame] | 303 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 304 | |
Elliott Hughes | 761928d | 2011-11-16 18:33:03 -0800 | [diff] [blame] | 305 | /* |
| 306 | * Unregister all events. |
| 307 | */ |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 308 | void UnregisterAll() |
Hiroshi Yamauchi | b139b6d | 2017-02-28 15:01:23 -0800 | [diff] [blame] | 309 | REQUIRES(!event_list_lock_) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 310 | REQUIRES_SHARED(Locks::mutator_lock_); |
Elliott Hughes | 761928d | 2011-11-16 18:33:03 -0800 | [diff] [blame] | 311 | |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 312 | private: |
Elliott Hughes | ba8eee1 | 2012-01-24 20:25:24 -0800 | [diff] [blame] | 313 | explicit JdwpState(const JdwpOptions* options); |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 314 | size_t ProcessRequest(Request* request, ExpandBuf* pReply, bool* skip_reply) |
| 315 | REQUIRES(!jdwp_token_lock_); |
Elliott Hughes | 761928d | 2011-11-16 18:33:03 -0800 | [diff] [blame] | 316 | bool InvokeInProgress(); |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 317 | bool IsConnected(); |
jeffhao | a77f0f6 | 2012-12-05 17:19:31 -0800 | [diff] [blame] | 318 | void SuspendByPolicy(JdwpSuspendPolicy suspend_policy, JDWP::ObjectId thread_self_id) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 319 | REQUIRES(!Locks::mutator_lock_); |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 320 | void SendRequestAndPossiblySuspend(ExpandBuf* pReq, JdwpSuspendPolicy suspend_policy, |
| 321 | ObjectId threadId) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 322 | REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!jdwp_token_lock_); |
Sebastien Hertz | 7d95565 | 2014-10-22 10:57:10 +0200 | [diff] [blame] | 323 | void CleanupMatchList(const std::vector<JdwpEvent*>& match_list) |
Hiroshi Yamauchi | b139b6d | 2017-02-28 15:01:23 -0800 | [diff] [blame] | 324 | REQUIRES(event_list_lock_) REQUIRES_SHARED(Locks::mutator_lock_); |
Elliott Hughes | 761928d | 2011-11-16 18:33:03 -0800 | [diff] [blame] | 325 | void EventFinish(ExpandBuf* pReq); |
Sebastien Hertz | 7d95565 | 2014-10-22 10:57:10 +0200 | [diff] [blame] | 326 | bool FindMatchingEvents(JdwpEventKind eventKind, const ModBasket& basket, |
| 327 | std::vector<JdwpEvent*>* match_list) |
Hiroshi Yamauchi | b139b6d | 2017-02-28 15:01:23 -0800 | [diff] [blame] | 328 | REQUIRES(!event_list_lock_) REQUIRES_SHARED(Locks::mutator_lock_); |
Sebastien Hertz | 7d95565 | 2014-10-22 10:57:10 +0200 | [diff] [blame] | 329 | void FindMatchingEventsLocked(JdwpEventKind eventKind, const ModBasket& basket, |
| 330 | std::vector<JdwpEvent*>* match_list) |
Hiroshi Yamauchi | b139b6d | 2017-02-28 15:01:23 -0800 | [diff] [blame] | 331 | REQUIRES(event_list_lock_) REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 332 | void UnregisterEvent(JdwpEvent* pEvent) |
Hiroshi Yamauchi | b139b6d | 2017-02-28 15:01:23 -0800 | [diff] [blame] | 333 | REQUIRES(event_list_lock_) REQUIRES_SHARED(Locks::mutator_lock_); |
Brian Carlstrom | f529352 | 2013-07-19 00:24:00 -0700 | [diff] [blame] | 334 | void SendBufferedRequest(uint32_t type, const std::vector<iovec>& iov); |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 335 | |
Sebastien Hertz | 2bf93f4 | 2015-01-09 18:44:05 +0100 | [diff] [blame] | 336 | /* |
| 337 | * When we hit a debugger event that requires suspension, it's important |
| 338 | * that we wait for the thread to suspend itself before processing any |
| 339 | * additional requests. Otherwise, if the debugger immediately sends a |
| 340 | * "resume thread" command, the resume might arrive before the thread has |
| 341 | * suspended itself. |
| 342 | * |
| 343 | * It's also important no event thread suspends while we process a command |
| 344 | * from the debugger. Otherwise we could post an event ("thread death") |
| 345 | * before sending the reply of the command being processed ("resume") and |
| 346 | * cause bad synchronization with the debugger. |
| 347 | * |
| 348 | * The thread wanting "exclusive" access to the JDWP world must call the |
| 349 | * SetWaitForJdwpToken method before processing a command from the |
| 350 | * debugger or sending an event to the debugger. |
| 351 | * Once the command is processed or the event thread has posted its event, |
| 352 | * it must call the ClearWaitForJdwpToken method to allow another thread |
| 353 | * to do JDWP stuff. |
| 354 | * |
| 355 | * Therefore the main JDWP handler loop will wait for the event thread |
| 356 | * suspension before processing the next command. Once the event thread |
| 357 | * has suspended itself and cleared the token, the JDWP handler continues |
| 358 | * processing commands. This works in the suspend-all case because the |
| 359 | * event thread doesn't suspend itself until everything else has suspended. |
| 360 | * |
| 361 | * It's possible that multiple threads could encounter thread-suspending |
| 362 | * events at the same time, so we grab a mutex in the SetWaitForJdwpToken |
| 363 | * call, and release it in the ClearWaitForJdwpToken call. |
| 364 | */ |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 365 | void SetWaitForJdwpToken(ObjectId threadId) REQUIRES(!jdwp_token_lock_); |
| 366 | void ClearWaitForJdwpToken() REQUIRES(!jdwp_token_lock_); |
Sebastien Hertz | 99660e1 | 2014-02-19 15:04:42 +0100 | [diff] [blame] | 367 | |
Brian Carlstrom | 7934ac2 | 2013-07-26 10:54:15 -0700 | [diff] [blame] | 368 | public: // TODO: fix privacy |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 369 | const JdwpOptions* options_; |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 370 | |
Elliott Hughes | a21039c | 2012-06-21 12:09:25 -0700 | [diff] [blame] | 371 | private: |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 372 | /* wait for creation of the JDWP thread */ |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 373 | Mutex thread_start_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER; |
| 374 | ConditionVariable thread_start_cond_ GUARDED_BY(thread_start_lock_); |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 375 | |
Elliott Hughes | 475fc23 | 2011-10-25 15:00:35 -0700 | [diff] [blame] | 376 | pthread_t pthread_; |
| 377 | Thread* thread_; |
Elliott Hughes | a21039c | 2012-06-21 12:09:25 -0700 | [diff] [blame] | 378 | |
Andreas Gampe | 7c5acbb | 2018-09-20 13:54:52 -0700 | [diff] [blame] | 379 | volatile bool debug_thread_started_ GUARDED_BY(thread_start_lock_); |
Elliott Hughes | a21039c | 2012-06-21 12:09:25 -0700 | [diff] [blame] | 380 | ObjectId debug_thread_id_; |
| 381 | |
Elliott Hughes | 7484741 | 2012-06-20 18:10:21 -0700 | [diff] [blame] | 382 | private: |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 383 | bool run; |
| 384 | |
Brian Carlstrom | 7934ac2 | 2013-07-26 10:54:15 -0700 | [diff] [blame] | 385 | public: // TODO: fix privacy |
Elliott Hughes | 68a5e3c | 2013-04-17 17:13:35 -0700 | [diff] [blame] | 386 | JdwpNetStateBase* netState; |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 387 | |
Elliott Hughes | a21039c | 2012-06-21 12:09:25 -0700 | [diff] [blame] | 388 | private: |
| 389 | // For wait-for-debugger. |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 390 | Mutex attach_lock_ ACQUIRED_AFTER(thread_start_lock_); |
| 391 | ConditionVariable attach_cond_ GUARDED_BY(attach_lock_); |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 392 | |
Elliott Hughes | a21039c | 2012-06-21 12:09:25 -0700 | [diff] [blame] | 393 | // Time of last debugger activity, in milliseconds. |
Ian Rogers | 37f3c96 | 2014-07-17 11:25:30 -0700 | [diff] [blame] | 394 | Atomic<int64_t> last_activity_time_ms_; |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 395 | |
Elliott Hughes | a21039c | 2012-06-21 12:09:25 -0700 | [diff] [blame] | 396 | // Global counters and a mutex to protect them. |
Mathieu Chartier | 4b95e8f | 2013-07-15 16:32:50 -0700 | [diff] [blame] | 397 | AtomicInteger request_serial_; |
| 398 | AtomicInteger event_serial_; |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 399 | |
Elliott Hughes | a21039c | 2012-06-21 12:09:25 -0700 | [diff] [blame] | 400 | // Linked list of events requested by the debugger (breakpoints, class prep, etc). |
Hiroshi Yamauchi | b139b6d | 2017-02-28 15:01:23 -0800 | [diff] [blame] | 401 | Mutex event_list_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER ACQUIRED_BEFORE(Locks::breakpoint_lock_); |
| 402 | JdwpEvent* event_list_ GUARDED_BY(event_list_lock_); |
| 403 | size_t event_list_size_ GUARDED_BY(event_list_lock_); // Number of elements in event_list_. |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 404 | |
Sebastien Hertz | 2bf93f4 | 2015-01-09 18:44:05 +0100 | [diff] [blame] | 405 | // Used to synchronize JDWP command handler thread and event threads so only one |
| 406 | // thread does JDWP stuff at a time. This prevent from interleaving command handling |
| 407 | // and event notification. Otherwise we could receive a "resume" command for an |
| 408 | // event thread that is not suspended yet, or post a "thread death" or event "VM death" |
| 409 | // event before sending the reply of the "resume" command that caused it. |
| 410 | Mutex jdwp_token_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER; |
| 411 | ConditionVariable jdwp_token_cond_ GUARDED_BY(jdwp_token_lock_); |
| 412 | ObjectId jdwp_token_owner_thread_id_; |
Sebastien Hertz | 99660e1 | 2014-02-19 15:04:42 +0100 | [diff] [blame] | 413 | |
Elliott Hughes | a21039c | 2012-06-21 12:09:25 -0700 | [diff] [blame] | 414 | bool ddm_is_active_; |
Elliott Hughes | 64f574f | 2013-02-20 14:57:12 -0800 | [diff] [blame] | 415 | |
Sebastien Hertz | 2bf93f4 | 2015-01-09 18:44:05 +0100 | [diff] [blame] | 416 | // Used for VirtualMachine.Exit command handling. |
Elliott Hughes | 64f574f | 2013-02-20 14:57:12 -0800 | [diff] [blame] | 417 | bool should_exit_; |
| 418 | int exit_status_; |
Sebastien Hertz | 4e5b208 | 2015-03-24 19:03:40 +0100 | [diff] [blame] | 419 | |
| 420 | // Used to synchronize runtime shutdown with JDWP command handler thread. |
| 421 | // When the runtime shuts down, it needs to stop JDWP command handler thread by closing the |
| 422 | // JDWP connection. However, if the JDWP thread is processing a command, it needs to wait |
| 423 | // for the command to finish so we can send its reply before closing the connection. |
Hiroshi Yamauchi | b139b6d | 2017-02-28 15:01:23 -0800 | [diff] [blame] | 424 | Mutex shutdown_lock_ ACQUIRED_AFTER(event_list_lock_); |
Sebastien Hertz | 4e5b208 | 2015-03-24 19:03:40 +0100 | [diff] [blame] | 425 | ConditionVariable shutdown_cond_ GUARDED_BY(shutdown_lock_); |
| 426 | bool processing_request_ GUARDED_BY(shutdown_lock_); |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 427 | }; |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 428 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 429 | std::string DescribeField(const FieldId& field_id) REQUIRES_SHARED(Locks::mutator_lock_); |
| 430 | std::string DescribeMethod(const MethodId& method_id) REQUIRES_SHARED(Locks::mutator_lock_); |
| 431 | std::string DescribeRefTypeId(const RefTypeId& ref_type_id) REQUIRES_SHARED(Locks::mutator_lock_); |
Elliott Hughes | 4b9702c | 2013-02-20 18:13:24 -0800 | [diff] [blame] | 432 | |
| 433 | class Request { |
| 434 | public: |
Elliott Hughes | cb69306 | 2013-02-21 09:48:08 -0800 | [diff] [blame] | 435 | Request(const uint8_t* bytes, uint32_t available); |
Elliott Hughes | 4b9702c | 2013-02-20 18:13:24 -0800 | [diff] [blame] | 436 | ~Request(); |
| 437 | |
| 438 | std::string ReadUtf8String(); |
| 439 | |
| 440 | // Helper function: read a variable-width value from the input buffer. |
| 441 | uint64_t ReadValue(size_t width); |
| 442 | |
| 443 | int32_t ReadSigned32(const char* what); |
| 444 | |
| 445 | uint32_t ReadUnsigned32(const char* what); |
| 446 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 447 | FieldId ReadFieldId() REQUIRES_SHARED(Locks::mutator_lock_); |
Elliott Hughes | 4b9702c | 2013-02-20 18:13:24 -0800 | [diff] [blame] | 448 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 449 | MethodId ReadMethodId() REQUIRES_SHARED(Locks::mutator_lock_); |
Elliott Hughes | 4b9702c | 2013-02-20 18:13:24 -0800 | [diff] [blame] | 450 | |
| 451 | ObjectId ReadObjectId(const char* specific_kind); |
| 452 | |
| 453 | ObjectId ReadArrayId(); |
| 454 | |
| 455 | ObjectId ReadObjectId(); |
| 456 | |
| 457 | ObjectId ReadThreadId(); |
| 458 | |
| 459 | ObjectId ReadThreadGroupId(); |
| 460 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 461 | RefTypeId ReadRefTypeId() REQUIRES_SHARED(Locks::mutator_lock_); |
Elliott Hughes | 4b9702c | 2013-02-20 18:13:24 -0800 | [diff] [blame] | 462 | |
| 463 | FrameId ReadFrameId(); |
| 464 | |
| 465 | template <typename T> T ReadEnum1(const char* specific_kind) { |
Elliott Hughes | cb69306 | 2013-02-21 09:48:08 -0800 | [diff] [blame] | 466 | T value = static_cast<T>(Read1()); |
Elliott Hughes | 4b9702c | 2013-02-20 18:13:24 -0800 | [diff] [blame] | 467 | VLOG(jdwp) << " " << specific_kind << " " << value; |
| 468 | return value; |
| 469 | } |
| 470 | |
| 471 | JdwpTag ReadTag(); |
| 472 | |
| 473 | JdwpTypeTag ReadTypeTag(); |
| 474 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 475 | JdwpLocation ReadLocation() REQUIRES_SHARED(Locks::mutator_lock_); |
Elliott Hughes | 4b9702c | 2013-02-20 18:13:24 -0800 | [diff] [blame] | 476 | |
| 477 | JdwpModKind ReadModKind(); |
| 478 | |
Elliott Hughes | cb69306 | 2013-02-21 09:48:08 -0800 | [diff] [blame] | 479 | // |
| 480 | // Return values from this JDWP packet's header. |
| 481 | // |
| 482 | size_t GetLength() { return byte_count_; } |
| 483 | uint32_t GetId() { return id_; } |
| 484 | uint8_t GetCommandSet() { return command_set_; } |
| 485 | uint8_t GetCommand() { return command_; } |
| 486 | |
| 487 | // Returns the number of bytes remaining. |
Elliott Hughes | 4b9702c | 2013-02-20 18:13:24 -0800 | [diff] [blame] | 488 | size_t size() { return end_ - p_; } |
Elliott Hughes | cb69306 | 2013-02-21 09:48:08 -0800 | [diff] [blame] | 489 | |
| 490 | // Returns a pointer to the next byte. |
Elliott Hughes | 4b9702c | 2013-02-20 18:13:24 -0800 | [diff] [blame] | 491 | const uint8_t* data() { return p_; } |
| 492 | |
| 493 | void Skip(size_t count) { p_ += count; } |
| 494 | |
| 495 | void CheckConsumed(); |
| 496 | |
| 497 | private: |
Elliott Hughes | cb69306 | 2013-02-21 09:48:08 -0800 | [diff] [blame] | 498 | uint8_t Read1(); |
Elliott Hughes | 4b9702c | 2013-02-20 18:13:24 -0800 | [diff] [blame] | 499 | uint16_t Read2BE(); |
Elliott Hughes | cb69306 | 2013-02-21 09:48:08 -0800 | [diff] [blame] | 500 | uint32_t Read4BE(); |
Elliott Hughes | 4b9702c | 2013-02-20 18:13:24 -0800 | [diff] [blame] | 501 | uint64_t Read8BE(); |
| 502 | |
Elliott Hughes | cb69306 | 2013-02-21 09:48:08 -0800 | [diff] [blame] | 503 | uint32_t byte_count_; |
| 504 | uint32_t id_; |
| 505 | uint8_t command_set_; |
| 506 | uint8_t command_; |
| 507 | |
Elliott Hughes | 4b9702c | 2013-02-20 18:13:24 -0800 | [diff] [blame] | 508 | const uint8_t* p_; |
| 509 | const uint8_t* end_; |
| 510 | |
| 511 | DISALLOW_COPY_AND_ASSIGN(Request); |
| 512 | }; |
| 513 | |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 514 | } // namespace JDWP |
| 515 | |
| 516 | } // namespace art |
| 517 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 518 | #endif // ART_RUNTIME_JDWP_JDWP_H_ |