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