diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h --- a/lldb/include/lldb/Target/Process.h +++ b/lldb/include/lldb/Target/Process.h @@ -1439,8 +1439,13 @@ /// \param[in] exit_status /// The value for the process's return code. /// - /// \see lldb::StateType - virtual bool SetExitStatus(int exit_status, const char *cstr); + /// \param[in] exit_string + /// A StringRef containing the reason for exiting. May be empty. + /// + /// \return + /// Returns \b false if the process was already in an exited state, \b + /// true otherwise. + virtual bool SetExitStatus(int exit_status, llvm::StringRef exit_string); /// Check if a process is still alive. /// diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -1053,27 +1053,27 @@ return nullptr; } -bool Process::SetExitStatus(int status, const char *cstr) { +bool Process::SetExitStatus(int status, llvm::StringRef exit_string) { // Use a mutex to protect setting the exit status. std::lock_guard guard(m_exit_status_mutex); Log *log(GetLog(LLDBLog::State | LLDBLog::Process)); - LLDB_LOGF(log, "(plugin = %s status=%i (0x%8.8x), description=%s%s%s)", - GetPluginName().data(), status, status, cstr ? "\"" : "", - cstr ? cstr : "NULL", cstr ? "\"" : ""); + LLDB_LOG(log, "(plugin = {0} status = {1} ({1:x8}), description=\"{2}\")", + GetPluginName(), status, exit_string); // We were already in the exited state if (m_private_state.GetValue() == eStateExited) { - LLDB_LOGF(log, - "(plugin = %s) ignoring exit status because state was already set " - "to eStateExited", - GetPluginName().data()); + LLDB_LOG( + log, + "(plugin = {0}) ignoring exit status because state was already set " + "to eStateExited", + GetPluginName()); return false; } m_exit_status = status; - if (cstr) - m_exit_string = cstr; + if (!exit_string.empty()) + m_exit_string = exit_string.str(); else m_exit_string.clear();