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 | 8f4b056 | 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 | */ |
Sebastien Hertz | 7d95565 | 2014-10-22 10:57:10 +0200 | [diff] [blame] | 208 | void PostLocationEvent(const EventLocation* pLoc, mirror::Object* thisPtr, int eventFlags, |
Jeff Hao | 579b024 | 2013-11-18 13:16:49 -0800 | [diff] [blame] | 209 | const JValue* returnValue) |
Hiroshi Yamauchi | b139b6d | 2017-02-28 15:01:23 -0800 | [diff] [blame] | 210 | REQUIRES(!event_list_lock_, !jdwp_token_lock_) REQUIRES_SHARED(Locks::mutator_lock_); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 211 | |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 212 | /* |
Sebastien Hertz | 3f52eaf | 2014-04-04 17:50:18 +0200 | [diff] [blame] | 213 | * A field of interest has been accessed or modified. This is used for field access and field |
| 214 | * modification events. |
| 215 | * |
| 216 | * "fieldValue" is non-null for field modification events only. |
| 217 | * "is_modification" is true for field modification, false for field access. |
| 218 | */ |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 219 | void PostFieldEvent(const EventLocation* pLoc, ArtField* field, mirror::Object* thisPtr, |
Sebastien Hertz | 6995c60 | 2014-09-09 12:10:13 +0200 | [diff] [blame] | 220 | const JValue* fieldValue, bool is_modification) |
Hiroshi Yamauchi | b139b6d | 2017-02-28 15:01:23 -0800 | [diff] [blame] | 221 | REQUIRES(!event_list_lock_, !jdwp_token_lock_) REQUIRES_SHARED(Locks::mutator_lock_); |
Sebastien Hertz | 3f52eaf | 2014-04-04 17:50:18 +0200 | [diff] [blame] | 222 | |
| 223 | /* |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 224 | * An exception has been thrown. |
| 225 | * |
| 226 | * Pass in a zeroed-out "*pCatchLoc" if the exception wasn't caught. |
| 227 | */ |
Sebastien Hertz | 7d95565 | 2014-10-22 10:57:10 +0200 | [diff] [blame] | 228 | void PostException(const EventLocation* pThrowLoc, mirror::Throwable* exception_object, |
Sebastien Hertz | 6995c60 | 2014-09-09 12:10:13 +0200 | [diff] [blame] | 229 | const EventLocation* pCatchLoc, mirror::Object* thisPtr) |
Hiroshi Yamauchi | b139b6d | 2017-02-28 15:01:23 -0800 | [diff] [blame] | 230 | REQUIRES(!event_list_lock_, !jdwp_token_lock_) REQUIRES_SHARED(Locks::mutator_lock_); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 231 | |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 232 | /* |
| 233 | * A thread has started or stopped. |
| 234 | */ |
Sebastien Hertz | 7d95565 | 2014-10-22 10:57:10 +0200 | [diff] [blame] | 235 | void PostThreadChange(Thread* thread, bool start) |
Hiroshi Yamauchi | b139b6d | 2017-02-28 15:01:23 -0800 | [diff] [blame] | 236 | REQUIRES(!event_list_lock_, !jdwp_token_lock_) REQUIRES_SHARED(Locks::mutator_lock_); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 237 | |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 238 | /* |
| 239 | * Class has been prepared. |
| 240 | */ |
Sebastien Hertz | 7d95565 | 2014-10-22 10:57:10 +0200 | [diff] [blame] | 241 | void PostClassPrepare(mirror::Class* klass) |
Hiroshi Yamauchi | b139b6d | 2017-02-28 15:01:23 -0800 | [diff] [blame] | 242 | REQUIRES(!event_list_lock_, !jdwp_token_lock_) REQUIRES_SHARED(Locks::mutator_lock_); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 243 | |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 244 | /* |
| 245 | * The VM is about to stop. |
| 246 | */ |
| 247 | bool PostVMDeath(); |
| 248 | |
Elliott Hughes | a21039c | 2012-06-21 12:09:25 -0700 | [diff] [blame] | 249 | // Called if/when we realize we're talking to DDMS. |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 250 | void NotifyDdmsActive() REQUIRES_SHARED(Locks::mutator_lock_); |
Elliott Hughes | a21039c | 2012-06-21 12:09:25 -0700 | [diff] [blame] | 251 | |
Mathieu Chartier | ad466ad | 2015-01-08 16:28:08 -0800 | [diff] [blame] | 252 | |
| 253 | void SetupChunkHeader(uint32_t type, size_t data_len, size_t header_size, uint8_t* out_header); |
| 254 | |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 255 | /* |
| 256 | * Send up a chunk of DDM data. |
| 257 | */ |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 258 | void DdmSendChunkV(uint32_t type, const iovec* iov, int iov_count) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 259 | REQUIRES_SHARED(Locks::mutator_lock_); |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 260 | |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 261 | bool HandlePacket() REQUIRES(!shutdown_lock_, !jdwp_token_lock_); |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 262 | |
Elliott Hughes | 68a5e3c | 2013-04-17 17:13:35 -0700 | [diff] [blame] | 263 | void SendRequest(ExpandBuf* pReq); |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 264 | |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 265 | void ResetState() |
Hiroshi Yamauchi | b139b6d | 2017-02-28 15:01:23 -0800 | [diff] [blame] | 266 | REQUIRES(!event_list_lock_) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 267 | REQUIRES_SHARED(Locks::mutator_lock_); |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 268 | |
| 269 | /* atomic ops to get next serial number */ |
| 270 | uint32_t NextRequestSerial(); |
| 271 | uint32_t NextEventSerial(); |
| 272 | |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 273 | void Run() |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 274 | REQUIRES(!Locks::mutator_lock_, !Locks::thread_suspend_count_lock_, !thread_start_lock_, |
Hiroshi Yamauchi | b139b6d | 2017-02-28 15:01:23 -0800 | [diff] [blame] | 275 | !attach_lock_, !event_list_lock_); |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 276 | |
Elliott Hughes | 761928d | 2011-11-16 18:33:03 -0800 | [diff] [blame] | 277 | /* |
| 278 | * Register an event by adding it to the event list. |
| 279 | * |
| 280 | * "*pEvent" must be storage allocated with jdwpEventAlloc(). The caller |
| 281 | * may discard its pointer after calling this. |
| 282 | */ |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 283 | JdwpError RegisterEvent(JdwpEvent* pEvent) |
Hiroshi Yamauchi | b139b6d | 2017-02-28 15:01:23 -0800 | [diff] [blame] | 284 | REQUIRES(!event_list_lock_) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 285 | REQUIRES_SHARED(Locks::mutator_lock_); |
Elliott Hughes | 761928d | 2011-11-16 18:33:03 -0800 | [diff] [blame] | 286 | |
| 287 | /* |
| 288 | * Unregister an event, given the requestId. |
| 289 | */ |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 290 | void UnregisterEventById(uint32_t requestId) |
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 | |
Alex Light | 5643caf | 2017-02-08 11:39:07 -0800 | [diff] [blame] | 294 | void UnregisterLocationEventsOnClass(ObjPtr<mirror::Class> klass) |
Hiroshi Yamauchi | b139b6d | 2017-02-28 15:01:23 -0800 | [diff] [blame] | 295 | REQUIRES(!event_list_lock_) |
Alex Light | 5643caf | 2017-02-08 11:39:07 -0800 | [diff] [blame] | 296 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 297 | |
Elliott Hughes | 761928d | 2011-11-16 18:33:03 -0800 | [diff] [blame] | 298 | /* |
| 299 | * Unregister all events. |
| 300 | */ |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 301 | void UnregisterAll() |
Hiroshi Yamauchi | b139b6d | 2017-02-28 15:01:23 -0800 | [diff] [blame] | 302 | REQUIRES(!event_list_lock_) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 303 | REQUIRES_SHARED(Locks::mutator_lock_); |
Elliott Hughes | 761928d | 2011-11-16 18:33:03 -0800 | [diff] [blame] | 304 | |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 305 | private: |
Elliott Hughes | ba8eee1 | 2012-01-24 20:25:24 -0800 | [diff] [blame] | 306 | explicit JdwpState(const JdwpOptions* options); |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 307 | size_t ProcessRequest(Request* request, ExpandBuf* pReply, bool* skip_reply) |
| 308 | REQUIRES(!jdwp_token_lock_); |
Elliott Hughes | 761928d | 2011-11-16 18:33:03 -0800 | [diff] [blame] | 309 | bool InvokeInProgress(); |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 310 | bool IsConnected(); |
jeffhao | a77f0f6 | 2012-12-05 17:19:31 -0800 | [diff] [blame] | 311 | void SuspendByPolicy(JdwpSuspendPolicy suspend_policy, JDWP::ObjectId thread_self_id) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 312 | REQUIRES(!Locks::mutator_lock_); |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 313 | void SendRequestAndPossiblySuspend(ExpandBuf* pReq, JdwpSuspendPolicy suspend_policy, |
| 314 | ObjectId threadId) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 315 | REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!jdwp_token_lock_); |
Sebastien Hertz | 7d95565 | 2014-10-22 10:57:10 +0200 | [diff] [blame] | 316 | void CleanupMatchList(const std::vector<JdwpEvent*>& match_list) |
Hiroshi Yamauchi | b139b6d | 2017-02-28 15:01:23 -0800 | [diff] [blame] | 317 | REQUIRES(event_list_lock_) REQUIRES_SHARED(Locks::mutator_lock_); |
Elliott Hughes | 761928d | 2011-11-16 18:33:03 -0800 | [diff] [blame] | 318 | void EventFinish(ExpandBuf* pReq); |
Sebastien Hertz | 7d95565 | 2014-10-22 10:57:10 +0200 | [diff] [blame] | 319 | bool FindMatchingEvents(JdwpEventKind eventKind, const ModBasket& basket, |
| 320 | std::vector<JdwpEvent*>* match_list) |
Hiroshi Yamauchi | b139b6d | 2017-02-28 15:01:23 -0800 | [diff] [blame] | 321 | REQUIRES(!event_list_lock_) REQUIRES_SHARED(Locks::mutator_lock_); |
Sebastien Hertz | 7d95565 | 2014-10-22 10:57:10 +0200 | [diff] [blame] | 322 | void FindMatchingEventsLocked(JdwpEventKind eventKind, const ModBasket& basket, |
| 323 | 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_); |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 325 | void UnregisterEvent(JdwpEvent* pEvent) |
Hiroshi Yamauchi | b139b6d | 2017-02-28 15:01:23 -0800 | [diff] [blame] | 326 | REQUIRES(event_list_lock_) REQUIRES_SHARED(Locks::mutator_lock_); |
Brian Carlstrom | f529352 | 2013-07-19 00:24:00 -0700 | [diff] [blame] | 327 | void SendBufferedRequest(uint32_t type, const std::vector<iovec>& iov); |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 328 | |
Sebastien Hertz | 2bf93f4 | 2015-01-09 18:44:05 +0100 | [diff] [blame] | 329 | /* |
| 330 | * When we hit a debugger event that requires suspension, it's important |
| 331 | * that we wait for the thread to suspend itself before processing any |
| 332 | * additional requests. Otherwise, if the debugger immediately sends a |
| 333 | * "resume thread" command, the resume might arrive before the thread has |
| 334 | * suspended itself. |
| 335 | * |
| 336 | * It's also important no event thread suspends while we process a command |
| 337 | * from the debugger. Otherwise we could post an event ("thread death") |
| 338 | * before sending the reply of the command being processed ("resume") and |
| 339 | * cause bad synchronization with the debugger. |
| 340 | * |
| 341 | * The thread wanting "exclusive" access to the JDWP world must call the |
| 342 | * SetWaitForJdwpToken method before processing a command from the |
| 343 | * debugger or sending an event to the debugger. |
| 344 | * Once the command is processed or the event thread has posted its event, |
| 345 | * it must call the ClearWaitForJdwpToken method to allow another thread |
| 346 | * to do JDWP stuff. |
| 347 | * |
| 348 | * Therefore the main JDWP handler loop will wait for the event thread |
| 349 | * suspension before processing the next command. Once the event thread |
| 350 | * has suspended itself and cleared the token, the JDWP handler continues |
| 351 | * processing commands. This works in the suspend-all case because the |
| 352 | * event thread doesn't suspend itself until everything else has suspended. |
| 353 | * |
| 354 | * It's possible that multiple threads could encounter thread-suspending |
| 355 | * events at the same time, so we grab a mutex in the SetWaitForJdwpToken |
| 356 | * call, and release it in the ClearWaitForJdwpToken call. |
| 357 | */ |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 358 | void SetWaitForJdwpToken(ObjectId threadId) REQUIRES(!jdwp_token_lock_); |
| 359 | void ClearWaitForJdwpToken() REQUIRES(!jdwp_token_lock_); |
Sebastien Hertz | 99660e1 | 2014-02-19 15:04:42 +0100 | [diff] [blame] | 360 | |
Brian Carlstrom | 7934ac2 | 2013-07-26 10:54:15 -0700 | [diff] [blame] | 361 | public: // TODO: fix privacy |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 362 | const JdwpOptions* options_; |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 363 | |
Elliott Hughes | a21039c | 2012-06-21 12:09:25 -0700 | [diff] [blame] | 364 | private: |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 365 | /* wait for creation of the JDWP thread */ |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 366 | Mutex thread_start_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER; |
| 367 | ConditionVariable thread_start_cond_ GUARDED_BY(thread_start_lock_); |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 368 | |
Elliott Hughes | 475fc23 | 2011-10-25 15:00:35 -0700 | [diff] [blame] | 369 | pthread_t pthread_; |
| 370 | Thread* thread_; |
Elliott Hughes | a21039c | 2012-06-21 12:09:25 -0700 | [diff] [blame] | 371 | |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 372 | volatile int32_t debug_thread_started_ GUARDED_BY(thread_start_lock_); |
Elliott Hughes | a21039c | 2012-06-21 12:09:25 -0700 | [diff] [blame] | 373 | ObjectId debug_thread_id_; |
| 374 | |
Elliott Hughes | 7484741 | 2012-06-20 18:10:21 -0700 | [diff] [blame] | 375 | private: |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 376 | bool run; |
| 377 | |
Brian Carlstrom | 7934ac2 | 2013-07-26 10:54:15 -0700 | [diff] [blame] | 378 | public: // TODO: fix privacy |
Elliott Hughes | 68a5e3c | 2013-04-17 17:13:35 -0700 | [diff] [blame] | 379 | JdwpNetStateBase* netState; |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 380 | |
Elliott Hughes | a21039c | 2012-06-21 12:09:25 -0700 | [diff] [blame] | 381 | private: |
| 382 | // For wait-for-debugger. |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 383 | Mutex attach_lock_ ACQUIRED_AFTER(thread_start_lock_); |
| 384 | ConditionVariable attach_cond_ GUARDED_BY(attach_lock_); |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 385 | |
Elliott Hughes | a21039c | 2012-06-21 12:09:25 -0700 | [diff] [blame] | 386 | // Time of last debugger activity, in milliseconds. |
Ian Rogers | 37f3c96 | 2014-07-17 11:25:30 -0700 | [diff] [blame] | 387 | Atomic<int64_t> last_activity_time_ms_; |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 388 | |
Elliott Hughes | a21039c | 2012-06-21 12:09:25 -0700 | [diff] [blame] | 389 | // Global counters and a mutex to protect them. |
Mathieu Chartier | 4b95e8f | 2013-07-15 16:32:50 -0700 | [diff] [blame] | 390 | AtomicInteger request_serial_; |
| 391 | AtomicInteger event_serial_; |
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 | // Linked list of events requested by the debugger (breakpoints, class prep, etc). |
Hiroshi Yamauchi | b139b6d | 2017-02-28 15:01:23 -0800 | [diff] [blame] | 394 | Mutex event_list_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER ACQUIRED_BEFORE(Locks::breakpoint_lock_); |
| 395 | JdwpEvent* event_list_ GUARDED_BY(event_list_lock_); |
| 396 | 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] | 397 | |
Sebastien Hertz | 2bf93f4 | 2015-01-09 18:44:05 +0100 | [diff] [blame] | 398 | // Used to synchronize JDWP command handler thread and event threads so only one |
| 399 | // thread does JDWP stuff at a time. This prevent from interleaving command handling |
| 400 | // and event notification. Otherwise we could receive a "resume" command for an |
| 401 | // event thread that is not suspended yet, or post a "thread death" or event "VM death" |
| 402 | // event before sending the reply of the "resume" command that caused it. |
| 403 | Mutex jdwp_token_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER; |
| 404 | ConditionVariable jdwp_token_cond_ GUARDED_BY(jdwp_token_lock_); |
| 405 | ObjectId jdwp_token_owner_thread_id_; |
Sebastien Hertz | 99660e1 | 2014-02-19 15:04:42 +0100 | [diff] [blame] | 406 | |
Elliott Hughes | a21039c | 2012-06-21 12:09:25 -0700 | [diff] [blame] | 407 | bool ddm_is_active_; |
Elliott Hughes | 64f574f | 2013-02-20 14:57:12 -0800 | [diff] [blame] | 408 | |
Sebastien Hertz | 2bf93f4 | 2015-01-09 18:44:05 +0100 | [diff] [blame] | 409 | // Used for VirtualMachine.Exit command handling. |
Elliott Hughes | 64f574f | 2013-02-20 14:57:12 -0800 | [diff] [blame] | 410 | bool should_exit_; |
| 411 | int exit_status_; |
Sebastien Hertz | 4e5b208 | 2015-03-24 19:03:40 +0100 | [diff] [blame] | 412 | |
| 413 | // Used to synchronize runtime shutdown with JDWP command handler thread. |
| 414 | // When the runtime shuts down, it needs to stop JDWP command handler thread by closing the |
| 415 | // JDWP connection. However, if the JDWP thread is processing a command, it needs to wait |
| 416 | // 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] | 417 | Mutex shutdown_lock_ ACQUIRED_AFTER(event_list_lock_); |
Sebastien Hertz | 4e5b208 | 2015-03-24 19:03:40 +0100 | [diff] [blame] | 418 | ConditionVariable shutdown_cond_ GUARDED_BY(shutdown_lock_); |
| 419 | bool processing_request_ GUARDED_BY(shutdown_lock_); |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 420 | }; |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 421 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 422 | std::string DescribeField(const FieldId& field_id) REQUIRES_SHARED(Locks::mutator_lock_); |
| 423 | std::string DescribeMethod(const MethodId& method_id) REQUIRES_SHARED(Locks::mutator_lock_); |
| 424 | 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] | 425 | |
| 426 | class Request { |
| 427 | public: |
Elliott Hughes | cb69306 | 2013-02-21 09:48:08 -0800 | [diff] [blame] | 428 | Request(const uint8_t* bytes, uint32_t available); |
Elliott Hughes | 4b9702c | 2013-02-20 18:13:24 -0800 | [diff] [blame] | 429 | ~Request(); |
| 430 | |
| 431 | std::string ReadUtf8String(); |
| 432 | |
| 433 | // Helper function: read a variable-width value from the input buffer. |
| 434 | uint64_t ReadValue(size_t width); |
| 435 | |
| 436 | int32_t ReadSigned32(const char* what); |
| 437 | |
| 438 | uint32_t ReadUnsigned32(const char* what); |
| 439 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 440 | FieldId ReadFieldId() REQUIRES_SHARED(Locks::mutator_lock_); |
Elliott Hughes | 4b9702c | 2013-02-20 18:13:24 -0800 | [diff] [blame] | 441 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 442 | MethodId ReadMethodId() REQUIRES_SHARED(Locks::mutator_lock_); |
Elliott Hughes | 4b9702c | 2013-02-20 18:13:24 -0800 | [diff] [blame] | 443 | |
| 444 | ObjectId ReadObjectId(const char* specific_kind); |
| 445 | |
| 446 | ObjectId ReadArrayId(); |
| 447 | |
| 448 | ObjectId ReadObjectId(); |
| 449 | |
| 450 | ObjectId ReadThreadId(); |
| 451 | |
| 452 | ObjectId ReadThreadGroupId(); |
| 453 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 454 | RefTypeId ReadRefTypeId() REQUIRES_SHARED(Locks::mutator_lock_); |
Elliott Hughes | 4b9702c | 2013-02-20 18:13:24 -0800 | [diff] [blame] | 455 | |
| 456 | FrameId ReadFrameId(); |
| 457 | |
| 458 | template <typename T> T ReadEnum1(const char* specific_kind) { |
Elliott Hughes | cb69306 | 2013-02-21 09:48:08 -0800 | [diff] [blame] | 459 | T value = static_cast<T>(Read1()); |
Elliott Hughes | 4b9702c | 2013-02-20 18:13:24 -0800 | [diff] [blame] | 460 | VLOG(jdwp) << " " << specific_kind << " " << value; |
| 461 | return value; |
| 462 | } |
| 463 | |
| 464 | JdwpTag ReadTag(); |
| 465 | |
| 466 | JdwpTypeTag ReadTypeTag(); |
| 467 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 468 | JdwpLocation ReadLocation() REQUIRES_SHARED(Locks::mutator_lock_); |
Elliott Hughes | 4b9702c | 2013-02-20 18:13:24 -0800 | [diff] [blame] | 469 | |
| 470 | JdwpModKind ReadModKind(); |
| 471 | |
Elliott Hughes | cb69306 | 2013-02-21 09:48:08 -0800 | [diff] [blame] | 472 | // |
| 473 | // Return values from this JDWP packet's header. |
| 474 | // |
| 475 | size_t GetLength() { return byte_count_; } |
| 476 | uint32_t GetId() { return id_; } |
| 477 | uint8_t GetCommandSet() { return command_set_; } |
| 478 | uint8_t GetCommand() { return command_; } |
| 479 | |
| 480 | // Returns the number of bytes remaining. |
Elliott Hughes | 4b9702c | 2013-02-20 18:13:24 -0800 | [diff] [blame] | 481 | size_t size() { return end_ - p_; } |
Elliott Hughes | cb69306 | 2013-02-21 09:48:08 -0800 | [diff] [blame] | 482 | |
| 483 | // Returns a pointer to the next byte. |
Elliott Hughes | 4b9702c | 2013-02-20 18:13:24 -0800 | [diff] [blame] | 484 | const uint8_t* data() { return p_; } |
| 485 | |
| 486 | void Skip(size_t count) { p_ += count; } |
| 487 | |
| 488 | void CheckConsumed(); |
| 489 | |
| 490 | private: |
Elliott Hughes | cb69306 | 2013-02-21 09:48:08 -0800 | [diff] [blame] | 491 | uint8_t Read1(); |
Elliott Hughes | 4b9702c | 2013-02-20 18:13:24 -0800 | [diff] [blame] | 492 | uint16_t Read2BE(); |
Elliott Hughes | cb69306 | 2013-02-21 09:48:08 -0800 | [diff] [blame] | 493 | uint32_t Read4BE(); |
Elliott Hughes | 4b9702c | 2013-02-20 18:13:24 -0800 | [diff] [blame] | 494 | uint64_t Read8BE(); |
| 495 | |
Elliott Hughes | cb69306 | 2013-02-21 09:48:08 -0800 | [diff] [blame] | 496 | uint32_t byte_count_; |
| 497 | uint32_t id_; |
| 498 | uint8_t command_set_; |
| 499 | uint8_t command_; |
| 500 | |
Elliott Hughes | 4b9702c | 2013-02-20 18:13:24 -0800 | [diff] [blame] | 501 | const uint8_t* p_; |
| 502 | const uint8_t* end_; |
| 503 | |
| 504 | DISALLOW_COPY_AND_ASSIGN(Request); |
| 505 | }; |
| 506 | |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 507 | } // namespace JDWP |
| 508 | |
| 509 | } // namespace art |
| 510 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 511 | #endif // ART_RUNTIME_JDWP_JDWP_H_ |