blob: a7fd1605df357f428726131af061672e480acfb3 [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_);
Ian Rogersc0542af2014-09-03 16:16:56 -0700291 static JDWP::JdwpError GetSourceFile(JDWP::RefTypeId ref_type_id, std::string* source_file)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700292 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogersc0542af2014-09-03 16:16:56 -0700293 static JDWP::JdwpError GetObjectTag(JDWP::ObjectId object_id, uint8_t* tag)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700294 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughesaed4be92011-12-02 16:16:23 -0800295 static size_t GetTagWidth(JDWP::JdwpTag tag);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700296
Ian Rogersc0542af2014-09-03 16:16:56 -0700297 static JDWP::JdwpError GetArrayLength(JDWP::ObjectId array_id, int32_t* length)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700298 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800299 static JDWP::JdwpError OutputArray(JDWP::ObjectId array_id, int offset, int count,
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700300 JDWP::ExpandBuf* pReply)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700301 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800302 static JDWP::JdwpError SetArrayElements(JDWP::ObjectId array_id, int offset, int count,
Ian Rogersc0542af2014-09-03 16:16:56 -0700303 JDWP::Request* request)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700304 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700305
Sebastien Hertz2c3e77a2015-04-02 16:26:48 +0200306 static JDWP::JdwpError CreateString(const std::string& str, JDWP::ObjectId* new_string_id)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700307 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz2c3e77a2015-04-02 16:26:48 +0200308 static JDWP::JdwpError CreateObject(JDWP::RefTypeId class_id, JDWP::ObjectId* new_object_id)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700309 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800310 static JDWP::JdwpError CreateArrayObject(JDWP::RefTypeId array_class_id, uint32_t length,
Sebastien Hertz2c3e77a2015-04-02 16:26:48 +0200311 JDWP::ObjectId* new_array_id)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700312 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700313
Sebastien Hertz6995c602014-09-09 12:10:13 +0200314 //
315 // Event filtering.
316 //
317 static bool MatchThread(JDWP::ObjectId expected_thread_id, Thread* event_thread)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700318 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz6995c602014-09-09 12:10:13 +0200319
320 static bool MatchLocation(const JDWP::JdwpLocation& expected_location,
321 const JDWP::EventLocation& event_location)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700322 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz6995c602014-09-09 12:10:13 +0200323
Mathieu Chartier3398c782016-09-30 10:27:43 -0700324 static bool MatchType(ObjPtr<mirror::Class> event_class, JDWP::RefTypeId class_id)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700325 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz6995c602014-09-09 12:10:13 +0200326
327 static bool MatchField(JDWP::RefTypeId expected_type_id, JDWP::FieldId expected_field_id,
Mathieu Chartierc7853442015-03-27 14:35:38 -0700328 ArtField* event_field)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700329 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz6995c602014-09-09 12:10:13 +0200330
331 static bool MatchInstance(JDWP::ObjectId expected_instance_id, mirror::Object* event_instance)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700332 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700333
Elliott Hughesec0f83d2013-01-15 16:54:08 -0800334 //
335 // Monitors.
336 //
337 static JDWP::JdwpError GetMonitorInfo(JDWP::ObjectId object_id, JDWP::ExpandBuf* reply)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700338 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughesec0f83d2013-01-15 16:54:08 -0800339 static JDWP::JdwpError GetOwnedMonitors(JDWP::ObjectId thread_id,
Ian Rogersc0542af2014-09-03 16:16:56 -0700340 std::vector<JDWP::ObjectId>* monitors,
341 std::vector<uint32_t>* stack_depths)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700342 REQUIRES(!Locks::thread_list_lock_) REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz52d131d2014-03-13 16:17:40 +0100343 static JDWP::JdwpError GetContendedMonitor(JDWP::ObjectId thread_id,
Ian Rogersc0542af2014-09-03 16:16:56 -0700344 JDWP::ObjectId* contended_monitor)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700345 REQUIRES(!Locks::thread_list_lock_) REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughesec0f83d2013-01-15 16:54:08 -0800346
347 //
348 // Heap.
349 //
350 static JDWP::JdwpError GetInstanceCounts(const std::vector<JDWP::RefTypeId>& class_ids,
Ian Rogersc0542af2014-09-03 16:16:56 -0700351 std::vector<uint64_t>* counts)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700352 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes3b78c942013-01-15 17:35:41 -0800353 static JDWP::JdwpError GetInstances(JDWP::RefTypeId class_id, int32_t max_count,
Ian Rogersc0542af2014-09-03 16:16:56 -0700354 std::vector<JDWP::ObjectId>* instances)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700355 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes0cbaff52013-01-16 15:28:01 -0800356 static JDWP::JdwpError GetReferringObjects(JDWP::ObjectId object_id, int32_t max_count,
Ian Rogersc0542af2014-09-03 16:16:56 -0700357 std::vector<JDWP::ObjectId>* referring_objects)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700358 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes64f574f2013-02-20 14:57:12 -0800359 static JDWP::JdwpError DisableCollection(JDWP::ObjectId object_id)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700360 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes64f574f2013-02-20 14:57:12 -0800361 static JDWP::JdwpError EnableCollection(JDWP::ObjectId object_id)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700362 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogersc0542af2014-09-03 16:16:56 -0700363 static JDWP::JdwpError IsCollected(JDWP::ObjectId object_id, bool* is_collected)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700364 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes64f574f2013-02-20 14:57:12 -0800365 static void DisposeObject(JDWP::ObjectId object_id, uint32_t reference_count)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700366 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughesec0f83d2013-01-15 16:54:08 -0800367
Elliott Hughes9777ba22013-01-17 09:04:19 -0800368 //
369 // Methods and fields.
370 //
Elliott Hughesa96836a2013-01-17 12:27:49 -0800371 static std::string GetMethodName(JDWP::MethodId method_id)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700372 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800373 static JDWP::JdwpError OutputDeclaredFields(JDWP::RefTypeId ref_type_id, bool with_generic,
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700374 JDWP::ExpandBuf* pReply)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700375 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800376 static JDWP::JdwpError OutputDeclaredMethods(JDWP::RefTypeId ref_type_id, bool with_generic,
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700377 JDWP::ExpandBuf* pReply)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700378 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800379 static JDWP::JdwpError OutputDeclaredInterfaces(JDWP::RefTypeId ref_type_id,
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700380 JDWP::ExpandBuf* pReply)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700381 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800382 static void OutputLineTable(JDWP::RefTypeId ref_type_id, JDWP::MethodId method_id,
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700383 JDWP::ExpandBuf* pReply)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700384 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800385 static void OutputVariableTable(JDWP::RefTypeId ref_type_id, JDWP::MethodId id, bool with_generic,
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700386 JDWP::ExpandBuf* pReply)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700387 REQUIRES_SHARED(Locks::mutator_lock_);
Jeff Hao579b0242013-11-18 13:16:49 -0800388 static void OutputMethodReturnValue(JDWP::MethodId method_id, const JValue* return_value,
389 JDWP::ExpandBuf* pReply)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700390 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz3f52eaf2014-04-04 17:50:18 +0200391 static void OutputFieldValue(JDWP::FieldId field_id, const JValue* field_value,
392 JDWP::ExpandBuf* pReply)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700393 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes9777ba22013-01-17 09:04:19 -0800394 static JDWP::JdwpError GetBytecodes(JDWP::RefTypeId class_id, JDWP::MethodId method_id,
Ian Rogersc0542af2014-09-03 16:16:56 -0700395 std::vector<uint8_t>* bytecodes)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700396 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700397
Elliott Hughesa96836a2013-01-17 12:27:49 -0800398 static std::string GetFieldName(JDWP::FieldId field_id)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700399 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800400 static JDWP::JdwpTag GetFieldBasicTag(JDWP::FieldId field_id)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700401 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800402 static JDWP::JdwpTag GetStaticFieldBasicTag(JDWP::FieldId field_id)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700403 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800404 static JDWP::JdwpError GetFieldValue(JDWP::ObjectId object_id, JDWP::FieldId field_id,
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700405 JDWP::ExpandBuf* pReply)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700406 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800407 static JDWP::JdwpError SetFieldValue(JDWP::ObjectId object_id, JDWP::FieldId field_id,
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700408 uint64_t value, int width)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700409 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800410 static JDWP::JdwpError GetStaticFieldValue(JDWP::RefTypeId ref_type_id, JDWP::FieldId field_id,
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700411 JDWP::ExpandBuf* pReply)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700412 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800413 static JDWP::JdwpError SetStaticFieldValue(JDWP::FieldId field_id, uint64_t value, int width)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700414 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700415
Sebastien Hertzb0b0b492014-09-15 11:27:27 +0200416 static JDWP::JdwpError StringToUtf8(JDWP::ObjectId string_id, std::string* str)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700417 REQUIRES_SHARED(Locks::mutator_lock_);
Jeff Hao579b0242013-11-18 13:16:49 -0800418 static void OutputJValue(JDWP::JdwpTag tag, const JValue* return_value, JDWP::ExpandBuf* pReply)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700419 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700420
421 /*
422 * Thread, ThreadGroup, Frame
423 */
Ian Rogersc0542af2014-09-03 16:16:56 -0700424 static JDWP::JdwpError GetThreadName(JDWP::ObjectId thread_id, std::string* name)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700425 REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Locks::thread_list_lock_);
Sebastien Hertz52d131d2014-03-13 16:17:40 +0100426 static JDWP::JdwpError GetThreadGroup(JDWP::ObjectId thread_id, JDWP::ExpandBuf* pReply)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700427 REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Locks::thread_list_lock_);
Sebastien Hertza06430c2014-09-15 19:21:30 +0200428 static JDWP::JdwpError GetThreadGroupName(JDWP::ObjectId thread_group_id,
429 JDWP::ExpandBuf* pReply)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700430 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertza06430c2014-09-15 19:21:30 +0200431 static JDWP::JdwpError GetThreadGroupParent(JDWP::ObjectId thread_group_id,
432 JDWP::ExpandBuf* pReply)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700433 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertza06430c2014-09-15 19:21:30 +0200434 static JDWP::JdwpError GetThreadGroupChildren(JDWP::ObjectId thread_group_id,
435 JDWP::ExpandBuf* pReply)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700436 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700437 static JDWP::ObjectId GetSystemThreadGroupId()
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700438 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700439
Jeff Hao920af3e2013-08-28 15:46:38 -0700440 static JDWP::JdwpThreadStatus ToJdwpThreadStatus(ThreadState state);
Sebastien Hertz52d131d2014-03-13 16:17:40 +0100441 static JDWP::JdwpError GetThreadStatus(JDWP::ObjectId thread_id,
442 JDWP::JdwpThreadStatus* pThreadStatus,
443 JDWP::JdwpSuspendStatus* pSuspendStatus)
Mathieu Chartier90443472015-07-16 20:32:27 -0700444 REQUIRES(!Locks::thread_list_lock_);
Sebastien Hertz52d131d2014-03-13 16:17:40 +0100445 static JDWP::JdwpError GetThreadDebugSuspendCount(JDWP::ObjectId thread_id,
446 JDWP::ExpandBuf* pReply)
Mathieu Chartier90443472015-07-16 20:32:27 -0700447 REQUIRES(!Locks::thread_list_lock_, !Locks::thread_suspend_count_lock_);
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700448 // static void WaitForSuspend(JDWP::ObjectId thread_id);
Elliott Hughescaf76542012-06-28 16:08:22 -0700449
Elliott Hughes026b1462012-06-28 20:43:49 -0700450 // Fills 'thread_ids' with the threads in the given thread group. If thread_group_id == 0,
Elliott Hughescaf76542012-06-28 16:08:22 -0700451 // returns all threads.
Sebastien Hertza06430c2014-09-15 19:21:30 +0200452 static void GetThreads(mirror::Object* thread_group, std::vector<JDWP::ObjectId>* thread_ids)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700453 REQUIRES(!Locks::thread_list_lock_) REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughescaf76542012-06-28 16:08:22 -0700454
Ian Rogersc0542af2014-09-03 16:16:56 -0700455 static JDWP::JdwpError GetThreadFrameCount(JDWP::ObjectId thread_id, size_t* result)
Mathieu Chartier90443472015-07-16 20:32:27 -0700456 REQUIRES(!Locks::thread_list_lock_);
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700457 static JDWP::JdwpError GetThreadFrames(JDWP::ObjectId thread_id, size_t start_frame,
458 size_t frame_count, JDWP::ExpandBuf* buf)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700459 REQUIRES(!Locks::thread_list_lock_) REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700460
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700461 static JDWP::ObjectId GetThreadSelfId() REQUIRES_SHARED(Locks::mutator_lock_);
462 static JDWP::ObjectId GetThreadId(Thread* thread) REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz6995c602014-09-09 12:10:13 +0200463
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700464 static void SuspendVM()
Mathieu Chartier90443472015-07-16 20:32:27 -0700465 REQUIRES(!Locks::thread_list_lock_, !Locks::thread_suspend_count_lock_);
Sebastien Hertz253fa552014-10-14 17:27:15 +0200466 static void ResumeVM()
Mathieu Chartier90443472015-07-16 20:32:27 -0700467 REQUIRES(!Locks::thread_list_lock_, !Locks::thread_suspend_count_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800468 static JDWP::JdwpError SuspendThread(JDWP::ObjectId thread_id, bool request_suspension = true)
Mathieu Chartier90443472015-07-16 20:32:27 -0700469 REQUIRES(!Locks::mutator_lock_, !Locks::thread_list_lock_,
470 !Locks::thread_suspend_count_lock_);
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700471
Elliott Hughes88d63092013-01-09 09:55:54 -0800472 static void ResumeThread(JDWP::ObjectId thread_id)
Mathieu Chartier90443472015-07-16 20:32:27 -0700473 REQUIRES(!Locks::thread_list_lock_, !Locks::thread_suspend_count_lock_)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700474 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700475 static void SuspendSelf();
476
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700477 static JDWP::JdwpError GetThisObject(JDWP::ObjectId thread_id, JDWP::FrameId frame_id,
478 JDWP::ObjectId* result)
Mathieu Chartier90443472015-07-16 20:32:27 -0700479 REQUIRES(!Locks::thread_list_lock_, !Locks::thread_suspend_count_lock_)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700480 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz8009f392014-09-01 17:07:11 +0200481 static JDWP::JdwpError GetLocalValues(JDWP::Request* request, JDWP::ExpandBuf* pReply)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700482 REQUIRES(!Locks::thread_list_lock_) REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz8009f392014-09-01 17:07:11 +0200483 static JDWP::JdwpError SetLocalValues(JDWP::Request* request)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700484 REQUIRES(!Locks::thread_list_lock_) REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700485
Sebastien Hertz52d131d2014-03-13 16:17:40 +0100486 static JDWP::JdwpError Interrupt(JDWP::ObjectId thread_id)
Mathieu Chartier90443472015-07-16 20:32:27 -0700487 REQUIRES(!Locks::thread_list_lock_);
Elliott Hughesf9501702013-01-11 11:22:27 -0800488
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700489 /*
490 * Debugger notification
491 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700492 enum EventFlag {
Elliott Hughes86964332012-02-15 19:37:42 -0800493 kBreakpoint = 0x01,
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700494 kSingleStep = 0x02,
495 kMethodEntry = 0x04,
496 kMethodExit = 0x08,
497 };
Mathieu Chartiere401d142015-04-22 13:56:20 -0700498 static void PostFieldAccessEvent(ArtMethod* m, int dex_pc, mirror::Object* this_object,
Mathieu Chartierc7853442015-03-27 14:35:38 -0700499 ArtField* f)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700500 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartiere401d142015-04-22 13:56:20 -0700501 static void PostFieldModificationEvent(ArtMethod* m, int dex_pc,
Mathieu Chartierc7853442015-03-27 14:35:38 -0700502 mirror::Object* this_object, ArtField* f,
Sebastien Hertz3f52eaf2014-04-04 17:50:18 +0200503 const JValue* field_value)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700504 REQUIRES_SHARED(Locks::mutator_lock_);
Nicolas Geoffray14691c52015-03-05 10:40:17 +0000505 static void PostException(mirror::Throwable* exception)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700506 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700507
Ian Rogers62d6c772013-02-27 08:32:07 -0800508 static void UpdateDebugger(Thread* thread, mirror::Object* this_object,
Mathieu Chartiere401d142015-04-22 13:56:20 -0700509 ArtMethod* method, uint32_t new_dex_pc,
Sebastien Hertz8379b222014-02-24 17:38:15 +0100510 int event_flags, const JValue* return_value)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700511 REQUIRES(!Locks::breakpoint_lock_) REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes91bf6cd2012-02-14 17:27:48 -0800512
Sebastien Hertzf3928792014-11-17 19:00:37 +0100513 // Indicates whether we need deoptimization for debugging.
514 static bool RequiresDeoptimization();
515
Sebastien Hertz4d25df32014-03-21 17:44:46 +0100516 // Records deoptimization request in the queue.
517 static void RequestDeoptimization(const DeoptimizationRequest& req)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700518 REQUIRES(!Locks::deoptimization_lock_) REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz138dbfc2013-12-04 18:15:25 +0100519
Sebastien Hertz4d25df32014-03-21 17:44:46 +0100520 // Manage deoptimization after updating JDWP events list. Suspends all threads, processes each
521 // request and finally resumes all threads.
Sebastien Hertz138dbfc2013-12-04 18:15:25 +0100522 static void ManageDeoptimization()
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
525 // Breakpoints.
Sebastien Hertz4d25df32014-03-21 17:44:46 +0100526 static void WatchLocation(const JDWP::JdwpLocation* pLoc, DeoptimizationRequest* req)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700527 REQUIRES(!Locks::breakpoint_lock_) REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz4d25df32014-03-21 17:44:46 +0100528 static void UnwatchLocation(const JDWP::JdwpLocation* pLoc, DeoptimizationRequest* req)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700529 REQUIRES(!Locks::breakpoint_lock_) REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz138dbfc2013-12-04 18:15:25 +0100530
Daniel Mihalyieb076692014-08-22 17:33:31 +0200531 /*
532 * Forced interpreter checkers for single-step and continue support.
533 */
534
535 // Indicates whether we need to force the use of interpreter to invoke a method.
536 // This allows to single-step or continue into the called method.
Mathieu Chartiere401d142015-04-22 13:56:20 -0700537 static bool IsForcedInterpreterNeededForCalling(Thread* thread, ArtMethod* m)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700538 REQUIRES_SHARED(Locks::mutator_lock_) {
Daniel Mihalyieb076692014-08-22 17:33:31 +0200539 if (!IsDebuggerActive()) {
540 return false;
541 }
542 return IsForcedInterpreterNeededForCallingImpl(thread, m);
543 }
544
545 // Indicates whether we need to force the use of interpreter entrypoint when calling a
546 // method through the resolution trampoline. This allows to single-step or continue into
547 // the called method.
Mathieu Chartiere401d142015-04-22 13:56:20 -0700548 static bool IsForcedInterpreterNeededForResolution(Thread* thread, ArtMethod* m)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700549 REQUIRES_SHARED(Locks::mutator_lock_) {
Daniel Mihalyieb076692014-08-22 17:33:31 +0200550 if (!IsDebuggerActive()) {
551 return false;
552 }
553 return IsForcedInterpreterNeededForResolutionImpl(thread, m);
554 }
555
556 // Indicates whether we need to force the use of instrumentation entrypoint when calling
557 // a method through the resolution trampoline. This allows to deoptimize the stack for
558 // debugging when we returned from the called method.
Mathieu Chartiere401d142015-04-22 13:56:20 -0700559 static bool IsForcedInstrumentationNeededForResolution(Thread* thread, ArtMethod* m)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700560 REQUIRES_SHARED(Locks::mutator_lock_) {
Daniel Mihalyieb076692014-08-22 17:33:31 +0200561 if (!IsDebuggerActive()) {
562 return false;
563 }
564 return IsForcedInstrumentationNeededForResolutionImpl(thread, m);
565 }
566
567 // Indicates whether we need to force the use of interpreter when returning from the
568 // interpreter into the runtime. This allows to deoptimize the stack and continue
569 // execution with interpreter for debugging.
Mathieu Chartiere401d142015-04-22 13:56:20 -0700570 static bool IsForcedInterpreterNeededForUpcall(Thread* thread, ArtMethod* m)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700571 REQUIRES_SHARED(Locks::mutator_lock_) {
Mingyao Yang99170c62015-07-06 11:10:37 -0700572 if (!IsDebuggerActive() && !thread->HasDebuggerShadowFrames()) {
Daniel Mihalyieb076692014-08-22 17:33:31 +0200573 return false;
574 }
575 return IsForcedInterpreterNeededForUpcallImpl(thread, m);
576 }
577
Sebastien Hertz520633b2015-09-08 17:03:36 +0200578 // Indicates whether we need to force the use of interpreter when handling an
579 // exception. This allows to deoptimize the stack and continue execution with
580 // the interpreter.
581 // Note: the interpreter will start by handling the exception when executing
582 // the deoptimized frames.
583 static bool IsForcedInterpreterNeededForException(Thread* thread)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700584 REQUIRES_SHARED(Locks::mutator_lock_) {
Mingyao Yang99170c62015-07-06 11:10:37 -0700585 if (!IsDebuggerActive() && !thread->HasDebuggerShadowFrames()) {
Sebastien Hertz520633b2015-09-08 17:03:36 +0200586 return false;
587 }
588 return IsForcedInterpreterNeededForExceptionImpl(thread);
589 }
590
Sebastien Hertz138dbfc2013-12-04 18:15:25 +0100591 // Single-stepping.
Elliott Hughes88d63092013-01-09 09:55:54 -0800592 static JDWP::JdwpError ConfigureStep(JDWP::ObjectId thread_id, JDWP::JdwpStepSize size,
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700593 JDWP::JdwpStepDepth depth)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700594 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz61b7f1b2013-11-15 15:59:30 +0100595 static void UnconfigureStep(JDWP::ObjectId thread_id)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700596 REQUIRES(!Locks::thread_list_lock_) REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700597
Sebastien Hertzcbc50642015-06-01 17:33:12 +0200598 /*
599 * Invoke support
600 */
601
602 // Called by the JDWP thread to prepare invocation in the event thread (suspended on an event).
603 // If the information sent by the debugger is incorrect, it will send a reply with the
604 // appropriate error code. Otherwise, it will attach a DebugInvokeReq object to the event thread
605 // and resume it (and possibly other threads depending on the invoke options).
606 // Unlike other commands, the JDWP thread will not send the reply to the debugger (see
607 // JdwpState::ProcessRequest). The reply will be sent by the event thread itself after method
608 // invocation completes (see FinishInvokeMethod). This is required to allow the JDWP thread to
609 // process incoming commands from the debugger while the invocation is still in progress in the
610 // event thread, especially if it gets suspended by a debug event occurring in another thread.
611 static JDWP::JdwpError PrepareInvokeMethod(uint32_t request_id, JDWP::ObjectId thread_id,
612 JDWP::ObjectId object_id, JDWP::RefTypeId class_id,
613 JDWP::MethodId method_id, uint32_t arg_count,
614 uint64_t arg_values[], JDWP::JdwpTag* arg_types,
615 uint32_t options)
Mathieu Chartier90443472015-07-16 20:32:27 -0700616 REQUIRES(!Locks::thread_list_lock_, !Locks::thread_suspend_count_lock_)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700617 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertzcbc50642015-06-01 17:33:12 +0200618
619 // Called by the event thread to execute a method prepared by the JDWP thread in the given
620 // DebugInvokeReq object. Once the invocation completes, the event thread attaches a reply
621 // to that DebugInvokeReq object so it can be sent to the debugger only when the event thread
622 // is ready to suspend (see FinishInvokeMethod).
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700623 static void ExecuteMethod(DebugInvokeReq* pReq);
624
Sebastien Hertzcbc50642015-06-01 17:33:12 +0200625 // Called by the event thread to send the reply of the invoke (created in ExecuteMethod)
626 // before suspending itself. This is to ensure the thread is ready to suspend before the
627 // debugger receives the reply.
628 static void FinishInvokeMethod(DebugInvokeReq* pReq);
629
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700630 /*
631 * DDM support.
632 */
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700633 static void DdmSendThreadNotification(Thread* t, uint32_t type)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700634 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz52d131d2014-03-13 16:17:40 +0100635 static void DdmSetThreadNotification(bool enable)
Mathieu Chartier90443472015-07-16 20:32:27 -0700636 REQUIRES(!Locks::thread_list_lock_);
Ian Rogersc0542af2014-09-03 16:16:56 -0700637 static bool DdmHandlePacket(JDWP::Request* request, uint8_t** pReplyBuf, int* pReplyLen);
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700638 static void DdmConnected() REQUIRES_SHARED(Locks::mutator_lock_);
639 static void DdmDisconnected() REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700640 static void DdmSendChunk(uint32_t type, const std::vector<uint8_t>& bytes)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700641 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700642 static void DdmSendChunk(uint32_t type, size_t len, const uint8_t* buf)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700643 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700644 static void DdmSendChunkV(uint32_t type, const iovec* iov, int iov_count)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700645 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes767a1472011-10-26 18:49:02 -0700646
Mathieu Chartiera6b1ead2015-10-06 10:32:38 -0700647 // Visit breakpoint roots, used to prevent unloading of methods with breakpoints.
Mathieu Chartierbb87e0f2015-04-03 11:21:55 -0700648 static void VisitRoots(RootVisitor* visitor)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700649 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartier3b05e9b2014-03-25 09:29:43 -0700650
Elliott Hughes545a0642011-11-08 19:10:03 -0800651 /*
Man Cao8c2ff642015-05-27 17:25:30 -0700652 * Allocation tracking support.
Elliott Hughes545a0642011-11-08 19:10:03 -0800653 */
Mathieu Chartier90443472015-07-16 20:32:27 -0700654 static void SetAllocTrackingEnabled(bool enabled) REQUIRES(!Locks::alloc_tracker_lock_);
Sebastien Hertz52d131d2014-03-13 16:17:40 +0100655 static jbyteArray GetRecentAllocations()
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700656 REQUIRES(!Locks::alloc_tracker_lock_) REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartier90443472015-07-16 20:32:27 -0700657 static void DumpRecentAllocations() REQUIRES(!Locks::alloc_tracker_lock_);
Elliott Hughes545a0642011-11-08 19:10:03 -0800658
Elliott Hughes767a1472011-10-26 18:49:02 -0700659 enum HpifWhen {
660 HPIF_WHEN_NEVER = 0,
661 HPIF_WHEN_NOW = 1,
662 HPIF_WHEN_NEXT_GC = 2,
663 HPIF_WHEN_EVERY_GC = 3
664 };
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700665 static int DdmHandleHpifChunk(HpifWhen when)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700666 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes767a1472011-10-26 18:49:02 -0700667
668 enum HpsgWhen {
669 HPSG_WHEN_NEVER = 0,
670 HPSG_WHEN_EVERY_GC = 1,
671 };
672 enum HpsgWhat {
673 HPSG_WHAT_MERGED_OBJECTS = 0,
674 HPSG_WHAT_DISTINCT_OBJECTS = 1,
675 };
676 static bool DdmHandleHpsgNhsgChunk(HpsgWhen when, HpsgWhat what, bool native);
677
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700678 static void DdmSendHeapInfo(HpifWhen reason)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700679 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700680 static void DdmSendHeapSegments(bool native)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700681 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes545a0642011-11-08 19:10:03 -0800682
Sebastien Hertz6995c602014-09-09 12:10:13 +0200683 static ObjectRegistry* GetObjectRegistry() {
684 return gRegistry;
685 }
686
687 static JDWP::JdwpTag TagFromObject(const ScopedObjectAccessUnchecked& soa, mirror::Object* o)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700688 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz6995c602014-09-09 12:10:13 +0200689
Mathieu Chartier3398c782016-09-30 10:27:43 -0700690 static JDWP::JdwpTypeTag GetTypeTag(ObjPtr<mirror::Class> klass)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700691 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz6995c602014-09-09 12:10:13 +0200692
Mathieu Chartierc7853442015-03-27 14:35:38 -0700693 static JDWP::FieldId ToFieldId(const ArtField* f)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700694 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz6995c602014-09-09 12:10:13 +0200695
Mathieu Chartiere401d142015-04-22 13:56:20 -0700696 static void SetJdwpLocation(JDWP::JdwpLocation* location, ArtMethod* m, uint32_t dex_pc)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700697 REQUIRES_SHARED(Locks::mutator_lock_)
Mathieu Chartier90443472015-07-16 20:32:27 -0700698 REQUIRES(!Locks::thread_list_lock_, !Locks::thread_suspend_count_lock_);
Sebastien Hertz6995c602014-09-09 12:10:13 +0200699
Mathieu Chartierad466ad2015-01-08 16:28:08 -0800700 static JDWP::JdwpState* GetJdwpState();
701
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700702 static uint32_t GetInstrumentationEvents() REQUIRES_SHARED(Locks::mutator_lock_) {
Sebastien Hertz9d6bf692015-04-10 12:12:33 +0200703 return instrumentation_events_;
704 }
705
Andreas Gampe04bbb5b2017-01-19 17:49:03 +0000706 static ThreadLifecycleCallback* GetThreadLifecycleCallback() {
707 return &thread_lifecycle_callback_;
708 }
Andreas Gampe0f01b582017-01-18 15:22:37 -0800709 static ClassLoadCallback* GetClassLoadCallback() {
710 return &class_load_callback_;
711 }
Andreas Gampe04bbb5b2017-01-19 17:49:03 +0000712
Elliott Hughes545a0642011-11-08 19:10:03 -0800713 private:
Sebastien Hertzcbc50642015-06-01 17:33:12 +0200714 static void ExecuteMethodWithoutPendingException(ScopedObjectAccess& soa, DebugInvokeReq* pReq)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700715 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertzcbc50642015-06-01 17:33:12 +0200716
717 static void BuildInvokeReply(JDWP::ExpandBuf* pReply, uint32_t request_id,
718 JDWP::JdwpTag result_tag, uint64_t result_value,
719 JDWP::ObjectId exception)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700720 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertzcbc50642015-06-01 17:33:12 +0200721
Sebastien Hertz8009f392014-09-01 17:07:11 +0200722 static JDWP::JdwpError GetLocalValue(const StackVisitor& visitor,
723 ScopedObjectAccessUnchecked& soa, int slot,
724 JDWP::JdwpTag tag, uint8_t* buf, size_t width)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700725 REQUIRES(!Locks::thread_list_lock_) REQUIRES_SHARED(Locks::mutator_lock_);
Mingyao Yang99170c62015-07-06 11:10:37 -0700726 static JDWP::JdwpError SetLocalValue(Thread* thread, StackVisitor& visitor, int slot,
727 JDWP::JdwpTag tag, uint64_t value, size_t width)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700728 REQUIRES(!Locks::thread_list_lock_) REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz8009f392014-09-01 17:07:11 +0200729
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700730 static void DdmBroadcast(bool connect) REQUIRES_SHARED(Locks::mutator_lock_);
Andreas Gampe04bbb5b2017-01-19 17:49:03 +0000731
732 static void PostThreadStart(Thread* t)
733 REQUIRES_SHARED(Locks::mutator_lock_);
734 static void PostThreadDeath(Thread* t)
735 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700736 static void PostThreadStartOrStop(Thread*, uint32_t)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700737 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughesa2155262011-11-16 16:26:58 -0800738
Andreas Gampe0f01b582017-01-18 15:22:37 -0800739 static void PostClassPrepare(mirror::Class* c)
740 REQUIRES_SHARED(Locks::mutator_lock_);
741
Mathieu Chartiere401d142015-04-22 13:56:20 -0700742 static void PostLocationEvent(ArtMethod* method, int pcOffset,
Sebastien Hertz8379b222014-02-24 17:38:15 +0100743 mirror::Object* thisPtr, int eventFlags,
744 const JValue* return_value)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700745 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz8379b222014-02-24 17:38:15 +0100746
Sebastien Hertz4d25df32014-03-21 17:44:46 +0100747 static void ProcessDeoptimizationRequest(const DeoptimizationRequest& request)
Mathieu Chartieraa516822015-10-02 15:53:37 -0700748 REQUIRES(Locks::mutator_lock_, Roles::uninterruptible_);
Sebastien Hertz4d25df32014-03-21 17:44:46 +0100749
Sebastien Hertz7ec2f1c2014-03-27 20:06:47 +0100750 static void RequestDeoptimizationLocked(const DeoptimizationRequest& req)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700751 REQUIRES(Locks::deoptimization_lock_) REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz7ec2f1c2014-03-27 20:06:47 +0100752
Mathieu Chartiere401d142015-04-22 13:56:20 -0700753 static bool IsForcedInterpreterNeededForCallingImpl(Thread* thread, ArtMethod* m)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700754 REQUIRES_SHARED(Locks::mutator_lock_);
Daniel Mihalyieb076692014-08-22 17:33:31 +0200755
Mathieu Chartiere401d142015-04-22 13:56:20 -0700756 static bool IsForcedInterpreterNeededForResolutionImpl(Thread* thread, ArtMethod* m)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700757 REQUIRES_SHARED(Locks::mutator_lock_);
Daniel Mihalyieb076692014-08-22 17:33:31 +0200758
Mathieu Chartiere401d142015-04-22 13:56:20 -0700759 static bool IsForcedInstrumentationNeededForResolutionImpl(Thread* thread, ArtMethod* m)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700760 REQUIRES_SHARED(Locks::mutator_lock_);
Daniel Mihalyieb076692014-08-22 17:33:31 +0200761
Mathieu Chartiere401d142015-04-22 13:56:20 -0700762 static bool IsForcedInterpreterNeededForUpcallImpl(Thread* thread, ArtMethod* m)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700763 REQUIRES_SHARED(Locks::mutator_lock_);
Daniel Mihalyieb076692014-08-22 17:33:31 +0200764
Sebastien Hertz520633b2015-09-08 17:03:36 +0200765 static bool IsForcedInterpreterNeededForExceptionImpl(Thread* thread)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700766 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz520633b2015-09-08 17:03:36 +0200767
Daniel Mihalyieb076692014-08-22 17:33:31 +0200768 // Indicates whether the debugger is making requests.
769 static bool gDebuggerActive;
770
Sebastien Hertz4e5b2082015-03-24 19:03:40 +0100771 // Indicates whether we should drop the JDWP connection because the runtime stops or the
772 // debugger called VirtualMachine.Dispose.
773 static bool gDisposed;
774
Daniel Mihalyieb076692014-08-22 17:33:31 +0200775 // The registry mapping objects to JDWP ids.
Sebastien Hertz6995c602014-09-09 12:10:13 +0200776 static ObjectRegistry* gRegistry;
777
Sebastien Hertz4d25df32014-03-21 17:44:46 +0100778 // Deoptimization requests to be processed each time the event list is updated. This is used when
779 // registering and unregistering events so we do not deoptimize while holding the event list
780 // lock.
Sebastien Hertz42cd43f2014-05-13 14:15:41 +0200781 // TODO rename to instrumentation_requests.
Brian Carlstrom306db812014-09-05 13:01:41 -0700782 static std::vector<DeoptimizationRequest> deoptimization_requests_ GUARDED_BY(Locks::deoptimization_lock_);
Sebastien Hertz4d25df32014-03-21 17:44:46 +0100783
784 // Count the number of events requiring full deoptimization. When the counter is > 0, everything
785 // is deoptimized, otherwise everything is undeoptimized.
786 // Note: we fully deoptimize on the first event only (when the counter is set to 1). We fully
787 // undeoptimize when the last event is unregistered (when the counter is set to 0).
Brian Carlstrom306db812014-09-05 13:01:41 -0700788 static size_t full_deoptimization_event_count_ GUARDED_BY(Locks::deoptimization_lock_);
Sebastien Hertz4d25df32014-03-21 17:44:46 +0100789
Sebastien Hertz42cd43f2014-05-13 14:15:41 +0200790 static size_t* GetReferenceCounterForEvent(uint32_t instrumentation_event);
791
792 // Instrumentation event reference counters.
793 // TODO we could use an array instead of having all these dedicated counters. Instrumentation
794 // events are bits of a mask so we could convert them to array index.
Brian Carlstrom306db812014-09-05 13:01:41 -0700795 static size_t dex_pc_change_event_ref_count_ GUARDED_BY(Locks::deoptimization_lock_);
796 static size_t method_enter_event_ref_count_ GUARDED_BY(Locks::deoptimization_lock_);
797 static size_t method_exit_event_ref_count_ GUARDED_BY(Locks::deoptimization_lock_);
798 static size_t field_read_event_ref_count_ GUARDED_BY(Locks::deoptimization_lock_);
799 static size_t field_write_event_ref_count_ GUARDED_BY(Locks::deoptimization_lock_);
800 static size_t exception_catch_event_ref_count_ GUARDED_BY(Locks::deoptimization_lock_);
Sebastien Hertz42cd43f2014-05-13 14:15:41 +0200801 static uint32_t instrumentation_events_ GUARDED_BY(Locks::mutator_lock_);
802
Andreas Gampe04bbb5b2017-01-19 17:49:03 +0000803 class DbgThreadLifecycleCallback : public ThreadLifecycleCallback {
804 public:
805 void ThreadStart(Thread* self) OVERRIDE REQUIRES_SHARED(Locks::mutator_lock_);
806 void ThreadDeath(Thread* self) OVERRIDE REQUIRES_SHARED(Locks::mutator_lock_);
807 };
808
Andreas Gampe0f01b582017-01-18 15:22:37 -0800809 class DbgClassLoadCallback : public ClassLoadCallback {
810 public:
811 void ClassLoad(Handle<mirror::Class> klass) OVERRIDE REQUIRES_SHARED(Locks::mutator_lock_);
812 void ClassPrepare(Handle<mirror::Class> temp_klass,
813 Handle<mirror::Class> klass) OVERRIDE REQUIRES_SHARED(Locks::mutator_lock_);
814 };
815
Andreas Gampe04bbb5b2017-01-19 17:49:03 +0000816 static DbgThreadLifecycleCallback thread_lifecycle_callback_;
Andreas Gampe0f01b582017-01-18 15:22:37 -0800817 static DbgClassLoadCallback class_load_callback_;
Andreas Gampe04bbb5b2017-01-19 17:49:03 +0000818
Ian Rogers719d1a32014-03-06 12:13:39 -0800819 DISALLOW_COPY_AND_ASSIGN(Dbg);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700820};
821
822#define CHUNK_TYPE(_name) \
Elliott Hughes82188472011-11-07 18:11:48 -0800823 static_cast<uint32_t>((_name)[0] << 24 | (_name)[1] << 16 | (_name)[2] << 8 | (_name)[3])
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700824
825} // namespace art
826
Brian Carlstromfc0e3212013-07-17 14:40:12 -0700827#endif // ART_RUNTIME_DEBUGGER_H_