summaryrefslogtreecommitdiffstats
path: root/lldb/source/Interpreter
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Interpreter')
-rw-r--r--lldb/source/Interpreter/Args.cpp76
-rw-r--r--lldb/source/Interpreter/CommandHistory.cpp8
-rw-r--r--lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp7
-rw-r--r--lldb/source/Interpreter/OptionValueArray.cpp9
-rw-r--r--lldb/source/Interpreter/OptionValueFileSpecLIst.cpp7
-rw-r--r--lldb/source/Interpreter/OptionValuePathMappings.cpp7
-rw-r--r--lldb/source/Interpreter/OptionValueSInt64.cpp4
-rw-r--r--lldb/source/Interpreter/OptionValueUInt64.cpp4
-rw-r--r--lldb/source/Interpreter/Property.cpp6
9 files changed, 31 insertions, 97 deletions
diff --git a/lldb/source/Interpreter/Args.cpp b/lldb/source/Interpreter/Args.cpp
index 93933802f57..61652a6c109 100644
--- a/lldb/source/Interpreter/Args.cpp
+++ b/lldb/source/Interpreter/Args.cpp
@@ -19,14 +19,13 @@
#include "lldb/Core/StreamFile.h"
#include "lldb/Core/StreamString.h"
#include "lldb/DataFormatters/FormatManager.h"
+#include "lldb/Host/StringConvert.h"
#include "lldb/Interpreter/Options.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Target/Process.h"
-//#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
-//#include "lldb/Target/Thread.h"
using namespace lldb;
using namespace lldb_private;
@@ -722,77 +721,6 @@ Args::Clear ()
m_args_quote_char.clear();
}
-int32_t
-Args::StringToSInt32 (const char *s, int32_t fail_value, int base, bool *success_ptr)
-{
- if (s && s[0])
- {
- char *end = nullptr;
- const long sval = ::strtol (s, &end, base);
- if (*end == '\0')
- {
- if (success_ptr)
- *success_ptr = ((sval <= INT32_MAX) && (sval >= INT32_MIN));
- return (int32_t)sval; // All characters were used, return the result
- }
- }
- if (success_ptr) *success_ptr = false;
- return fail_value;
-}
-
-uint32_t
-Args::StringToUInt32 (const char *s, uint32_t fail_value, int base, bool *success_ptr)
-{
- if (s && s[0])
- {
- char *end = nullptr;
- const unsigned long uval = ::strtoul (s, &end, base);
- if (*end == '\0')
- {
- if (success_ptr)
- *success_ptr = (uval <= UINT32_MAX);
- return (uint32_t)uval; // All characters were used, return the result
- }
- }
- if (success_ptr) *success_ptr = false;
- return fail_value;
-}
-
-
-int64_t
-Args::StringToSInt64 (const char *s, int64_t fail_value, int base, bool *success_ptr)
-{
- if (s && s[0])
- {
- char *end = nullptr;
- int64_t uval = ::strtoll (s, &end, base);
- if (*end == '\0')
- {
- if (success_ptr) *success_ptr = true;
- return uval; // All characters were used, return the result
- }
- }
- if (success_ptr) *success_ptr = false;
- return fail_value;
-}
-
-uint64_t
-Args::StringToUInt64 (const char *s, uint64_t fail_value, int base, bool *success_ptr)
-{
- if (s && s[0])
- {
- char *end = nullptr;
- uint64_t uval = ::strtoull (s, &end, base);
- if (*end == '\0')
- {
- if (success_ptr) *success_ptr = true;
- return uval; // All characters were used, return the result
- }
- }
- if (success_ptr) *success_ptr = false;
- return fail_value;
-}
-
lldb::addr_t
Args::StringToAddress (const ExecutionContext *exe_ctx, const char *s, lldb::addr_t fail_value, Error *error_ptr)
{
@@ -878,7 +806,7 @@ Args::StringToAddress (const ExecutionContext *exe_ctx, const char *s, lldb::add
if (regex_match.GetMatchAtIndex(s, 3, str))
{
- offset = Args::StringToUInt64(str.c_str(), 0, 0, &success);
+ offset = StringConvert::ToUInt64(str.c_str(), 0, 0, &success);
if (success)
{
diff --git a/lldb/source/Interpreter/CommandHistory.cpp b/lldb/source/Interpreter/CommandHistory.cpp
index 26996a62564..bbe64b446ac 100644
--- a/lldb/source/Interpreter/CommandHistory.cpp
+++ b/lldb/source/Interpreter/CommandHistory.cpp
@@ -7,8 +7,10 @@
//
//===----------------------------------------------------------------------===//
+#include <inttypes.h>
+
#include "lldb/Interpreter/CommandHistory.h"
-#include "lldb/Interpreter/Args.h"
+#include "lldb/Host/StringConvert.h"
using namespace lldb;
using namespace lldb_private;
@@ -47,7 +49,7 @@ CommandHistory::FindString (const char* input_str) const
if (input_str[1] == '-')
{
bool success;
- size_t idx = Args::StringToUInt32 (input_str+2, 0, 0, &success);
+ size_t idx = StringConvert::ToUInt32 (input_str+2, 0, 0, &success);
if (!success)
return nullptr;
if (idx > m_history.size())
@@ -66,7 +68,7 @@ CommandHistory::FindString (const char* input_str) const
else
{
bool success;
- uint32_t idx = Args::StringToUInt32 (input_str+1, 0, 0, &success);
+ uint32_t idx = StringConvert::ToUInt32 (input_str+1, 0, 0, &success);
if (!success)
return nullptr;
if (idx >= m_history.size())
diff --git a/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp b/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp
index b6c63fa44c4..72d7ff597ab 100644
--- a/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp
+++ b/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp
@@ -16,6 +16,7 @@
// Other libraries and framework includes
// Project includes
#include "lldb/DataFormatters/ValueObjectPrinter.h"
+#include "lldb/Host/StringConvert.h"
#include "lldb/Target/Target.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Utility/Utils.h"
@@ -89,13 +90,13 @@ OptionGroupValueObjectDisplay::SetOptionValue (CommandInterpreter &interpreter,
case 'A': ignore_cap = true; break;
case 'D':
- max_depth = Args::StringToUInt32 (option_arg, UINT32_MAX, 0, &success);
+ max_depth = StringConvert::ToUInt32 (option_arg, UINT32_MAX, 0, &success);
if (!success)
error.SetErrorStringWithFormat("invalid max depth '%s'", option_arg);
break;
case 'P':
- ptr_depth = Args::StringToUInt32 (option_arg, 0, 0, &success);
+ ptr_depth = StringConvert::ToUInt32 (option_arg, 0, 0, &success);
if (!success)
error.SetErrorStringWithFormat("invalid pointer depth '%s'", option_arg);
break;
@@ -103,7 +104,7 @@ OptionGroupValueObjectDisplay::SetOptionValue (CommandInterpreter &interpreter,
case 'Y':
if (option_arg)
{
- no_summary_depth = Args::StringToUInt32 (option_arg, 0, 0, &success);
+ no_summary_depth = StringConvert::ToUInt32 (option_arg, 0, 0, &success);
if (!success)
error.SetErrorStringWithFormat("invalid pointer depth '%s'", option_arg);
}
diff --git a/lldb/source/Interpreter/OptionValueArray.cpp b/lldb/source/Interpreter/OptionValueArray.cpp
index c0d48c1e7bd..86d49c9ba3b 100644
--- a/lldb/source/Interpreter/OptionValueArray.cpp
+++ b/lldb/source/Interpreter/OptionValueArray.cpp
@@ -14,6 +14,7 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Core/Stream.h"
+#include "lldb/Host/StringConvert.h"
#include "lldb/Interpreter/Args.h"
using namespace lldb;
@@ -97,7 +98,7 @@ OptionValueArray::GetSubValue (const ExecutionContext *exe_ctx,
sub_value = end_bracket + 1;
std::string index_str (name+1, end_bracket);
const size_t array_count = m_values.size();
- int32_t idx = Args::StringToSInt32(index_str.c_str(), INT32_MAX, 0, nullptr);
+ int32_t idx = StringConvert::ToSInt32(index_str.c_str(), INT32_MAX, 0, nullptr);
if (idx != INT32_MAX)
{
;
@@ -177,7 +178,7 @@ OptionValueArray::SetArgs (const Args &args, VarSetOperationType op)
case eVarSetOperationInsertAfter:
if (argc > 1)
{
- uint32_t idx = Args::StringToUInt32(args.GetArgumentAtIndex(0), UINT32_MAX);
+ uint32_t idx = StringConvert::ToUInt32(args.GetArgumentAtIndex(0), UINT32_MAX);
const uint32_t count = GetSize();
if (idx > count)
{
@@ -225,7 +226,7 @@ OptionValueArray::SetArgs (const Args &args, VarSetOperationType op)
for (i=0; i<argc; ++i)
{
const size_t idx =
- Args::StringToSInt32(args.GetArgumentAtIndex(i), INT32_MAX);
+ StringConvert::ToSInt32(args.GetArgumentAtIndex(i), INT32_MAX);
if (idx >= size)
{
all_indexes_valid = false;
@@ -274,7 +275,7 @@ OptionValueArray::SetArgs (const Args &args, VarSetOperationType op)
case eVarSetOperationReplace:
if (argc > 1)
{
- uint32_t idx = Args::StringToUInt32(args.GetArgumentAtIndex(0), UINT32_MAX);
+ uint32_t idx = StringConvert::ToUInt32(args.GetArgumentAtIndex(0), UINT32_MAX);
const uint32_t count = GetSize();
if (idx > count)
{
diff --git a/lldb/source/Interpreter/OptionValueFileSpecLIst.cpp b/lldb/source/Interpreter/OptionValueFileSpecLIst.cpp
index 7150ad47464..0e696ca91db 100644
--- a/lldb/source/Interpreter/OptionValueFileSpecLIst.cpp
+++ b/lldb/source/Interpreter/OptionValueFileSpecLIst.cpp
@@ -14,6 +14,7 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Core/Stream.h"
+#include "lldb/Host/StringConvert.h"
#include "lldb/Interpreter/Args.h"
using namespace lldb;
@@ -57,7 +58,7 @@ OptionValueFileSpecList::SetValueFromCString (const char *value, VarSetOperation
case eVarSetOperationReplace:
if (argc > 1)
{
- uint32_t idx = Args::StringToUInt32(args.GetArgumentAtIndex(0), UINT32_MAX);
+ uint32_t idx = StringConvert::ToUInt32(args.GetArgumentAtIndex(0), UINT32_MAX);
const uint32_t count = m_current_value.GetSize();
if (idx > count)
{
@@ -108,7 +109,7 @@ OptionValueFileSpecList::SetValueFromCString (const char *value, VarSetOperation
case eVarSetOperationInsertAfter:
if (argc > 1)
{
- uint32_t idx = Args::StringToUInt32(args.GetArgumentAtIndex(0), UINT32_MAX);
+ uint32_t idx = StringConvert::ToUInt32(args.GetArgumentAtIndex(0), UINT32_MAX);
const uint32_t count = m_current_value.GetSize();
if (idx > count)
{
@@ -140,7 +141,7 @@ OptionValueFileSpecList::SetValueFromCString (const char *value, VarSetOperation
size_t i;
for (i=0; all_indexes_valid && i<argc; ++i)
{
- const int idx = Args::StringToSInt32(args.GetArgumentAtIndex(i), INT32_MAX);
+ const int idx = StringConvert::ToSInt32(args.GetArgumentAtIndex(i), INT32_MAX);
if (idx == INT32_MAX)
all_indexes_valid = false;
else
diff --git a/lldb/source/Interpreter/OptionValuePathMappings.cpp b/lldb/source/Interpreter/OptionValuePathMappings.cpp
index 56f2ecf4f5f..b1e714e9707 100644
--- a/lldb/source/Interpreter/OptionValuePathMappings.cpp
+++ b/lldb/source/Interpreter/OptionValuePathMappings.cpp
@@ -14,6 +14,7 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Core/Stream.h"
+#include "lldb/Host/StringConvert.h"
#include "lldb/Interpreter/Args.h"
using namespace lldb;
@@ -50,7 +51,7 @@ OptionValuePathMappings::SetValueFromCString (const char *value, VarSetOperation
// Must be at least one index + 1 pair of paths, and the pair count must be even
if (argc >= 3 && (((argc - 1) & 1) == 0))
{
- uint32_t idx = Args::StringToUInt32(args.GetArgumentAtIndex(0), UINT32_MAX);
+ uint32_t idx = StringConvert::ToUInt32(args.GetArgumentAtIndex(0), UINT32_MAX);
const uint32_t count = m_path_mappings.GetSize();
if (idx > count)
{
@@ -108,7 +109,7 @@ OptionValuePathMappings::SetValueFromCString (const char *value, VarSetOperation
// Must be at least one index + 1 pair of paths, and the pair count must be even
if (argc >= 3 && (((argc - 1) & 1) == 0))
{
- uint32_t idx = Args::StringToUInt32(args.GetArgumentAtIndex(0), UINT32_MAX);
+ uint32_t idx = StringConvert::ToUInt32(args.GetArgumentAtIndex(0), UINT32_MAX);
const uint32_t count = m_path_mappings.GetSize();
if (idx > count)
{
@@ -141,7 +142,7 @@ OptionValuePathMappings::SetValueFromCString (const char *value, VarSetOperation
size_t i;
for (i=0; all_indexes_valid && i<argc; ++i)
{
- const int idx = Args::StringToSInt32(args.GetArgumentAtIndex(i), INT32_MAX);
+ const int idx = StringConvert::ToSInt32(args.GetArgumentAtIndex(i), INT32_MAX);
if (idx == INT32_MAX)
all_indexes_valid = false;
else
diff --git a/lldb/source/Interpreter/OptionValueSInt64.cpp b/lldb/source/Interpreter/OptionValueSInt64.cpp
index 1827cc1d873..c69172921a6 100644
--- a/lldb/source/Interpreter/OptionValueSInt64.cpp
+++ b/lldb/source/Interpreter/OptionValueSInt64.cpp
@@ -14,7 +14,7 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Core/Stream.h"
-#include "lldb/Interpreter/Args.h"
+#include "lldb/Host/StringConvert.h"
using namespace lldb;
using namespace lldb_private;
@@ -51,7 +51,7 @@ OptionValueSInt64::SetValueFromCString (const char *value_cstr, VarSetOperationT
case eVarSetOperationAssign:
{
bool success = false;
- int64_t value = Args::StringToSInt64 (value_cstr, 0, 0, &success);
+ int64_t value = StringConvert::ToSInt64 (value_cstr, 0, 0, &success);
if (success)
{
if (value >= m_min_value && value <= m_max_value)
diff --git a/lldb/source/Interpreter/OptionValueUInt64.cpp b/lldb/source/Interpreter/OptionValueUInt64.cpp
index 3e12c030255..48de433d36c 100644
--- a/lldb/source/Interpreter/OptionValueUInt64.cpp
+++ b/lldb/source/Interpreter/OptionValueUInt64.cpp
@@ -14,7 +14,7 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Core/Stream.h"
-#include "lldb/Interpreter/Args.h"
+#include "lldb/Host/StringConvert.h"
using namespace lldb;
using namespace lldb_private;
@@ -58,7 +58,7 @@ OptionValueUInt64::SetValueFromCString (const char *value_cstr, VarSetOperationT
case eVarSetOperationAssign:
{
bool success = false;
- uint64_t value = Args::StringToUInt64 (value_cstr, 0, 0, &success);
+ uint64_t value = StringConvert::ToUInt64 (value_cstr, 0, 0, &success);
if (success)
{
m_value_was_set = true;
diff --git a/lldb/source/Interpreter/Property.cpp b/lldb/source/Interpreter/Property.cpp
index 7f7219fc0d5..36976b889da 100644
--- a/lldb/source/Interpreter/Property.cpp
+++ b/lldb/source/Interpreter/Property.cpp
@@ -16,7 +16,7 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Core/UserSettingsController.h"
-#include "lldb/Interpreter/Args.h"
+#include "lldb/Host/StringConvert.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/OptionValues.h"
@@ -137,7 +137,7 @@ Property::Property (const PropertyDefinition &definition) :
// "definition.default_cstr_value" is NULL, otherwise interpret
// "definition.default_cstr_value" as a string value that represents the default
// value.
- m_value_sp.reset (new OptionValueSInt64(definition.default_cstr_value ? Args::StringToSInt64 (definition.default_cstr_value) : definition.default_uint_value));
+ m_value_sp.reset (new OptionValueSInt64(definition.default_cstr_value ? StringConvert::ToSInt64 (definition.default_cstr_value) : definition.default_uint_value));
break;
case OptionValue::eTypeUInt64:
@@ -145,7 +145,7 @@ Property::Property (const PropertyDefinition &definition) :
// "definition.default_cstr_value" is NULL, otherwise interpret
// "definition.default_cstr_value" as a string value that represents the default
// value.
- m_value_sp.reset (new OptionValueUInt64(definition.default_cstr_value ? Args::StringToUInt64 (definition.default_cstr_value) : definition.default_uint_value));
+ m_value_sp.reset (new OptionValueUInt64(definition.default_cstr_value ? StringConvert::ToUInt64 (definition.default_cstr_value) : definition.default_uint_value));
break;
case OptionValue::eTypeUUID:
OpenPOWER on IntegriCloud