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 | |
| 17 | /* |
| 18 | * Dalvik-specific side of debugger support. (The JDWP code is intended to |
| 19 | * be relatively generic.) |
| 20 | */ |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 21 | #ifndef ART_RUNTIME_DEBUGGER_H_ |
| 22 | #define ART_RUNTIME_DEBUGGER_H_ |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 23 | |
| 24 | #include <pthread.h> |
| 25 | |
Mathieu Chartier | 4345c46 | 2014-06-27 10:20:14 -0700 | [diff] [blame] | 26 | #include <map> |
Sebastien Hertz | 61b7f1b | 2013-11-15 15:59:30 +0100 | [diff] [blame] | 27 | #include <set> |
Elliott Hughes | 3bb8156 | 2011-10-21 18:52:59 -0700 | [diff] [blame] | 28 | #include <string> |
Sebastien Hertz | 4d25df3 | 2014-03-21 17:44:46 +0100 | [diff] [blame] | 29 | #include <vector> |
Elliott Hughes | 3bb8156 | 2011-10-21 18:52:59 -0700 | [diff] [blame] | 30 | |
Mathieu Chartier | e34fa1d | 2015-01-14 14:55:47 -0800 | [diff] [blame] | 31 | #include "gc_root.h" |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 32 | #include "jdwp/jdwp.h" |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 33 | #include "jni.h" |
| 34 | #include "jvalue.h" |
Mathieu Chartier | 83c8ee0 | 2014-01-28 14:50:23 -0800 | [diff] [blame] | 35 | #include "object_callbacks.h" |
Jeff Hao | 920af3e | 2013-08-28 15:46:38 -0700 | [diff] [blame] | 36 | #include "thread_state.h" |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 37 | |
| 38 | namespace art { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 39 | namespace mirror { |
Sebastien Hertz | 3f52eaf | 2014-04-04 17:50:18 +0200 | [diff] [blame] | 40 | class ArtField; |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 41 | class ArtMethod; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 42 | class Class; |
| 43 | class Object; |
| 44 | class Throwable; |
| 45 | } // namespace mirror |
Hiroshi Yamauchi | b5a9e3d | 2014-06-09 12:11:20 -0700 | [diff] [blame] | 46 | class AllocRecord; |
Sebastien Hertz | 6995c60 | 2014-09-09 12:10:13 +0200 | [diff] [blame] | 47 | class ObjectRegistry; |
| 48 | class ScopedObjectAccessUnchecked; |
Sebastien Hertz | 8009f39 | 2014-09-01 17:07:11 +0200 | [diff] [blame] | 49 | class StackVisitor; |
Ian Rogers | 1b09b09 | 2012-08-20 15:35:52 -0700 | [diff] [blame] | 50 | class Thread; |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 51 | class ThrowLocation; |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 52 | |
| 53 | /* |
| 54 | * Invoke-during-breakpoint support. |
| 55 | */ |
| 56 | struct DebugInvokeReq { |
Elliott Hughes | 7b3cdfc | 2011-12-08 21:28:17 -0800 | [diff] [blame] | 57 | DebugInvokeReq() |
Sebastien Hertz | d38667a | 2013-11-25 15:43:54 +0100 | [diff] [blame] | 58 | : ready(false), invoke_needed(false), |
| 59 | receiver(NULL), thread(NULL), klass(NULL), method(NULL), |
| 60 | arg_count(0), arg_values(NULL), options(0), error(JDWP::ERR_NONE), |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 61 | result_tag(JDWP::JT_VOID), exception(0), |
Sebastien Hertz | d38667a | 2013-11-25 15:43:54 +0100 | [diff] [blame] | 62 | lock("a DebugInvokeReq lock", kBreakpointInvokeLock), |
| 63 | cond("a DebugInvokeReq condition variable", lock) { |
Elliott Hughes | 475fc23 | 2011-10-25 15:00:35 -0700 | [diff] [blame] | 64 | } |
| 65 | |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 66 | /* boolean; only set when we're in the tail end of an event handler */ |
| 67 | bool ready; |
| 68 | |
| 69 | /* boolean; set if the JDWP thread wants this thread to do work */ |
Sebastien Hertz | d38667a | 2013-11-25 15:43:54 +0100 | [diff] [blame] | 70 | bool invoke_needed; |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 71 | |
| 72 | /* request */ |
Sebastien Hertz | d38667a | 2013-11-25 15:43:54 +0100 | [diff] [blame] | 73 | mirror::Object* receiver; /* not used for ClassType.InvokeMethod */ |
| 74 | mirror::Object* thread; |
| 75 | mirror::Class* klass; |
| 76 | mirror::ArtMethod* method; |
| 77 | uint32_t arg_count; |
| 78 | uint64_t* arg_values; /* will be NULL if arg_count_ == 0 */ |
| 79 | uint32_t options; |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 80 | |
| 81 | /* result */ |
Elliott Hughes | 475fc23 | 2011-10-25 15:00:35 -0700 | [diff] [blame] | 82 | JDWP::JdwpError error; |
Elliott Hughes | d07986f | 2011-12-06 18:27:45 -0800 | [diff] [blame] | 83 | JDWP::JdwpTag result_tag; |
Elliott Hughes | 475fc23 | 2011-10-25 15:00:35 -0700 | [diff] [blame] | 84 | JValue result_value; |
| 85 | JDWP::ObjectId exception; |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 86 | |
| 87 | /* condition variable to wait on while the method executes */ |
Sebastien Hertz | d38667a | 2013-11-25 15:43:54 +0100 | [diff] [blame] | 88 | Mutex lock DEFAULT_MUTEX_ACQUIRED_AFTER; |
| 89 | ConditionVariable cond GUARDED_BY(lock); |
Sebastien Hertz | 61b7f1b | 2013-11-15 15:59:30 +0100 | [diff] [blame] | 90 | |
Mathieu Chartier | e34fa1d | 2015-01-14 14:55:47 -0800 | [diff] [blame] | 91 | void VisitRoots(RootCallback* callback, void* arg, const RootInfo& root_info) |
Mathieu Chartier | 3b05e9b | 2014-03-25 09:29:43 -0700 | [diff] [blame] | 92 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 93 | |
Sebastien Hertz | bb43b43 | 2014-04-14 11:59:08 +0200 | [diff] [blame] | 94 | void Clear(); |
| 95 | |
Sebastien Hertz | 61b7f1b | 2013-11-15 15:59:30 +0100 | [diff] [blame] | 96 | private: |
| 97 | DISALLOW_COPY_AND_ASSIGN(DebugInvokeReq); |
| 98 | }; |
| 99 | |
| 100 | // Thread local data-structure that holds fields for controlling single-stepping. |
| 101 | struct SingleStepControl { |
| 102 | SingleStepControl() |
| 103 | : is_active(false), step_size(JDWP::SS_MIN), step_depth(JDWP::SD_INTO), |
| 104 | method(nullptr), stack_depth(0) { |
| 105 | } |
| 106 | |
| 107 | // Are we single-stepping right now? |
| 108 | bool is_active; |
| 109 | |
| 110 | // See JdwpStepSize and JdwpStepDepth for details. |
| 111 | JDWP::JdwpStepSize step_size; |
| 112 | JDWP::JdwpStepDepth step_depth; |
| 113 | |
| 114 | // The location this single-step was initiated from. |
| 115 | // A single-step is initiated in a suspended thread. We save here the current method and the |
| 116 | // set of DEX pcs associated to the source line number where the suspension occurred. |
| 117 | // This is used to support SD_INTO and SD_OVER single-step depths so we detect when a single-step |
| 118 | // causes the execution of an instruction in a different method or at a different line number. |
| 119 | mirror::ArtMethod* method; |
| 120 | std::set<uint32_t> dex_pcs; |
| 121 | |
| 122 | // The stack depth when this single-step was initiated. This is used to support SD_OVER and SD_OUT |
| 123 | // single-step depth. |
| 124 | int stack_depth; |
| 125 | |
Mathieu Chartier | e34fa1d | 2015-01-14 14:55:47 -0800 | [diff] [blame] | 126 | void VisitRoots(RootCallback* callback, void* arg, const RootInfo& root_info) |
Mathieu Chartier | 3b05e9b | 2014-03-25 09:29:43 -0700 | [diff] [blame] | 127 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 128 | |
Sebastien Hertz | bb43b43 | 2014-04-14 11:59:08 +0200 | [diff] [blame] | 129 | bool ContainsDexPc(uint32_t dex_pc) const; |
| 130 | |
| 131 | void Clear(); |
| 132 | |
Sebastien Hertz | 61b7f1b | 2013-11-15 15:59:30 +0100 | [diff] [blame] | 133 | private: |
| 134 | DISALLOW_COPY_AND_ASSIGN(SingleStepControl); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 135 | }; |
| 136 | |
Sebastien Hertz | 42cd43f | 2014-05-13 14:15:41 +0200 | [diff] [blame] | 137 | // TODO rename to InstrumentationRequest. |
Hiroshi Yamauchi | 0ec17d2 | 2014-07-07 13:07:08 -0700 | [diff] [blame] | 138 | class DeoptimizationRequest { |
| 139 | public: |
Sebastien Hertz | 4d25df3 | 2014-03-21 17:44:46 +0100 | [diff] [blame] | 140 | enum Kind { |
| 141 | kNothing, // no action. |
Sebastien Hertz | 42cd43f | 2014-05-13 14:15:41 +0200 | [diff] [blame] | 142 | kRegisterForEvent, // start listening for instrumentation event. |
| 143 | kUnregisterForEvent, // stop listening for instrumentation event. |
Sebastien Hertz | 4d25df3 | 2014-03-21 17:44:46 +0100 | [diff] [blame] | 144 | kFullDeoptimization, // deoptimize everything. |
| 145 | kFullUndeoptimization, // undeoptimize everything. |
| 146 | kSelectiveDeoptimization, // deoptimize one method. |
| 147 | kSelectiveUndeoptimization // undeoptimize one method. |
| 148 | }; |
| 149 | |
Hiroshi Yamauchi | 0ec17d2 | 2014-07-07 13:07:08 -0700 | [diff] [blame] | 150 | DeoptimizationRequest() : kind_(kNothing), instrumentation_event_(0), method_(nullptr) {} |
Sebastien Hertz | 4d25df3 | 2014-03-21 17:44:46 +0100 | [diff] [blame] | 151 | |
Hiroshi Yamauchi | 0ec17d2 | 2014-07-07 13:07:08 -0700 | [diff] [blame] | 152 | DeoptimizationRequest(const DeoptimizationRequest& other) |
| 153 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) |
| 154 | : kind_(other.kind_), instrumentation_event_(other.instrumentation_event_) { |
| 155 | // Create a new JNI global reference for the method. |
| 156 | SetMethod(other.Method()); |
| 157 | } |
Sebastien Hertz | 4d25df3 | 2014-03-21 17:44:46 +0100 | [diff] [blame] | 158 | |
Hiroshi Yamauchi | 0ec17d2 | 2014-07-07 13:07:08 -0700 | [diff] [blame] | 159 | mirror::ArtMethod* Method() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 160 | |
| 161 | void SetMethod(mirror::ArtMethod* m) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 162 | |
| 163 | // Name 'Kind()' would collide with the above enum name. |
| 164 | Kind GetKind() const { |
| 165 | return kind_; |
| 166 | } |
| 167 | |
| 168 | void SetKind(Kind kind) { |
| 169 | kind_ = kind; |
| 170 | } |
| 171 | |
| 172 | uint32_t InstrumentationEvent() const { |
| 173 | return instrumentation_event_; |
| 174 | } |
| 175 | |
| 176 | void SetInstrumentationEvent(uint32_t instrumentation_event) { |
| 177 | instrumentation_event_ = instrumentation_event; |
| 178 | } |
| 179 | |
| 180 | private: |
| 181 | Kind kind_; |
Sebastien Hertz | 4d25df3 | 2014-03-21 17:44:46 +0100 | [diff] [blame] | 182 | |
Sebastien Hertz | 42cd43f | 2014-05-13 14:15:41 +0200 | [diff] [blame] | 183 | // TODO we could use a union to hold the instrumentation_event and the method since they |
| 184 | // respectively have sense only for kRegisterForEvent/kUnregisterForEvent and |
| 185 | // kSelectiveDeoptimization/kSelectiveUndeoptimization. |
| 186 | |
| 187 | // Event to start or stop listening to. Only for kRegisterForEvent and kUnregisterForEvent. |
Hiroshi Yamauchi | 0ec17d2 | 2014-07-07 13:07:08 -0700 | [diff] [blame] | 188 | uint32_t instrumentation_event_; |
Sebastien Hertz | 42cd43f | 2014-05-13 14:15:41 +0200 | [diff] [blame] | 189 | |
Sebastien Hertz | 4d25df3 | 2014-03-21 17:44:46 +0100 | [diff] [blame] | 190 | // Method for selective deoptimization. |
Hiroshi Yamauchi | 0ec17d2 | 2014-07-07 13:07:08 -0700 | [diff] [blame] | 191 | jmethodID method_; |
Sebastien Hertz | 4d25df3 | 2014-03-21 17:44:46 +0100 | [diff] [blame] | 192 | }; |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 193 | std::ostream& operator<<(std::ostream& os, const DeoptimizationRequest::Kind& rhs); |
Sebastien Hertz | 4d25df3 | 2014-03-21 17:44:46 +0100 | [diff] [blame] | 194 | |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 195 | class Dbg { |
Elliott Hughes | ff17f1f | 2012-01-24 18:12:29 -0800 | [diff] [blame] | 196 | public: |
Mathieu Chartier | 4345c46 | 2014-06-27 10:20:14 -0700 | [diff] [blame] | 197 | class TypeCache { |
| 198 | public: |
| 199 | // Returns a weak global for the input type. Deduplicates. |
Brian Carlstrom | 306db81 | 2014-09-05 13:01:41 -0700 | [diff] [blame] | 200 | jobject Add(mirror::Class* t) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_, |
| 201 | Locks::alloc_tracker_lock_); |
Mathieu Chartier | 4345c46 | 2014-06-27 10:20:14 -0700 | [diff] [blame] | 202 | // Clears the type cache and deletes all the weak global refs. |
Brian Carlstrom | 306db81 | 2014-09-05 13:01:41 -0700 | [diff] [blame] | 203 | void Clear() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_, |
| 204 | Locks::alloc_tracker_lock_); |
Mathieu Chartier | 4345c46 | 2014-06-27 10:20:14 -0700 | [diff] [blame] | 205 | |
| 206 | private: |
| 207 | std::multimap<int32_t, jobject> objects_; |
| 208 | }; |
| 209 | |
Elliott Hughes | 3bb8156 | 2011-10-21 18:52:59 -0700 | [diff] [blame] | 210 | static bool ParseJdwpOptions(const std::string& options); |
Elliott Hughes | 4ffd313 | 2011-10-24 12:06:42 -0700 | [diff] [blame] | 211 | static void SetJdwpAllowed(bool allowed); |
| 212 | |
Elliott Hughes | d1cc836 | 2011-10-24 16:58:50 -0700 | [diff] [blame] | 213 | static void StartJdwp(); |
| 214 | static void StopJdwp(); |
| 215 | |
Elliott Hughes | 767a147 | 2011-10-26 18:49:02 -0700 | [diff] [blame] | 216 | // Invoked by the GC in case we need to keep DDMS informed. |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 217 | static void GcDidFinish() LOCKS_EXCLUDED(Locks::mutator_lock_); |
Elliott Hughes | 767a147 | 2011-10-26 18:49:02 -0700 | [diff] [blame] | 218 | |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 219 | // Return the DebugInvokeReq for the current thread. |
| 220 | static DebugInvokeReq* GetInvokeReq(); |
| 221 | |
Elliott Hughes | 475fc23 | 2011-10-25 15:00:35 -0700 | [diff] [blame] | 222 | static Thread* GetDebugThread(); |
| 223 | static void ClearWaitForEventThread(); |
| 224 | |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 225 | /* |
| 226 | * Enable/disable breakpoints and step modes. Used to provide a heads-up |
| 227 | * when the debugger attaches. |
| 228 | */ |
| 229 | static void Connected(); |
Sebastien Hertz | 138dbfc | 2013-12-04 18:15:25 +0100 | [diff] [blame] | 230 | static void GoActive() |
Brian Carlstrom | 306db81 | 2014-09-05 13:01:41 -0700 | [diff] [blame] | 231 | LOCKS_EXCLUDED(Locks::breakpoint_lock_, Locks::deoptimization_lock_, Locks::mutator_lock_); |
| 232 | static void Disconnected() LOCKS_EXCLUDED(Locks::deoptimization_lock_, Locks::mutator_lock_); |
Elliott Hughes | 8696433 | 2012-02-15 19:37:42 -0800 | [diff] [blame] | 233 | static void Disposed(); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 234 | |
Elliott Hughes | c0f0933 | 2012-03-26 13:27:06 -0700 | [diff] [blame] | 235 | // Returns true if we're actually debugging with a real debugger, false if it's |
| 236 | // just DDMS (or nothing at all). |
| 237 | static bool IsDebuggerActive(); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 238 | |
Elliott Hughes | c0f0933 | 2012-03-26 13:27:06 -0700 | [diff] [blame] | 239 | // Returns true if we had -Xrunjdwp or -agentlib:jdwp= on the command line. |
| 240 | static bool IsJdwpConfigured(); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 241 | |
Elliott Hughes | 8696433 | 2012-02-15 19:37:42 -0800 | [diff] [blame] | 242 | static bool IsDisposed(); |
| 243 | |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 244 | /* |
| 245 | * Time, in milliseconds, since the last debugger activity. Does not |
| 246 | * include DDMS activity. Returns -1 if there has been no activity. |
| 247 | * Returns 0 if we're in the middle of handling a debugger request. |
| 248 | */ |
| 249 | static int64_t LastDebuggerActivity(); |
| 250 | |
Sebastien Hertz | 253fa55 | 2014-10-14 17:27:15 +0200 | [diff] [blame] | 251 | static void UndoDebuggerSuspensions() |
| 252 | LOCKS_EXCLUDED(Locks::thread_list_lock_, |
| 253 | Locks::thread_suspend_count_lock_); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 254 | |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 255 | /* |
| 256 | * Class, Object, Array |
| 257 | */ |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 258 | static std::string GetClassName(JDWP::RefTypeId id) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 259 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Sebastien Hertz | 6995c60 | 2014-09-09 12:10:13 +0200 | [diff] [blame] | 260 | static std::string GetClassName(mirror::Class* klass) |
| 261 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | c0542af | 2014-09-03 16:16:56 -0700 | [diff] [blame] | 262 | static JDWP::JdwpError GetClassObject(JDWP::RefTypeId id, JDWP::ObjectId* class_object_id) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 263 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | c0542af | 2014-09-03 16:16:56 -0700 | [diff] [blame] | 264 | static JDWP::JdwpError GetSuperclass(JDWP::RefTypeId id, JDWP::RefTypeId* superclass_id) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 265 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 266 | static JDWP::JdwpError GetClassLoader(JDWP::RefTypeId id, JDWP::ExpandBuf* pReply) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 267 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 268 | static JDWP::JdwpError GetModifiers(JDWP::RefTypeId id, JDWP::ExpandBuf* pReply) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 269 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 88d6309 | 2013-01-09 09:55:54 -0800 | [diff] [blame] | 270 | static JDWP::JdwpError GetReflectedType(JDWP::RefTypeId class_id, JDWP::ExpandBuf* pReply) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 271 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | c0542af | 2014-09-03 16:16:56 -0700 | [diff] [blame] | 272 | static void GetClassList(std::vector<JDWP::RefTypeId>* classes) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 273 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 88d6309 | 2013-01-09 09:55:54 -0800 | [diff] [blame] | 274 | static JDWP::JdwpError GetClassInfo(JDWP::RefTypeId class_id, JDWP::JdwpTypeTag* pTypeTag, |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 275 | uint32_t* pStatus, std::string* pDescriptor) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 276 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | c0542af | 2014-09-03 16:16:56 -0700 | [diff] [blame] | 277 | static void FindLoadedClassBySignature(const char* descriptor, std::vector<JDWP::RefTypeId>* ids) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 278 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 64f574f | 2013-02-20 14:57:12 -0800 | [diff] [blame] | 279 | static JDWP::JdwpError GetReferenceType(JDWP::ObjectId object_id, JDWP::ExpandBuf* pReply) |
| 280 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | fc0e94b | 2013-09-23 23:51:32 -0700 | [diff] [blame] | 281 | static JDWP::JdwpError GetSignature(JDWP::RefTypeId ref_type_id, std::string* signature) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 282 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | c0542af | 2014-09-03 16:16:56 -0700 | [diff] [blame] | 283 | static JDWP::JdwpError GetSourceFile(JDWP::RefTypeId ref_type_id, std::string* source_file) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 284 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | c0542af | 2014-09-03 16:16:56 -0700 | [diff] [blame] | 285 | static JDWP::JdwpError GetObjectTag(JDWP::ObjectId object_id, uint8_t* tag) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 286 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | aed4be9 | 2011-12-02 16:16:23 -0800 | [diff] [blame] | 287 | static size_t GetTagWidth(JDWP::JdwpTag tag); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 288 | |
Ian Rogers | c0542af | 2014-09-03 16:16:56 -0700 | [diff] [blame] | 289 | static JDWP::JdwpError GetArrayLength(JDWP::ObjectId array_id, int32_t* length) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 290 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 88d6309 | 2013-01-09 09:55:54 -0800 | [diff] [blame] | 291 | static JDWP::JdwpError OutputArray(JDWP::ObjectId array_id, int offset, int count, |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 292 | JDWP::ExpandBuf* pReply) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 293 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 88d6309 | 2013-01-09 09:55:54 -0800 | [diff] [blame] | 294 | static JDWP::JdwpError SetArrayElements(JDWP::ObjectId array_id, int offset, int count, |
Ian Rogers | c0542af | 2014-09-03 16:16:56 -0700 | [diff] [blame] | 295 | JDWP::Request* request) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 296 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 297 | |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 298 | static JDWP::ObjectId CreateString(const std::string& str) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 299 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | c0542af | 2014-09-03 16:16:56 -0700 | [diff] [blame] | 300 | static JDWP::JdwpError CreateObject(JDWP::RefTypeId class_id, JDWP::ObjectId* new_object) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 301 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 88d6309 | 2013-01-09 09:55:54 -0800 | [diff] [blame] | 302 | static JDWP::JdwpError CreateArrayObject(JDWP::RefTypeId array_class_id, uint32_t length, |
Ian Rogers | c0542af | 2014-09-03 16:16:56 -0700 | [diff] [blame] | 303 | JDWP::ObjectId* new_array) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 304 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 305 | |
Sebastien Hertz | 6995c60 | 2014-09-09 12:10:13 +0200 | [diff] [blame] | 306 | // |
| 307 | // Event filtering. |
| 308 | // |
| 309 | static bool MatchThread(JDWP::ObjectId expected_thread_id, Thread* event_thread) |
| 310 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 311 | |
| 312 | static bool MatchLocation(const JDWP::JdwpLocation& expected_location, |
| 313 | const JDWP::EventLocation& event_location) |
| 314 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 315 | |
| 316 | static bool MatchType(mirror::Class* event_class, JDWP::RefTypeId class_id) |
| 317 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 318 | |
| 319 | static bool MatchField(JDWP::RefTypeId expected_type_id, JDWP::FieldId expected_field_id, |
| 320 | mirror::ArtField* event_field) |
| 321 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 322 | |
| 323 | static bool MatchInstance(JDWP::ObjectId expected_instance_id, mirror::Object* event_instance) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 324 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 325 | |
Elliott Hughes | ec0f83d | 2013-01-15 16:54:08 -0800 | [diff] [blame] | 326 | // |
| 327 | // Monitors. |
| 328 | // |
| 329 | static JDWP::JdwpError GetMonitorInfo(JDWP::ObjectId object_id, JDWP::ExpandBuf* reply) |
| 330 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 331 | static JDWP::JdwpError GetOwnedMonitors(JDWP::ObjectId thread_id, |
Ian Rogers | c0542af | 2014-09-03 16:16:56 -0700 | [diff] [blame] | 332 | std::vector<JDWP::ObjectId>* monitors, |
| 333 | std::vector<uint32_t>* stack_depths) |
Sebastien Hertz | 52d131d | 2014-03-13 16:17:40 +0100 | [diff] [blame] | 334 | LOCKS_EXCLUDED(Locks::thread_list_lock_) |
Elliott Hughes | ec0f83d | 2013-01-15 16:54:08 -0800 | [diff] [blame] | 335 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Sebastien Hertz | 52d131d | 2014-03-13 16:17:40 +0100 | [diff] [blame] | 336 | static JDWP::JdwpError GetContendedMonitor(JDWP::ObjectId thread_id, |
Ian Rogers | c0542af | 2014-09-03 16:16:56 -0700 | [diff] [blame] | 337 | JDWP::ObjectId* contended_monitor) |
Sebastien Hertz | 52d131d | 2014-03-13 16:17:40 +0100 | [diff] [blame] | 338 | LOCKS_EXCLUDED(Locks::thread_list_lock_) |
Elliott Hughes | ec0f83d | 2013-01-15 16:54:08 -0800 | [diff] [blame] | 339 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 340 | |
| 341 | // |
| 342 | // Heap. |
| 343 | // |
| 344 | static JDWP::JdwpError GetInstanceCounts(const std::vector<JDWP::RefTypeId>& class_ids, |
Ian Rogers | c0542af | 2014-09-03 16:16:56 -0700 | [diff] [blame] | 345 | std::vector<uint64_t>* counts) |
Elliott Hughes | ec0f83d | 2013-01-15 16:54:08 -0800 | [diff] [blame] | 346 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 3b78c94 | 2013-01-15 17:35:41 -0800 | [diff] [blame] | 347 | static JDWP::JdwpError GetInstances(JDWP::RefTypeId class_id, int32_t max_count, |
Ian Rogers | c0542af | 2014-09-03 16:16:56 -0700 | [diff] [blame] | 348 | std::vector<JDWP::ObjectId>* instances) |
Elliott Hughes | 3b78c94 | 2013-01-15 17:35:41 -0800 | [diff] [blame] | 349 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 0cbaff5 | 2013-01-16 15:28:01 -0800 | [diff] [blame] | 350 | static JDWP::JdwpError GetReferringObjects(JDWP::ObjectId object_id, int32_t max_count, |
Ian Rogers | c0542af | 2014-09-03 16:16:56 -0700 | [diff] [blame] | 351 | std::vector<JDWP::ObjectId>* referring_objects) |
Elliott Hughes | 0cbaff5 | 2013-01-16 15:28:01 -0800 | [diff] [blame] | 352 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 64f574f | 2013-02-20 14:57:12 -0800 | [diff] [blame] | 353 | static JDWP::JdwpError DisableCollection(JDWP::ObjectId object_id) |
| 354 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 355 | static JDWP::JdwpError EnableCollection(JDWP::ObjectId object_id) |
| 356 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | c0542af | 2014-09-03 16:16:56 -0700 | [diff] [blame] | 357 | static JDWP::JdwpError IsCollected(JDWP::ObjectId object_id, bool* is_collected) |
Elliott Hughes | 64f574f | 2013-02-20 14:57:12 -0800 | [diff] [blame] | 358 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 359 | static void DisposeObject(JDWP::ObjectId object_id, uint32_t reference_count) |
| 360 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | ec0f83d | 2013-01-15 16:54:08 -0800 | [diff] [blame] | 361 | |
Elliott Hughes | 9777ba2 | 2013-01-17 09:04:19 -0800 | [diff] [blame] | 362 | // |
| 363 | // Methods and fields. |
| 364 | // |
Elliott Hughes | a96836a | 2013-01-17 12:27:49 -0800 | [diff] [blame] | 365 | static std::string GetMethodName(JDWP::MethodId method_id) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 366 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 88d6309 | 2013-01-09 09:55:54 -0800 | [diff] [blame] | 367 | static JDWP::JdwpError OutputDeclaredFields(JDWP::RefTypeId ref_type_id, bool with_generic, |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 368 | JDWP::ExpandBuf* pReply) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 369 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 88d6309 | 2013-01-09 09:55:54 -0800 | [diff] [blame] | 370 | static JDWP::JdwpError OutputDeclaredMethods(JDWP::RefTypeId ref_type_id, bool with_generic, |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 371 | JDWP::ExpandBuf* pReply) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 372 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 88d6309 | 2013-01-09 09:55:54 -0800 | [diff] [blame] | 373 | static JDWP::JdwpError OutputDeclaredInterfaces(JDWP::RefTypeId ref_type_id, |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 374 | JDWP::ExpandBuf* pReply) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 375 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 88d6309 | 2013-01-09 09:55:54 -0800 | [diff] [blame] | 376 | static void OutputLineTable(JDWP::RefTypeId ref_type_id, JDWP::MethodId method_id, |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 377 | JDWP::ExpandBuf* pReply) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 378 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 88d6309 | 2013-01-09 09:55:54 -0800 | [diff] [blame] | 379 | static void OutputVariableTable(JDWP::RefTypeId ref_type_id, JDWP::MethodId id, bool with_generic, |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 380 | JDWP::ExpandBuf* pReply) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 381 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Jeff Hao | 579b024 | 2013-11-18 13:16:49 -0800 | [diff] [blame] | 382 | static void OutputMethodReturnValue(JDWP::MethodId method_id, const JValue* return_value, |
| 383 | JDWP::ExpandBuf* pReply) |
| 384 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Sebastien Hertz | 3f52eaf | 2014-04-04 17:50:18 +0200 | [diff] [blame] | 385 | static void OutputFieldValue(JDWP::FieldId field_id, const JValue* field_value, |
| 386 | JDWP::ExpandBuf* pReply) |
| 387 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 9777ba2 | 2013-01-17 09:04:19 -0800 | [diff] [blame] | 388 | static JDWP::JdwpError GetBytecodes(JDWP::RefTypeId class_id, JDWP::MethodId method_id, |
Ian Rogers | c0542af | 2014-09-03 16:16:56 -0700 | [diff] [blame] | 389 | std::vector<uint8_t>* bytecodes) |
Elliott Hughes | 9777ba2 | 2013-01-17 09:04:19 -0800 | [diff] [blame] | 390 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 391 | |
Elliott Hughes | a96836a | 2013-01-17 12:27:49 -0800 | [diff] [blame] | 392 | static std::string GetFieldName(JDWP::FieldId field_id) |
| 393 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 88d6309 | 2013-01-09 09:55:54 -0800 | [diff] [blame] | 394 | static JDWP::JdwpTag GetFieldBasicTag(JDWP::FieldId field_id) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 395 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 88d6309 | 2013-01-09 09:55:54 -0800 | [diff] [blame] | 396 | static JDWP::JdwpTag GetStaticFieldBasicTag(JDWP::FieldId field_id) |
Brian Carlstrom | f69863b | 2013-07-17 21:53:13 -0700 | [diff] [blame] | 397 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 88d6309 | 2013-01-09 09:55:54 -0800 | [diff] [blame] | 398 | static JDWP::JdwpError GetFieldValue(JDWP::ObjectId object_id, JDWP::FieldId field_id, |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 399 | JDWP::ExpandBuf* pReply) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 400 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 88d6309 | 2013-01-09 09:55:54 -0800 | [diff] [blame] | 401 | static JDWP::JdwpError SetFieldValue(JDWP::ObjectId object_id, JDWP::FieldId field_id, |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 402 | uint64_t value, int width) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 403 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 88d6309 | 2013-01-09 09:55:54 -0800 | [diff] [blame] | 404 | static JDWP::JdwpError GetStaticFieldValue(JDWP::RefTypeId ref_type_id, JDWP::FieldId field_id, |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 405 | JDWP::ExpandBuf* pReply) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 406 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 88d6309 | 2013-01-09 09:55:54 -0800 | [diff] [blame] | 407 | static JDWP::JdwpError SetStaticFieldValue(JDWP::FieldId field_id, uint64_t value, int width) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 408 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 409 | |
Sebastien Hertz | b0b0b49 | 2014-09-15 11:27:27 +0200 | [diff] [blame] | 410 | static JDWP::JdwpError StringToUtf8(JDWP::ObjectId string_id, std::string* str) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 411 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Jeff Hao | 579b024 | 2013-11-18 13:16:49 -0800 | [diff] [blame] | 412 | static void OutputJValue(JDWP::JdwpTag tag, const JValue* return_value, JDWP::ExpandBuf* pReply) |
| 413 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 414 | |
| 415 | /* |
| 416 | * Thread, ThreadGroup, Frame |
| 417 | */ |
Ian Rogers | c0542af | 2014-09-03 16:16:56 -0700 | [diff] [blame] | 418 | static JDWP::JdwpError GetThreadName(JDWP::ObjectId thread_id, std::string* name) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 419 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) |
| 420 | LOCKS_EXCLUDED(Locks::thread_list_lock_); |
Sebastien Hertz | 52d131d | 2014-03-13 16:17:40 +0100 | [diff] [blame] | 421 | static JDWP::JdwpError GetThreadGroup(JDWP::ObjectId thread_id, JDWP::ExpandBuf* pReply) |
Sebastien Hertz | a06430c | 2014-09-15 19:21:30 +0200 | [diff] [blame] | 422 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) |
Sebastien Hertz | 52d131d | 2014-03-13 16:17:40 +0100 | [diff] [blame] | 423 | LOCKS_EXCLUDED(Locks::thread_list_lock_); |
Sebastien Hertz | a06430c | 2014-09-15 19:21:30 +0200 | [diff] [blame] | 424 | static JDWP::JdwpError GetThreadGroupName(JDWP::ObjectId thread_group_id, |
| 425 | JDWP::ExpandBuf* pReply) |
| 426 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 427 | static JDWP::JdwpError GetThreadGroupParent(JDWP::ObjectId thread_group_id, |
| 428 | JDWP::ExpandBuf* pReply) |
| 429 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 430 | static JDWP::JdwpError GetThreadGroupChildren(JDWP::ObjectId thread_group_id, |
| 431 | JDWP::ExpandBuf* pReply) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 432 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 433 | static JDWP::ObjectId GetSystemThreadGroupId() |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 434 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 435 | |
Jeff Hao | 920af3e | 2013-08-28 15:46:38 -0700 | [diff] [blame] | 436 | static JDWP::JdwpThreadStatus ToJdwpThreadStatus(ThreadState state); |
Sebastien Hertz | 52d131d | 2014-03-13 16:17:40 +0100 | [diff] [blame] | 437 | static JDWP::JdwpError GetThreadStatus(JDWP::ObjectId thread_id, |
| 438 | JDWP::JdwpThreadStatus* pThreadStatus, |
| 439 | JDWP::JdwpSuspendStatus* pSuspendStatus) |
| 440 | LOCKS_EXCLUDED(Locks::thread_list_lock_); |
| 441 | static JDWP::JdwpError GetThreadDebugSuspendCount(JDWP::ObjectId thread_id, |
| 442 | JDWP::ExpandBuf* pReply) |
| 443 | LOCKS_EXCLUDED(Locks::thread_list_lock_, |
| 444 | Locks::thread_suspend_count_lock_); |
Brian Carlstrom | 7934ac2 | 2013-07-26 10:54:15 -0700 | [diff] [blame] | 445 | // static void WaitForSuspend(JDWP::ObjectId thread_id); |
Elliott Hughes | caf7654 | 2012-06-28 16:08:22 -0700 | [diff] [blame] | 446 | |
Elliott Hughes | 026b146 | 2012-06-28 20:43:49 -0700 | [diff] [blame] | 447 | // Fills 'thread_ids' with the threads in the given thread group. If thread_group_id == 0, |
Elliott Hughes | caf7654 | 2012-06-28 16:08:22 -0700 | [diff] [blame] | 448 | // returns all threads. |
Sebastien Hertz | a06430c | 2014-09-15 19:21:30 +0200 | [diff] [blame] | 449 | static void GetThreads(mirror::Object* thread_group, std::vector<JDWP::ObjectId>* thread_ids) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 450 | LOCKS_EXCLUDED(Locks::thread_list_lock_) |
| 451 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | caf7654 | 2012-06-28 16:08:22 -0700 | [diff] [blame] | 452 | |
Ian Rogers | c0542af | 2014-09-03 16:16:56 -0700 | [diff] [blame] | 453 | static JDWP::JdwpError GetThreadFrameCount(JDWP::ObjectId thread_id, size_t* result) |
Sebastien Hertz | 52d131d | 2014-03-13 16:17:40 +0100 | [diff] [blame] | 454 | LOCKS_EXCLUDED(Locks::thread_list_lock_); |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 455 | static JDWP::JdwpError GetThreadFrames(JDWP::ObjectId thread_id, size_t start_frame, |
| 456 | size_t frame_count, JDWP::ExpandBuf* buf) |
Sebastien Hertz | 52d131d | 2014-03-13 16:17:40 +0100 | [diff] [blame] | 457 | LOCKS_EXCLUDED(Locks::thread_list_lock_) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 458 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 459 | |
Sebastien Hertz | 6995c60 | 2014-09-09 12:10:13 +0200 | [diff] [blame] | 460 | static JDWP::ObjectId GetThreadSelfId() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 461 | static JDWP::ObjectId GetThreadId(Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 462 | |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 463 | static void SuspendVM() |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 464 | LOCKS_EXCLUDED(Locks::thread_list_lock_, |
| 465 | Locks::thread_suspend_count_lock_); |
Sebastien Hertz | 253fa55 | 2014-10-14 17:27:15 +0200 | [diff] [blame] | 466 | static void ResumeVM() |
| 467 | LOCKS_EXCLUDED(Locks::thread_list_lock_, |
| 468 | Locks::thread_suspend_count_lock_); |
Elliott Hughes | 88d6309 | 2013-01-09 09:55:54 -0800 | [diff] [blame] | 469 | static JDWP::JdwpError SuspendThread(JDWP::ObjectId thread_id, bool request_suspension = true) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 470 | LOCKS_EXCLUDED(Locks::mutator_lock_, |
| 471 | Locks::thread_list_lock_, |
| 472 | Locks::thread_suspend_count_lock_); |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 473 | |
Elliott Hughes | 88d6309 | 2013-01-09 09:55:54 -0800 | [diff] [blame] | 474 | static void ResumeThread(JDWP::ObjectId thread_id) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 475 | LOCKS_EXCLUDED(Locks::thread_list_lock_, |
| 476 | Locks::thread_suspend_count_lock_) |
| 477 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 478 | static void SuspendSelf(); |
| 479 | |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 480 | static JDWP::JdwpError GetThisObject(JDWP::ObjectId thread_id, JDWP::FrameId frame_id, |
| 481 | JDWP::ObjectId* result) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 482 | LOCKS_EXCLUDED(Locks::thread_list_lock_, |
| 483 | Locks::thread_suspend_count_lock_) |
| 484 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Sebastien Hertz | 8009f39 | 2014-09-01 17:07:11 +0200 | [diff] [blame] | 485 | static JDWP::JdwpError GetLocalValues(JDWP::Request* request, JDWP::ExpandBuf* pReply) |
Sebastien Hertz | 52d131d | 2014-03-13 16:17:40 +0100 | [diff] [blame] | 486 | LOCKS_EXCLUDED(Locks::thread_list_lock_) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 487 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Sebastien Hertz | 8009f39 | 2014-09-01 17:07:11 +0200 | [diff] [blame] | 488 | static JDWP::JdwpError SetLocalValues(JDWP::Request* request) |
Sebastien Hertz | 52d131d | 2014-03-13 16:17:40 +0100 | [diff] [blame] | 489 | LOCKS_EXCLUDED(Locks::thread_list_lock_) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 490 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 491 | |
Sebastien Hertz | 52d131d | 2014-03-13 16:17:40 +0100 | [diff] [blame] | 492 | static JDWP::JdwpError Interrupt(JDWP::ObjectId thread_id) |
| 493 | LOCKS_EXCLUDED(Locks::thread_list_lock_); |
Elliott Hughes | f950170 | 2013-01-11 11:22:27 -0800 | [diff] [blame] | 494 | |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 495 | /* |
| 496 | * Debugger notification |
| 497 | */ |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 498 | enum EventFlag { |
Elliott Hughes | 8696433 | 2012-02-15 19:37:42 -0800 | [diff] [blame] | 499 | kBreakpoint = 0x01, |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 500 | kSingleStep = 0x02, |
| 501 | kMethodEntry = 0x04, |
| 502 | kMethodExit = 0x08, |
| 503 | }; |
Sebastien Hertz | 3f52eaf | 2014-04-04 17:50:18 +0200 | [diff] [blame] | 504 | static void PostFieldAccessEvent(mirror::ArtMethod* m, int dex_pc, mirror::Object* this_object, |
| 505 | mirror::ArtField* f) |
| 506 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 507 | static void PostFieldModificationEvent(mirror::ArtMethod* m, int dex_pc, |
| 508 | mirror::Object* this_object, mirror::ArtField* f, |
| 509 | const JValue* field_value) |
| 510 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 511 | static void PostException(const ThrowLocation& throw_location, mirror::ArtMethod* catch_method, |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 512 | uint32_t catch_dex_pc, mirror::Throwable* exception) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 513 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 514 | static void PostThreadStart(Thread* t) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 515 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 516 | static void PostThreadDeath(Thread* t) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 517 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 518 | static void PostClassPrepare(mirror::Class* c) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 519 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 520 | |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 521 | static void UpdateDebugger(Thread* thread, mirror::Object* this_object, |
Sebastien Hertz | 8379b22 | 2014-02-24 17:38:15 +0100 | [diff] [blame] | 522 | mirror::ArtMethod* method, uint32_t new_dex_pc, |
| 523 | int event_flags, const JValue* return_value) |
jeffhao | 09bfc6a | 2012-12-11 18:11:43 -0800 | [diff] [blame] | 524 | LOCKS_EXCLUDED(Locks::breakpoint_lock_) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 525 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 91bf6cd | 2012-02-14 17:27:48 -0800 | [diff] [blame] | 526 | |
Sebastien Hertz | f392879 | 2014-11-17 19:00:37 +0100 | [diff] [blame] | 527 | // Indicates whether we need deoptimization for debugging. |
| 528 | static bool RequiresDeoptimization(); |
| 529 | |
Sebastien Hertz | 4d25df3 | 2014-03-21 17:44:46 +0100 | [diff] [blame] | 530 | // Records deoptimization request in the queue. |
| 531 | static void RequestDeoptimization(const DeoptimizationRequest& req) |
Brian Carlstrom | 306db81 | 2014-09-05 13:01:41 -0700 | [diff] [blame] | 532 | LOCKS_EXCLUDED(Locks::deoptimization_lock_) |
Sebastien Hertz | 138dbfc | 2013-12-04 18:15:25 +0100 | [diff] [blame] | 533 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 534 | |
Sebastien Hertz | 7ec2f1c | 2014-03-27 20:06:47 +0100 | [diff] [blame] | 535 | // Support delayed full undeoptimization requests. This is currently only used for single-step |
| 536 | // events. |
Brian Carlstrom | 306db81 | 2014-09-05 13:01:41 -0700 | [diff] [blame] | 537 | static void DelayFullUndeoptimization() LOCKS_EXCLUDED(Locks::deoptimization_lock_); |
Sebastien Hertz | 7ec2f1c | 2014-03-27 20:06:47 +0100 | [diff] [blame] | 538 | static void ProcessDelayedFullUndeoptimizations() |
Brian Carlstrom | 306db81 | 2014-09-05 13:01:41 -0700 | [diff] [blame] | 539 | LOCKS_EXCLUDED(Locks::deoptimization_lock_) |
Sebastien Hertz | 7ec2f1c | 2014-03-27 20:06:47 +0100 | [diff] [blame] | 540 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 541 | |
Sebastien Hertz | 4d25df3 | 2014-03-21 17:44:46 +0100 | [diff] [blame] | 542 | // Manage deoptimization after updating JDWP events list. Suspends all threads, processes each |
| 543 | // request and finally resumes all threads. |
Sebastien Hertz | 138dbfc | 2013-12-04 18:15:25 +0100 | [diff] [blame] | 544 | static void ManageDeoptimization() |
Brian Carlstrom | 306db81 | 2014-09-05 13:01:41 -0700 | [diff] [blame] | 545 | LOCKS_EXCLUDED(Locks::deoptimization_lock_) |
Sebastien Hertz | 138dbfc | 2013-12-04 18:15:25 +0100 | [diff] [blame] | 546 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 547 | |
| 548 | // Breakpoints. |
Sebastien Hertz | 4d25df3 | 2014-03-21 17:44:46 +0100 | [diff] [blame] | 549 | static void WatchLocation(const JDWP::JdwpLocation* pLoc, DeoptimizationRequest* req) |
| 550 | LOCKS_EXCLUDED(Locks::breakpoint_lock_) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 551 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Sebastien Hertz | 4d25df3 | 2014-03-21 17:44:46 +0100 | [diff] [blame] | 552 | static void UnwatchLocation(const JDWP::JdwpLocation* pLoc, DeoptimizationRequest* req) |
| 553 | LOCKS_EXCLUDED(Locks::breakpoint_lock_) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 554 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Sebastien Hertz | 138dbfc | 2013-12-04 18:15:25 +0100 | [diff] [blame] | 555 | |
| 556 | // Single-stepping. |
Elliott Hughes | 88d6309 | 2013-01-09 09:55:54 -0800 | [diff] [blame] | 557 | static JDWP::JdwpError ConfigureStep(JDWP::ObjectId thread_id, JDWP::JdwpStepSize size, |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 558 | JDWP::JdwpStepDepth depth) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 559 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Sebastien Hertz | 61b7f1b | 2013-11-15 15:59:30 +0100 | [diff] [blame] | 560 | static void UnconfigureStep(JDWP::ObjectId thread_id) |
Sebastien Hertz | 52d131d | 2014-03-13 16:17:40 +0100 | [diff] [blame] | 561 | LOCKS_EXCLUDED(Locks::thread_list_lock_) |
Sebastien Hertz | 61b7f1b | 2013-11-15 15:59:30 +0100 | [diff] [blame] | 562 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 563 | |
Elliott Hughes | 88d6309 | 2013-01-09 09:55:54 -0800 | [diff] [blame] | 564 | static JDWP::JdwpError InvokeMethod(JDWP::ObjectId thread_id, JDWP::ObjectId object_id, |
| 565 | JDWP::RefTypeId class_id, JDWP::MethodId method_id, |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 566 | uint32_t arg_count, uint64_t* arg_values, |
| 567 | JDWP::JdwpTag* arg_types, uint32_t options, |
| 568 | JDWP::JdwpTag* pResultTag, uint64_t* pResultValue, |
| 569 | JDWP::ObjectId* pExceptObj) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 570 | LOCKS_EXCLUDED(Locks::thread_list_lock_, |
| 571 | Locks::thread_suspend_count_lock_) |
| 572 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 573 | static void ExecuteMethod(DebugInvokeReq* pReq); |
| 574 | |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 575 | /* |
| 576 | * DDM support. |
| 577 | */ |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 578 | static void DdmSendThreadNotification(Thread* t, uint32_t type) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 579 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Sebastien Hertz | 52d131d | 2014-03-13 16:17:40 +0100 | [diff] [blame] | 580 | static void DdmSetThreadNotification(bool enable) |
| 581 | LOCKS_EXCLUDED(Locks::thread_list_lock_); |
Ian Rogers | c0542af | 2014-09-03 16:16:56 -0700 | [diff] [blame] | 582 | static bool DdmHandlePacket(JDWP::Request* request, uint8_t** pReplyBuf, int* pReplyLen); |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 583 | static void DdmConnected() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 584 | static void DdmDisconnected() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 585 | static void DdmSendChunk(uint32_t type, const std::vector<uint8_t>& bytes) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 586 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 587 | static void DdmSendChunk(uint32_t type, size_t len, const uint8_t* buf) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 588 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 589 | static void DdmSendChunkV(uint32_t type, const iovec* iov, int iov_count) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 590 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 767a147 | 2011-10-26 18:49:02 -0700 | [diff] [blame] | 591 | |
Mathieu Chartier | 3b05e9b | 2014-03-25 09:29:43 -0700 | [diff] [blame] | 592 | static void VisitRoots(RootCallback* callback, void* arg) |
| 593 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 594 | |
Elliott Hughes | 545a064 | 2011-11-08 19:10:03 -0800 | [diff] [blame] | 595 | /* |
| 596 | * Recent allocation tracking support. |
| 597 | */ |
Ian Rogers | 844506b | 2014-09-12 19:59:33 -0700 | [diff] [blame] | 598 | static void RecordAllocation(Thread* self, mirror::Class* type, size_t byte_count) |
Brian Carlstrom | 306db81 | 2014-09-05 13:01:41 -0700 | [diff] [blame] | 599 | LOCKS_EXCLUDED(Locks::alloc_tracker_lock_) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 600 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Brian Carlstrom | 306db81 | 2014-09-05 13:01:41 -0700 | [diff] [blame] | 601 | static void SetAllocTrackingEnabled(bool enabled) LOCKS_EXCLUDED(Locks::alloc_tracker_lock_); |
Ian Rogers | 719d1a3 | 2014-03-06 12:13:39 -0800 | [diff] [blame] | 602 | static bool IsAllocTrackingEnabled() { |
| 603 | return recent_allocation_records_ != nullptr; |
| 604 | } |
Sebastien Hertz | 52d131d | 2014-03-13 16:17:40 +0100 | [diff] [blame] | 605 | static jbyteArray GetRecentAllocations() |
Brian Carlstrom | 306db81 | 2014-09-05 13:01:41 -0700 | [diff] [blame] | 606 | LOCKS_EXCLUDED(Locks::alloc_tracker_lock_) |
Sebastien Hertz | 52d131d | 2014-03-13 16:17:40 +0100 | [diff] [blame] | 607 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Brian Carlstrom | 306db81 | 2014-09-05 13:01:41 -0700 | [diff] [blame] | 608 | static size_t HeadIndex() EXCLUSIVE_LOCKS_REQUIRED(Locks::alloc_tracker_lock_); |
| 609 | static void DumpRecentAllocations() LOCKS_EXCLUDED(Locks::alloc_tracker_lock_); |
Elliott Hughes | 545a064 | 2011-11-08 19:10:03 -0800 | [diff] [blame] | 610 | |
Elliott Hughes | 767a147 | 2011-10-26 18:49:02 -0700 | [diff] [blame] | 611 | enum HpifWhen { |
| 612 | HPIF_WHEN_NEVER = 0, |
| 613 | HPIF_WHEN_NOW = 1, |
| 614 | HPIF_WHEN_NEXT_GC = 2, |
| 615 | HPIF_WHEN_EVERY_GC = 3 |
| 616 | }; |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 617 | static int DdmHandleHpifChunk(HpifWhen when) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 618 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 767a147 | 2011-10-26 18:49:02 -0700 | [diff] [blame] | 619 | |
| 620 | enum HpsgWhen { |
| 621 | HPSG_WHEN_NEVER = 0, |
| 622 | HPSG_WHEN_EVERY_GC = 1, |
| 623 | }; |
| 624 | enum HpsgWhat { |
| 625 | HPSG_WHAT_MERGED_OBJECTS = 0, |
| 626 | HPSG_WHAT_DISTINCT_OBJECTS = 1, |
| 627 | }; |
| 628 | static bool DdmHandleHpsgNhsgChunk(HpsgWhen when, HpsgWhat what, bool native); |
| 629 | |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 630 | static void DdmSendHeapInfo(HpifWhen reason) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 631 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 632 | static void DdmSendHeapSegments(bool native) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 633 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 545a064 | 2011-11-08 19:10:03 -0800 | [diff] [blame] | 634 | |
Sebastien Hertz | 6995c60 | 2014-09-09 12:10:13 +0200 | [diff] [blame] | 635 | static ObjectRegistry* GetObjectRegistry() { |
| 636 | return gRegistry; |
| 637 | } |
| 638 | |
| 639 | static JDWP::JdwpTag TagFromObject(const ScopedObjectAccessUnchecked& soa, mirror::Object* o) |
| 640 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 641 | |
| 642 | static JDWP::JdwpTypeTag GetTypeTag(mirror::Class* klass) |
| 643 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 644 | |
| 645 | static JDWP::FieldId ToFieldId(const mirror::ArtField* f) |
| 646 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 647 | |
| 648 | static void SetJdwpLocation(JDWP::JdwpLocation* location, mirror::ArtMethod* m, uint32_t dex_pc) |
| 649 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 650 | |
Mathieu Chartier | ad466ad | 2015-01-08 16:28:08 -0800 | [diff] [blame] | 651 | static JDWP::JdwpState* GetJdwpState(); |
| 652 | |
Elliott Hughes | 545a064 | 2011-11-08 19:10:03 -0800 | [diff] [blame] | 653 | private: |
Sebastien Hertz | 8009f39 | 2014-09-01 17:07:11 +0200 | [diff] [blame] | 654 | static JDWP::JdwpError GetLocalValue(const StackVisitor& visitor, |
| 655 | ScopedObjectAccessUnchecked& soa, int slot, |
| 656 | JDWP::JdwpTag tag, uint8_t* buf, size_t width) |
| 657 | LOCKS_EXCLUDED(Locks::thread_list_lock_) |
| 658 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 659 | static JDWP::JdwpError SetLocalValue(StackVisitor& visitor, int slot, JDWP::JdwpTag tag, |
| 660 | uint64_t value, size_t width) |
| 661 | LOCKS_EXCLUDED(Locks::thread_list_lock_) |
| 662 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 663 | |
Brian Carlstrom | 2d88862 | 2013-07-18 17:02:00 -0700 | [diff] [blame] | 664 | static void DdmBroadcast(bool connect) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 665 | static void PostThreadStartOrStop(Thread*, uint32_t) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 666 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | a215526 | 2011-11-16 16:26:58 -0800 | [diff] [blame] | 667 | |
Sebastien Hertz | 8379b22 | 2014-02-24 17:38:15 +0100 | [diff] [blame] | 668 | static void PostLocationEvent(mirror::ArtMethod* method, int pcOffset, |
| 669 | mirror::Object* thisPtr, int eventFlags, |
| 670 | const JValue* return_value) |
| 671 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 672 | |
Sebastien Hertz | 4d25df3 | 2014-03-21 17:44:46 +0100 | [diff] [blame] | 673 | static void ProcessDeoptimizationRequest(const DeoptimizationRequest& request) |
| 674 | EXCLUSIVE_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 675 | |
Sebastien Hertz | 7ec2f1c | 2014-03-27 20:06:47 +0100 | [diff] [blame] | 676 | static void RequestDeoptimizationLocked(const DeoptimizationRequest& req) |
Brian Carlstrom | 306db81 | 2014-09-05 13:01:41 -0700 | [diff] [blame] | 677 | EXCLUSIVE_LOCKS_REQUIRED(Locks::deoptimization_lock_) |
Sebastien Hertz | 7ec2f1c | 2014-03-27 20:06:47 +0100 | [diff] [blame] | 678 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 679 | |
Brian Carlstrom | 306db81 | 2014-09-05 13:01:41 -0700 | [diff] [blame] | 680 | static AllocRecord* recent_allocation_records_ PT_GUARDED_BY(Locks::alloc_tracker_lock_); |
| 681 | static size_t alloc_record_max_ GUARDED_BY(Locks::alloc_tracker_lock_); |
| 682 | static size_t alloc_record_head_ GUARDED_BY(Locks::alloc_tracker_lock_); |
| 683 | static size_t alloc_record_count_ GUARDED_BY(Locks::alloc_tracker_lock_); |
Sebastien Hertz | 4d25df3 | 2014-03-21 17:44:46 +0100 | [diff] [blame] | 684 | |
Sebastien Hertz | 6995c60 | 2014-09-09 12:10:13 +0200 | [diff] [blame] | 685 | static ObjectRegistry* gRegistry; |
| 686 | |
Sebastien Hertz | 4d25df3 | 2014-03-21 17:44:46 +0100 | [diff] [blame] | 687 | // Deoptimization requests to be processed each time the event list is updated. This is used when |
| 688 | // registering and unregistering events so we do not deoptimize while holding the event list |
| 689 | // lock. |
Sebastien Hertz | 42cd43f | 2014-05-13 14:15:41 +0200 | [diff] [blame] | 690 | // TODO rename to instrumentation_requests. |
Brian Carlstrom | 306db81 | 2014-09-05 13:01:41 -0700 | [diff] [blame] | 691 | static std::vector<DeoptimizationRequest> deoptimization_requests_ GUARDED_BY(Locks::deoptimization_lock_); |
Sebastien Hertz | 4d25df3 | 2014-03-21 17:44:46 +0100 | [diff] [blame] | 692 | |
| 693 | // Count the number of events requiring full deoptimization. When the counter is > 0, everything |
| 694 | // is deoptimized, otherwise everything is undeoptimized. |
| 695 | // Note: we fully deoptimize on the first event only (when the counter is set to 1). We fully |
| 696 | // undeoptimize when the last event is unregistered (when the counter is set to 0). |
Brian Carlstrom | 306db81 | 2014-09-05 13:01:41 -0700 | [diff] [blame] | 697 | static size_t full_deoptimization_event_count_ GUARDED_BY(Locks::deoptimization_lock_); |
Sebastien Hertz | 4d25df3 | 2014-03-21 17:44:46 +0100 | [diff] [blame] | 698 | |
Sebastien Hertz | 7ec2f1c | 2014-03-27 20:06:47 +0100 | [diff] [blame] | 699 | // Count the number of full undeoptimization requests delayed to next resume or end of debug |
| 700 | // session. |
Brian Carlstrom | 306db81 | 2014-09-05 13:01:41 -0700 | [diff] [blame] | 701 | static size_t delayed_full_undeoptimization_count_ GUARDED_BY(Locks::deoptimization_lock_); |
Sebastien Hertz | 7ec2f1c | 2014-03-27 20:06:47 +0100 | [diff] [blame] | 702 | |
Sebastien Hertz | 42cd43f | 2014-05-13 14:15:41 +0200 | [diff] [blame] | 703 | static size_t* GetReferenceCounterForEvent(uint32_t instrumentation_event); |
| 704 | |
Mathieu Chartier | 4345c46 | 2014-06-27 10:20:14 -0700 | [diff] [blame] | 705 | // Weak global type cache, TODO improve this. |
Brian Carlstrom | 306db81 | 2014-09-05 13:01:41 -0700 | [diff] [blame] | 706 | static TypeCache type_cache_ GUARDED_BY(Locks::alloc_tracker_lock_); |
Mathieu Chartier | 4345c46 | 2014-06-27 10:20:14 -0700 | [diff] [blame] | 707 | |
Sebastien Hertz | 42cd43f | 2014-05-13 14:15:41 +0200 | [diff] [blame] | 708 | // Instrumentation event reference counters. |
| 709 | // TODO we could use an array instead of having all these dedicated counters. Instrumentation |
| 710 | // events are bits of a mask so we could convert them to array index. |
Brian Carlstrom | 306db81 | 2014-09-05 13:01:41 -0700 | [diff] [blame] | 711 | static size_t dex_pc_change_event_ref_count_ GUARDED_BY(Locks::deoptimization_lock_); |
| 712 | static size_t method_enter_event_ref_count_ GUARDED_BY(Locks::deoptimization_lock_); |
| 713 | static size_t method_exit_event_ref_count_ GUARDED_BY(Locks::deoptimization_lock_); |
| 714 | static size_t field_read_event_ref_count_ GUARDED_BY(Locks::deoptimization_lock_); |
| 715 | static size_t field_write_event_ref_count_ GUARDED_BY(Locks::deoptimization_lock_); |
| 716 | static size_t exception_catch_event_ref_count_ GUARDED_BY(Locks::deoptimization_lock_); |
Sebastien Hertz | 42cd43f | 2014-05-13 14:15:41 +0200 | [diff] [blame] | 717 | static uint32_t instrumentation_events_ GUARDED_BY(Locks::mutator_lock_); |
| 718 | |
Brian Carlstrom | 306db81 | 2014-09-05 13:01:41 -0700 | [diff] [blame] | 719 | friend class AllocRecord; // For type_cache_ with proper annotalysis. |
Ian Rogers | 719d1a3 | 2014-03-06 12:13:39 -0800 | [diff] [blame] | 720 | DISALLOW_COPY_AND_ASSIGN(Dbg); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 721 | }; |
| 722 | |
| 723 | #define CHUNK_TYPE(_name) \ |
Elliott Hughes | 8218847 | 2011-11-07 18:11:48 -0800 | [diff] [blame] | 724 | static_cast<uint32_t>((_name)[0] << 24 | (_name)[1] << 16 | (_name)[2] << 8 | (_name)[3]) |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 725 | |
| 726 | } // namespace art |
| 727 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 728 | #endif // ART_RUNTIME_DEBUGGER_H_ |