[Lldb-commits] [PATCH] D157662: [lldb][NFCI] Change parameter type in Process::SetExitStatus
Alex Langford via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Thu Aug 10 15:39:14 PDT 2023
bulbazord created this revision.
bulbazord added reviewers: JDevlieghere, mib, jingham, jasonmolenda.
Herald added a project: All.
bulbazord requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
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).
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D157662
Files:
lldb/include/lldb/Target/Process.h
lldb/source/Target/Process.cpp
Index: lldb/source/Target/Process.cpp
===================================================================
--- lldb/source/Target/Process.cpp
+++ 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<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();
Index: lldb/include/lldb/Target/Process.h
===================================================================
--- lldb/include/lldb/Target/Process.h
+++ 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.
///
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157662.549187.patch
Type: text/x-patch
Size: 2239 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230810/c34b9c5d/attachment.bin>
More information about the lldb-commits
mailing list