blob: c1c1dd442979a9953eb6771e8b3d10c045de4fd8 [file] [log] [blame]
Elliott Hughes872d4ec2011-10-21 17:07:15 -07001/*
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 Carlstromfc0e3212013-07-17 14:40:12 -070021#ifndef ART_RUNTIME_DEBUGGER_H_
22#define ART_RUNTIME_DEBUGGER_H_
Elliott Hughes872d4ec2011-10-21 17:07:15 -070023
24#include <pthread.h>
25
Sebastien Hertz61b7f1b2013-11-15 15:59:30 +010026#include <set>
Elliott Hughes3bb81562011-10-21 18:52:59 -070027#include <string>
Sebastien Hertz4d25df32014-03-21 17:44:46 +010028#include <vector>
Elliott Hughes3bb81562011-10-21 18:52:59 -070029
Elliott Hughes872d4ec2011-10-21 17:07:15 -070030#include "jdwp/jdwp.h"
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080031#include "jni.h"
32#include "jvalue.h"
Mathieu Chartier83c8ee02014-01-28 14:50:23 -080033#include "object_callbacks.h"
Jeff Hao920af3e2013-08-28 15:46:38 -070034#include "thread_state.h"
Elliott Hughes872d4ec2011-10-21 17:07:15 -070035
36namespace art {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080037namespace mirror {
Brian Carlstromea46f952013-07-30 01:26:50 -070038class ArtMethod;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080039class Class;
40class Object;
41class Throwable;
42} // namespace mirror
Elliott Hughes545a0642011-11-08 19:10:03 -080043struct AllocRecord;
Ian Rogers1b09b092012-08-20 15:35:52 -070044class Thread;
Ian Rogers62d6c772013-02-27 08:32:07 -080045class ThrowLocation;
Elliott Hughes872d4ec2011-10-21 17:07:15 -070046
47/*
48 * Invoke-during-breakpoint support.
49 */
50struct DebugInvokeReq {
Elliott Hughes7b3cdfc2011-12-08 21:28:17 -080051 DebugInvokeReq()
Sebastien Hertzd38667a2013-11-25 15:43:54 +010052 : ready(false), invoke_needed(false),
53 receiver(NULL), thread(NULL), klass(NULL), method(NULL),
54 arg_count(0), arg_values(NULL), options(0), error(JDWP::ERR_NONE),
Ian Rogers00f7d0e2012-07-19 15:28:27 -070055 result_tag(JDWP::JT_VOID), exception(0),
Sebastien Hertzd38667a2013-11-25 15:43:54 +010056 lock("a DebugInvokeReq lock", kBreakpointInvokeLock),
57 cond("a DebugInvokeReq condition variable", lock) {
Elliott Hughes475fc232011-10-25 15:00:35 -070058 }
59
Elliott Hughes872d4ec2011-10-21 17:07:15 -070060 /* boolean; only set when we're in the tail end of an event handler */
61 bool ready;
62
63 /* boolean; set if the JDWP thread wants this thread to do work */
Sebastien Hertzd38667a2013-11-25 15:43:54 +010064 bool invoke_needed;
Elliott Hughes872d4ec2011-10-21 17:07:15 -070065
66 /* request */
Sebastien Hertzd38667a2013-11-25 15:43:54 +010067 mirror::Object* receiver; /* not used for ClassType.InvokeMethod */
68 mirror::Object* thread;
69 mirror::Class* klass;
70 mirror::ArtMethod* method;
71 uint32_t arg_count;
72 uint64_t* arg_values; /* will be NULL if arg_count_ == 0 */
73 uint32_t options;
Elliott Hughes872d4ec2011-10-21 17:07:15 -070074
75 /* result */
Elliott Hughes475fc232011-10-25 15:00:35 -070076 JDWP::JdwpError error;
Elliott Hughesd07986f2011-12-06 18:27:45 -080077 JDWP::JdwpTag result_tag;
Elliott Hughes475fc232011-10-25 15:00:35 -070078 JValue result_value;
79 JDWP::ObjectId exception;
Elliott Hughes872d4ec2011-10-21 17:07:15 -070080
81 /* condition variable to wait on while the method executes */
Sebastien Hertzd38667a2013-11-25 15:43:54 +010082 Mutex lock DEFAULT_MUTEX_ACQUIRED_AFTER;
83 ConditionVariable cond GUARDED_BY(lock);
Sebastien Hertz61b7f1b2013-11-15 15:59:30 +010084
Mathieu Chartier3b05e9b2014-03-25 09:29:43 -070085 void VisitRoots(RootCallback* callback, void* arg, uint32_t tid, RootType root_type)
86 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
87
Sebastien Hertzbb43b432014-04-14 11:59:08 +020088 void Clear();
89
Sebastien Hertz61b7f1b2013-11-15 15:59:30 +010090 private:
91 DISALLOW_COPY_AND_ASSIGN(DebugInvokeReq);
92};
93
94// Thread local data-structure that holds fields for controlling single-stepping.
95struct SingleStepControl {
96 SingleStepControl()
97 : is_active(false), step_size(JDWP::SS_MIN), step_depth(JDWP::SD_INTO),
98 method(nullptr), stack_depth(0) {
99 }
100
101 // Are we single-stepping right now?
102 bool is_active;
103
104 // See JdwpStepSize and JdwpStepDepth for details.
105 JDWP::JdwpStepSize step_size;
106 JDWP::JdwpStepDepth step_depth;
107
108 // The location this single-step was initiated from.
109 // A single-step is initiated in a suspended thread. We save here the current method and the
110 // set of DEX pcs associated to the source line number where the suspension occurred.
111 // This is used to support SD_INTO and SD_OVER single-step depths so we detect when a single-step
112 // causes the execution of an instruction in a different method or at a different line number.
113 mirror::ArtMethod* method;
114 std::set<uint32_t> dex_pcs;
115
116 // The stack depth when this single-step was initiated. This is used to support SD_OVER and SD_OUT
117 // single-step depth.
118 int stack_depth;
119
Mathieu Chartier3b05e9b2014-03-25 09:29:43 -0700120 void VisitRoots(RootCallback* callback, void* arg, uint32_t tid, RootType root_type)
121 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
122
Sebastien Hertzbb43b432014-04-14 11:59:08 +0200123 bool ContainsDexPc(uint32_t dex_pc) const;
124
125 void Clear();
126
Sebastien Hertz61b7f1b2013-11-15 15:59:30 +0100127 private:
128 DISALLOW_COPY_AND_ASSIGN(SingleStepControl);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700129};
130
Sebastien Hertz4d25df32014-03-21 17:44:46 +0100131struct DeoptimizationRequest {
132 enum Kind {
133 kNothing, // no action.
134 kFullDeoptimization, // deoptimize everything.
135 kFullUndeoptimization, // undeoptimize everything.
136 kSelectiveDeoptimization, // deoptimize one method.
137 kSelectiveUndeoptimization // undeoptimize one method.
138 };
139
140 DeoptimizationRequest() : kind(kNothing), method(nullptr) {}
141
142 void VisitRoots(RootCallback* callback, void* arg);
143
144 Kind kind;
145
146 // Method for selective deoptimization.
147 mirror::ArtMethod* method;
148};
149
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700150class Dbg {
Elliott Hughesff17f1f2012-01-24 18:12:29 -0800151 public:
Elliott Hughes3bb81562011-10-21 18:52:59 -0700152 static bool ParseJdwpOptions(const std::string& options);
Elliott Hughes4ffd3132011-10-24 12:06:42 -0700153 static void SetJdwpAllowed(bool allowed);
154
Elliott Hughesd1cc8362011-10-24 16:58:50 -0700155 static void StartJdwp();
156 static void StopJdwp();
157
Elliott Hughes767a1472011-10-26 18:49:02 -0700158 // Invoked by the GC in case we need to keep DDMS informed.
Ian Rogersb726dcb2012-09-05 08:57:23 -0700159 static void GcDidFinish() LOCKS_EXCLUDED(Locks::mutator_lock_);
Elliott Hughes767a1472011-10-26 18:49:02 -0700160
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700161 // Return the DebugInvokeReq for the current thread.
162 static DebugInvokeReq* GetInvokeReq();
163
Elliott Hughes475fc232011-10-25 15:00:35 -0700164 static Thread* GetDebugThread();
165 static void ClearWaitForEventThread();
166
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700167 /*
168 * Enable/disable breakpoints and step modes. Used to provide a heads-up
169 * when the debugger attaches.
170 */
171 static void Connected();
Sebastien Hertz138dbfc2013-12-04 18:15:25 +0100172 static void GoActive()
Sebastien Hertz4d25df32014-03-21 17:44:46 +0100173 LOCKS_EXCLUDED(Locks::breakpoint_lock_, deoptimization_lock_, Locks::mutator_lock_);
174 static void Disconnected() LOCKS_EXCLUDED(deoptimization_lock_, Locks::mutator_lock_);
Elliott Hughes86964332012-02-15 19:37:42 -0800175 static void Disposed();
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700176
Elliott Hughesc0f09332012-03-26 13:27:06 -0700177 // Returns true if we're actually debugging with a real debugger, false if it's
178 // just DDMS (or nothing at all).
179 static bool IsDebuggerActive();
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700180
Elliott Hughesc0f09332012-03-26 13:27:06 -0700181 // Returns true if we had -Xrunjdwp or -agentlib:jdwp= on the command line.
182 static bool IsJdwpConfigured();
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700183
Elliott Hughes86964332012-02-15 19:37:42 -0800184 static bool IsDisposed();
185
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700186 /*
187 * Time, in milliseconds, since the last debugger activity. Does not
188 * include DDMS activity. Returns -1 if there has been no activity.
189 * Returns 0 if we're in the middle of handling a debugger request.
190 */
191 static int64_t LastDebuggerActivity();
192
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700193 static void UndoDebuggerSuspensions();
194
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700195 /*
196 * Class, Object, Array
197 */
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700198 static std::string GetClassName(JDWP::RefTypeId id)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700199 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800200 static JDWP::JdwpError GetClassObject(JDWP::RefTypeId id, JDWP::ObjectId& class_object_id)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700201 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800202 static JDWP::JdwpError GetSuperclass(JDWP::RefTypeId id, JDWP::RefTypeId& superclass_id)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700203 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700204 static JDWP::JdwpError GetClassLoader(JDWP::RefTypeId id, JDWP::ExpandBuf* pReply)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700205 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700206 static JDWP::JdwpError GetModifiers(JDWP::RefTypeId id, JDWP::ExpandBuf* pReply)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700207 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800208 static JDWP::JdwpError GetReflectedType(JDWP::RefTypeId class_id, JDWP::ExpandBuf* pReply)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700209 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700210 static void GetClassList(std::vector<JDWP::RefTypeId>& classes)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700211 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800212 static JDWP::JdwpError GetClassInfo(JDWP::RefTypeId class_id, JDWP::JdwpTypeTag* pTypeTag,
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700213 uint32_t* pStatus, std::string* pDescriptor)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700214 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700215 static void FindLoadedClassBySignature(const char* descriptor, std::vector<JDWP::RefTypeId>& ids)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700216 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughes64f574f2013-02-20 14:57:12 -0800217 static JDWP::JdwpError GetReferenceType(JDWP::ObjectId object_id, JDWP::ExpandBuf* pReply)
218 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogersfc0e94b2013-09-23 23:51:32 -0700219 static JDWP::JdwpError GetSignature(JDWP::RefTypeId ref_type_id, std::string* signature)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700220 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800221 static JDWP::JdwpError GetSourceFile(JDWP::RefTypeId ref_type_id, std::string& source_file)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700222 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800223 static JDWP::JdwpError GetObjectTag(JDWP::ObjectId object_id, uint8_t& tag)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700224 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughesaed4be92011-12-02 16:16:23 -0800225 static size_t GetTagWidth(JDWP::JdwpTag tag);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700226
Elliott Hughes88d63092013-01-09 09:55:54 -0800227 static JDWP::JdwpError GetArrayLength(JDWP::ObjectId array_id, int& length)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700228 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800229 static JDWP::JdwpError OutputArray(JDWP::ObjectId array_id, int offset, int count,
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700230 JDWP::ExpandBuf* pReply)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700231 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800232 static JDWP::JdwpError SetArrayElements(JDWP::ObjectId array_id, int offset, int count,
Elliott Hughes4b9702c2013-02-20 18:13:24 -0800233 JDWP::Request& request)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700234 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700235
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700236 static JDWP::ObjectId CreateString(const std::string& str)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700237 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800238 static JDWP::JdwpError CreateObject(JDWP::RefTypeId class_id, JDWP::ObjectId& new_object)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700239 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800240 static JDWP::JdwpError CreateArrayObject(JDWP::RefTypeId array_class_id, uint32_t length,
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700241 JDWP::ObjectId& new_array)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700242 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700243
Elliott Hughes88d63092013-01-09 09:55:54 -0800244 static bool MatchType(JDWP::RefTypeId instance_class_id, JDWP::RefTypeId class_id)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700245 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700246
Elliott Hughesec0f83d2013-01-15 16:54:08 -0800247 //
248 // Monitors.
249 //
250 static JDWP::JdwpError GetMonitorInfo(JDWP::ObjectId object_id, JDWP::ExpandBuf* reply)
251 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
252 static JDWP::JdwpError GetOwnedMonitors(JDWP::ObjectId thread_id,
253 std::vector<JDWP::ObjectId>& monitors,
254 std::vector<uint32_t>& stack_depths)
Sebastien Hertz52d131d2014-03-13 16:17:40 +0100255 LOCKS_EXCLUDED(Locks::thread_list_lock_)
Elliott Hughesec0f83d2013-01-15 16:54:08 -0800256 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Sebastien Hertz52d131d2014-03-13 16:17:40 +0100257 static JDWP::JdwpError GetContendedMonitor(JDWP::ObjectId thread_id,
258 JDWP::ObjectId& contended_monitor)
259 LOCKS_EXCLUDED(Locks::thread_list_lock_)
Elliott Hughesec0f83d2013-01-15 16:54:08 -0800260 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
261
262 //
263 // Heap.
264 //
265 static JDWP::JdwpError GetInstanceCounts(const std::vector<JDWP::RefTypeId>& class_ids,
266 std::vector<uint64_t>& counts)
267 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughes3b78c942013-01-15 17:35:41 -0800268 static JDWP::JdwpError GetInstances(JDWP::RefTypeId class_id, int32_t max_count,
269 std::vector<JDWP::ObjectId>& instances)
270 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughes0cbaff52013-01-16 15:28:01 -0800271 static JDWP::JdwpError GetReferringObjects(JDWP::ObjectId object_id, int32_t max_count,
272 std::vector<JDWP::ObjectId>& referring_objects)
273 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughes64f574f2013-02-20 14:57:12 -0800274 static JDWP::JdwpError DisableCollection(JDWP::ObjectId object_id)
275 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
276 static JDWP::JdwpError EnableCollection(JDWP::ObjectId object_id)
277 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
278 static JDWP::JdwpError IsCollected(JDWP::ObjectId object_id, bool& is_collected)
279 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
280 static void DisposeObject(JDWP::ObjectId object_id, uint32_t reference_count)
281 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughesec0f83d2013-01-15 16:54:08 -0800282
Elliott Hughes9777ba22013-01-17 09:04:19 -0800283 //
284 // Methods and fields.
285 //
Elliott Hughesa96836a2013-01-17 12:27:49 -0800286 static std::string GetMethodName(JDWP::MethodId method_id)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700287 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800288 static JDWP::JdwpError OutputDeclaredFields(JDWP::RefTypeId ref_type_id, bool with_generic,
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700289 JDWP::ExpandBuf* pReply)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700290 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800291 static JDWP::JdwpError OutputDeclaredMethods(JDWP::RefTypeId ref_type_id, bool with_generic,
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700292 JDWP::ExpandBuf* pReply)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700293 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800294 static JDWP::JdwpError OutputDeclaredInterfaces(JDWP::RefTypeId ref_type_id,
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700295 JDWP::ExpandBuf* pReply)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700296 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800297 static void OutputLineTable(JDWP::RefTypeId ref_type_id, JDWP::MethodId method_id,
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700298 JDWP::ExpandBuf* pReply)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700299 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800300 static void OutputVariableTable(JDWP::RefTypeId ref_type_id, JDWP::MethodId id, bool with_generic,
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700301 JDWP::ExpandBuf* pReply)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700302 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Jeff Hao579b0242013-11-18 13:16:49 -0800303 static void OutputMethodReturnValue(JDWP::MethodId method_id, const JValue* return_value,
304 JDWP::ExpandBuf* pReply)
305 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughes9777ba22013-01-17 09:04:19 -0800306 static JDWP::JdwpError GetBytecodes(JDWP::RefTypeId class_id, JDWP::MethodId method_id,
307 std::vector<uint8_t>& bytecodes)
308 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700309
Elliott Hughesa96836a2013-01-17 12:27:49 -0800310 static std::string GetFieldName(JDWP::FieldId field_id)
311 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800312 static JDWP::JdwpTag GetFieldBasicTag(JDWP::FieldId field_id)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700313 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800314 static JDWP::JdwpTag GetStaticFieldBasicTag(JDWP::FieldId field_id)
Brian Carlstromf69863b2013-07-17 21:53:13 -0700315 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800316 static JDWP::JdwpError GetFieldValue(JDWP::ObjectId object_id, JDWP::FieldId field_id,
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700317 JDWP::ExpandBuf* pReply)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700318 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800319 static JDWP::JdwpError SetFieldValue(JDWP::ObjectId object_id, JDWP::FieldId field_id,
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700320 uint64_t value, int width)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700321 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800322 static JDWP::JdwpError GetStaticFieldValue(JDWP::RefTypeId ref_type_id, JDWP::FieldId field_id,
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700323 JDWP::ExpandBuf* pReply)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700324 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800325 static JDWP::JdwpError SetStaticFieldValue(JDWP::FieldId field_id, uint64_t value, int width)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700326 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700327
Elliott Hughes88d63092013-01-09 09:55:54 -0800328 static std::string StringToUtf8(JDWP::ObjectId string_id)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700329 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Jeff Hao579b0242013-11-18 13:16:49 -0800330 static void OutputJValue(JDWP::JdwpTag tag, const JValue* return_value, JDWP::ExpandBuf* pReply)
331 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700332
333 /*
334 * Thread, ThreadGroup, Frame
335 */
Elliott Hughes88d63092013-01-09 09:55:54 -0800336 static JDWP::JdwpError GetThreadName(JDWP::ObjectId thread_id, std::string& name)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700337 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
338 LOCKS_EXCLUDED(Locks::thread_list_lock_);
Sebastien Hertz52d131d2014-03-13 16:17:40 +0100339 static JDWP::JdwpError GetThreadGroup(JDWP::ObjectId thread_id, JDWP::ExpandBuf* pReply)
340 LOCKS_EXCLUDED(Locks::thread_list_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800341 static std::string GetThreadGroupName(JDWP::ObjectId thread_group_id);
342 static JDWP::ObjectId GetThreadGroupParent(JDWP::ObjectId thread_group_id)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700343 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700344 static JDWP::ObjectId GetSystemThreadGroupId()
Ian Rogersb726dcb2012-09-05 08:57:23 -0700345 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700346 static JDWP::ObjectId GetMainThreadGroupId();
347
Jeff Hao920af3e2013-08-28 15:46:38 -0700348 static JDWP::JdwpThreadStatus ToJdwpThreadStatus(ThreadState state);
Sebastien Hertz52d131d2014-03-13 16:17:40 +0100349 static JDWP::JdwpError GetThreadStatus(JDWP::ObjectId thread_id,
350 JDWP::JdwpThreadStatus* pThreadStatus,
351 JDWP::JdwpSuspendStatus* pSuspendStatus)
352 LOCKS_EXCLUDED(Locks::thread_list_lock_);
353 static JDWP::JdwpError GetThreadDebugSuspendCount(JDWP::ObjectId thread_id,
354 JDWP::ExpandBuf* pReply)
355 LOCKS_EXCLUDED(Locks::thread_list_lock_,
356 Locks::thread_suspend_count_lock_);
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700357 // static void WaitForSuspend(JDWP::ObjectId thread_id);
Elliott Hughescaf76542012-06-28 16:08:22 -0700358
Elliott Hughes026b1462012-06-28 20:43:49 -0700359 // Fills 'thread_ids' with the threads in the given thread group. If thread_group_id == 0,
Elliott Hughescaf76542012-06-28 16:08:22 -0700360 // returns all threads.
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700361 static void GetThreads(JDWP::ObjectId thread_group_id, std::vector<JDWP::ObjectId>& thread_ids)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700362 LOCKS_EXCLUDED(Locks::thread_list_lock_)
363 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughescaf76542012-06-28 16:08:22 -0700364 static void GetChildThreadGroups(JDWP::ObjectId thread_group_id, std::vector<JDWP::ObjectId>& child_thread_group_ids);
365
Sebastien Hertz52d131d2014-03-13 16:17:40 +0100366 static JDWP::JdwpError GetThreadFrameCount(JDWP::ObjectId thread_id, size_t& result)
367 LOCKS_EXCLUDED(Locks::thread_list_lock_);
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700368 static JDWP::JdwpError GetThreadFrames(JDWP::ObjectId thread_id, size_t start_frame,
369 size_t frame_count, JDWP::ExpandBuf* buf)
Sebastien Hertz52d131d2014-03-13 16:17:40 +0100370 LOCKS_EXCLUDED(Locks::thread_list_lock_)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700371 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700372
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700373 static JDWP::ObjectId GetThreadSelfId()
Ian Rogersb726dcb2012-09-05 08:57:23 -0700374 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700375 static void SuspendVM()
Ian Rogersb726dcb2012-09-05 08:57:23 -0700376 LOCKS_EXCLUDED(Locks::thread_list_lock_,
377 Locks::thread_suspend_count_lock_);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700378 static void ResumeVM();
Elliott Hughes88d63092013-01-09 09:55:54 -0800379 static JDWP::JdwpError SuspendThread(JDWP::ObjectId thread_id, bool request_suspension = true)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700380 LOCKS_EXCLUDED(Locks::mutator_lock_,
381 Locks::thread_list_lock_,
382 Locks::thread_suspend_count_lock_);
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700383
Elliott Hughes88d63092013-01-09 09:55:54 -0800384 static void ResumeThread(JDWP::ObjectId thread_id)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700385 LOCKS_EXCLUDED(Locks::thread_list_lock_,
386 Locks::thread_suspend_count_lock_)
387 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700388 static void SuspendSelf();
389
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700390 static JDWP::JdwpError GetThisObject(JDWP::ObjectId thread_id, JDWP::FrameId frame_id,
391 JDWP::ObjectId* result)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700392 LOCKS_EXCLUDED(Locks::thread_list_lock_,
393 Locks::thread_suspend_count_lock_)
394 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Sebastien Hertzcb19ebf2014-03-11 15:26:35 +0100395 static JDWP::JdwpError GetLocalValue(JDWP::ObjectId thread_id, JDWP::FrameId frame_id, int slot,
396 JDWP::JdwpTag tag, uint8_t* buf, size_t expectedLen)
Sebastien Hertz52d131d2014-03-13 16:17:40 +0100397 LOCKS_EXCLUDED(Locks::thread_list_lock_)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700398 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Sebastien Hertzcb19ebf2014-03-11 15:26:35 +0100399 static JDWP::JdwpError SetLocalValue(JDWP::ObjectId thread_id, JDWP::FrameId frame_id, int slot,
400 JDWP::JdwpTag tag, uint64_t value, size_t width)
Sebastien Hertz52d131d2014-03-13 16:17:40 +0100401 LOCKS_EXCLUDED(Locks::thread_list_lock_)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700402 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700403
Sebastien Hertz52d131d2014-03-13 16:17:40 +0100404 static JDWP::JdwpError Interrupt(JDWP::ObjectId thread_id)
405 LOCKS_EXCLUDED(Locks::thread_list_lock_);
Elliott Hughesf9501702013-01-11 11:22:27 -0800406
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700407 /*
408 * Debugger notification
409 */
410 enum {
Elliott Hughes86964332012-02-15 19:37:42 -0800411 kBreakpoint = 0x01,
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700412 kSingleStep = 0x02,
413 kMethodEntry = 0x04,
414 kMethodExit = 0x08,
415 };
Ian Rogersef7d42f2014-01-06 12:55:46 -0800416 static void PostLocationEvent(mirror::ArtMethod* method, int pcOffset,
Jeff Hao579b0242013-11-18 13:16:49 -0800417 mirror::Object* thisPtr, int eventFlags,
418 const JValue* return_value)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700419 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers62d6c772013-02-27 08:32:07 -0800420 static void PostException(Thread* thread, const ThrowLocation& throw_location,
Brian Carlstromea46f952013-07-30 01:26:50 -0700421 mirror::ArtMethod* catch_method,
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800422 uint32_t catch_dex_pc, mirror::Throwable* exception)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700423 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700424 static void PostThreadStart(Thread* t)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700425 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700426 static void PostThreadDeath(Thread* t)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700427 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800428 static void PostClassPrepare(mirror::Class* c)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700429 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700430
Ian Rogers62d6c772013-02-27 08:32:07 -0800431 static void UpdateDebugger(Thread* thread, mirror::Object* this_object,
Ian Rogersef7d42f2014-01-06 12:55:46 -0800432 mirror::ArtMethod* method, uint32_t new_dex_pc)
jeffhao09bfc6a2012-12-11 18:11:43 -0800433 LOCKS_EXCLUDED(Locks::breakpoint_lock_)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700434 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughes91bf6cd2012-02-14 17:27:48 -0800435
Sebastien Hertz4d25df32014-03-21 17:44:46 +0100436 // Records deoptimization request in the queue.
437 static void RequestDeoptimization(const DeoptimizationRequest& req)
438 LOCKS_EXCLUDED(deoptimization_lock_)
Sebastien Hertz138dbfc2013-12-04 18:15:25 +0100439 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
440
Sebastien Hertz4d25df32014-03-21 17:44:46 +0100441 // Manage deoptimization after updating JDWP events list. Suspends all threads, processes each
442 // request and finally resumes all threads.
Sebastien Hertz138dbfc2013-12-04 18:15:25 +0100443 static void ManageDeoptimization()
Sebastien Hertz4d25df32014-03-21 17:44:46 +0100444 LOCKS_EXCLUDED(deoptimization_lock_)
Sebastien Hertz138dbfc2013-12-04 18:15:25 +0100445 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
446
447 // Breakpoints.
Sebastien Hertz4d25df32014-03-21 17:44:46 +0100448 static void WatchLocation(const JDWP::JdwpLocation* pLoc, DeoptimizationRequest* req)
449 LOCKS_EXCLUDED(Locks::breakpoint_lock_)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700450 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Sebastien Hertz4d25df32014-03-21 17:44:46 +0100451 static void UnwatchLocation(const JDWP::JdwpLocation* pLoc, DeoptimizationRequest* req)
452 LOCKS_EXCLUDED(Locks::breakpoint_lock_)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700453 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Sebastien Hertz138dbfc2013-12-04 18:15:25 +0100454
455 // Single-stepping.
Elliott Hughes88d63092013-01-09 09:55:54 -0800456 static JDWP::JdwpError ConfigureStep(JDWP::ObjectId thread_id, JDWP::JdwpStepSize size,
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700457 JDWP::JdwpStepDepth depth)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700458 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Sebastien Hertz61b7f1b2013-11-15 15:59:30 +0100459 static void UnconfigureStep(JDWP::ObjectId thread_id)
Sebastien Hertz52d131d2014-03-13 16:17:40 +0100460 LOCKS_EXCLUDED(Locks::thread_list_lock_)
Sebastien Hertz61b7f1b2013-11-15 15:59:30 +0100461 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700462
Elliott Hughes88d63092013-01-09 09:55:54 -0800463 static JDWP::JdwpError InvokeMethod(JDWP::ObjectId thread_id, JDWP::ObjectId object_id,
464 JDWP::RefTypeId class_id, JDWP::MethodId method_id,
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700465 uint32_t arg_count, uint64_t* arg_values,
466 JDWP::JdwpTag* arg_types, uint32_t options,
467 JDWP::JdwpTag* pResultTag, uint64_t* pResultValue,
468 JDWP::ObjectId* pExceptObj)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700469 LOCKS_EXCLUDED(Locks::thread_list_lock_,
470 Locks::thread_suspend_count_lock_)
471 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700472 static void ExecuteMethod(DebugInvokeReq* pReq);
473
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700474 /*
475 * DDM support.
476 */
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700477 static void DdmSendThreadNotification(Thread* t, uint32_t type)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700478 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Sebastien Hertz52d131d2014-03-13 16:17:40 +0100479 static void DdmSetThreadNotification(bool enable)
480 LOCKS_EXCLUDED(Locks::thread_list_lock_);
Elliott Hughes4b9702c2013-02-20 18:13:24 -0800481 static bool DdmHandlePacket(JDWP::Request& request, uint8_t** pReplyBuf, int* pReplyLen);
Ian Rogersb726dcb2012-09-05 08:57:23 -0700482 static void DdmConnected() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
483 static void DdmDisconnected() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700484 static void DdmSendChunk(uint32_t type, const std::vector<uint8_t>& bytes)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700485 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700486 static void DdmSendChunk(uint32_t type, size_t len, const uint8_t* buf)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700487 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700488 static void DdmSendChunkV(uint32_t type, const iovec* iov, int iov_count)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700489 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughes767a1472011-10-26 18:49:02 -0700490
Mathieu Chartier3b05e9b2014-03-25 09:29:43 -0700491 static void VisitRoots(RootCallback* callback, void* arg)
492 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
493
Elliott Hughes545a0642011-11-08 19:10:03 -0800494 /*
495 * Recent allocation tracking support.
496 */
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800497 static void RecordAllocation(mirror::Class* type, size_t byte_count)
Sebastien Hertz52d131d2014-03-13 16:17:40 +0100498 LOCKS_EXCLUDED(alloc_tracker_lock_)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700499 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Sebastien Hertz52d131d2014-03-13 16:17:40 +0100500 static void SetAllocTrackingEnabled(bool enabled) LOCKS_EXCLUDED(alloc_tracker_lock_);
Ian Rogers719d1a32014-03-06 12:13:39 -0800501 static bool IsAllocTrackingEnabled() {
502 return recent_allocation_records_ != nullptr;
503 }
Sebastien Hertz52d131d2014-03-13 16:17:40 +0100504 static jbyteArray GetRecentAllocations()
505 LOCKS_EXCLUDED(alloc_tracker_lock_)
506 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers719d1a32014-03-06 12:13:39 -0800507 static size_t HeadIndex() EXCLUSIVE_LOCKS_REQUIRED(alloc_tracker_lock_);
Sebastien Hertz52d131d2014-03-13 16:17:40 +0100508 static void DumpRecentAllocations() LOCKS_EXCLUDED(alloc_tracker_lock_);
Elliott Hughes545a0642011-11-08 19:10:03 -0800509
Mathieu Chartier412c7fc2014-02-07 12:18:39 -0800510 // Updates the stored direct object pointers (called from SweepSystemWeaks).
Mathieu Chartier83c8ee02014-01-28 14:50:23 -0800511 static void UpdateObjectPointers(IsMarkedCallback* callback, void* arg)
Sebastien Hertz52d131d2014-03-13 16:17:40 +0100512 LOCKS_EXCLUDED(alloc_tracker_lock_)
Mathieu Chartier412c7fc2014-02-07 12:18:39 -0800513 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
514
Elliott Hughes767a1472011-10-26 18:49:02 -0700515 enum HpifWhen {
516 HPIF_WHEN_NEVER = 0,
517 HPIF_WHEN_NOW = 1,
518 HPIF_WHEN_NEXT_GC = 2,
519 HPIF_WHEN_EVERY_GC = 3
520 };
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700521 static int DdmHandleHpifChunk(HpifWhen when)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700522 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughes767a1472011-10-26 18:49:02 -0700523
524 enum HpsgWhen {
525 HPSG_WHEN_NEVER = 0,
526 HPSG_WHEN_EVERY_GC = 1,
527 };
528 enum HpsgWhat {
529 HPSG_WHAT_MERGED_OBJECTS = 0,
530 HPSG_WHAT_DISTINCT_OBJECTS = 1,
531 };
532 static bool DdmHandleHpsgNhsgChunk(HpsgWhen when, HpsgWhat what, bool native);
533
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700534 static void DdmSendHeapInfo(HpifWhen reason)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700535 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700536 static void DdmSendHeapSegments(bool native)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700537 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughes545a0642011-11-08 19:10:03 -0800538
Mathieu Chartier412c7fc2014-02-07 12:18:39 -0800539 static void AllowNewObjectRegistryObjects() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
540 static void DisallowNewObjectRegistryObjects() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
541
Elliott Hughes545a0642011-11-08 19:10:03 -0800542 private:
Brian Carlstrom2d888622013-07-18 17:02:00 -0700543 static void DdmBroadcast(bool connect) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700544 static void PostThreadStartOrStop(Thread*, uint32_t)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700545 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughesa2155262011-11-16 16:26:58 -0800546
Sebastien Hertz4d25df32014-03-21 17:44:46 +0100547 static void ProcessDeoptimizationRequest(const DeoptimizationRequest& request)
548 EXCLUSIVE_LOCKS_REQUIRED(Locks::mutator_lock_);
549
Ian Rogers719d1a32014-03-06 12:13:39 -0800550 static Mutex* alloc_tracker_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER;
551
552 static AllocRecord* recent_allocation_records_ PT_GUARDED_BY(alloc_tracker_lock_);
553 static size_t alloc_record_max_ GUARDED_BY(alloc_tracker_lock_);
554 static size_t alloc_record_head_ GUARDED_BY(alloc_tracker_lock_);
555 static size_t alloc_record_count_ GUARDED_BY(alloc_tracker_lock_);
556
Sebastien Hertz4d25df32014-03-21 17:44:46 +0100557 // Guards deoptimization requests.
558 static Mutex* deoptimization_lock_ ACQUIRED_AFTER(Locks::breakpoint_lock_);
559
560 // Deoptimization requests to be processed each time the event list is updated. This is used when
561 // registering and unregistering events so we do not deoptimize while holding the event list
562 // lock.
563 static std::vector<DeoptimizationRequest> deoptimization_requests_ GUARDED_BY(deoptimization_lock_);
564
565 // Count the number of events requiring full deoptimization. When the counter is > 0, everything
566 // is deoptimized, otherwise everything is undeoptimized.
567 // Note: we fully deoptimize on the first event only (when the counter is set to 1). We fully
568 // undeoptimize when the last event is unregistered (when the counter is set to 0).
569 static size_t full_deoptimization_event_count_ GUARDED_BY(deoptimization_lock_);
570
Ian Rogers719d1a32014-03-06 12:13:39 -0800571 DISALLOW_COPY_AND_ASSIGN(Dbg);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700572};
573
574#define CHUNK_TYPE(_name) \
Elliott Hughes82188472011-11-07 18:11:48 -0800575 static_cast<uint32_t>((_name)[0] << 24 | (_name)[1] << 16 | (_name)[2] << 8 | (_name)[3])
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700576
577} // namespace art
578
Brian Carlstromfc0e3212013-07-17 14:40:12 -0700579#endif // ART_RUNTIME_DEBUGGER_H_