diff options
Diffstat (limited to 'lldb/source/Plugins/Process/MacOSX-User')
6 files changed, 60 insertions, 3 deletions
diff --git a/lldb/source/Plugins/Process/MacOSX-User/source/MacOSX/MachException.cpp b/lldb/source/Plugins/Process/MacOSX-User/source/MacOSX/MachException.cpp index 483cca2fd65..1264398ef26 100644 --- a/lldb/source/Plugins/Process/MacOSX-User/source/MacOSX/MachException.cpp +++ b/lldb/source/Plugins/Process/MacOSX-User/source/MacOSX/MachException.cpp @@ -265,6 +265,7 @@ MachException::Message::Receive(mach_port_t port, mach_msg_option_t options, mac notify_port); // Dump any errors we get + log = ProcessMacOSXLog::GetLogIfAllCategoriesSet(PD_LOG_EXCEPTIONS); if (log && err.GetError() != MACH_RCV_TIMED_OUT) { log->Error("::mach_msg ( msg->{bits = %#x, size = %u remote_port = %#x, local_port = %#x, reserved = 0x%x, id = 0x%x}, option = %#x, send_size = %u, rcv_size = %u, rcv_name = %#x, timeout = %u, notify = %#x)", diff --git a/lldb/source/Plugins/Process/MacOSX-User/source/MacOSX/MachTask.cpp b/lldb/source/Plugins/Process/MacOSX-User/source/MacOSX/MachTask.cpp index a315fddcc72..4d6d3b1c792 100644 --- a/lldb/source/Plugins/Process/MacOSX-User/source/MacOSX/MachTask.cpp +++ b/lldb/source/Plugins/Process/MacOSX-User/source/MacOSX/MachTask.cpp @@ -547,6 +547,7 @@ MachTask::ExceptionThread (void *arg) if (err.GetError() == MACH_RCV_INTERRUPTED) { + log = ProcessMacOSXLog::GetLogIfAllCategoriesSet (PD_LOG_EXCEPTIONS); // If we have no task port we should exit this thread if (!mach_task->ExceptionPortIsValid()) { @@ -576,6 +577,8 @@ MachTask::ExceptionThread (void *arg) { if (num_exceptions_received > 0) { + log = ProcessMacOSXLog::GetLogIfAllCategoriesSet (PD_LOG_EXCEPTIONS); + // We were receiving all current exceptions with a timeout of zero // it is time to go back to our normal looping mode num_exceptions_received = 0; @@ -619,6 +622,7 @@ MachTask::ExceptionThread (void *arg) } else if (err.GetError() != KERN_SUCCESS) { + log = ProcessMacOSXLog::GetLogIfAllCategoriesSet (PD_LOG_EXCEPTIONS); if (log) log->Printf ("got some other error, do something about it??? nah, continuing for now..."); // TODO: notify of error? @@ -645,6 +649,7 @@ MachTask::ExceptionThread (void *arg) } #endif // #if defined (__arm__) + log = ProcessMacOSXLog::GetLogIfAllCategoriesSet (PD_LOG_EXCEPTIONS); if (log) log->Printf ("MachTask::%s (arg = %p) thread exiting...", __FUNCTION__, arg); return NULL; diff --git a/lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp b/lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp index 96bb7d44e87..3288fc80b0d 100644 --- a/lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp +++ b/lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp @@ -742,6 +742,7 @@ ProcessMacOSX::DoSIGSTOP (bool clear_all_breakpoints) if (!StateIsStoppedState (state)) { + log = ProcessMacOSXLog::GetLogIfAllCategoriesSet(PD_LOG_PROCESS); if (log) log->Printf("ProcessMacOSX::DoSIGSTOP() failed to stop after sending SIGSTOP"); return error; @@ -778,6 +779,7 @@ ProcessMacOSX::DoSIGSTOP (bool clear_all_breakpoints) else error.SetErrorToErrno(); + log = ProcessMacOSXLog::GetLogIfAllCategoriesSet(PD_LOG_PROCESS); if (log || error.Fail()) error.PutToLog(log, "ProcessMacOSX::DoSIGSTOP() ::kill (pid = %i, SIGSTOP)", pid); @@ -791,6 +793,7 @@ ProcessMacOSX::DoSIGSTOP (bool clear_all_breakpoints) // Make sure the process resumed if (StateIsStoppedState (state)) { + log = ProcessMacOSXLog::GetLogIfAllCategoriesSet(PD_LOG_PROCESS); if (log) log->Printf ("ProcessMacOSX::DoSIGSTOP() couldn't resume process, state = %s", StateAsCString(state)); error.SetErrorStringWithFormat("ProcessMacOSX::DoSIGSTOP() couldn't resume process, state = %s", StateAsCString(state)); @@ -803,6 +806,7 @@ ProcessMacOSX::DoSIGSTOP (bool clear_all_breakpoints) state = WaitForStateChangedEventsPrivate (&timeout_time, event_sp); if (!StateIsStoppedState (state)) { + log = ProcessMacOSXLog::GetLogIfAllCategoriesSet(PD_LOG_PROCESS); if (log) log->Printf("ProcessMacOSX::DoSIGSTOP() failed to stop after sending SIGSTOP"); error.SetErrorString("ProcessMacOSX::DoSIGSTOP() failed to stop after sending SIGSTOP"); @@ -1256,6 +1260,7 @@ ProcessMacOSX::STDIOThread(void *arg) int nfds = std::max<int>(stdout_fd, stderr_fd) + 1; int num_set_fds = select (nfds, &read_fds, NULL, NULL, NULL); + log = ProcessMacOSXLog::GetLogIfAllCategoriesSet (PD_LOG_PROCESS); if (log) log->Printf("select (nfds, &read_fds, NULL, NULL, NULL) => %d", num_set_fds); @@ -1343,6 +1348,7 @@ ProcessMacOSX::STDIOThread(void *arg) } } + log = ProcessMacOSXLog::GetLogIfAllCategoriesSet (PD_LOG_PROCESS); if (log) log->Printf("ProcessMacOSX::%s (%p): thread exiting...", __FUNCTION__, arg); @@ -1647,6 +1653,7 @@ ProcessMacOSX::LaunchForDebug else launch_err.SetErrorToErrno(); + log = ProcessMacOSXLog::GetLogIfAllCategoriesSet (PD_LOG_PROCESS); if (launch_err.Fail() || log) launch_err.PutToLog(log, "::ptrace (PT_ATTACHEXC, pid = %i, 0, 0 )", pid); diff --git a/lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSXLog.cpp b/lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSXLog.cpp index 1fcb9cce58c..b0211720871 100644 --- a/lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSXLog.cpp +++ b/lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSXLog.cpp @@ -35,7 +35,44 @@ ProcessMacOSXLog::GetLogIfAllCategoriesSet (uint32_t mask) } void -ProcessMacOSXLog::DisableLog () +ProcessMacOSXLog::DisableLog (Args &args, Stream *feedback_strm) +{ + if (g_log) + { + uint32_t flag_bits = g_log->GetMask().Get(); + const size_t argc = args.GetArgumentCount (); + for (size_t i = 0; i < argc; ++i) + { + const char *arg = args.GetArgumentAtIndex (i); + + if (::strcasecmp (arg, "all") == 0 ) flag_bits &= ~PD_LOG_ALL; + else if (::strcasestr (arg, "break") == arg ) flag_bits &= ~PD_LOG_BREAKPOINTS; + else if (::strcasecmp (arg, "default") == 0 ) flag_bits &= ~PD_LOG_DEFAULT; + else if (::strcasestr (arg, "exc") == arg ) flag_bits &= ~PD_LOG_EXCEPTIONS; + else if (::strcasecmp (arg, "memory") == 0 ) flag_bits &= ~PD_LOG_MEMORY; + else if (::strcasecmp (arg, "data-short") == 0 ) flag_bits &= ~PD_LOG_MEMORY_DATA_SHORT; + else if (::strcasecmp (arg, "data-long") == 0 ) flag_bits &= ~PD_LOG_MEMORY_DATA_LONG; + else if (::strcasecmp (arg, "protections")== 0 ) flag_bits &= ~PD_LOG_PROCESS; + else if (::strcasecmp (arg, "step") == 0 ) flag_bits &= ~PD_LOG_STEP; + else if (::strcasecmp (arg, "task") == 0 ) flag_bits &= ~PD_LOG_TASK; + else if (::strcasecmp (arg, "thread") == 0 ) flag_bits &= ~PD_LOG_THREAD; + else if (::strcasecmp (arg, "verbose") == 0 ) flag_bits &= ~PD_LOG_VERBOSE; + else if (::strcasestr (arg, "watch") == arg ) flag_bits &= ~PD_LOG_WATCHPOINTS; + else + { + feedback_strm->Printf("error: unrecognized log category '%s'\n", arg); + ListLogCategories (feedback_strm); + } + } + if (flag_bits == 0) + DeleteLog (); + else + g_log->GetMask().Reset (flag_bits); + } +} + +void +ProcessMacOSXLog::DeleteLog () { if (g_log) { @@ -47,7 +84,7 @@ ProcessMacOSXLog::DisableLog () Log * ProcessMacOSXLog::EnableLog (StreamSP &log_stream_sp, uint32_t log_options, Args &args, Stream *feedback_strm) { - DisableLog (); + DeleteLog (); g_log = new Log (log_stream_sp); if (g_log) { diff --git a/lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSXLog.h b/lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSXLog.h index cb2a4e8ee98..74e5278e870 100644 --- a/lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSXLog.h +++ b/lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSXLog.h @@ -47,7 +47,10 @@ public: GetLogIfAllCategoriesSet(uint32_t mask = 0); static void - DisableLog (); + DisableLog (lldb_private::Args &args, lldb_private::Stream *feedback_strm); + + static void + DeleteLog (); static lldb_private::Log * EnableLog (lldb::StreamSP &log_stream_sp, uint32_t log_options, lldb_private::Args &args, lldb_private::Stream *feedback_strm); diff --git a/lldb/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.cpp b/lldb/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.cpp index c400ef6eaee..07130f89134 100644 --- a/lldb/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.cpp +++ b/lldb/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.cpp @@ -257,6 +257,7 @@ ThreadMacOSX::Suspend() Error err(::thread_suspend (tid), eErrorTypeMachKernel); if (err.Success()) m_suspend_count++; + log = ProcessMacOSXLog::GetLogIfAllCategoriesSet(PD_LOG_THREAD); if (log || err.Fail()) err.PutToLog(log, "::thread_suspend (%4.4x)", tid); } @@ -277,6 +278,7 @@ ThreadMacOSX::Resume() Error err(::thread_resume (tid), eErrorTypeMachKernel); if (err.Success()) m_suspend_count--; + log = ProcessMacOSXLog::GetLogIfAllCategoriesSet(PD_LOG_THREAD); if (log || err.Fail()) err.PutToLog(log, "::thread_resume (%4.4x)", tid); } @@ -301,6 +303,7 @@ ThreadMacOSX::RestoreSuspendCount() err = ::thread_resume (tid); if (err.Success()) --m_suspend_count; + log = ProcessMacOSXLog::GetLogIfAllCategoriesSet(PD_LOG_THREAD); if (log || err.Fail()) err.PutToLog(log, "::thread_resume (%4.4x)", tid); } @@ -312,6 +315,7 @@ ThreadMacOSX::RestoreSuspendCount() err = ::thread_suspend (tid); if (err.Success()) --m_suspend_count; + log = ProcessMacOSXLog::GetLogIfAllCategoriesSet(PD_LOG_THREAD); if (log || err.Fail()) err.PutToLog(log, "::thread_suspend (%4.4x)", tid); } |