blob: 3b4a5e16b0a73b0744fe9b2cddc2f65949effadf [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"
Elliott Hughes872d4ec2011-10-21 17:07:15 -070031#include "jdwp/jdwp.h"
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080032#include "jni.h"
33#include "jvalue.h"
Mathieu Chartier3398c782016-09-30 10:27:43 -070034#include "obj_ptr.h"
Mingyao Yang99170c62015-07-06 11:10:37 -070035#include "thread.h"
Jeff Hao920af3e2013-08-28 15:46:38 -070036#include "thread_state.h"
Elliott Hughes872d4ec2011-10-21 17:07:15 -070037
38namespace art {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080039namespace mirror {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080040class Class;
41class Object;
42class Throwable;
43} // namespace mirror
Mathieu Chartierc7853442015-03-27 14:35:38 -070044class ArtField;
Mathieu Chartiere401d142015-04-22 13:56:20 -070045class ArtMethod;
Sebastien Hertz6995c602014-09-09 12:10:13 +020046class ObjectRegistry;
Sebastien Hertzcbc50642015-06-01 17:33:12 +020047class ScopedObjectAccess;
Sebastien Hertz6995c602014-09-09 12:10:13 +020048class ScopedObjectAccessUnchecked;
Sebastien Hertz8009f392014-09-01 17:07:11 +020049class StackVisitor;
Ian Rogers1b09b092012-08-20 15:35:52 -070050class Thread;
Elliott Hughes872d4ec2011-10-21 17:07:15 -070051
52/*
53 * Invoke-during-breakpoint support.
54 */
55struct DebugInvokeReq {
Sebastien Hertzcbc50642015-06-01 17:33:12 +020056 DebugInvokeReq(uint32_t invoke_request_id, JDWP::ObjectId invoke_thread_id,
57 mirror::Object* invoke_receiver, mirror::Class* invoke_class,
Mathieu Chartiere401d142015-04-22 13:56:20 -070058 ArtMethod* invoke_method, uint32_t invoke_options,
Sebastien Hertzcbc50642015-06-01 17:33:12 +020059 uint64_t args[], uint32_t args_count)
60 : request_id(invoke_request_id), thread_id(invoke_thread_id), receiver(invoke_receiver),
61 klass(invoke_class), method(invoke_method), arg_count(args_count), arg_values(args),
62 options(invoke_options), reply(JDWP::expandBufAlloc()) {
Elliott Hughes475fc232011-10-25 15:00:35 -070063 }
64
Sebastien Hertzcbc50642015-06-01 17:33:12 +020065 ~DebugInvokeReq() {
66 JDWP::expandBufFree(reply);
67 }
68
69 // Request
70 const uint32_t request_id;
71 const JDWP::ObjectId thread_id;
72 GcRoot<mirror::Object> receiver; // not used for ClassType.InvokeMethod.
Sebastien Hertz1558b572015-02-25 15:05:59 +010073 GcRoot<mirror::Class> klass;
Sebastien Hertzcbc50642015-06-01 17:33:12 +020074 ArtMethod* const method;
Sebastien Hertz1558b572015-02-25 15:05:59 +010075 const uint32_t arg_count;
Sebastien Hertzcbc50642015-06-01 17:33:12 +020076 std::unique_ptr<uint64_t[]> arg_values; // will be null if arg_count_ == 0. We take ownership
77 // of this array so we must delete it upon destruction.
Sebastien Hertz1558b572015-02-25 15:05:59 +010078 const uint32_t options;
Elliott Hughes872d4ec2011-10-21 17:07:15 -070079
Sebastien Hertzcbc50642015-06-01 17:33:12 +020080 // Reply
81 JDWP::ExpandBuf* const reply;
Sebastien Hertz61b7f1b2013-11-15 15:59:30 +010082
Mathieu Chartierbb87e0f2015-04-03 11:21:55 -070083 void VisitRoots(RootVisitor* visitor, const RootInfo& root_info)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -070084 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartier3b05e9b2014-03-25 09:29:43 -070085
Sebastien Hertz61b7f1b2013-11-15 15:59:30 +010086 private:
87 DISALLOW_COPY_AND_ASSIGN(DebugInvokeReq);
88};
89
90// Thread local data-structure that holds fields for controlling single-stepping.
Sebastien Hertz597c4f02015-01-26 17:37:14 +010091class SingleStepControl {
92 public:
93 SingleStepControl(JDWP::JdwpStepSize step_size, JDWP::JdwpStepDepth step_depth,
Mathieu Chartiere401d142015-04-22 13:56:20 -070094 int stack_depth, ArtMethod* method)
Sebastien Hertz597c4f02015-01-26 17:37:14 +010095 : step_size_(step_size), step_depth_(step_depth),
96 stack_depth_(stack_depth), method_(method) {
Sebastien Hertz61b7f1b2013-11-15 15:59:30 +010097 }
98
Sebastien Hertz597c4f02015-01-26 17:37:14 +010099 JDWP::JdwpStepSize GetStepSize() const {
100 return step_size_;
101 }
Sebastien Hertz61b7f1b2013-11-15 15:59:30 +0100102
Sebastien Hertz597c4f02015-01-26 17:37:14 +0100103 JDWP::JdwpStepDepth GetStepDepth() const {
104 return step_depth_;
105 }
106
107 int GetStackDepth() const {
108 return stack_depth_;
109 }
110
Mathieu Chartiere401d142015-04-22 13:56:20 -0700111 ArtMethod* GetMethod() const {
112 return method_;
Sebastien Hertz597c4f02015-01-26 17:37:14 +0100113 }
114
115 const std::set<uint32_t>& GetDexPcs() const {
116 return dex_pcs_;
117 }
118
Sebastien Hertz597c4f02015-01-26 17:37:14 +0100119 void AddDexPc(uint32_t dex_pc);
120
121 bool ContainsDexPc(uint32_t dex_pc) const;
122
123 private:
Sebastien Hertz61b7f1b2013-11-15 15:59:30 +0100124 // See JdwpStepSize and JdwpStepDepth for details.
Sebastien Hertz597c4f02015-01-26 17:37:14 +0100125 const JDWP::JdwpStepSize step_size_;
126 const JDWP::JdwpStepDepth step_depth_;
127
128 // The stack depth when this single-step was initiated. This is used to support SD_OVER and SD_OUT
129 // single-step depth.
130 const int stack_depth_;
Sebastien Hertz61b7f1b2013-11-15 15:59:30 +0100131
132 // The location this single-step was initiated from.
133 // A single-step is initiated in a suspended thread. We save here the current method and the
134 // set of DEX pcs associated to the source line number where the suspension occurred.
135 // This is used to support SD_INTO and SD_OVER single-step depths so we detect when a single-step
136 // causes the execution of an instruction in a different method or at a different line number.
Mathieu Chartiere401d142015-04-22 13:56:20 -0700137 ArtMethod* method_;
138
Sebastien Hertz597c4f02015-01-26 17:37:14 +0100139 std::set<uint32_t> dex_pcs_;
Sebastien Hertz61b7f1b2013-11-15 15:59:30 +0100140
Sebastien Hertz61b7f1b2013-11-15 15:59:30 +0100141 DISALLOW_COPY_AND_ASSIGN(SingleStepControl);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700142};
143
Sebastien Hertz42cd43f2014-05-13 14:15:41 +0200144// TODO rename to InstrumentationRequest.
Hiroshi Yamauchi0ec17d22014-07-07 13:07:08 -0700145class DeoptimizationRequest {
146 public:
Sebastien Hertz4d25df32014-03-21 17:44:46 +0100147 enum Kind {
148 kNothing, // no action.
Sebastien Hertz42cd43f2014-05-13 14:15:41 +0200149 kRegisterForEvent, // start listening for instrumentation event.
150 kUnregisterForEvent, // stop listening for instrumentation event.
Sebastien Hertz4d25df32014-03-21 17:44:46 +0100151 kFullDeoptimization, // deoptimize everything.
152 kFullUndeoptimization, // undeoptimize everything.
153 kSelectiveDeoptimization, // deoptimize one method.
154 kSelectiveUndeoptimization // undeoptimize one method.
155 };
156
Hiroshi Yamauchi0ec17d22014-07-07 13:07:08 -0700157 DeoptimizationRequest() : kind_(kNothing), instrumentation_event_(0), method_(nullptr) {}
Sebastien Hertz4d25df32014-03-21 17:44:46 +0100158
Hiroshi Yamauchi0ec17d22014-07-07 13:07:08 -0700159 DeoptimizationRequest(const DeoptimizationRequest& other)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700160 REQUIRES_SHARED(Locks::mutator_lock_)
Hiroshi Yamauchi0ec17d22014-07-07 13:07:08 -0700161 : kind_(other.kind_), instrumentation_event_(other.instrumentation_event_) {
162 // Create a new JNI global reference for the method.
163 SetMethod(other.Method());
164 }
Sebastien Hertz4d25df32014-03-21 17:44:46 +0100165
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700166 ArtMethod* Method() const REQUIRES_SHARED(Locks::mutator_lock_);
Hiroshi Yamauchi0ec17d22014-07-07 13:07:08 -0700167
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700168 void SetMethod(ArtMethod* m) REQUIRES_SHARED(Locks::mutator_lock_);
Hiroshi Yamauchi0ec17d22014-07-07 13:07:08 -0700169
170 // Name 'Kind()' would collide with the above enum name.
171 Kind GetKind() const {
172 return kind_;
173 }
174
175 void SetKind(Kind kind) {
176 kind_ = kind;
177 }
178
179 uint32_t InstrumentationEvent() const {
180 return instrumentation_event_;
181 }
182
183 void SetInstrumentationEvent(uint32_t instrumentation_event) {
184 instrumentation_event_ = instrumentation_event;
185 }
186
187 private:
188 Kind kind_;
Sebastien Hertz4d25df32014-03-21 17:44:46 +0100189
Sebastien Hertz42cd43f2014-05-13 14:15:41 +0200190 // TODO we could use a union to hold the instrumentation_event and the method since they
191 // respectively have sense only for kRegisterForEvent/kUnregisterForEvent and
192 // kSelectiveDeoptimization/kSelectiveUndeoptimization.
193
194 // Event to start or stop listening to. Only for kRegisterForEvent and kUnregisterForEvent.
Hiroshi Yamauchi0ec17d22014-07-07 13:07:08 -0700195 uint32_t instrumentation_event_;
Sebastien Hertz42cd43f2014-05-13 14:15:41 +0200196
Sebastien Hertz4d25df32014-03-21 17:44:46 +0100197 // Method for selective deoptimization.
Hiroshi Yamauchi0ec17d22014-07-07 13:07:08 -0700198 jmethodID method_;
Sebastien Hertz4d25df32014-03-21 17:44:46 +0100199};
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700200std::ostream& operator<<(std::ostream& os, const DeoptimizationRequest::Kind& rhs);
Sebastien Hertz4d25df32014-03-21 17:44:46 +0100201
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700202class Dbg {
Elliott Hughesff17f1f2012-01-24 18:12:29 -0800203 public:
Elliott Hughes4ffd3132011-10-24 12:06:42 -0700204 static void SetJdwpAllowed(bool allowed);
Leonard Mosescueb842212016-10-06 17:26:36 -0700205 static bool IsJdwpAllowed();
Elliott Hughes4ffd3132011-10-24 12:06:42 -0700206
Sebastien Hertzb3b173b2015-02-06 09:16:32 +0100207 static void StartJdwp();
Elliott Hughesd1cc8362011-10-24 16:58:50 -0700208 static void StopJdwp();
209
Elliott Hughes767a1472011-10-26 18:49:02 -0700210 // Invoked by the GC in case we need to keep DDMS informed.
Mathieu Chartier90443472015-07-16 20:32:27 -0700211 static void GcDidFinish() REQUIRES(!Locks::mutator_lock_);
Elliott Hughes767a1472011-10-26 18:49:02 -0700212
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700213 // Return the DebugInvokeReq for the current thread.
214 static DebugInvokeReq* GetInvokeReq();
215
Elliott Hughes475fc232011-10-25 15:00:35 -0700216 static Thread* GetDebugThread();
217 static void ClearWaitForEventThread();
218
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700219 /*
220 * Enable/disable breakpoints and step modes. Used to provide a heads-up
221 * when the debugger attaches.
222 */
223 static void Connected();
Sebastien Hertz138dbfc2013-12-04 18:15:25 +0100224 static void GoActive()
Mathieu Chartier90443472015-07-16 20:32:27 -0700225 REQUIRES(!Locks::breakpoint_lock_, !Locks::deoptimization_lock_, !Locks::mutator_lock_);
226 static void Disconnected() REQUIRES(!Locks::deoptimization_lock_, !Locks::mutator_lock_);
Sebastien Hertz4e5b2082015-03-24 19:03:40 +0100227 static void Dispose() {
228 gDisposed = true;
229 }
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700230
Elliott Hughesc0f09332012-03-26 13:27:06 -0700231 // Returns true if we're actually debugging with a real debugger, false if it's
232 // just DDMS (or nothing at all).
Daniel Mihalyieb076692014-08-22 17:33:31 +0200233 static bool IsDebuggerActive() {
234 return gDebuggerActive;
235 }
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700236
Sebastien Hertzb3b173b2015-02-06 09:16:32 +0100237 // Configures JDWP with parsed command-line options.
238 static void ConfigureJdwp(const JDWP::JdwpOptions& jdwp_options);
239
Elliott Hughesc0f09332012-03-26 13:27:06 -0700240 // Returns true if we had -Xrunjdwp or -agentlib:jdwp= on the command line.
241 static bool IsJdwpConfigured();
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700242
Mathieu Chartierd8565452015-03-26 09:41:50 -0700243 // Returns true if a method has any breakpoints.
Mathieu Chartiere401d142015-04-22 13:56:20 -0700244 static bool MethodHasAnyBreakpoints(ArtMethod* method)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700245 REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Locks::breakpoint_lock_);
Mathieu Chartierd8565452015-03-26 09:41:50 -0700246
Sebastien Hertz4e5b2082015-03-24 19:03:40 +0100247 static bool IsDisposed() {
248 return gDisposed;
249 }
Elliott Hughes86964332012-02-15 19:37:42 -0800250
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700251 /*
252 * Time, in milliseconds, since the last debugger activity. Does not
253 * include DDMS activity. Returns -1 if there has been no activity.
254 * Returns 0 if we're in the middle of handling a debugger request.
255 */
256 static int64_t LastDebuggerActivity();
257
Sebastien Hertz253fa552014-10-14 17:27:15 +0200258 static void UndoDebuggerSuspensions()
Mathieu Chartier90443472015-07-16 20:32:27 -0700259 REQUIRES(!Locks::thread_list_lock_, !Locks::thread_suspend_count_lock_);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700260
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700261 /*
262 * Class, Object, Array
263 */
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700264 static std::string GetClassName(JDWP::RefTypeId id)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700265 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz6995c602014-09-09 12:10:13 +0200266 static std::string GetClassName(mirror::Class* klass)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700267 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogersc0542af2014-09-03 16:16:56 -0700268 static JDWP::JdwpError GetClassObject(JDWP::RefTypeId id, JDWP::ObjectId* class_object_id)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700269 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogersc0542af2014-09-03 16:16:56 -0700270 static JDWP::JdwpError GetSuperclass(JDWP::RefTypeId id, JDWP::RefTypeId* superclass_id)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700271 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700272 static JDWP::JdwpError GetClassLoader(JDWP::RefTypeId id, JDWP::ExpandBuf* pReply)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700273 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700274 static JDWP::JdwpError GetModifiers(JDWP::RefTypeId id, JDWP::ExpandBuf* pReply)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700275 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800276 static JDWP::JdwpError GetReflectedType(JDWP::RefTypeId class_id, JDWP::ExpandBuf* pReply)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700277 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogersc0542af2014-09-03 16:16:56 -0700278 static void GetClassList(std::vector<JDWP::RefTypeId>* classes)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700279 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800280 static JDWP::JdwpError GetClassInfo(JDWP::RefTypeId class_id, JDWP::JdwpTypeTag* pTypeTag,
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700281 uint32_t* pStatus, std::string* pDescriptor)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700282 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogersc0542af2014-09-03 16:16:56 -0700283 static void FindLoadedClassBySignature(const char* descriptor, std::vector<JDWP::RefTypeId>* ids)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700284 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes64f574f2013-02-20 14:57:12 -0800285 static JDWP::JdwpError GetReferenceType(JDWP::ObjectId object_id, JDWP::ExpandBuf* pReply)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700286 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogersfc0e94b2013-09-23 23:51:32 -0700287 static JDWP::JdwpError GetSignature(JDWP::RefTypeId ref_type_id, std::string* signature)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700288 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogersc0542af2014-09-03 16:16:56 -0700289 static JDWP::JdwpError GetSourceFile(JDWP::RefTypeId ref_type_id, std::string* source_file)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700290 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogersc0542af2014-09-03 16:16:56 -0700291 static JDWP::JdwpError GetObjectTag(JDWP::ObjectId object_id, uint8_t* tag)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700292 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughesaed4be92011-12-02 16:16:23 -0800293 static size_t GetTagWidth(JDWP::JdwpTag tag);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700294
Ian Rogersc0542af2014-09-03 16:16:56 -0700295 static JDWP::JdwpError GetArrayLength(JDWP::ObjectId array_id, int32_t* length)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700296 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800297 static JDWP::JdwpError OutputArray(JDWP::ObjectId array_id, int offset, int count,
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700298 JDWP::ExpandBuf* pReply)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700299 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800300 static JDWP::JdwpError SetArrayElements(JDWP::ObjectId array_id, int offset, int count,
Ian Rogersc0542af2014-09-03 16:16:56 -0700301 JDWP::Request* request)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700302 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700303
Sebastien Hertz2c3e77a2015-04-02 16:26:48 +0200304 static JDWP::JdwpError CreateString(const std::string& str, JDWP::ObjectId* new_string_id)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700305 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz2c3e77a2015-04-02 16:26:48 +0200306 static JDWP::JdwpError CreateObject(JDWP::RefTypeId class_id, JDWP::ObjectId* new_object_id)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700307 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800308 static JDWP::JdwpError CreateArrayObject(JDWP::RefTypeId array_class_id, uint32_t length,
Sebastien Hertz2c3e77a2015-04-02 16:26:48 +0200309 JDWP::ObjectId* new_array_id)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700310 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700311
Sebastien Hertz6995c602014-09-09 12:10:13 +0200312 //
313 // Event filtering.
314 //
315 static bool MatchThread(JDWP::ObjectId expected_thread_id, Thread* event_thread)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700316 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz6995c602014-09-09 12:10:13 +0200317
318 static bool MatchLocation(const JDWP::JdwpLocation& expected_location,
319 const JDWP::EventLocation& event_location)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700320 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz6995c602014-09-09 12:10:13 +0200321
Mathieu Chartier3398c782016-09-30 10:27:43 -0700322 static bool MatchType(ObjPtr<mirror::Class> event_class, JDWP::RefTypeId class_id)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700323 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz6995c602014-09-09 12:10:13 +0200324
325 static bool MatchField(JDWP::RefTypeId expected_type_id, JDWP::FieldId expected_field_id,
Mathieu Chartierc7853442015-03-27 14:35:38 -0700326 ArtField* event_field)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700327 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz6995c602014-09-09 12:10:13 +0200328
329 static bool MatchInstance(JDWP::ObjectId expected_instance_id, mirror::Object* event_instance)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700330 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700331
Elliott Hughesec0f83d2013-01-15 16:54:08 -0800332 //
333 // Monitors.
334 //
335 static JDWP::JdwpError GetMonitorInfo(JDWP::ObjectId object_id, JDWP::ExpandBuf* reply)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700336 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughesec0f83d2013-01-15 16:54:08 -0800337 static JDWP::JdwpError GetOwnedMonitors(JDWP::ObjectId thread_id,
Ian Rogersc0542af2014-09-03 16:16:56 -0700338 std::vector<JDWP::ObjectId>* monitors,
339 std::vector<uint32_t>* stack_depths)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700340 REQUIRES(!Locks::thread_list_lock_) REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz52d131d2014-03-13 16:17:40 +0100341 static JDWP::JdwpError GetContendedMonitor(JDWP::ObjectId thread_id,
Ian Rogersc0542af2014-09-03 16:16:56 -0700342 JDWP::ObjectId* contended_monitor)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700343 REQUIRES(!Locks::thread_list_lock_) REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughesec0f83d2013-01-15 16:54:08 -0800344
345 //
346 // Heap.
347 //
348 static JDWP::JdwpError GetInstanceCounts(const std::vector<JDWP::RefTypeId>& class_ids,
Ian Rogersc0542af2014-09-03 16:16:56 -0700349 std::vector<uint64_t>* counts)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700350 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes3b78c942013-01-15 17:35:41 -0800351 static JDWP::JdwpError GetInstances(JDWP::RefTypeId class_id, int32_t max_count,
Ian Rogersc0542af2014-09-03 16:16:56 -0700352 std::vector<JDWP::ObjectId>* instances)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700353 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes0cbaff52013-01-16 15:28:01 -0800354 static JDWP::JdwpError GetReferringObjects(JDWP::ObjectId object_id, int32_t max_count,
Ian Rogersc0542af2014-09-03 16:16:56 -0700355 std::vector<JDWP::ObjectId>* referring_objects)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700356 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes64f574f2013-02-20 14:57:12 -0800357 static JDWP::JdwpError DisableCollection(JDWP::ObjectId object_id)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700358 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes64f574f2013-02-20 14:57:12 -0800359 static JDWP::JdwpError EnableCollection(JDWP::ObjectId object_id)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700360 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogersc0542af2014-09-03 16:16:56 -0700361 static JDWP::JdwpError IsCollected(JDWP::ObjectId object_id, bool* is_collected)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700362 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes64f574f2013-02-20 14:57:12 -0800363 static void DisposeObject(JDWP::ObjectId object_id, uint32_t reference_count)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700364 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughesec0f83d2013-01-15 16:54:08 -0800365
Elliott Hughes9777ba22013-01-17 09:04:19 -0800366 //
367 // Methods and fields.
368 //
Elliott Hughesa96836a2013-01-17 12:27:49 -0800369 static std::string GetMethodName(JDWP::MethodId method_id)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700370 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800371 static JDWP::JdwpError OutputDeclaredFields(JDWP::RefTypeId ref_type_id, bool with_generic,
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700372 JDWP::ExpandBuf* pReply)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700373 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800374 static JDWP::JdwpError OutputDeclaredMethods(JDWP::RefTypeId ref_type_id, bool with_generic,
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700375 JDWP::ExpandBuf* pReply)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700376 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800377 static JDWP::JdwpError OutputDeclaredInterfaces(JDWP::RefTypeId ref_type_id,
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700378 JDWP::ExpandBuf* pReply)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700379 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800380 static void OutputLineTable(JDWP::RefTypeId ref_type_id, JDWP::MethodId method_id,
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700381 JDWP::ExpandBuf* pReply)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700382 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800383 static void OutputVariableTable(JDWP::RefTypeId ref_type_id, JDWP::MethodId id, bool with_generic,
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700384 JDWP::ExpandBuf* pReply)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700385 REQUIRES_SHARED(Locks::mutator_lock_);
Jeff Hao579b0242013-11-18 13:16:49 -0800386 static void OutputMethodReturnValue(JDWP::MethodId method_id, const JValue* return_value,
387 JDWP::ExpandBuf* pReply)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700388 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz3f52eaf2014-04-04 17:50:18 +0200389 static void OutputFieldValue(JDWP::FieldId field_id, const JValue* field_value,
390 JDWP::ExpandBuf* pReply)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700391 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes9777ba22013-01-17 09:04:19 -0800392 static JDWP::JdwpError GetBytecodes(JDWP::RefTypeId class_id, JDWP::MethodId method_id,
Ian Rogersc0542af2014-09-03 16:16:56 -0700393 std::vector<uint8_t>* bytecodes)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700394 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700395
Elliott Hughesa96836a2013-01-17 12:27:49 -0800396 static std::string GetFieldName(JDWP::FieldId field_id)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700397 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800398 static JDWP::JdwpTag GetFieldBasicTag(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 GetStaticFieldBasicTag(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::JdwpError GetFieldValue(JDWP::ObjectId object_id, JDWP::FieldId field_id,
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700403 JDWP::ExpandBuf* pReply)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700404 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800405 static JDWP::JdwpError SetFieldValue(JDWP::ObjectId object_id, JDWP::FieldId field_id,
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700406 uint64_t value, int width)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700407 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800408 static JDWP::JdwpError GetStaticFieldValue(JDWP::RefTypeId ref_type_id, JDWP::FieldId field_id,
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700409 JDWP::ExpandBuf* pReply)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700410 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800411 static JDWP::JdwpError SetStaticFieldValue(JDWP::FieldId field_id, uint64_t value, int width)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700412 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700413
Sebastien Hertzb0b0b492014-09-15 11:27:27 +0200414 static JDWP::JdwpError StringToUtf8(JDWP::ObjectId string_id, std::string* str)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700415 REQUIRES_SHARED(Locks::mutator_lock_);
Jeff Hao579b0242013-11-18 13:16:49 -0800416 static void OutputJValue(JDWP::JdwpTag tag, const JValue* return_value, JDWP::ExpandBuf* pReply)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700417 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700418
419 /*
420 * Thread, ThreadGroup, Frame
421 */
Ian Rogersc0542af2014-09-03 16:16:56 -0700422 static JDWP::JdwpError GetThreadName(JDWP::ObjectId thread_id, std::string* name)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700423 REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Locks::thread_list_lock_);
Sebastien Hertz52d131d2014-03-13 16:17:40 +0100424 static JDWP::JdwpError GetThreadGroup(JDWP::ObjectId thread_id, JDWP::ExpandBuf* pReply)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700425 REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Locks::thread_list_lock_);
Sebastien Hertza06430c2014-09-15 19:21:30 +0200426 static JDWP::JdwpError GetThreadGroupName(JDWP::ObjectId thread_group_id,
427 JDWP::ExpandBuf* pReply)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700428 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertza06430c2014-09-15 19:21:30 +0200429 static JDWP::JdwpError GetThreadGroupParent(JDWP::ObjectId thread_group_id,
430 JDWP::ExpandBuf* pReply)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700431 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertza06430c2014-09-15 19:21:30 +0200432 static JDWP::JdwpError GetThreadGroupChildren(JDWP::ObjectId thread_group_id,
433 JDWP::ExpandBuf* pReply)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700434 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700435 static JDWP::ObjectId GetSystemThreadGroupId()
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700436 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700437
Jeff Hao920af3e2013-08-28 15:46:38 -0700438 static JDWP::JdwpThreadStatus ToJdwpThreadStatus(ThreadState state);
Sebastien Hertz52d131d2014-03-13 16:17:40 +0100439 static JDWP::JdwpError GetThreadStatus(JDWP::ObjectId thread_id,
440 JDWP::JdwpThreadStatus* pThreadStatus,
441 JDWP::JdwpSuspendStatus* pSuspendStatus)
Mathieu Chartier90443472015-07-16 20:32:27 -0700442 REQUIRES(!Locks::thread_list_lock_);
Sebastien Hertz52d131d2014-03-13 16:17:40 +0100443 static JDWP::JdwpError GetThreadDebugSuspendCount(JDWP::ObjectId thread_id,
444 JDWP::ExpandBuf* pReply)
Mathieu Chartier90443472015-07-16 20:32:27 -0700445 REQUIRES(!Locks::thread_list_lock_, !Locks::thread_suspend_count_lock_);
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700446 // static void WaitForSuspend(JDWP::ObjectId thread_id);
Elliott Hughescaf76542012-06-28 16:08:22 -0700447
Elliott Hughes026b1462012-06-28 20:43:49 -0700448 // Fills 'thread_ids' with the threads in the given thread group. If thread_group_id == 0,
Elliott Hughescaf76542012-06-28 16:08:22 -0700449 // returns all threads.
Sebastien Hertza06430c2014-09-15 19:21:30 +0200450 static void GetThreads(mirror::Object* thread_group, std::vector<JDWP::ObjectId>* thread_ids)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700451 REQUIRES(!Locks::thread_list_lock_) REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughescaf76542012-06-28 16:08:22 -0700452
Ian Rogersc0542af2014-09-03 16:16:56 -0700453 static JDWP::JdwpError GetThreadFrameCount(JDWP::ObjectId thread_id, size_t* result)
Mathieu Chartier90443472015-07-16 20:32:27 -0700454 REQUIRES(!Locks::thread_list_lock_);
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700455 static JDWP::JdwpError GetThreadFrames(JDWP::ObjectId thread_id, size_t start_frame,
456 size_t frame_count, JDWP::ExpandBuf* buf)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700457 REQUIRES(!Locks::thread_list_lock_) REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700458
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700459 static JDWP::ObjectId GetThreadSelfId() REQUIRES_SHARED(Locks::mutator_lock_);
460 static JDWP::ObjectId GetThreadId(Thread* thread) REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz6995c602014-09-09 12:10:13 +0200461
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700462 static void SuspendVM()
Mathieu Chartier90443472015-07-16 20:32:27 -0700463 REQUIRES(!Locks::thread_list_lock_, !Locks::thread_suspend_count_lock_);
Sebastien Hertz253fa552014-10-14 17:27:15 +0200464 static void ResumeVM()
Mathieu Chartier90443472015-07-16 20:32:27 -0700465 REQUIRES(!Locks::thread_list_lock_, !Locks::thread_suspend_count_lock_);
Elliott Hughes88d63092013-01-09 09:55:54 -0800466 static JDWP::JdwpError SuspendThread(JDWP::ObjectId thread_id, bool request_suspension = true)
Mathieu Chartier90443472015-07-16 20:32:27 -0700467 REQUIRES(!Locks::mutator_lock_, !Locks::thread_list_lock_,
468 !Locks::thread_suspend_count_lock_);
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700469
Elliott Hughes88d63092013-01-09 09:55:54 -0800470 static void ResumeThread(JDWP::ObjectId thread_id)
Mathieu Chartier90443472015-07-16 20:32:27 -0700471 REQUIRES(!Locks::thread_list_lock_, !Locks::thread_suspend_count_lock_)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700472 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700473 static void SuspendSelf();
474
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700475 static JDWP::JdwpError GetThisObject(JDWP::ObjectId thread_id, JDWP::FrameId frame_id,
476 JDWP::ObjectId* result)
Mathieu Chartier90443472015-07-16 20:32:27 -0700477 REQUIRES(!Locks::thread_list_lock_, !Locks::thread_suspend_count_lock_)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700478 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz8009f392014-09-01 17:07:11 +0200479 static JDWP::JdwpError GetLocalValues(JDWP::Request* request, JDWP::ExpandBuf* pReply)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700480 REQUIRES(!Locks::thread_list_lock_) REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz8009f392014-09-01 17:07:11 +0200481 static JDWP::JdwpError SetLocalValues(JDWP::Request* request)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700482 REQUIRES(!Locks::thread_list_lock_) REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700483
Sebastien Hertz52d131d2014-03-13 16:17:40 +0100484 static JDWP::JdwpError Interrupt(JDWP::ObjectId thread_id)
Mathieu Chartier90443472015-07-16 20:32:27 -0700485 REQUIRES(!Locks::thread_list_lock_);
Elliott Hughesf9501702013-01-11 11:22:27 -0800486
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700487 /*
488 * Debugger notification
489 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700490 enum EventFlag {
Elliott Hughes86964332012-02-15 19:37:42 -0800491 kBreakpoint = 0x01,
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700492 kSingleStep = 0x02,
493 kMethodEntry = 0x04,
494 kMethodExit = 0x08,
495 };
Mathieu Chartiere401d142015-04-22 13:56:20 -0700496 static void PostFieldAccessEvent(ArtMethod* m, int dex_pc, mirror::Object* this_object,
Mathieu Chartierc7853442015-03-27 14:35:38 -0700497 ArtField* f)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700498 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartiere401d142015-04-22 13:56:20 -0700499 static void PostFieldModificationEvent(ArtMethod* m, int dex_pc,
Mathieu Chartierc7853442015-03-27 14:35:38 -0700500 mirror::Object* this_object, ArtField* f,
Sebastien Hertz3f52eaf2014-04-04 17:50:18 +0200501 const JValue* field_value)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700502 REQUIRES_SHARED(Locks::mutator_lock_);
Nicolas Geoffray14691c52015-03-05 10:40:17 +0000503 static void PostException(mirror::Throwable* exception)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700504 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700505 static void PostThreadStart(Thread* t)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700506 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700507 static void PostThreadDeath(Thread* t)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700508 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800509 static void PostClassPrepare(mirror::Class* c)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700510 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700511
Ian Rogers62d6c772013-02-27 08:32:07 -0800512 static void UpdateDebugger(Thread* thread, mirror::Object* this_object,
Mathieu Chartiere401d142015-04-22 13:56:20 -0700513 ArtMethod* method, uint32_t new_dex_pc,
Sebastien Hertz8379b222014-02-24 17:38:15 +0100514 int event_flags, const JValue* return_value)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700515 REQUIRES(!Locks::breakpoint_lock_) REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes91bf6cd2012-02-14 17:27:48 -0800516
Sebastien Hertzf3928792014-11-17 19:00:37 +0100517 // Indicates whether we need deoptimization for debugging.
518 static bool RequiresDeoptimization();
519
Sebastien Hertz4d25df32014-03-21 17:44:46 +0100520 // Records deoptimization request in the queue.
521 static void RequestDeoptimization(const DeoptimizationRequest& req)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700522 REQUIRES(!Locks::deoptimization_lock_) REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz138dbfc2013-12-04 18:15:25 +0100523
Sebastien Hertz4d25df32014-03-21 17:44:46 +0100524 // Manage deoptimization after updating JDWP events list. Suspends all threads, processes each
525 // request and finally resumes all threads.
Sebastien Hertz138dbfc2013-12-04 18:15:25 +0100526 static void ManageDeoptimization()
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700527 REQUIRES(!Locks::deoptimization_lock_) REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz138dbfc2013-12-04 18:15:25 +0100528
529 // Breakpoints.
Sebastien Hertz4d25df32014-03-21 17:44:46 +0100530 static void WatchLocation(const JDWP::JdwpLocation* pLoc, DeoptimizationRequest* req)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700531 REQUIRES(!Locks::breakpoint_lock_) REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz4d25df32014-03-21 17:44:46 +0100532 static void UnwatchLocation(const JDWP::JdwpLocation* pLoc, DeoptimizationRequest* req)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700533 REQUIRES(!Locks::breakpoint_lock_) REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz138dbfc2013-12-04 18:15:25 +0100534
Daniel Mihalyieb076692014-08-22 17:33:31 +0200535 /*
536 * Forced interpreter checkers for single-step and continue support.
537 */
538
539 // Indicates whether we need to force the use of interpreter to invoke a method.
540 // This allows to single-step or continue into the called method.
Mathieu Chartiere401d142015-04-22 13:56:20 -0700541 static bool IsForcedInterpreterNeededForCalling(Thread* thread, ArtMethod* m)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700542 REQUIRES_SHARED(Locks::mutator_lock_) {
Daniel Mihalyieb076692014-08-22 17:33:31 +0200543 if (!IsDebuggerActive()) {
544 return false;
545 }
546 return IsForcedInterpreterNeededForCallingImpl(thread, m);
547 }
548
549 // Indicates whether we need to force the use of interpreter entrypoint when calling a
550 // method through the resolution trampoline. This allows to single-step or continue into
551 // the called method.
Mathieu Chartiere401d142015-04-22 13:56:20 -0700552 static bool IsForcedInterpreterNeededForResolution(Thread* thread, ArtMethod* m)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700553 REQUIRES_SHARED(Locks::mutator_lock_) {
Daniel Mihalyieb076692014-08-22 17:33:31 +0200554 if (!IsDebuggerActive()) {
555 return false;
556 }
557 return IsForcedInterpreterNeededForResolutionImpl(thread, m);
558 }
559
560 // Indicates whether we need to force the use of instrumentation entrypoint when calling
561 // a method through the resolution trampoline. This allows to deoptimize the stack for
562 // debugging when we returned from the called method.
Mathieu Chartiere401d142015-04-22 13:56:20 -0700563 static bool IsForcedInstrumentationNeededForResolution(Thread* thread, ArtMethod* m)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700564 REQUIRES_SHARED(Locks::mutator_lock_) {
Daniel Mihalyieb076692014-08-22 17:33:31 +0200565 if (!IsDebuggerActive()) {
566 return false;
567 }
568 return IsForcedInstrumentationNeededForResolutionImpl(thread, m);
569 }
570
571 // Indicates whether we need to force the use of interpreter when returning from the
572 // interpreter into the runtime. This allows to deoptimize the stack and continue
573 // execution with interpreter for debugging.
Mathieu Chartiere401d142015-04-22 13:56:20 -0700574 static bool IsForcedInterpreterNeededForUpcall(Thread* thread, ArtMethod* m)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700575 REQUIRES_SHARED(Locks::mutator_lock_) {
Mingyao Yang99170c62015-07-06 11:10:37 -0700576 if (!IsDebuggerActive() && !thread->HasDebuggerShadowFrames()) {
Daniel Mihalyieb076692014-08-22 17:33:31 +0200577 return false;
578 }
579 return IsForcedInterpreterNeededForUpcallImpl(thread, m);
580 }
581
Sebastien Hertz520633b2015-09-08 17:03:36 +0200582 // Indicates whether we need to force the use of interpreter when handling an
583 // exception. This allows to deoptimize the stack and continue execution with
584 // the interpreter.
585 // Note: the interpreter will start by handling the exception when executing
586 // the deoptimized frames.
587 static bool IsForcedInterpreterNeededForException(Thread* thread)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700588 REQUIRES_SHARED(Locks::mutator_lock_) {
Mingyao Yang99170c62015-07-06 11:10:37 -0700589 if (!IsDebuggerActive() && !thread->HasDebuggerShadowFrames()) {
Sebastien Hertz520633b2015-09-08 17:03:36 +0200590 return false;
591 }
592 return IsForcedInterpreterNeededForExceptionImpl(thread);
593 }
594
Sebastien Hertz138dbfc2013-12-04 18:15:25 +0100595 // Single-stepping.
Elliott Hughes88d63092013-01-09 09:55:54 -0800596 static JDWP::JdwpError ConfigureStep(JDWP::ObjectId thread_id, JDWP::JdwpStepSize size,
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700597 JDWP::JdwpStepDepth depth)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700598 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz61b7f1b2013-11-15 15:59:30 +0100599 static void UnconfigureStep(JDWP::ObjectId thread_id)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700600 REQUIRES(!Locks::thread_list_lock_) REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700601
Sebastien Hertzcbc50642015-06-01 17:33:12 +0200602 /*
603 * Invoke support
604 */
605
606 // Called by the JDWP thread to prepare invocation in the event thread (suspended on an event).
607 // If the information sent by the debugger is incorrect, it will send a reply with the
608 // appropriate error code. Otherwise, it will attach a DebugInvokeReq object to the event thread
609 // and resume it (and possibly other threads depending on the invoke options).
610 // Unlike other commands, the JDWP thread will not send the reply to the debugger (see
611 // JdwpState::ProcessRequest). The reply will be sent by the event thread itself after method
612 // invocation completes (see FinishInvokeMethod). This is required to allow the JDWP thread to
613 // process incoming commands from the debugger while the invocation is still in progress in the
614 // event thread, especially if it gets suspended by a debug event occurring in another thread.
615 static JDWP::JdwpError PrepareInvokeMethod(uint32_t request_id, JDWP::ObjectId thread_id,
616 JDWP::ObjectId object_id, JDWP::RefTypeId class_id,
617 JDWP::MethodId method_id, uint32_t arg_count,
618 uint64_t arg_values[], JDWP::JdwpTag* arg_types,
619 uint32_t options)
Mathieu Chartier90443472015-07-16 20:32:27 -0700620 REQUIRES(!Locks::thread_list_lock_, !Locks::thread_suspend_count_lock_)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700621 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertzcbc50642015-06-01 17:33:12 +0200622
623 // Called by the event thread to execute a method prepared by the JDWP thread in the given
624 // DebugInvokeReq object. Once the invocation completes, the event thread attaches a reply
625 // to that DebugInvokeReq object so it can be sent to the debugger only when the event thread
626 // is ready to suspend (see FinishInvokeMethod).
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700627 static void ExecuteMethod(DebugInvokeReq* pReq);
628
Sebastien Hertzcbc50642015-06-01 17:33:12 +0200629 // Called by the event thread to send the reply of the invoke (created in ExecuteMethod)
630 // before suspending itself. This is to ensure the thread is ready to suspend before the
631 // debugger receives the reply.
632 static void FinishInvokeMethod(DebugInvokeReq* pReq);
633
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700634 /*
635 * DDM support.
636 */
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700637 static void DdmSendThreadNotification(Thread* t, uint32_t type)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700638 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz52d131d2014-03-13 16:17:40 +0100639 static void DdmSetThreadNotification(bool enable)
Mathieu Chartier90443472015-07-16 20:32:27 -0700640 REQUIRES(!Locks::thread_list_lock_);
Ian Rogersc0542af2014-09-03 16:16:56 -0700641 static bool DdmHandlePacket(JDWP::Request* request, uint8_t** pReplyBuf, int* pReplyLen);
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700642 static void DdmConnected() REQUIRES_SHARED(Locks::mutator_lock_);
643 static void DdmDisconnected() REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700644 static void DdmSendChunk(uint32_t type, const std::vector<uint8_t>& bytes)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700645 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700646 static void DdmSendChunk(uint32_t type, size_t len, const uint8_t* buf)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700647 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700648 static void DdmSendChunkV(uint32_t type, const iovec* iov, int iov_count)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700649 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes767a1472011-10-26 18:49:02 -0700650
Mathieu Chartiera6b1ead2015-10-06 10:32:38 -0700651 // Visit breakpoint roots, used to prevent unloading of methods with breakpoints.
Mathieu Chartierbb87e0f2015-04-03 11:21:55 -0700652 static void VisitRoots(RootVisitor* visitor)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700653 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartier3b05e9b2014-03-25 09:29:43 -0700654
Elliott Hughes545a0642011-11-08 19:10:03 -0800655 /*
Man Cao8c2ff642015-05-27 17:25:30 -0700656 * Allocation tracking support.
Elliott Hughes545a0642011-11-08 19:10:03 -0800657 */
Mathieu Chartier90443472015-07-16 20:32:27 -0700658 static void SetAllocTrackingEnabled(bool enabled) REQUIRES(!Locks::alloc_tracker_lock_);
Sebastien Hertz52d131d2014-03-13 16:17:40 +0100659 static jbyteArray GetRecentAllocations()
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700660 REQUIRES(!Locks::alloc_tracker_lock_) REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartier90443472015-07-16 20:32:27 -0700661 static void DumpRecentAllocations() REQUIRES(!Locks::alloc_tracker_lock_);
Elliott Hughes545a0642011-11-08 19:10:03 -0800662
Elliott Hughes767a1472011-10-26 18:49:02 -0700663 enum HpifWhen {
664 HPIF_WHEN_NEVER = 0,
665 HPIF_WHEN_NOW = 1,
666 HPIF_WHEN_NEXT_GC = 2,
667 HPIF_WHEN_EVERY_GC = 3
668 };
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700669 static int DdmHandleHpifChunk(HpifWhen when)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700670 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes767a1472011-10-26 18:49:02 -0700671
672 enum HpsgWhen {
673 HPSG_WHEN_NEVER = 0,
674 HPSG_WHEN_EVERY_GC = 1,
675 };
676 enum HpsgWhat {
677 HPSG_WHAT_MERGED_OBJECTS = 0,
678 HPSG_WHAT_DISTINCT_OBJECTS = 1,
679 };
680 static bool DdmHandleHpsgNhsgChunk(HpsgWhen when, HpsgWhat what, bool native);
681
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700682 static void DdmSendHeapInfo(HpifWhen reason)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700683 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700684 static void DdmSendHeapSegments(bool native)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700685 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes545a0642011-11-08 19:10:03 -0800686
Sebastien Hertz6995c602014-09-09 12:10:13 +0200687 static ObjectRegistry* GetObjectRegistry() {
688 return gRegistry;
689 }
690
691 static JDWP::JdwpTag TagFromObject(const ScopedObjectAccessUnchecked& soa, mirror::Object* o)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700692 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz6995c602014-09-09 12:10:13 +0200693
Mathieu Chartier3398c782016-09-30 10:27:43 -0700694 static JDWP::JdwpTypeTag GetTypeTag(ObjPtr<mirror::Class> klass)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700695 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz6995c602014-09-09 12:10:13 +0200696
Mathieu Chartierc7853442015-03-27 14:35:38 -0700697 static JDWP::FieldId ToFieldId(const ArtField* f)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700698 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz6995c602014-09-09 12:10:13 +0200699
Mathieu Chartiere401d142015-04-22 13:56:20 -0700700 static void SetJdwpLocation(JDWP::JdwpLocation* location, ArtMethod* m, uint32_t dex_pc)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700701 REQUIRES_SHARED(Locks::mutator_lock_)
Mathieu Chartier90443472015-07-16 20:32:27 -0700702 REQUIRES(!Locks::thread_list_lock_, !Locks::thread_suspend_count_lock_);
Sebastien Hertz6995c602014-09-09 12:10:13 +0200703
Mathieu Chartierad466ad2015-01-08 16:28:08 -0800704 static JDWP::JdwpState* GetJdwpState();
705
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700706 static uint32_t GetInstrumentationEvents() REQUIRES_SHARED(Locks::mutator_lock_) {
Sebastien Hertz9d6bf692015-04-10 12:12:33 +0200707 return instrumentation_events_;
708 }
709
Elliott Hughes545a0642011-11-08 19:10:03 -0800710 private:
Sebastien Hertzcbc50642015-06-01 17:33:12 +0200711 static void ExecuteMethodWithoutPendingException(ScopedObjectAccess& soa, DebugInvokeReq* pReq)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700712 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertzcbc50642015-06-01 17:33:12 +0200713
714 static void BuildInvokeReply(JDWP::ExpandBuf* pReply, uint32_t request_id,
715 JDWP::JdwpTag result_tag, uint64_t result_value,
716 JDWP::ObjectId exception)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700717 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertzcbc50642015-06-01 17:33:12 +0200718
Sebastien Hertz8009f392014-09-01 17:07:11 +0200719 static JDWP::JdwpError GetLocalValue(const StackVisitor& visitor,
720 ScopedObjectAccessUnchecked& soa, int slot,
721 JDWP::JdwpTag tag, uint8_t* buf, size_t width)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700722 REQUIRES(!Locks::thread_list_lock_) REQUIRES_SHARED(Locks::mutator_lock_);
Mingyao Yang99170c62015-07-06 11:10:37 -0700723 static JDWP::JdwpError SetLocalValue(Thread* thread, StackVisitor& visitor, int slot,
724 JDWP::JdwpTag tag, uint64_t value, size_t width)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700725 REQUIRES(!Locks::thread_list_lock_) REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz8009f392014-09-01 17:07:11 +0200726
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700727 static void DdmBroadcast(bool connect) REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700728 static void PostThreadStartOrStop(Thread*, uint32_t)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700729 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughesa2155262011-11-16 16:26:58 -0800730
Mathieu Chartiere401d142015-04-22 13:56:20 -0700731 static void PostLocationEvent(ArtMethod* method, int pcOffset,
Sebastien Hertz8379b222014-02-24 17:38:15 +0100732 mirror::Object* thisPtr, int eventFlags,
733 const JValue* return_value)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700734 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz8379b222014-02-24 17:38:15 +0100735
Sebastien Hertz4d25df32014-03-21 17:44:46 +0100736 static void ProcessDeoptimizationRequest(const DeoptimizationRequest& request)
Mathieu Chartieraa516822015-10-02 15:53:37 -0700737 REQUIRES(Locks::mutator_lock_, Roles::uninterruptible_);
Sebastien Hertz4d25df32014-03-21 17:44:46 +0100738
Sebastien Hertz7ec2f1c2014-03-27 20:06:47 +0100739 static void RequestDeoptimizationLocked(const DeoptimizationRequest& req)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700740 REQUIRES(Locks::deoptimization_lock_) REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz7ec2f1c2014-03-27 20:06:47 +0100741
Mathieu Chartiere401d142015-04-22 13:56:20 -0700742 static bool IsForcedInterpreterNeededForCallingImpl(Thread* thread, ArtMethod* m)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700743 REQUIRES_SHARED(Locks::mutator_lock_);
Daniel Mihalyieb076692014-08-22 17:33:31 +0200744
Mathieu Chartiere401d142015-04-22 13:56:20 -0700745 static bool IsForcedInterpreterNeededForResolutionImpl(Thread* thread, ArtMethod* m)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700746 REQUIRES_SHARED(Locks::mutator_lock_);
Daniel Mihalyieb076692014-08-22 17:33:31 +0200747
Mathieu Chartiere401d142015-04-22 13:56:20 -0700748 static bool IsForcedInstrumentationNeededForResolutionImpl(Thread* thread, ArtMethod* m)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700749 REQUIRES_SHARED(Locks::mutator_lock_);
Daniel Mihalyieb076692014-08-22 17:33:31 +0200750
Mathieu Chartiere401d142015-04-22 13:56:20 -0700751 static bool IsForcedInterpreterNeededForUpcallImpl(Thread* thread, ArtMethod* m)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700752 REQUIRES_SHARED(Locks::mutator_lock_);
Daniel Mihalyieb076692014-08-22 17:33:31 +0200753
Sebastien Hertz520633b2015-09-08 17:03:36 +0200754 static bool IsForcedInterpreterNeededForExceptionImpl(Thread* thread)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700755 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz520633b2015-09-08 17:03:36 +0200756
Daniel Mihalyieb076692014-08-22 17:33:31 +0200757 // Indicates whether the debugger is making requests.
758 static bool gDebuggerActive;
759
Sebastien Hertz4e5b2082015-03-24 19:03:40 +0100760 // Indicates whether we should drop the JDWP connection because the runtime stops or the
761 // debugger called VirtualMachine.Dispose.
762 static bool gDisposed;
763
Daniel Mihalyieb076692014-08-22 17:33:31 +0200764 // The registry mapping objects to JDWP ids.
Sebastien Hertz6995c602014-09-09 12:10:13 +0200765 static ObjectRegistry* gRegistry;
766
Sebastien Hertz4d25df32014-03-21 17:44:46 +0100767 // Deoptimization requests to be processed each time the event list is updated. This is used when
768 // registering and unregistering events so we do not deoptimize while holding the event list
769 // lock.
Sebastien Hertz42cd43f2014-05-13 14:15:41 +0200770 // TODO rename to instrumentation_requests.
Brian Carlstrom306db812014-09-05 13:01:41 -0700771 static std::vector<DeoptimizationRequest> deoptimization_requests_ GUARDED_BY(Locks::deoptimization_lock_);
Sebastien Hertz4d25df32014-03-21 17:44:46 +0100772
773 // Count the number of events requiring full deoptimization. When the counter is > 0, everything
774 // is deoptimized, otherwise everything is undeoptimized.
775 // Note: we fully deoptimize on the first event only (when the counter is set to 1). We fully
776 // undeoptimize when the last event is unregistered (when the counter is set to 0).
Brian Carlstrom306db812014-09-05 13:01:41 -0700777 static size_t full_deoptimization_event_count_ GUARDED_BY(Locks::deoptimization_lock_);
Sebastien Hertz4d25df32014-03-21 17:44:46 +0100778
Sebastien Hertz42cd43f2014-05-13 14:15:41 +0200779 static size_t* GetReferenceCounterForEvent(uint32_t instrumentation_event);
780
781 // Instrumentation event reference counters.
782 // TODO we could use an array instead of having all these dedicated counters. Instrumentation
783 // events are bits of a mask so we could convert them to array index.
Brian Carlstrom306db812014-09-05 13:01:41 -0700784 static size_t dex_pc_change_event_ref_count_ GUARDED_BY(Locks::deoptimization_lock_);
785 static size_t method_enter_event_ref_count_ GUARDED_BY(Locks::deoptimization_lock_);
786 static size_t method_exit_event_ref_count_ GUARDED_BY(Locks::deoptimization_lock_);
787 static size_t field_read_event_ref_count_ GUARDED_BY(Locks::deoptimization_lock_);
788 static size_t field_write_event_ref_count_ GUARDED_BY(Locks::deoptimization_lock_);
789 static size_t exception_catch_event_ref_count_ GUARDED_BY(Locks::deoptimization_lock_);
Sebastien Hertz42cd43f2014-05-13 14:15:41 +0200790 static uint32_t instrumentation_events_ GUARDED_BY(Locks::mutator_lock_);
791
Ian Rogers719d1a32014-03-06 12:13:39 -0800792 DISALLOW_COPY_AND_ASSIGN(Dbg);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700793};
794
795#define CHUNK_TYPE(_name) \
Elliott Hughes82188472011-11-07 18:11:48 -0800796 static_cast<uint32_t>((_name)[0] << 24 | (_name)[1] << 16 | (_name)[2] << 8 | (_name)[3])
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700797
798} // namespace art
799
Brian Carlstromfc0e3212013-07-17 14:40:12 -0700800#endif // ART_RUNTIME_DEBUGGER_H_