[Lldb-commits] [lldb] 5a25f97 - [lldb][NFCI] Change parameter type in Process::SetExitStatus
Alex Langford via lldb-commits
lldb-commits at lists.llvm.org
Mon Aug 14 15:52:22 PDT 2023
Author: Alex Langford
Date: 2023-08-14T15:49:03-07:00
New Revision: 5a25f97e69500d4f65ce0e56027787752c7aab61
URL: https://github.com/llvm/llvm-project/commit/5a25f97e69500d4f65ce0e56027787752c7aab61
DIFF: https://github.com/llvm/llvm-project/commit/5a25f97e69500d4f65ce0e56027787752c7aab61.diff
LOG: [lldb][NFCI] Change parameter type in Process::SetExitStatus
My primary motivation here is actually to change something in
UnixSignals, but this change is a necesary precondition.
I've also updated the documentation and rewritten the log statements to
use `formatv` instead of `printf` (printf-style formatting and
llvm::StringRef don't mix well).
Differential Revision: https://reviews.llvm.org/D157662
Added:
Modified:
lldb/include/lldb/Target/Process.h
lldb/source/Target/Process.cpp
Removed:
################################################################################
diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h
index affd3fbc37b07a..6ea6f82548aaf8 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -1439,8 +1439,13 @@ class Process : public std::enable_shared_from_this<Process>,
/// \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
index 447d03b1cb288e..ea08ddb6bfedaa 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -1053,27 +1053,27 @@ const char *Process::GetExitDescription() {
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<std::mutex> 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();
More information about the lldb-commits
mailing list