1872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes/* 2872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes * Copyright (C) 2008 The Android Open Source Project 3872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes * 4872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes * Licensed under the Apache License, Version 2.0 (the "License"); 5872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes * you may not use this file except in compliance with the License. 6872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes * You may obtain a copy of the License at 7872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes * 8872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes * http://www.apache.org/licenses/LICENSE-2.0 9872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes * 10872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes * Unless required by applicable law or agreed to in writing, software 11872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes * distributed under the License is distributed on an "AS IS" BASIS, 12872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes * See the License for the specific language governing permissions and 14872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes * limitations under the License. 15872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes */ 16872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes 17872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes/* 18872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes * Dalvik-specific side of debugger support. (The JDWP code is intended to 19872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes * be relatively generic.) 20872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes */ 21fc0e3219edc9a5bf81b166e82fd5db2796eb6a0dBrian Carlstrom#ifndef ART_RUNTIME_DEBUGGER_H_ 22fc0e3219edc9a5bf81b166e82fd5db2796eb6a0dBrian Carlstrom#define ART_RUNTIME_DEBUGGER_H_ 23872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes 24872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes#include <pthread.h> 25872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes 263bb81563481d02b5a6349b8ed918392454e761d8Elliott Hughes#include <string> 273bb81563481d02b5a6349b8ed918392454e761d8Elliott Hughes 28872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes#include "jdwp/jdwp.h" 292dd0e2cea360bc9206eb88ecc40d259e796c239dIan Rogers#include "jni.h" 302dd0e2cea360bc9206eb88ecc40d259e796c239dIan Rogers#include "jvalue.h" 312dd0e2cea360bc9206eb88ecc40d259e796c239dIan Rogers#include "root_visitor.h" 32920af3e556c730a5fbdab90a6d0ec1a2dbe8940bJeff Hao#include "thread_state.h" 33872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes 34872d4ec7225444d9400d30f9027247deb91012fdElliott Hughesnamespace art { 352dd0e2cea360bc9206eb88ecc40d259e796c239dIan Rogersnamespace mirror { 36ea46f950e7a51585db293cd7f047de190a482414Brian Carlstromclass ArtMethod; 372dd0e2cea360bc9206eb88ecc40d259e796c239dIan Rogersclass Class; 382dd0e2cea360bc9206eb88ecc40d259e796c239dIan Rogersclass Object; 392dd0e2cea360bc9206eb88ecc40d259e796c239dIan Rogersclass Throwable; 402dd0e2cea360bc9206eb88ecc40d259e796c239dIan Rogers} // namespace mirror 41545a064aca775ba801790fced3d713d8a87bfc61Elliott Hughesstruct AllocRecord; 421b09b094a85e03f6ef5f687f58bb91c433273ba1Ian Rogersclass Thread; 4362d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogersclass ThrowLocation; 44872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes 45872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes/* 46872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes * Invoke-during-breakpoint support. 47872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes */ 48872d4ec7225444d9400d30f9027247deb91012fdElliott Hughesstruct DebugInvokeReq { 497b3cdfcca472b779cf8745fb8460935e56229f11Elliott Hughes DebugInvokeReq() 5000f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers : ready(false), invoke_needed_(false), 5100f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers receiver_(NULL), thread_(NULL), class_(NULL), method_(NULL), 5200f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers arg_count_(0), arg_values_(NULL), options_(0), error(JDWP::ERR_NONE), 5300f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers result_tag(JDWP::JT_VOID), exception(0), 549b5aa6f2029d3dae305009ac72e44ca97ca7b638jeffhao lock_("a DebugInvokeReq lock", kBreakpointInvokeLock), 55c604d731730b43231f63040c8db1d58304da0cf3Ian Rogers cond_("a DebugInvokeReq condition variable", lock_) { 56475fc23a4a7f35d1be87ea0b06c80df317a720acElliott Hughes } 57475fc23a4a7f35d1be87ea0b06c80df317a720acElliott Hughes 58872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes /* boolean; only set when we're in the tail end of an event handler */ 59872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes bool ready; 60872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes 61872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes /* boolean; set if the JDWP thread wants this thread to do work */ 62d07986fad0d08cdf05505cf9230714a2cf0dd9aeElliott Hughes bool invoke_needed_; 63872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes 64872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes /* request */ 652dd0e2cea360bc9206eb88ecc40d259e796c239dIan Rogers mirror::Object* receiver_; /* not used for ClassType.InvokeMethod */ 662dd0e2cea360bc9206eb88ecc40d259e796c239dIan Rogers mirror::Object* thread_; 672dd0e2cea360bc9206eb88ecc40d259e796c239dIan Rogers mirror::Class* class_; 68ea46f950e7a51585db293cd7f047de190a482414Brian Carlstrom mirror::ArtMethod* method_; 6945651fde99f52546e71241bb0e8a10d16a9f216aElliott Hughes uint32_t arg_count_; 7045651fde99f52546e71241bb0e8a10d16a9f216aElliott Hughes uint64_t* arg_values_; /* will be NULL if arg_count_ == 0 */ 71d07986fad0d08cdf05505cf9230714a2cf0dd9aeElliott Hughes uint32_t options_; 72872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes 73872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes /* result */ 74475fc23a4a7f35d1be87ea0b06c80df317a720acElliott Hughes JDWP::JdwpError error; 75d07986fad0d08cdf05505cf9230714a2cf0dd9aeElliott Hughes JDWP::JdwpTag result_tag; 76475fc23a4a7f35d1be87ea0b06c80df317a720acElliott Hughes JValue result_value; 77475fc23a4a7f35d1be87ea0b06c80df317a720acElliott Hughes JDWP::ObjectId exception; 78872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes 79872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes /* condition variable to wait on while the method executes */ 80c604d731730b43231f63040c8db1d58304da0cf3Ian Rogers Mutex lock_ DEFAULT_MUTEX_ACQUIRED_AFTER; 81c604d731730b43231f63040c8db1d58304da0cf3Ian Rogers ConditionVariable cond_ GUARDED_BY(lock_); 82872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes}; 83872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes 84872d4ec7225444d9400d30f9027247deb91012fdElliott Hughesclass Dbg { 85ff17f1fd3ff32f93e45588eb2b158832d73f9afaElliott Hughes public: 863bb81563481d02b5a6349b8ed918392454e761d8Elliott Hughes static bool ParseJdwpOptions(const std::string& options); 874ffd31315bc0d00ec278e85feed15985de5ac3dcElliott Hughes static void SetJdwpAllowed(bool allowed); 884ffd31315bc0d00ec278e85feed15985de5ac3dcElliott Hughes 89d1cc8363d4f4bbac7568b1d02a5ca481cd10830fElliott Hughes static void StartJdwp(); 90d1cc8363d4f4bbac7568b1d02a5ca481cd10830fElliott Hughes static void StopJdwp(); 91d1cc8363d4f4bbac7568b1d02a5ca481cd10830fElliott Hughes 92767a147529da3ee8240f3ce4cd3af22ae454be64Elliott Hughes // Invoked by the GC in case we need to keep DDMS informed. 93b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers static void GcDidFinish() LOCKS_EXCLUDED(Locks::mutator_lock_); 94767a147529da3ee8240f3ce4cd3af22ae454be64Elliott Hughes 95872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes // Return the DebugInvokeReq for the current thread. 96872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes static DebugInvokeReq* GetInvokeReq(); 97872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes 98475fc23a4a7f35d1be87ea0b06c80df317a720acElliott Hughes static Thread* GetDebugThread(); 99475fc23a4a7f35d1be87ea0b06c80df317a720acElliott Hughes static void ClearWaitForEventThread(); 100475fc23a4a7f35d1be87ea0b06c80df317a720acElliott Hughes 101872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes /* 102872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes * Enable/disable breakpoints and step modes. Used to provide a heads-up 103872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes * when the debugger attaches. 104872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes */ 105872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes static void Connected(); 10662d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers static void GoActive() LOCKS_EXCLUDED(Locks::breakpoint_lock_, Locks::mutator_lock_); 10762d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers static void Disconnected() LOCKS_EXCLUDED(Locks::mutator_lock_); 1088696433d1b3d8ba15288483b777edd888de69135Elliott Hughes static void Disposed(); 109872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes 110c0f0933249cf516b37717faa766e1e9808f7c1f8Elliott Hughes // Returns true if we're actually debugging with a real debugger, false if it's 111c0f0933249cf516b37717faa766e1e9808f7c1f8Elliott Hughes // just DDMS (or nothing at all). 112c0f0933249cf516b37717faa766e1e9808f7c1f8Elliott Hughes static bool IsDebuggerActive(); 113872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes 114c0f0933249cf516b37717faa766e1e9808f7c1f8Elliott Hughes // Returns true if we had -Xrunjdwp or -agentlib:jdwp= on the command line. 115c0f0933249cf516b37717faa766e1e9808f7c1f8Elliott Hughes static bool IsJdwpConfigured(); 116872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes 1178696433d1b3d8ba15288483b777edd888de69135Elliott Hughes static bool IsDisposed(); 1188696433d1b3d8ba15288483b777edd888de69135Elliott Hughes 119872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes /* 120872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes * Time, in milliseconds, since the last debugger activity. Does not 121872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes * include DDMS activity. Returns -1 if there has been no activity. 122872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes * Returns 0 if we're in the middle of handling a debugger request. 123872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes */ 124872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes static int64_t LastDebuggerActivity(); 125872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes 126872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes static void UndoDebuggerSuspensions(); 127872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes 128872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes /* 129872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes * Class, Object, Array 130872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes */ 13100f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers static std::string GetClassName(JDWP::RefTypeId id) 132b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 13388d630950cb5c6a1cb6457ce03a17c074ae13628Elliott Hughes static JDWP::JdwpError GetClassObject(JDWP::RefTypeId id, JDWP::ObjectId& class_object_id) 134b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 13588d630950cb5c6a1cb6457ce03a17c074ae13628Elliott Hughes static JDWP::JdwpError GetSuperclass(JDWP::RefTypeId id, JDWP::RefTypeId& superclass_id) 136b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 13700f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers static JDWP::JdwpError GetClassLoader(JDWP::RefTypeId id, JDWP::ExpandBuf* pReply) 138b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 13900f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers static JDWP::JdwpError GetModifiers(JDWP::RefTypeId id, JDWP::ExpandBuf* pReply) 140b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 14188d630950cb5c6a1cb6457ce03a17c074ae13628Elliott Hughes static JDWP::JdwpError GetReflectedType(JDWP::RefTypeId class_id, JDWP::ExpandBuf* pReply) 142b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 14300f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers static void GetClassList(std::vector<JDWP::RefTypeId>& classes) 144b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 14588d630950cb5c6a1cb6457ce03a17c074ae13628Elliott Hughes static JDWP::JdwpError GetClassInfo(JDWP::RefTypeId class_id, JDWP::JdwpTypeTag* pTypeTag, 14600f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers uint32_t* pStatus, std::string* pDescriptor) 147b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 14800f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers static void FindLoadedClassBySignature(const char* descriptor, std::vector<JDWP::RefTypeId>& ids) 149b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 15064f574f474aa77c72778640ab21f8cfa72546812Elliott Hughes static JDWP::JdwpError GetReferenceType(JDWP::ObjectId object_id, JDWP::ExpandBuf* pReply) 15164f574f474aa77c72778640ab21f8cfa72546812Elliott Hughes SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 15288d630950cb5c6a1cb6457ce03a17c074ae13628Elliott Hughes static JDWP::JdwpError GetSignature(JDWP::RefTypeId ref_type_id, std::string& signature) 153b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 15488d630950cb5c6a1cb6457ce03a17c074ae13628Elliott Hughes static JDWP::JdwpError GetSourceFile(JDWP::RefTypeId ref_type_id, std::string& source_file) 155b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 15688d630950cb5c6a1cb6457ce03a17c074ae13628Elliott Hughes static JDWP::JdwpError GetObjectTag(JDWP::ObjectId object_id, uint8_t& tag) 157b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 158aed4be94da51b4fbb54c728151f0daf11535f6abElliott Hughes static size_t GetTagWidth(JDWP::JdwpTag tag); 159872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes 16088d630950cb5c6a1cb6457ce03a17c074ae13628Elliott Hughes static JDWP::JdwpError GetArrayLength(JDWP::ObjectId array_id, int& length) 161b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 16288d630950cb5c6a1cb6457ce03a17c074ae13628Elliott Hughes static JDWP::JdwpError OutputArray(JDWP::ObjectId array_id, int offset, int count, 16300f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers JDWP::ExpandBuf* pReply) 164b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 16588d630950cb5c6a1cb6457ce03a17c074ae13628Elliott Hughes static JDWP::JdwpError SetArrayElements(JDWP::ObjectId array_id, int offset, int count, 1664b9702c6912c6f8745a77f5b5af56e7fe196e7c2Elliott Hughes JDWP::Request& request) 167b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 16800f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers 16900f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers static JDWP::ObjectId CreateString(const std::string& str) 170b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 17188d630950cb5c6a1cb6457ce03a17c074ae13628Elliott Hughes static JDWP::JdwpError CreateObject(JDWP::RefTypeId class_id, JDWP::ObjectId& new_object) 172b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 17388d630950cb5c6a1cb6457ce03a17c074ae13628Elliott Hughes static JDWP::JdwpError CreateArrayObject(JDWP::RefTypeId array_class_id, uint32_t length, 17400f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers JDWP::ObjectId& new_array) 175b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 17600f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers 17788d630950cb5c6a1cb6457ce03a17c074ae13628Elliott Hughes static bool MatchType(JDWP::RefTypeId instance_class_id, JDWP::RefTypeId class_id) 178b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 179872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes 180ec0f83d95e2174c97e93279ffa71642be7e12b60Elliott Hughes // 181ec0f83d95e2174c97e93279ffa71642be7e12b60Elliott Hughes // Monitors. 182ec0f83d95e2174c97e93279ffa71642be7e12b60Elliott Hughes // 183ec0f83d95e2174c97e93279ffa71642be7e12b60Elliott Hughes static JDWP::JdwpError GetMonitorInfo(JDWP::ObjectId object_id, JDWP::ExpandBuf* reply) 184ec0f83d95e2174c97e93279ffa71642be7e12b60Elliott Hughes SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 185ec0f83d95e2174c97e93279ffa71642be7e12b60Elliott Hughes static JDWP::JdwpError GetOwnedMonitors(JDWP::ObjectId thread_id, 186ec0f83d95e2174c97e93279ffa71642be7e12b60Elliott Hughes std::vector<JDWP::ObjectId>& monitors, 187ec0f83d95e2174c97e93279ffa71642be7e12b60Elliott Hughes std::vector<uint32_t>& stack_depths) 188ec0f83d95e2174c97e93279ffa71642be7e12b60Elliott Hughes SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 189ec0f83d95e2174c97e93279ffa71642be7e12b60Elliott Hughes static JDWP::JdwpError GetContendedMonitor(JDWP::ObjectId thread_id, JDWP::ObjectId& contended_monitor) 190ec0f83d95e2174c97e93279ffa71642be7e12b60Elliott Hughes SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 191ec0f83d95e2174c97e93279ffa71642be7e12b60Elliott Hughes 192ec0f83d95e2174c97e93279ffa71642be7e12b60Elliott Hughes // 193ec0f83d95e2174c97e93279ffa71642be7e12b60Elliott Hughes // Heap. 194ec0f83d95e2174c97e93279ffa71642be7e12b60Elliott Hughes // 195ec0f83d95e2174c97e93279ffa71642be7e12b60Elliott Hughes static JDWP::JdwpError GetInstanceCounts(const std::vector<JDWP::RefTypeId>& class_ids, 196ec0f83d95e2174c97e93279ffa71642be7e12b60Elliott Hughes std::vector<uint64_t>& counts) 197ec0f83d95e2174c97e93279ffa71642be7e12b60Elliott Hughes SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 1983b78c949ab839d21454bc6f18c7640d2ae8c22f3Elliott Hughes static JDWP::JdwpError GetInstances(JDWP::RefTypeId class_id, int32_t max_count, 1993b78c949ab839d21454bc6f18c7640d2ae8c22f3Elliott Hughes std::vector<JDWP::ObjectId>& instances) 2003b78c949ab839d21454bc6f18c7640d2ae8c22f3Elliott Hughes SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 2010cbaff584244ee767027aff35cd3c625aaee2994Elliott Hughes static JDWP::JdwpError GetReferringObjects(JDWP::ObjectId object_id, int32_t max_count, 2020cbaff584244ee767027aff35cd3c625aaee2994Elliott Hughes std::vector<JDWP::ObjectId>& referring_objects) 2030cbaff584244ee767027aff35cd3c625aaee2994Elliott Hughes SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 20464f574f474aa77c72778640ab21f8cfa72546812Elliott Hughes static JDWP::JdwpError DisableCollection(JDWP::ObjectId object_id) 20564f574f474aa77c72778640ab21f8cfa72546812Elliott Hughes SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 20664f574f474aa77c72778640ab21f8cfa72546812Elliott Hughes static JDWP::JdwpError EnableCollection(JDWP::ObjectId object_id) 20764f574f474aa77c72778640ab21f8cfa72546812Elliott Hughes SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 20864f574f474aa77c72778640ab21f8cfa72546812Elliott Hughes static JDWP::JdwpError IsCollected(JDWP::ObjectId object_id, bool& is_collected) 20964f574f474aa77c72778640ab21f8cfa72546812Elliott Hughes SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 21064f574f474aa77c72778640ab21f8cfa72546812Elliott Hughes static void DisposeObject(JDWP::ObjectId object_id, uint32_t reference_count) 21164f574f474aa77c72778640ab21f8cfa72546812Elliott Hughes SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 212ec0f83d95e2174c97e93279ffa71642be7e12b60Elliott Hughes 2139777ba230c83a0edcbda2cf7b208339e77bf171bElliott Hughes // 2149777ba230c83a0edcbda2cf7b208339e77bf171bElliott Hughes // Methods and fields. 2159777ba230c83a0edcbda2cf7b208339e77bf171bElliott Hughes // 216a96836a4115ad08762567c10bd4d198c5b644985Elliott Hughes static std::string GetMethodName(JDWP::MethodId method_id) 217b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 21888d630950cb5c6a1cb6457ce03a17c074ae13628Elliott Hughes static JDWP::JdwpError OutputDeclaredFields(JDWP::RefTypeId ref_type_id, bool with_generic, 21900f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers JDWP::ExpandBuf* pReply) 220b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 22188d630950cb5c6a1cb6457ce03a17c074ae13628Elliott Hughes static JDWP::JdwpError OutputDeclaredMethods(JDWP::RefTypeId ref_type_id, bool with_generic, 22200f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers JDWP::ExpandBuf* pReply) 223b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 22488d630950cb5c6a1cb6457ce03a17c074ae13628Elliott Hughes static JDWP::JdwpError OutputDeclaredInterfaces(JDWP::RefTypeId ref_type_id, 22500f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers JDWP::ExpandBuf* pReply) 226b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 22788d630950cb5c6a1cb6457ce03a17c074ae13628Elliott Hughes static void OutputLineTable(JDWP::RefTypeId ref_type_id, JDWP::MethodId method_id, 22800f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers JDWP::ExpandBuf* pReply) 229b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 23088d630950cb5c6a1cb6457ce03a17c074ae13628Elliott Hughes static void OutputVariableTable(JDWP::RefTypeId ref_type_id, JDWP::MethodId id, bool with_generic, 23100f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers JDWP::ExpandBuf* pReply) 232b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 2339777ba230c83a0edcbda2cf7b208339e77bf171bElliott Hughes static JDWP::JdwpError GetBytecodes(JDWP::RefTypeId class_id, JDWP::MethodId method_id, 2349777ba230c83a0edcbda2cf7b208339e77bf171bElliott Hughes std::vector<uint8_t>& bytecodes) 2359777ba230c83a0edcbda2cf7b208339e77bf171bElliott Hughes SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 23600f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers 237a96836a4115ad08762567c10bd4d198c5b644985Elliott Hughes static std::string GetFieldName(JDWP::FieldId field_id) 238a96836a4115ad08762567c10bd4d198c5b644985Elliott Hughes SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 23988d630950cb5c6a1cb6457ce03a17c074ae13628Elliott Hughes static JDWP::JdwpTag GetFieldBasicTag(JDWP::FieldId field_id) 240b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 24188d630950cb5c6a1cb6457ce03a17c074ae13628Elliott Hughes static JDWP::JdwpTag GetStaticFieldBasicTag(JDWP::FieldId field_id) 242f69863b3039fc621ff4250e262d2a024d5e79ec8Brian Carlstrom SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 24388d630950cb5c6a1cb6457ce03a17c074ae13628Elliott Hughes static JDWP::JdwpError GetFieldValue(JDWP::ObjectId object_id, JDWP::FieldId field_id, 24400f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers JDWP::ExpandBuf* pReply) 245b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 24688d630950cb5c6a1cb6457ce03a17c074ae13628Elliott Hughes static JDWP::JdwpError SetFieldValue(JDWP::ObjectId object_id, JDWP::FieldId field_id, 24700f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers uint64_t value, int width) 248b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 24988d630950cb5c6a1cb6457ce03a17c074ae13628Elliott Hughes static JDWP::JdwpError GetStaticFieldValue(JDWP::RefTypeId ref_type_id, JDWP::FieldId field_id, 25000f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers JDWP::ExpandBuf* pReply) 251b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 25288d630950cb5c6a1cb6457ce03a17c074ae13628Elliott Hughes static JDWP::JdwpError SetStaticFieldValue(JDWP::FieldId field_id, uint64_t value, int width) 253b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 25400f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers 25588d630950cb5c6a1cb6457ce03a17c074ae13628Elliott Hughes static std::string StringToUtf8(JDWP::ObjectId string_id) 256b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 257872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes 258872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes /* 259872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes * Thread, ThreadGroup, Frame 260872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes */ 26188d630950cb5c6a1cb6457ce03a17c074ae13628Elliott Hughes static JDWP::JdwpError GetThreadName(JDWP::ObjectId thread_id, std::string& name) 262b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) 263b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers LOCKS_EXCLUDED(Locks::thread_list_lock_); 26488d630950cb5c6a1cb6457ce03a17c074ae13628Elliott Hughes static JDWP::JdwpError GetThreadGroup(JDWP::ObjectId thread_id, JDWP::ExpandBuf* pReply); 26588d630950cb5c6a1cb6457ce03a17c074ae13628Elliott Hughes static std::string GetThreadGroupName(JDWP::ObjectId thread_group_id); 26688d630950cb5c6a1cb6457ce03a17c074ae13628Elliott Hughes static JDWP::ObjectId GetThreadGroupParent(JDWP::ObjectId thread_group_id) 267b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 26800f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers static JDWP::ObjectId GetSystemThreadGroupId() 269b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 270872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes static JDWP::ObjectId GetMainThreadGroupId(); 271872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes 272920af3e556c730a5fbdab90a6d0ec1a2dbe8940bJeff Hao static JDWP::JdwpThreadStatus ToJdwpThreadStatus(ThreadState state); 27388d630950cb5c6a1cb6457ce03a17c074ae13628Elliott Hughes static JDWP::JdwpError GetThreadStatus(JDWP::ObjectId thread_id, JDWP::JdwpThreadStatus* pThreadStatus, JDWP::JdwpSuspendStatus* pSuspendStatus); 27488d630950cb5c6a1cb6457ce03a17c074ae13628Elliott Hughes static JDWP::JdwpError GetThreadDebugSuspendCount(JDWP::ObjectId thread_id, JDWP::ExpandBuf* pReply); 2757934ac288acfb2552bb0b06ec1f61e5820d924a4Brian Carlstrom // static void WaitForSuspend(JDWP::ObjectId thread_id); 276caf7654a0e6c76c7489970b1a246fccf220f9982Elliott Hughes 277026b14660723c2b25a4f3ef6394f43a4fe64ba92Elliott Hughes // Fills 'thread_ids' with the threads in the given thread group. If thread_group_id == 0, 278caf7654a0e6c76c7489970b1a246fccf220f9982Elliott Hughes // returns all threads. 27900f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers static void GetThreads(JDWP::ObjectId thread_group_id, std::vector<JDWP::ObjectId>& thread_ids) 280b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers LOCKS_EXCLUDED(Locks::thread_list_lock_) 281b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 282caf7654a0e6c76c7489970b1a246fccf220f9982Elliott Hughes static void GetChildThreadGroups(JDWP::ObjectId thread_group_id, std::vector<JDWP::ObjectId>& child_thread_group_ids); 283caf7654a0e6c76c7489970b1a246fccf220f9982Elliott Hughes 28488d630950cb5c6a1cb6457ce03a17c074ae13628Elliott Hughes static JDWP::JdwpError GetThreadFrameCount(JDWP::ObjectId thread_id, size_t& result); 28500f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers static JDWP::JdwpError GetThreadFrames(JDWP::ObjectId thread_id, size_t start_frame, 28600f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers size_t frame_count, JDWP::ExpandBuf* buf) 287b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 28800f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers 28900f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers static JDWP::ObjectId GetThreadSelfId() 290b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 29100f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers static void SuspendVM() 292b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers LOCKS_EXCLUDED(Locks::thread_list_lock_, 293b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers Locks::thread_suspend_count_lock_); 294872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes static void ResumeVM(); 29588d630950cb5c6a1cb6457ce03a17c074ae13628Elliott Hughes static JDWP::JdwpError SuspendThread(JDWP::ObjectId thread_id, bool request_suspension = true) 296b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers LOCKS_EXCLUDED(Locks::mutator_lock_, 297b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers Locks::thread_list_lock_, 298b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers Locks::thread_suspend_count_lock_); 29900f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers 30088d630950cb5c6a1cb6457ce03a17c074ae13628Elliott Hughes static void ResumeThread(JDWP::ObjectId thread_id) 301b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers LOCKS_EXCLUDED(Locks::thread_list_lock_, 302b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers Locks::thread_suspend_count_lock_) 303b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 304872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes static void SuspendSelf(); 305872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes 30600f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers static JDWP::JdwpError GetThisObject(JDWP::ObjectId thread_id, JDWP::FrameId frame_id, 30700f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers JDWP::ObjectId* result) 308b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers LOCKS_EXCLUDED(Locks::thread_list_lock_, 309b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers Locks::thread_suspend_count_lock_) 310b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 31188d630950cb5c6a1cb6457ce03a17c074ae13628Elliott Hughes static void GetLocalValue(JDWP::ObjectId thread_id, JDWP::FrameId frame_id, int slot, 31200f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers JDWP::JdwpTag tag, uint8_t* buf, size_t expectedLen) 313b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 31488d630950cb5c6a1cb6457ce03a17c074ae13628Elliott Hughes static void SetLocalValue(JDWP::ObjectId thread_id, JDWP::FrameId frame_id, int slot, 31500f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers JDWP::JdwpTag tag, uint64_t value, size_t width) 316b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 317872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes 318f9501700f51586cb6ba7cc0ffcb5a920bd64adf1Elliott Hughes static JDWP::JdwpError Interrupt(JDWP::ObjectId thread_id); 319f9501700f51586cb6ba7cc0ffcb5a920bd64adf1Elliott Hughes 320872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes /* 321872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes * Debugger notification 322872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes */ 323872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes enum { 3248696433d1b3d8ba15288483b777edd888de69135Elliott Hughes kBreakpoint = 0x01, 325872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes kSingleStep = 0x02, 326872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes kMethodEntry = 0x04, 327872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes kMethodExit = 0x08, 328872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes }; 329ea46f950e7a51585db293cd7f047de190a482414Brian Carlstrom static void PostLocationEvent(const mirror::ArtMethod* method, int pcOffset, 3302dd0e2cea360bc9206eb88ecc40d259e796c239dIan Rogers mirror::Object* thisPtr, int eventFlags) 331b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 33262d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers static void PostException(Thread* thread, const ThrowLocation& throw_location, 333ea46f950e7a51585db293cd7f047de190a482414Brian Carlstrom mirror::ArtMethod* catch_method, 3342dd0e2cea360bc9206eb88ecc40d259e796c239dIan Rogers uint32_t catch_dex_pc, mirror::Throwable* exception) 335b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 33600f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers static void PostThreadStart(Thread* t) 337b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 33800f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers static void PostThreadDeath(Thread* t) 339b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 3402dd0e2cea360bc9206eb88ecc40d259e796c239dIan Rogers static void PostClassPrepare(mirror::Class* c) 341b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 34200f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers 34362d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers static void UpdateDebugger(Thread* thread, mirror::Object* this_object, 344ea46f950e7a51585db293cd7f047de190a482414Brian Carlstrom const mirror::ArtMethod* method, uint32_t new_dex_pc) 34509bfc6a50bdc9366b13ac3ab479d9278c853d90ajeffhao LOCKS_EXCLUDED(Locks::breakpoint_lock_) 346b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 34700f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers 34800f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers static void WatchLocation(const JDWP::JdwpLocation* pLoc) 34909bfc6a50bdc9366b13ac3ab479d9278c853d90ajeffhao LOCKS_EXCLUDED(Locks::breakpoint_lock_) 350b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 35100f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers static void UnwatchLocation(const JDWP::JdwpLocation* pLoc) 35209bfc6a50bdc9366b13ac3ab479d9278c853d90ajeffhao LOCKS_EXCLUDED(Locks::breakpoint_lock_) 353b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 35488d630950cb5c6a1cb6457ce03a17c074ae13628Elliott Hughes static JDWP::JdwpError ConfigureStep(JDWP::ObjectId thread_id, JDWP::JdwpStepSize size, 35500f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers JDWP::JdwpStepDepth depth) 35609bfc6a50bdc9366b13ac3ab479d9278c853d90ajeffhao LOCKS_EXCLUDED(Locks::breakpoint_lock_) 357b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 35888d630950cb5c6a1cb6457ce03a17c074ae13628Elliott Hughes static void UnconfigureStep(JDWP::ObjectId thread_id) LOCKS_EXCLUDED(Locks::breakpoint_lock_); 359872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes 36088d630950cb5c6a1cb6457ce03a17c074ae13628Elliott Hughes static JDWP::JdwpError InvokeMethod(JDWP::ObjectId thread_id, JDWP::ObjectId object_id, 36188d630950cb5c6a1cb6457ce03a17c074ae13628Elliott Hughes JDWP::RefTypeId class_id, JDWP::MethodId method_id, 36200f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers uint32_t arg_count, uint64_t* arg_values, 36300f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers JDWP::JdwpTag* arg_types, uint32_t options, 36400f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers JDWP::JdwpTag* pResultTag, uint64_t* pResultValue, 36500f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers JDWP::ObjectId* pExceptObj) 366b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers LOCKS_EXCLUDED(Locks::thread_list_lock_, 367b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers Locks::thread_suspend_count_lock_) 368b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 369872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes static void ExecuteMethod(DebugInvokeReq* pReq); 370872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes 371872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes /* 372872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes * DDM support. 373872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes */ 37400f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers static void DdmSendThreadNotification(Thread* t, uint32_t type) 375b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 37647fce01c0f27dba716fa6b97242562fbc5c26eeaElliott Hughes static void DdmSetThreadNotification(bool enable); 3774b9702c6912c6f8745a77f5b5af56e7fe196e7c2Elliott Hughes static bool DdmHandlePacket(JDWP::Request& request, uint8_t** pReplyBuf, int* pReplyLen); 378b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers static void DdmConnected() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 379b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers static void DdmDisconnected() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 38000f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers static void DdmSendChunk(uint32_t type, const std::vector<uint8_t>& bytes) 381b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 38200f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers static void DdmSendChunk(uint32_t type, size_t len, const uint8_t* buf) 383b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 38400f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers static void DdmSendChunkV(uint32_t type, const iovec* iov, int iov_count) 385b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 386767a147529da3ee8240f3ce4cd3af22ae454be64Elliott Hughes 387545a064aca775ba801790fced3d713d8a87bfc61Elliott Hughes /* 388545a064aca775ba801790fced3d713d8a87bfc61Elliott Hughes * Recent allocation tracking support. 389545a064aca775ba801790fced3d713d8a87bfc61Elliott Hughes */ 3902dd0e2cea360bc9206eb88ecc40d259e796c239dIan Rogers static void RecordAllocation(mirror::Class* type, size_t byte_count) 391b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 392545a064aca775ba801790fced3d713d8a87bfc61Elliott Hughes static void SetAllocTrackingEnabled(bool enabled); 393545a064aca775ba801790fced3d713d8a87bfc61Elliott Hughes static inline bool IsAllocTrackingEnabled() { return recent_allocation_records_ != NULL; } 3942dd0e2cea360bc9206eb88ecc40d259e796c239dIan Rogers static jbyteArray GetRecentAllocations() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 395545a064aca775ba801790fced3d713d8a87bfc61Elliott Hughes static void DumpRecentAllocations(); 396545a064aca775ba801790fced3d713d8a87bfc61Elliott Hughes 397767a147529da3ee8240f3ce4cd3af22ae454be64Elliott Hughes enum HpifWhen { 398767a147529da3ee8240f3ce4cd3af22ae454be64Elliott Hughes HPIF_WHEN_NEVER = 0, 399767a147529da3ee8240f3ce4cd3af22ae454be64Elliott Hughes HPIF_WHEN_NOW = 1, 400767a147529da3ee8240f3ce4cd3af22ae454be64Elliott Hughes HPIF_WHEN_NEXT_GC = 2, 401767a147529da3ee8240f3ce4cd3af22ae454be64Elliott Hughes HPIF_WHEN_EVERY_GC = 3 402767a147529da3ee8240f3ce4cd3af22ae454be64Elliott Hughes }; 40300f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers static int DdmHandleHpifChunk(HpifWhen when) 404b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 405767a147529da3ee8240f3ce4cd3af22ae454be64Elliott Hughes 406767a147529da3ee8240f3ce4cd3af22ae454be64Elliott Hughes enum HpsgWhen { 407767a147529da3ee8240f3ce4cd3af22ae454be64Elliott Hughes HPSG_WHEN_NEVER = 0, 408767a147529da3ee8240f3ce4cd3af22ae454be64Elliott Hughes HPSG_WHEN_EVERY_GC = 1, 409767a147529da3ee8240f3ce4cd3af22ae454be64Elliott Hughes }; 410767a147529da3ee8240f3ce4cd3af22ae454be64Elliott Hughes enum HpsgWhat { 411767a147529da3ee8240f3ce4cd3af22ae454be64Elliott Hughes HPSG_WHAT_MERGED_OBJECTS = 0, 412767a147529da3ee8240f3ce4cd3af22ae454be64Elliott Hughes HPSG_WHAT_DISTINCT_OBJECTS = 1, 413767a147529da3ee8240f3ce4cd3af22ae454be64Elliott Hughes }; 414767a147529da3ee8240f3ce4cd3af22ae454be64Elliott Hughes static bool DdmHandleHpsgNhsgChunk(HpsgWhen when, HpsgWhat what, bool native); 415767a147529da3ee8240f3ce4cd3af22ae454be64Elliott Hughes 41600f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers static void DdmSendHeapInfo(HpifWhen reason) 417b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 41800f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers static void DdmSendHeapSegments(bool native) 419b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 420545a064aca775ba801790fced3d713d8a87bfc61Elliott Hughes 421545a064aca775ba801790fced3d713d8a87bfc61Elliott Hughes private: 4222d88862f0752a7a0e65145b088f49dabd49d4284Brian Carlstrom static void DdmBroadcast(bool connect) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 42300f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers static void PostThreadStartOrStop(Thread*, uint32_t) 424b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 425a215526d5c789cbef0f81a1f9aba22541a841ccaElliott Hughes 426545a064aca775ba801790fced3d713d8a87bfc61Elliott Hughes static AllocRecord* recent_allocation_records_; 427872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes}; 428872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes 429872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes#define CHUNK_TYPE(_name) \ 4308218847294600bbfcdc041a46c2b579b6e70cf3bElliott Hughes static_cast<uint32_t>((_name)[0] << 24 | (_name)[1] << 16 | (_name)[2] << 8 | (_name)[3]) 431872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes 432872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes} // namespace art 433872d4ec7225444d9400d30f9027247deb91012fdElliott Hughes 434fc0e3219edc9a5bf81b166e82fd5db2796eb6a0dBrian Carlstrom#endif // ART_RUNTIME_DEBUGGER_H_ 435