diff options
author | Raphael Isemann <teemperor@gmail.com> | 2020-07-01 17:00:12 +0200 |
---|---|---|
committer | Raphael Isemann <teemperor@gmail.com> | 2020-07-01 17:19:31 +0200 |
commit | 9010cef2af0affdef774a721f6adb52a40041da5 (patch) | |
tree | 422ca0deeed452b262b6ac85e0d4004505a2c4a0 /lldb/source/Commands/CommandObjectProcess.cpp | |
parent | a61fa1a4b9d247e34ea5541422f7040a37baf6e7 (diff) | |
download | llvm-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/CommandObjectProcess.cpp')
-rw-r--r-- | lldb/source/Commands/CommandObjectProcess.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp index aa90ad6..3659f0d 100644 --- a/lldb/source/Commands/CommandObjectProcess.cpp +++ b/lldb/source/Commands/CommandObjectProcess.cpp @@ -13,7 +13,6 @@ #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.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" @@ -1059,10 +1058,10 @@ protected: int signo = LLDB_INVALID_SIGNAL_NUMBER; const char *signal_name = command.GetArgumentAtIndex(0); - if (::isxdigit(signal_name[0])) - signo = - StringConvert::ToSInt32(signal_name, LLDB_INVALID_SIGNAL_NUMBER, 0); - else + if (::isxdigit(signal_name[0])) { + if (!llvm::to_integer(signal_name, signo)) + signo = LLDB_INVALID_SIGNAL_NUMBER; + } else signo = process->GetUnixSignals()->GetSignalNumberFromName(signal_name); if (signo == LLDB_INVALID_SIGNAL_NUMBER) { @@ -1410,7 +1409,8 @@ public: real_value = 0; else { // If the value isn't 'true' or 'false', it had better be 0 or 1. - real_value = StringConvert::ToUInt32(option.c_str(), 3); + if (!llvm::to_integer(option, real_value)) + real_value = 3; if (real_value != 0 && real_value != 1) okay = false; } |