blob: 7d6d3448fb963fb44dadd98bb4ec41adb90ce52a [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#include "debugger.h"
18
Elliott Hughes3bb81562011-10-21 18:52:59 -070019#include <sys/uio.h>
20
Elliott Hughes475fc232011-10-25 15:00:35 -070021#include "thread_list.h"
22
Elliott Hughes872d4ec2011-10-21 17:07:15 -070023namespace art {
24
Elliott Hughes475fc232011-10-25 15:00:35 -070025class ObjectRegistry {
26 public:
27 ObjectRegistry() : lock_("ObjectRegistry lock") {
28 }
29
30 JDWP::ObjectId Add(Object* o) {
31 if (o == NULL) {
32 return 0;
33 }
34 JDWP::ObjectId id = static_cast<JDWP::ObjectId>(reinterpret_cast<uintptr_t>(o));
35 MutexLock mu(lock_);
36 map_[id] = o;
37 return id;
38 }
39
40 bool Contains(JDWP::ObjectId id) {
41 MutexLock mu(lock_);
42 return map_.find(id) != map_.end();
43 }
44
45 private:
46 Mutex lock_;
47 std::map<JDWP::ObjectId, Object*> map_;
48};
49
Elliott Hughes4ffd3132011-10-24 12:06:42 -070050// JDWP is allowed unless the Zygote forbids it.
51static bool gJdwpAllowed = true;
52
Elliott Hughes3bb81562011-10-21 18:52:59 -070053// Was there a -Xrunjdwp or -agent argument on the command-line?
54static bool gJdwpConfigured = false;
55
56// Broken-down JDWP options. (Only valid if gJdwpConfigured is true.)
Elliott Hughes376a7a02011-10-24 18:35:55 -070057static JDWP::JdwpOptions gJdwpOptions;
Elliott Hughes3bb81562011-10-21 18:52:59 -070058
59// Runtime JDWP state.
60static JDWP::JdwpState* gJdwpState = NULL;
61static bool gDebuggerConnected; // debugger or DDMS is connected.
62static bool gDebuggerActive; // debugger is making requests.
63
Elliott Hughes475fc232011-10-25 15:00:35 -070064static ObjectRegistry* gRegistry = NULL;
65
Elliott Hughes3bb81562011-10-21 18:52:59 -070066/*
67 * Handle one of the JDWP name/value pairs.
68 *
69 * JDWP options are:
70 * help: if specified, show help message and bail
71 * transport: may be dt_socket or dt_shmem
72 * address: for dt_socket, "host:port", or just "port" when listening
73 * server: if "y", wait for debugger to attach; if "n", attach to debugger
74 * timeout: how long to wait for debugger to connect / listen
75 *
76 * Useful with server=n (these aren't supported yet):
77 * onthrow=<exception-name>: connect to debugger when exception thrown
78 * onuncaught=y|n: connect to debugger when uncaught exception thrown
79 * launch=<command-line>: launch the debugger itself
80 *
81 * The "transport" option is required, as is "address" if server=n.
82 */
83static bool ParseJdwpOption(const std::string& name, const std::string& value) {
84 if (name == "transport") {
85 if (value == "dt_socket") {
Elliott Hughes376a7a02011-10-24 18:35:55 -070086 gJdwpOptions.transport = JDWP::kJdwpTransportSocket;
Elliott Hughes3bb81562011-10-21 18:52:59 -070087 } else if (value == "dt_android_adb") {
Elliott Hughes376a7a02011-10-24 18:35:55 -070088 gJdwpOptions.transport = JDWP::kJdwpTransportAndroidAdb;
Elliott Hughes3bb81562011-10-21 18:52:59 -070089 } else {
90 LOG(ERROR) << "JDWP transport not supported: " << value;
91 return false;
92 }
93 } else if (name == "server") {
94 if (value == "n") {
Elliott Hughes376a7a02011-10-24 18:35:55 -070095 gJdwpOptions.server = false;
Elliott Hughes3bb81562011-10-21 18:52:59 -070096 } else if (value == "y") {
Elliott Hughes376a7a02011-10-24 18:35:55 -070097 gJdwpOptions.server = true;
Elliott Hughes3bb81562011-10-21 18:52:59 -070098 } else {
99 LOG(ERROR) << "JDWP option 'server' must be 'y' or 'n'";
100 return false;
101 }
102 } else if (name == "suspend") {
103 if (value == "n") {
Elliott Hughes376a7a02011-10-24 18:35:55 -0700104 gJdwpOptions.suspend = false;
Elliott Hughes3bb81562011-10-21 18:52:59 -0700105 } else if (value == "y") {
Elliott Hughes376a7a02011-10-24 18:35:55 -0700106 gJdwpOptions.suspend = true;
Elliott Hughes3bb81562011-10-21 18:52:59 -0700107 } else {
108 LOG(ERROR) << "JDWP option 'suspend' must be 'y' or 'n'";
109 return false;
110 }
111 } else if (name == "address") {
112 /* this is either <port> or <host>:<port> */
113 std::string port_string;
Elliott Hughes376a7a02011-10-24 18:35:55 -0700114 gJdwpOptions.host.clear();
Elliott Hughes3bb81562011-10-21 18:52:59 -0700115 std::string::size_type colon = value.find(':');
116 if (colon != std::string::npos) {
Elliott Hughes376a7a02011-10-24 18:35:55 -0700117 gJdwpOptions.host = value.substr(0, colon);
Elliott Hughes3bb81562011-10-21 18:52:59 -0700118 port_string = value.substr(colon + 1);
119 } else {
120 port_string = value;
121 }
122 if (port_string.empty()) {
123 LOG(ERROR) << "JDWP address missing port: " << value;
124 return false;
125 }
126 char* end;
127 long port = strtol(port_string.c_str(), &end, 10);
128 if (*end != '\0') {
129 LOG(ERROR) << "JDWP address has junk in port field: " << value;
130 return false;
131 }
Elliott Hughes376a7a02011-10-24 18:35:55 -0700132 gJdwpOptions.port = port;
Elliott Hughes3bb81562011-10-21 18:52:59 -0700133 } else if (name == "launch" || name == "onthrow" || name == "oncaught" || name == "timeout") {
134 /* valid but unsupported */
135 LOG(INFO) << "Ignoring JDWP option '" << name << "'='" << value << "'";
136 } else {
137 LOG(INFO) << "Ignoring unrecognized JDWP option '" << name << "'='" << value << "'";
138 }
139
140 return true;
141}
142
143/*
144 * Parse the latter half of a -Xrunjdwp/-agentlib:jdwp= string, e.g.:
145 * "transport=dt_socket,address=8000,server=y,suspend=n"
146 */
147bool Dbg::ParseJdwpOptions(const std::string& options) {
148 std::vector<std::string> pairs;
149 Split(options, ',', pairs);
150
151 for (size_t i = 0; i < pairs.size(); ++i) {
152 std::string::size_type equals = pairs[i].find('=');
153 if (equals == std::string::npos) {
154 LOG(ERROR) << "Can't parse JDWP option '" << pairs[i] << "' in '" << options << "'";
155 return false;
156 }
157 ParseJdwpOption(pairs[i].substr(0, equals), pairs[i].substr(equals + 1));
158 }
159
Elliott Hughes376a7a02011-10-24 18:35:55 -0700160 if (gJdwpOptions.transport == JDWP::kJdwpTransportUnknown) {
Elliott Hughes3bb81562011-10-21 18:52:59 -0700161 LOG(ERROR) << "Must specify JDWP transport: " << options;
162 }
Elliott Hughes376a7a02011-10-24 18:35:55 -0700163 if (!gJdwpOptions.server && (gJdwpOptions.host.empty() || gJdwpOptions.port == 0)) {
Elliott Hughes3bb81562011-10-21 18:52:59 -0700164 LOG(ERROR) << "Must specify JDWP host and port when server=n: " << options;
165 return false;
166 }
167
168 gJdwpConfigured = true;
169 return true;
170}
171
Elliott Hughesd1cc8362011-10-24 16:58:50 -0700172void Dbg::StartJdwp() {
Elliott Hughes376a7a02011-10-24 18:35:55 -0700173 if (!gJdwpAllowed || !gJdwpConfigured) {
174 // No JDWP for you!
175 return;
176 }
177
Elliott Hughes475fc232011-10-25 15:00:35 -0700178 CHECK(gRegistry == NULL);
179 gRegistry = new ObjectRegistry;
180
Elliott Hughesd1cc8362011-10-24 16:58:50 -0700181 // Init JDWP if the debugger is enabled. This may connect out to a
182 // debugger, passively listen for a debugger, or block waiting for a
183 // debugger.
Elliott Hughes376a7a02011-10-24 18:35:55 -0700184 gJdwpState = JDWP::JdwpState::Create(&gJdwpOptions);
185 if (gJdwpState == NULL) {
186 LOG(WARNING) << "debugger thread failed to initialize";
Elliott Hughes475fc232011-10-25 15:00:35 -0700187 return;
Elliott Hughesd1cc8362011-10-24 16:58:50 -0700188 }
189
190 // If a debugger has already attached, send the "welcome" message.
191 // This may cause us to suspend all threads.
Elliott Hughes376a7a02011-10-24 18:35:55 -0700192 if (gJdwpState->IsActive()) {
Elliott Hughesd1cc8362011-10-24 16:58:50 -0700193 //ScopedThreadStateChange(Thread::Current(), Thread::kRunnable);
Elliott Hughes376a7a02011-10-24 18:35:55 -0700194 if (!gJdwpState->PostVMStart()) {
Elliott Hughesd1cc8362011-10-24 16:58:50 -0700195 LOG(WARNING) << "failed to post 'start' message to debugger";
196 }
197 }
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700198}
199
Elliott Hughesd1cc8362011-10-24 16:58:50 -0700200void Dbg::StopJdwp() {
Elliott Hughes376a7a02011-10-24 18:35:55 -0700201 delete gJdwpState;
Elliott Hughes475fc232011-10-25 15:00:35 -0700202 delete gRegistry;
203 gRegistry = NULL;
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700204}
205
Elliott Hughes4ffd3132011-10-24 12:06:42 -0700206void Dbg::SetJdwpAllowed(bool allowed) {
207 gJdwpAllowed = allowed;
208}
209
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700210DebugInvokeReq* Dbg::GetInvokeReq() {
Elliott Hughes475fc232011-10-25 15:00:35 -0700211 return Thread::Current()->GetInvokeReq();
212}
213
214Thread* Dbg::GetDebugThread() {
215 return (gJdwpState != NULL) ? gJdwpState->GetDebugThread() : NULL;
216}
217
218void Dbg::ClearWaitForEventThread() {
219 gJdwpState->ClearWaitForEventThread();
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700220}
221
222void Dbg::Connected() {
Elliott Hughes3bb81562011-10-21 18:52:59 -0700223 CHECK(!gDebuggerConnected);
224 LOG(VERBOSE) << "JDWP has attached";
225 gDebuggerConnected = true;
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700226}
227
228void Dbg::Active() {
229 UNIMPLEMENTED(FATAL);
230}
231
232void Dbg::Disconnected() {
233 UNIMPLEMENTED(FATAL);
234}
235
236bool Dbg::IsDebuggerConnected() {
Elliott Hughes3bb81562011-10-21 18:52:59 -0700237 return gDebuggerActive;
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700238}
239
240bool Dbg::IsDebuggingEnabled() {
Elliott Hughes3bb81562011-10-21 18:52:59 -0700241 return gJdwpConfigured;
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700242}
243
244int64_t Dbg::LastDebuggerActivity() {
245 UNIMPLEMENTED(WARNING);
246 return -1;
247}
248
249int Dbg::ThreadRunning() {
Elliott Hughesd1cc8362011-10-24 16:58:50 -0700250 return static_cast<int>(Thread::Current()->SetState(Thread::kRunnable));
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700251}
252
253int Dbg::ThreadWaiting() {
Elliott Hughesd1cc8362011-10-24 16:58:50 -0700254 return static_cast<int>(Thread::Current()->SetState(Thread::kVmWait));
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700255}
256
Elliott Hughes6ba581a2011-10-25 11:45:35 -0700257int Dbg::ThreadContinuing(int new_state) {
258 return static_cast<int>(Thread::Current()->SetState(static_cast<Thread::State>(new_state)));
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700259}
260
261void Dbg::UndoDebuggerSuspensions() {
262 UNIMPLEMENTED(FATAL);
263}
264
265void Dbg::Exit(int status) {
266 UNIMPLEMENTED(FATAL);
267}
268
269const char* Dbg::GetClassDescriptor(JDWP::RefTypeId id) {
270 UNIMPLEMENTED(FATAL);
271 return NULL;
272}
273
274JDWP::ObjectId Dbg::GetClassObject(JDWP::RefTypeId id) {
275 UNIMPLEMENTED(FATAL);
276 return 0;
277}
278
279JDWP::RefTypeId Dbg::GetSuperclass(JDWP::RefTypeId id) {
280 UNIMPLEMENTED(FATAL);
281 return 0;
282}
283
284JDWP::ObjectId Dbg::GetClassLoader(JDWP::RefTypeId id) {
285 UNIMPLEMENTED(FATAL);
286 return 0;
287}
288
289uint32_t Dbg::GetAccessFlags(JDWP::RefTypeId id) {
290 UNIMPLEMENTED(FATAL);
291 return 0;
292}
293
294bool Dbg::IsInterface(JDWP::RefTypeId id) {
295 UNIMPLEMENTED(FATAL);
296 return false;
297}
298
299void Dbg::GetClassList(uint32_t* pNumClasses, JDWP::RefTypeId** pClassRefBuf) {
300 UNIMPLEMENTED(FATAL);
301}
302
303void Dbg::GetVisibleClassList(JDWP::ObjectId classLoaderId, uint32_t* pNumClasses, JDWP::RefTypeId** pClassRefBuf) {
304 UNIMPLEMENTED(FATAL);
305}
306
307void Dbg::GetClassInfo(JDWP::RefTypeId classId, uint8_t* pTypeTag, uint32_t* pStatus, const char** pSignature) {
308 UNIMPLEMENTED(FATAL);
309}
310
311bool Dbg::FindLoadedClassBySignature(const char* classDescriptor, JDWP::RefTypeId* pRefTypeId) {
312 UNIMPLEMENTED(FATAL);
313 return false;
314}
315
316void Dbg::GetObjectType(JDWP::ObjectId objectId, uint8_t* pRefTypeTag, JDWP::RefTypeId* pRefTypeId) {
317 UNIMPLEMENTED(FATAL);
318}
319
320uint8_t Dbg::GetClassObjectType(JDWP::RefTypeId refTypeId) {
321 UNIMPLEMENTED(FATAL);
322 return 0;
323}
324
325const char* Dbg::GetSignature(JDWP::RefTypeId refTypeId) {
326 UNIMPLEMENTED(FATAL);
327 return NULL;
328}
329
330const char* Dbg::GetSourceFile(JDWP::RefTypeId refTypeId) {
331 UNIMPLEMENTED(FATAL);
332 return NULL;
333}
334
335const char* Dbg::GetObjectTypeName(JDWP::ObjectId objectId) {
336 UNIMPLEMENTED(FATAL);
337 return NULL;
338}
339
340uint8_t Dbg::GetObjectTag(JDWP::ObjectId objectId) {
341 UNIMPLEMENTED(FATAL);
342 return 0;
343}
344
345int Dbg::GetTagWidth(int tag) {
346 UNIMPLEMENTED(FATAL);
347 return 0;
348}
349
350int Dbg::GetArrayLength(JDWP::ObjectId arrayId) {
351 UNIMPLEMENTED(FATAL);
352 return 0;
353}
354
355uint8_t Dbg::GetArrayElementTag(JDWP::ObjectId arrayId) {
356 UNIMPLEMENTED(FATAL);
357 return 0;
358}
359
360bool Dbg::OutputArray(JDWP::ObjectId arrayId, int firstIndex, int count, JDWP::ExpandBuf* pReply) {
361 UNIMPLEMENTED(FATAL);
362 return false;
363}
364
365bool Dbg::SetArrayElements(JDWP::ObjectId arrayId, int firstIndex, int count, const uint8_t* buf) {
366 UNIMPLEMENTED(FATAL);
367 return false;
368}
369
370JDWP::ObjectId Dbg::CreateString(const char* str) {
371 UNIMPLEMENTED(FATAL);
372 return 0;
373}
374
375JDWP::ObjectId Dbg::CreateObject(JDWP::RefTypeId classId) {
376 UNIMPLEMENTED(FATAL);
377 return 0;
378}
379
380JDWP::ObjectId Dbg::CreateArrayObject(JDWP::RefTypeId arrayTypeId, uint32_t length) {
381 UNIMPLEMENTED(FATAL);
382 return 0;
383}
384
385bool Dbg::MatchType(JDWP::RefTypeId instClassId, JDWP::RefTypeId classId) {
386 UNIMPLEMENTED(FATAL);
387 return false;
388}
389
390const char* Dbg::GetMethodName(JDWP::RefTypeId refTypeId, JDWP::MethodId id) {
391 UNIMPLEMENTED(FATAL);
392 return NULL;
393}
394
395void Dbg::OutputAllFields(JDWP::RefTypeId refTypeId, bool withGeneric, JDWP::ExpandBuf* pReply) {
396 UNIMPLEMENTED(FATAL);
397}
398
399void Dbg::OutputAllMethods(JDWP::RefTypeId refTypeId, bool withGeneric, JDWP::ExpandBuf* pReply) {
400 UNIMPLEMENTED(FATAL);
401}
402
403void Dbg::OutputAllInterfaces(JDWP::RefTypeId refTypeId, JDWP::ExpandBuf* pReply) {
404 UNIMPLEMENTED(FATAL);
405}
406
407void Dbg::OutputLineTable(JDWP::RefTypeId refTypeId, JDWP::MethodId methodId, JDWP::ExpandBuf* pReply) {
408 UNIMPLEMENTED(FATAL);
409}
410
411void Dbg::OutputVariableTable(JDWP::RefTypeId refTypeId, JDWP::MethodId id, bool withGeneric, JDWP::ExpandBuf* pReply) {
412 UNIMPLEMENTED(FATAL);
413}
414
415uint8_t Dbg::GetFieldBasicTag(JDWP::ObjectId objId, JDWP::FieldId fieldId) {
416 UNIMPLEMENTED(FATAL);
417 return 0;
418}
419
420uint8_t Dbg::GetStaticFieldBasicTag(JDWP::RefTypeId refTypeId, JDWP::FieldId fieldId) {
421 UNIMPLEMENTED(FATAL);
422 return 0;
423}
424
425void Dbg::GetFieldValue(JDWP::ObjectId objectId, JDWP::FieldId fieldId, JDWP::ExpandBuf* pReply) {
426 UNIMPLEMENTED(FATAL);
427}
428
429void Dbg::SetFieldValue(JDWP::ObjectId objectId, JDWP::FieldId fieldId, uint64_t value, int width) {
430 UNIMPLEMENTED(FATAL);
431}
432
433void Dbg::GetStaticFieldValue(JDWP::RefTypeId refTypeId, JDWP::FieldId fieldId, JDWP::ExpandBuf* pReply) {
434 UNIMPLEMENTED(FATAL);
435}
436
437void Dbg::SetStaticFieldValue(JDWP::RefTypeId refTypeId, JDWP::FieldId fieldId, uint64_t rawValue, int width) {
438 UNIMPLEMENTED(FATAL);
439}
440
441char* Dbg::StringToUtf8(JDWP::ObjectId strId) {
442 UNIMPLEMENTED(FATAL);
443 return NULL;
444}
445
446char* Dbg::GetThreadName(JDWP::ObjectId threadId) {
447 UNIMPLEMENTED(FATAL);
448 return NULL;
449}
450
451JDWP::ObjectId Dbg::GetThreadGroup(JDWP::ObjectId threadId) {
452 UNIMPLEMENTED(FATAL);
453 return 0;
454}
455
456char* Dbg::GetThreadGroupName(JDWP::ObjectId threadGroupId) {
457 UNIMPLEMENTED(FATAL);
458 return NULL;
459}
460
461JDWP::ObjectId Dbg::GetThreadGroupParent(JDWP::ObjectId threadGroupId) {
462 UNIMPLEMENTED(FATAL);
463 return 0;
464}
465
466JDWP::ObjectId Dbg::GetSystemThreadGroupId() {
467 UNIMPLEMENTED(FATAL);
468 return 0;
469}
470
471JDWP::ObjectId Dbg::GetMainThreadGroupId() {
472 UNIMPLEMENTED(FATAL);
473 return 0;
474}
475
476bool Dbg::GetThreadStatus(JDWP::ObjectId threadId, uint32_t* threadStatus, uint32_t* suspendStatus) {
477 UNIMPLEMENTED(FATAL);
478 return false;
479}
480
481uint32_t Dbg::GetThreadSuspendCount(JDWP::ObjectId threadId) {
482 UNIMPLEMENTED(FATAL);
483 return 0;
484}
485
486bool Dbg::ThreadExists(JDWP::ObjectId threadId) {
487 UNIMPLEMENTED(FATAL);
488 return false;
489}
490
491bool Dbg::IsSuspended(JDWP::ObjectId threadId) {
492 UNIMPLEMENTED(FATAL);
493 return false;
494}
495
496//void Dbg::WaitForSuspend(JDWP::ObjectId threadId);
497
498void Dbg::GetThreadGroupThreads(JDWP::ObjectId threadGroupId, JDWP::ObjectId** ppThreadIds, uint32_t* pThreadCount) {
499 UNIMPLEMENTED(FATAL);
500}
501
502void Dbg::GetAllThreads(JDWP::ObjectId** ppThreadIds, uint32_t* pThreadCount) {
503 UNIMPLEMENTED(FATAL);
504}
505
506int Dbg::GetThreadFrameCount(JDWP::ObjectId threadId) {
507 UNIMPLEMENTED(FATAL);
508 return 0;
509}
510
511bool Dbg::GetThreadFrame(JDWP::ObjectId threadId, int num, JDWP::FrameId* pFrameId, JDWP::JdwpLocation* pLoc) {
512 UNIMPLEMENTED(FATAL);
513 return false;
514}
515
516JDWP::ObjectId Dbg::GetThreadSelfId() {
Elliott Hughes475fc232011-10-25 15:00:35 -0700517 return gRegistry->Add(Thread::Current()->GetPeer());
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700518}
519
Elliott Hughes475fc232011-10-25 15:00:35 -0700520void Dbg::SuspendVM() {
521 Runtime::Current()->GetThreadList()->SuspendAll(true);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700522}
523
524void Dbg::ResumeVM() {
Elliott Hughes475fc232011-10-25 15:00:35 -0700525 Runtime::Current()->GetThreadList()->ResumeAll(true);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700526}
527
528void Dbg::SuspendThread(JDWP::ObjectId threadId) {
529 UNIMPLEMENTED(FATAL);
530}
531
532void Dbg::ResumeThread(JDWP::ObjectId threadId) {
533 UNIMPLEMENTED(FATAL);
534}
535
536void Dbg::SuspendSelf() {
Elliott Hughes475fc232011-10-25 15:00:35 -0700537 Runtime::Current()->GetThreadList()->SuspendSelfForDebugger();
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700538}
539
540bool Dbg::GetThisObject(JDWP::ObjectId threadId, JDWP::FrameId frameId, JDWP::ObjectId* pThisId) {
541 UNIMPLEMENTED(FATAL);
542 return false;
543}
544
545void Dbg::GetLocalValue(JDWP::ObjectId threadId, JDWP::FrameId frameId, int slot, uint8_t tag, uint8_t* buf, int expectedLen) {
546 UNIMPLEMENTED(FATAL);
547}
548
549void Dbg::SetLocalValue(JDWP::ObjectId threadId, JDWP::FrameId frameId, int slot, uint8_t tag, uint64_t value, int width) {
550 UNIMPLEMENTED(FATAL);
551}
552
553void Dbg::PostLocationEvent(const Method* method, int pcOffset, Object* thisPtr, int eventFlags) {
554 UNIMPLEMENTED(FATAL);
555}
556
557void Dbg::PostException(void* throwFp, int throwRelPc, void* catchFp, int catchRelPc, Object* exception) {
558 UNIMPLEMENTED(FATAL);
559}
560
561void Dbg::PostThreadStart(Thread* t) {
Elliott Hughes3bb81562011-10-21 18:52:59 -0700562 if (!gDebuggerConnected) {
563 return;
564 }
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700565 UNIMPLEMENTED(WARNING);
566}
567
568void Dbg::PostThreadDeath(Thread* t) {
Elliott Hughes3bb81562011-10-21 18:52:59 -0700569 if (!gDebuggerConnected) {
570 return;
571 }
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700572 UNIMPLEMENTED(WARNING);
573}
574
575void Dbg::PostClassPrepare(Class* c) {
576 UNIMPLEMENTED(FATAL);
577}
578
579bool Dbg::WatchLocation(const JDWP::JdwpLocation* pLoc) {
580 UNIMPLEMENTED(FATAL);
581 return false;
582}
583
584void Dbg::UnwatchLocation(const JDWP::JdwpLocation* pLoc) {
585 UNIMPLEMENTED(FATAL);
586}
587
588bool Dbg::ConfigureStep(JDWP::ObjectId threadId, JDWP::JdwpStepSize size, JDWP::JdwpStepDepth depth) {
589 UNIMPLEMENTED(FATAL);
590 return false;
591}
592
593void Dbg::UnconfigureStep(JDWP::ObjectId threadId) {
594 UNIMPLEMENTED(FATAL);
595}
596
597JDWP::JdwpError Dbg::InvokeMethod(JDWP::ObjectId threadId, JDWP::ObjectId objectId, JDWP::RefTypeId classId, JDWP::MethodId methodId, uint32_t numArgs, uint64_t* argArray, uint32_t options, uint8_t* pResultTag, uint64_t* pResultValue, JDWP::ObjectId* pExceptObj) {
598 UNIMPLEMENTED(FATAL);
599 return JDWP::ERR_NONE;
600}
601
602void Dbg::ExecuteMethod(DebugInvokeReq* pReq) {
603 UNIMPLEMENTED(FATAL);
604}
605
606void Dbg::RegisterObjectId(JDWP::ObjectId id) {
607 UNIMPLEMENTED(FATAL);
608}
609
610bool Dbg::DdmHandlePacket(const uint8_t* buf, int dataLen, uint8_t** pReplyBuf, int* pReplyLen) {
611 UNIMPLEMENTED(FATAL);
612 return false;
613}
614
615void Dbg::DdmConnected() {
616 UNIMPLEMENTED(FATAL);
617}
618
619void Dbg::DdmDisconnected() {
620 UNIMPLEMENTED(FATAL);
621}
622
Elliott Hughes3bb81562011-10-21 18:52:59 -0700623void Dbg::DdmSendChunk(int type, size_t byte_count, const uint8_t* buf) {
624 CHECK(buf != NULL);
625 iovec vec[1];
626 vec[0].iov_base = reinterpret_cast<void*>(const_cast<uint8_t*>(buf));
627 vec[0].iov_len = byte_count;
628 Dbg::DdmSendChunkV(type, vec, 1);
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700629}
630
631void Dbg::DdmSendChunkV(int type, const struct iovec* iov, int iovcnt) {
Elliott Hughes3bb81562011-10-21 18:52:59 -0700632 if (gJdwpState == NULL) {
633 LOG(VERBOSE) << "Debugger thread not active, ignoring DDM send: " << type;
634 } else {
Elliott Hughes376a7a02011-10-24 18:35:55 -0700635 gJdwpState->DdmSendChunkV(type, iov, iovcnt);
Elliott Hughes3bb81562011-10-21 18:52:59 -0700636 }
Elliott Hughes872d4ec2011-10-21 17:07:15 -0700637}
638
639} // namespace art