1 //===-- ProcessKDP.cpp ------------------------------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // C Includes 11 #include <errno.h> 12 #include <stdlib.h> 13 14 // C++ Includes 15 // Other libraries and framework includes 16 #include "lldb/Core/ConnectionFileDescriptor.h" 17 #include "lldb/Core/Debugger.h" 18 #include "lldb/Core/PluginManager.h" 19 #include "lldb/Core/State.h" 20 #include "lldb/Host/Host.h" 21 #include "lldb/Target/Target.h" 22 #include "lldb/Target/Thread.h" 23 24 // Project includes 25 #include "ProcessKDP.h" 26 #include "ProcessKDPLog.h" 27 #include "ThreadKDP.h" 28 #include "StopInfoMachException.h" 29 30 using namespace lldb; 31 using namespace lldb_private; 32 33 const char * 34 ProcessKDP::GetPluginNameStatic() 35 { 36 return "kdp-remote"; 37 } 38 39 const char * 40 ProcessKDP::GetPluginDescriptionStatic() 41 { 42 return "KDP Remote protocol based debugging plug-in for darwin kernel debugging."; 43 } 44 45 void 46 ProcessKDP::Terminate() 47 { 48 PluginManager::UnregisterPlugin (ProcessKDP::CreateInstance); 49 } 50 51 52 Process* 53 ProcessKDP::CreateInstance (Target &target, Listener &listener) 54 { 55 return new ProcessKDP (target, listener); 56 } 57 58 bool 59 ProcessKDP::CanDebug(Target &target, bool plugin_specified_by_name) 60 { 61 // For now we are just making sure the file exists for a given module 62 ModuleSP exe_module_sp(target.GetExecutableModule()); 63 if (exe_module_sp.get()) 64 { 65 const llvm::Triple &triple_ref = target.GetArchitecture().GetTriple(); 66 if (triple_ref.getOS() == llvm::Triple::Darwin && 67 triple_ref.getVendor() == llvm::Triple::Apple) 68 { 69 ObjectFile *exe_objfile = exe_module_sp->GetObjectFile(); 70 if (exe_objfile->GetType() == ObjectFile::eTypeExecutable && 71 exe_objfile->GetStrata() == ObjectFile::eStrataKernel) 72 return true; 73 } 74 return false; 75 } 76 // No target executable, assume we can debug if our plug-in was specified by name 77 return plugin_specified_by_name; 78 } 79 80 //---------------------------------------------------------------------- 81 // ProcessKDP constructor 82 //---------------------------------------------------------------------- 83 ProcessKDP::ProcessKDP(Target& target, Listener &listener) : 84 Process (target, listener), 85 m_comm("lldb.process.kdp-remote.communication"), 86 m_async_broadcaster ("lldb.process.kdp-remote.async-broadcaster"), 87 m_async_thread (LLDB_INVALID_HOST_THREAD) 88 { 89 // m_async_broadcaster.SetEventName (eBroadcastBitAsyncThreadShouldExit, "async thread should exit"); 90 // m_async_broadcaster.SetEventName (eBroadcastBitAsyncContinue, "async thread continue"); 91 } 92 93 //---------------------------------------------------------------------- 94 // Destructor 95 //---------------------------------------------------------------------- 96 ProcessKDP::~ProcessKDP() 97 { 98 Clear(); 99 } 100 101 //---------------------------------------------------------------------- 102 // PluginInterface 103 //---------------------------------------------------------------------- 104 const char * 105 ProcessKDP::GetPluginName() 106 { 107 return "Process debugging plug-in that uses the Darwin KDP remote protocol"; 108 } 109 110 const char * 111 ProcessKDP::GetShortPluginName() 112 { 113 return GetPluginNameStatic(); 114 } 115 116 uint32_t 117 ProcessKDP::GetPluginVersion() 118 { 119 return 1; 120 } 121 122 Error 123 ProcessKDP::WillLaunch (Module* module) 124 { 125 Error error; 126 error.SetErrorString ("launching not supported in kdp-remote plug-in"); 127 return error; 128 } 129 130 Error 131 ProcessKDP::WillAttachToProcessWithID (lldb::pid_t pid) 132 { 133 Error error; 134 error.SetErrorString ("attaching to a by process ID not supported in kdp-remote plug-in"); 135 return error; 136 } 137 138 Error 139 ProcessKDP::WillAttachToProcessWithName (const char *process_name, bool wait_for_launch) 140 { 141 Error error; 142 error.SetErrorString ("attaching to a by process name not supported in kdp-remote plug-in"); 143 return error; 144 } 145 146 Error 147 ProcessKDP::DoConnectRemote (const char *remote_url) 148 { 149 // TODO: fill in the remote connection to the remote KDP here! 150 Error error; 151 152 if (remote_url == NULL || remote_url[0] == '\0') 153 remote_url = "udp://localhost:41139"; 154 155 std::auto_ptr<ConnectionFileDescriptor> conn_ap(new ConnectionFileDescriptor()); 156 if (conn_ap.get()) 157 { 158 // Only try once for now. 159 // TODO: check if we should be retrying? 160 const uint32_t max_retry_count = 1; 161 for (uint32_t retry_count = 0; retry_count < max_retry_count; ++retry_count) 162 { 163 if (conn_ap->Connect(remote_url, &error) == eConnectionStatusSuccess) 164 break; 165 usleep (100000); 166 } 167 } 168 169 if (conn_ap->IsConnected()) 170 { 171 const uint16_t reply_port = conn_ap->GetReadPort (); 172 173 if (reply_port != 0) 174 { 175 m_comm.SetConnection(conn_ap.release()); 176 177 if (m_comm.SendRequestReattach(reply_port)) 178 { 179 if (m_comm.SendRequestConnect(reply_port, reply_port, "Greetings from LLDB...")) 180 { 181 m_comm.GetVersion(); 182 uint32_t cpu = m_comm.GetCPUType(); 183 uint32_t sub = m_comm.GetCPUSubtype(); 184 ArchSpec kernel_arch; 185 kernel_arch.SetArchitecture(eArchTypeMachO, cpu, sub); 186 m_target.SetArchitecture(kernel_arch); 187 SetID (1); 188 UpdateThreadListIfNeeded (); 189 SetPrivateState (eStateStopped); 190 StreamSP async_strm_sp(m_target.GetDebugger().GetAsyncOutputStream()); 191 if (async_strm_sp) 192 { 193 const char *cstr; 194 if ((cstr = m_comm.GetKernelVersion ()) != NULL) 195 { 196 async_strm_sp->Printf ("Version: %s\n", cstr); 197 async_strm_sp->Flush(); 198 } 199 // if ((cstr = m_comm.GetImagePath ()) != NULL) 200 // { 201 // async_strm_sp->Printf ("Image Path: %s\n", cstr); 202 // async_strm_sp->Flush(); 203 // } 204 } 205 } 206 } 207 else 208 { 209 error.SetErrorString("KDP reattach failed"); 210 } 211 } 212 else 213 { 214 error.SetErrorString("invalid reply port from UDP connection"); 215 } 216 } 217 else 218 { 219 if (error.Success()) 220 error.SetErrorStringWithFormat ("failed to connect to '%s'", remote_url); 221 } 222 if (error.Fail()) 223 m_comm.Disconnect(); 224 225 return error; 226 } 227 228 //---------------------------------------------------------------------- 229 // Process Control 230 //---------------------------------------------------------------------- 231 Error 232 ProcessKDP::DoLaunch (Module* module, 233 char const *argv[], 234 char const *envp[], 235 uint32_t launch_flags, 236 const char *stdin_path, 237 const char *stdout_path, 238 const char *stderr_path, 239 const char *working_dir) 240 { 241 Error error; 242 error.SetErrorString ("launching not supported in kdp-remote plug-in"); 243 return error; 244 } 245 246 247 Error 248 ProcessKDP::DoAttachToProcessWithID (lldb::pid_t attach_pid) 249 { 250 Error error; 251 error.SetErrorString ("attach to process by ID is not suppported in kdp remote debugging"); 252 return error; 253 } 254 255 Error 256 ProcessKDP::DoAttachToProcessWithName (const char *process_name, bool wait_for_launch) 257 { 258 Error error; 259 error.SetErrorString ("attach to process by name is not suppported in kdp remote debugging"); 260 return error; 261 } 262 263 264 void 265 ProcessKDP::DidAttach () 266 { 267 LogSP log (ProcessKDPLog::GetLogIfAllCategoriesSet (KDP_LOG_PROCESS)); 268 if (log) 269 log->Printf ("ProcessKDP::DidLaunch()"); 270 if (GetID() != LLDB_INVALID_PROCESS_ID) 271 { 272 // TODO: figure out the register context that we will use 273 } 274 } 275 276 Error 277 ProcessKDP::WillResume () 278 { 279 return Error(); 280 } 281 282 Error 283 ProcessKDP::DoResume () 284 { 285 Error error; 286 if (!m_comm.SendRequestResume ()) 287 error.SetErrorString ("KDP resume failed"); 288 return error; 289 } 290 291 uint32_t 292 ProcessKDP::UpdateThreadListIfNeeded () 293 { 294 // locker will keep a mutex locked until it goes out of scope 295 LogSP log (ProcessKDPLog::GetLogIfAllCategoriesSet (KDP_LOG_THREAD)); 296 if (log && log->GetMask().Test(KDP_LOG_VERBOSE)) 297 log->Printf ("ProcessKDP::%s (pid = %i)", __FUNCTION__, GetID()); 298 299 Mutex::Locker locker (m_thread_list.GetMutex ()); 300 const uint32_t stop_id = GetStopID(); 301 if (m_thread_list.GetSize(false) == 0) 302 { 303 // We currently are making only one thread per core and we 304 // actually don't know about actual threads. Eventually we 305 // want to get the thread list from memory and note which 306 // threads are on CPU as those are the only ones that we 307 // will be able to resume. 308 ThreadList curr_thread_list (this); 309 curr_thread_list.SetStopID(stop_id); 310 const uint32_t cpu_mask = m_comm.GetCPUMask(); 311 for (uint32_t cpu_mask_bit = 1; cpu_mask_bit & cpu_mask; cpu_mask_bit <<= 1) 312 { 313 // The thread ID is currently the CPU mask bit 314 ThreadSP thread_sp (new ThreadKDP (*this, cpu_mask_bit)); 315 curr_thread_list.AddThread(thread_sp); 316 } 317 m_thread_list = curr_thread_list; 318 } 319 return GetThreadList().GetSize(false); 320 } 321 322 323 StateType 324 ProcessKDP::SetThreadStopInfo (StringExtractor& stop_packet) 325 { 326 // TODO: figure out why we stopped given the packet that tells us we stopped... 327 return eStateStopped; 328 } 329 330 void 331 ProcessKDP::RefreshStateAfterStop () 332 { 333 // Let all threads recover from stopping and do any clean up based 334 // on the previous thread state (if any). 335 m_thread_list.RefreshStateAfterStop(); 336 //SetThreadStopInfo (m_last_stop_packet); 337 } 338 339 Error 340 ProcessKDP::DoHalt (bool &caused_stop) 341 { 342 Error error; 343 344 // bool timed_out = false; 345 Mutex::Locker locker; 346 347 if (m_public_state.GetValue() == eStateAttaching) 348 { 349 // We are being asked to halt during an attach. We need to just close 350 // our file handle and debugserver will go away, and we can be done... 351 m_comm.Disconnect(); 352 } 353 else 354 { 355 if (!m_comm.SendRequestSuspend ()) 356 error.SetErrorString ("KDP halt failed"); 357 } 358 return error; 359 } 360 361 Error 362 ProcessKDP::InterruptIfRunning (bool discard_thread_plans, 363 bool catch_stop_event, 364 EventSP &stop_event_sp) 365 { 366 Error error; 367 368 LogSP log (ProcessKDPLog::GetLogIfAllCategoriesSet(KDP_LOG_PROCESS)); 369 370 bool paused_private_state_thread = false; 371 const bool is_running = m_comm.IsRunning(); 372 if (log) 373 log->Printf ("ProcessKDP::InterruptIfRunning(discard_thread_plans=%i, catch_stop_event=%i) is_running=%i", 374 discard_thread_plans, 375 catch_stop_event, 376 is_running); 377 378 if (discard_thread_plans) 379 { 380 if (log) 381 log->Printf ("ProcessKDP::InterruptIfRunning() discarding all thread plans"); 382 m_thread_list.DiscardThreadPlans(); 383 } 384 if (is_running) 385 { 386 if (catch_stop_event) 387 { 388 if (log) 389 log->Printf ("ProcessKDP::InterruptIfRunning() pausing private state thread"); 390 PausePrivateStateThread(); 391 paused_private_state_thread = true; 392 } 393 394 bool timed_out = false; 395 // bool sent_interrupt = false; 396 Mutex::Locker locker; 397 398 // TODO: implement halt in CommunicationKDP 399 // if (!m_comm.SendInterrupt (locker, 1, sent_interrupt, timed_out)) 400 // { 401 // if (timed_out) 402 // error.SetErrorString("timed out sending interrupt packet"); 403 // else 404 // error.SetErrorString("unknown error sending interrupt packet"); 405 // if (paused_private_state_thread) 406 // ResumePrivateStateThread(); 407 // return error; 408 // } 409 410 if (catch_stop_event) 411 { 412 // LISTEN HERE 413 TimeValue timeout_time; 414 timeout_time = TimeValue::Now(); 415 timeout_time.OffsetWithSeconds(5); 416 StateType state = WaitForStateChangedEventsPrivate (&timeout_time, stop_event_sp); 417 418 timed_out = state == eStateInvalid; 419 if (log) 420 log->Printf ("ProcessKDP::InterruptIfRunning() catch stop event: state = %s, timed-out=%i", StateAsCString(state), timed_out); 421 422 if (timed_out) 423 error.SetErrorString("unable to verify target stopped"); 424 } 425 426 if (paused_private_state_thread) 427 { 428 if (log) 429 log->Printf ("ProcessKDP::InterruptIfRunning() resuming private state thread"); 430 ResumePrivateStateThread(); 431 } 432 } 433 return error; 434 } 435 436 Error 437 ProcessKDP::WillDetach () 438 { 439 LogSP log (ProcessKDPLog::GetLogIfAllCategoriesSet(KDP_LOG_PROCESS)); 440 if (log) 441 log->Printf ("ProcessKDP::WillDetach()"); 442 443 bool discard_thread_plans = true; 444 bool catch_stop_event = true; 445 EventSP event_sp; 446 return InterruptIfRunning (discard_thread_plans, catch_stop_event, event_sp); 447 } 448 449 Error 450 ProcessKDP::DoDetach() 451 { 452 Error error; 453 LogSP log (ProcessKDPLog::GetLogIfAllCategoriesSet(KDP_LOG_PROCESS)); 454 if (log) 455 log->Printf ("ProcessKDP::DoDetach()"); 456 457 DisableAllBreakpointSites (); 458 459 m_thread_list.DiscardThreadPlans(); 460 461 if (m_comm.IsConnected()) 462 { 463 464 m_comm.SendRequestDisconnect(); 465 466 size_t response_size = m_comm.Disconnect (); 467 if (log) 468 { 469 if (response_size) 470 log->PutCString ("ProcessKDP::DoDetach() detach packet sent successfully"); 471 else 472 log->PutCString ("ProcessKDP::DoDetach() detach packet send failed"); 473 } 474 } 475 // Sleep for one second to let the process get all detached... 476 StopAsyncThread (); 477 478 m_comm.StopReadThread(); 479 m_comm.Disconnect(); // Disconnect from the debug server. 480 481 SetPrivateState (eStateDetached); 482 ResumePrivateStateThread(); 483 484 //KillDebugserverProcess (); 485 return error; 486 } 487 488 Error 489 ProcessKDP::DoDestroy () 490 { 491 Error error; 492 LogSP log (ProcessKDPLog::GetLogIfAllCategoriesSet(KDP_LOG_PROCESS)); 493 if (log) 494 log->Printf ("ProcessKDP::DoDestroy()"); 495 496 // Interrupt if our inferior is running... 497 if (m_comm.IsConnected()) 498 { 499 if (m_public_state.GetValue() == eStateAttaching) 500 { 501 // We are being asked to halt during an attach. We need to just close 502 // our file handle and debugserver will go away, and we can be done... 503 m_comm.Disconnect(); 504 } 505 else 506 { 507 DisableAllBreakpointSites (); 508 509 m_comm.SendRequestDisconnect(); 510 511 StringExtractor response; 512 // TODO: Send kill packet? 513 SetExitStatus(SIGABRT, NULL); 514 } 515 } 516 StopAsyncThread (); 517 m_comm.StopReadThread(); 518 m_comm.Disconnect(); // Disconnect from the debug server. 519 return error; 520 } 521 522 //------------------------------------------------------------------ 523 // Process Queries 524 //------------------------------------------------------------------ 525 526 bool 527 ProcessKDP::IsAlive () 528 { 529 return m_comm.IsConnected() && m_private_state.GetValue() != eStateExited; 530 } 531 532 //------------------------------------------------------------------ 533 // Process Memory 534 //------------------------------------------------------------------ 535 size_t 536 ProcessKDP::DoReadMemory (addr_t addr, void *buf, size_t size, Error &error) 537 { 538 if (m_comm.IsConnected()) 539 return m_comm.SendRequestReadMemory (addr, buf, size, error); 540 error.SetErrorString ("not connected"); 541 return 0; 542 } 543 544 size_t 545 ProcessKDP::DoWriteMemory (addr_t addr, const void *buf, size_t size, Error &error) 546 { 547 error.SetErrorString ("ProcessKDP::DoReadMemory not implemented"); 548 return 0; 549 } 550 551 lldb::addr_t 552 ProcessKDP::DoAllocateMemory (size_t size, uint32_t permissions, Error &error) 553 { 554 error.SetErrorString ("memory allocation not suppported in kdp remote debugging"); 555 return LLDB_INVALID_ADDRESS; 556 } 557 558 Error 559 ProcessKDP::DoDeallocateMemory (lldb::addr_t addr) 560 { 561 Error error; 562 error.SetErrorString ("memory deallocation not suppported in kdp remote debugging"); 563 return error; 564 } 565 566 Error 567 ProcessKDP::EnableBreakpoint (BreakpointSite *bp_site) 568 { 569 if (m_comm.LocalBreakpointsAreSupported ()) 570 { 571 Error error; 572 if (!bp_site->IsEnabled()) 573 { 574 if (m_comm.SendRequestBreakpoint(true, bp_site->GetLoadAddress())) 575 { 576 bp_site->SetEnabled(true); 577 bp_site->SetType (BreakpointSite::eExternal); 578 } 579 else 580 { 581 error.SetErrorString ("KDP set breakpoint failed"); 582 } 583 } 584 return error; 585 } 586 return EnableSoftwareBreakpoint (bp_site); 587 } 588 589 Error 590 ProcessKDP::DisableBreakpoint (BreakpointSite *bp_site) 591 { 592 if (m_comm.LocalBreakpointsAreSupported ()) 593 { 594 Error error; 595 if (bp_site->IsEnabled()) 596 { 597 BreakpointSite::Type bp_type = bp_site->GetType(); 598 if (bp_type == BreakpointSite::eExternal) 599 { 600 if (m_comm.SendRequestBreakpoint(false, bp_site->GetLoadAddress())) 601 bp_site->SetEnabled(false); 602 else 603 error.SetErrorString ("KDP remove breakpoint failed"); 604 } 605 else 606 { 607 error = DisableSoftwareBreakpoint (bp_site); 608 } 609 } 610 return error; 611 } 612 return DisableSoftwareBreakpoint (bp_site); 613 } 614 615 Error 616 ProcessKDP::EnableWatchpoint (WatchpointLocation *wp) 617 { 618 Error error; 619 error.SetErrorString ("watchpoints are not suppported in kdp remote debugging"); 620 return error; 621 } 622 623 Error 624 ProcessKDP::DisableWatchpoint (WatchpointLocation *wp) 625 { 626 Error error; 627 error.SetErrorString ("watchpoints are not suppported in kdp remote debugging"); 628 return error; 629 } 630 631 void 632 ProcessKDP::Clear() 633 { 634 Mutex::Locker locker (m_thread_list.GetMutex ()); 635 m_thread_list.Clear(); 636 } 637 638 Error 639 ProcessKDP::DoSignal (int signo) 640 { 641 Error error; 642 error.SetErrorString ("sending signals is not suppported in kdp remote debugging"); 643 return error; 644 } 645 646 void 647 ProcessKDP::Initialize() 648 { 649 static bool g_initialized = false; 650 651 if (g_initialized == false) 652 { 653 g_initialized = true; 654 PluginManager::RegisterPlugin (GetPluginNameStatic(), 655 GetPluginDescriptionStatic(), 656 CreateInstance); 657 658 Log::Callbacks log_callbacks = { 659 ProcessKDPLog::DisableLog, 660 ProcessKDPLog::EnableLog, 661 ProcessKDPLog::ListLogCategories 662 }; 663 664 Log::RegisterLogChannel (ProcessKDP::GetPluginNameStatic(), log_callbacks); 665 } 666 } 667 668 bool 669 ProcessKDP::StartAsyncThread () 670 { 671 LogSP log (ProcessKDPLog::GetLogIfAllCategoriesSet(KDP_LOG_PROCESS)); 672 673 if (log) 674 log->Printf ("ProcessKDP::%s ()", __FUNCTION__); 675 676 // Create a thread that watches our internal state and controls which 677 // events make it to clients (into the DCProcess event queue). 678 m_async_thread = Host::ThreadCreate ("<lldb.process.kdp-remote.async>", ProcessKDP::AsyncThread, this, NULL); 679 return IS_VALID_LLDB_HOST_THREAD(m_async_thread); 680 } 681 682 void 683 ProcessKDP::StopAsyncThread () 684 { 685 LogSP log (ProcessKDPLog::GetLogIfAllCategoriesSet(KDP_LOG_PROCESS)); 686 687 if (log) 688 log->Printf ("ProcessKDP::%s ()", __FUNCTION__); 689 690 m_async_broadcaster.BroadcastEvent (eBroadcastBitAsyncThreadShouldExit); 691 692 // Stop the stdio thread 693 if (IS_VALID_LLDB_HOST_THREAD(m_async_thread)) 694 { 695 Host::ThreadJoin (m_async_thread, NULL, NULL); 696 } 697 } 698 699 700 void * 701 ProcessKDP::AsyncThread (void *arg) 702 { 703 ProcessKDP *process = (ProcessKDP*) arg; 704 705 LogSP log (ProcessKDPLog::GetLogIfAllCategoriesSet (KDP_LOG_PROCESS)); 706 if (log) 707 log->Printf ("ProcessKDP::%s (arg = %p, pid = %i) thread starting...", __FUNCTION__, arg, process->GetID()); 708 709 Listener listener ("ProcessKDP::AsyncThread"); 710 EventSP event_sp; 711 const uint32_t desired_event_mask = eBroadcastBitAsyncContinue | 712 eBroadcastBitAsyncThreadShouldExit; 713 714 if (listener.StartListeningForEvents (&process->m_async_broadcaster, desired_event_mask) == desired_event_mask) 715 { 716 listener.StartListeningForEvents (&process->m_comm, Communication::eBroadcastBitReadThreadDidExit); 717 718 bool done = false; 719 while (!done) 720 { 721 if (log) 722 log->Printf ("ProcessKDP::%s (arg = %p, pid = %i) listener.WaitForEvent (NULL, event_sp)...", __FUNCTION__, arg, process->GetID()); 723 if (listener.WaitForEvent (NULL, event_sp)) 724 { 725 const uint32_t event_type = event_sp->GetType(); 726 if (event_sp->BroadcasterIs (&process->m_async_broadcaster)) 727 { 728 if (log) 729 log->Printf ("ProcessKDP::%s (arg = %p, pid = %i) Got an event of type: %d...", __FUNCTION__, arg, process->GetID(), event_type); 730 731 switch (event_type) 732 { 733 case eBroadcastBitAsyncContinue: 734 { 735 const EventDataBytes *continue_packet = EventDataBytes::GetEventDataFromEvent(event_sp.get()); 736 737 if (continue_packet) 738 { 739 // TODO: do continue support here 740 741 // const char *continue_cstr = (const char *)continue_packet->GetBytes (); 742 // const size_t continue_cstr_len = continue_packet->GetByteSize (); 743 // if (log) 744 // log->Printf ("ProcessKDP::%s (arg = %p, pid = %i) got eBroadcastBitAsyncContinue: %s", __FUNCTION__, arg, process->GetID(), continue_cstr); 745 // 746 // if (::strstr (continue_cstr, "vAttach") == NULL) 747 // process->SetPrivateState(eStateRunning); 748 // StringExtractor response; 749 // StateType stop_state = process->GetCommunication().SendContinuePacketAndWaitForResponse (process, continue_cstr, continue_cstr_len, response); 750 // 751 // switch (stop_state) 752 // { 753 // case eStateStopped: 754 // case eStateCrashed: 755 // case eStateSuspended: 756 // process->m_last_stop_packet = response; 757 // process->SetPrivateState (stop_state); 758 // break; 759 // 760 // case eStateExited: 761 // process->m_last_stop_packet = response; 762 // response.SetFilePos(1); 763 // process->SetExitStatus(response.GetHexU8(), NULL); 764 // done = true; 765 // break; 766 // 767 // case eStateInvalid: 768 // process->SetExitStatus(-1, "lost connection"); 769 // break; 770 // 771 // default: 772 // process->SetPrivateState (stop_state); 773 // break; 774 // } 775 } 776 } 777 break; 778 779 case eBroadcastBitAsyncThreadShouldExit: 780 if (log) 781 log->Printf ("ProcessKDP::%s (arg = %p, pid = %i) got eBroadcastBitAsyncThreadShouldExit...", __FUNCTION__, arg, process->GetID()); 782 done = true; 783 break; 784 785 default: 786 if (log) 787 log->Printf ("ProcessKDP::%s (arg = %p, pid = %i) got unknown event 0x%8.8x", __FUNCTION__, arg, process->GetID(), event_type); 788 done = true; 789 break; 790 } 791 } 792 else if (event_sp->BroadcasterIs (&process->m_comm)) 793 { 794 if (event_type & Communication::eBroadcastBitReadThreadDidExit) 795 { 796 process->SetExitStatus (-1, "lost connection"); 797 done = true; 798 } 799 } 800 } 801 else 802 { 803 if (log) 804 log->Printf ("ProcessKDP::%s (arg = %p, pid = %i) listener.WaitForEvent (NULL, event_sp) => false", __FUNCTION__, arg, process->GetID()); 805 done = true; 806 } 807 } 808 } 809 810 if (log) 811 log->Printf ("ProcessKDP::%s (arg = %p, pid = %i) thread exiting...", __FUNCTION__, arg, process->GetID()); 812 813 process->m_async_thread = LLDB_INVALID_HOST_THREAD; 814 return NULL; 815 } 816 817 818