Process.h revision a2784ee3c8451936d50abf94dcb29527d1a2a85a
1//===-- Process.h -----------------------------------------------*- 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#ifndef liblldb_Process_h_ 11#define liblldb_Process_h_ 12 13// C Includes 14// C++ Includes 15#include <list> 16 17// Other libraries and framework includes 18// Project includes 19#include "lldb/lldb-private.h" 20#include "lldb/Interpreter/Args.h" 21#include "lldb/Interpreter/Options.h" 22#include "lldb/Core/Broadcaster.h" 23#include "lldb/Core/Error.h" 24#include "lldb/Core/Event.h" 25#include "lldb/Core/StringList.h" 26#include "lldb/Core/ThreadSafeValue.h" 27#include "lldb/Core/PluginInterface.h" 28#include "lldb/Core/UserSettingsController.h" 29#include "lldb/Breakpoint/BreakpointSiteList.h" 30#include "lldb/Expression/ClangPersistentVariables.h" 31#include "lldb/Expression/IRDynamicChecks.h" 32#include "lldb/Target/ExecutionContextScope.h" 33#include "lldb/Target/ObjCObjectPrinter.h" 34#include "lldb/Target/ThreadList.h" 35#include "lldb/Target/UnixSignals.h" 36 37namespace lldb_private { 38 39 40typedef enum ProcessPlugins 41{ 42 eMacosx, 43 eRemoteDebugger 44} ProcessPlugins; 45 46 47class ProcessInstanceSettings : public InstanceSettings 48{ 49public: 50 51 ProcessInstanceSettings (UserSettingsController &owner, bool live_instance = true, const char *name = NULL); 52 53 ProcessInstanceSettings (const ProcessInstanceSettings &rhs); 54 55 virtual 56 ~ProcessInstanceSettings (); 57 58 ProcessInstanceSettings& 59 operator= (const ProcessInstanceSettings &rhs); 60 61 62 void 63 UpdateInstanceSettingsVariable (const ConstString &var_name, 64 const char *index_value, 65 const char *value, 66 const ConstString &instance_name, 67 const SettingEntry &entry, 68 lldb::VarSetOperationType op, 69 Error &err, 70 bool pending); 71 72 void 73 GetInstanceSettingsValue (const SettingEntry &entry, 74 const ConstString &var_name, 75 StringList &value); 76 77 78protected: 79 80 void 81 CopyInstanceSettings (const lldb::InstanceSettingsSP &new_settings, 82 bool pending); 83 84 static const ConstString 85 CreateInstanceName (); 86 87 static const ConstString & 88 RunArgsVarName (); 89 90 static const ConstString & 91 EnvVarsVarName (); 92 93 static const ConstString & 94 InputPathVarName (); 95 96 static const ConstString & 97 OutputPathVarName (); 98 99 static const ConstString & 100 ErrorPathVarName (); 101 102 static const ConstString & 103 PluginVarName (); 104 105 static const ConstString & 106 DisableASLRVarName(); 107 108 109private: 110 111 Args m_run_args; 112 std::map<std::string, std::string> m_env_vars; 113 std::string m_input_path; 114 std::string m_output_path; 115 std::string m_error_path; 116 ProcessPlugins m_plugin; 117 bool m_disable_aslr; 118}; 119 120 121//---------------------------------------------------------------------- 122/// @class Process Process.h "lldb/Target/Process.h" 123/// @brief A plug-in interface definition class for debugging a process. 124//---------------------------------------------------------------------- 125class Process : 126 public UserID, 127 public Broadcaster, 128 public ExecutionContextScope, 129 public PluginInterface, 130 public ProcessInstanceSettings 131{ 132friend class ThreadList; 133 134public: 135 136 //------------------------------------------------------------------ 137 /// Broadcaster event bits definitions. 138 //------------------------------------------------------------------ 139 enum 140 { 141 eBroadcastBitStateChanged = (1 << 0), 142 eBroadcastBitInterrupt = (1 << 1), 143 eBroadcastBitSTDOUT = (1 << 2), 144 eBroadcastBitSTDERR = (1 << 3) 145 }; 146 147 enum 148 { 149 eBroadcastInternalStateControlStop = (1<<0), 150 eBroadcastInternalStateControlPause = (1<<1), 151 eBroadcastInternalStateControlResume = (1<<2) 152 }; 153 154 //------------------------------------------------------------------ 155 /// A notification structure that can be used by clients to listen 156 /// for changes in a process's lifetime. 157 /// 158 /// @see RegisterNotificationCallbacks (const Notifications&) 159 /// @see UnregisterNotificationCallbacks (const Notifications&) 160 //------------------------------------------------------------------ 161#ifndef SWIG 162 typedef struct 163 { 164 void *baton; 165 void (*initialize)(void *baton, Process *process); 166 void (*process_state_changed) (void *baton, Process *process, lldb::StateType state); 167 } Notifications; 168 169 class ProcessEventData : 170 public EventData 171 { 172 public: 173 ProcessEventData (); 174 ProcessEventData (const lldb::ProcessSP &process, lldb::StateType state); 175 176 virtual ~ProcessEventData(); 177 178 static const ConstString & 179 GetFlavorString (); 180 181 virtual const ConstString & 182 GetFlavor () const; 183 184 const lldb::ProcessSP & 185 GetProcessSP() const; 186 187 lldb::StateType 188 GetState() const; 189 190 bool 191 GetRestarted () const; 192 193 virtual void 194 Dump (Stream *s) const; 195 196 virtual void 197 DoOnRemoval (Event *event_ptr); 198 199 static const Process::ProcessEventData * 200 GetEventDataFromEvent (const Event *event_ptr); 201 202 static lldb::ProcessSP 203 GetProcessFromEvent (const Event *event_ptr); 204 205 static lldb::StateType 206 GetStateFromEvent (const Event *event_ptr); 207 208 static bool 209 GetRestartedFromEvent (const Event *event_ptr); 210 211 static void 212 SetRestartedInEvent (Event *event_ptr, bool new_value); 213 214 static bool 215 SetUpdateStateOnRemoval (Event *event_ptr); 216 217 218 private: 219 220 void 221 SetUpdateStateOnRemoval(); 222 223 void 224 SetRestarted (bool new_value); 225 226 lldb::ProcessSP m_process_sp; 227 lldb::StateType m_state; 228 bool m_restarted; // For "eStateStopped" events, this is true if the target was automatically restarted. 229 bool m_update_state; 230 DISALLOW_COPY_AND_ASSIGN (ProcessEventData); 231 232 }; 233 234 class ProcessSettingsController : public UserSettingsController 235 { 236 public: 237 238 ProcessSettingsController (); 239 240 virtual 241 ~ProcessSettingsController (); 242 243 void 244 UpdateGlobalVariable (const ConstString &var_name, 245 const char *index_value, 246 const char *value, 247 const SettingEntry &entry, 248 lldb::VarSetOperationType op, 249 Error&err); 250 251 void 252 GetGlobalSettingsValue (const ConstString &var_name, 253 StringList &value); 254 255 static SettingEntry global_settings_table[]; 256 static SettingEntry instance_settings_table[]; 257 258 protected: 259 260 lldb::InstanceSettingsSP 261 CreateNewInstanceSettings (const char *instance_name); 262 263 static lldb::OptionEnumValueElement g_plugins[]; 264 265 private: 266 267 // Class-wide settings. 268 269 DISALLOW_COPY_AND_ASSIGN (ProcessSettingsController); 270 }; 271 272#endif 273 274 static lldb::UserSettingsControllerSP 275 GetSettingsController (bool finish = false); 276 277 //------------------------------------------------------------------ 278 /// Construct with a shared pointer to a target, and the Process listener. 279 //------------------------------------------------------------------ 280 Process(Target &target, Listener &listener); 281 282 //------------------------------------------------------------------ 283 /// Destructor. 284 /// 285 /// The destructor is virtual since this class is designed to be 286 /// inherited from by the plug-in instance. 287 //------------------------------------------------------------------ 288 virtual 289 ~Process(); 290 291 //------------------------------------------------------------------ 292 /// Find a Process plug-in that can debug \a module using the 293 /// currently selected architecture. 294 /// 295 /// Scans all loaded plug-in interfaces that implement versions of 296 /// the Process plug-in interface and returns the first instance 297 /// that can debug the file. 298 /// 299 /// @param[in] module_sp 300 /// The module shared pointer that this process will debug. 301 /// 302 /// @param[in] plugin_name 303 /// If NULL, select the best plug-in for the binary. If non-NULL 304 /// then look for a plugin whose PluginInfo's name matches 305 /// this string. 306 /// 307 /// @see Process::CanDebug () 308 //------------------------------------------------------------------ 309 static Process* 310 FindPlugin (Target &target, const char *plugin_name, Listener &listener); 311 312 313 314 //------------------------------------------------------------------ 315 /// Static function that can be used with the \b host function 316 /// Host::StartMonitoringChildProcess (). 317 /// 318 /// This function can be used by lldb_private::Process subclasses 319 /// when they want to watch for a local process and have its exit 320 /// status automatically set when the host child process exits. 321 /// Subclasses should call Host::StartMonitoringChildProcess () 322 /// with: 323 /// callback = Process::SetHostProcessExitStatus 324 /// callback_baton = NULL 325 /// pid = Process::GetID() 326 /// monitor_signals = false 327 //------------------------------------------------------------------ 328 static bool 329 SetProcessExitStatus (void *callback_baton, // The callback baton which should be set to NULL 330 lldb::pid_t pid, // The process ID we want to monitor 331 int signo, // Zero for no signal 332 int status); // Exit value of process if signal is zero 333 334 //------------------------------------------------------------------ 335 /// Check if a plug-in instance can debug the file in \a module. 336 /// 337 /// Each plug-in is given a chance to say wether it can debug 338 /// the file in \a module. If the Process plug-in instance can 339 /// debug a file on the current system, it should return \b true. 340 /// 341 /// @return 342 /// Returns \b true if this Process plug-in instance can 343 /// debug the executable, \b false otherwise. 344 //------------------------------------------------------------------ 345 virtual bool 346 CanDebug (Target &target) = 0; 347 348 349 //------------------------------------------------------------------ 350 /// This object is about to be destroyed, do any necessary cleanup. 351 /// 352 /// Subclasses that override this method should always call this 353 /// superclass method. 354 //------------------------------------------------------------------ 355 virtual void 356 Finalize(); 357 358 //------------------------------------------------------------------ 359 /// Launch a new process. 360 /// 361 /// Launch a new process by spawning a new process using the 362 /// target object's executable module's file as the file to launch. 363 /// Arguments are given in \a argv, and the environment variables 364 /// are in \a envp. Standard input and output files can be 365 /// optionally re-directed to \a stdin_path, \a stdout_path, and 366 /// \a stderr_path. 367 /// 368 /// This function is not meant to be overridden by Process 369 /// subclasses. It will first call Process::WillLaunch (Module *) 370 /// and if that returns \b true, Process::DoLaunch (Module*, 371 /// char const *[],char const *[],const char *,const char *, 372 /// const char *) will be called to actually do the launching. If 373 /// DoLaunch returns \b true, then Process::DidLaunch() will be 374 /// called. 375 /// 376 /// @param[in] argv 377 /// The argument array. 378 /// 379 /// @param[in] envp 380 /// The environment array. 381 /// 382 /// @param[in] launch_flags 383 /// Flags to modify the launch (@see lldb::LaunchFlags) 384 /// 385 /// @param[in] stdin_path 386 /// The path to use when re-directing the STDIN of the new 387 /// process. If all stdXX_path arguments are NULL, a pseudo 388 /// terminal will be used. 389 /// 390 /// @param[in] stdout_path 391 /// The path to use when re-directing the STDOUT of the new 392 /// process. If all stdXX_path arguments are NULL, a pseudo 393 /// terminal will be used. 394 /// 395 /// @param[in] stderr_path 396 /// The path to use when re-directing the STDERR of the new 397 /// process. If all stdXX_path arguments are NULL, a pseudo 398 /// terminal will be used. 399 /// 400 /// @return 401 /// An error object. Call GetID() to get the process ID if 402 /// the error object is success. 403 //------------------------------------------------------------------ 404 virtual Error 405 Launch (char const *argv[], 406 char const *envp[], 407 uint32_t launch_flags, 408 const char *stdin_path, 409 const char *stdout_path, 410 const char *stderr_path); 411 412 //------------------------------------------------------------------ 413 /// Attach to an existing process using a process ID. 414 /// 415 /// This function is not meant to be overridden by Process 416 /// subclasses. It will first call Process::WillAttach (lldb::pid_t) 417 /// and if that returns \b true, Process::DoAttach (lldb::pid_t) will 418 /// be called to actually do the attach. If DoAttach returns \b 419 /// true, then Process::DidAttach() will be called. 420 /// 421 /// @param[in] pid 422 /// The process ID that we should attempt to attach to. 423 /// 424 /// @return 425 /// Returns \a pid if attaching was successful, or 426 /// LLDB_INVALID_PROCESS_ID if attaching fails. 427 //------------------------------------------------------------------ 428 virtual Error 429 Attach (lldb::pid_t pid); 430 431 //------------------------------------------------------------------ 432 /// Attach to an existing process by process name. 433 /// 434 /// This function is not meant to be overridden by Process 435 /// subclasses. It will first call 436 /// Process::WillAttach (const char *) and if that returns \b 437 /// true, Process::DoAttach (const char *) will be called to 438 /// actually do the attach. If DoAttach returns \b true, then 439 /// Process::DidAttach() will be called. 440 /// 441 /// @param[in] process_name 442 /// A process name to match against the current process list. 443 /// 444 /// @return 445 /// Returns \a pid if attaching was successful, or 446 /// LLDB_INVALID_PROCESS_ID if attaching fails. 447 //------------------------------------------------------------------ 448 virtual Error 449 Attach (const char *process_name, bool wait_for_launch); 450 451 //------------------------------------------------------------------ 452 /// List the processes matching the given partial name. 453 /// 454 /// FIXME: Is it too heavyweight to create an entire process object to do this? 455 /// The problem is for remote processes we're going to have to set up the same transport 456 /// to get this data as to actually attach. So we need to factor out transport 457 /// and process before we can do this separately from the process. 458 /// 459 /// @param[in] name 460 /// A partial name to match against the current process list. 461 /// 462 /// @param[out] matches 463 /// The list of process names matching \a name. 464 /// 465 /// @param[in] pids 466 /// A vector filled with the pids that correspond to the names in \a matches. 467 /// 468 /// @return 469 /// Returns the number of matching processes. 470 //------------------------------------------------------------------ 471 472 virtual uint32_t 473 ListProcessesMatchingName (const char *name, StringList &matches, std::vector<lldb::pid_t> &pids); 474 475 //------------------------------------------------------------------ 476 /// Find the architecture of a process by pid. 477 /// 478 /// FIXME: See comment for ListProcessesMatchingName. 479 /// 480 /// @param[in] pid 481 /// A pid to inspect. 482 /// 483 /// @return 484 /// Returns the architecture of the process or an invalid architecture if the process can't be found. 485 //------------------------------------------------------------------ 486 virtual ArchSpec 487 GetArchSpecForExistingProcess (lldb::pid_t pid); 488 489 //------------------------------------------------------------------ 490 /// Find the architecture of a process by name. 491 /// 492 /// FIXME: See comment for ListProcessesMatchingName. 493 /// 494 /// @param[in] process_name 495 /// The process name to inspect. 496 /// 497 /// @return 498 /// Returns the architecture of the process or an invalid architecture if the process can't be found. 499 //------------------------------------------------------------------ 500 virtual ArchSpec 501 GetArchSpecForExistingProcess (const char *process_name); 502 503 uint32_t 504 GetAddressByteSize(); 505 506 //------------------------------------------------------------------ 507 /// Get the image information address for the current process. 508 /// 509 /// Some runtimes have system functions that can help dynamic 510 /// loaders locate the dynamic loader information needed to observe 511 /// shared libraries being loaded or unloaded. This function is 512 /// in the Process interface (as opposed to the DynamicLoader 513 /// interface) to ensure that remote debugging can take advantage of 514 /// this functionality. 515 /// 516 /// @return 517 /// The address of the dynamic loader information, or 518 /// LLDB_INVALID_ADDRESS if this is not supported by this 519 /// interface. 520 //------------------------------------------------------------------ 521 virtual lldb::addr_t 522 GetImageInfoAddress (); 523 524 //------------------------------------------------------------------ 525 /// Register for process and thread notifications. 526 /// 527 /// Clients can register nofication callbacks by filling out a 528 /// Process::Notifications structure and calling this function. 529 /// 530 /// @param[in] callbacks 531 /// A structure that contains the notification baton and 532 /// callback functions. 533 /// 534 /// @see Process::Notifications 535 //------------------------------------------------------------------ 536#ifndef SWIG 537 void 538 RegisterNotificationCallbacks (const Process::Notifications& callbacks); 539#endif 540 //------------------------------------------------------------------ 541 /// Unregister for process and thread notifications. 542 /// 543 /// Clients can unregister nofication callbacks by passing a copy of 544 /// the original baton and callbacks in \a callbacks. 545 /// 546 /// @param[in] callbacks 547 /// A structure that contains the notification baton and 548 /// callback functions. 549 /// 550 /// @return 551 /// Returns \b true if the notification callbacks were 552 /// successfully removed from the process, \b false otherwise. 553 /// 554 /// @see Process::Notifications 555 //------------------------------------------------------------------ 556#ifndef SWIG 557 bool 558 UnregisterNotificationCallbacks (const Process::Notifications& callbacks); 559#endif 560 //================================================================== 561 // Built in Process Control functions 562 //================================================================== 563 //------------------------------------------------------------------ 564 /// Resumes all of a process's threads as configured using the 565 /// Thread run control functions. 566 /// 567 /// Threads for a process should be updated with one of the run 568 /// control actions (resume, step, or suspend) that they should take 569 /// when the process is resumed. If no run control action is given 570 /// to a thread it will be resumed by default. 571 /// 572 /// This function is not meant to be overridden by Process 573 /// subclasses. This function will take care of disabling any 574 /// breakpoints that threads may be stopped at, single stepping, and 575 /// re-enabling breakpoints, and enabling the basic flow control 576 /// that the plug-in instances need not worry about. 577 /// 578 /// @return 579 /// Returns an error object. 580 /// 581 /// @see Thread:Resume() 582 /// @see Thread:Step() 583 /// @see Thread:Suspend() 584 //------------------------------------------------------------------ 585 virtual Error 586 Resume (); 587 588 //------------------------------------------------------------------ 589 /// Halts a running process. 590 /// 591 /// This function is not meant to be overridden by Process 592 /// subclasses. 593 /// 594 /// @return 595 /// Returns an error object. 596 //------------------------------------------------------------------ 597 virtual Error 598 Halt (); 599 600 //------------------------------------------------------------------ 601 /// Detaches from a running or stopped process. 602 /// 603 /// This function is not meant to be overridden by Process 604 /// subclasses. 605 /// 606 /// @return 607 /// Returns an error object. 608 //------------------------------------------------------------------ 609 virtual Error 610 Detach (); 611 612 //------------------------------------------------------------------ 613 /// Kills the process and shuts down all threads that were spawned 614 /// to track and monitor the process. 615 /// 616 /// This function is not meant to be overridden by Process 617 /// subclasses. 618 /// 619 /// @return 620 /// Returns an error object. 621 //------------------------------------------------------------------ 622 virtual Error 623 Destroy(); 624 625 //------------------------------------------------------------------ 626 /// Sends a process a UNIX signal \a signal. 627 /// 628 /// This function is not meant to be overridden by Process 629 /// subclasses. 630 /// 631 /// @return 632 /// Returns an error object. 633 //------------------------------------------------------------------ 634 virtual Error 635 Signal (int signal); 636 637 virtual UnixSignals & 638 GetUnixSignals (); 639 640 641 //================================================================== 642 // Plug-in Process Control Overrides 643 //================================================================== 644 645 //------------------------------------------------------------------ 646 /// Called before attaching to a process. 647 /// 648 /// Allow Process plug-ins to execute some code before attaching a 649 /// process. 650 /// 651 /// @return 652 /// Returns an error object. 653 //------------------------------------------------------------------ 654 virtual Error 655 WillAttachToProcessWithID (lldb::pid_t pid) 656 { 657 return Error(); 658 } 659 660 //------------------------------------------------------------------ 661 /// Called before attaching to a process. 662 /// 663 /// Allow Process plug-ins to execute some code before attaching a 664 /// process. 665 /// 666 /// @return 667 /// Returns an error object. 668 //------------------------------------------------------------------ 669 virtual Error 670 WillAttachToProcessWithName (const char *process_name, bool wait_for_launch) 671 { 672 return Error(); 673 } 674 675 //------------------------------------------------------------------ 676 /// Attach to an existing process using a process ID. 677 /// 678 /// @param[in] pid 679 /// The process ID that we should attempt to attach to. 680 /// 681 /// @return 682 /// Returns \a pid if attaching was successful, or 683 /// LLDB_INVALID_PROCESS_ID if attaching fails. 684 //------------------------------------------------------------------ 685 virtual Error 686 DoAttachToProcessWithID (lldb::pid_t pid) = 0; 687 688 //------------------------------------------------------------------ 689 /// Attach to an existing process using a partial process name. 690 /// 691 /// @param[in] process_name 692 /// The name of the process to attach to. 693 /// 694 /// @param[in] wait_for_launch 695 /// If \b true, wait for the process to be launched and attach 696 /// as soon as possible after it does launch. If \b false, then 697 /// search for a matching process the currently exists. 698 /// 699 /// @return 700 /// Returns \a pid if attaching was successful, or 701 /// LLDB_INVALID_PROCESS_ID if attaching fails. 702 //------------------------------------------------------------------ 703 virtual Error 704 DoAttachToProcessWithName (const char *process_name, bool wait_for_launch) 705 { 706 Error error; 707 error.SetErrorString("attach by name is not supported"); 708 return error; 709 } 710 711 //------------------------------------------------------------------ 712 /// Called after attaching a process. 713 /// 714 /// Allow Process plug-ins to execute some code after attaching to 715 /// a process. 716 //------------------------------------------------------------------ 717 virtual void 718 DidAttach () {} 719 720 721 //------------------------------------------------------------------ 722 /// Called before launching to a process. 723 /// 724 /// Allow Process plug-ins to execute some code before launching a 725 /// process. 726 /// 727 /// @return 728 /// Returns an error object. 729 //------------------------------------------------------------------ 730 virtual Error 731 WillLaunch (Module* module) 732 { 733 return Error(); 734 } 735 736 //------------------------------------------------------------------ 737 /// Launch a new process. 738 /// 739 /// Launch a new process by spawning a new process using \a module's 740 /// file as the file to launch. Arguments are given in \a argv, 741 /// and the environment variables are in \a envp. Standard input 742 /// and output files can be optionally re-directed to \a stdin_path, 743 /// \a stdout_path, and \a stderr_path. 744 /// 745 /// @param[in] module 746 /// The module from which to extract the file specification and 747 /// launch. 748 /// 749 /// @param[in] argv 750 /// The argument array. 751 /// 752 /// @param[in] envp 753 /// The environment array. 754 /// 755 /// @param[in] launch_flags 756 /// Flags to modify the launch (@see lldb::LaunchFlags) 757 /// 758 /// @param[in] stdin_path 759 /// The path to use when re-directing the STDIN of the new 760 /// process. If all stdXX_path arguments are NULL, a pseudo 761 /// terminal will be used. 762 /// 763 /// @param[in] stdout_path 764 /// The path to use when re-directing the STDOUT of the new 765 /// process. If all stdXX_path arguments are NULL, a pseudo 766 /// terminal will be used. 767 /// 768 /// @param[in] stderr_path 769 /// The path to use when re-directing the STDERR of the new 770 /// process. If all stdXX_path arguments are NULL, a pseudo 771 /// terminal will be used. 772 /// 773 /// @return 774 /// A new valid process ID, or LLDB_INVALID_PROCESS_ID if 775 /// launching fails. 776 //------------------------------------------------------------------ 777 virtual Error 778 DoLaunch (Module* module, 779 char const *argv[], 780 char const *envp[], 781 uint32_t launch_flags, 782 const char *stdin_path, 783 const char *stdout_path, 784 const char *stderr_path) = 0; 785 786 //------------------------------------------------------------------ 787 /// Called after launching a process. 788 /// 789 /// Allow Process plug-ins to execute some code after launching 790 /// a process. 791 //------------------------------------------------------------------ 792 virtual void 793 DidLaunch () {} 794 795 796 797 //------------------------------------------------------------------ 798 /// Called before resuming to a process. 799 /// 800 /// Allow Process plug-ins to execute some code before resuming a 801 /// process. 802 /// 803 /// @return 804 /// Returns an error object. 805 //------------------------------------------------------------------ 806 virtual Error 807 WillResume () { return Error(); } 808 809 //------------------------------------------------------------------ 810 /// Resumes all of a process's threads as configured using the 811 /// Thread run control functions. 812 /// 813 /// Threads for a process should be updated with one of the run 814 /// control actions (resume, step, or suspend) that they should take 815 /// when the process is resumed. If no run control action is given 816 /// to a thread it will be resumed by default. 817 /// 818 /// @return 819 /// Returns \b true if the process successfully resumes using 820 /// the thread run control actions, \b false otherwise. 821 /// 822 /// @see Thread:Resume() 823 /// @see Thread:Step() 824 /// @see Thread:Suspend() 825 //------------------------------------------------------------------ 826 virtual Error 827 DoResume () = 0; 828 829 //------------------------------------------------------------------ 830 /// Called after resuming a process. 831 /// 832 /// Allow Process plug-ins to execute some code after resuming 833 /// a process. 834 //------------------------------------------------------------------ 835 virtual void 836 DidResume () {} 837 838 839 //------------------------------------------------------------------ 840 /// Called before halting to a process. 841 /// 842 /// Allow Process plug-ins to execute some code before halting a 843 /// process. 844 /// 845 /// @return 846 /// Returns an error object. 847 //------------------------------------------------------------------ 848 virtual Error 849 WillHalt () { return Error(); } 850 851 //------------------------------------------------------------------ 852 /// Halts a running process. 853 /// 854 /// @return 855 /// Returns \b true if the process successfully halts, \b false 856 /// otherwise. 857 //------------------------------------------------------------------ 858 virtual Error 859 DoHalt () = 0; 860 861 //------------------------------------------------------------------ 862 /// Called after halting a process. 863 /// 864 /// Allow Process plug-ins to execute some code after halting 865 /// a process. 866 //------------------------------------------------------------------ 867 virtual void 868 DidHalt () {} 869 870 //------------------------------------------------------------------ 871 /// Called before detaching from a process. 872 /// 873 /// Allow Process plug-ins to execute some code before detaching 874 /// from a process. 875 /// 876 /// @return 877 /// Returns an error object. 878 //------------------------------------------------------------------ 879 virtual Error 880 WillDetach () 881 { 882 return Error(); 883 } 884 885 //------------------------------------------------------------------ 886 /// Detaches from a running or stopped process. 887 /// 888 /// @return 889 /// Returns \b true if the process successfully detaches, \b 890 /// false otherwise. 891 //------------------------------------------------------------------ 892 virtual Error 893 DoDetach () = 0; 894 895 //------------------------------------------------------------------ 896 /// Called after detaching from a process. 897 /// 898 /// Allow Process plug-ins to execute some code after detaching 899 /// from a process. 900 //------------------------------------------------------------------ 901 virtual void 902 DidDetach () {} 903 904 //------------------------------------------------------------------ 905 /// Called before sending a signal to a process. 906 /// 907 /// Allow Process plug-ins to execute some code before sending a 908 /// signal to a process. 909 /// 910 /// @return 911 /// Returns no error if it is safe to proceed with a call to 912 /// Process::DoSignal(int), otherwise an error describing what 913 /// prevents the signal from being sent. 914 //------------------------------------------------------------------ 915 virtual Error 916 WillSignal () { return Error(); } 917 918 //------------------------------------------------------------------ 919 /// Sends a process a UNIX signal \a signal. 920 /// 921 /// @return 922 /// Returns an error object. 923 //------------------------------------------------------------------ 924 virtual Error 925 DoSignal (int signal) = 0; 926 927 928 929 virtual Error 930 WillDestroy () { return Error(); } 931 932 virtual Error 933 DoDestroy () = 0; 934 935 virtual void 936 DidDestroy () { } 937 938 939 //------------------------------------------------------------------ 940 /// Called after sending a signal to a process. 941 /// 942 /// Allow Process plug-ins to execute some code after sending a 943 /// signal to a process. 944 //------------------------------------------------------------------ 945 virtual void 946 DidSignal () {} 947 948 949 //------------------------------------------------------------------ 950 /// Currently called as part of ShouldStop. 951 /// FIXME: Should really happen when the target stops before the 952 /// event is taken from the queue... 953 /// 954 /// This callback is called as the event 955 /// is about to be queued up to allow Process plug-ins to execute 956 /// some code prior to clients being notified that a process was 957 /// stopped. Common operations include updating the thread list, 958 /// invalidating any thread state (registers, stack, etc) prior to 959 /// letting the notification go out. 960 /// 961 //------------------------------------------------------------------ 962 virtual void 963 RefreshStateAfterStop () = 0; 964 965 //------------------------------------------------------------------ 966 /// Get the target object pointer for this module. 967 /// 968 /// @return 969 /// A Target object pointer to the target that owns this 970 /// module. 971 //------------------------------------------------------------------ 972 Target & 973 GetTarget (); 974 975 //------------------------------------------------------------------ 976 /// Get the const target object pointer for this module. 977 /// 978 /// @return 979 /// A const Target object pointer to the target that owns this 980 /// module. 981 //------------------------------------------------------------------ 982 const Target & 983 GetTarget () const; 984 985 //------------------------------------------------------------------ 986 /// Get accessor for the current process state. 987 /// 988 /// @return 989 /// The current state of the process. 990 /// 991 /// @see lldb::StateType 992 //------------------------------------------------------------------ 993 lldb::StateType 994 GetState (); 995 996protected: 997 friend class CommandObjectProcessLaunch; 998 friend class ProcessEventData; 999 friend class CommandObjectBreakpointCommand; 1000 1001 void 1002 SetState (lldb::EventSP &event_sp); 1003 1004 lldb::StateType 1005 GetPrivateState (); 1006 1007public: 1008 //------------------------------------------------------------------ 1009 /// Get the exit status for a process. 1010 /// 1011 /// @return 1012 /// The process's return code, or -1 if the current process 1013 /// state is not eStateExited. 1014 //------------------------------------------------------------------ 1015 int 1016 GetExitStatus (); 1017 1018 //------------------------------------------------------------------ 1019 /// Get a textual description of what the process exited. 1020 /// 1021 /// @return 1022 /// The textual description of why the process exited, or NULL 1023 /// if there is no description available. 1024 //------------------------------------------------------------------ 1025 const char * 1026 GetExitDescription (); 1027 1028 1029 virtual void 1030 DidExit () 1031 { 1032 } 1033 1034 //------------------------------------------------------------------ 1035 /// Get the number of times this process has posted a stop event. 1036 /// 1037 /// @return 1038 /// The number of times this process has stopped while being 1039 /// debugged. 1040 //------------------------------------------------------------------ 1041 uint32_t 1042 GetStopID () const; 1043 1044 //------------------------------------------------------------------ 1045 /// Set accessor for the process exit status (return code). 1046 /// 1047 /// Sometimes a child exits and the exit can be detected by global 1048 /// functions (signal handler for SIGCHLD for example). This 1049 /// accessor allows the exit status to be set from an external 1050 /// source. 1051 /// 1052 /// Setting this will cause a eStateExited event to be posted to 1053 /// the process event queue. 1054 /// 1055 /// @param[in] exit_status 1056 /// The value for the process's return code. 1057 /// 1058 /// @see lldb::StateType 1059 //------------------------------------------------------------------ 1060 virtual void 1061 SetExitStatus (int exit_status, const char *cstr); 1062 1063 //------------------------------------------------------------------ 1064 /// Check if a process is still alive. 1065 /// 1066 /// @return 1067 /// Returns \b true if the process is still valid, \b false 1068 /// otherwise. 1069 //------------------------------------------------------------------ 1070 virtual bool 1071 IsAlive () = 0; 1072 1073 //------------------------------------------------------------------ 1074 /// Actually do the reading of memory from a process. 1075 /// 1076 /// Subclasses must override this function and can return fewer 1077 /// bytes than requested when memory requests are too large. This 1078 /// class will break up the memory requests and keep advancing the 1079 /// arguments along as needed. 1080 /// 1081 /// @param[in] vm_addr 1082 /// A virtual load address that indicates where to start reading 1083 /// memory from. 1084 /// 1085 /// @param[in] size 1086 /// The number of bytes to read. 1087 /// 1088 /// @param[out] buf 1089 /// A byte buffer that is at least \a size bytes long that 1090 /// will receive the memory bytes. 1091 /// 1092 /// @return 1093 /// The number of bytes that were actually read into \a buf. 1094 //------------------------------------------------------------------ 1095 virtual size_t 1096 DoReadMemory (lldb::addr_t vm_addr, 1097 void *buf, 1098 size_t size, 1099 Error &error) = 0; 1100 1101 //------------------------------------------------------------------ 1102 /// Read of memory from a process. 1103 /// 1104 /// This function will read memory from the current process's 1105 /// address space and remove any traps that may have been inserted 1106 /// into the memory. 1107 /// 1108 /// This function is not meant to be overridden by Process 1109 /// subclasses, the subclasses should implement 1110 /// Process::DoReadMemory (lldb::addr_t, size_t, void *). 1111 /// 1112 /// @param[in] vm_addr 1113 /// A virtual load address that indicates where to start reading 1114 /// memory from. 1115 /// 1116 /// @param[out] buf 1117 /// A byte buffer that is at least \a size bytes long that 1118 /// will receive the memory bytes. 1119 /// 1120 /// @param[in] size 1121 /// The number of bytes to read. 1122 /// 1123 /// @return 1124 /// The number of bytes that were actually read into \a buf. If 1125 /// the returned number is greater than zero, yet less than \a 1126 /// size, then this function will get called again with \a 1127 /// vm_addr, \a buf, and \a size updated appropriately. Zero is 1128 /// returned to indicate an error. 1129 //------------------------------------------------------------------ 1130 size_t 1131 ReadMemory (lldb::addr_t vm_addr, 1132 void *buf, 1133 size_t size, 1134 Error &error); 1135 1136 //------------------------------------------------------------------ 1137 /// Actually do the writing of memory to a process. 1138 /// 1139 /// @param[in] vm_addr 1140 /// A virtual load address that indicates where to start writing 1141 /// memory to. 1142 /// 1143 /// @param[in] buf 1144 /// A byte buffer that is at least \a size bytes long that 1145 /// contains the data to write. 1146 /// 1147 /// @param[in] size 1148 /// The number of bytes to write. 1149 /// 1150 /// @return 1151 /// The number of bytes that were actually written. 1152 //------------------------------------------------------------------ 1153 virtual size_t 1154 DoWriteMemory (lldb::addr_t vm_addr, const void *buf, size_t size, Error &error) = 0; 1155 1156 //------------------------------------------------------------------ 1157 /// Write memory to a process. 1158 /// 1159 /// This function will write memory to the current process's 1160 /// address space and maintain any traps that might be present due 1161 /// to software breakpoints. 1162 /// 1163 /// This function is not meant to be overridden by Process 1164 /// subclasses, the subclasses should implement 1165 /// Process::DoWriteMemory (lldb::addr_t, size_t, void *). 1166 /// 1167 /// @param[in] vm_addr 1168 /// A virtual load address that indicates where to start writing 1169 /// memory to. 1170 /// 1171 /// @param[in] buf 1172 /// A byte buffer that is at least \a size bytes long that 1173 /// contains the data to write. 1174 /// 1175 /// @param[in] size 1176 /// The number of bytes to write. 1177 /// 1178 /// @return 1179 /// The number of bytes that were actually written. 1180 //------------------------------------------------------------------ 1181 size_t 1182 WriteMemory (lldb::addr_t vm_addr, const void *buf, size_t size, Error &error); 1183 1184 1185 //------------------------------------------------------------------ 1186 /// Actually allocate memory in the process. 1187 /// 1188 /// This function will allocate memory in the process's address 1189 /// space. This can't rely on the generic function calling mechanism, 1190 /// since that requires this function. 1191 /// 1192 /// @param[in] size 1193 /// The size of the allocation requested. 1194 /// 1195 /// @return 1196 /// The address of the allocated buffer in the process, or 1197 /// LLDB_INVALID_ADDRESS if the allocation failed. 1198 //------------------------------------------------------------------ 1199 1200 virtual lldb::addr_t 1201 DoAllocateMemory (size_t size, uint32_t permissions, Error &error) = 0; 1202 1203 //------------------------------------------------------------------ 1204 /// The public interface to allocating memory in the process. 1205 /// 1206 /// This function will allocate memory in the process's address 1207 /// space. This can't rely on the generic function calling mechanism, 1208 /// since that requires this function. 1209 /// 1210 /// @param[in] size 1211 /// The size of the allocation requested. 1212 /// 1213 /// @param[in] permissions 1214 /// Or together any of the lldb::Permissions bits. The permissions on 1215 /// a given memory allocation can't be changed after allocation. Note 1216 /// that a block that isn't set writable can still be written on from lldb, 1217 /// just not by the process itself. 1218 /// 1219 /// @return 1220 /// The address of the allocated buffer in the process, or 1221 /// LLDB_INVALID_ADDRESS if the allocation failed. 1222 //------------------------------------------------------------------ 1223 1224 lldb::addr_t 1225 AllocateMemory (size_t size, uint32_t permissions, Error &error); 1226 1227 //------------------------------------------------------------------ 1228 /// Actually deallocate memory in the process. 1229 /// 1230 /// This function will deallocate memory in the process's address 1231 /// space that was allocated with AllocateMemory. 1232 /// 1233 /// @param[in] ptr 1234 /// A return value from AllocateMemory, pointing to the memory you 1235 /// want to deallocate. 1236 /// 1237 /// @return 1238 /// \btrue if the memory was deallocated, \bfalse otherwise. 1239 //------------------------------------------------------------------ 1240 1241 virtual Error 1242 DoDeallocateMemory (lldb::addr_t ptr) = 0; 1243 1244 //------------------------------------------------------------------ 1245 /// The public interface to deallocating memory in the process. 1246 /// 1247 /// This function will deallocate memory in the process's address 1248 /// space that was allocated with AllocateMemory. 1249 /// 1250 /// @param[in] ptr 1251 /// A return value from AllocateMemory, pointing to the memory you 1252 /// want to deallocate. 1253 /// 1254 /// @return 1255 /// \btrue if the memory was deallocated, \bfalse otherwise. 1256 //------------------------------------------------------------------ 1257 1258 Error 1259 DeallocateMemory (lldb::addr_t ptr); 1260 1261 //------------------------------------------------------------------ 1262 /// Get any available STDOUT. 1263 /// 1264 /// If the process was launched without supplying valid file paths 1265 /// for stdin, stdout, and stderr, then the Process class might 1266 /// try to cache the STDOUT for the process if it is able. Events 1267 /// will be queued indicating that there is STDOUT available that 1268 /// can be retrieved using this function. 1269 /// 1270 /// @param[out] buf 1271 /// A buffer that will receive any STDOUT bytes that are 1272 /// currently available. 1273 /// 1274 /// @param[out] buf_size 1275 /// The size in bytes for the buffer \a buf. 1276 /// 1277 /// @return 1278 /// The number of bytes written into \a buf. If this value is 1279 /// equal to \a buf_size, another call to this function should 1280 /// be made to retrieve more STDOUT data. 1281 //------------------------------------------------------------------ 1282 virtual size_t 1283 GetSTDOUT (char *buf, size_t buf_size, Error &error) 1284 { 1285 error.SetErrorString("stdout unsupported"); 1286 return 0; 1287 } 1288 1289 1290 //------------------------------------------------------------------ 1291 /// Get any available STDERR. 1292 /// 1293 /// If the process was launched without supplying valid file paths 1294 /// for stdin, stdout, and stderr, then the Process class might 1295 /// try to cache the STDERR for the process if it is able. Events 1296 /// will be queued indicating that there is STDERR available that 1297 /// can be retrieved using this function. 1298 /// 1299 /// @param[out] buf 1300 /// A buffer that will receive any STDERR bytes that are 1301 /// currently available. 1302 /// 1303 /// @param[out] buf_size 1304 /// The size in bytes for the buffer \a buf. 1305 /// 1306 /// @return 1307 /// The number of bytes written into \a buf. If this value is 1308 /// equal to \a buf_size, another call to this function should 1309 /// be made to retrieve more STDERR data. 1310 //------------------------------------------------------------------ 1311 virtual size_t 1312 GetSTDERR (char *buf, size_t buf_size, Error &error) 1313 { 1314 error.SetErrorString("stderr unsupported"); 1315 return 0; 1316 } 1317 1318 virtual size_t 1319 PutSTDIN (const char *buf, size_t buf_size, Error &error) 1320 { 1321 error.SetErrorString("stdin unsupported"); 1322 return 0; 1323 } 1324 1325 //---------------------------------------------------------------------- 1326 // Process Breakpoints 1327 //---------------------------------------------------------------------- 1328 virtual size_t 1329 GetSoftwareBreakpointTrapOpcode (BreakpointSite* bp_site) = 0; 1330 1331 virtual Error 1332 EnableBreakpoint (BreakpointSite *bp_site) = 0; 1333 1334 virtual Error 1335 DisableBreakpoint (BreakpointSite *bp_site) = 0; 1336 1337 // This is implemented completely using the lldb::Process API. Subclasses 1338 // don't need to implement this function unless the standard flow of 1339 // read existing opcode, write breakpoint opcode, verify breakpoint opcode 1340 // doesn't work for a specific process plug-in. 1341 virtual Error 1342 EnableSoftwareBreakpoint (BreakpointSite *bp_site); 1343 1344 // This is implemented completely using the lldb::Process API. Subclasses 1345 // don't need to implement this function unless the standard flow of 1346 // restoring original opcode in memory and verifying the restored opcode 1347 // doesn't work for a specific process plug-in. 1348 virtual Error 1349 DisableSoftwareBreakpoint (BreakpointSite *bp_site); 1350 1351 BreakpointSiteList & 1352 GetBreakpointSiteList(); 1353 1354 const BreakpointSiteList & 1355 GetBreakpointSiteList() const; 1356 1357 void 1358 DisableAllBreakpointSites (); 1359 1360 Error 1361 ClearBreakpointSiteByID (lldb::user_id_t break_id); 1362 1363 lldb::break_id_t 1364 CreateBreakpointSite (lldb::BreakpointLocationSP &owner, 1365 bool use_hardware); 1366 1367 Error 1368 DisableBreakpointSiteByID (lldb::user_id_t break_id); 1369 1370 Error 1371 EnableBreakpointSiteByID (lldb::user_id_t break_id); 1372 1373 1374 // BreakpointLocations use RemoveOwnerFromBreakpointSite to remove 1375 // themselves from the owner's list of this breakpoint sites. This has to 1376 // be a static function because you can't be sure that removing the 1377 // breakpoint from it's containing map won't delete the breakpoint site, 1378 // and doing that in an instance method isn't copasetic. 1379 void 1380 RemoveOwnerFromBreakpointSite (lldb::user_id_t owner_id, 1381 lldb::user_id_t owner_loc_id, 1382 lldb::BreakpointSiteSP &bp_site_sp); 1383 1384 //---------------------------------------------------------------------- 1385 // Process Watchpoints (optional) 1386 //---------------------------------------------------------------------- 1387 virtual Error 1388 EnableWatchpoint (WatchpointLocation *bp_loc); 1389 1390 virtual Error 1391 DisableWatchpoint (WatchpointLocation *bp_loc); 1392 1393 //------------------------------------------------------------------ 1394 // Thread Queries 1395 //------------------------------------------------------------------ 1396 virtual uint32_t 1397 UpdateThreadListIfNeeded () = 0; 1398 1399 ThreadList & 1400 GetThreadList (); 1401 1402 const ThreadList & 1403 GetThreadList () const; 1404 1405 uint32_t 1406 GetNextThreadIndexID (); 1407 1408 //------------------------------------------------------------------ 1409 // Event Handling 1410 //------------------------------------------------------------------ 1411 lldb::StateType 1412 GetNextEvent (lldb::EventSP &event_sp); 1413 1414 lldb::StateType 1415 WaitForProcessToStop (const TimeValue *timeout); 1416 1417 lldb::StateType 1418 WaitForStateChangedEvents (const TimeValue *timeout, lldb::EventSP &event_sp); 1419 1420 Event * 1421 PeekAtStateChangedEvents (); 1422 1423 //------------------------------------------------------------------ 1424 /// This is the part of the event handling that for a process event. 1425 /// It decides what to do with the event and returns true if the 1426 /// event needs to be propagated to the user, and false otherwise. 1427 /// If the event is not propagated, this call will most likely set 1428 /// the target to executing again. 1429 /// 1430 /// @param[in] event_ptr 1431 /// This is the event we are handling. 1432 /// 1433 /// @return 1434 /// Returns \b true if the event should be reported to the 1435 /// user, \b false otherwise. 1436 //------------------------------------------------------------------ 1437 bool 1438 ShouldBroadcastEvent (Event *event_ptr); 1439 1440 //------------------------------------------------------------------ 1441 /// Gets the byte order for this process. 1442 /// 1443 /// @return 1444 /// A valid ByteOrder enumeration, or eByteOrderInvalid. 1445 //------------------------------------------------------------------ 1446 virtual lldb::ByteOrder 1447 GetByteOrder () const = 0; 1448 1449 const ConstString & 1450 GetTargetTriple () 1451 { 1452 return m_target_triple; 1453 } 1454 1455 const ABI * 1456 GetABI (); 1457 1458 virtual DynamicLoader * 1459 GetDynamicLoader (); 1460 1461 bool 1462 IsRunning () const; 1463 1464 DynamicCheckerFunctions *GetDynamicCheckers() 1465 { 1466 return m_dynamic_checkers.get(); 1467 } 1468 1469 void SetDynamicCheckers(DynamicCheckerFunctions *dynamic_checkers) 1470 { 1471 m_dynamic_checkers.reset(dynamic_checkers); 1472 } 1473 1474 //------------------------------------------------------------------ 1475 // lldb::ExecutionContextScope pure virtual functions 1476 //------------------------------------------------------------------ 1477 virtual Target * 1478 CalculateTarget (); 1479 1480 virtual Process * 1481 CalculateProcess (); 1482 1483 virtual Thread * 1484 CalculateThread (); 1485 1486 virtual StackFrame * 1487 CalculateStackFrame (); 1488 1489 virtual void 1490 Calculate (ExecutionContext &exe_ctx); 1491 1492 lldb::ProcessSP 1493 GetSP (); 1494 1495 ClangPersistentVariables & 1496 GetPersistentVariables(); 1497 1498 ObjCObjectPrinter & 1499 GetObjCObjectPrinter(); 1500 1501protected: 1502 //------------------------------------------------------------------ 1503 // Member variables 1504 //------------------------------------------------------------------ 1505 Target & m_target; ///< The target that owns this process. 1506 ThreadSafeValue<lldb::StateType> m_public_state; 1507 ThreadSafeValue<lldb::StateType> m_private_state; // The actual state of our process 1508 Broadcaster m_private_state_broadcaster; // This broadcaster feeds state changed events into the private state thread's listener. 1509 Broadcaster m_private_state_control_broadcaster; // This is the control broadcaster, used to pause, resume & stop the private state thread. 1510 Listener m_private_state_listener; // This is the listener for the private state thread. 1511 Predicate<bool> m_private_state_control_wait; /// This Predicate is used to signal that a control operation is complete. 1512 lldb::thread_t m_private_state_thread; // Thread ID for the thread that watches interal state events 1513 uint32_t m_stop_id; ///< A count of many times the process has stopped. 1514 uint32_t m_thread_index_id; ///< Each thread is created with a 1 based index that won't get re-used. 1515 int m_exit_status; ///< The exit status of the process, or -1 if not set. 1516 std::string m_exit_string; ///< A textual description of why a process exited. 1517 ThreadList m_thread_list; ///< The threads for this process. 1518 std::vector<Notifications> m_notifications; ///< The list of notifications that this process can deliver. 1519 Listener &m_listener; 1520 BreakpointSiteList m_breakpoint_site_list; ///< This is the list of breakpoint locations we intend 1521 ///< to insert in the target. 1522 ClangPersistentVariables m_persistent_vars; ///< These are the persistent variables associated with this process for the expression parser. 1523 std::auto_ptr<DynamicCheckerFunctions> m_dynamic_checkers; ///< The functions used by the expression parser to validate data that expressions use. 1524 UnixSignals m_unix_signals; /// This is the current signal set for this process. 1525 ConstString m_target_triple; 1526 lldb::ABISP m_abi_sp; 1527 ObjCObjectPrinter m_objc_object_printer; 1528 1529 size_t 1530 RemoveBreakpointOpcodesFromBuffer (lldb::addr_t addr, size_t size, uint8_t *buf) const; 1531 1532 void 1533 SynchronouslyNotifyStateChanged (lldb::StateType state); 1534 1535 void 1536 SetPublicState (lldb::StateType new_state); 1537 1538 void 1539 SetPrivateState (lldb::StateType state); 1540 1541 bool 1542 StartPrivateStateThread (); 1543 1544 void 1545 StopPrivateStateThread (); 1546 1547 void 1548 PausePrivateStateThread (); 1549 1550 void 1551 ResumePrivateStateThread (); 1552 1553 static void * 1554 PrivateStateThread (void *arg); 1555 1556 void * 1557 RunPrivateStateThread (); 1558 1559 void 1560 HandlePrivateEvent (lldb::EventSP &event_sp); 1561 1562 lldb::StateType 1563 WaitForProcessStopPrivate (const TimeValue *timeout, lldb::EventSP &event_sp); 1564 1565 Error 1566 CompleteAttach (); 1567 1568 1569 // This waits for both the state change broadcaster, and the control broadcaster. 1570 // If control_only, it only waits for the control broadcaster. 1571 1572 bool 1573 WaitForEventsPrivate (const TimeValue *timeout, lldb::EventSP &event_sp, bool control_only); 1574 1575 lldb::StateType 1576 WaitForStateChangedEventsPrivate (const TimeValue *timeout, lldb::EventSP &event_sp); 1577 1578 lldb::StateType 1579 WaitForState (const TimeValue *timeout, 1580 const lldb::StateType *match_states, 1581 const uint32_t num_match_states); 1582 1583 size_t 1584 WriteMemoryPrivate (lldb::addr_t addr, const void *buf, size_t size, Error &error); 1585 1586private: 1587 //------------------------------------------------------------------ 1588 // For Process only 1589 //------------------------------------------------------------------ 1590 void ControlPrivateStateThread (uint32_t signal); 1591 1592 DISALLOW_COPY_AND_ASSIGN (Process); 1593 1594}; 1595 1596} // namespace lldb_private 1597 1598#endif // liblldb_Process_h_ 1599