aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectFrame.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/CommandObjectFrame.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/CommandObjectFrame.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectFrame.cpp21
1 files changed, 16 insertions, 5 deletions
diff --git a/lldb/source/Commands/CommandObjectFrame.cpp b/lldb/source/Commands/CommandObjectFrame.cpp
index 5677b16..6ebad9b 100644
--- a/lldb/source/Commands/CommandObjectFrame.cpp
+++ b/lldb/source/Commands/CommandObjectFrame.cpp
@@ -12,7 +12,6 @@
#include "lldb/DataFormatters/ValueObjectPrinter.h"
#include "lldb/Host/Config.h"
#include "lldb/Host/OptionParser.h"
-#include "lldb/Host/StringConvert.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/OptionGroupFormat.h"
@@ -986,8 +985,13 @@ protected:
return false;
}
- uint32_t recognizer_id =
- StringConvert::ToUInt32(command.GetArgumentAtIndex(0), 0, 0);
+ uint32_t recognizer_id;
+ if (!llvm::to_integer(command.GetArgumentAtIndex(0), recognizer_id)) {
+ result.AppendErrorWithFormat("'%s' is not a valid recognizer id.\n",
+ command.GetArgumentAtIndex(0));
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
StackFrameRecognizerManager::RemoveRecognizerWithID(recognizer_id);
result.SetStatus(eReturnStatusSuccessFinishResult);
@@ -1067,6 +1071,15 @@ public:
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
+ const char *frame_index_str = command.GetArgumentAtIndex(0);
+ uint32_t frame_index;
+ if (!llvm::to_integer(frame_index_str, frame_index)) {
+ result.AppendErrorWithFormat("'%s' is not a valid frame index.",
+ frame_index_str);
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
+
Process *process = m_exe_ctx.GetProcessPtr();
if (process == nullptr) {
result.AppendError("no process");
@@ -1086,8 +1099,6 @@ protected:
return false;
}
- uint32_t frame_index =
- StringConvert::ToUInt32(command.GetArgumentAtIndex(0), 0, 0);
StackFrameSP frame_sp = thread->GetStackFrameAtIndex(frame_index);
if (!frame_sp) {
result.AppendErrorWithFormat("no frame with index %u", frame_index);