blob: 4f3ff40e86d95592ad4bbac824a50fafd259439e [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
Mathieu Chartiere34fa1d2015-01-14 14:55:47 -080030#include "gc_root.h"
Andreas Gampe0f01b582017-01-18 15:22:37 -080031#include "class_linker.h"
32#include "handle.h"
Elliott Hughes872d4ec2011-10-21 17:07:15 -070033#include "jdwp/jdwp.h"
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080034#include "jni.h"
35#include "jvalue.h"
Mathieu Chartier3398c782016-09-30 10:27:43 -070036#include "obj_ptr.h"
Mingyao Yang99170c62015-07-06 11:10:37 -070037#include "thread.h"
Jeff Hao920af3e2013-08-28 15:46:38 -070038#include "thread_state.h"
Elliott Hughes872d4ec2011-10-21 17:07:15 -070039
40namespace art {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080041namespace mirror {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080042class Class;
43class Object;
44class Throwable;
45} // namespace mirror
Mathieu Chartierc7853442015-03-27 14:35:38 -070046class ArtField;
Mathieu Chartiere401d142015-04-22 13:56:20 -070047class ArtMethod;
Sebastien Hertz6995c602014-09-09 12:10:13 +020048class ObjectRegistry;
Sebastien Hertzcbc50642015-06-01 17:33:12 +020049class ScopedObjectAccess;
Sebastien Hertz6995c602014-09-09 12:10:13 +020050class ScopedObjectAccessUnchecked;
Sebastien Hertz8009f392014-09-01 17:07:11 +020051class StackVisitor;
Ian Rogers1b09b092012-08-20 15:35:52 -070052class Thread;
Elliott Hughes872d4ec2011-10-21 17:07:15 -070053
54/*
55 * Invoke-during-breakpoint support.
56 */
57struct DebugInvokeReq {
Sebastien Hertzcbc50642015-06-01 17:33:12 +020058 DebugInvokeReq(uint32_t invoke_request_id, JDWP::ObjectId invoke_thread_id,
59 mirror::Object* invoke_receiver, mirror::Class* invoke_class,
Mathieu Chartiere401d142015-04-22 13:56:20 -070060 ArtMethod* invoke_method, uint32_t invoke_options,
Sebastien Hertzcbc50642015-06-01 17:33:12 +020061 uint64_t args[], uint32_t args_count)
62 : request_id(invoke_request_id), thread_id(invoke_thread_id), receiver(invoke_receiver),
63 klass(invoke_class), method(invoke_method), arg_count(args_count), arg_values(args),
64 options(invoke_options), reply(JDWP::expandBufAlloc()) {
Elliott Hughes475fc232011-10-25 15:00:35 -070065 }
66
Sebastien Hertzcbc50642015-06-01 17:33:12 +020067 ~DebugInvokeReq() {
68 JDWP::expandBufFree(reply);
69 }
70
71 // Request
72 const uint32_t request_id;
73 const JDWP::ObjectId thread_id;
74 GcRoot<mirror::Object> receiver; // not used for ClassType.InvokeMethod.
Sebastien Hertz1558b572015-02-25 15:05:59 +010075 GcRoot<mirror::Class> klass;
Sebastien Hertzcbc50642015-06-01 17:33:12 +020076 ArtMethod* const method;
Sebastien Hertz1558b572015-02-25 15:05:59 +010077 const uint32_t arg_count;
Sebastien Hertzcbc50642015-06-01 17:33:12 +020078 std::unique_ptr<uint64_t[]> arg_values; // will be null if arg_count_ == 0. We take ownership
79 // of this array so we must delete it upon destruction.
Sebastien Hertz1558b572015-02-25 15:05:59 +010080 const uint32_t options;
Elliott Hughes872d4ec2011-10-21 17:07:15 -070081
Sebastien Hertzcbc50642015-06-01 17:33:12 +020082 // Reply
83 JDWP::ExpandBuf* const reply;
Sebastien Hertz61b7f1b2013-11-15 15:59:30 +010084
Mathieu Chartierbb87e0f2015-04-03 11:21:55 -070085 void VisitRoots(RootVisitor* visitor, const RootInfo& root_info)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -070086 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartier3b05e9b2014-03-25 09:29:43 -070087
Sebastien Hertz61b7f1b2013-11-15 15:59:30 +010088 private:
89 DISALLOW_COPY_AND_ASSIGN(DebugInvokeReq);
90};
91
92// Thread local data-structure that holds fields for controlling single-stepping.
Sebastien Hertz597c4f02015-01-26 17:37:14 +010093class SingleStepControl {
94 public:
95 SingleStepControl(JDWP::JdwpStepSize step_size, JDWP::JdwpStepDepth step_depth,
Mathieu Chartiere401d142015-04-22 13:56:20 -070096 int stack_depth, ArtMethod* method)
Sebastien Hertz597c4f02015-01-26 17:37:14 +010097 : step_size_(step_size), step_depth_(step_depth),
98 stack_depth_(stack_depth), method_(method) {
Sebastien Hertz61b7f1b2013-11-15 15:59:30 +010099 }
100
Sebastien Hertz597c4f02015-01-26 17:37:14 +0100101 JDWP::JdwpStepSize GetStepSize() const {
102 return step_size_;
103 }
Sebastien Hertz61b7f1b2013-11-15 15:59:30 +0100104
Sebastien Hertz597c4f02015-01-26 17:37:14 +0100105 JDWP::JdwpStepDepth GetStepDepth() const {
106 return step_depth_;
107 }
108
109 int GetStackDepth() const {
110 return stack_depth_;
111 }
112
Mathieu Chartiere401d142015-04-22 13:56:20 -0700113 ArtMethod* GetMethod() const {
114 return method_;
Sebastien Hertz597c4f02015-01-26 17:37:14 +0100115 }
116
117 const std::set<uint32_t>& GetDexPcs() const {
118 return dex_pcs_;
119 }
120
Sebastien Hertz597c4f02015-01-26 17:37:14 +0100121 void AddDexPc(uint32_t dex_pc);
122
123 bool ContainsDexPc(uint32_t dex_pc) const;
124
125 private:
Sebastien Hertz61b7f1b2013-11-15 15:59:30 +0100126 // See JdwpStepSize and JdwpStepDepth for details.
Sebastien Hertz597c4f02015-01-26 17:37:14 +0100127 const JDWP::JdwpStepSize step_size_;
128 const JDWP::JdwpStepDepth step_depth_;
129
130 // The stack depth when this single-step was initiated. This is used to support SD_OVER and SD_OUT
131 // single-step depth.
132 const int stack_depth_;
Sebastien Hertz61b7f1b2013-11-15 15:59:30 +0100133
134 // The location this single-step was initiated from.
135 // A single-step is initiated in a suspended thread. We save here the current method and the
136 // set of DEX pcs associated to the source line number where the suspension occurred.
137 // This is used to support SD_INTO and SD_OVER single-step depths so we detect when a single-step
138 // causes the execution of an instruction in a different method or at a different line number.
Mathieu Chartiere401d142015-04-22 13:56:20 -0700139 ArtMethod* method_;
140
Sebastien Hertz597c4f02015-01-26 17:37:14 +0100141 std::set<uint32_t> dex_pcs_;
Sebastien Hertz61b7f1b2013-11-15 15:59:30 +0100142
Sebastien Hertz61b7f1b2013-11-15 15:59:30 +0100143 DISALLOW_COPY_AND_ASSIGN(SingleStepControl);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700144};
145
Sebastien Hertz42cd43f2014-05-13 14:15:41 +0200146// TODO rename to InstrumentationRequest.
Hiroshi Yamauchi0ec17d22014-07-07 13:07:08 -0700147class DeoptimizationRequest {
148 public:
Sebastien Hertz4d25df32014-03-21 17:44:46 +0100149 enum Kind {
150 kNothing, // no action.
Sebastien Hertz42cd43f2014-05-13 14:15:41 +0200151 kRegisterForEvent, // start listening for instrumentation event.
152 kUnregisterForEvent, // stop listening for instrumentation event.
Sebastien Hertz4d25df32014-03-21 17:44:46 +0100153 kFullDeoptimization, // deoptimize everything.
154 kFullUndeoptimization, // undeoptimize everything.
155 kSelectiveDeoptimization, // deoptimize one method.
156 kSelectiveUndeoptimization // undeoptimize one method.
157 };
158
Hiroshi Yamauchi0ec17d22014-07-07 13:07:08 -0700159 DeoptimizationRequest() : kind_(kNothing), instrumentation_event_(0), method_(nullptr) {}
Sebastien Hertz4d25df32014-03-21 17:44:46 +0100160
Hiroshi Yamauchi0ec17d22014-07-07 13:07:08 -0700161 DeoptimizationRequest(const DeoptimizationRequest& other)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700162 REQUIRES_SHARED(Locks::mutator_lock_)
Hiroshi Yamauchi0ec17d22014-07-07 13:07:08 -0700163 : kind_(other.kind_), instrumentation_event_(other.instrumentation_event_) {
164 // Create a new JNI global reference for the method.
165 SetMethod(other.Method());
166 }
Sebastien Hertz4d25df32014-03-21 17:44:46 +0100167
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700168 ArtMethod* Method() const REQUIRES_SHARED(Locks::mutator_lock_);
Hiroshi Yamauchi0ec17d22014-07-07 13:07:08 -0700169
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700170 void SetMethod(ArtMethod* m) REQUIRES_SHARED(Locks::mutator_lock_);
Hiroshi Yamauchi0ec17d22014-07-07 13:07:08 -0700171
172 // Name 'Kind()' would collide with the above enum name.
173 Kind GetKind() const {
174 return kind_;
175 }
176
177 void SetKind(Kind kind) {
178 kind_ = kind;
179 }
180
181 uint32_t InstrumentationEvent() const {
182 return instrumentation_event_;
183 }
184
185 void SetInstrumentationEvent(uint32_t instrumentation_event) {
186 instrumentation_event_ = instrumentation_event;
187 }
188
189 private:
190 Kind kind_;
Sebastien Hertz4d25df32014-03-21 17:44:46 +0100191
Sebastien Hertz42cd43f2014-05-13 14:15:41 +0200192 // TODO we could use a union to hold the instrumentation_event and the method since they
193 // respectively have sense only for kRegisterForEvent/kUnregisterForEvent and
194 // kSelectiveDeoptimization/kSelectiveUndeoptimization.
195
196 // Event to start or stop listening to. Only for kRegisterForEvent and kUnregisterForEvent.
Hiroshi Yamauchi0ec17d22014-07-07 13:07:08 -0700197 uint32_t instrumentation_event_;
Sebastien Hertz42cd43f2014-05-13 14:15:41 +0200198
Sebastien Hertz4d25df32014-03-21 17:44:46 +0100199 // Method for selective deoptimization.
Hiroshi Yamauchi0ec17d22014-07-07 13:07:08 -0700200 jmethodID method_;
Sebastien Hertz4d25df32014-03-21 17:44:46 +0100201};
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700202std::ostream& operator<<(std::ostream& os, const DeoptimizationRequest::Kind& rhs);
Sebastien Hertz4d25df32014-03-21 17:44:46 +0100203
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700204class Dbg {
Elliott Hughesff17f1f2012-01-24 18:12:29 -0800205 public:
Elliott Hughes4ffd3132011-10-24 12:06:42 -0700206 static void SetJdwpAllowed(bool allowed);
Leonard Mosescueb842212016-10-06 17:26:36 -0700207 static bool IsJdwpAllowed();
Elliott Hughes4ffd3132011-10-24 12:06:42 -0700208
Sebastien Hertzb3b173b2015-02-06 09:16:32 +0100209 static void StartJdwp();
Elliott Hughesd1cc8362011-10-24 16:58:50 -0700210 static void StopJdwp();
211
Elliott Hughes767a1472011-10-26 18:49:02 -0700212 // Invoked by the GC in case we need to keep DDMS informed.
Mathieu Chartier90443472015-07-16 20:32:27 -0700213 static void GcDidFinish() REQUIRES(!Locks::mutator_lock_);
Elliott Hughes767a1472011-10-26 18:49:02 -0700214
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700215 // Return the DebugInvokeReq for the current thread.
216 static DebugInvokeReq* GetInvokeReq();
217
Elliott Hughes475fc232011-10-25 15:00:35 -0700218 static Thread* GetDebugThread();
219 static void ClearWaitForEventThread();
220
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700221 /*
222 * Enable/disable breakpoints and step modes. Used to provide a heads-up
223 * when the debugger attaches.
224 */
225 static void Connected();
Sebastien Hertz138dbfc2013-12-04 18:15:25 +0100226 static void GoActive()
Mathieu Chartier90443472015-07-16 20:32:27 -0700227 REQUIRES(!Locks::breakpoint_lock_, !Locks::deoptimization_lock_, !Locks::mutator_lock_);
228 static void Disconnected() REQUIRES(!Locks::deoptimization_lock_, !Locks::mutator_lock_);
Sebastien Hertz4e5b2082015-03-24 19:03:40 +0100229 static void Dispose() {
230 gDisposed = true;
231 }
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700232
Elliott Hughesc0f09332012-03-26 13:27:06 -0700233 // Returns true if we're actually debugging with a real debugger, false if it's
234 // just DDMS (or nothing at all).
Daniel Mihalyieb076692014-08-22 17:33:31 +0200235 static bool IsDebuggerActive() {
236 return gDebuggerActive;
237 }
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700238
Sebastien Hertzb3b173b2015-02-06 09:16:32 +0100239 // Configures JDWP with parsed command-line options.
240 static void ConfigureJdwp(const JDWP::JdwpOptions& jdwp_options);
241
Elliott Hughesc0f09332012-03-26 13:27:06 -0700242 // Returns true if we had -Xrunjdwp or -agentlib:jdwp= on the command line.
243 static bool IsJdwpConfigured();
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700244
Mathieu Chartierd8565452015-03-26 09:41:50 -0700245 // Returns true if a method has any breakpoints.
Mathieu Chartiere401d142015-04-22 13:56:20 -0700246 static bool MethodHasAnyBreakpoints(ArtMethod* method)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700247 REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Locks::breakpoint_lock_);
Mathieu Chartierd8565452015-03-26 09:41:50 -0700248
Sebastien Hertz4e5b2082015-03-24 19:03:40 +0100249 static bool IsDisposed() {
250 return gDisposed;
251 }
Elliott Hughes86964332012-02-15 19:37:42 -0800252
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700253 /*
254 * Time, in milliseconds, since the last debugger activity. Does not
255 * include DDMS activity. Returns -1 if there has been no activity.
256 * Returns 0 if we're in the middle of handling a debugger request.
257 */
258 static int64_t LastDebuggerActivity();
259
Sebastien Hertz253fa552014-10-14 17:27:15 +0200260 static void UndoDebuggerSuspensions()
Mathieu Chartier90443472015-07-16 20:32:27 -0700261 REQUIRES(!Locks::thread_list_lock_, !Locks::thread_suspend_count_lock_);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700262
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700263 /*
264 * Class, Object, Array
265 */
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700266 static std::string GetClassName(JDWP::RefTypeId id)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700267 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz6995c602014-09-09 12:10:13 +0200268 static std::string GetClassName(mirror::Class* klass)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700269 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogersc0542af2014-09-03 16:16:56 -0700270 static JDWP::JdwpError GetClassObject(JDWP::RefTypeId id, JDWP::ObjectId* class_object_id)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700271 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogersc0542af2014-09-03 16:16:56 -0700272 static JDWP::JdwpError GetSuperclass(JDWP::RefTypeId id, JDWP::RefTypeId* superclass_id)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700273 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700274 static JDWP::JdwpError GetClassLoader(JDWP::RefTypeId id, JDWP::ExpandBuf* pReply)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700275 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700276 static JDWP::JdwpError GetModifiers(JDWP::RefTypeId id, JDWP::ExpandBuf* pReply)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700277 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800278 static JDWP::JdwpError GetReflectedType(JDWP::RefTypeId class_id, JDWP::ExpandBuf* pReply)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700279 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogersc0542af2014-09-03 16:16:56 -0700280 static void GetClassList(std::vector<JDWP::RefTypeId>* classes)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700281 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800282 static JDWP::JdwpError GetClassInfo(JDWP::RefTypeId class_id, JDWP::JdwpTypeTag* pTypeTag,
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700283 uint32_t* pStatus, std::string* pDescriptor)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700284 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogersc0542af2014-09-03 16:16:56 -0700285 static void FindLoadedClassBySignature(const char* descriptor, std::vector<JDWP::RefTypeId>* ids)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700286 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes64f574f2013-02-20 14:57:12 -0800287 static JDWP::JdwpError GetReferenceType(JDWP::ObjectId object_id, JDWP::ExpandBuf* pReply)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700288 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogersfc0e94b2013-09-23 23:51:32 -0700289 static JDWP::JdwpError GetSignature(JDWP::RefTypeId ref_type_id, std::string* signature)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700290 REQUIRES_SHARED(Locks::mutator_lock_);
Orion Hodson77d8a1c2017-04-24 14:53:19 +0100291 static JDWP::JdwpError GetSourceDebugExtension(JDWP::RefTypeId ref_type_id,
292 std::string* extension_data)
293 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogersc0542af2014-09-03 16:16:56 -0700294 static JDWP::JdwpError GetSourceFile(JDWP::RefTypeId ref_type_id, std::string* source_file)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700295 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogersc0542af2014-09-03 16:16:56 -0700296 static JDWP::JdwpError GetObjectTag(JDWP::ObjectId object_id, uint8_t* tag)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700297 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughesaed4be92011-12-02 16:16:23 -0800298 static size_t GetTagWidth(JDWP::JdwpTag tag);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700299
Ian Rogersc0542af2014-09-03 16:16:56 -0700300 static JDWP::JdwpError GetArrayLength(JDWP::ObjectId array_id, int32_t* length)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700301 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800302 static JDWP::JdwpError OutputArray(JDWP::ObjectId array_id, int offset, int count,
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700303 JDWP::ExpandBuf* pReply)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700304 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800305 static JDWP::JdwpError SetArrayElements(JDWP::ObjectId array_id, int offset, int count,
Ian Rogersc0542af2014-09-03 16:16:56 -0700306 JDWP::Request* request)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700307 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700308
Sebastien Hertz2c3e77a2015-04-02 16:26:48 +0200309 static JDWP::JdwpError CreateString(const std::string& str, JDWP::ObjectId* new_string_id)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700310 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz2c3e77a2015-04-02 16:26:48 +0200311 static JDWP::JdwpError CreateObject(JDWP::RefTypeId class_id, JDWP::ObjectId* new_object_id)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700312 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800313 static JDWP::JdwpError CreateArrayObject(JDWP::RefTypeId array_class_id, uint32_t length,
Sebastien Hertz2c3e77a2015-04-02 16:26:48 +0200314 JDWP::ObjectId* new_array_id)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700315 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700316
Sebastien Hertz6995c602014-09-09 12:10:13 +0200317 //
318 // Event filtering.
319 //
320 static bool MatchThread(JDWP::ObjectId expected_thread_id, Thread* event_thread)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700321 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz6995c602014-09-09 12:10:13 +0200322
323 static bool MatchLocation(const JDWP::JdwpLocation& expected_location,
324 const JDWP::EventLocation& event_location)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700325 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz6995c602014-09-09 12:10:13 +0200326
Mathieu Chartier3398c782016-09-30 10:27:43 -0700327 static bool MatchType(ObjPtr<mirror::Class> event_class, JDWP::RefTypeId class_id)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700328 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz6995c602014-09-09 12:10:13 +0200329
330 static bool MatchField(JDWP::RefTypeId expected_type_id, JDWP::FieldId expected_field_id,
Mathieu Chartierc7853442015-03-27 14:35:38 -0700331 ArtField* event_field)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700332 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz6995c602014-09-09 12:10:13 +0200333
334 static bool MatchInstance(JDWP::ObjectId expected_instance_id, mirror::Object* event_instance)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700335 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700336
Elliott Hughesec0f83d2013-01-15 16:54:08 -0800337 //
338 // Monitors.
339 //
340 static JDWP::JdwpError GetMonitorInfo(JDWP::ObjectId object_id, JDWP::ExpandBuf* reply)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700341 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughesec0f83d2013-01-15 16:54:08 -0800342 static JDWP::JdwpError GetOwnedMonitors(JDWP::ObjectId thread_id,
Ian Rogersc0542af2014-09-03 16:16:56 -0700343 std::vector<JDWP::ObjectId>* monitors,
344 std::vector<uint32_t>* stack_depths)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700345 REQUIRES(!Locks::thread_list_lock_) REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz52d131d2014-03-13 16:17:40 +0100346 static JDWP::JdwpError GetContendedMonitor(JDWP::ObjectId thread_id,
Ian Rogersc0542af2014-09-03 16:16:56 -0700347 JDWP::ObjectId* contended_monitor)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700348 REQUIRES(!Locks::thread_list_lock_) REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughesec0f83d2013-01-15 16:54:08 -0800349
350 //
351 // Heap.
352 //
353 static JDWP::JdwpError GetInstanceCounts(const std::vector<JDWP::RefTypeId>& class_ids,
Ian Rogersc0542af2014-09-03 16:16:56 -0700354 std::vector<uint64_t>* counts)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700355 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes3b78c942013-01-15 17:35:41 -0800356 static JDWP::JdwpError GetInstances(JDWP::RefTypeId class_id, int32_t max_count,
Ian Rogersc0542af2014-09-03 16:16:56 -0700357 std::vector<JDWP::ObjectId>* instances)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700358 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes0cbaff52013-01-16 15:28:01 -0800359 static JDWP::JdwpError GetReferringObjects(JDWP::ObjectId object_id, int32_t max_count,
Ian Rogersc0542af2014-09-03 16:16:56 -0700360 std::vector<JDWP::ObjectId>* referring_objects)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700361 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes64f574f2013-02-20 14:57:12 -0800362 static JDWP::JdwpError DisableCollection(JDWP::ObjectId object_id)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700363 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes64f574f2013-02-20 14:57:12 -0800364 static JDWP::JdwpError EnableCollection(JDWP::ObjectId object_id)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700365 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogersc0542af2014-09-03 16:16:56 -0700366 static JDWP::JdwpError IsCollected(JDWP::ObjectId object_id, bool* is_collected)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700367 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes64f574f2013-02-20 14:57:12 -0800368 static void DisposeObject(JDWP::ObjectId object_id, uint32_t reference_count)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700369 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughesec0f83d2013-01-15 16:54:08 -0800370
Elliott Hughes9777ba22013-01-17 09:04:19 -0800371 //
372 // Methods and fields.
373 //
Elliott Hughesa96836a2013-01-17 12:27:49 -0800374 static std::string GetMethodName(JDWP::MethodId method_id)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700375 REQUIRES_SHARED(Locks::mutator_lock_);
Alex Light73376312017-04-06 10:10:51 -0700376 static bool IsMethodObsolete(JDWP::MethodId method_id)
377 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800378 static JDWP::JdwpError OutputDeclaredFields(JDWP::RefTypeId ref_type_id, bool with_generic,
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700379 JDWP::ExpandBuf* pReply)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700380 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800381 static JDWP::JdwpError OutputDeclaredMethods(JDWP::RefTypeId ref_type_id, bool with_generic,
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700382 JDWP::ExpandBuf* pReply)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700383 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800384 static JDWP::JdwpError OutputDeclaredInterfaces(JDWP::RefTypeId ref_type_id,
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700385 JDWP::ExpandBuf* pReply)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700386 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800387 static void OutputLineTable(JDWP::RefTypeId ref_type_id, JDWP::MethodId method_id,
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700388 JDWP::ExpandBuf* pReply)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700389 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800390 static void OutputVariableTable(JDWP::RefTypeId ref_type_id, JDWP::MethodId id, bool with_generic,
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700391 JDWP::ExpandBuf* pReply)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700392 REQUIRES_SHARED(Locks::mutator_lock_);
Jeff Hao579b0242013-11-18 13:16:49 -0800393 static void OutputMethodReturnValue(JDWP::MethodId method_id, const JValue* return_value,
394 JDWP::ExpandBuf* pReply)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700395 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz3f52eaf2014-04-04 17:50:18 +0200396 static void OutputFieldValue(JDWP::FieldId field_id, const JValue* field_value,
397 JDWP::ExpandBuf* pReply)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700398 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes9777ba22013-01-17 09:04:19 -0800399 static JDWP::JdwpError GetBytecodes(JDWP::RefTypeId class_id, JDWP::MethodId method_id,
Ian Rogersc0542af2014-09-03 16:16:56 -0700400 std::vector<uint8_t>* bytecodes)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700401 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700402
Elliott Hughesa96836a2013-01-17 12:27:49 -0800403 static std::string GetFieldName(JDWP::FieldId field_id)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700404 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800405 static JDWP::JdwpTag GetFieldBasicTag(JDWP::FieldId field_id)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700406 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800407 static JDWP::JdwpTag GetStaticFieldBasicTag(JDWP::FieldId field_id)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700408 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800409 static JDWP::JdwpError GetFieldValue(JDWP::ObjectId object_id, JDWP::FieldId field_id,
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700410 JDWP::ExpandBuf* pReply)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700411 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800412 static JDWP::JdwpError SetFieldValue(JDWP::ObjectId object_id, JDWP::FieldId field_id,
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700413 uint64_t value, int width)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700414 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800415 static JDWP::JdwpError GetStaticFieldValue(JDWP::RefTypeId ref_type_id, JDWP::FieldId field_id,
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700416 JDWP::ExpandBuf* pReply)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700417 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800418 static JDWP::JdwpError SetStaticFieldValue(JDWP::FieldId field_id, uint64_t value, int width)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700419 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700420
Sebastien Hertzb0b0b492014-09-15 11:27:27 +0200421 static JDWP::JdwpError StringToUtf8(JDWP::ObjectId string_id, std::string* str)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700422 REQUIRES_SHARED(Locks::mutator_lock_);
Jeff Hao579b0242013-11-18 13:16:49 -0800423 static void OutputJValue(JDWP::JdwpTag tag, const JValue* return_value, JDWP::ExpandBuf* pReply)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700424 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700425
426 /*
427 * Thread, ThreadGroup, Frame
428 */
Ian Rogersc0542af2014-09-03 16:16:56 -0700429 static JDWP::JdwpError GetThreadName(JDWP::ObjectId thread_id, std::string* name)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700430 REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Locks::thread_list_lock_);
Sebastien Hertz52d131d2014-03-13 16:17:40 +0100431 static JDWP::JdwpError GetThreadGroup(JDWP::ObjectId thread_id, JDWP::ExpandBuf* pReply)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700432 REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Locks::thread_list_lock_);
Sebastien Hertza06430c2014-09-15 19:21:30 +0200433 static JDWP::JdwpError GetThreadGroupName(JDWP::ObjectId thread_group_id,
434 JDWP::ExpandBuf* pReply)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700435 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertza06430c2014-09-15 19:21:30 +0200436 static JDWP::JdwpError GetThreadGroupParent(JDWP::ObjectId thread_group_id,
437 JDWP::ExpandBuf* pReply)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700438 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertza06430c2014-09-15 19:21:30 +0200439 static JDWP::JdwpError GetThreadGroupChildren(JDWP::ObjectId thread_group_id,
440 JDWP::ExpandBuf* pReply)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700441 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700442 static JDWP::ObjectId GetSystemThreadGroupId()
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700443 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700444
Jeff Hao920af3e2013-08-28 15:46:38 -0700445 static JDWP::JdwpThreadStatus ToJdwpThreadStatus(ThreadState state);
Sebastien Hertz52d131d2014-03-13 16:17:40 +0100446 static JDWP::JdwpError GetThreadStatus(JDWP::ObjectId thread_id,
447 JDWP::JdwpThreadStatus* pThreadStatus,
448 JDWP::JdwpSuspendStatus* pSuspendStatus)
Mathieu Chartier90443472015-07-16 20:32:27 -0700449 REQUIRES(!Locks::thread_list_lock_);
Sebastien Hertz52d131d2014-03-13 16:17:40 +0100450 static JDWP::JdwpError GetThreadDebugSuspendCount(JDWP::ObjectId thread_id,
451 JDWP::ExpandBuf* pReply)
Mathieu Chartier90443472015-07-16 20:32:27 -0700452 REQUIRES(!Locks::thread_list_lock_, !Locks::thread_suspend_count_lock_);
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700453 // static void WaitForSuspend(JDWP::ObjectId thread_id);
Elliott Hughescaf76542012-06-28 16:08:22 -0700454
Elliott Hughes026b1462012-06-28 20:43:49 -0700455 // Fills 'thread_ids' with the threads in the given thread group. If thread_group_id == 0,
Elliott Hughescaf76542012-06-28 16:08:22 -0700456 // returns all threads.
Sebastien Hertza06430c2014-09-15 19:21:30 +0200457 static void GetThreads(mirror::Object* thread_group, std::vector<JDWP::ObjectId>* thread_ids)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700458 REQUIRES(!Locks::thread_list_lock_) REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughescaf76542012-06-28 16:08:22 -0700459
Ian Rogersc0542af2014-09-03 16:16:56 -0700460 static JDWP::JdwpError GetThreadFrameCount(JDWP::ObjectId thread_id, size_t* result)
Mathieu Chartier90443472015-07-16 20:32:27 -0700461 REQUIRES(!Locks::thread_list_lock_);
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700462 static JDWP::JdwpError GetThreadFrames(JDWP::ObjectId thread_id, size_t start_frame,
463 size_t frame_count, JDWP::ExpandBuf* buf)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700464 REQUIRES(!Locks::thread_list_lock_) REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700465
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700466 static JDWP::ObjectId GetThreadSelfId() REQUIRES_SHARED(Locks::mutator_lock_);
467 static JDWP::ObjectId GetThreadId(Thread* thread) REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz6995c602014-09-09 12:10:13 +0200468
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700469 static void SuspendVM()
Mathieu Chartier90443472015-07-16 20:32:27 -0700470 REQUIRES(!Locks::thread_list_lock_, !Locks::thread_suspend_count_lock_);
Sebastien Hertz253fa552014-10-14 17:27:15 +0200471 static void ResumeVM()
Mathieu Chartier90443472015-07-16 20:32:27 -0700472 REQUIRES(!Locks::thread_list_lock_, !Locks::thread_suspend_count_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800473 static JDWP::JdwpError SuspendThread(JDWP::ObjectId thread_id, bool request_suspension = true)
Mathieu Chartier90443472015-07-16 20:32:27 -0700474 REQUIRES(!Locks::mutator_lock_, !Locks::thread_list_lock_,
475 !Locks::thread_suspend_count_lock_);
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700476
Elliott Hughes88d63092013-01-09 09:55:54 -0800477 static void ResumeThread(JDWP::ObjectId thread_id)
Mathieu Chartier90443472015-07-16 20:32:27 -0700478 REQUIRES(!Locks::thread_list_lock_, !Locks::thread_suspend_count_lock_)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700479 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700480 static void SuspendSelf();
481
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700482 static JDWP::JdwpError GetThisObject(JDWP::ObjectId thread_id, JDWP::FrameId frame_id,
483 JDWP::ObjectId* result)
Mathieu Chartier90443472015-07-16 20:32:27 -0700484 REQUIRES(!Locks::thread_list_lock_, !Locks::thread_suspend_count_lock_)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700485 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz8009f392014-09-01 17:07:11 +0200486 static JDWP::JdwpError GetLocalValues(JDWP::Request* request, JDWP::ExpandBuf* pReply)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700487 REQUIRES(!Locks::thread_list_lock_) REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz8009f392014-09-01 17:07:11 +0200488 static JDWP::JdwpError SetLocalValues(JDWP::Request* request)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700489 REQUIRES(!Locks::thread_list_lock_) REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700490
Sebastien Hertz52d131d2014-03-13 16:17:40 +0100491 static JDWP::JdwpError Interrupt(JDWP::ObjectId thread_id)
Mathieu Chartier90443472015-07-16 20:32:27 -0700492 REQUIRES(!Locks::thread_list_lock_);
Elliott Hughesf9501702013-01-11 11:22:27 -0800493
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700494 /*
495 * Debugger notification
496 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700497 enum EventFlag {
Elliott Hughes86964332012-02-15 19:37:42 -0800498 kBreakpoint = 0x01,
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700499 kSingleStep = 0x02,
500 kMethodEntry = 0x04,
501 kMethodExit = 0x08,
502 };
Mathieu Chartiere401d142015-04-22 13:56:20 -0700503 static void PostFieldAccessEvent(ArtMethod* m, int dex_pc, mirror::Object* this_object,
Mathieu Chartierc7853442015-03-27 14:35:38 -0700504 ArtField* f)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700505 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartiere401d142015-04-22 13:56:20 -0700506 static void PostFieldModificationEvent(ArtMethod* m, int dex_pc,
Mathieu Chartierc7853442015-03-27 14:35:38 -0700507 mirror::Object* this_object, ArtField* f,
Sebastien Hertz3f52eaf2014-04-04 17:50:18 +0200508 const JValue* field_value)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700509 REQUIRES_SHARED(Locks::mutator_lock_);
Nicolas Geoffray14691c52015-03-05 10:40:17 +0000510 static void PostException(mirror::Throwable* exception)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700511 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700512
Ian Rogers62d6c772013-02-27 08:32:07 -0800513 static void UpdateDebugger(Thread* thread, mirror::Object* this_object,
Mathieu Chartiere401d142015-04-22 13:56:20 -0700514 ArtMethod* method, uint32_t new_dex_pc,
Sebastien Hertz8379b222014-02-24 17:38:15 +0100515 int event_flags, const JValue* return_value)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700516 REQUIRES(!Locks::breakpoint_lock_) REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes91bf6cd2012-02-14 17:27:48 -0800517
Sebastien Hertzf3928792014-11-17 19:00:37 +0100518 // Indicates whether we need deoptimization for debugging.
519 static bool RequiresDeoptimization();
520
Sebastien Hertz4d25df32014-03-21 17:44:46 +0100521 // Records deoptimization request in the queue.
522 static void RequestDeoptimization(const DeoptimizationRequest& req)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700523 REQUIRES(!Locks::deoptimization_lock_) REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz138dbfc2013-12-04 18:15:25 +0100524
Sebastien Hertz4d25df32014-03-21 17:44:46 +0100525 // Manage deoptimization after updating JDWP events list. Suspends all threads, processes each
526 // request and finally resumes all threads.
Sebastien Hertz138dbfc2013-12-04 18:15:25 +0100527 static void ManageDeoptimization()
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700528 REQUIRES(!Locks::deoptimization_lock_) REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz138dbfc2013-12-04 18:15:25 +0100529
530 // Breakpoints.
Sebastien Hertz4d25df32014-03-21 17:44:46 +0100531 static void WatchLocation(const JDWP::JdwpLocation* pLoc, DeoptimizationRequest* req)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700532 REQUIRES(!Locks::breakpoint_lock_) REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz4d25df32014-03-21 17:44:46 +0100533 static void UnwatchLocation(const JDWP::JdwpLocation* pLoc, DeoptimizationRequest* req)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700534 REQUIRES(!Locks::breakpoint_lock_) REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz138dbfc2013-12-04 18:15:25 +0100535
Daniel Mihalyieb076692014-08-22 17:33:31 +0200536 /*
537 * Forced interpreter checkers for single-step and continue support.
538 */
539
540 // Indicates whether we need to force the use of interpreter to invoke a method.
541 // This allows to single-step or continue into the called method.
Mathieu Chartiere401d142015-04-22 13:56:20 -0700542 static bool IsForcedInterpreterNeededForCalling(Thread* thread, ArtMethod* m)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700543 REQUIRES_SHARED(Locks::mutator_lock_) {
Daniel Mihalyieb076692014-08-22 17:33:31 +0200544 if (!IsDebuggerActive()) {
545 return false;
546 }
547 return IsForcedInterpreterNeededForCallingImpl(thread, m);
548 }
549
550 // Indicates whether we need to force the use of interpreter entrypoint when calling a
551 // method through the resolution trampoline. This allows to single-step or continue into
552 // the called method.
Mathieu Chartiere401d142015-04-22 13:56:20 -0700553 static bool IsForcedInterpreterNeededForResolution(Thread* thread, ArtMethod* m)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700554 REQUIRES_SHARED(Locks::mutator_lock_) {
Daniel Mihalyieb076692014-08-22 17:33:31 +0200555 if (!IsDebuggerActive()) {
556 return false;
557 }
558 return IsForcedInterpreterNeededForResolutionImpl(thread, m);
559 }
560
561 // Indicates whether we need to force the use of instrumentation entrypoint when calling
562 // a method through the resolution trampoline. This allows to deoptimize the stack for
563 // debugging when we returned from the called method.
Mathieu Chartiere401d142015-04-22 13:56:20 -0700564 static bool IsForcedInstrumentationNeededForResolution(Thread* thread, ArtMethod* m)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700565 REQUIRES_SHARED(Locks::mutator_lock_) {
Daniel Mihalyieb076692014-08-22 17:33:31 +0200566 if (!IsDebuggerActive()) {
567 return false;
568 }
569 return IsForcedInstrumentationNeededForResolutionImpl(thread, m);
570 }
571
572 // Indicates whether we need to force the use of interpreter when returning from the
573 // interpreter into the runtime. This allows to deoptimize the stack and continue
574 // execution with interpreter for debugging.
Mathieu Chartiere401d142015-04-22 13:56:20 -0700575 static bool IsForcedInterpreterNeededForUpcall(Thread* thread, ArtMethod* m)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700576 REQUIRES_SHARED(Locks::mutator_lock_) {
Mingyao Yang99170c62015-07-06 11:10:37 -0700577 if (!IsDebuggerActive() && !thread->HasDebuggerShadowFrames()) {
Daniel Mihalyieb076692014-08-22 17:33:31 +0200578 return false;
579 }
580 return IsForcedInterpreterNeededForUpcallImpl(thread, m);
581 }
582
Sebastien Hertz520633b2015-09-08 17:03:36 +0200583 // Indicates whether we need to force the use of interpreter when handling an
584 // exception. This allows to deoptimize the stack and continue execution with
585 // the interpreter.
586 // Note: the interpreter will start by handling the exception when executing
587 // the deoptimized frames.
588 static bool IsForcedInterpreterNeededForException(Thread* thread)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700589 REQUIRES_SHARED(Locks::mutator_lock_) {
Mingyao Yang99170c62015-07-06 11:10:37 -0700590 if (!IsDebuggerActive() && !thread->HasDebuggerShadowFrames()) {
Sebastien Hertz520633b2015-09-08 17:03:36 +0200591 return false;
592 }
593 return IsForcedInterpreterNeededForExceptionImpl(thread);
594 }
595
Sebastien Hertz138dbfc2013-12-04 18:15:25 +0100596 // Single-stepping.
Elliott Hughes88d63092013-01-09 09:55:54 -0800597 static JDWP::JdwpError ConfigureStep(JDWP::ObjectId thread_id, JDWP::JdwpStepSize size,
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700598 JDWP::JdwpStepDepth depth)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700599 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz61b7f1b2013-11-15 15:59:30 +0100600 static void UnconfigureStep(JDWP::ObjectId thread_id)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700601 REQUIRES(!Locks::thread_list_lock_) REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700602
Sebastien Hertzcbc50642015-06-01 17:33:12 +0200603 /*
604 * Invoke support
605 */
606
607 // Called by the JDWP thread to prepare invocation in the event thread (suspended on an event).
608 // If the information sent by the debugger is incorrect, it will send a reply with the
609 // appropriate error code. Otherwise, it will attach a DebugInvokeReq object to the event thread
610 // and resume it (and possibly other threads depending on the invoke options).
611 // Unlike other commands, the JDWP thread will not send the reply to the debugger (see
612 // JdwpState::ProcessRequest). The reply will be sent by the event thread itself after method
613 // invocation completes (see FinishInvokeMethod). This is required to allow the JDWP thread to
614 // process incoming commands from the debugger while the invocation is still in progress in the
615 // event thread, especially if it gets suspended by a debug event occurring in another thread.
616 static JDWP::JdwpError PrepareInvokeMethod(uint32_t request_id, JDWP::ObjectId thread_id,
617 JDWP::ObjectId object_id, JDWP::RefTypeId class_id,
618 JDWP::MethodId method_id, uint32_t arg_count,
619 uint64_t arg_values[], JDWP::JdwpTag* arg_types,
620 uint32_t options)
Mathieu Chartier90443472015-07-16 20:32:27 -0700621 REQUIRES(!Locks::thread_list_lock_, !Locks::thread_suspend_count_lock_)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700622 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertzcbc50642015-06-01 17:33:12 +0200623
624 // Called by the event thread to execute a method prepared by the JDWP thread in the given
625 // DebugInvokeReq object. Once the invocation completes, the event thread attaches a reply
626 // to that DebugInvokeReq object so it can be sent to the debugger only when the event thread
627 // is ready to suspend (see FinishInvokeMethod).
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700628 static void ExecuteMethod(DebugInvokeReq* pReq);
629
Sebastien Hertzcbc50642015-06-01 17:33:12 +0200630 // Called by the event thread to send the reply of the invoke (created in ExecuteMethod)
631 // before suspending itself. This is to ensure the thread is ready to suspend before the
632 // debugger receives the reply.
633 static void FinishInvokeMethod(DebugInvokeReq* pReq);
634
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700635 /*
636 * DDM support.
637 */
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700638 static void DdmSendThreadNotification(Thread* t, uint32_t type)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700639 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz52d131d2014-03-13 16:17:40 +0100640 static void DdmSetThreadNotification(bool enable)
Mathieu Chartier90443472015-07-16 20:32:27 -0700641 REQUIRES(!Locks::thread_list_lock_);
Ian Rogersc0542af2014-09-03 16:16:56 -0700642 static bool DdmHandlePacket(JDWP::Request* request, uint8_t** pReplyBuf, int* pReplyLen);
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700643 static void DdmConnected() REQUIRES_SHARED(Locks::mutator_lock_);
644 static void DdmDisconnected() REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700645 static void DdmSendChunk(uint32_t type, const std::vector<uint8_t>& bytes)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700646 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700647 static void DdmSendChunk(uint32_t type, size_t len, const uint8_t* buf)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700648 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700649 static void DdmSendChunkV(uint32_t type, const iovec* iov, int iov_count)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700650 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes767a1472011-10-26 18:49:02 -0700651
Mathieu Chartiera6b1ead2015-10-06 10:32:38 -0700652 // Visit breakpoint roots, used to prevent unloading of methods with breakpoints.
Mathieu Chartierbb87e0f2015-04-03 11:21:55 -0700653 static void VisitRoots(RootVisitor* visitor)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700654 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartier3b05e9b2014-03-25 09:29:43 -0700655
Elliott Hughes545a0642011-11-08 19:10:03 -0800656 /*
Man Cao8c2ff642015-05-27 17:25:30 -0700657 * Allocation tracking support.
Elliott Hughes545a0642011-11-08 19:10:03 -0800658 */
Mathieu Chartier90443472015-07-16 20:32:27 -0700659 static void SetAllocTrackingEnabled(bool enabled) REQUIRES(!Locks::alloc_tracker_lock_);
Sebastien Hertz52d131d2014-03-13 16:17:40 +0100660 static jbyteArray GetRecentAllocations()
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700661 REQUIRES(!Locks::alloc_tracker_lock_) REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartier90443472015-07-16 20:32:27 -0700662 static void DumpRecentAllocations() REQUIRES(!Locks::alloc_tracker_lock_);
Elliott Hughes545a0642011-11-08 19:10:03 -0800663
Elliott Hughes767a1472011-10-26 18:49:02 -0700664 enum HpifWhen {
665 HPIF_WHEN_NEVER = 0,
666 HPIF_WHEN_NOW = 1,
667 HPIF_WHEN_NEXT_GC = 2,
668 HPIF_WHEN_EVERY_GC = 3
669 };
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700670 static int DdmHandleHpifChunk(HpifWhen when)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700671 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes767a1472011-10-26 18:49:02 -0700672
673 enum HpsgWhen {
674 HPSG_WHEN_NEVER = 0,
675 HPSG_WHEN_EVERY_GC = 1,
676 };
677 enum HpsgWhat {
678 HPSG_WHAT_MERGED_OBJECTS = 0,
679 HPSG_WHAT_DISTINCT_OBJECTS = 1,
680 };
681 static bool DdmHandleHpsgNhsgChunk(HpsgWhen when, HpsgWhat what, bool native);
682
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700683 static void DdmSendHeapInfo(HpifWhen reason)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700684 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700685 static void DdmSendHeapSegments(bool native)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700686 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes545a0642011-11-08 19:10:03 -0800687
Sebastien Hertz6995c602014-09-09 12:10:13 +0200688 static ObjectRegistry* GetObjectRegistry() {
689 return gRegistry;
690 }
691
692 static JDWP::JdwpTag TagFromObject(const ScopedObjectAccessUnchecked& soa, mirror::Object* o)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700693 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz6995c602014-09-09 12:10:13 +0200694
Mathieu Chartier3398c782016-09-30 10:27:43 -0700695 static JDWP::JdwpTypeTag GetTypeTag(ObjPtr<mirror::Class> klass)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700696 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz6995c602014-09-09 12:10:13 +0200697
Mathieu Chartierc7853442015-03-27 14:35:38 -0700698 static JDWP::FieldId ToFieldId(const ArtField* f)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700699 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz6995c602014-09-09 12:10:13 +0200700
Mathieu Chartiere401d142015-04-22 13:56:20 -0700701 static void SetJdwpLocation(JDWP::JdwpLocation* location, ArtMethod* m, uint32_t dex_pc)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700702 REQUIRES_SHARED(Locks::mutator_lock_)
Mathieu Chartier90443472015-07-16 20:32:27 -0700703 REQUIRES(!Locks::thread_list_lock_, !Locks::thread_suspend_count_lock_);
Sebastien Hertz6995c602014-09-09 12:10:13 +0200704
Mathieu Chartierad466ad2015-01-08 16:28:08 -0800705 static JDWP::JdwpState* GetJdwpState();
706
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700707 static uint32_t GetInstrumentationEvents() REQUIRES_SHARED(Locks::mutator_lock_) {
Sebastien Hertz9d6bf692015-04-10 12:12:33 +0200708 return instrumentation_events_;
709 }
710
Andreas Gampe04bbb5b2017-01-19 17:49:03 +0000711 static ThreadLifecycleCallback* GetThreadLifecycleCallback() {
712 return &thread_lifecycle_callback_;
713 }
Andreas Gampe0f01b582017-01-18 15:22:37 -0800714 static ClassLoadCallback* GetClassLoadCallback() {
715 return &class_load_callback_;
716 }
Andreas Gampe04bbb5b2017-01-19 17:49:03 +0000717
Elliott Hughes545a0642011-11-08 19:10:03 -0800718 private:
Sebastien Hertzcbc50642015-06-01 17:33:12 +0200719 static void ExecuteMethodWithoutPendingException(ScopedObjectAccess& soa, DebugInvokeReq* pReq)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700720 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertzcbc50642015-06-01 17:33:12 +0200721
722 static void BuildInvokeReply(JDWP::ExpandBuf* pReply, uint32_t request_id,
723 JDWP::JdwpTag result_tag, uint64_t result_value,
724 JDWP::ObjectId exception)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700725 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertzcbc50642015-06-01 17:33:12 +0200726
Sebastien Hertz8009f392014-09-01 17:07:11 +0200727 static JDWP::JdwpError GetLocalValue(const StackVisitor& visitor,
728 ScopedObjectAccessUnchecked& soa, int slot,
729 JDWP::JdwpTag tag, uint8_t* buf, size_t width)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700730 REQUIRES(!Locks::thread_list_lock_) REQUIRES_SHARED(Locks::mutator_lock_);
Mingyao Yang99170c62015-07-06 11:10:37 -0700731 static JDWP::JdwpError SetLocalValue(Thread* thread, StackVisitor& visitor, int slot,
732 JDWP::JdwpTag tag, uint64_t value, size_t width)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700733 REQUIRES(!Locks::thread_list_lock_) REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz8009f392014-09-01 17:07:11 +0200734
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700735 static void DdmBroadcast(bool connect) REQUIRES_SHARED(Locks::mutator_lock_);
Andreas Gampe04bbb5b2017-01-19 17:49:03 +0000736
737 static void PostThreadStart(Thread* t)
738 REQUIRES_SHARED(Locks::mutator_lock_);
739 static void PostThreadDeath(Thread* t)
740 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700741 static void PostThreadStartOrStop(Thread*, uint32_t)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700742 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughesa2155262011-11-16 16:26:58 -0800743
Andreas Gampe0f01b582017-01-18 15:22:37 -0800744 static void PostClassPrepare(mirror::Class* c)
745 REQUIRES_SHARED(Locks::mutator_lock_);
746
Mathieu Chartiere401d142015-04-22 13:56:20 -0700747 static void PostLocationEvent(ArtMethod* method, int pcOffset,
Sebastien Hertz8379b222014-02-24 17:38:15 +0100748 mirror::Object* thisPtr, int eventFlags,
749 const JValue* return_value)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700750 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz8379b222014-02-24 17:38:15 +0100751
Sebastien Hertz4d25df32014-03-21 17:44:46 +0100752 static void ProcessDeoptimizationRequest(const DeoptimizationRequest& request)
Mathieu Chartieraa516822015-10-02 15:53:37 -0700753 REQUIRES(Locks::mutator_lock_, Roles::uninterruptible_);
Sebastien Hertz4d25df32014-03-21 17:44:46 +0100754
Sebastien Hertz7ec2f1c2014-03-27 20:06:47 +0100755 static void RequestDeoptimizationLocked(const DeoptimizationRequest& req)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700756 REQUIRES(Locks::deoptimization_lock_) REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz7ec2f1c2014-03-27 20:06:47 +0100757
Mathieu Chartiere401d142015-04-22 13:56:20 -0700758 static bool IsForcedInterpreterNeededForCallingImpl(Thread* thread, ArtMethod* m)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700759 REQUIRES_SHARED(Locks::mutator_lock_);
Daniel Mihalyieb076692014-08-22 17:33:31 +0200760
Mathieu Chartiere401d142015-04-22 13:56:20 -0700761 static bool IsForcedInterpreterNeededForResolutionImpl(Thread* thread, ArtMethod* m)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700762 REQUIRES_SHARED(Locks::mutator_lock_);
Daniel Mihalyieb076692014-08-22 17:33:31 +0200763
Mathieu Chartiere401d142015-04-22 13:56:20 -0700764 static bool IsForcedInstrumentationNeededForResolutionImpl(Thread* thread, ArtMethod* m)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700765 REQUIRES_SHARED(Locks::mutator_lock_);
Daniel Mihalyieb076692014-08-22 17:33:31 +0200766
Mathieu Chartiere401d142015-04-22 13:56:20 -0700767 static bool IsForcedInterpreterNeededForUpcallImpl(Thread* thread, ArtMethod* m)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700768 REQUIRES_SHARED(Locks::mutator_lock_);
Daniel Mihalyieb076692014-08-22 17:33:31 +0200769
Sebastien Hertz520633b2015-09-08 17:03:36 +0200770 static bool IsForcedInterpreterNeededForExceptionImpl(Thread* thread)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700771 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz520633b2015-09-08 17:03:36 +0200772
Daniel Mihalyieb076692014-08-22 17:33:31 +0200773 // Indicates whether the debugger is making requests.
774 static bool gDebuggerActive;
775
Sebastien Hertz4e5b2082015-03-24 19:03:40 +0100776 // Indicates whether we should drop the JDWP connection because the runtime stops or the
777 // debugger called VirtualMachine.Dispose.
778 static bool gDisposed;
779
Daniel Mihalyieb076692014-08-22 17:33:31 +0200780 // The registry mapping objects to JDWP ids.
Sebastien Hertz6995c602014-09-09 12:10:13 +0200781 static ObjectRegistry* gRegistry;
782
Sebastien Hertz4d25df32014-03-21 17:44:46 +0100783 // Deoptimization requests to be processed each time the event list is updated. This is used when
784 // registering and unregistering events so we do not deoptimize while holding the event list
785 // lock.
Sebastien Hertz42cd43f2014-05-13 14:15:41 +0200786 // TODO rename to instrumentation_requests.
Brian Carlstrom306db812014-09-05 13:01:41 -0700787 static std::vector<DeoptimizationRequest> deoptimization_requests_ GUARDED_BY(Locks::deoptimization_lock_);
Sebastien Hertz4d25df32014-03-21 17:44:46 +0100788
789 // Count the number of events requiring full deoptimization. When the counter is > 0, everything
790 // is deoptimized, otherwise everything is undeoptimized.
791 // Note: we fully deoptimize on the first event only (when the counter is set to 1). We fully
792 // undeoptimize when the last event is unregistered (when the counter is set to 0).
Brian Carlstrom306db812014-09-05 13:01:41 -0700793 static size_t full_deoptimization_event_count_ GUARDED_BY(Locks::deoptimization_lock_);
Sebastien Hertz4d25df32014-03-21 17:44:46 +0100794
Sebastien Hertz42cd43f2014-05-13 14:15:41 +0200795 static size_t* GetReferenceCounterForEvent(uint32_t instrumentation_event);
796
797 // Instrumentation event reference counters.
798 // TODO we could use an array instead of having all these dedicated counters. Instrumentation
799 // events are bits of a mask so we could convert them to array index.
Brian Carlstrom306db812014-09-05 13:01:41 -0700800 static size_t dex_pc_change_event_ref_count_ GUARDED_BY(Locks::deoptimization_lock_);
801 static size_t method_enter_event_ref_count_ GUARDED_BY(Locks::deoptimization_lock_);
802 static size_t method_exit_event_ref_count_ GUARDED_BY(Locks::deoptimization_lock_);
803 static size_t field_read_event_ref_count_ GUARDED_BY(Locks::deoptimization_lock_);
804 static size_t field_write_event_ref_count_ GUARDED_BY(Locks::deoptimization_lock_);
805 static size_t exception_catch_event_ref_count_ GUARDED_BY(Locks::deoptimization_lock_);
Sebastien Hertz42cd43f2014-05-13 14:15:41 +0200806 static uint32_t instrumentation_events_ GUARDED_BY(Locks::mutator_lock_);
807
Andreas Gampe04bbb5b2017-01-19 17:49:03 +0000808 class DbgThreadLifecycleCallback : public ThreadLifecycleCallback {
809 public:
810 void ThreadStart(Thread* self) OVERRIDE REQUIRES_SHARED(Locks::mutator_lock_);
811 void ThreadDeath(Thread* self) OVERRIDE REQUIRES_SHARED(Locks::mutator_lock_);
812 };
813
Andreas Gampe0f01b582017-01-18 15:22:37 -0800814 class DbgClassLoadCallback : public ClassLoadCallback {
815 public:
816 void ClassLoad(Handle<mirror::Class> klass) OVERRIDE REQUIRES_SHARED(Locks::mutator_lock_);
817 void ClassPrepare(Handle<mirror::Class> temp_klass,
818 Handle<mirror::Class> klass) OVERRIDE REQUIRES_SHARED(Locks::mutator_lock_);
819 };
820
Andreas Gampe04bbb5b2017-01-19 17:49:03 +0000821 static DbgThreadLifecycleCallback thread_lifecycle_callback_;
Andreas Gampe0f01b582017-01-18 15:22:37 -0800822 static DbgClassLoadCallback class_load_callback_;
Andreas Gampe04bbb5b2017-01-19 17:49:03 +0000823
Ian Rogers719d1a32014-03-06 12:13:39 -0800824 DISALLOW_COPY_AND_ASSIGN(Dbg);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700825};
826
827#define CHUNK_TYPE(_name) \
Elliott Hughes82188472011-11-07 18:11:48 -0800828 static_cast<uint32_t>((_name)[0] << 24 | (_name)[1] << 16 | (_name)[2] << 8 | (_name)[3])
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700829
830} // namespace art
831
Brian Carlstromfc0e3212013-07-17 14:40:12 -0700832#endif // ART_RUNTIME_DEBUGGER_H_