Process.h revision 090f83176695d86197b0e86b67dee4160ec5003d
1868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)//===-- Process.h -----------------------------------------------*- C++ -*-===// 2868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// 3868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// The LLVM Compiler Infrastructure 4868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// 51e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// This file is distributed under the University of Illinois Open Source 6868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// License. See LICENSE.TXT for details. 7424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)// 8424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)//===----------------------------------------------------------------------===// 95d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#ifndef liblldb_Process_h_ 115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#define liblldb_Process_h_ 121e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 13a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// C Includes 14a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#include <limits.h> 15a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#include <spawn.h> 16868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 174e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)// C++ Includes 184e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)#include <list> 195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include <iosfwd> 204e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)#include <vector> 215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 22a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// Other libraries and framework includes 235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Project includes 248bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "lldb/lldb-private.h" 25868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "lldb/Core/ArchSpec.h" 26868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "lldb/Core/Broadcaster.h" 27868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "lldb/Core/Communication.h" 28424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include "lldb/Core/Error.h" 29424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include "lldb/Core/Event.h" 30424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include "lldb/Core/RangeMap.h" 31424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include "lldb/Core/StringList.h" 32424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include "lldb/Core/ThreadSafeValue.h" 33424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include "lldb/Core/PluginInterface.h" 34424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include "lldb/Core/UserSettingsController.h" 355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "lldb/Breakpoint/BreakpointSiteList.h" 365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "lldb/Expression/ClangPersistentVariables.h" 375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "lldb/Expression/IRDynamicChecks.h" 385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "lldb/Host/FileSpec.h" 395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "lldb/Host/Host.h" 40424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include "lldb/Host/ReadWriteLock.h" 41424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include "lldb/Interpreter/Args.h" 42424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include "lldb/Interpreter/Options.h" 435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "lldb/Target/ExecutionContextScope.h" 44424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include "lldb/Target/Memory.h" 45424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include "lldb/Target/ThreadList.h" 46424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include "lldb/Target/UnixSignals.h" 47424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include "lldb/Utility/PseudoTerminal.h" 48424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) 49424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)namespace lldb_private { 50868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 51868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)//---------------------------------------------------------------------- 52a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// ProcessProperties 534e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)//---------------------------------------------------------------------- 54a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)class ProcessProperties : public Properties 55868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles){ 56424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)public: 57868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) ProcessProperties(bool is_global); 58a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual 604e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) ~ProcessProperties(); 61a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 62424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) bool 63424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) GetDisableMemoryCache() const; 645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 65424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) Args 66424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) GetExtraStartupCommands () const; 67424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) 68424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) void 69868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) SetExtraStartupCommands (const Args &args); 70868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 71868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) FileSpec 72424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) GetPythonOSPluginPath () const; 73424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) 74424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) void 75a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) SetPythonOSPluginPath (const FileSpec &file); 76a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bool 785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) GetIgnoreBreakpointsInExpressions () const; 795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void 815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) SetIgnoreBreakpointsInExpressions (bool ignore); 825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bool 845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) GetUnwindOnErrorInExpressions () const; 855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void 875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) SetUnwindOnErrorInExpressions (bool ignore); 885d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 895d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bool 905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) GetStopOnSharedLibraryEvents () const; 91a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 92424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) void 93a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) SetStopOnSharedLibraryEvents (bool stop); 94a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)}; 95868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 96868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)typedef STD_SHARED_PTR(ProcessProperties) ProcessPropertiesSP; 975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)//---------------------------------------------------------------------- 995d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// ProcessInfo 1005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// 1015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// A base class for information for a process. This can be used to fill 1025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// out information for a process prior to launching it, or it can be 1035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// used for an instance of a process and can be filled in with the 1045d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// existing values for that process. 1055d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)//---------------------------------------------------------------------- 1065d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class ProcessInfo 1075d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles){ 1085d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)public: 1095d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ProcessInfo () : 1105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) m_executable (), 1115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) m_arguments (), 1125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) m_environment (), 1135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) m_uid (UINT32_MAX), 1145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) m_gid (UINT32_MAX), 1155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) m_arch(), 1165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) m_pid (LLDB_INVALID_PROCESS_ID) 1175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) { 118868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) } 119424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) 120868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) ProcessInfo (const char *name, 121868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const ArchSpec &arch, 122868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) lldb::pid_t pid) : 123a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) m_executable (name, false), 124a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) m_arguments (), 125a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) m_environment(), 1265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) m_uid (UINT32_MAX), 1275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) m_gid (UINT32_MAX), 1285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) m_arch (arch), 1295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) m_pid (pid) 1304e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) { 1314e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) } 1324e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 1334e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) void 1348bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) Clear () 1358bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) { 1365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) m_executable.Clear(); 1375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) m_arguments.Clear(); 1385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) m_environment.Clear(); 1395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) m_uid = UINT32_MAX; 1405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) m_gid = UINT32_MAX; 1415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) m_arch.Clear(); 1425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) m_pid = LLDB_INVALID_PROCESS_ID; 1435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 1445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const char * 1465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) GetName() const 1475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) { 1484e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) return m_executable.GetFilename().GetCString(); 1494e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) } 150a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 151a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) size_t 152a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) GetNameLength() const 1535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) { 154a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) return m_executable.GetFilename().GetLength(); 155a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) } 156a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 1574e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) FileSpec & 158424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) GetExecutableFile () 159424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) { 160424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) return m_executable; 1615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 162868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 163868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) void 1644e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) SetExecutableFile (const FileSpec &exe_file, bool add_exe_file_as_first_arg) 1654e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) { 1664e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) if (exe_file) 1674e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) { 168a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) m_executable = exe_file; 169a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) if (add_exe_file_as_first_arg) 170a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) { 171a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) char filename[PATH_MAX]; 1724e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) if (exe_file.GetPath(filename, sizeof(filename))) 1734e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) m_arguments.InsertArgumentAtIndex (0, filename); 1744e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) } 175a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) } 1764e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) else 1774e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) { 1788bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) m_executable.Clear(); 1798bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) } 1808bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) } 1818bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1828bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) const FileSpec & 183a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) GetExecutableFile () const 184a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) { 1858bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) return m_executable; 1868bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) } 1875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1885d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) uint32_t 1895d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) GetUserID() const 1905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) { 1915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return m_uid; 1925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 1935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) uint32_t 1955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) GetGroupID() const 1965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) { 1975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return m_gid; 1985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 1995d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bool 2015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) UserIDIsValid () const 2025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) { 2035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return m_uid != UINT32_MAX; 2045d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 2055d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2065d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bool 2075d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) GroupIDIsValid () const 2085d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) { 2095d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return m_gid != UINT32_MAX; 2105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 2115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void 2135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) SetUserID (uint32_t uid) 2145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) { 2155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) m_uid = uid; 2165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 2175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void 2195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) SetGroupID (uint32_t gid) 2205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) { 2215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) m_gid = gid; 2225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 2235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ArchSpec & 2255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) GetArchitecture () 2265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) { 2275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return m_arch; 2285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 2295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const ArchSpec & 2315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) GetArchitecture () const 2325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) { 2335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return m_arch; 2345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 2355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) lldb::pid_t 2375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) GetProcessID () const 2385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) { 2395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return m_pid; 2405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 2415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void 2435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) SetProcessID (lldb::pid_t pid) 2445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) { 2455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) m_pid = pid; 2465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 2475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bool 2495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ProcessIDIsValid() const 2505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) { 2515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return m_pid != LLDB_INVALID_PROCESS_ID; 2525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 2535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void 2555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) Dump (Stream &s, Platform *platform) const; 2565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) Args & 2585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) GetArguments () 2595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) { 2605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return m_arguments; 2615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 2625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const Args & 2645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) GetArguments () const 2655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) { 2665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return m_arguments; 2675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 2685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const char * 2705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) GetArg0 () const 2715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) { 2725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (m_arg0.empty()) 2735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return NULL; 2745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return m_arg0.c_str(); 2755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 2765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void 2785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) SetArg0 (const char *arg) 2795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) { 2805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (arg && arg[0]) 2815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) m_arg0.clear(); 2825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) else 2835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) m_arg0 = arg; 2845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 2855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void 2875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) SetArguments (const Args& args, bool first_arg_is_executable); 2885d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2895d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void 2905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) SetArguments (char const **argv, bool first_arg_is_executable); 2915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) Args & 2935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) GetEnvironmentEntries () 2945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) { 2955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return m_environment; 2965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 2975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const Args & 2995d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) GetEnvironmentEntries () const 3005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) { 3015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return m_environment; 3025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 3035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 3045d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)protected: 3055d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) FileSpec m_executable; 3065d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) std::string m_arg0; // argv[0] if supported. If empty, then use m_executable. 3075d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Not all process plug-ins support specifying an argv[0] 3085d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // that differs from the resolved platform executable 3095d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // (which is in m_executable) 3105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) Args m_arguments; // All program arguments except argv[0] 3115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) Args m_environment; 3125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) uint32_t m_uid; 3135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) uint32_t m_gid; 3145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ArchSpec m_arch; 3155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) lldb::pid_t m_pid; 3165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}; 3175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 3185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)//---------------------------------------------------------------------- 3195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// ProcessInstanceInfo 3205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// 3215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Describes an existing process and any discoverable information that 3225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// pertains to that process. 3235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)//---------------------------------------------------------------------- 3245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class ProcessInstanceInfo : public ProcessInfo 3255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles){ 3265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)public: 3275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ProcessInstanceInfo () : 3285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ProcessInfo (), 3295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) m_euid (UINT32_MAX), 3305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) m_egid (UINT32_MAX), 3315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) m_parent_pid (LLDB_INVALID_PROCESS_ID) 3325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) { 3335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 3345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 3355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ProcessInstanceInfo (const char *name, 3365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const ArchSpec &arch, 3375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) lldb::pid_t pid) : 3385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ProcessInfo (name, arch, pid), 3395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) m_euid (UINT32_MAX), 3405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) m_egid (UINT32_MAX), 3415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) m_parent_pid (LLDB_INVALID_PROCESS_ID) 3425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) { 3435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 3445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 3455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void 3465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) Clear () 3475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) { 3485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ProcessInfo::Clear(); 3495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) m_euid = UINT32_MAX; 3505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) m_egid = UINT32_MAX; 3515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) m_parent_pid = LLDB_INVALID_PROCESS_ID; 3525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 3535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 3545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) uint32_t 3555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) GetEffectiveUserID() const 3565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) { 3575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return m_euid; 3585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 3595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 3605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) uint32_t 3615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) GetEffectiveGroupID() const 3625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) { 3635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return m_egid; 3645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 3655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 3665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bool 3675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EffectiveUserIDIsValid () const 3685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) { 3695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return m_euid != UINT32_MAX; 3705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 3715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 3725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bool 3735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EffectiveGroupIDIsValid () const 3745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) { 3755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return m_egid != UINT32_MAX; 3765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 3775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 3785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void 3795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) SetEffectiveUserID (uint32_t uid) 3805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) { 3815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) m_euid = uid; 3825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 3835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 3845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void 3855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) SetEffectiveGroupID (uint32_t gid) 3865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) { 3875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) m_egid = gid; 3885d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 3895d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 3905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) lldb::pid_t 3915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) GetParentProcessID () const 3925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) { 3935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return m_parent_pid; 3945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 3955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 3965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void 3975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) SetParentProcessID (lldb::pid_t pid) 3985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) { 3995d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) m_parent_pid = pid; 4005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 4015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 4025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bool 4035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ParentProcessIDIsValid() const 4045d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) { 4055d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return m_parent_pid != LLDB_INVALID_PROCESS_ID; 4065d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 4075d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 4085d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void 4095d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) Dump (Stream &s, Platform *platform) const; 4105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 4115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) static void 4125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) DumpTableHeader (Stream &s, Platform *platform, bool show_args, bool verbose); 4135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 4145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void 4155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) DumpAsTableRow (Stream &s, Platform *platform, bool show_args, bool verbose) const; 4165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 4175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)protected: 4185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) uint32_t m_euid; 4195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) uint32_t m_egid; 4205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) lldb::pid_t m_parent_pid; 4215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}; 4225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 4235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 4245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)//---------------------------------------------------------------------- 425868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// ProcessLaunchInfo 426// 427// Describes any information that is required to launch a process. 428//---------------------------------------------------------------------- 429 430class ProcessLaunchInfo : public ProcessInfo 431{ 432public: 433 434 class FileAction 435 { 436 public: 437 enum Action 438 { 439 eFileActionNone, 440 eFileActionClose, 441 eFileActionDuplicate, 442 eFileActionOpen 443 }; 444 445 446 FileAction () : 447 m_action (eFileActionNone), 448 m_fd (-1), 449 m_arg (-1), 450 m_path () 451 { 452 } 453 454 void 455 Clear() 456 { 457 m_action = eFileActionNone; 458 m_fd = -1; 459 m_arg = -1; 460 m_path.clear(); 461 } 462 463 bool 464 Close (int fd); 465 466 bool 467 Duplicate (int fd, int dup_fd); 468 469 bool 470 Open (int fd, const char *path, bool read, bool write); 471 472 static bool 473 AddPosixSpawnFileAction (posix_spawn_file_actions_t *file_actions, 474 const FileAction *info, 475 Log *log, 476 Error& error); 477 478 int 479 GetFD () const 480 { 481 return m_fd; 482 } 483 484 Action 485 GetAction () const 486 { 487 return m_action; 488 } 489 490 int 491 GetActionArgument () const 492 { 493 return m_arg; 494 } 495 496 const char * 497 GetPath () const 498 { 499 if (m_path.empty()) 500 return NULL; 501 return m_path.c_str(); 502 } 503 504 protected: 505 Action m_action; // The action for this file 506 int m_fd; // An existing file descriptor 507 int m_arg; // oflag for eFileActionOpen*, dup_fd for eFileActionDuplicate 508 std::string m_path; // A file path to use for opening after fork or posix_spawn 509 }; 510 511 ProcessLaunchInfo () : 512 ProcessInfo(), 513 m_working_dir (), 514 m_plugin_name (), 515 m_shell (), 516 m_flags (0), 517 m_file_actions (), 518 m_pty (), 519 m_resume_count (0), 520 m_monitor_callback (NULL), 521 m_monitor_callback_baton (NULL), 522 m_monitor_signals (false) 523 { 524 } 525 526 ProcessLaunchInfo (const char *stdin_path, 527 const char *stdout_path, 528 const char *stderr_path, 529 const char *working_directory, 530 uint32_t launch_flags) : 531 ProcessInfo(), 532 m_working_dir (), 533 m_plugin_name (), 534 m_shell (), 535 m_flags (launch_flags), 536 m_file_actions (), 537 m_pty (), 538 m_resume_count (0), 539 m_monitor_callback (NULL), 540 m_monitor_callback_baton (NULL), 541 m_monitor_signals (false) 542 { 543 if (stdin_path) 544 { 545 ProcessLaunchInfo::FileAction file_action; 546 const bool read = true; 547 const bool write = false; 548 if (file_action.Open(STDIN_FILENO, stdin_path, read, write)) 549 AppendFileAction (file_action); 550 } 551 if (stdout_path) 552 { 553 ProcessLaunchInfo::FileAction file_action; 554 const bool read = false; 555 const bool write = true; 556 if (file_action.Open(STDOUT_FILENO, stdout_path, read, write)) 557 AppendFileAction (file_action); 558 } 559 if (stderr_path) 560 { 561 ProcessLaunchInfo::FileAction file_action; 562 const bool read = false; 563 const bool write = true; 564 if (file_action.Open(STDERR_FILENO, stderr_path, read, write)) 565 AppendFileAction (file_action); 566 } 567 if (working_directory) 568 SetWorkingDirectory(working_directory); 569 } 570 571 void 572 AppendFileAction (const FileAction &info) 573 { 574 m_file_actions.push_back(info); 575 } 576 577 bool 578 AppendCloseFileAction (int fd) 579 { 580 FileAction file_action; 581 if (file_action.Close (fd)) 582 { 583 AppendFileAction (file_action); 584 return true; 585 } 586 return false; 587 } 588 589 bool 590 AppendDuplicateFileAction (int fd, int dup_fd) 591 { 592 FileAction file_action; 593 if (file_action.Duplicate (fd, dup_fd)) 594 { 595 AppendFileAction (file_action); 596 return true; 597 } 598 return false; 599 } 600 601 bool 602 AppendOpenFileAction (int fd, const char *path, bool read, bool write) 603 { 604 FileAction file_action; 605 if (file_action.Open (fd, path, read, write)) 606 { 607 AppendFileAction (file_action); 608 return true; 609 } 610 return false; 611 } 612 613 bool 614 AppendSuppressFileAction (int fd, bool read, bool write) 615 { 616 FileAction file_action; 617 if (file_action.Open (fd, "/dev/null", read, write)) 618 { 619 AppendFileAction (file_action); 620 return true; 621 } 622 return false; 623 } 624 625 void 626 FinalizeFileActions (Target *target, 627 bool default_to_use_pty); 628 629 size_t 630 GetNumFileActions () const 631 { 632 return m_file_actions.size(); 633 } 634 635 const FileAction * 636 GetFileActionAtIndex (size_t idx) const 637 { 638 if (idx < m_file_actions.size()) 639 return &m_file_actions[idx]; 640 return NULL; 641 } 642 643 const FileAction * 644 GetFileActionForFD (int fd) const 645 { 646 for (size_t idx=0, count=m_file_actions.size(); idx < count; ++idx) 647 { 648 if (m_file_actions[idx].GetFD () == fd) 649 return &m_file_actions[idx]; 650 } 651 return NULL; 652 } 653 654 Flags & 655 GetFlags () 656 { 657 return m_flags; 658 } 659 660 const Flags & 661 GetFlags () const 662 { 663 return m_flags; 664 } 665 666 const char * 667 GetWorkingDirectory () const 668 { 669 if (m_working_dir.empty()) 670 return NULL; 671 return m_working_dir.c_str(); 672 } 673 674 void 675 SetWorkingDirectory (const char *working_dir) 676 { 677 if (working_dir && working_dir[0]) 678 m_working_dir.assign (working_dir); 679 else 680 m_working_dir.clear(); 681 } 682 683 void 684 SwapWorkingDirectory (std::string &working_dir) 685 { 686 m_working_dir.swap (working_dir); 687 } 688 689 690 const char * 691 GetProcessPluginName () const 692 { 693 if (m_plugin_name.empty()) 694 return NULL; 695 return m_plugin_name.c_str(); 696 } 697 698 void 699 SetProcessPluginName (const char *plugin) 700 { 701 if (plugin && plugin[0]) 702 m_plugin_name.assign (plugin); 703 else 704 m_plugin_name.clear(); 705 } 706 707 const char * 708 GetShell () const 709 { 710 if (m_shell.empty()) 711 return NULL; 712 return m_shell.c_str(); 713 } 714 715 void 716 SetShell (const char * path) 717 { 718 if (path && path[0]) 719 { 720 m_shell.assign (path); 721 m_flags.Set (lldb::eLaunchFlagLaunchInShell); 722 } 723 else 724 { 725 m_shell.clear(); 726 m_flags.Clear (lldb::eLaunchFlagLaunchInShell); 727 } 728 } 729 730 uint32_t 731 GetResumeCount () const 732 { 733 return m_resume_count; 734 } 735 736 void 737 SetResumeCount (uint32_t c) 738 { 739 m_resume_count = c; 740 } 741 742 bool 743 GetLaunchInSeparateProcessGroup () 744 { 745 return m_flags.Test(lldb::eLaunchFlagLaunchInSeparateProcessGroup); 746 } 747 748 void 749 SetLaunchInSeparateProcessGroup (bool separate) 750 { 751 if (separate) 752 m_flags.Set(lldb::eLaunchFlagLaunchInSeparateProcessGroup); 753 else 754 m_flags.Clear (lldb::eLaunchFlagLaunchInSeparateProcessGroup); 755 756 } 757 758 void 759 Clear () 760 { 761 ProcessInfo::Clear(); 762 m_working_dir.clear(); 763 m_plugin_name.clear(); 764 m_shell.clear(); 765 m_flags.Clear(); 766 m_file_actions.clear(); 767 m_resume_count = 0; 768 } 769 770 bool 771 ConvertArgumentsForLaunchingInShell (Error &error, 772 bool localhost, 773 bool will_debug, 774 bool first_arg_is_full_shell_command); 775 776 void 777 SetMonitorProcessCallback (Host::MonitorChildProcessCallback callback, 778 void *baton, 779 bool monitor_signals) 780 { 781 m_monitor_callback = callback; 782 m_monitor_callback_baton = baton; 783 m_monitor_signals = monitor_signals; 784 } 785 786 bool 787 MonitorProcess () const 788 { 789 if (m_monitor_callback && ProcessIDIsValid()) 790 { 791 Host::StartMonitoringChildProcess (m_monitor_callback, 792 m_monitor_callback_baton, 793 GetProcessID(), 794 m_monitor_signals); 795 return true; 796 } 797 return false; 798 } 799 800 lldb_utility::PseudoTerminal & 801 GetPTY () 802 { 803 return m_pty; 804 } 805 806protected: 807 std::string m_working_dir; 808 std::string m_plugin_name; 809 std::string m_shell; 810 Flags m_flags; // Bitwise OR of bits from lldb::LaunchFlags 811 std::vector<FileAction> m_file_actions; // File actions for any other files 812 lldb_utility::PseudoTerminal m_pty; 813 uint32_t m_resume_count; // How many times do we resume after launching 814 Host::MonitorChildProcessCallback m_monitor_callback; 815 void *m_monitor_callback_baton; 816 bool m_monitor_signals; 817 818}; 819 820//---------------------------------------------------------------------- 821// ProcessLaunchInfo 822// 823// Describes any information that is required to launch a process. 824//---------------------------------------------------------------------- 825 826class ProcessAttachInfo : public ProcessInstanceInfo 827{ 828public: 829 ProcessAttachInfo() : 830 ProcessInstanceInfo(), 831 m_plugin_name (), 832 m_resume_count (0), 833 m_wait_for_launch (false), 834 m_ignore_existing (true), 835 m_continue_once_attached (false) 836 { 837 } 838 839 ProcessAttachInfo (const ProcessLaunchInfo &launch_info) : 840 ProcessInstanceInfo(), 841 m_plugin_name (), 842 m_resume_count (0), 843 m_wait_for_launch (false), 844 m_ignore_existing (true), 845 m_continue_once_attached (false) 846 { 847 ProcessInfo::operator= (launch_info); 848 SetProcessPluginName (launch_info.GetProcessPluginName()); 849 SetResumeCount (launch_info.GetResumeCount()); 850 } 851 852 bool 853 GetWaitForLaunch () const 854 { 855 return m_wait_for_launch; 856 } 857 858 void 859 SetWaitForLaunch (bool b) 860 { 861 m_wait_for_launch = b; 862 } 863 864 bool 865 GetIgnoreExisting () const 866 { 867 return m_ignore_existing; 868 } 869 870 void 871 SetIgnoreExisting (bool b) 872 { 873 m_ignore_existing = b; 874 } 875 876 bool 877 GetContinueOnceAttached () const 878 { 879 return m_continue_once_attached; 880 } 881 882 void 883 SetContinueOnceAttached (bool b) 884 { 885 m_continue_once_attached = b; 886 } 887 888 uint32_t 889 GetResumeCount () const 890 { 891 return m_resume_count; 892 } 893 894 void 895 SetResumeCount (uint32_t c) 896 { 897 m_resume_count = c; 898 } 899 900 const char * 901 GetProcessPluginName () const 902 { 903 if (m_plugin_name.empty()) 904 return NULL; 905 return m_plugin_name.c_str(); 906 } 907 908 void 909 SetProcessPluginName (const char *plugin) 910 { 911 if (plugin && plugin[0]) 912 m_plugin_name.assign (plugin); 913 else 914 m_plugin_name.clear(); 915 } 916 917 void 918 Clear () 919 { 920 ProcessInstanceInfo::Clear(); 921 m_plugin_name.clear(); 922 m_resume_count = 0; 923 m_wait_for_launch = false; 924 m_ignore_existing = true; 925 m_continue_once_attached = false; 926 } 927 928 bool 929 ProcessInfoSpecified () const 930 { 931 if (GetExecutableFile()) 932 return true; 933 if (GetProcessID() != LLDB_INVALID_PROCESS_ID) 934 return true; 935 if (GetParentProcessID() != LLDB_INVALID_PROCESS_ID) 936 return true; 937 return false; 938 } 939protected: 940 std::string m_plugin_name; 941 uint32_t m_resume_count; // How many times do we resume after launching 942 bool m_wait_for_launch; 943 bool m_ignore_existing; 944 bool m_continue_once_attached; // Supports the use-case scenario of immediately continuing the process once attached. 945}; 946 947class ProcessLaunchCommandOptions : public Options 948{ 949public: 950 951 ProcessLaunchCommandOptions (CommandInterpreter &interpreter) : 952 Options(interpreter) 953 { 954 // Keep default values of all options in one place: OptionParsingStarting () 955 OptionParsingStarting (); 956 } 957 958 ~ProcessLaunchCommandOptions () 959 { 960 } 961 962 Error 963 SetOptionValue (uint32_t option_idx, const char *option_arg); 964 965 void 966 OptionParsingStarting () 967 { 968 launch_info.Clear(); 969 } 970 971 const OptionDefinition* 972 GetDefinitions () 973 { 974 return g_option_table; 975 } 976 977 // Options table: Required for subclasses of Options. 978 979 static OptionDefinition g_option_table[]; 980 981 // Instance variables to hold the values for command options. 982 983 ProcessLaunchInfo launch_info; 984}; 985 986//---------------------------------------------------------------------- 987// ProcessInstanceInfoMatch 988// 989// A class to help matching one ProcessInstanceInfo to another. 990//---------------------------------------------------------------------- 991 992class ProcessInstanceInfoMatch 993{ 994public: 995 ProcessInstanceInfoMatch () : 996 m_match_info (), 997 m_name_match_type (eNameMatchIgnore), 998 m_match_all_users (false) 999 { 1000 } 1001 1002 ProcessInstanceInfoMatch (const char *process_name, 1003 NameMatchType process_name_match_type) : 1004 m_match_info (), 1005 m_name_match_type (process_name_match_type), 1006 m_match_all_users (false) 1007 { 1008 m_match_info.GetExecutableFile().SetFile(process_name, false); 1009 } 1010 1011 ProcessInstanceInfo & 1012 GetProcessInfo () 1013 { 1014 return m_match_info; 1015 } 1016 1017 const ProcessInstanceInfo & 1018 GetProcessInfo () const 1019 { 1020 return m_match_info; 1021 } 1022 1023 bool 1024 GetMatchAllUsers () const 1025 { 1026 return m_match_all_users; 1027 } 1028 1029 void 1030 SetMatchAllUsers (bool b) 1031 { 1032 m_match_all_users = b; 1033 } 1034 1035 NameMatchType 1036 GetNameMatchType () const 1037 { 1038 return m_name_match_type; 1039 } 1040 1041 void 1042 SetNameMatchType (NameMatchType name_match_type) 1043 { 1044 m_name_match_type = name_match_type; 1045 } 1046 1047 bool 1048 NameMatches (const char *process_name) const; 1049 1050 bool 1051 Matches (const ProcessInstanceInfo &proc_info) const; 1052 1053 bool 1054 MatchAllProcesses () const; 1055 void 1056 Clear (); 1057 1058protected: 1059 ProcessInstanceInfo m_match_info; 1060 NameMatchType m_name_match_type; 1061 bool m_match_all_users; 1062}; 1063 1064class ProcessInstanceInfoList 1065{ 1066public: 1067 ProcessInstanceInfoList () : 1068 m_infos() 1069 { 1070 } 1071 1072 void 1073 Clear() 1074 { 1075 m_infos.clear(); 1076 } 1077 1078 size_t 1079 GetSize() 1080 { 1081 return m_infos.size(); 1082 } 1083 1084 void 1085 Append (const ProcessInstanceInfo &info) 1086 { 1087 m_infos.push_back (info); 1088 } 1089 1090 const char * 1091 GetProcessNameAtIndex (size_t idx) 1092 { 1093 if (idx < m_infos.size()) 1094 return m_infos[idx].GetName(); 1095 return NULL; 1096 } 1097 1098 size_t 1099 GetProcessNameLengthAtIndex (size_t idx) 1100 { 1101 if (idx < m_infos.size()) 1102 return m_infos[idx].GetNameLength(); 1103 return 0; 1104 } 1105 1106 lldb::pid_t 1107 GetProcessIDAtIndex (size_t idx) 1108 { 1109 if (idx < m_infos.size()) 1110 return m_infos[idx].GetProcessID(); 1111 return 0; 1112 } 1113 1114 bool 1115 GetInfoAtIndex (size_t idx, ProcessInstanceInfo &info) 1116 { 1117 if (idx < m_infos.size()) 1118 { 1119 info = m_infos[idx]; 1120 return true; 1121 } 1122 return false; 1123 } 1124 1125 // You must ensure "idx" is valid before calling this function 1126 const ProcessInstanceInfo & 1127 GetProcessInfoAtIndex (size_t idx) const 1128 { 1129 assert (idx < m_infos.size()); 1130 return m_infos[idx]; 1131 } 1132 1133protected: 1134 typedef std::vector<ProcessInstanceInfo> collection; 1135 collection m_infos; 1136}; 1137 1138 1139// This class tracks the Modification state of the process. Things that can currently modify 1140// the program are running the program (which will up the StopID) and writing memory (which 1141// will up the MemoryID.) 1142// FIXME: Should we also include modification of register states? 1143 1144class ProcessModID 1145{ 1146friend bool operator== (const ProcessModID &lhs, const ProcessModID &rhs); 1147public: 1148 ProcessModID () : 1149 m_stop_id (0), 1150 m_last_natural_stop_id(0), 1151 m_resume_id (0), 1152 m_memory_id (0), 1153 m_last_user_expression_resume (0), 1154 m_running_user_expression (false) 1155 {} 1156 1157 ProcessModID (const ProcessModID &rhs) : 1158 m_stop_id (rhs.m_stop_id), 1159 m_memory_id (rhs.m_memory_id) 1160 {} 1161 1162 const ProcessModID & operator= (const ProcessModID &rhs) 1163 { 1164 if (this != &rhs) 1165 { 1166 m_stop_id = rhs.m_stop_id; 1167 m_memory_id = rhs.m_memory_id; 1168 } 1169 return *this; 1170 } 1171 1172 ~ProcessModID () {} 1173 1174 void BumpStopID () { 1175 m_stop_id++; 1176 if (!IsLastResumeForUserExpression()) 1177 m_last_natural_stop_id++; 1178 } 1179 1180 void BumpMemoryID () { m_memory_id++; } 1181 1182 void BumpResumeID () { 1183 m_resume_id++; 1184 if (m_running_user_expression > 0) 1185 m_last_user_expression_resume = m_resume_id; 1186 } 1187 1188 uint32_t GetStopID() const { return m_stop_id; } 1189 uint32_t GetLastNaturalStopID() const { return m_last_natural_stop_id; } 1190 uint32_t GetMemoryID () const { return m_memory_id; } 1191 uint32_t GetResumeID () const { return m_resume_id; } 1192 uint32_t GetLastUserExpressionResumeID () const { return m_last_user_expression_resume; } 1193 1194 bool MemoryIDEqual (const ProcessModID &compare) const 1195 { 1196 return m_memory_id == compare.m_memory_id; 1197 } 1198 1199 bool StopIDEqual (const ProcessModID &compare) const 1200 { 1201 return m_stop_id == compare.m_stop_id; 1202 } 1203 1204 void SetInvalid () 1205 { 1206 m_stop_id = UINT32_MAX; 1207 } 1208 1209 bool IsValid () const 1210 { 1211 return m_stop_id != UINT32_MAX; 1212 } 1213 1214 bool 1215 IsLastResumeForUserExpression () const 1216 { 1217 return m_resume_id == m_last_user_expression_resume; 1218 } 1219 1220 void 1221 SetRunningUserExpression (bool on) 1222 { 1223 // REMOVEME printf ("Setting running user expression %s at resume id %d - value: %d.\n", on ? "on" : "off", m_resume_id, m_running_user_expression); 1224 if (on) 1225 m_running_user_expression++; 1226 else 1227 m_running_user_expression--; 1228 } 1229 1230private: 1231 uint32_t m_stop_id; 1232 uint32_t m_last_natural_stop_id; 1233 uint32_t m_resume_id; 1234 uint32_t m_memory_id; 1235 uint32_t m_last_user_expression_resume; 1236 uint32_t m_running_user_expression; 1237}; 1238inline bool operator== (const ProcessModID &lhs, const ProcessModID &rhs) 1239{ 1240 if (lhs.StopIDEqual (rhs) 1241 && lhs.MemoryIDEqual (rhs)) 1242 return true; 1243 else 1244 return false; 1245} 1246 1247inline bool operator!= (const ProcessModID &lhs, const ProcessModID &rhs) 1248{ 1249 if (!lhs.StopIDEqual (rhs) 1250 || !lhs.MemoryIDEqual (rhs)) 1251 return true; 1252 else 1253 return false; 1254} 1255 1256class MemoryRegionInfo 1257{ 1258public: 1259 typedef Range<lldb::addr_t, lldb::addr_t> RangeType; 1260 1261 enum OptionalBool { 1262 eDontKnow = -1, 1263 eNo = 0, 1264 eYes = 1 1265 }; 1266 1267 MemoryRegionInfo () : 1268 m_range (), 1269 m_read (eDontKnow), 1270 m_write (eDontKnow), 1271 m_execute (eDontKnow) 1272 { 1273 } 1274 1275 ~MemoryRegionInfo () 1276 { 1277 } 1278 1279 RangeType & 1280 GetRange() 1281 { 1282 return m_range; 1283 } 1284 1285 void 1286 Clear() 1287 { 1288 m_range.Clear(); 1289 m_read = m_write = m_execute = eDontKnow; 1290 } 1291 1292 const RangeType & 1293 GetRange() const 1294 { 1295 return m_range; 1296 } 1297 1298 OptionalBool 1299 GetReadable () const 1300 { 1301 return m_read; 1302 } 1303 1304 OptionalBool 1305 GetWritable () const 1306 { 1307 return m_write; 1308 } 1309 1310 OptionalBool 1311 GetExecutable () const 1312 { 1313 return m_execute; 1314 } 1315 1316 void 1317 SetReadable (OptionalBool val) 1318 { 1319 m_read = val; 1320 } 1321 1322 void 1323 SetWritable (OptionalBool val) 1324 { 1325 m_write = val; 1326 } 1327 1328 void 1329 SetExecutable (OptionalBool val) 1330 { 1331 m_execute = val; 1332 } 1333 1334protected: 1335 RangeType m_range; 1336 OptionalBool m_read; 1337 OptionalBool m_write; 1338 OptionalBool m_execute; 1339}; 1340 1341//---------------------------------------------------------------------- 1342/// @class Process Process.h "lldb/Target/Process.h" 1343/// @brief A plug-in interface definition class for debugging a process. 1344//---------------------------------------------------------------------- 1345class Process : 1346 public STD_ENABLE_SHARED_FROM_THIS(Process), 1347 public ProcessProperties, 1348 public UserID, 1349 public Broadcaster, 1350 public ExecutionContextScope, 1351 public PluginInterface 1352{ 1353friend class ThreadList; 1354friend class ClangFunction; // For WaitForStateChangeEventsPrivate 1355friend class CommandObjectProcessLaunch; 1356friend class ProcessEventData; 1357friend class CommandObjectBreakpointCommand; 1358friend class StopInfo; 1359 1360public: 1361 1362 //------------------------------------------------------------------ 1363 /// Broadcaster event bits definitions. 1364 //------------------------------------------------------------------ 1365 enum 1366 { 1367 eBroadcastBitStateChanged = (1 << 0), 1368 eBroadcastBitInterrupt = (1 << 1), 1369 eBroadcastBitSTDOUT = (1 << 2), 1370 eBroadcastBitSTDERR = (1 << 3), 1371 eBroadcastBitProfileData = (1 << 4) 1372 }; 1373 1374 enum 1375 { 1376 eBroadcastInternalStateControlStop = (1<<0), 1377 eBroadcastInternalStateControlPause = (1<<1), 1378 eBroadcastInternalStateControlResume = (1<<2) 1379 }; 1380 1381 typedef Range<lldb::addr_t, lldb::addr_t> LoadRange; 1382 // We use a read/write lock to allow on or more clients to 1383 // access the process state while the process is stopped (reader). 1384 // We lock the write lock to control access to the process 1385 // while it is running (readers, or clients that want the process 1386 // stopped can block waiting for the process to stop, or just 1387 // try to lock it to see if they can immediately access the stopped 1388 // process. If the try read lock fails, then the process is running. 1389 typedef ReadWriteLock::ReadLocker StopLocker; 1390 typedef ReadWriteLock::WriteLocker RunLocker; 1391 1392 // These two functions fill out the Broadcaster interface: 1393 1394 static ConstString &GetStaticBroadcasterClass (); 1395 1396 virtual ConstString &GetBroadcasterClass() const 1397 { 1398 return GetStaticBroadcasterClass(); 1399 } 1400 1401 1402 //------------------------------------------------------------------ 1403 /// A notification structure that can be used by clients to listen 1404 /// for changes in a process's lifetime. 1405 /// 1406 /// @see RegisterNotificationCallbacks (const Notifications&) 1407 /// @see UnregisterNotificationCallbacks (const Notifications&) 1408 //------------------------------------------------------------------ 1409#ifndef SWIG 1410 typedef struct 1411 { 1412 void *baton; 1413 void (*initialize)(void *baton, Process *process); 1414 void (*process_state_changed) (void *baton, Process *process, lldb::StateType state); 1415 } Notifications; 1416 1417 class ProcessEventData : 1418 public EventData 1419 { 1420 friend class Process; 1421 1422 public: 1423 ProcessEventData (); 1424 ProcessEventData (const lldb::ProcessSP &process, lldb::StateType state); 1425 1426 virtual ~ProcessEventData(); 1427 1428 static const ConstString & 1429 GetFlavorString (); 1430 1431 virtual const ConstString & 1432 GetFlavor () const; 1433 1434 const lldb::ProcessSP & 1435 GetProcessSP() const 1436 { 1437 return m_process_sp; 1438 } 1439 lldb::StateType 1440 GetState() const 1441 { 1442 return m_state; 1443 } 1444 bool 1445 GetRestarted () const 1446 { 1447 return m_restarted; 1448 } 1449 bool 1450 GetInterrupted () const 1451 { 1452 return m_interrupted; 1453 } 1454 1455 virtual void 1456 Dump (Stream *s) const; 1457 1458 virtual void 1459 DoOnRemoval (Event *event_ptr); 1460 1461 static const Process::ProcessEventData * 1462 GetEventDataFromEvent (const Event *event_ptr); 1463 1464 static lldb::ProcessSP 1465 GetProcessFromEvent (const Event *event_ptr); 1466 1467 static lldb::StateType 1468 GetStateFromEvent (const Event *event_ptr); 1469 1470 static bool 1471 GetRestartedFromEvent (const Event *event_ptr); 1472 1473 static void 1474 SetRestartedInEvent (Event *event_ptr, bool new_value); 1475 1476 static bool 1477 GetInterruptedFromEvent (const Event *event_ptr); 1478 1479 static void 1480 SetInterruptedInEvent (Event *event_ptr, bool new_value); 1481 1482 static bool 1483 SetUpdateStateOnRemoval (Event *event_ptr); 1484 1485 private: 1486 1487 void 1488 SetUpdateStateOnRemoval() 1489 { 1490 m_update_state++; 1491 } 1492 void 1493 SetRestarted (bool new_value) 1494 { 1495 m_restarted = new_value; 1496 } 1497 void 1498 SetInterrupted (bool new_value) 1499 { 1500 m_interrupted = new_value; 1501 } 1502 1503 lldb::ProcessSP m_process_sp; 1504 lldb::StateType m_state; 1505 bool m_restarted; // For "eStateStopped" events, this is true if the target was automatically restarted. 1506 int m_update_state; 1507 bool m_interrupted; 1508 DISALLOW_COPY_AND_ASSIGN (ProcessEventData); 1509 1510 }; 1511 1512#endif 1513 1514 static void 1515 SettingsInitialize (); 1516 1517 static void 1518 SettingsTerminate (); 1519 1520 static const ProcessPropertiesSP & 1521 GetGlobalProperties(); 1522 1523 //------------------------------------------------------------------ 1524 /// Construct with a shared pointer to a target, and the Process listener. 1525 //------------------------------------------------------------------ 1526 Process(Target &target, Listener &listener); 1527 1528 //------------------------------------------------------------------ 1529 /// Destructor. 1530 /// 1531 /// The destructor is virtual since this class is designed to be 1532 /// inherited from by the plug-in instance. 1533 //------------------------------------------------------------------ 1534 virtual 1535 ~Process(); 1536 1537 //------------------------------------------------------------------ 1538 /// Find a Process plug-in that can debug \a module using the 1539 /// currently selected architecture. 1540 /// 1541 /// Scans all loaded plug-in interfaces that implement versions of 1542 /// the Process plug-in interface and returns the first instance 1543 /// that can debug the file. 1544 /// 1545 /// @param[in] module_sp 1546 /// The module shared pointer that this process will debug. 1547 /// 1548 /// @param[in] plugin_name 1549 /// If NULL, select the best plug-in for the binary. If non-NULL 1550 /// then look for a plugin whose PluginInfo's name matches 1551 /// this string. 1552 /// 1553 /// @see Process::CanDebug () 1554 //------------------------------------------------------------------ 1555 static lldb::ProcessSP 1556 FindPlugin (Target &target, 1557 const char *plugin_name, 1558 Listener &listener, 1559 const FileSpec *crash_file_path); 1560 1561 1562 1563 //------------------------------------------------------------------ 1564 /// Static function that can be used with the \b host function 1565 /// Host::StartMonitoringChildProcess (). 1566 /// 1567 /// This function can be used by lldb_private::Process subclasses 1568 /// when they want to watch for a local process and have its exit 1569 /// status automatically set when the host child process exits. 1570 /// Subclasses should call Host::StartMonitoringChildProcess () 1571 /// with: 1572 /// callback = Process::SetHostProcessExitStatus 1573 /// callback_baton = NULL 1574 /// pid = Process::GetID() 1575 /// monitor_signals = false 1576 //------------------------------------------------------------------ 1577 static bool 1578 SetProcessExitStatus (void *callback_baton, // The callback baton which should be set to NULL 1579 lldb::pid_t pid, // The process ID we want to monitor 1580 bool exited, 1581 int signo, // Zero for no signal 1582 int status); // Exit value of process if signal is zero 1583 1584 lldb::ByteOrder 1585 GetByteOrder () const; 1586 1587 uint32_t 1588 GetAddressByteSize () const; 1589 1590 uint32_t 1591 GetUniqueID() const 1592 { 1593 return m_process_unique_id; 1594 } 1595 //------------------------------------------------------------------ 1596 /// Check if a plug-in instance can debug the file in \a module. 1597 /// 1598 /// Each plug-in is given a chance to say whether it can debug 1599 /// the file in \a module. If the Process plug-in instance can 1600 /// debug a file on the current system, it should return \b true. 1601 /// 1602 /// @return 1603 /// Returns \b true if this Process plug-in instance can 1604 /// debug the executable, \b false otherwise. 1605 //------------------------------------------------------------------ 1606 virtual bool 1607 CanDebug (Target &target, 1608 bool plugin_specified_by_name) = 0; 1609 1610 1611 //------------------------------------------------------------------ 1612 /// This object is about to be destroyed, do any necessary cleanup. 1613 /// 1614 /// Subclasses that override this method should always call this 1615 /// superclass method. 1616 //------------------------------------------------------------------ 1617 virtual void 1618 Finalize(); 1619 1620 1621 //------------------------------------------------------------------ 1622 /// Return whether this object is valid (i.e. has not been finalized.) 1623 /// 1624 /// @return 1625 /// Returns \b true if this Process has not been finalized 1626 /// and \b false otherwise. 1627 //------------------------------------------------------------------ 1628 bool 1629 IsValid() const 1630 { 1631 return !m_finalize_called; 1632 } 1633 1634 //------------------------------------------------------------------ 1635 /// Return a multi-word command object that can be used to expose 1636 /// plug-in specific commands. 1637 /// 1638 /// This object will be used to resolve plug-in commands and can be 1639 /// triggered by a call to: 1640 /// 1641 /// (lldb) process commmand <args> 1642 /// 1643 /// @return 1644 /// A CommandObject which can be one of the concrete subclasses 1645 /// of CommandObject like CommandObjectRaw, CommandObjectParsed, 1646 /// or CommandObjectMultiword. 1647 //------------------------------------------------------------------ 1648 virtual CommandObject * 1649 GetPluginCommandObject() 1650 { 1651 return NULL; 1652 } 1653 1654 //------------------------------------------------------------------ 1655 /// Launch a new process. 1656 /// 1657 /// Launch a new process by spawning a new process using the 1658 /// target object's executable module's file as the file to launch. 1659 /// Arguments are given in \a argv, and the environment variables 1660 /// are in \a envp. Standard input and output files can be 1661 /// optionally re-directed to \a stdin_path, \a stdout_path, and 1662 /// \a stderr_path. 1663 /// 1664 /// This function is not meant to be overridden by Process 1665 /// subclasses. It will first call Process::WillLaunch (Module *) 1666 /// and if that returns \b true, Process::DoLaunch (Module*, 1667 /// char const *[],char const *[],const char *,const char *, 1668 /// const char *) will be called to actually do the launching. If 1669 /// DoLaunch returns \b true, then Process::DidLaunch() will be 1670 /// called. 1671 /// 1672 /// @param[in] argv 1673 /// The argument array. 1674 /// 1675 /// @param[in] envp 1676 /// The environment array. 1677 /// 1678 /// @param[in] launch_flags 1679 /// Flags to modify the launch (@see lldb::LaunchFlags) 1680 /// 1681 /// @param[in] stdin_path 1682 /// The path to use when re-directing the STDIN of the new 1683 /// process. If all stdXX_path arguments are NULL, a pseudo 1684 /// terminal will be used. 1685 /// 1686 /// @param[in] stdout_path 1687 /// The path to use when re-directing the STDOUT of the new 1688 /// process. If all stdXX_path arguments are NULL, a pseudo 1689 /// terminal will be used. 1690 /// 1691 /// @param[in] stderr_path 1692 /// The path to use when re-directing the STDERR of the new 1693 /// process. If all stdXX_path arguments are NULL, a pseudo 1694 /// terminal will be used. 1695 /// 1696 /// @param[in] working_directory 1697 /// The working directory to have the child process run in 1698 /// 1699 /// @return 1700 /// An error object. Call GetID() to get the process ID if 1701 /// the error object is success. 1702 //------------------------------------------------------------------ 1703 virtual Error 1704 Launch (const ProcessLaunchInfo &launch_info); 1705 1706 virtual Error 1707 LoadCore (); 1708 1709 virtual Error 1710 DoLoadCore () 1711 { 1712 Error error; 1713 error.SetErrorStringWithFormat("error: %s does not support loading core files.", GetShortPluginName()); 1714 return error; 1715 } 1716 1717 //------------------------------------------------------------------ 1718 /// Get the dynamic loader plug-in for this process. 1719 /// 1720 /// The default action is to let the DynamicLoader plug-ins check 1721 /// the main executable and the DynamicLoader will select itself 1722 /// automatically. Subclasses can override this if inspecting the 1723 /// executable is not desired, or if Process subclasses can only 1724 /// use a specific DynamicLoader plug-in. 1725 //------------------------------------------------------------------ 1726 virtual DynamicLoader * 1727 GetDynamicLoader (); 1728 1729 //------------------------------------------------------------------ 1730 /// Attach to an existing process using the process attach info. 1731 /// 1732 /// This function is not meant to be overridden by Process 1733 /// subclasses. It will first call WillAttach (lldb::pid_t) 1734 /// or WillAttach (const char *), and if that returns \b 1735 /// true, DoAttach (lldb::pid_t) or DoAttach (const char *) will 1736 /// be called to actually do the attach. If DoAttach returns \b 1737 /// true, then Process::DidAttach() will be called. 1738 /// 1739 /// @param[in] pid 1740 /// The process ID that we should attempt to attach to. 1741 /// 1742 /// @return 1743 /// Returns \a pid if attaching was successful, or 1744 /// LLDB_INVALID_PROCESS_ID if attaching fails. 1745 //------------------------------------------------------------------ 1746 virtual Error 1747 Attach (ProcessAttachInfo &attach_info); 1748 1749 //------------------------------------------------------------------ 1750 /// Attach to a remote system via a URL 1751 /// 1752 /// @param[in] strm 1753 /// A stream where output intended for the user 1754 /// (if the driver has a way to display that) generated during 1755 /// the connection. This may be NULL if no output is needed.A 1756 /// 1757 /// @param[in] remote_url 1758 /// The URL format that we are connecting to. 1759 /// 1760 /// @return 1761 /// Returns an error object. 1762 //------------------------------------------------------------------ 1763 virtual Error 1764 ConnectRemote (Stream *strm, const char *remote_url); 1765 1766 bool 1767 GetShouldDetach () const 1768 { 1769 return m_should_detach; 1770 } 1771 1772 void 1773 SetShouldDetach (bool b) 1774 { 1775 m_should_detach = b; 1776 } 1777 1778 //------------------------------------------------------------------ 1779 /// Get the image information address for the current process. 1780 /// 1781 /// Some runtimes have system functions that can help dynamic 1782 /// loaders locate the dynamic loader information needed to observe 1783 /// shared libraries being loaded or unloaded. This function is 1784 /// in the Process interface (as opposed to the DynamicLoader 1785 /// interface) to ensure that remote debugging can take advantage of 1786 /// this functionality. 1787 /// 1788 /// @return 1789 /// The address of the dynamic loader information, or 1790 /// LLDB_INVALID_ADDRESS if this is not supported by this 1791 /// interface. 1792 //------------------------------------------------------------------ 1793 virtual lldb::addr_t 1794 GetImageInfoAddress (); 1795 1796 //------------------------------------------------------------------ 1797 /// Load a shared library into this process. 1798 /// 1799 /// Try and load a shared library into the current process. This 1800 /// call might fail in the dynamic loader plug-in says it isn't safe 1801 /// to try and load shared libraries at the moment. 1802 /// 1803 /// @param[in] image_spec 1804 /// The image file spec that points to the shared library that 1805 /// you want to load. 1806 /// 1807 /// @param[out] error 1808 /// An error object that gets filled in with any errors that 1809 /// might occur when trying to load the shared library. 1810 /// 1811 /// @return 1812 /// A token that represents the shared library that can be 1813 /// later used to unload the shared library. A value of 1814 /// LLDB_INVALID_IMAGE_TOKEN will be returned if the shared 1815 /// library can't be opened. 1816 //------------------------------------------------------------------ 1817 virtual uint32_t 1818 LoadImage (const FileSpec &image_spec, Error &error); 1819 1820 virtual Error 1821 UnloadImage (uint32_t image_token); 1822 1823 //------------------------------------------------------------------ 1824 /// Register for process and thread notifications. 1825 /// 1826 /// Clients can register nofication callbacks by filling out a 1827 /// Process::Notifications structure and calling this function. 1828 /// 1829 /// @param[in] callbacks 1830 /// A structure that contains the notification baton and 1831 /// callback functions. 1832 /// 1833 /// @see Process::Notifications 1834 //------------------------------------------------------------------ 1835#ifndef SWIG 1836 void 1837 RegisterNotificationCallbacks (const Process::Notifications& callbacks); 1838#endif 1839 //------------------------------------------------------------------ 1840 /// Unregister for process and thread notifications. 1841 /// 1842 /// Clients can unregister nofication callbacks by passing a copy of 1843 /// the original baton and callbacks in \a callbacks. 1844 /// 1845 /// @param[in] callbacks 1846 /// A structure that contains the notification baton and 1847 /// callback functions. 1848 /// 1849 /// @return 1850 /// Returns \b true if the notification callbacks were 1851 /// successfully removed from the process, \b false otherwise. 1852 /// 1853 /// @see Process::Notifications 1854 //------------------------------------------------------------------ 1855#ifndef SWIG 1856 bool 1857 UnregisterNotificationCallbacks (const Process::Notifications& callbacks); 1858#endif 1859 //================================================================== 1860 // Built in Process Control functions 1861 //================================================================== 1862 //------------------------------------------------------------------ 1863 /// Resumes all of a process's threads as configured using the 1864 /// Thread run control functions. 1865 /// 1866 /// Threads for a process should be updated with one of the run 1867 /// control actions (resume, step, or suspend) that they should take 1868 /// when the process is resumed. If no run control action is given 1869 /// to a thread it will be resumed by default. 1870 /// 1871 /// This function is not meant to be overridden by Process 1872 /// subclasses. This function will take care of disabling any 1873 /// breakpoints that threads may be stopped at, single stepping, and 1874 /// re-enabling breakpoints, and enabling the basic flow control 1875 /// that the plug-in instances need not worry about. 1876 /// 1877 /// N.B. This function also sets the Write side of the Run Lock, 1878 /// which is unset when the corresponding stop event is pulled off 1879 /// the Public Event Queue. If you need to resume the process without 1880 /// setting the Run Lock, use PrivateResume (though you should only do 1881 /// that from inside the Process class. 1882 /// 1883 /// @return 1884 /// Returns an error object. 1885 /// 1886 /// @see Thread:Resume() 1887 /// @see Thread:Step() 1888 /// @see Thread:Suspend() 1889 //------------------------------------------------------------------ 1890 Error 1891 Resume(); 1892 1893 //------------------------------------------------------------------ 1894 /// Halts a running process. 1895 /// 1896 /// This function is not meant to be overridden by Process 1897 /// subclasses. 1898 /// If the process is successfully halted, a eStateStopped 1899 /// process event with GetInterrupted will be broadcast. If false, we will 1900 /// halt the process with no events generated by the halt. 1901 /// 1902 /// @return 1903 /// Returns an error object. If the error is empty, the process is halted. 1904 /// otherwise the halt has failed. 1905 //------------------------------------------------------------------ 1906 Error 1907 Halt (); 1908 1909 //------------------------------------------------------------------ 1910 /// Detaches from a running or stopped process. 1911 /// 1912 /// This function is not meant to be overridden by Process 1913 /// subclasses. 1914 /// 1915 /// @return 1916 /// Returns an error object. 1917 //------------------------------------------------------------------ 1918 Error 1919 Detach (); 1920 1921 //------------------------------------------------------------------ 1922 /// Kills the process and shuts down all threads that were spawned 1923 /// to track and monitor the process. 1924 /// 1925 /// This function is not meant to be overridden by Process 1926 /// subclasses. 1927 /// 1928 /// @return 1929 /// Returns an error object. 1930 //------------------------------------------------------------------ 1931 Error 1932 Destroy(); 1933 1934 //------------------------------------------------------------------ 1935 /// Sends a process a UNIX signal \a signal. 1936 /// 1937 /// This function is not meant to be overridden by Process 1938 /// subclasses. 1939 /// 1940 /// @return 1941 /// Returns an error object. 1942 //------------------------------------------------------------------ 1943 Error 1944 Signal (int signal); 1945 1946 virtual UnixSignals & 1947 GetUnixSignals () 1948 { 1949 return m_unix_signals; 1950 } 1951 1952 //================================================================== 1953 // Plug-in Process Control Overrides 1954 //================================================================== 1955 1956 //------------------------------------------------------------------ 1957 /// Called before attaching to a process. 1958 /// 1959 /// Allow Process plug-ins to execute some code before attaching a 1960 /// process. 1961 /// 1962 /// @return 1963 /// Returns an error object. 1964 //------------------------------------------------------------------ 1965 virtual Error 1966 WillAttachToProcessWithID (lldb::pid_t pid) 1967 { 1968 return Error(); 1969 } 1970 1971 //------------------------------------------------------------------ 1972 /// Called before attaching to a process. 1973 /// 1974 /// Allow Process plug-ins to execute some code before attaching a 1975 /// process. 1976 /// 1977 /// @return 1978 /// Returns an error object. 1979 //------------------------------------------------------------------ 1980 virtual Error 1981 WillAttachToProcessWithName (const char *process_name, bool wait_for_launch) 1982 { 1983 return Error(); 1984 } 1985 1986 //------------------------------------------------------------------ 1987 /// Attach to a remote system via a URL 1988 /// 1989 /// @param[in] strm 1990 /// A stream where output intended for the user 1991 /// (if the driver has a way to display that) generated during 1992 /// the connection. This may be NULL if no output is needed.A 1993 /// 1994 /// @param[in] remote_url 1995 /// The URL format that we are connecting to. 1996 /// 1997 /// @return 1998 /// Returns an error object. 1999 //------------------------------------------------------------------ 2000 virtual Error 2001 DoConnectRemote (Stream *strm, const char *remote_url) 2002 { 2003 Error error; 2004 error.SetErrorString ("remote connections are not supported"); 2005 return error; 2006 } 2007 2008 //------------------------------------------------------------------ 2009 /// Attach to an existing process using a process ID. 2010 /// 2011 /// @param[in] pid 2012 /// The process ID that we should attempt to attach to. 2013 /// 2014 /// @return 2015 /// Returns \a pid if attaching was successful, or 2016 /// LLDB_INVALID_PROCESS_ID if attaching fails. 2017 //------------------------------------------------------------------ 2018 virtual Error 2019 DoAttachToProcessWithID (lldb::pid_t pid) 2020 { 2021 Error error; 2022 error.SetErrorStringWithFormat("error: %s does not support attaching to a process by pid", GetShortPluginName()); 2023 return error; 2024 } 2025 2026 //------------------------------------------------------------------ 2027 /// Attach to an existing process using a process ID. 2028 /// 2029 /// @param[in] pid 2030 /// The process ID that we should attempt to attach to. 2031 /// 2032 /// @param[in] attach_info 2033 /// Information on how to do the attach. For example, GetUserID() 2034 /// will return the uid to attach as. 2035 /// 2036 /// @return 2037 /// Returns \a pid if attaching was successful, or 2038 /// LLDB_INVALID_PROCESS_ID if attaching fails. 2039 /// hanming : need flag 2040 //------------------------------------------------------------------ 2041 virtual Error 2042 DoAttachToProcessWithID (lldb::pid_t pid, const ProcessAttachInfo &attach_info) 2043 { 2044 Error error; 2045 error.SetErrorStringWithFormat("error: %s does not support attaching to a process by pid", GetShortPluginName()); 2046 return error; 2047 } 2048 2049 //------------------------------------------------------------------ 2050 /// Attach to an existing process using a partial process name. 2051 /// 2052 /// @param[in] process_name 2053 /// The name of the process to attach to. 2054 /// 2055 /// @param[in] wait_for_launch 2056 /// If \b true, wait for the process to be launched and attach 2057 /// as soon as possible after it does launch. If \b false, then 2058 /// search for a matching process the currently exists. 2059 /// 2060 /// @param[in] attach_info 2061 /// Information on how to do the attach. For example, GetUserID() 2062 /// will return the uid to attach as. 2063 /// 2064 /// @return 2065 /// Returns \a pid if attaching was successful, or 2066 /// LLDB_INVALID_PROCESS_ID if attaching fails. 2067 //------------------------------------------------------------------ 2068 virtual Error 2069 DoAttachToProcessWithName (const char *process_name, bool wait_for_launch, const ProcessAttachInfo &attach_info) 2070 { 2071 Error error; 2072 error.SetErrorString("attach by name is not supported"); 2073 return error; 2074 } 2075 2076 //------------------------------------------------------------------ 2077 /// Called after attaching a process. 2078 /// 2079 /// Allow Process plug-ins to execute some code after attaching to 2080 /// a process. 2081 //------------------------------------------------------------------ 2082 virtual void 2083 DidAttach () {} 2084 2085 2086 //------------------------------------------------------------------ 2087 /// Called after a process re-execs itself. 2088 /// 2089 /// Allow Process plug-ins to execute some code after a process has 2090 /// exec'ed itself. Subclasses typically should override DoDidExec() 2091 /// as the lldb_private::Process class needs to remove its dynamic 2092 /// loader, runtime, ABI and other plug-ins, as well as unload all 2093 /// shared libraries. 2094 //------------------------------------------------------------------ 2095 virtual void 2096 DidExec (); 2097 2098 //------------------------------------------------------------------ 2099 /// Subclasses of Process should implement this function if they 2100 /// need to do anything after a process exec's itself. 2101 //------------------------------------------------------------------ 2102 virtual void 2103 DoDidExec () 2104 { 2105 } 2106 2107 //------------------------------------------------------------------ 2108 /// Called before launching to a process. 2109 /// 2110 /// Allow Process plug-ins to execute some code before launching a 2111 /// process. 2112 /// 2113 /// @return 2114 /// Returns an error object. 2115 //------------------------------------------------------------------ 2116 virtual Error 2117 WillLaunch (Module* module) 2118 { 2119 return Error(); 2120 } 2121 2122 //------------------------------------------------------------------ 2123 /// Launch a new process. 2124 /// 2125 /// Launch a new process by spawning a new process using \a module's 2126 /// file as the file to launch. Arguments are given in \a argv, 2127 /// and the environment variables are in \a envp. Standard input 2128 /// and output files can be optionally re-directed to \a stdin_path, 2129 /// \a stdout_path, and \a stderr_path. 2130 /// 2131 /// @param[in] module 2132 /// The module from which to extract the file specification and 2133 /// launch. 2134 /// 2135 /// @param[in] argv 2136 /// The argument array. 2137 /// 2138 /// @param[in] envp 2139 /// The environment array. 2140 /// 2141 /// @param[in] launch_flags 2142 /// Flags to modify the launch (@see lldb::LaunchFlags) 2143 /// 2144 /// @param[in] stdin_path 2145 /// The path to use when re-directing the STDIN of the new 2146 /// process. If all stdXX_path arguments are NULL, a pseudo 2147 /// terminal will be used. 2148 /// 2149 /// @param[in] stdout_path 2150 /// The path to use when re-directing the STDOUT of the new 2151 /// process. If all stdXX_path arguments are NULL, a pseudo 2152 /// terminal will be used. 2153 /// 2154 /// @param[in] stderr_path 2155 /// The path to use when re-directing the STDERR of the new 2156 /// process. If all stdXX_path arguments are NULL, a pseudo 2157 /// terminal will be used. 2158 /// 2159 /// @param[in] working_directory 2160 /// The working directory to have the child process run in 2161 /// 2162 /// @return 2163 /// A new valid process ID, or LLDB_INVALID_PROCESS_ID if 2164 /// launching fails. 2165 //------------------------------------------------------------------ 2166 virtual Error 2167 DoLaunch (Module *exe_module, 2168 const ProcessLaunchInfo &launch_info) 2169 { 2170 Error error; 2171 error.SetErrorStringWithFormat("error: %s does not support launching processes", GetShortPluginName()); 2172 return error; 2173 } 2174 2175 2176 //------------------------------------------------------------------ 2177 /// Called after launching a process. 2178 /// 2179 /// Allow Process plug-ins to execute some code after launching 2180 /// a process. 2181 //------------------------------------------------------------------ 2182 virtual void 2183 DidLaunch () {} 2184 2185 2186 2187 //------------------------------------------------------------------ 2188 /// Called before resuming to a process. 2189 /// 2190 /// Allow Process plug-ins to execute some code before resuming a 2191 /// process. 2192 /// 2193 /// @return 2194 /// Returns an error object. 2195 //------------------------------------------------------------------ 2196 virtual Error 2197 WillResume () { return Error(); } 2198 2199 //------------------------------------------------------------------ 2200 /// Resumes all of a process's threads as configured using the 2201 /// Thread run control functions. 2202 /// 2203 /// Threads for a process should be updated with one of the run 2204 /// control actions (resume, step, or suspend) that they should take 2205 /// when the process is resumed. If no run control action is given 2206 /// to a thread it will be resumed by default. 2207 /// 2208 /// @return 2209 /// Returns \b true if the process successfully resumes using 2210 /// the thread run control actions, \b false otherwise. 2211 /// 2212 /// @see Thread:Resume() 2213 /// @see Thread:Step() 2214 /// @see Thread:Suspend() 2215 //------------------------------------------------------------------ 2216 virtual Error 2217 DoResume () 2218 { 2219 Error error; 2220 error.SetErrorStringWithFormat("error: %s does not support resuming processes", GetShortPluginName()); 2221 return error; 2222 } 2223 2224 2225 //------------------------------------------------------------------ 2226 /// Called after resuming a process. 2227 /// 2228 /// Allow Process plug-ins to execute some code after resuming 2229 /// a process. 2230 //------------------------------------------------------------------ 2231 virtual void 2232 DidResume () {} 2233 2234 2235 //------------------------------------------------------------------ 2236 /// Called before halting to a process. 2237 /// 2238 /// Allow Process plug-ins to execute some code before halting a 2239 /// process. 2240 /// 2241 /// @return 2242 /// Returns an error object. 2243 //------------------------------------------------------------------ 2244 virtual Error 2245 WillHalt () { return Error(); } 2246 2247 //------------------------------------------------------------------ 2248 /// Halts a running process. 2249 /// 2250 /// DoHalt must produce one and only one stop StateChanged event if it actually 2251 /// stops the process. If the stop happens through some natural event (for 2252 /// instance a SIGSTOP), then forwarding that event will do. Otherwise, you must 2253 /// generate the event manually. Note also, the private event thread is stopped when 2254 /// DoHalt is run to prevent the events generated while halting to trigger 2255 /// other state changes before the halt is complete. 2256 /// 2257 /// @param[out] caused_stop 2258 /// If true, then this Halt caused the stop, otherwise, the 2259 /// process was already stopped. 2260 /// 2261 /// @return 2262 /// Returns \b true if the process successfully halts, \b false 2263 /// otherwise. 2264 //------------------------------------------------------------------ 2265 virtual Error 2266 DoHalt (bool &caused_stop) 2267 { 2268 Error error; 2269 error.SetErrorStringWithFormat("error: %s does not support halting processes", GetShortPluginName()); 2270 return error; 2271 } 2272 2273 2274 //------------------------------------------------------------------ 2275 /// Called after halting a process. 2276 /// 2277 /// Allow Process plug-ins to execute some code after halting 2278 /// a process. 2279 //------------------------------------------------------------------ 2280 virtual void 2281 DidHalt () {} 2282 2283 //------------------------------------------------------------------ 2284 /// Called before detaching from a process. 2285 /// 2286 /// Allow Process plug-ins to execute some code before detaching 2287 /// from a process. 2288 /// 2289 /// @return 2290 /// Returns an error object. 2291 //------------------------------------------------------------------ 2292 virtual Error 2293 WillDetach () 2294 { 2295 return Error(); 2296 } 2297 2298 //------------------------------------------------------------------ 2299 /// Detaches from a running or stopped process. 2300 /// 2301 /// @return 2302 /// Returns \b true if the process successfully detaches, \b 2303 /// false otherwise. 2304 //------------------------------------------------------------------ 2305 virtual Error 2306 DoDetach () 2307 { 2308 Error error; 2309 error.SetErrorStringWithFormat("error: %s does not support detaching from processes", GetShortPluginName()); 2310 return error; 2311 } 2312 2313 2314 //------------------------------------------------------------------ 2315 /// Called after detaching from a process. 2316 /// 2317 /// Allow Process plug-ins to execute some code after detaching 2318 /// from a process. 2319 //------------------------------------------------------------------ 2320 virtual void 2321 DidDetach () {} 2322 2323 //------------------------------------------------------------------ 2324 /// Called before sending a signal to a process. 2325 /// 2326 /// Allow Process plug-ins to execute some code before sending a 2327 /// signal to a process. 2328 /// 2329 /// @return 2330 /// Returns no error if it is safe to proceed with a call to 2331 /// Process::DoSignal(int), otherwise an error describing what 2332 /// prevents the signal from being sent. 2333 //------------------------------------------------------------------ 2334 virtual Error 2335 WillSignal () { return Error(); } 2336 2337 //------------------------------------------------------------------ 2338 /// Sends a process a UNIX signal \a signal. 2339 /// 2340 /// @return 2341 /// Returns an error object. 2342 //------------------------------------------------------------------ 2343 virtual Error 2344 DoSignal (int signal) 2345 { 2346 Error error; 2347 error.SetErrorStringWithFormat("error: %s does not support senging signals to processes", GetShortPluginName()); 2348 return error; 2349 } 2350 2351 virtual Error 2352 WillDestroy () { return Error(); } 2353 2354 virtual Error 2355 DoDestroy () = 0; 2356 2357 virtual void 2358 DidDestroy () { } 2359 2360 2361 //------------------------------------------------------------------ 2362 /// Called after sending a signal to a process. 2363 /// 2364 /// Allow Process plug-ins to execute some code after sending a 2365 /// signal to a process. 2366 //------------------------------------------------------------------ 2367 virtual void 2368 DidSignal () {} 2369 2370 //------------------------------------------------------------------ 2371 /// Currently called as part of ShouldStop. 2372 /// FIXME: Should really happen when the target stops before the 2373 /// event is taken from the queue... 2374 /// 2375 /// This callback is called as the event 2376 /// is about to be queued up to allow Process plug-ins to execute 2377 /// some code prior to clients being notified that a process was 2378 /// stopped. Common operations include updating the thread list, 2379 /// invalidating any thread state (registers, stack, etc) prior to 2380 /// letting the notification go out. 2381 /// 2382 //------------------------------------------------------------------ 2383 virtual void 2384 RefreshStateAfterStop () = 0; 2385 2386 //------------------------------------------------------------------ 2387 /// Get the target object pointer for this module. 2388 /// 2389 /// @return 2390 /// A Target object pointer to the target that owns this 2391 /// module. 2392 //------------------------------------------------------------------ 2393 Target & 2394 GetTarget () 2395 { 2396 return m_target; 2397 } 2398 2399 //------------------------------------------------------------------ 2400 /// Get the const target object pointer for this module. 2401 /// 2402 /// @return 2403 /// A const Target object pointer to the target that owns this 2404 /// module. 2405 //------------------------------------------------------------------ 2406 const Target & 2407 GetTarget () const 2408 { 2409 return m_target; 2410 } 2411 2412 //------------------------------------------------------------------ 2413 /// Flush all data in the process. 2414 /// 2415 /// Flush the memory caches, all threads, and any other cached data 2416 /// in the process. 2417 /// 2418 /// This function can be called after a world changing event like 2419 /// adding a new symbol file, or after the process makes a large 2420 /// context switch (from boot ROM to booted into an OS). 2421 //------------------------------------------------------------------ 2422 void 2423 Flush (); 2424 2425 //------------------------------------------------------------------ 2426 /// Get accessor for the current process state. 2427 /// 2428 /// @return 2429 /// The current state of the process. 2430 /// 2431 /// @see lldb::StateType 2432 //------------------------------------------------------------------ 2433 lldb::StateType 2434 GetState (); 2435 2436 ExecutionResults 2437 RunThreadPlan (ExecutionContext &exe_ctx, 2438 lldb::ThreadPlanSP &thread_plan_sp, 2439 bool stop_others, 2440 bool run_others, 2441 bool unwind_on_error, 2442 bool ignore_breakpoints, 2443 uint32_t timeout_usec, 2444 Stream &errors); 2445 2446 static const char * 2447 ExecutionResultAsCString (ExecutionResults result); 2448 2449 void 2450 GetStatus (Stream &ostrm); 2451 2452 size_t 2453 GetThreadStatus (Stream &ostrm, 2454 bool only_threads_with_stop_reason, 2455 uint32_t start_frame, 2456 uint32_t num_frames, 2457 uint32_t num_frames_with_source); 2458 2459 void 2460 SendAsyncInterrupt (); 2461 2462protected: 2463 2464 void 2465 SetState (lldb::EventSP &event_sp); 2466 2467 lldb::StateType 2468 GetPrivateState (); 2469 2470 //------------------------------------------------------------------ 2471 /// The "private" side of resuming a process. This doesn't alter the 2472 /// state of m_run_lock, but just causes the process to resume. 2473 /// 2474 /// @return 2475 /// An Error object describing the success or failure of the resume. 2476 //------------------------------------------------------------------ 2477 Error 2478 PrivateResume (); 2479 2480 //------------------------------------------------------------------ 2481 // Called internally 2482 //------------------------------------------------------------------ 2483 void 2484 CompleteAttach (); 2485 2486public: 2487 //------------------------------------------------------------------ 2488 /// Get the exit status for a process. 2489 /// 2490 /// @return 2491 /// The process's return code, or -1 if the current process 2492 /// state is not eStateExited. 2493 //------------------------------------------------------------------ 2494 int 2495 GetExitStatus (); 2496 2497 //------------------------------------------------------------------ 2498 /// Get a textual description of what the process exited. 2499 /// 2500 /// @return 2501 /// The textual description of why the process exited, or NULL 2502 /// if there is no description available. 2503 //------------------------------------------------------------------ 2504 const char * 2505 GetExitDescription (); 2506 2507 2508 virtual void 2509 DidExit () 2510 { 2511 } 2512 2513 //------------------------------------------------------------------ 2514 /// Get the Modification ID of the process. 2515 /// 2516 /// @return 2517 /// The modification ID of the process. 2518 //------------------------------------------------------------------ 2519 ProcessModID 2520 GetModID () const 2521 { 2522 return m_mod_id; 2523 } 2524 2525 const ProcessModID & 2526 GetModIDRef () const 2527 { 2528 return m_mod_id; 2529 } 2530 2531 uint32_t 2532 GetStopID () const 2533 { 2534 return m_mod_id.GetStopID(); 2535 } 2536 2537 uint32_t 2538 GetResumeID () const 2539 { 2540 return m_mod_id.GetResumeID(); 2541 } 2542 2543 uint32_t 2544 GetLastUserExpressionResumeID () const 2545 { 2546 return m_mod_id.GetLastUserExpressionResumeID(); 2547 } 2548 2549 uint32_t 2550 GetLastNaturalStopID() 2551 { 2552 return m_mod_id.GetLastNaturalStopID(); 2553 } 2554 2555 //------------------------------------------------------------------ 2556 /// Set accessor for the process exit status (return code). 2557 /// 2558 /// Sometimes a child exits and the exit can be detected by global 2559 /// functions (signal handler for SIGCHLD for example). This 2560 /// accessor allows the exit status to be set from an external 2561 /// source. 2562 /// 2563 /// Setting this will cause a eStateExited event to be posted to 2564 /// the process event queue. 2565 /// 2566 /// @param[in] exit_status 2567 /// The value for the process's return code. 2568 /// 2569 /// @see lldb::StateType 2570 //------------------------------------------------------------------ 2571 virtual bool 2572 SetExitStatus (int exit_status, const char *cstr); 2573 2574 //------------------------------------------------------------------ 2575 /// Check if a process is still alive. 2576 /// 2577 /// @return 2578 /// Returns \b true if the process is still valid, \b false 2579 /// otherwise. 2580 //------------------------------------------------------------------ 2581 virtual bool 2582 IsAlive () = 0; 2583 2584 //------------------------------------------------------------------ 2585 /// Actually do the reading of memory from a process. 2586 /// 2587 /// Subclasses must override this function and can return fewer 2588 /// bytes than requested when memory requests are too large. This 2589 /// class will break up the memory requests and keep advancing the 2590 /// arguments along as needed. 2591 /// 2592 /// @param[in] vm_addr 2593 /// A virtual load address that indicates where to start reading 2594 /// memory from. 2595 /// 2596 /// @param[in] size 2597 /// The number of bytes to read. 2598 /// 2599 /// @param[out] buf 2600 /// A byte buffer that is at least \a size bytes long that 2601 /// will receive the memory bytes. 2602 /// 2603 /// @return 2604 /// The number of bytes that were actually read into \a buf. 2605 //------------------------------------------------------------------ 2606 virtual size_t 2607 DoReadMemory (lldb::addr_t vm_addr, 2608 void *buf, 2609 size_t size, 2610 Error &error) = 0; 2611 2612 //------------------------------------------------------------------ 2613 /// Read of memory from a process. 2614 /// 2615 /// This function will read memory from the current process's 2616 /// address space and remove any traps that may have been inserted 2617 /// into the memory. 2618 /// 2619 /// This function is not meant to be overridden by Process 2620 /// subclasses, the subclasses should implement 2621 /// Process::DoReadMemory (lldb::addr_t, size_t, void *). 2622 /// 2623 /// @param[in] vm_addr 2624 /// A virtual load address that indicates where to start reading 2625 /// memory from. 2626 /// 2627 /// @param[out] buf 2628 /// A byte buffer that is at least \a size bytes long that 2629 /// will receive the memory bytes. 2630 /// 2631 /// @param[in] size 2632 /// The number of bytes to read. 2633 /// 2634 /// @return 2635 /// The number of bytes that were actually read into \a buf. If 2636 /// the returned number is greater than zero, yet less than \a 2637 /// size, then this function will get called again with \a 2638 /// vm_addr, \a buf, and \a size updated appropriately. Zero is 2639 /// returned to indicate an error. 2640 //------------------------------------------------------------------ 2641 virtual size_t 2642 ReadMemory (lldb::addr_t vm_addr, 2643 void *buf, 2644 size_t size, 2645 Error &error); 2646 2647 //------------------------------------------------------------------ 2648 /// Read a NULL terminated C string from memory 2649 /// 2650 /// This function will read a cache page at a time until the NULL 2651 /// C string terminator is found. It will stop reading if the NULL 2652 /// termination byte isn't found before reading \a cstr_max_len 2653 /// bytes, and the results are always guaranteed to be NULL 2654 /// terminated (at most cstr_max_len - 1 bytes will be read). 2655 //------------------------------------------------------------------ 2656 size_t 2657 ReadCStringFromMemory (lldb::addr_t vm_addr, 2658 char *cstr, 2659 size_t cstr_max_len, 2660 Error &error); 2661 2662 size_t 2663 ReadCStringFromMemory (lldb::addr_t vm_addr, 2664 std::string &out_str, 2665 Error &error); 2666 2667 size_t 2668 ReadMemoryFromInferior (lldb::addr_t vm_addr, 2669 void *buf, 2670 size_t size, 2671 Error &error); 2672 2673 //------------------------------------------------------------------ 2674 /// Reads an unsigned integer of the specified byte size from 2675 /// process memory. 2676 /// 2677 /// @param[in] load_addr 2678 /// A load address of the integer to read. 2679 /// 2680 /// @param[in] byte_size 2681 /// The size in byte of the integer to read. 2682 /// 2683 /// @param[in] fail_value 2684 /// The value to return if we fail to read an integer. 2685 /// 2686 /// @param[out] error 2687 /// An error that indicates the success or failure of this 2688 /// operation. If error indicates success (error.Success()), 2689 /// then the value returned can be trusted, otherwise zero 2690 /// will be returned. 2691 /// 2692 /// @return 2693 /// The unsigned integer that was read from the process memory 2694 /// space. If the integer was smaller than a uint64_t, any 2695 /// unused upper bytes will be zero filled. If the process 2696 /// byte order differs from the host byte order, the integer 2697 /// value will be appropriately byte swapped into host byte 2698 /// order. 2699 //------------------------------------------------------------------ 2700 uint64_t 2701 ReadUnsignedIntegerFromMemory (lldb::addr_t load_addr, 2702 size_t byte_size, 2703 uint64_t fail_value, 2704 Error &error); 2705 2706 lldb::addr_t 2707 ReadPointerFromMemory (lldb::addr_t vm_addr, 2708 Error &error); 2709 2710 bool 2711 WritePointerToMemory (lldb::addr_t vm_addr, 2712 lldb::addr_t ptr_value, 2713 Error &error); 2714 2715 //------------------------------------------------------------------ 2716 /// Actually do the writing of memory to a process. 2717 /// 2718 /// @param[in] vm_addr 2719 /// A virtual load address that indicates where to start writing 2720 /// memory to. 2721 /// 2722 /// @param[in] buf 2723 /// A byte buffer that is at least \a size bytes long that 2724 /// contains the data to write. 2725 /// 2726 /// @param[in] size 2727 /// The number of bytes to write. 2728 /// 2729 /// @param[out] error 2730 /// An error value in case the memory write fails. 2731 /// 2732 /// @return 2733 /// The number of bytes that were actually written. 2734 //------------------------------------------------------------------ 2735 virtual size_t 2736 DoWriteMemory (lldb::addr_t vm_addr, const void *buf, size_t size, Error &error) 2737 { 2738 error.SetErrorStringWithFormat("error: %s does not support writing to processes", GetShortPluginName()); 2739 return 0; 2740 } 2741 2742 2743 //------------------------------------------------------------------ 2744 /// Write all or part of a scalar value to memory. 2745 /// 2746 /// The value contained in \a scalar will be swapped to match the 2747 /// byte order of the process that is being debugged. If \a size is 2748 /// less than the size of scalar, the least significate \a size bytes 2749 /// from scalar will be written. If \a size is larger than the byte 2750 /// size of scalar, then the extra space will be padded with zeros 2751 /// and the scalar value will be placed in the least significant 2752 /// bytes in memory. 2753 /// 2754 /// @param[in] vm_addr 2755 /// A virtual load address that indicates where to start writing 2756 /// memory to. 2757 /// 2758 /// @param[in] scalar 2759 /// The scalar to write to the debugged process. 2760 /// 2761 /// @param[in] size 2762 /// This value can be smaller or larger than the scalar value 2763 /// itself. If \a size is smaller than the size of \a scalar, 2764 /// the least significant bytes in \a scalar will be used. If 2765 /// \a size is larger than the byte size of \a scalar, then 2766 /// the extra space will be padded with zeros. If \a size is 2767 /// set to UINT32_MAX, then the size of \a scalar will be used. 2768 /// 2769 /// @param[out] error 2770 /// An error value in case the memory write fails. 2771 /// 2772 /// @return 2773 /// The number of bytes that were actually written. 2774 //------------------------------------------------------------------ 2775 size_t 2776 WriteScalarToMemory (lldb::addr_t vm_addr, 2777 const Scalar &scalar, 2778 size_t size, 2779 Error &error); 2780 2781 size_t 2782 ReadScalarIntegerFromMemory (lldb::addr_t addr, 2783 uint32_t byte_size, 2784 bool is_signed, 2785 Scalar &scalar, 2786 Error &error); 2787 2788 //------------------------------------------------------------------ 2789 /// Write memory to a process. 2790 /// 2791 /// This function will write memory to the current process's 2792 /// address space and maintain any traps that might be present due 2793 /// to software breakpoints. 2794 /// 2795 /// This function is not meant to be overridden by Process 2796 /// subclasses, the subclasses should implement 2797 /// Process::DoWriteMemory (lldb::addr_t, size_t, void *). 2798 /// 2799 /// @param[in] vm_addr 2800 /// A virtual load address that indicates where to start writing 2801 /// memory to. 2802 /// 2803 /// @param[in] buf 2804 /// A byte buffer that is at least \a size bytes long that 2805 /// contains the data to write. 2806 /// 2807 /// @param[in] size 2808 /// The number of bytes to write. 2809 /// 2810 /// @return 2811 /// The number of bytes that were actually written. 2812 //------------------------------------------------------------------ 2813 size_t 2814 WriteMemory (lldb::addr_t vm_addr, const void *buf, size_t size, Error &error); 2815 2816 2817 //------------------------------------------------------------------ 2818 /// Actually allocate memory in the process. 2819 /// 2820 /// This function will allocate memory in the process's address 2821 /// space. This can't rely on the generic function calling mechanism, 2822 /// since that requires this function. 2823 /// 2824 /// @param[in] size 2825 /// The size of the allocation requested. 2826 /// 2827 /// @return 2828 /// The address of the allocated buffer in the process, or 2829 /// LLDB_INVALID_ADDRESS if the allocation failed. 2830 //------------------------------------------------------------------ 2831 2832 virtual lldb::addr_t 2833 DoAllocateMemory (size_t size, uint32_t permissions, Error &error) 2834 { 2835 error.SetErrorStringWithFormat("error: %s does not support allocating in the debug process", GetShortPluginName()); 2836 return LLDB_INVALID_ADDRESS; 2837 } 2838 2839 2840 //------------------------------------------------------------------ 2841 /// The public interface to allocating memory in the process. 2842 /// 2843 /// This function will allocate memory in the process's address 2844 /// space. This can't rely on the generic function calling mechanism, 2845 /// since that requires this function. 2846 /// 2847 /// @param[in] size 2848 /// The size of the allocation requested. 2849 /// 2850 /// @param[in] permissions 2851 /// Or together any of the lldb::Permissions bits. The permissions on 2852 /// a given memory allocation can't be changed after allocation. Note 2853 /// that a block that isn't set writable can still be written on from lldb, 2854 /// just not by the process itself. 2855 /// 2856 /// @param[in/out] error 2857 /// An error object to fill in if things go wrong. 2858 /// @return 2859 /// The address of the allocated buffer in the process, or 2860 /// LLDB_INVALID_ADDRESS if the allocation failed. 2861 //------------------------------------------------------------------ 2862 2863 lldb::addr_t 2864 AllocateMemory (size_t size, uint32_t permissions, Error &error); 2865 2866 virtual Error 2867 GetMemoryRegionInfo (lldb::addr_t load_addr, 2868 MemoryRegionInfo &range_info) 2869 { 2870 Error error; 2871 error.SetErrorString ("Process::GetMemoryRegionInfo() not supported"); 2872 return error; 2873 } 2874 2875 virtual Error 2876 GetWatchpointSupportInfo (uint32_t &num) 2877 { 2878 Error error; 2879 error.SetErrorString ("Process::GetWatchpointSupportInfo() not supported"); 2880 return error; 2881 } 2882 2883 virtual Error 2884 GetWatchpointSupportInfo (uint32_t &num, bool& after) 2885 { 2886 Error error; 2887 error.SetErrorString ("Process::GetWatchpointSupportInfo() not supported"); 2888 return error; 2889 } 2890 2891 lldb::ModuleSP 2892 ReadModuleFromMemory (const FileSpec& file_spec, 2893 lldb::addr_t header_addr, 2894 bool add_image_to_target, 2895 bool load_sections_in_target); 2896 2897 //------------------------------------------------------------------ 2898 /// Attempt to get the attributes for a region of memory in the process. 2899 /// 2900 /// It may be possible for the remote debug server to inspect attributes 2901 /// for a region of memory in the process, such as whether there is a 2902 /// valid page of memory at a given address or whether that page is 2903 /// readable/writable/executable by the process. 2904 /// 2905 /// @param[in] load_addr 2906 /// The address of interest in the process. 2907 /// 2908 /// @param[out] permissions 2909 /// If this call returns successfully, this bitmask will have 2910 /// its Permissions bits set to indicate whether the region is 2911 /// readable/writable/executable. If this call fails, the 2912 /// bitmask values are undefined. 2913 /// 2914 /// @return 2915 /// Returns true if it was able to determine the attributes of the 2916 /// memory region. False if not. 2917 //------------------------------------------------------------------ 2918 2919 virtual bool 2920 GetLoadAddressPermissions (lldb::addr_t load_addr, uint32_t &permissions) 2921 { 2922 MemoryRegionInfo range_info; 2923 permissions = 0; 2924 Error error (GetMemoryRegionInfo (load_addr, range_info)); 2925 if (!error.Success()) 2926 return false; 2927 if (range_info.GetReadable() == MemoryRegionInfo::eDontKnow 2928 || range_info.GetWritable() == MemoryRegionInfo::eDontKnow 2929 || range_info.GetExecutable() == MemoryRegionInfo::eDontKnow) 2930 { 2931 return false; 2932 } 2933 2934 if (range_info.GetReadable() == MemoryRegionInfo::eYes) 2935 permissions |= lldb::ePermissionsReadable; 2936 2937 if (range_info.GetWritable() == MemoryRegionInfo::eYes) 2938 permissions |= lldb::ePermissionsWritable; 2939 2940 if (range_info.GetExecutable() == MemoryRegionInfo::eYes) 2941 permissions |= lldb::ePermissionsExecutable; 2942 2943 return true; 2944 } 2945 2946 //------------------------------------------------------------------ 2947 /// Determines whether executing JIT-compiled code in this process 2948 /// is possible. 2949 /// 2950 /// @return 2951 /// True if execution of JIT code is possible; false otherwise. 2952 //------------------------------------------------------------------ 2953 bool CanJIT (); 2954 2955 //------------------------------------------------------------------ 2956 /// Sets whether executing JIT-compiled code in this process 2957 /// is possible. 2958 /// 2959 /// @param[in] can_jit 2960 /// True if execution of JIT code is possible; false otherwise. 2961 //------------------------------------------------------------------ 2962 void SetCanJIT (bool can_jit); 2963 2964 //------------------------------------------------------------------ 2965 /// Actually deallocate memory in the process. 2966 /// 2967 /// This function will deallocate memory in the process's address 2968 /// space that was allocated with AllocateMemory. 2969 /// 2970 /// @param[in] ptr 2971 /// A return value from AllocateMemory, pointing to the memory you 2972 /// want to deallocate. 2973 /// 2974 /// @return 2975 /// \btrue if the memory was deallocated, \bfalse otherwise. 2976 //------------------------------------------------------------------ 2977 2978 virtual Error 2979 DoDeallocateMemory (lldb::addr_t ptr) 2980 { 2981 Error error; 2982 error.SetErrorStringWithFormat("error: %s does not support deallocating in the debug process", GetShortPluginName()); 2983 return error; 2984 } 2985 2986 2987 //------------------------------------------------------------------ 2988 /// The public interface to deallocating memory in the process. 2989 /// 2990 /// This function will deallocate memory in the process's address 2991 /// space that was allocated with AllocateMemory. 2992 /// 2993 /// @param[in] ptr 2994 /// A return value from AllocateMemory, pointing to the memory you 2995 /// want to deallocate. 2996 /// 2997 /// @return 2998 /// \btrue if the memory was deallocated, \bfalse otherwise. 2999 //------------------------------------------------------------------ 3000 3001 Error 3002 DeallocateMemory (lldb::addr_t ptr); 3003 3004 //------------------------------------------------------------------ 3005 /// Get any available STDOUT. 3006 /// 3007 /// If the process was launched without supplying valid file paths 3008 /// for stdin, stdout, and stderr, then the Process class might 3009 /// try to cache the STDOUT for the process if it is able. Events 3010 /// will be queued indicating that there is STDOUT available that 3011 /// can be retrieved using this function. 3012 /// 3013 /// @param[out] buf 3014 /// A buffer that will receive any STDOUT bytes that are 3015 /// currently available. 3016 /// 3017 /// @param[out] buf_size 3018 /// The size in bytes for the buffer \a buf. 3019 /// 3020 /// @return 3021 /// The number of bytes written into \a buf. If this value is 3022 /// equal to \a buf_size, another call to this function should 3023 /// be made to retrieve more STDOUT data. 3024 //------------------------------------------------------------------ 3025 virtual size_t 3026 GetSTDOUT (char *buf, size_t buf_size, Error &error); 3027 3028 //------------------------------------------------------------------ 3029 /// Get any available STDERR. 3030 /// 3031 /// If the process was launched without supplying valid file paths 3032 /// for stdin, stdout, and stderr, then the Process class might 3033 /// try to cache the STDERR for the process if it is able. Events 3034 /// will be queued indicating that there is STDERR available that 3035 /// can be retrieved using this function. 3036 /// 3037 /// @param[out] buf 3038 /// A buffer that will receive any STDERR bytes that are 3039 /// currently available. 3040 /// 3041 /// @param[out] buf_size 3042 /// The size in bytes for the buffer \a buf. 3043 /// 3044 /// @return 3045 /// The number of bytes written into \a buf. If this value is 3046 /// equal to \a buf_size, another call to this function should 3047 /// be made to retrieve more STDERR data. 3048 //------------------------------------------------------------------ 3049 virtual size_t 3050 GetSTDERR (char *buf, size_t buf_size, Error &error); 3051 3052 virtual size_t 3053 PutSTDIN (const char *buf, size_t buf_size, Error &error) 3054 { 3055 error.SetErrorString("stdin unsupported"); 3056 return 0; 3057 } 3058 3059 //------------------------------------------------------------------ 3060 /// Get any available profile data. 3061 /// 3062 /// @param[out] buf 3063 /// A buffer that will receive any profile data bytes that are 3064 /// currently available. 3065 /// 3066 /// @param[out] buf_size 3067 /// The size in bytes for the buffer \a buf. 3068 /// 3069 /// @return 3070 /// The number of bytes written into \a buf. If this value is 3071 /// equal to \a buf_size, another call to this function should 3072 /// be made to retrieve more profile data. 3073 //------------------------------------------------------------------ 3074 virtual size_t 3075 GetAsyncProfileData (char *buf, size_t buf_size, Error &error); 3076 3077 //---------------------------------------------------------------------- 3078 // Process Breakpoints 3079 //---------------------------------------------------------------------- 3080 size_t 3081 GetSoftwareBreakpointTrapOpcode (BreakpointSite* bp_site); 3082 3083 virtual Error 3084 EnableBreakpoint (BreakpointSite *bp_site) 3085 { 3086 Error error; 3087 error.SetErrorStringWithFormat("error: %s does not support enabling breakpoints", GetShortPluginName()); 3088 return error; 3089 } 3090 3091 3092 virtual Error 3093 DisableBreakpoint (BreakpointSite *bp_site) 3094 { 3095 Error error; 3096 error.SetErrorStringWithFormat("error: %s does not support disabling breakpoints", GetShortPluginName()); 3097 return error; 3098 } 3099 3100 3101 // This is implemented completely using the lldb::Process API. Subclasses 3102 // don't need to implement this function unless the standard flow of 3103 // read existing opcode, write breakpoint opcode, verify breakpoint opcode 3104 // doesn't work for a specific process plug-in. 3105 virtual Error 3106 EnableSoftwareBreakpoint (BreakpointSite *bp_site); 3107 3108 // This is implemented completely using the lldb::Process API. Subclasses 3109 // don't need to implement this function unless the standard flow of 3110 // restoring original opcode in memory and verifying the restored opcode 3111 // doesn't work for a specific process plug-in. 3112 virtual Error 3113 DisableSoftwareBreakpoint (BreakpointSite *bp_site); 3114 3115 BreakpointSiteList & 3116 GetBreakpointSiteList(); 3117 3118 const BreakpointSiteList & 3119 GetBreakpointSiteList() const; 3120 3121 void 3122 DisableAllBreakpointSites (); 3123 3124 Error 3125 ClearBreakpointSiteByID (lldb::user_id_t break_id); 3126 3127 lldb::break_id_t 3128 CreateBreakpointSite (const lldb::BreakpointLocationSP &owner, 3129 bool use_hardware); 3130 3131 Error 3132 DisableBreakpointSiteByID (lldb::user_id_t break_id); 3133 3134 Error 3135 EnableBreakpointSiteByID (lldb::user_id_t break_id); 3136 3137 3138 // BreakpointLocations use RemoveOwnerFromBreakpointSite to remove 3139 // themselves from the owner's list of this breakpoint sites. This has to 3140 // be a static function because you can't be sure that removing the 3141 // breakpoint from it's containing map won't delete the breakpoint site, 3142 // and doing that in an instance method isn't copasetic. 3143 void 3144 RemoveOwnerFromBreakpointSite (lldb::user_id_t owner_id, 3145 lldb::user_id_t owner_loc_id, 3146 lldb::BreakpointSiteSP &bp_site_sp); 3147 3148 //---------------------------------------------------------------------- 3149 // Process Watchpoints (optional) 3150 //---------------------------------------------------------------------- 3151 virtual Error 3152 EnableWatchpoint (Watchpoint *wp, bool notify = true); 3153 3154 virtual Error 3155 DisableWatchpoint (Watchpoint *wp, bool notify = true); 3156 3157 //------------------------------------------------------------------ 3158 // Thread Queries 3159 //------------------------------------------------------------------ 3160 virtual bool 3161 UpdateThreadList (ThreadList &old_thread_list, ThreadList &new_thread_list) = 0; 3162 3163 void 3164 UpdateThreadListIfNeeded (); 3165 3166 ThreadList & 3167 GetThreadList () 3168 { 3169 return m_thread_list; 3170 } 3171 3172 // This is obsoleted and will be removed very soon. 3173 uint32_t 3174 GetNextThreadIndexID (); 3175 3176 uint32_t 3177 GetNextThreadIndexID (uint64_t thread_id); 3178 3179 lldb::ThreadSP 3180 CreateOSPluginThread (lldb::tid_t tid, lldb::addr_t context); 3181 3182 // Returns true if an index id has been assigned to a thread. 3183 bool 3184 HasAssignedIndexIDToThread(uint64_t sb_thread_id); 3185 3186 // Given a thread_id, it will assign a more reasonable index id for display to the user. 3187 // If the thread_id has previously been assigned, the same index id will be used. 3188 uint32_t 3189 AssignIndexIDToThread(uint64_t thread_id); 3190 3191 //------------------------------------------------------------------ 3192 // Event Handling 3193 //------------------------------------------------------------------ 3194 lldb::StateType 3195 GetNextEvent (lldb::EventSP &event_sp); 3196 3197 lldb::StateType 3198 WaitForProcessToStop (const TimeValue *timeout, lldb::EventSP *event_sp_ptr = NULL); 3199 3200 lldb::StateType 3201 WaitForStateChangedEvents (const TimeValue *timeout, lldb::EventSP &event_sp); 3202 3203 Event * 3204 PeekAtStateChangedEvents (); 3205 3206 3207 class 3208 ProcessEventHijacker 3209 { 3210 public: 3211 ProcessEventHijacker (Process &process, Listener *listener) : 3212 m_process (process) 3213 { 3214 m_process.HijackProcessEvents (listener); 3215 } 3216 ~ProcessEventHijacker () 3217 { 3218 m_process.RestoreProcessEvents(); 3219 } 3220 3221 private: 3222 Process &m_process; 3223 }; 3224 friend class ProcessEventHijacker; 3225 //------------------------------------------------------------------ 3226 /// If you need to ensure that you and only you will hear about some public 3227 /// event, then make a new listener, set to listen to process events, and 3228 /// then call this with that listener. Then you will have to wait on that 3229 /// listener explicitly for events (rather than using the GetNextEvent & WaitFor* 3230 /// calls above. Be sure to call RestoreProcessEvents when you are done. 3231 /// 3232 /// @param[in] listener 3233 /// This is the new listener to whom all process events will be delivered. 3234 /// 3235 /// @return 3236 /// Returns \b true if the new listener could be installed, 3237 /// \b false otherwise. 3238 //------------------------------------------------------------------ 3239 bool 3240 HijackProcessEvents (Listener *listener); 3241 3242 //------------------------------------------------------------------ 3243 /// Restores the process event broadcasting to its normal state. 3244 /// 3245 //------------------------------------------------------------------ 3246 void 3247 RestoreProcessEvents (); 3248 3249protected: 3250 //------------------------------------------------------------------ 3251 /// This is the part of the event handling that for a process event. 3252 /// It decides what to do with the event and returns true if the 3253 /// event needs to be propagated to the user, and false otherwise. 3254 /// If the event is not propagated, this call will most likely set 3255 /// the target to executing again. 3256 /// 3257 /// @param[in] event_ptr 3258 /// This is the event we are handling. 3259 /// 3260 /// @return 3261 /// Returns \b true if the event should be reported to the 3262 /// user, \b false otherwise. 3263 //------------------------------------------------------------------ 3264 bool 3265 ShouldBroadcastEvent (Event *event_ptr); 3266 3267public: 3268 const lldb::ABISP & 3269 GetABI (); 3270 3271 OperatingSystem * 3272 GetOperatingSystem () 3273 { 3274 return m_os_ap.get(); 3275 } 3276 3277 3278 virtual LanguageRuntime * 3279 GetLanguageRuntime (lldb::LanguageType language, bool retry_if_null = true); 3280 3281 virtual CPPLanguageRuntime * 3282 GetCPPLanguageRuntime (bool retry_if_null = true); 3283 3284 virtual ObjCLanguageRuntime * 3285 GetObjCLanguageRuntime (bool retry_if_null = true); 3286 3287 bool 3288 IsPossibleDynamicValue (ValueObject& in_value); 3289 3290 bool 3291 IsRunning () const; 3292 3293 DynamicCheckerFunctions *GetDynamicCheckers() 3294 { 3295 return m_dynamic_checkers_ap.get(); 3296 } 3297 3298 void SetDynamicCheckers(DynamicCheckerFunctions *dynamic_checkers) 3299 { 3300 m_dynamic_checkers_ap.reset(dynamic_checkers); 3301 } 3302 3303 //------------------------------------------------------------------ 3304 /// Call this to set the lldb in the mode where it breaks on new thread 3305 /// creations, and then auto-restarts. This is useful when you are trying 3306 /// to run only one thread, but either that thread or the kernel is creating 3307 /// new threads in the process. If you stop when the thread is created, you 3308 /// can immediately suspend it, and keep executing only the one thread you intend. 3309 /// 3310 /// @return 3311 /// Returns \b true if we were able to start up the notification 3312 /// \b false otherwise. 3313 //------------------------------------------------------------------ 3314 virtual bool 3315 StartNoticingNewThreads() 3316 { 3317 return true; 3318 } 3319 3320 //------------------------------------------------------------------ 3321 /// Call this to turn off the stop & notice new threads mode. 3322 /// 3323 /// @return 3324 /// Returns \b true if we were able to start up the notification 3325 /// \b false otherwise. 3326 //------------------------------------------------------------------ 3327 virtual bool 3328 StopNoticingNewThreads() 3329 { 3330 return true; 3331 } 3332 3333 void 3334 SetRunningUserExpression (bool on); 3335 3336 //------------------------------------------------------------------ 3337 // lldb::ExecutionContextScope pure virtual functions 3338 //------------------------------------------------------------------ 3339 virtual lldb::TargetSP 3340 CalculateTarget (); 3341 3342 virtual lldb::ProcessSP 3343 CalculateProcess () 3344 { 3345 return shared_from_this(); 3346 } 3347 3348 virtual lldb::ThreadSP 3349 CalculateThread () 3350 { 3351 return lldb::ThreadSP(); 3352 } 3353 3354 virtual lldb::StackFrameSP 3355 CalculateStackFrame () 3356 { 3357 return lldb::StackFrameSP(); 3358 } 3359 3360 virtual void 3361 CalculateExecutionContext (ExecutionContext &exe_ctx); 3362 3363 void 3364 SetSTDIOFileDescriptor (int file_descriptor); 3365 3366 //------------------------------------------------------------------ 3367 // Add a permanent region of memory that should never be read or 3368 // written to. This can be used to ensure that memory reads or writes 3369 // to certain areas of memory never end up being sent to the 3370 // DoReadMemory or DoWriteMemory functions which can improve 3371 // performance. 3372 //------------------------------------------------------------------ 3373 void 3374 AddInvalidMemoryRegion (const LoadRange ®ion); 3375 3376 //------------------------------------------------------------------ 3377 // Remove a permanent region of memory that should never be read or 3378 // written to that was previously added with AddInvalidMemoryRegion. 3379 //------------------------------------------------------------------ 3380 bool 3381 RemoveInvalidMemoryRange (const LoadRange ®ion); 3382 3383 //------------------------------------------------------------------ 3384 // If the setup code of a thread plan needs to do work that might involve 3385 // calling a function in the target, it should not do that work directly 3386 // in one of the thread plan functions (DidPush/WillResume) because 3387 // such work needs to be handled carefully. Instead, put that work in 3388 // a PreResumeAction callback, and register it with the process. It will 3389 // get done before the actual "DoResume" gets called. 3390 //------------------------------------------------------------------ 3391 3392 typedef bool (PreResumeActionCallback)(void *); 3393 3394 void 3395 AddPreResumeAction (PreResumeActionCallback callback, void *baton); 3396 3397 bool 3398 RunPreResumeActions (); 3399 3400 void 3401 ClearPreResumeActions (); 3402 3403 ReadWriteLock & 3404 GetRunLock () 3405 { 3406 return m_run_lock; 3407 } 3408 3409protected: 3410 //------------------------------------------------------------------ 3411 // NextEventAction provides a way to register an action on the next 3412 // event that is delivered to this process. There is currently only 3413 // one next event action allowed in the process at one time. If a 3414 // new "NextEventAction" is added while one is already present, the 3415 // old action will be discarded (with HandleBeingUnshipped called 3416 // after it is discarded.) 3417 //------------------------------------------------------------------ 3418 class NextEventAction 3419 { 3420 public: 3421 typedef enum EventActionResult 3422 { 3423 eEventActionSuccess, 3424 eEventActionRetry, 3425 eEventActionExit 3426 } EventActionResult; 3427 3428 NextEventAction (Process *process) : 3429 m_process(process) 3430 { 3431 } 3432 3433 virtual 3434 ~NextEventAction() 3435 { 3436 } 3437 3438 virtual EventActionResult PerformAction (lldb::EventSP &event_sp) = 0; 3439 virtual void HandleBeingUnshipped () {} 3440 virtual EventActionResult HandleBeingInterrupted () = 0; 3441 virtual const char *GetExitString() = 0; 3442 protected: 3443 Process *m_process; 3444 }; 3445 3446 void SetNextEventAction (Process::NextEventAction *next_event_action) 3447 { 3448 if (m_next_event_action_ap.get()) 3449 m_next_event_action_ap->HandleBeingUnshipped(); 3450 3451 m_next_event_action_ap.reset(next_event_action); 3452 } 3453 3454 // This is the completer for Attaching: 3455 class AttachCompletionHandler : public NextEventAction 3456 { 3457 public: 3458 AttachCompletionHandler (Process *process, uint32_t exec_count) : 3459 NextEventAction (process), 3460 m_exec_count (exec_count) 3461 { 3462 } 3463 3464 virtual 3465 ~AttachCompletionHandler() 3466 { 3467 } 3468 3469 virtual EventActionResult PerformAction (lldb::EventSP &event_sp); 3470 virtual EventActionResult HandleBeingInterrupted (); 3471 virtual const char *GetExitString(); 3472 private: 3473 uint32_t m_exec_count; 3474 std::string m_exit_string; 3475 }; 3476 3477 bool 3478 HijackPrivateProcessEvents (Listener *listener); 3479 3480 void 3481 RestorePrivateProcessEvents (); 3482 3483 bool 3484 PrivateStateThreadIsValid () const 3485 { 3486 return IS_VALID_LLDB_HOST_THREAD(m_private_state_thread); 3487 } 3488 3489 //------------------------------------------------------------------ 3490 // Type definitions 3491 //------------------------------------------------------------------ 3492 typedef std::map<lldb::LanguageType, lldb::LanguageRuntimeSP> LanguageRuntimeCollection; 3493 3494 struct PreResumeCallbackAndBaton 3495 { 3496 bool (*callback) (void *); 3497 void *baton; 3498 PreResumeCallbackAndBaton (PreResumeActionCallback in_callback, void *in_baton) : 3499 callback (in_callback), 3500 baton (in_baton) 3501 { 3502 } 3503 }; 3504 3505 //------------------------------------------------------------------ 3506 // Member variables 3507 //------------------------------------------------------------------ 3508 Target & m_target; ///< The target that owns this process. 3509 ThreadSafeValue<lldb::StateType> m_public_state; 3510 ThreadSafeValue<lldb::StateType> m_private_state; // The actual state of our process 3511 Broadcaster m_private_state_broadcaster; // This broadcaster feeds state changed events into the private state thread's listener. 3512 Broadcaster m_private_state_control_broadcaster; // This is the control broadcaster, used to pause, resume & stop the private state thread. 3513 Listener m_private_state_listener; // This is the listener for the private state thread. 3514 Predicate<bool> m_private_state_control_wait; /// This Predicate is used to signal that a control operation is complete. 3515 lldb::thread_t m_private_state_thread; // Thread ID for the thread that watches interal state events 3516 ProcessModID m_mod_id; ///< Tracks the state of the process over stops and other alterations. 3517 uint32_t m_process_unique_id; ///< Each lldb_private::Process class that is created gets a unique integer ID that increments with each new instance 3518 uint32_t m_thread_index_id; ///< Each thread is created with a 1 based index that won't get re-used. 3519 std::map<uint64_t, uint32_t> m_thread_id_to_index_id_map; 3520 int m_exit_status; ///< The exit status of the process, or -1 if not set. 3521 std::string m_exit_string; ///< A textual description of why a process exited. 3522 ThreadList m_thread_list; ///< The threads for this process. 3523 std::vector<Notifications> m_notifications; ///< The list of notifications that this process can deliver. 3524 std::vector<lldb::addr_t> m_image_tokens; 3525 Listener &m_listener; 3526 BreakpointSiteList m_breakpoint_site_list; ///< This is the list of breakpoint locations we intend to insert in the target. 3527 std::auto_ptr<DynamicLoader> m_dyld_ap; 3528 std::auto_ptr<DynamicCheckerFunctions> m_dynamic_checkers_ap; ///< The functions used by the expression parser to validate data that expressions use. 3529 std::auto_ptr<OperatingSystem> m_os_ap; 3530 UnixSignals m_unix_signals; /// This is the current signal set for this process. 3531 lldb::ABISP m_abi_sp; 3532 lldb::InputReaderSP m_process_input_reader; 3533 Communication m_stdio_communication; 3534 Mutex m_stdio_communication_mutex; 3535 std::string m_stdout_data; 3536 std::string m_stderr_data; 3537 Mutex m_profile_data_comm_mutex; 3538 std::vector<std::string> m_profile_data; 3539 MemoryCache m_memory_cache; 3540 AllocatedMemoryCache m_allocated_memory_cache; 3541 bool m_should_detach; /// Should we detach if the process object goes away with an explicit call to Kill or Detach? 3542 LanguageRuntimeCollection m_language_runtimes; 3543 std::auto_ptr<NextEventAction> m_next_event_action_ap; 3544 std::vector<PreResumeCallbackAndBaton> m_pre_resume_actions; 3545 ReadWriteLock m_run_lock; 3546 Predicate<bool> m_currently_handling_event; 3547 bool m_finalize_called; 3548 3549 enum { 3550 eCanJITDontKnow= 0, 3551 eCanJITYes, 3552 eCanJITNo 3553 } m_can_jit; 3554 3555 size_t 3556 RemoveBreakpointOpcodesFromBuffer (lldb::addr_t addr, size_t size, uint8_t *buf) const; 3557 3558 void 3559 SynchronouslyNotifyStateChanged (lldb::StateType state); 3560 3561 void 3562 SetPublicState (lldb::StateType new_state); 3563 3564 void 3565 SetPrivateState (lldb::StateType state); 3566 3567 bool 3568 StartPrivateStateThread (bool force = false); 3569 3570 void 3571 StopPrivateStateThread (); 3572 3573 void 3574 PausePrivateStateThread (); 3575 3576 void 3577 ResumePrivateStateThread (); 3578 3579 static void * 3580 PrivateStateThread (void *arg); 3581 3582 void * 3583 RunPrivateStateThread (); 3584 3585 void 3586 HandlePrivateEvent (lldb::EventSP &event_sp); 3587 3588 lldb::StateType 3589 WaitForProcessStopPrivate (const TimeValue *timeout, lldb::EventSP &event_sp); 3590 3591 // This waits for both the state change broadcaster, and the control broadcaster. 3592 // If control_only, it only waits for the control broadcaster. 3593 3594 bool 3595 WaitForEventsPrivate (const TimeValue *timeout, lldb::EventSP &event_sp, bool control_only); 3596 3597 lldb::StateType 3598 WaitForStateChangedEventsPrivate (const TimeValue *timeout, lldb::EventSP &event_sp); 3599 3600 lldb::StateType 3601 WaitForState (const TimeValue *timeout, 3602 const lldb::StateType *match_states, 3603 const uint32_t num_match_states); 3604 3605 size_t 3606 WriteMemoryPrivate (lldb::addr_t addr, const void *buf, size_t size, Error &error); 3607 3608 void 3609 AppendSTDOUT (const char *s, size_t len); 3610 3611 void 3612 AppendSTDERR (const char *s, size_t len); 3613 3614 void 3615 BroadcastAsyncProfileData(const char *s, size_t len); 3616 3617 static void 3618 STDIOReadThreadBytesReceived (void *baton, const void *src, size_t src_len); 3619 3620 void 3621 PushProcessInputReader (); 3622 3623 void 3624 PopProcessInputReader (); 3625 3626 void 3627 ResetProcessInputReader (); 3628 3629 static size_t 3630 ProcessInputReaderCallback (void *baton, 3631 InputReader &reader, 3632 lldb::InputReaderAction notification, 3633 const char *bytes, 3634 size_t bytes_len); 3635 3636 3637private: 3638 //------------------------------------------------------------------ 3639 // For Process only 3640 //------------------------------------------------------------------ 3641 void ControlPrivateStateThread (uint32_t signal); 3642 3643 DISALLOW_COPY_AND_ASSIGN (Process); 3644 3645}; 3646 3647} // namespace lldb_private 3648 3649#endif // liblldb_Process_h_ 3650