aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectThread.cpp
diff options
context:
space:
mode:
authorRaphael Isemann <teemperor@gmail.com>2020-07-01 17:00:12 +0200
committerRaphael Isemann <teemperor@gmail.com>2020-07-01 17:19:31 +0200
commit9010cef2af0affdef774a721f6adb52a40041da5 (patch)
tree422ca0deeed452b262b6ac85e0d4004505a2c4a0 /lldb/source/Commands/CommandObjectThread.cpp
parenta61fa1a4b9d247e34ea5541422f7040a37baf6e7 (diff)
downloadllvm-9010cef2af0affdef774a721f6adb52a40041da5.zip
llvm-9010cef2af0affdef774a721f6adb52a40041da5.tar.gz
llvm-9010cef2af0affdef774a721f6adb52a40041da5.tar.bz2
[lldb] Replace StringConvert with llvm::to_integer when parsing integer values in CommandObjects
Summary: This replaces the current use of LLDB's own `StringConvert` with LLVM's `to_integer` which has a less error-prone API and doesn't use special 'error values' to designate parsing problems. Where needed I also added missing error handling code that prints a parsing error instead of continuing with the error value returned from `StringConvert` (which either gave a cryptic error message or just took the error value performed an incorrect action with it. For example, `frame recognizer delete -1` just deleted the frame recognizer at index 0). Reviewers: #lldb, labath Reviewed By: labath Subscribers: labath, abidh, JDevlieghere Differential Revision: https://reviews.llvm.org/D82297
Diffstat (limited to 'lldb/source/Commands/CommandObjectThread.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectThread.cpp40
1 files changed, 17 insertions, 23 deletions
diff --git a/lldb/source/Commands/CommandObjectThread.cpp b/lldb/source/Commands/CommandObjectThread.cpp
index 8e599ed..f0ad179 100644
--- a/lldb/source/Commands/CommandObjectThread.cpp
+++ b/lldb/source/Commands/CommandObjectThread.cpp
@@ -10,7 +10,6 @@
#include "lldb/Core/ValueObject.h"
#include "lldb/Host/OptionParser.h"
-#include "lldb/Host/StringConvert.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/OptionArgParser.h"
@@ -109,11 +108,8 @@ public:
process->GetThreadList().GetMutex());
for (size_t i = 0; i < num_args; i++) {
- bool success;
-
- uint32_t thread_idx = StringConvert::ToUInt32(
- command.GetArgumentAtIndex(i), 0, 0, &success);
- if (!success) {
+ uint32_t thread_idx;
+ if (!llvm::to_integer(command.GetArgumentAtIndex(i), thread_idx)) {
result.AppendErrorWithFormat("invalid thread specification: \"%s\"\n",
command.GetArgumentAtIndex(i));
result.SetStatus(eReturnStatusFailed);
@@ -565,9 +561,9 @@ protected:
}
} else {
const char *thread_idx_cstr = command.GetArgumentAtIndex(0);
- uint32_t step_thread_idx =
- StringConvert::ToUInt32(thread_idx_cstr, LLDB_INVALID_INDEX32);
- if (step_thread_idx == LLDB_INVALID_INDEX32) {
+ uint32_t step_thread_idx;
+
+ if (!llvm::to_integer(thread_idx_cstr, step_thread_idx)) {
result.AppendErrorWithFormat("invalid thread index '%s'.\n",
thread_idx_cstr);
result.SetStatus(eReturnStatusFailed);
@@ -1095,9 +1091,7 @@ protected:
size_t num_args = command.GetArgumentCount();
for (size_t i = 0; i < num_args; i++) {
uint32_t line_number;
- line_number = StringConvert::ToUInt32(command.GetArgumentAtIndex(i),
- UINT32_MAX);
- if (line_number == UINT32_MAX) {
+ if (!llvm::to_integer(command.GetArgumentAtIndex(i), line_number)) {
result.AppendErrorWithFormat("invalid line number: '%s'.\n",
command.GetArgumentAtIndex(i));
result.SetStatus(eReturnStatusFailed);
@@ -1321,8 +1315,13 @@ protected:
return false;
}
- uint32_t index_id =
- StringConvert::ToUInt32(command.GetArgumentAtIndex(0), 0, 0);
+ uint32_t index_id;
+ if (!llvm::to_integer(command.GetArgumentAtIndex(0), index_id)) {
+ result.AppendErrorWithFormat("Invalid thread index '%s'",
+ command.GetArgumentAtIndex(0));
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
Thread *new_thread =
process->GetThreadList().FindThreadByIndexID(index_id).get();
@@ -1989,10 +1988,8 @@ public:
return false;
}
- bool success;
- uint32_t thread_plan_idx =
- StringConvert::ToUInt32(args.GetArgumentAtIndex(0), 0, 0, &success);
- if (!success) {
+ uint32_t thread_plan_idx;
+ if (!llvm::to_integer(args.GetArgumentAtIndex(0), thread_plan_idx)) {
result.AppendErrorWithFormat(
"Invalid thread index: \"%s\" - should be unsigned int.",
args.GetArgumentAtIndex(0));
@@ -2066,11 +2063,8 @@ public:
process->GetThreadList().GetMutex());
for (size_t i = 0; i < num_args; i++) {
- bool success;
-
- lldb::tid_t tid = StringConvert::ToUInt64(
- args.GetArgumentAtIndex(i), 0, 0, &success);
- if (!success) {
+ lldb::tid_t tid;
+ if (!llvm::to_integer(args.GetArgumentAtIndex(i), tid)) {
result.AppendErrorWithFormat("invalid thread specification: \"%s\"\n",
args.GetArgumentAtIndex(i));
result.SetStatus(eReturnStatusFailed);