aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectThread.cpp
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2024-08-27 10:59:31 -0700
committerGitHub <noreply@github.com>2024-08-27 10:59:31 -0700
commit0642cd768b80665585c8500bed2933a3b99123dc (patch)
treea412a5eafff54ef9a7cb884e01907a4f521f5140 /lldb/source/Commands/CommandObjectThread.cpp
parentacb33a0c9bc902dc1aef703c02b8fd3a1132cb14 (diff)
downloadllvm-0642cd768b80665585c8500bed2933a3b99123dc.zip
llvm-0642cd768b80665585c8500bed2933a3b99123dc.tar.gz
llvm-0642cd768b80665585c8500bed2933a3b99123dc.tar.bz2
[lldb] Turn lldb_private::Status into a value type. (#106163)
This patch removes all of the Set.* methods from Status. This cleanup is part of a series of patches that make it harder use the anti-pattern of keeping a long-lives Status object around and updating it while dropping any errors it contains on the floor. This patch is largely NFC, the more interesting next steps this enables is to: 1. remove Status.Clear() 2. assert that Status::operator=() never overwrites an error 3. remove Status::operator=() Note that step (2) will bring 90% of the benefits for users, and step (3) will dramatically clean up the error handling code in various places. In the end my goal is to convert all APIs that are of the form ` ResultTy DoFoo(Status& error) ` to ` llvm::Expected<ResultTy> DoFoo() ` How to read this patch? The interesting changes are in Status.h and Status.cpp, all other changes are mostly ` perl -pi -e 's/\.SetErrorString/ = Status::FromErrorString/g' $(git grep -l SetErrorString lldb/source) ` plus the occasional manual cleanup.
Diffstat (limited to 'lldb/source/Commands/CommandObjectThread.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectThread.cpp46
1 files changed, 25 insertions, 21 deletions
diff --git a/lldb/source/Commands/CommandObjectThread.cpp b/lldb/source/Commands/CommandObjectThread.cpp
index 6a89c16..edbec0e 100644
--- a/lldb/source/Commands/CommandObjectThread.cpp
+++ b/lldb/source/Commands/CommandObjectThread.cpp
@@ -66,7 +66,7 @@ public:
case 'c':
if (option_arg.getAsInteger(0, m_count)) {
m_count = UINT32_MAX;
- error.SetErrorStringWithFormat(
+ error = Status::FromErrorStringWithFormat(
"invalid integer value for option '%c': %s", short_option,
option_arg.data());
}
@@ -76,7 +76,7 @@ public:
break;
case 's':
if (option_arg.getAsInteger(0, m_start))
- error.SetErrorStringWithFormat(
+ error = Status::FromErrorStringWithFormat(
"invalid integer value for option '%c': %s", short_option,
option_arg.data());
break;
@@ -85,7 +85,7 @@ public:
m_extended_backtrace =
OptionArgParser::ToBoolean(option_arg, false, &success);
if (!success)
- error.SetErrorStringWithFormat(
+ error = Status::FromErrorStringWithFormat(
"invalid boolean value for option '%c': %s", short_option,
option_arg.data());
} break;
@@ -286,7 +286,7 @@ public:
bool avoid_no_debug =
OptionArgParser::ToBoolean(option_arg, true, &success);
if (!success)
- error.SetErrorStringWithFormat(
+ error = Status::FromErrorStringWithFormat(
"invalid boolean value for option '%c': %s", short_option,
option_arg.data());
else {
@@ -299,7 +299,7 @@ public:
bool avoid_no_debug =
OptionArgParser::ToBoolean(option_arg, true, &success);
if (!success)
- error.SetErrorStringWithFormat(
+ error = Status::FromErrorStringWithFormat(
"invalid boolean value for option '%c': %s", short_option,
option_arg.data());
else {
@@ -309,7 +309,7 @@ public:
case 'c':
if (option_arg.getAsInteger(0, m_step_count))
- error.SetErrorStringWithFormat(
+ error = Status::FromErrorStringWithFormat(
"invalid integer value for option '%c': %s", short_option,
option_arg.data());
break;
@@ -326,8 +326,8 @@ public:
break;
}
if (option_arg.getAsInteger(0, m_end_line))
- error.SetErrorStringWithFormat("invalid end line number '%s'",
- option_arg.str().c_str());
+ error = Status::FromErrorStringWithFormat(
+ "invalid end line number '%s'", option_arg.str().c_str());
break;
case 'r':
@@ -817,15 +817,15 @@ public:
case 't':
if (option_arg.getAsInteger(0, m_thread_idx)) {
m_thread_idx = LLDB_INVALID_INDEX32;
- error.SetErrorStringWithFormat("invalid thread index '%s'",
- option_arg.str().c_str());
+ error = Status::FromErrorStringWithFormat("invalid thread index '%s'",
+ option_arg.str().c_str());
}
break;
case 'f':
if (option_arg.getAsInteger(0, m_frame_idx)) {
m_frame_idx = LLDB_INVALID_FRAME_ID;
- error.SetErrorStringWithFormat("invalid frame index '%s'",
- option_arg.str().c_str());
+ error = Status::FromErrorStringWithFormat("invalid frame index '%s'",
+ option_arg.str().c_str());
}
break;
case 'm': {
@@ -1118,7 +1118,8 @@ public:
case 't': {
if (option_arg.getAsInteger(0, m_thread_id)) {
m_thread_id = LLDB_INVALID_THREAD_ID;
- return Status("Invalid thread ID: '%s'.", option_arg.str().c_str());
+ return Status::FromErrorStringWithFormat("Invalid thread ID: '%s'.",
+ option_arg.str().c_str());
}
break;
}
@@ -1489,7 +1490,7 @@ public:
if (success)
m_from_expression = tmp_value;
else {
- error.SetErrorStringWithFormat(
+ error = Status::FromErrorStringWithFormat(
"invalid boolean value '%s' for 'x' option",
option_arg.str().c_str());
}
@@ -1641,15 +1642,17 @@ public:
case 'f':
m_filenames.AppendIfUnique(FileSpec(option_arg));
if (m_filenames.GetSize() > 1)
- return Status("only one source file expected.");
+ return Status::FromErrorString("only one source file expected.");
break;
case 'l':
if (option_arg.getAsInteger(0, m_line_num))
- return Status("invalid line number: '%s'.", option_arg.str().c_str());
+ return Status::FromErrorStringWithFormat("invalid line number: '%s'.",
+ option_arg.str().c_str());
break;
case 'b':
if (option_arg.getAsInteger(0, m_line_offset))
- return Status("invalid line offset: '%s'.", option_arg.str().c_str());
+ return Status::FromErrorStringWithFormat("invalid line offset: '%s'.",
+ option_arg.str().c_str());
break;
case 'a':
m_load_addr = OptionArgParser::ToAddress(execution_context, option_arg,
@@ -1774,7 +1777,8 @@ public:
case 't':
lldb::tid_t tid;
if (option_arg.getAsInteger(0, tid))
- return Status("invalid tid: '%s'.", option_arg.str().c_str());
+ return Status::FromErrorStringWithFormat("invalid tid: '%s'.",
+ option_arg.str().c_str());
m_tids.push_back(tid);
break;
case 'u':
@@ -2235,7 +2239,7 @@ public:
int32_t count;
if (option_arg.empty() || option_arg.getAsInteger(0, count) ||
count < 0)
- error.SetErrorStringWithFormat(
+ error = Status::FromErrorStringWithFormat(
"invalid integer value for option '%s'",
option_arg.str().c_str());
else
@@ -2249,7 +2253,7 @@ public:
case 's': {
int32_t skip;
if (option_arg.empty() || option_arg.getAsInteger(0, skip) || skip < 0)
- error.SetErrorStringWithFormat(
+ error = Status::FromErrorStringWithFormat(
"invalid integer value for option '%s'",
option_arg.str().c_str());
else
@@ -2259,7 +2263,7 @@ public:
case 'i': {
uint64_t id;
if (option_arg.empty() || option_arg.getAsInteger(0, id))
- error.SetErrorStringWithFormat(
+ error = Status::FromErrorStringWithFormat(
"invalid integer value for option '%s'",
option_arg.str().c_str());
else