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 | */ |
| 21 | #ifndef ART_DEBUGGER_H_ |
| 22 | #define ART_DEBUGGER_H_ |
| 23 | |
| 24 | #include <pthread.h> |
| 25 | |
Elliott Hughes | 3bb8156 | 2011-10-21 18:52:59 -0700 | [diff] [blame] | 26 | #include <string> |
| 27 | |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 28 | #include "jdwp/jdwp.h" |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 29 | #include "jni.h" |
| 30 | #include "jvalue.h" |
| 31 | #include "root_visitor.h" |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 32 | |
| 33 | namespace art { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 34 | namespace mirror { |
| 35 | class AbstractMethod; |
| 36 | class Class; |
| 37 | class Object; |
| 38 | class Throwable; |
| 39 | } // namespace mirror |
Elliott Hughes | 545a064 | 2011-11-08 19:10:03 -0800 | [diff] [blame] | 40 | struct AllocRecord; |
Ian Rogers | 1b09b09 | 2012-08-20 15:35:52 -0700 | [diff] [blame] | 41 | class Thread; |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 42 | |
| 43 | /* |
| 44 | * Invoke-during-breakpoint support. |
| 45 | */ |
| 46 | struct DebugInvokeReq { |
Elliott Hughes | 7b3cdfc | 2011-12-08 21:28:17 -0800 | [diff] [blame] | 47 | DebugInvokeReq() |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 48 | : ready(false), invoke_needed_(false), |
| 49 | receiver_(NULL), thread_(NULL), class_(NULL), method_(NULL), |
| 50 | arg_count_(0), arg_values_(NULL), options_(0), error(JDWP::ERR_NONE), |
| 51 | result_tag(JDWP::JT_VOID), exception(0), |
jeffhao | 9b5aa6f | 2012-12-18 11:47:11 -0800 | [diff] [blame] | 52 | lock_("a DebugInvokeReq lock", kBreakpointInvokeLock), |
Ian Rogers | c604d73 | 2012-10-14 16:09:54 -0700 | [diff] [blame] | 53 | cond_("a DebugInvokeReq condition variable", lock_) { |
Elliott Hughes | 475fc23 | 2011-10-25 15:00:35 -0700 | [diff] [blame] | 54 | } |
| 55 | |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 56 | /* boolean; only set when we're in the tail end of an event handler */ |
| 57 | bool ready; |
| 58 | |
| 59 | /* boolean; set if the JDWP thread wants this thread to do work */ |
Elliott Hughes | d07986f | 2011-12-06 18:27:45 -0800 | [diff] [blame] | 60 | bool invoke_needed_; |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 61 | |
| 62 | /* request */ |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 63 | mirror::Object* receiver_; /* not used for ClassType.InvokeMethod */ |
| 64 | mirror::Object* thread_; |
| 65 | mirror::Class* class_; |
| 66 | mirror::AbstractMethod* method_; |
Elliott Hughes | 45651fd | 2012-02-21 15:48:20 -0800 | [diff] [blame] | 67 | uint32_t arg_count_; |
| 68 | uint64_t* arg_values_; /* will be NULL if arg_count_ == 0 */ |
Elliott Hughes | d07986f | 2011-12-06 18:27:45 -0800 | [diff] [blame] | 69 | uint32_t options_; |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 70 | |
| 71 | /* result */ |
Elliott Hughes | 475fc23 | 2011-10-25 15:00:35 -0700 | [diff] [blame] | 72 | JDWP::JdwpError error; |
Elliott Hughes | d07986f | 2011-12-06 18:27:45 -0800 | [diff] [blame] | 73 | JDWP::JdwpTag result_tag; |
Elliott Hughes | 475fc23 | 2011-10-25 15:00:35 -0700 | [diff] [blame] | 74 | JValue result_value; |
| 75 | JDWP::ObjectId exception; |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 76 | |
| 77 | /* condition variable to wait on while the method executes */ |
Ian Rogers | c604d73 | 2012-10-14 16:09:54 -0700 | [diff] [blame] | 78 | Mutex lock_ DEFAULT_MUTEX_ACQUIRED_AFTER; |
| 79 | ConditionVariable cond_ GUARDED_BY(lock_); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 80 | }; |
| 81 | |
| 82 | class Dbg { |
Elliott Hughes | ff17f1f | 2012-01-24 18:12:29 -0800 | [diff] [blame] | 83 | public: |
Elliott Hughes | 3bb8156 | 2011-10-21 18:52:59 -0700 | [diff] [blame] | 84 | static bool ParseJdwpOptions(const std::string& options); |
Elliott Hughes | 4ffd313 | 2011-10-24 12:06:42 -0700 | [diff] [blame] | 85 | static void SetJdwpAllowed(bool allowed); |
| 86 | |
Elliott Hughes | d1cc836 | 2011-10-24 16:58:50 -0700 | [diff] [blame] | 87 | static void StartJdwp(); |
| 88 | static void StopJdwp(); |
| 89 | |
Elliott Hughes | 767a147 | 2011-10-26 18:49:02 -0700 | [diff] [blame] | 90 | // Invoked by the GC in case we need to keep DDMS informed. |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 91 | static void GcDidFinish() LOCKS_EXCLUDED(Locks::mutator_lock_); |
Elliott Hughes | 767a147 | 2011-10-26 18:49:02 -0700 | [diff] [blame] | 92 | |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 93 | // Return the DebugInvokeReq for the current thread. |
| 94 | static DebugInvokeReq* GetInvokeReq(); |
| 95 | |
Elliott Hughes | 475fc23 | 2011-10-25 15:00:35 -0700 | [diff] [blame] | 96 | static Thread* GetDebugThread(); |
| 97 | static void ClearWaitForEventThread(); |
| 98 | |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 99 | /* |
| 100 | * Enable/disable breakpoints and step modes. Used to provide a heads-up |
| 101 | * when the debugger attaches. |
| 102 | */ |
| 103 | static void Connected(); |
jeffhao | 09bfc6a | 2012-12-11 18:11:43 -0800 | [diff] [blame] | 104 | static void GoActive() LOCKS_EXCLUDED(Locks::breakpoint_lock_); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 105 | static void Disconnected(); |
Elliott Hughes | 8696433 | 2012-02-15 19:37:42 -0800 | [diff] [blame] | 106 | static void Disposed(); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 107 | |
Elliott Hughes | c0f0933 | 2012-03-26 13:27:06 -0700 | [diff] [blame] | 108 | // Returns true if we're actually debugging with a real debugger, false if it's |
| 109 | // just DDMS (or nothing at all). |
| 110 | static bool IsDebuggerActive(); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 111 | |
Elliott Hughes | c0f0933 | 2012-03-26 13:27:06 -0700 | [diff] [blame] | 112 | // Returns true if we had -Xrunjdwp or -agentlib:jdwp= on the command line. |
| 113 | static bool IsJdwpConfigured(); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 114 | |
Elliott Hughes | 8696433 | 2012-02-15 19:37:42 -0800 | [diff] [blame] | 115 | static bool IsDisposed(); |
| 116 | |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 117 | /* |
| 118 | * Time, in milliseconds, since the last debugger activity. Does not |
| 119 | * include DDMS activity. Returns -1 if there has been no activity. |
| 120 | * Returns 0 if we're in the middle of handling a debugger request. |
| 121 | */ |
| 122 | static int64_t LastDebuggerActivity(); |
| 123 | |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 124 | static void UndoDebuggerSuspensions(); |
| 125 | |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 126 | /* |
| 127 | * Class, Object, Array |
| 128 | */ |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 129 | static std::string GetClassName(JDWP::RefTypeId id) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 130 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 88d6309 | 2013-01-09 09:55:54 -0800 | [diff] [blame] | 131 | static JDWP::JdwpError GetClassObject(JDWP::RefTypeId id, JDWP::ObjectId& class_object_id) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 132 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 88d6309 | 2013-01-09 09:55:54 -0800 | [diff] [blame] | 133 | static JDWP::JdwpError GetSuperclass(JDWP::RefTypeId id, JDWP::RefTypeId& superclass_id) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 134 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 135 | static JDWP::JdwpError GetClassLoader(JDWP::RefTypeId id, JDWP::ExpandBuf* pReply) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 136 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 137 | static JDWP::JdwpError GetModifiers(JDWP::RefTypeId id, JDWP::ExpandBuf* pReply) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 138 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 88d6309 | 2013-01-09 09:55:54 -0800 | [diff] [blame] | 139 | static JDWP::JdwpError GetReflectedType(JDWP::RefTypeId class_id, JDWP::ExpandBuf* pReply) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 140 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 141 | static void GetClassList(std::vector<JDWP::RefTypeId>& classes) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 142 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 88d6309 | 2013-01-09 09:55:54 -0800 | [diff] [blame] | 143 | static JDWP::JdwpError GetClassInfo(JDWP::RefTypeId class_id, JDWP::JdwpTypeTag* pTypeTag, |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 144 | uint32_t* pStatus, std::string* pDescriptor) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 145 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 146 | static void FindLoadedClassBySignature(const char* descriptor, std::vector<JDWP::RefTypeId>& ids) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 147 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 64f574f | 2013-02-20 14:57:12 -0800 | [diff] [blame] | 148 | static JDWP::JdwpError GetReferenceType(JDWP::ObjectId object_id, JDWP::ExpandBuf* pReply) |
| 149 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 88d6309 | 2013-01-09 09:55:54 -0800 | [diff] [blame] | 150 | static JDWP::JdwpError GetSignature(JDWP::RefTypeId ref_type_id, std::string& signature) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 151 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 88d6309 | 2013-01-09 09:55:54 -0800 | [diff] [blame] | 152 | 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] | 153 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 88d6309 | 2013-01-09 09:55:54 -0800 | [diff] [blame] | 154 | static JDWP::JdwpError GetObjectTag(JDWP::ObjectId object_id, uint8_t& tag) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 155 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | aed4be9 | 2011-12-02 16:16:23 -0800 | [diff] [blame] | 156 | static size_t GetTagWidth(JDWP::JdwpTag tag); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 157 | |
Elliott Hughes | 88d6309 | 2013-01-09 09:55:54 -0800 | [diff] [blame] | 158 | static JDWP::JdwpError GetArrayLength(JDWP::ObjectId array_id, int& length) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 159 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 88d6309 | 2013-01-09 09:55:54 -0800 | [diff] [blame] | 160 | static JDWP::JdwpError OutputArray(JDWP::ObjectId array_id, int offset, int count, |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 161 | JDWP::ExpandBuf* pReply) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 162 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 88d6309 | 2013-01-09 09:55:54 -0800 | [diff] [blame] | 163 | static JDWP::JdwpError SetArrayElements(JDWP::ObjectId array_id, int offset, int count, |
Elliott Hughes | 4b9702c | 2013-02-20 18:13:24 -0800 | [diff] [blame^] | 164 | JDWP::Request& request) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 165 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 166 | |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 167 | static JDWP::ObjectId CreateString(const std::string& str) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 168 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 88d6309 | 2013-01-09 09:55:54 -0800 | [diff] [blame] | 169 | static JDWP::JdwpError CreateObject(JDWP::RefTypeId class_id, JDWP::ObjectId& new_object) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 170 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 88d6309 | 2013-01-09 09:55:54 -0800 | [diff] [blame] | 171 | static JDWP::JdwpError CreateArrayObject(JDWP::RefTypeId array_class_id, uint32_t length, |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 172 | JDWP::ObjectId& new_array) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 173 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 174 | |
Elliott Hughes | 88d6309 | 2013-01-09 09:55:54 -0800 | [diff] [blame] | 175 | static bool MatchType(JDWP::RefTypeId instance_class_id, JDWP::RefTypeId class_id) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 176 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 177 | |
Elliott Hughes | ec0f83d | 2013-01-15 16:54:08 -0800 | [diff] [blame] | 178 | // |
| 179 | // Monitors. |
| 180 | // |
| 181 | static JDWP::JdwpError GetMonitorInfo(JDWP::ObjectId object_id, JDWP::ExpandBuf* reply) |
| 182 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 183 | static JDWP::JdwpError GetOwnedMonitors(JDWP::ObjectId thread_id, |
| 184 | std::vector<JDWP::ObjectId>& monitors, |
| 185 | std::vector<uint32_t>& stack_depths) |
| 186 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 187 | static JDWP::JdwpError GetContendedMonitor(JDWP::ObjectId thread_id, JDWP::ObjectId& contended_monitor) |
| 188 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 189 | |
| 190 | // |
| 191 | // Heap. |
| 192 | // |
| 193 | static JDWP::JdwpError GetInstanceCounts(const std::vector<JDWP::RefTypeId>& class_ids, |
| 194 | std::vector<uint64_t>& counts) |
| 195 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 3b78c94 | 2013-01-15 17:35:41 -0800 | [diff] [blame] | 196 | static JDWP::JdwpError GetInstances(JDWP::RefTypeId class_id, int32_t max_count, |
| 197 | std::vector<JDWP::ObjectId>& instances) |
| 198 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 0cbaff5 | 2013-01-16 15:28:01 -0800 | [diff] [blame] | 199 | static JDWP::JdwpError GetReferringObjects(JDWP::ObjectId object_id, int32_t max_count, |
| 200 | std::vector<JDWP::ObjectId>& referring_objects) |
| 201 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 64f574f | 2013-02-20 14:57:12 -0800 | [diff] [blame] | 202 | static JDWP::JdwpError DisableCollection(JDWP::ObjectId object_id) |
| 203 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 204 | static JDWP::JdwpError EnableCollection(JDWP::ObjectId object_id) |
| 205 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 206 | static JDWP::JdwpError IsCollected(JDWP::ObjectId object_id, bool& is_collected) |
| 207 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 208 | static void DisposeObject(JDWP::ObjectId object_id, uint32_t reference_count) |
| 209 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | ec0f83d | 2013-01-15 16:54:08 -0800 | [diff] [blame] | 210 | |
Elliott Hughes | 9777ba2 | 2013-01-17 09:04:19 -0800 | [diff] [blame] | 211 | // |
| 212 | // Methods and fields. |
| 213 | // |
Elliott Hughes | a96836a | 2013-01-17 12:27:49 -0800 | [diff] [blame] | 214 | static std::string GetMethodName(JDWP::MethodId method_id) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 215 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 88d6309 | 2013-01-09 09:55:54 -0800 | [diff] [blame] | 216 | static JDWP::JdwpError OutputDeclaredFields(JDWP::RefTypeId ref_type_id, bool with_generic, |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 217 | JDWP::ExpandBuf* pReply) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 218 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 88d6309 | 2013-01-09 09:55:54 -0800 | [diff] [blame] | 219 | static JDWP::JdwpError OutputDeclaredMethods(JDWP::RefTypeId ref_type_id, bool with_generic, |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 220 | JDWP::ExpandBuf* pReply) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 221 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 88d6309 | 2013-01-09 09:55:54 -0800 | [diff] [blame] | 222 | static JDWP::JdwpError OutputDeclaredInterfaces(JDWP::RefTypeId ref_type_id, |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 223 | JDWP::ExpandBuf* pReply) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 224 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 88d6309 | 2013-01-09 09:55:54 -0800 | [diff] [blame] | 225 | static void OutputLineTable(JDWP::RefTypeId ref_type_id, JDWP::MethodId method_id, |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 226 | JDWP::ExpandBuf* pReply) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 227 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 88d6309 | 2013-01-09 09:55:54 -0800 | [diff] [blame] | 228 | 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] | 229 | JDWP::ExpandBuf* pReply) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 230 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 9777ba2 | 2013-01-17 09:04:19 -0800 | [diff] [blame] | 231 | static JDWP::JdwpError GetBytecodes(JDWP::RefTypeId class_id, JDWP::MethodId method_id, |
| 232 | std::vector<uint8_t>& bytecodes) |
| 233 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 234 | |
Elliott Hughes | a96836a | 2013-01-17 12:27:49 -0800 | [diff] [blame] | 235 | static std::string GetFieldName(JDWP::FieldId field_id) |
| 236 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 88d6309 | 2013-01-09 09:55:54 -0800 | [diff] [blame] | 237 | static JDWP::JdwpTag GetFieldBasicTag(JDWP::FieldId field_id) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 238 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 88d6309 | 2013-01-09 09:55:54 -0800 | [diff] [blame] | 239 | static JDWP::JdwpTag GetStaticFieldBasicTag(JDWP::FieldId field_id) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 240 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);; |
Elliott Hughes | 88d6309 | 2013-01-09 09:55:54 -0800 | [diff] [blame] | 241 | static JDWP::JdwpError GetFieldValue(JDWP::ObjectId object_id, JDWP::FieldId field_id, |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 242 | JDWP::ExpandBuf* pReply) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 243 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 88d6309 | 2013-01-09 09:55:54 -0800 | [diff] [blame] | 244 | static JDWP::JdwpError SetFieldValue(JDWP::ObjectId object_id, JDWP::FieldId field_id, |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 245 | uint64_t value, int width) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 246 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 88d6309 | 2013-01-09 09:55:54 -0800 | [diff] [blame] | 247 | 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] | 248 | JDWP::ExpandBuf* pReply) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 249 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 88d6309 | 2013-01-09 09:55:54 -0800 | [diff] [blame] | 250 | 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] | 251 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 252 | |
Elliott Hughes | 88d6309 | 2013-01-09 09:55:54 -0800 | [diff] [blame] | 253 | static std::string StringToUtf8(JDWP::ObjectId string_id) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 254 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 255 | |
| 256 | /* |
| 257 | * Thread, ThreadGroup, Frame |
| 258 | */ |
Elliott Hughes | 88d6309 | 2013-01-09 09:55:54 -0800 | [diff] [blame] | 259 | static JDWP::JdwpError GetThreadName(JDWP::ObjectId thread_id, std::string& name) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 260 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) |
| 261 | LOCKS_EXCLUDED(Locks::thread_list_lock_); |
Elliott Hughes | 88d6309 | 2013-01-09 09:55:54 -0800 | [diff] [blame] | 262 | static JDWP::JdwpError GetThreadGroup(JDWP::ObjectId thread_id, JDWP::ExpandBuf* pReply); |
| 263 | static std::string GetThreadGroupName(JDWP::ObjectId thread_group_id); |
| 264 | static JDWP::ObjectId GetThreadGroupParent(JDWP::ObjectId thread_group_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::ObjectId GetSystemThreadGroupId() |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 267 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 268 | static JDWP::ObjectId GetMainThreadGroupId(); |
| 269 | |
Elliott Hughes | 88d6309 | 2013-01-09 09:55:54 -0800 | [diff] [blame] | 270 | static JDWP::JdwpError GetThreadStatus(JDWP::ObjectId thread_id, JDWP::JdwpThreadStatus* pThreadStatus, JDWP::JdwpSuspendStatus* pSuspendStatus); |
| 271 | static JDWP::JdwpError GetThreadDebugSuspendCount(JDWP::ObjectId thread_id, JDWP::ExpandBuf* pReply); |
Elliott Hughes | 88d6309 | 2013-01-09 09:55:54 -0800 | [diff] [blame] | 272 | //static void WaitForSuspend(JDWP::ObjectId thread_id); |
Elliott Hughes | caf7654 | 2012-06-28 16:08:22 -0700 | [diff] [blame] | 273 | |
Elliott Hughes | 026b146 | 2012-06-28 20:43:49 -0700 | [diff] [blame] | 274 | // 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] | 275 | // returns all threads. |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 276 | static void GetThreads(JDWP::ObjectId thread_group_id, std::vector<JDWP::ObjectId>& thread_ids) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 277 | LOCKS_EXCLUDED(Locks::thread_list_lock_) |
| 278 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | caf7654 | 2012-06-28 16:08:22 -0700 | [diff] [blame] | 279 | static void GetChildThreadGroups(JDWP::ObjectId thread_group_id, std::vector<JDWP::ObjectId>& child_thread_group_ids); |
| 280 | |
Elliott Hughes | 88d6309 | 2013-01-09 09:55:54 -0800 | [diff] [blame] | 281 | static JDWP::JdwpError GetThreadFrameCount(JDWP::ObjectId thread_id, size_t& result); |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 282 | static JDWP::JdwpError GetThreadFrames(JDWP::ObjectId thread_id, size_t start_frame, |
| 283 | size_t frame_count, JDWP::ExpandBuf* buf) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 284 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 285 | |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 286 | static JDWP::ObjectId GetThreadSelfId() |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 287 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 288 | static void SuspendVM() |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 289 | LOCKS_EXCLUDED(Locks::thread_list_lock_, |
| 290 | Locks::thread_suspend_count_lock_); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 291 | static void ResumeVM(); |
Elliott Hughes | 88d6309 | 2013-01-09 09:55:54 -0800 | [diff] [blame] | 292 | static JDWP::JdwpError SuspendThread(JDWP::ObjectId thread_id, bool request_suspension = true) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 293 | LOCKS_EXCLUDED(Locks::mutator_lock_, |
| 294 | Locks::thread_list_lock_, |
| 295 | Locks::thread_suspend_count_lock_); |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 296 | |
Elliott Hughes | 88d6309 | 2013-01-09 09:55:54 -0800 | [diff] [blame] | 297 | static void ResumeThread(JDWP::ObjectId thread_id) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 298 | LOCKS_EXCLUDED(Locks::thread_list_lock_, |
| 299 | Locks::thread_suspend_count_lock_) |
| 300 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 301 | static void SuspendSelf(); |
| 302 | |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 303 | static JDWP::JdwpError GetThisObject(JDWP::ObjectId thread_id, JDWP::FrameId frame_id, |
| 304 | JDWP::ObjectId* result) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 305 | LOCKS_EXCLUDED(Locks::thread_list_lock_, |
| 306 | Locks::thread_suspend_count_lock_) |
| 307 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 88d6309 | 2013-01-09 09:55:54 -0800 | [diff] [blame] | 308 | static void GetLocalValue(JDWP::ObjectId thread_id, JDWP::FrameId frame_id, int slot, |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 309 | JDWP::JdwpTag tag, uint8_t* buf, size_t expectedLen) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 310 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 88d6309 | 2013-01-09 09:55:54 -0800 | [diff] [blame] | 311 | static void SetLocalValue(JDWP::ObjectId thread_id, JDWP::FrameId frame_id, int slot, |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 312 | JDWP::JdwpTag tag, uint64_t value, size_t width) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 313 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 314 | |
Elliott Hughes | f950170 | 2013-01-11 11:22:27 -0800 | [diff] [blame] | 315 | static JDWP::JdwpError Interrupt(JDWP::ObjectId thread_id); |
| 316 | |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 317 | /* |
| 318 | * Debugger notification |
| 319 | */ |
| 320 | enum { |
Elliott Hughes | 8696433 | 2012-02-15 19:37:42 -0800 | [diff] [blame] | 321 | kBreakpoint = 0x01, |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 322 | kSingleStep = 0x02, |
| 323 | kMethodEntry = 0x04, |
| 324 | kMethodExit = 0x08, |
| 325 | }; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 326 | static void PostLocationEvent(const mirror::AbstractMethod* method, int pcOffset, |
| 327 | mirror::Object* thisPtr, int eventFlags) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 328 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 329 | static void PostException(Thread* thread, JDWP::FrameId throw_frame_id, |
| 330 | mirror::AbstractMethod* throw_method, |
| 331 | uint32_t throw_dex_pc, mirror::AbstractMethod* catch_method, |
| 332 | uint32_t catch_dex_pc, mirror::Throwable* exception) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 333 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 334 | static void PostThreadStart(Thread* t) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 335 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 336 | static void PostThreadDeath(Thread* t) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 337 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 338 | static void PostClassPrepare(mirror::Class* c) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 339 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 340 | |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 341 | static void UpdateDebugger(int32_t dex_pc, Thread* self) |
jeffhao | 09bfc6a | 2012-12-11 18:11:43 -0800 | [diff] [blame] | 342 | LOCKS_EXCLUDED(Locks::breakpoint_lock_) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 343 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 91bf6cd | 2012-02-14 17:27:48 -0800 | [diff] [blame] | 344 | |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 345 | static void WatchLocation(const JDWP::JdwpLocation* pLoc) |
jeffhao | 09bfc6a | 2012-12-11 18:11:43 -0800 | [diff] [blame] | 346 | LOCKS_EXCLUDED(Locks::breakpoint_lock_) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 347 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 348 | static void UnwatchLocation(const JDWP::JdwpLocation* pLoc) |
jeffhao | 09bfc6a | 2012-12-11 18:11:43 -0800 | [diff] [blame] | 349 | LOCKS_EXCLUDED(Locks::breakpoint_lock_) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 350 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 88d6309 | 2013-01-09 09:55:54 -0800 | [diff] [blame] | 351 | static JDWP::JdwpError ConfigureStep(JDWP::ObjectId thread_id, JDWP::JdwpStepSize size, |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 352 | JDWP::JdwpStepDepth depth) |
jeffhao | 09bfc6a | 2012-12-11 18:11:43 -0800 | [diff] [blame] | 353 | LOCKS_EXCLUDED(Locks::breakpoint_lock_) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 354 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 88d6309 | 2013-01-09 09:55:54 -0800 | [diff] [blame] | 355 | static void UnconfigureStep(JDWP::ObjectId thread_id) LOCKS_EXCLUDED(Locks::breakpoint_lock_); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 356 | |
Elliott Hughes | 88d6309 | 2013-01-09 09:55:54 -0800 | [diff] [blame] | 357 | static JDWP::JdwpError InvokeMethod(JDWP::ObjectId thread_id, JDWP::ObjectId object_id, |
| 358 | JDWP::RefTypeId class_id, JDWP::MethodId method_id, |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 359 | uint32_t arg_count, uint64_t* arg_values, |
| 360 | JDWP::JdwpTag* arg_types, uint32_t options, |
| 361 | JDWP::JdwpTag* pResultTag, uint64_t* pResultValue, |
| 362 | JDWP::ObjectId* pExceptObj) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 363 | LOCKS_EXCLUDED(Locks::thread_list_lock_, |
| 364 | Locks::thread_suspend_count_lock_) |
| 365 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 366 | static void ExecuteMethod(DebugInvokeReq* pReq); |
| 367 | |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 368 | /* |
| 369 | * DDM support. |
| 370 | */ |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 371 | static void DdmSendThreadNotification(Thread* t, uint32_t type) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 372 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 47fce01 | 2011-10-25 18:37:19 -0700 | [diff] [blame] | 373 | static void DdmSetThreadNotification(bool enable); |
Elliott Hughes | 4b9702c | 2013-02-20 18:13:24 -0800 | [diff] [blame^] | 374 | static bool DdmHandlePacket(JDWP::Request& request, uint8_t** pReplyBuf, int* pReplyLen); |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 375 | static void DdmConnected() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 376 | static void DdmDisconnected() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 377 | static void DdmSendChunk(uint32_t type, const std::vector<uint8_t>& bytes) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 378 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 379 | 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] | 380 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 381 | static void DdmSendChunkV(uint32_t type, const iovec* iov, int iov_count) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 382 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 767a147 | 2011-10-26 18:49:02 -0700 | [diff] [blame] | 383 | |
Elliott Hughes | 545a064 | 2011-11-08 19:10:03 -0800 | [diff] [blame] | 384 | /* |
| 385 | * Recent allocation tracking support. |
| 386 | */ |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 387 | static void RecordAllocation(mirror::Class* type, size_t byte_count) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 388 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 545a064 | 2011-11-08 19:10:03 -0800 | [diff] [blame] | 389 | static void SetAllocTrackingEnabled(bool enabled); |
| 390 | static inline bool IsAllocTrackingEnabled() { return recent_allocation_records_ != NULL; } |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 391 | static jbyteArray GetRecentAllocations() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 545a064 | 2011-11-08 19:10:03 -0800 | [diff] [blame] | 392 | static void DumpRecentAllocations(); |
| 393 | |
Elliott Hughes | 767a147 | 2011-10-26 18:49:02 -0700 | [diff] [blame] | 394 | enum HpifWhen { |
| 395 | HPIF_WHEN_NEVER = 0, |
| 396 | HPIF_WHEN_NOW = 1, |
| 397 | HPIF_WHEN_NEXT_GC = 2, |
| 398 | HPIF_WHEN_EVERY_GC = 3 |
| 399 | }; |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 400 | static int DdmHandleHpifChunk(HpifWhen when) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 401 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 767a147 | 2011-10-26 18:49:02 -0700 | [diff] [blame] | 402 | |
| 403 | enum HpsgWhen { |
| 404 | HPSG_WHEN_NEVER = 0, |
| 405 | HPSG_WHEN_EVERY_GC = 1, |
| 406 | }; |
| 407 | enum HpsgWhat { |
| 408 | HPSG_WHAT_MERGED_OBJECTS = 0, |
| 409 | HPSG_WHAT_DISTINCT_OBJECTS = 1, |
| 410 | }; |
| 411 | static bool DdmHandleHpsgNhsgChunk(HpsgWhen when, HpsgWhat what, bool native); |
| 412 | |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 413 | static void DdmSendHeapInfo(HpifWhen reason) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 414 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 415 | static void DdmSendHeapSegments(bool native) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 416 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 545a064 | 2011-11-08 19:10:03 -0800 | [diff] [blame] | 417 | |
| 418 | private: |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 419 | static void DdmBroadcast(bool) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 420 | static void PostThreadStartOrStop(Thread*, uint32_t) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 421 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | a215526 | 2011-11-16 16:26:58 -0800 | [diff] [blame] | 422 | |
Elliott Hughes | 545a064 | 2011-11-08 19:10:03 -0800 | [diff] [blame] | 423 | static AllocRecord* recent_allocation_records_; |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 424 | }; |
| 425 | |
| 426 | #define CHUNK_TYPE(_name) \ |
Elliott Hughes | 8218847 | 2011-11-07 18:11:48 -0800 | [diff] [blame] | 427 | 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] | 428 | |
| 429 | } // namespace art |
| 430 | |
| 431 | #endif // ART_DEBUGGER_H_ |