Skip to content

Commit 5a25f97

Browse files
committed
[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
1 parent 1ab42ba commit 5a25f97

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

lldb/include/lldb/Target/Process.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1439,8 +1439,13 @@ class Process : public std::enable_shared_from_this<Process>,
14391439
/// \param[in] exit_status
14401440
/// The value for the process's return code.
14411441
///
1442-
/// \see lldb::StateType
1443-
virtual bool SetExitStatus(int exit_status, const char *cstr);
1442+
/// \param[in] exit_string
1443+
/// A StringRef containing the reason for exiting. May be empty.
1444+
///
1445+
/// \return
1446+
/// Returns \b false if the process was already in an exited state, \b
1447+
/// true otherwise.
1448+
virtual bool SetExitStatus(int exit_status, llvm::StringRef exit_string);
14441449

14451450
/// Check if a process is still alive.
14461451
///

lldb/source/Target/Process.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,27 +1053,27 @@ const char *Process::GetExitDescription() {
10531053
return nullptr;
10541054
}
10551055

1056-
bool Process::SetExitStatus(int status, const char *cstr) {
1056+
bool Process::SetExitStatus(int status, llvm::StringRef exit_string) {
10571057
// Use a mutex to protect setting the exit status.
10581058
std::lock_guard<std::mutex> guard(m_exit_status_mutex);
10591059

10601060
Log *log(GetLog(LLDBLog::State | LLDBLog::Process));
1061-
LLDB_LOGF(log, "(plugin = %s status=%i (0x%8.8x), description=%s%s%s)",
1062-
GetPluginName().data(), status, status, cstr ? "\"" : "",
1063-
cstr ? cstr : "NULL", cstr ? "\"" : "");
1061+
LLDB_LOG(log, "(plugin = {0} status = {1} ({1:x8}), description=\"{2}\")",
1062+
GetPluginName(), status, exit_string);
10641063

10651064
// We were already in the exited state
10661065
if (m_private_state.GetValue() == eStateExited) {
1067-
LLDB_LOGF(log,
1068-
"(plugin = %s) ignoring exit status because state was already set "
1069-
"to eStateExited",
1070-
GetPluginName().data());
1066+
LLDB_LOG(
1067+
log,
1068+
"(plugin = {0}) ignoring exit status because state was already set "
1069+
"to eStateExited",
1070+
GetPluginName());
10711071
return false;
10721072
}
10731073

10741074
m_exit_status = status;
1075-
if (cstr)
1076-
m_exit_string = cstr;
1075+
if (!exit_string.empty())
1076+
m_exit_string = exit_string.str();
10771077
else
10781078
m_exit_string.clear();
10791079

0 commit comments

Comments
 (0)