Lines Matching defs:MachProcess
1 //===-- MachProcess.cpp -----------------------------------------*- C++ -*-===//
35 #include "MachProcess.h"
73 MachProcess::MachProcess() :
110 MachProcess::~MachProcess()
117 MachProcess::SetProcessID(pid_t pid)
130 MachProcess::GetState()
138 MachProcess::ThreadGetName(nub_thread_t tid)
144 MachProcess::ThreadGetState(nub_thread_t tid)
151 MachProcess::GetNumThreads () const
157 MachProcess::GetThreadAtIndex (nub_size_t thread_idx) const
163 MachProcess::GetThreadIDForMachPortNumber (thread_t mach_port_number) const
169 MachProcess::SyncThreadState (nub_thread_t tid)
185 MachProcess::GetCurrentThread ()
191 MachProcess::GetCurrentThreadMachPort ()
197 MachProcess::SetCurrentThread(nub_thread_t tid)
203 MachProcess::GetThreadStoppedReason(nub_thread_t tid, struct DNBThreadStopInfo *stop_info)
215 MachProcess::DumpThreadStoppedReason(nub_thread_t tid) const
221 MachProcess::GetThreadInfo(nub_thread_t tid) const
227 MachProcess::GetCPUType ()
230 m_cpu_type = MachProcess::GetCPUTypeForLocalProcess (m_pid);
235 MachProcess::GetRegisterSetInfo (nub_thread_t tid, nub_size_t *num_reg_sets) const
249 MachProcess::GetRegisterValue ( nub_thread_t tid, uint32_t set, uint32_t reg, DNBRegisterValue *value ) const
255 MachProcess::SetRegisterValue ( nub_thread_t tid, uint32_t set, uint32_t reg, const DNBRegisterValue *value ) const
261 MachProcess::SetState(nub_state_t new_state)
273 DNBLogThreadedIf(LOG_PROCESS, "MachProcess::SetState(%s) ignoring new state since current state is exited", DNBStateAsString(new_state));
277 DNBLogThreadedIf(LOG_PROCESS, "MachProcess::SetState(%s) ignoring redundant state change...", DNBStateAsString(new_state));
286 DNBLogThreadedIf(LOG_PROCESS, "MachProcess::SetState(%s) upating state (previous state was %s), event_mask = 0x%8.8x", DNBStateAsString(new_state), DNBStateAsString(old_state), event_mask);
310 MachProcess::Clear()
337 MachProcess::StartSTDIOThread()
339 DNBLogThreadedIf(LOG_PROCESS, "MachProcess::%s ( )", __FUNCTION__);
341 return ::pthread_create (&m_stdio_thread, NULL, MachProcess::STDIOThread, this) == 0;
345 MachProcess::SetEnableAsyncProfiling(bool enable, uint64_t interval_usec, DNBProfileDataScanType scan_type)
363 MachProcess::StartProfileThread()
365 DNBLogThreadedIf(LOG_PROCESS, "MachProcess::%s ( )", __FUNCTION__);
367 return ::pthread_create (&m_profile_thread, NULL, MachProcess::ProfileThread, this) == 0;
372 MachProcess::LookupSymbol(const char *name, const char *shlib)
380 MachProcess::Resume (const DNBThreadResumeActions& thread_actions)
382 DNBLogThreadedIf(LOG_PROCESS, "MachProcess::Resume ()");
401 MachProcess::Kill (const struct timespec *timeout_abstime)
403 DNBLogThreadedIf(LOG_PROCESS, "MachProcess::Kill ()");
405 DNBLogThreadedIf(LOG_PROCESS, "MachProcess::Kill() DoSIGSTOP() state = %s", DNBStateAsString(state));
411 DNBLogThreadedIf(LOG_PROCESS, "MachProcess::Kill() DoSIGSTOP() ::ptrace (PT_KILL, pid=%u, 0, 0) => 0x%8.8x (%s)", m_pid, err.Error(), err.AsString());
433 MachProcess::Signal (int signal, const struct timespec *timeout_abstime)
435 DNBLogThreadedIf(LOG_PROCESS, "MachProcess::Signal (signal = %d, timeout = %p)", signal, timeout_abstime);
442 DNBLogThreadedIf(LOG_PROCESS, "MachProcess::Signal (signal = %d, timeout = %p) waiting for signal to stop process...", signal, timeout_abstime);
445 DNBLogThreadedIf(LOG_PROCESS, "MachProcess::Signal (signal = %d, timeout = %p) state = %s", signal, timeout_abstime, DNBStateAsString(state));
448 DNBLogThreadedIf(LOG_PROCESS, "MachProcess::Signal (signal = %d, timeout = %p) not waiting...", signal, timeout_abstime);
458 MachProcess::DoSIGSTOP (bool clear_bps_and_wps, bool allow_running, uint32_t *thread_idx_ptr)
461 DNBLogThreadedIf(LOG_PROCESS, "MachProcess::DoSIGSTOP() state = %s", DNBStateAsString (state));
482 DNBLogThreadedIf(LOG_PROCESS, "MachProcess::DoSIGSTOP() state = %s -- resuming process", DNBStateAsString (state));
498 DNBLogThreadedIf(LOG_PROCESS, "MachProcess::DoSIGSTOP() state = %s -- sending SIGSTOP", DNBStateAsString (state));
515 MachProcess::Detach()
517 DNBLogThreadedIf(LOG_PROCESS, "MachProcess::Detach()");
521 DNBLogThreadedIf(LOG_PROCESS, "MachProcess::Detach() DoSIGSTOP() returned %s", DNBStateAsString(state));
565 // ReadMemory from the MachProcess level will always remove any software
572 MachProcess::ReadMemory (nub_addr_t addr, nub_size_t size, void *buf)
588 // WriteMemory from the MachProcess level will always write memory around
597 MachProcess::WriteMemory (nub_addr_t addr, nub_size_t size, const void *buf)
657 MachProcess::ReplyToAllExceptions ()
695 MachProcess::PrivateResume ()
718 MachProcess::CreateBreakpoint(nub_addr_t addr, nub_size_t length, bool hardware)
720 DNBLogThreadedIf(LOG_BREAKPOINTS, "MachProcess::CreateBreakpoint ( addr = 0x%8.8llx, length = %llu, hardware = %i)", (uint64_t)addr, (uint64_t)length, hardware);
730 DNBLogThreadedIf(LOG_BREAKPOINTS, "MachProcess::CreateBreakpoint ( addr = 0x%8.8llx, length = %llu) => %p", (uint64_t)addr, (uint64_t)length, bp);
742 MachProcess::CreateWatchpoint(nub_addr_t addr, nub_size_t length, uint32_t watch_flags, bool hardware)
744 DNBLogThreadedIf(LOG_WATCHPOINTS, "MachProcess::CreateWatchpoint ( addr = 0x%8.8llx, length = %llu, flags = 0x%8.8x, hardware = %i)", (uint64_t)addr, (uint64_t)length, watch_flags, hardware);
757 DNBLogThreadedIf(LOG_WATCHPOINTS, "MachProcess::CreateWatchpoint ( addr = 0x%8.8llx, length = %llu) => %p", (uint64_t)addr, (uint64_t)length, wp);
762 DNBLogThreadedIf(LOG_WATCHPOINTS, "MachProcess::CreateWatchpoint ( addr = 0x%8.8llx, length = %llu) => FAILED", (uint64_t)addr, (uint64_t)length);
770 MachProcess::DisableAllBreakpoints (bool remove)
772 DNBLogThreadedIf(LOG_BREAKPOINTS, "MachProcess::%s (remove = %d )", __FUNCTION__, remove);
781 MachProcess::DisableAllWatchpoints(bool remove)
783 DNBLogThreadedIf(LOG_WATCHPOINTS, "MachProcess::%s (remove = %d )", __FUNCTION__, remove);
792 MachProcess::DisableBreakpoint(nub_addr_t addr, bool remove)
815 DNBLogThreadedIf(LOG_BREAKPOINTS | LOG_VERBOSE, "MachProcess::DisableBreakpoint ( addr = 0x%8.8llx, remove = %d )", (uint64_t)addr, remove);
830 DNBLogThreadedIf(LOG_BREAKPOINTS, "MachProcess::DisableBreakpoint ( addr = 0x%8.8llx, remove = %d ) (hardware) => success", (uint64_t)addr, remove);
864 DNBLogError("MachProcess::DisableBreakpoint ( addr = 0x%8.8llx, remove = %d ) memory write failed when restoring original opcode", addr, remove);
869 DNBLogWarning("MachProcess::DisableBreakpoint ( addr = 0x%8.8llx, remove = %d ) expected a breakpoint opcode but didn't find one.", addr, remove);
876 DNBLogThreadedIf(LOG_BREAKPOINTS | LOG_VERBOSE, "MachProcess::DisableBreakpoint ( addr = 0x%8.8llx, remove = %d ) is not enabled", addr, remove);
898 DNBLogThreadedIf(LOG_BREAKPOINTS, "MachProcess::DisableBreakpoint ( addr = 0x%8.8llx, remove = %d ) => success", (uint64_t)addr, remove);
904 DNBLogError("MachProcess::DisableBreakpoint ( addr = 0x%8.8llx, remove = %d ) : failed to restore original opcode", (uint64_t)addr, remove);
906 DNBLogError("MachProcess::DisableBreakpoint ( addr = 0x%8.8llx, remove = %d ) : opcode changed", (uint64_t)addr, remove);
911 DNBLogWarning("MachProcess::DisableBreakpoint: unable to disable breakpoint 0x%8.8llx", (uint64_t)addr);
917 DNBLogWarning("MachProcess::DisableBreakpoint: unable to read memory at 0x%8.8llx", (uint64_t)addr);
923 DNBLogError("MachProcess::DisableBreakpoint ( addr = 0x%8.8llx, remove = %d ) invalid breakpoint address", (uint64_t)addr, remove);
929 MachProcess::DisableWatchpoint(nub_addr_t addr, bool remove)
931 DNBLogThreadedIf(LOG_WATCHPOINTS, "MachProcess::%s(addr = 0x%8.8llx, remove = %d)", __FUNCTION__, (uint64_t)addr, remove);
940 DNBLogThreadedIf(LOG_WATCHPOINTS, "MachProcess::DisableWatchpoint ( addr = 0x%8.8llx, remove = %d )", (uint64_t)addr, remove);
951 DNBLogThreadedIf(LOG_WATCHPOINTS, "MachProcess
960 DNBLogError("MachProcess::DisableWatchpoint ( addr = 0x%8.8llx, remove = %d ) invalid watchpoint ID", (uint64_t)addr, remove);
967 MachProcess::GetNumSupportedHardwareWatchpoints () const
973 MachProcess::EnableBreakpoint(nub_addr_t addr)
975 DNBLogThreadedIf(LOG_BREAKPOINTS, "MachProcess::EnableBreakpoint ( addr = 0x%8.8llx )", (uint64_t)addr);
981 DNBLogWarning("MachProcess::EnableBreakpoint ( addr = 0x%8.8llx ): breakpoint already enabled.", (uint64_t)addr);
1015 DNBLogThreadedIf(LOG_BREAKPOINTS, "MachProcess::EnableBreakpoint ( addr = 0x%8.8llx ) : SUCCESS.", (uint64_t)addr);
1020 DNBLogError("MachProcess::EnableBreakpoint ( addr = 0x%8.8llx ): breakpoint opcode verification failed.", (uint64_t)addr);
1025 DNBLogError("MachProcess::EnableBreakpoint ( addr = 0x%8.8llx ): unable to read memory to verify breakpoint opcode.", (uint64_t)addr);
1030 DNBLogError("MachProcess::EnableBreakpoint ( addr = 0x%8.8llx ): unable to write breakpoint opcode to memory.", (uint64_t)addr);
1035 DNBLogError("MachProcess::EnableBreakpoint ( addr = 0x%8.8llx ): unable to read memory at breakpoint address.", (uint64_t)addr);
1040 DNBLogError("MachProcess::EnableBreakpoint ( addr = 0x%8.8llx ) no software breakpoint opcode for current architecture.", (uint64_t)addr);
1048 MachProcess::EnableWatchpoint(nub_addr_t addr)
1050 DNBLogThreadedIf(LOG_WATCHPOINTS, "MachProcess::EnableWatchpoint(addr = 0x%8.8llx)", (uint64_t)addr);
1057 DNBLogWarning("MachProcess::EnableWatchpoint(addr = 0x%8.8llx): watchpoint already enabled.", (uint64_t)addr);
1079 MachProcess::ExceptionMessageReceived (const MachException::Message& exceptionMessage)
1086 DNBLogThreadedIf(LOG_EXCEPTIONS, "MachProcess::ExceptionMessageReceived ( )");
1094 MachProcess::ExceptionMessageBundleComplete()
1140 cpu_type_t process_cpu_type = MachProcess::GetCPUTypeForLocalProcess (m_pid);
1159 // Let the thread list figure use the MachProcess to forward all exceptions
1195 MachProcess::CopyImageInfos ( struct DNBExecutableImageInfo **image_infos, bool only_changed)
1203 MachProcess::SharedLibrariesUpdated ( )
1214 MachProcess::AppendSTDOUT (char* s, size_t len)
1216 DNBLogThreadedIf(LOG_PROCESS, "MachProcess::%s (<%llu> %s) ...", __FUNCTION__, (uint64_t)len, s);
1226 MachProcess::GetAvailableSTDOUT (char *buf, size_t buf_size)
1228 DNBLogThreadedIf(LOG_PROCESS, "MachProcess::%s (&%p[%llu]) ...", __FUNCTION__, buf, (uint64_t)buf_size);
1249 MachProcess::GetDYLDAllImageInfosAddress ()
1256 MachProcess::GetAvailableSTDERR (char *buf, size_t buf_size)
1262 MachProcess::STDIOThread(void *arg)
1264 MachProcess *proc = (MachProcess*) arg;
1265 DNBLogThreadedIf(LOG_PROCESS, "MachProcess::%s ( arg = %p ) thread starting...", __FUNCTION__, arg);
1382 DNBLogThreadedIf(LOG_PROCESS, "MachProcess::%s (%p): thread exiting...", __FUNCTION__, arg);
1388 MachProcess::SignalAsyncProfileData (const char *info)
1390 DNBLogThreadedIf(LOG_PROCESS, "MachProcess::%s (%s) ...", __FUNCTION__, info);
1401 MachProcess::GetAsyncProfileData (char *buf, size_t buf_size)
1403 DNBLogThreadedIf(LOG_PROCESS, "MachProcess::%s (&%p[%llu]) ...", __FUNCTION__, buf, (uint64_t)buf_size);
1428 MachProcess::ProfileThread(void *arg)
1430 MachProcess *proc = (MachProcess*) arg;
1431 DNBLogThreadedIf(LOG_PROCESS, "MachProcess::%s ( arg = %p ) thread starting...", __FUNCTION__, arg);
1458 MachProcess::AttachForDebug (pid_t pid, char *err_str, size_t err_len)
1524 MachProcess::PrepareForAttach (const char *path, nub_launch_flavor_t launch_flavor, bool waitfor, DNBError &err_str)
1536 DNBLogThreadedIf(LOG_PROCESS, "MachProcess::PrepareForAttach(): path '%s' doesn't contain .app, we can't tell springboard to wait for launch...", path);
1589 MachProcess::CheckForProcess (const void *attach_token)
1613 MachProcess::CleanupAfterAttach (const void *attach_token, bool success, DNBError &err_str)
1646 MachProcess::LaunchForDebug
1672 m_pid = MachProcess::ForkChildForPTraceDebugging (path, argv, envp, this, launch_err);
1710 m_pid = MachProcess::PosixSpawnChildForPTraceDebugging (path,
1787 MachProcess::PosixSpawnChildForPTraceDebugging
1798 MachProcess* process,
1954 cpu_type_t pid_cpu_type = MachProcess::GetCPUTypeForLocalProcess (pid);
1955 DNBLogThreadedIf(LOG_PROCESS, "MachProcess::%s ( ) pid=%i, cpu_type=0x%8.8x", __FUNCTION__, pid, pid_cpu_type);
1972 MachProcess::GetCPUTypeForLocalProcess (pid_t pid)
1990 MachProcess::ForkChildForPTraceDebugging
1995 MachProcess* process,
2002 // terminal so we can read it in our MachProcess::STDIOThread
2067 MachProcess::SBLaunchForDebug (const char *path, char const *argv[], char const *envp[], bool no_stdio, DNBError &launch_err)
2076 m_pid = MachProcess::SBForkChildForPTraceDebugging(path, argv, envp, no_stdio, this, launch_err);
2153 MachProcess::SBForkChildForPTraceDebugging (const char *app_bundle_path, char const *argv[], char const *envp[], bool no_stdio, MachProcess* process, DNBError &launch_err)