Moved Args::StringToXIntYZ to StringConvert::ToXIntYZ

The refactor was motivated by some comments that Greg made
http://reviews.llvm.org/D6918

and also to break a dependency cascade that caused functions linking
in string->int conversion functions to pull in most of lldb

llvm-svn: 226199
This commit is contained in:
Vince Harron 2015-01-15 20:08:35 +00:00
parent 66c9fb0d52
commit 5275aaa0cc
40 changed files with 341 additions and 248 deletions

View File

@ -0,0 +1,45 @@
//===-- StringConvert.h -----------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef liblldb_StringConvert_h_
#define liblldb_StringConvert_h_
// C Includes
#include <stdint.h>
// C++ Includes
// Other libraries and framework includes
// Project includes
namespace lldb_private {
namespace StringConvert {
//----------------------------------------------------------------------
/// @namespace StringConvert StringConvert.h "lldb/Host/StringConvert.h"
/// @brief Utility classes for converting strings into Integers
//----------------------------------------------------------------------
int32_t
ToSInt32 (const char *s, int32_t fail_value = 0, int base = 0, bool *success_ptr = nullptr);
uint32_t
ToUInt32 (const char *s, uint32_t fail_value = 0, int base = 0, bool *success_ptr = nullptr);
int64_t
ToSInt64 (const char *s, int64_t fail_value = 0, int base = 0, bool *success_ptr = nullptr);
uint64_t
ToUInt64 (const char *s, uint64_t fail_value = 0, int base = 0, bool *success_ptr = nullptr);
} // namespace StringConvert
} // namespace lldb_private
#endif

View File

@ -347,18 +347,6 @@ public:
bool trailing = true,
bool return_null_if_empty = true);
static int32_t
StringToSInt32 (const char *s, int32_t fail_value = 0, int base = 0, bool *success_ptr = NULL);
static uint32_t
StringToUInt32 (const char *s, uint32_t fail_value = 0, int base = 0, bool *success_ptr = NULL);
static int64_t
StringToSInt64 (const char *s, int64_t fail_value = 0, int base = 0, bool *success_ptr = NULL);
static uint64_t
StringToUInt64 (const char *s, uint64_t fail_value = 0, int base = 0, bool *success_ptr = NULL);
static bool
UInt64ValueIsValidForByteSize (uint64_t uval64, size_t total_byte_size)
{

View File

@ -585,6 +585,9 @@
26FFC19E14FC072100087D58 /* DynamicLoaderPOSIXDYLD.h in Headers */ = {isa = PBXBuildFile; fileRef = 26FFC19814FC072100087D58 /* DynamicLoaderPOSIXDYLD.h */; };
33064C9A1A5C7A330033D415 /* UriParser.cpp in CopyFiles */ = {isa = PBXBuildFile; fileRef = 33064C991A5C7A330033D415 /* UriParser.cpp */; };
33064C9C1A5C7A490033D415 /* UriParser.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 33064C9B1A5C7A490033D415 /* UriParser.h */; };
33E5E8421A672A240024ED68 /* StringConvert.cpp in CopyFiles */ = {isa = PBXBuildFile; fileRef = 33E5E8411A672A240024ED68 /* StringConvert.cpp */; };
33E5E8461A6736D30024ED68 /* StringConvert.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 33E5E8451A6736D30024ED68 /* StringConvert.h */; };
33E5E8471A674FB60024ED68 /* StringConvert.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 33E5E8411A672A240024ED68 /* StringConvert.cpp */; };
3FDFDDBD199C3A06009756A7 /* FileAction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3FDFDDBC199C3A06009756A7 /* FileAction.cpp */; };
3FDFDDBF199D345E009756A7 /* FileCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3FDFDDBE199D345E009756A7 /* FileCache.cpp */; };
3FDFDDC6199D37ED009756A7 /* FileSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3FDFDDC5199D37ED009756A7 /* FileSystem.cpp */; };
@ -937,7 +940,9 @@
dstSubfolderSpec = 0;
files = (
AF90106515AB7D3600FF120D /* lldb.1 in CopyFiles */,
33E5E8461A6736D30024ED68 /* StringConvert.h in CopyFiles */,
33064C9C1A5C7A490033D415 /* UriParser.h in CopyFiles */,
33E5E8421A672A240024ED68 /* StringConvert.cpp in CopyFiles */,
33064C9A1A5C7A330033D415 /* UriParser.cpp in CopyFiles */,
);
runOnlyForDeploymentPostprocessing = 1;
@ -1806,6 +1811,8 @@
26FFC19814FC072100087D58 /* DynamicLoaderPOSIXDYLD.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DynamicLoaderPOSIXDYLD.h; sourceTree = "<group>"; };
33064C991A5C7A330033D415 /* UriParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UriParser.cpp; path = source/Utility/UriParser.cpp; sourceTree = "<group>"; };
33064C9B1A5C7A490033D415 /* UriParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UriParser.h; path = source/Utility/UriParser.h; sourceTree = "<group>"; };
33E5E8411A672A240024ED68 /* StringConvert.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StringConvert.cpp; sourceTree = "<group>"; };
33E5E8451A6736D30024ED68 /* StringConvert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StringConvert.h; path = include/lldb/Host/StringConvert.h; sourceTree = SOURCE_ROOT; };
3F5E8AF31A40D4A500A73232 /* PipeBase.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = PipeBase.h; path = include/lldb/Host/PipeBase.h; sourceTree = "<group>"; };
3FDFD6C3199C396E009756A7 /* FileAction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FileAction.h; path = include/lldb/Target/FileAction.h; sourceTree = "<group>"; };
3FDFDDBC199C3A06009756A7 /* FileAction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FileAction.cpp; path = source/Target/FileAction.cpp; sourceTree = "<group>"; };
@ -3681,6 +3688,7 @@
26BC7DD010F1B7C100F91463 /* Host */ = {
isa = PBXGroup;
children = (
33E5E8451A6736D30024ED68 /* StringConvert.h */,
69A01E1A1236C5D400C660B5 /* common */,
3FDFE53919A29399009756A7 /* freebsd */,
233B009C19610D130090E598 /* linux */,
@ -4321,6 +4329,7 @@
69A01E1A1236C5D400C660B5 /* common */ = {
isa = PBXGroup;
children = (
33E5E8411A672A240024ED68 /* StringConvert.cpp */,
25420ED11A649D88009ADBCB /* PipeBase.cpp */,
26CFDCA2186163A4000E63E5 /* Editline.cpp */,
260C6EA213011581005E16B0 /* File.cpp */,
@ -5106,6 +5115,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
33E5E8471A674FB60024ED68 /* StringConvert.cpp in Sources */,
26D1804216CEDF0700EDFB5B /* TimeSpecTimeout.cpp in Sources */,
2689FFDA13353D9D00698AC0 /* lldb.cpp in Sources */,
2689FFDB13353DA300698AC0 /* lldb-log.cpp in Sources */,
@ -6121,6 +6131,7 @@
"-DLLDB_USE_BUILTIN_DEMANGLER",
);
OTHER_LDFLAGS = "";
PATH = /opt/local/bin;
PRODUCT_NAME = "lib$(TARGET_NAME)";
SKIP_INSTALL = YES;
STANDARD_C_PLUS_PLUS_LIBRARY_TYPE = static;
@ -6157,6 +6168,7 @@
"-DLLDB_USE_BUILTIN_DEMANGLER",
);
OTHER_LDFLAGS = "";
PATH = /opt/local/bin;
PRODUCT_NAME = "lib$(TARGET_NAME)";
SKIP_INSTALL = YES;
STANDARD_C_PLUS_PLUS_LIBRARY_TYPE = static;
@ -6193,6 +6205,7 @@
"-DLLDB_USE_BUILTIN_DEMANGLER",
);
OTHER_LDFLAGS = "";
PATH = /opt/local/bin;
PRODUCT_NAME = "lib$(TARGET_NAME)";
SKIP_INSTALL = YES;
STANDARD_C_PLUS_PLUS_LIBRARY_TYPE = static;
@ -7253,6 +7266,7 @@
"-DLLDB_USE_BUILTIN_DEMANGLER",
);
OTHER_LDFLAGS = "";
PATH = /opt/local/bin;
PRODUCT_NAME = "lib$(TARGET_NAME)";
SKIP_INSTALL = YES;
STANDARD_C_PLUS_PLUS_LIBRARY_TYPE = static;

View File

@ -117,7 +117,7 @@ add_lldb_library(liblldb SHARED
${LLDB_VERS_GENERATED_FILE}
)
else ()
add_lldb_library(liblldb
add_lldb_library(liblldb SHARED
lldb.cpp
lldb-log.cpp
${LLDB_WRAP_PYTHON}

View File

@ -19,6 +19,7 @@
#include "lldb/Breakpoint/Breakpoint.h"
#include "lldb/Breakpoint/BreakpointIDList.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Host/StringConvert.h"
#include "lldb/Interpreter/Options.h"
#include "lldb/Interpreter/OptionValueString.h"
#include "lldb/Interpreter/OptionValueUInt64.h"
@ -140,7 +141,7 @@ public:
break;
case 'C':
m_column = Args::StringToUInt32 (option_arg, 0);
m_column = StringConvert::ToUInt32 (option_arg, 0);
break;
case 'c':
@ -207,7 +208,7 @@ public:
case 'i':
{
m_ignore_count = Args::StringToUInt32(option_arg, UINT32_MAX, 0);
m_ignore_count = StringConvert::ToUInt32(option_arg, UINT32_MAX, 0);
if (m_ignore_count == UINT32_MAX)
error.SetErrorStringWithFormat ("invalid ignore count '%s'", option_arg);
break;
@ -229,7 +230,7 @@ public:
break;
case 'l':
m_line_num = Args::StringToUInt32 (option_arg, 0);
m_line_num = StringConvert::ToUInt32 (option_arg, 0);
break;
case 'M':
@ -276,7 +277,7 @@ public:
case 't' :
{
m_thread_id = Args::StringToUInt64(option_arg, LLDB_INVALID_THREAD_ID, 0);
m_thread_id = StringConvert::ToUInt64(option_arg, LLDB_INVALID_THREAD_ID, 0);
if (m_thread_id == LLDB_INVALID_THREAD_ID)
error.SetErrorStringWithFormat ("invalid thread id string '%s'", option_arg);
}
@ -297,7 +298,7 @@ public:
case 'x':
{
m_thread_index = Args::StringToUInt32(option_arg, UINT32_MAX, 0);
m_thread_index = StringConvert::ToUInt32(option_arg, UINT32_MAX, 0);
if (m_thread_id == UINT32_MAX)
error.SetErrorStringWithFormat ("invalid thread index string '%s'", option_arg);
@ -838,7 +839,7 @@ public:
break;
case 'i':
{
m_ignore_count = Args::StringToUInt32(option_arg, UINT32_MAX, 0);
m_ignore_count = StringConvert::ToUInt32(option_arg, UINT32_MAX, 0);
if (m_ignore_count == UINT32_MAX)
error.SetErrorStringWithFormat ("invalid ignore count '%s'", option_arg);
}
@ -865,7 +866,7 @@ public:
}
else
{
m_thread_id = Args::StringToUInt64(option_arg, LLDB_INVALID_THREAD_ID, 0);
m_thread_id = StringConvert::ToUInt64(option_arg, LLDB_INVALID_THREAD_ID, 0);
if (m_thread_id == LLDB_INVALID_THREAD_ID)
error.SetErrorStringWithFormat ("invalid thread id string '%s'", option_arg);
else
@ -896,7 +897,7 @@ public:
}
else
{
m_thread_index = Args::StringToUInt32 (option_arg, UINT32_MAX, 0);
m_thread_index = StringConvert::ToUInt32 (option_arg, UINT32_MAX, 0);
if (m_thread_id == UINT32_MAX)
error.SetErrorStringWithFormat ("invalid thread index string '%s'", option_arg);
else
@ -1555,7 +1556,7 @@ public:
break;
case 'l':
m_line_num = Args::StringToUInt32 (option_arg, 0);
m_line_num = StringConvert::ToUInt32 (option_arg, 0);
break;
default:

View File

@ -19,7 +19,7 @@
#include "lldb/Core/Disassembler.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/SourceManager.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Host/StringConvert.h"
#include "lldb/Interpreter/CommandCompletions.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
@ -76,13 +76,13 @@ CommandObjectDisassemble::CommandOptions::SetOptionValue (uint32_t option_idx, c
break;
case 'C':
num_lines_context = Args::StringToUInt32(option_arg, 0, 0, &success);
num_lines_context = StringConvert::ToUInt32(option_arg, 0, 0, &success);
if (!success)
error.SetErrorStringWithFormat ("invalid num context lines string: \"%s\"", option_arg);
break;
case 'c':
num_instructions = Args::StringToUInt32(option_arg, 0, 0, &success);
num_instructions = StringConvert::ToUInt32(option_arg, 0, 0, &success);
if (!success)
error.SetErrorStringWithFormat ("invalid num of instructions string: \"%s\"", option_arg);
break;

View File

@ -15,7 +15,6 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "lldb/Interpreter/Args.h"
#include "lldb/Core/Value.h"
#include "lldb/Core/ValueObjectVariable.h"
#include "lldb/DataFormatters/ValueObjectPrinter.h"
@ -24,6 +23,7 @@
#include "lldb/Expression/ClangFunction.h"
#include "lldb/Expression/DWARFExpression.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/StringConvert.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
@ -119,7 +119,7 @@ CommandObjectExpression::CommandOptions::SetOptionValue (CommandInterpreter &int
{
bool success;
uint32_t result;
result = Args::StringToUInt32(option_arg, 0, 0, &success);
result = StringConvert::ToUInt32(option_arg, 0, 0, &success);
if (success)
timeout = result;
else

View File

@ -27,6 +27,7 @@
#include "lldb/DataFormatters/DataVisualization.h"
#include "lldb/DataFormatters/ValueObjectPrinter.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/StringConvert.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
@ -119,7 +120,7 @@ public:
switch (short_option)
{
case 'r':
relative_frame_offset = Args::StringToSInt32 (option_arg, INT32_MIN, 0, &success);
relative_frame_offset = StringConvert::ToSInt32 (option_arg, INT32_MIN, 0, &success);
if (!success)
error.SetErrorStringWithFormat ("invalid frame offset argument '%s'", option_arg);
break;
@ -246,7 +247,7 @@ protected:
{
const char *frame_idx_cstr = command.GetArgumentAtIndex(0);
bool success = false;
frame_idx = Args::StringToUInt32 (frame_idx_cstr, UINT32_MAX, 0, &success);
frame_idx = StringConvert::ToUInt32 (frame_idx_cstr, UINT32_MAX, 0, &success);
if (!success)
{
result.AppendErrorWithFormat ("invalid frame index argument '%s'", frame_idx_cstr);

View File

@ -29,6 +29,7 @@
#include "lldb/Core/Timer.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Host/StringConvert.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
@ -444,7 +445,7 @@ protected:
if (strcasecmp(sub_command, "enable") == 0)
{
bool success;
uint32_t depth = Args::StringToUInt32(args.GetArgumentAtIndex(1), 0, 0, &success);
uint32_t depth = StringConvert::ToUInt32(args.GetArgumentAtIndex(1), 0, 0, &success);
if (success)
{
Timer::SetDisplayDepth (depth);

View File

@ -24,6 +24,7 @@
#include "lldb/Core/StreamString.h"
#include "lldb/Core/ValueObjectMemory.h"
#include "lldb/DataFormatters/ValueObjectPrinter.h"
#include "lldb/Host/StringConvert.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/CommandInterpreter.h"
@ -1293,7 +1294,7 @@ public:
case 'o':
{
bool success;
m_infile_offset = Args::StringToUInt64(option_arg, 0, 0, &success);
m_infile_offset = StringConvert::ToUInt64(option_arg, 0, 0, &success);
if (!success)
{
error.SetErrorStringWithFormat("invalid offset string '%s'", option_arg);
@ -1539,7 +1540,7 @@ protected:
case eFormatPointer:
// Decode hex bytes
uval64 = Args::StringToUInt64(value_str, UINT64_MAX, 16, &success);
uval64 = StringConvert::ToUInt64(value_str, UINT64_MAX, 16, &success);
if (!success)
{
result.AppendErrorWithFormat ("'%s' is not a valid hex string value.\n", value_str);
@ -1567,7 +1568,7 @@ protected:
break;
case eFormatBinary:
uval64 = Args::StringToUInt64(value_str, UINT64_MAX, 2, &success);
uval64 = StringConvert::ToUInt64(value_str, UINT64_MAX, 2, &success);
if (!success)
{
result.AppendErrorWithFormat ("'%s' is not a valid binary string value.\n", value_str);
@ -1607,7 +1608,7 @@ protected:
break;
case eFormatDecimal:
sval64 = Args::StringToSInt64(value_str, INT64_MAX, 0, &success);
sval64 = StringConvert::ToSInt64(value_str, INT64_MAX, 0, &success);
if (!success)
{
result.AppendErrorWithFormat ("'%s' is not a valid signed decimal value.\n", value_str);
@ -1624,7 +1625,7 @@ protected:
break;
case eFormatUnsigned:
uval64 = Args::StringToUInt64(value_str, UINT64_MAX, 0, &success);
uval64 = StringConvert::ToUInt64(value_str, UINT64_MAX, 0, &success);
if (!success)
{
result.AppendErrorWithFormat ("'%s' is not a valid unsigned decimal string value.\n", value_str);
@ -1641,7 +1642,7 @@ protected:
break;
case eFormatOctal:
uval64 = Args::StringToUInt64(value_str, UINT64_MAX, 8, &success);
uval64 = StringConvert::ToUInt64(value_str, UINT64_MAX, 8, &success);
if (!success)
{
result.AppendErrorWithFormat ("'%s' is not a valid octal string value.\n", value_str);

View File

@ -19,6 +19,7 @@
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Host/StringConvert.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandOptionValidators.h"
@ -104,7 +105,7 @@ public:
case 'v':
{
bool ok;
uint32_t perms = Args::StringToUInt32(option_arg, 777, 8, &ok);
uint32_t perms = StringConvert::ToUInt32(option_arg, 777, 8, &ok);
if (!ok)
error.SetErrorStringWithFormat("invalid value for permissions: %s", option_arg);
else
@ -751,7 +752,7 @@ public:
{
std::string cmd_line;
args.GetCommandString(cmd_line);
const lldb::user_id_t fd = Args::StringToUInt64(cmd_line.c_str(), UINT64_MAX);
const lldb::user_id_t fd = StringConvert::ToUInt64(cmd_line.c_str(), UINT64_MAX);
Error error;
bool success = platform_sp->CloseFile(fd, error);
if (success)
@ -803,7 +804,7 @@ public:
{
std::string cmd_line;
args.GetCommandString(cmd_line);
const lldb::user_id_t fd = Args::StringToUInt64(cmd_line.c_str(), UINT64_MAX);
const lldb::user_id_t fd = StringConvert::ToUInt64(cmd_line.c_str(), UINT64_MAX);
std::string buffer(m_options.m_count,0);
Error error;
uint32_t retcode = platform_sp->ReadFile(fd, m_options.m_offset, &buffer[0], m_options.m_count, error);
@ -849,12 +850,12 @@ protected:
switch (short_option)
{
case 'o':
m_offset = Args::StringToUInt32(option_arg, 0, 0, &success);
m_offset = StringConvert::ToUInt32(option_arg, 0, 0, &success);
if (!success)
error.SetErrorStringWithFormat("invalid offset: '%s'", option_arg);
break;
case 'c':
m_count = Args::StringToUInt32(option_arg, 0, 0, &success);
m_count = StringConvert::ToUInt32(option_arg, 0, 0, &success);
if (!success)
error.SetErrorStringWithFormat("invalid offset: '%s'", option_arg);
break;
@ -930,7 +931,7 @@ public:
std::string cmd_line;
args.GetCommandString(cmd_line);
Error error;
const lldb::user_id_t fd = Args::StringToUInt64(cmd_line.c_str(), UINT64_MAX);
const lldb::user_id_t fd = StringConvert::ToUInt64(cmd_line.c_str(), UINT64_MAX);
uint32_t retcode = platform_sp->WriteFile (fd,
m_options.m_offset,
&m_options.m_data[0],
@ -977,7 +978,7 @@ protected:
switch (short_option)
{
case 'o':
m_offset = Args::StringToUInt32(option_arg, 0, 0, &success);
m_offset = StringConvert::ToUInt32(option_arg, 0, 0, &success);
if (!success)
error.SetErrorStringWithFormat("invalid offset: '%s'", option_arg);
break;
@ -1537,37 +1538,37 @@ protected:
switch (short_option)
{
case 'p':
match_info.GetProcessInfo().SetProcessID (Args::StringToUInt32 (option_arg, LLDB_INVALID_PROCESS_ID, 0, &success));
match_info.GetProcessInfo().SetProcessID (StringConvert::ToUInt32 (option_arg, LLDB_INVALID_PROCESS_ID, 0, &success));
if (!success)
error.SetErrorStringWithFormat("invalid process ID string: '%s'", option_arg);
break;
case 'P':
match_info.GetProcessInfo().SetParentProcessID (Args::StringToUInt32 (option_arg, LLDB_INVALID_PROCESS_ID, 0, &success));
match_info.GetProcessInfo().SetParentProcessID (StringConvert::ToUInt32 (option_arg, LLDB_INVALID_PROCESS_ID, 0, &success));
if (!success)
error.SetErrorStringWithFormat("invalid parent process ID string: '%s'", option_arg);
break;
case 'u':
match_info.GetProcessInfo().SetUserID (Args::StringToUInt32 (option_arg, UINT32_MAX, 0, &success));
match_info.GetProcessInfo().SetUserID (StringConvert::ToUInt32 (option_arg, UINT32_MAX, 0, &success));
if (!success)
error.SetErrorStringWithFormat("invalid user ID string: '%s'", option_arg);
break;
case 'U':
match_info.GetProcessInfo().SetEffectiveUserID (Args::StringToUInt32 (option_arg, UINT32_MAX, 0, &success));
match_info.GetProcessInfo().SetEffectiveUserID (StringConvert::ToUInt32 (option_arg, UINT32_MAX, 0, &success));
if (!success)
error.SetErrorStringWithFormat("invalid effective user ID string: '%s'", option_arg);
break;
case 'g':
match_info.GetProcessInfo().SetGroupID (Args::StringToUInt32 (option_arg, UINT32_MAX, 0, &success));
match_info.GetProcessInfo().SetGroupID (StringConvert::ToUInt32 (option_arg, UINT32_MAX, 0, &success));
if (!success)
error.SetErrorStringWithFormat("invalid group ID string: '%s'", option_arg);
break;
case 'G':
match_info.GetProcessInfo().SetEffectiveGroupID (Args::StringToUInt32 (option_arg, UINT32_MAX, 0, &success));
match_info.GetProcessInfo().SetEffectiveGroupID (StringConvert::ToUInt32 (option_arg, UINT32_MAX, 0, &success));
if (!success)
error.SetErrorStringWithFormat("invalid effective group ID string: '%s'", option_arg);
break;
@ -1730,7 +1731,7 @@ protected:
for (size_t i=0; i<argc; ++ i)
{
const char *arg = args.GetArgumentAtIndex(i);
lldb::pid_t pid = Args::StringToUInt32 (arg, LLDB_INVALID_PROCESS_ID, 0, &success);
lldb::pid_t pid = StringConvert::ToUInt32 (arg, LLDB_INVALID_PROCESS_ID, 0, &success);
if (success)
{
ProcessInstanceInfo proc_info;
@ -1805,7 +1806,7 @@ public:
{
case 'p':
{
lldb::pid_t pid = Args::StringToUInt32 (option_arg, LLDB_INVALID_PROCESS_ID, 0, &success);
lldb::pid_t pid = StringConvert::ToUInt32 (option_arg, LLDB_INVALID_PROCESS_ID, 0, &success);
if (!success || pid == LLDB_INVALID_PROCESS_ID)
{
error.SetErrorStringWithFormat("invalid process ID '%s'", option_arg);
@ -2055,7 +2056,7 @@ public:
case 't':
{
bool success;
timeout = Args::StringToUInt32(option_value, 10, 10, &success);
timeout = StringConvert::ToUInt32(option_value, 10, 10, &success);
if (!success)
error.SetErrorStringWithFormat("could not convert \"%s\" to a numeric value.", option_value);
break;

View File

@ -22,6 +22,7 @@
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/StringConvert.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/Options.h"
#include "lldb/Interpreter/CommandInterpreter.h"
@ -353,7 +354,7 @@ public:
case 'p':
{
lldb::pid_t pid = Args::StringToUInt32 (option_arg, LLDB_INVALID_PROCESS_ID, 0, &success);
lldb::pid_t pid = StringConvert::ToUInt32 (option_arg, LLDB_INVALID_PROCESS_ID, 0, &success);
if (!success || pid == LLDB_INVALID_PROCESS_ID)
{
error.SetErrorStringWithFormat("invalid process ID '%s'", option_arg);
@ -714,7 +715,7 @@ protected:
switch (short_option)
{
case 'i':
m_ignore = Args::StringToUInt32 (option_arg, 0, 0, &success);
m_ignore = StringConvert::ToUInt32 (option_arg, 0, 0, &success);
if (!success)
error.SetErrorStringWithFormat ("invalid value for ignore option: \"%s\", should be a number.", option_arg);
break;
@ -1297,7 +1298,7 @@ protected:
for (uint32_t i=0; i<argc; ++i)
{
const char *image_token_cstr = command.GetArgumentAtIndex(i);
uint32_t image_token = Args::StringToUInt32(image_token_cstr, LLDB_INVALID_IMAGE_TOKEN, 0);
uint32_t image_token = StringConvert::ToUInt32(image_token_cstr, LLDB_INVALID_IMAGE_TOKEN, 0);
if (image_token == LLDB_INVALID_IMAGE_TOKEN)
{
result.AppendErrorWithFormat ("invalid image index argument '%s'", image_token_cstr);
@ -1371,7 +1372,7 @@ protected:
const char *signal_name = command.GetArgumentAtIndex(0);
if (::isxdigit (signal_name[0]))
signo = Args::StringToSInt32(signal_name, LLDB_INVALID_SIGNAL_NUMBER, 0);
signo = StringConvert::ToSInt32(signal_name, LLDB_INVALID_SIGNAL_NUMBER, 0);
else
signo = process->GetUnixSignals().GetSignalNumberFromName (signal_name);
@ -1754,7 +1755,7 @@ public:
else
{
// If the value isn't 'true' or 'false', it had better be 0 or 1.
real_value = Args::StringToUInt32 (option.c_str(), 3);
real_value = StringConvert::ToUInt32 (option.c_str(), 3);
if (real_value != 0 && real_value != 1)
okay = false;
}

View File

@ -15,7 +15,6 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "lldb/Interpreter/Args.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/FileLineResolver.h"
#include "lldb/Core/Module.h"
@ -24,6 +23,7 @@
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Host/FileSpec.h"
#include "lldb/Host/StringConvert.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/Symbol.h"
@ -63,7 +63,7 @@ class CommandObjectSourceInfo : public CommandObjectParsed
switch (short_option)
{
case 'l':
start_line = Args::StringToUInt32 (option_arg, 0);
start_line = StringConvert::ToUInt32 (option_arg, 0);
if (start_line == 0)
error.SetErrorStringWithFormat("invalid line number: '%s'", option_arg);
break;
@ -171,13 +171,13 @@ class CommandObjectSourceList : public CommandObjectParsed
switch (short_option)
{
case 'l':
start_line = Args::StringToUInt32 (option_arg, 0);
start_line = StringConvert::ToUInt32 (option_arg, 0);
if (start_line == 0)
error.SetErrorStringWithFormat("invalid line number: '%s'", option_arg);
break;
case 'c':
num_lines = Args::StringToUInt32 (option_arg, 0);
num_lines = StringConvert::ToUInt32 (option_arg, 0);
if (num_lines == 0)
error.SetErrorStringWithFormat("invalid line count: '%s'", option_arg);
break;

View File

@ -27,6 +27,7 @@
#include "lldb/Core/Timer.h"
#include "lldb/Core/ValueObjectVariable.h"
#include "lldb/DataFormatters/ValueObjectPrinter.h"
#include "lldb/Host/StringConvert.h"
#include "lldb/Host/Symbols.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
@ -522,7 +523,7 @@ protected:
{
bool success = false;
const char *target_idx_arg = args.GetArgumentAtIndex(0);
uint32_t target_idx = Args::StringToUInt32 (target_idx_arg, UINT32_MAX, 0, &success);
uint32_t target_idx = StringConvert::ToUInt32 (target_idx_arg, UINT32_MAX, 0, &success);
if (success)
{
TargetList &target_list = m_interpreter.GetDebugger().GetTargetList();
@ -629,7 +630,7 @@ protected:
for (uint32_t arg_idx = 0; success && arg_idx < argc; ++arg_idx)
{
const char *target_idx_arg = args.GetArgumentAtIndex(arg_idx);
uint32_t target_idx = Args::StringToUInt32 (target_idx_arg, UINT32_MAX, 0, &success);
uint32_t target_idx = StringConvert::ToUInt32 (target_idx_arg, UINT32_MAX, 0, &success);
if (success)
{
if (target_idx < num_targets)
@ -1260,7 +1261,7 @@ protected:
{
bool success = false;
uint32_t insert_idx = Args::StringToUInt32(command.GetArgumentAtIndex(0), UINT32_MAX, 0, &success);
uint32_t insert_idx = StringConvert::ToUInt32(command.GetArgumentAtIndex(0), UINT32_MAX, 0, &success);
if (!success)
{
@ -2963,7 +2964,7 @@ protected:
{
ConstString const_sect_name(sect_name);
bool success = false;
addr_t load_addr = Args::StringToUInt64(load_addr_cstr, LLDB_INVALID_ADDRESS, 0, &success);
addr_t load_addr = StringConvert::ToUInt64(load_addr_cstr, LLDB_INVALID_ADDRESS, 0, &success);
if (success)
{
SectionSP section_sp (section_list->FindSectionByName(const_sect_name));
@ -3890,7 +3891,7 @@ public:
break;
case 'o':
m_offset = Args::StringToUInt64(option_arg, LLDB_INVALID_ADDRESS);
m_offset = StringConvert::ToUInt64(option_arg, LLDB_INVALID_ADDRESS);
if (m_offset == LLDB_INVALID_ADDRESS)
error.SetErrorStringWithFormat ("invalid offset string '%s'", option_arg);
break;
@ -3910,7 +3911,7 @@ public:
break;
case 'l':
m_line_number = Args::StringToUInt32(option_arg, UINT32_MAX);
m_line_number = StringConvert::ToUInt32(option_arg, UINT32_MAX);
if (m_line_number == UINT32_MAX)
error.SetErrorStringWithFormat ("invalid line number string '%s'", option_arg);
else if (m_line_number == 0)
@ -4873,7 +4874,7 @@ public:
break;
case 'e':
m_line_end = Args::StringToUInt32 (option_arg, UINT_MAX, 0, &success);
m_line_end = StringConvert::ToUInt32 (option_arg, UINT_MAX, 0, &success);
if (!success)
{
error.SetErrorStringWithFormat ("invalid end line number: \"%s\"", option_arg);
@ -4883,7 +4884,7 @@ public:
break;
case 'l':
m_line_start = Args::StringToUInt32 (option_arg, 0, 0, &success);
m_line_start = StringConvert::ToUInt32 (option_arg, 0, 0, &success);
if (!success)
{
error.SetErrorStringWithFormat ("invalid start line number: \"%s\"", option_arg);
@ -4912,7 +4913,7 @@ public:
break;
case 't' :
{
m_thread_id = Args::StringToUInt64(option_arg, LLDB_INVALID_THREAD_ID, 0);
m_thread_id = StringConvert::ToUInt64(option_arg, LLDB_INVALID_THREAD_ID, 0);
if (m_thread_id == LLDB_INVALID_THREAD_ID)
error.SetErrorStringWithFormat ("invalid thread id string '%s'", option_arg);
m_thread_specified = true;
@ -4928,7 +4929,7 @@ public:
break;
case 'x':
{
m_thread_index = Args::StringToUInt32(option_arg, UINT32_MAX, 0);
m_thread_index = StringConvert::ToUInt32(option_arg, UINT32_MAX, 0);
if (m_thread_id == UINT32_MAX)
error.SetErrorStringWithFormat ("invalid thread index string '%s'", option_arg);
m_thread_specified = true;
@ -5233,7 +5234,7 @@ protected:
bool success;
for (size_t i = 0; i < num_args; i++)
{
lldb::user_id_t user_id = Args::StringToUInt32 (command.GetArgumentAtIndex(i), 0, 0, &success);
lldb::user_id_t user_id = StringConvert::ToUInt32 (command.GetArgumentAtIndex(i), 0, 0, &success);
if (!success)
{
result.AppendErrorWithFormat ("invalid stop hook id: \"%s\".\n", command.GetArgumentAtIndex(i));
@ -5302,7 +5303,7 @@ protected:
{
for (size_t i = 0; i < num_args; i++)
{
lldb::user_id_t user_id = Args::StringToUInt32 (command.GetArgumentAtIndex(i), 0, 0, &success);
lldb::user_id_t user_id = StringConvert::ToUInt32 (command.GetArgumentAtIndex(i), 0, 0, &success);
if (!success)
{
result.AppendErrorWithFormat ("invalid stop hook id: \"%s\".\n", command.GetArgumentAtIndex(i));

View File

@ -19,6 +19,7 @@
#include "lldb/Core/State.h"
#include "lldb/Core/SourceManager.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/StringConvert.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/Options.h"
@ -95,7 +96,7 @@ public:
{
bool success;
uint32_t thread_idx = Args::StringToUInt32(command.GetArgumentAtIndex(i), 0, 0, &success);
uint32_t thread_idx = StringConvert::ToUInt32(command.GetArgumentAtIndex(i), 0, 0, &success);
if (!success)
{
result.AppendErrorWithFormat ("invalid thread specification: \"%s\"\n", command.GetArgumentAtIndex(i));
@ -178,7 +179,7 @@ public:
case 'c':
{
bool success;
int32_t input_count = Args::StringToSInt32 (option_arg, -1, 0, &success);
int32_t input_count = StringConvert::ToSInt32 (option_arg, -1, 0, &success);
if (!success)
error.SetErrorStringWithFormat("invalid integer value for option '%c'", short_option);
if (input_count < -1)
@ -190,7 +191,7 @@ public:
case 's':
{
bool success;
m_start = Args::StringToUInt32 (option_arg, 0, 0, &success);
m_start = StringConvert::ToUInt32 (option_arg, 0, 0, &success);
if (!success)
error.SetErrorStringWithFormat("invalid integer value for option '%c'", short_option);
}
@ -384,7 +385,7 @@ public:
case 'c':
{
m_step_count = Args::StringToUInt32(option_arg, UINT32_MAX, 0);
m_step_count = StringConvert::ToUInt32(option_arg, UINT32_MAX, 0);
if (m_step_count == UINT32_MAX)
error.SetErrorStringWithFormat ("invalid ignore count '%s'", option_arg);
break;
@ -522,7 +523,7 @@ protected:
else
{
const char *thread_idx_cstr = command.GetArgumentAtIndex(0);
uint32_t step_thread_idx = Args::StringToUInt32 (thread_idx_cstr, LLDB_INVALID_INDEX32);
uint32_t step_thread_idx = StringConvert::ToUInt32 (thread_idx_cstr, LLDB_INVALID_INDEX32);
if (step_thread_idx == LLDB_INVALID_INDEX32)
{
result.AppendErrorWithFormat ("invalid thread index '%s'.\n", thread_idx_cstr);
@ -812,7 +813,7 @@ public:
{
bool success;
const int base = 0;
uint32_t thread_idx = Args::StringToUInt32 (command.GetArgumentAtIndex(i), LLDB_INVALID_INDEX32, base, &success);
uint32_t thread_idx = StringConvert::ToUInt32 (command.GetArgumentAtIndex(i), LLDB_INVALID_INDEX32, base, &success);
if (success)
{
Thread *thread = process->GetThreadList().FindThreadByIndexID(thread_idx).get();
@ -986,7 +987,7 @@ public:
{
case 't':
{
m_thread_idx = Args::StringToUInt32 (option_arg, LLDB_INVALID_INDEX32);
m_thread_idx = StringConvert::ToUInt32 (option_arg, LLDB_INVALID_INDEX32);
if (m_thread_idx == LLDB_INVALID_INDEX32)
{
error.SetErrorStringWithFormat ("invalid thread index '%s'", option_arg);
@ -995,7 +996,7 @@ public:
break;
case 'f':
{
m_frame_idx = Args::StringToUInt32 (option_arg, LLDB_INVALID_FRAME_ID);
m_frame_idx = StringConvert::ToUInt32 (option_arg, LLDB_INVALID_FRAME_ID);
if (m_frame_idx == LLDB_INVALID_FRAME_ID)
{
error.SetErrorStringWithFormat ("invalid frame index '%s'", option_arg);
@ -1119,7 +1120,7 @@ protected:
return false;
}
line_number = Args::StringToUInt32 (command.GetArgumentAtIndex(0), UINT32_MAX);
line_number = StringConvert::ToUInt32 (command.GetArgumentAtIndex(0), UINT32_MAX);
if (line_number == UINT32_MAX)
{
result.AppendErrorWithFormat ("invalid line number: '%s'.\n", command.GetArgumentAtIndex(0));
@ -1351,7 +1352,7 @@ protected:
return false;
}
uint32_t index_id = Args::StringToUInt32(command.GetArgumentAtIndex(0), 0, 0);
uint32_t index_id = StringConvert::ToUInt32(command.GetArgumentAtIndex(0), 0, 0);
Thread *new_thread = process->GetThreadList().FindThreadByIndexID(index_id).get();
if (new_thread == NULL)
@ -1796,12 +1797,12 @@ public:
return Error("only one source file expected.");
break;
case 'l':
m_line_num = Args::StringToUInt32 (option_arg, 0, 0, &success);
m_line_num = StringConvert::ToUInt32 (option_arg, 0, 0, &success);
if (!success || m_line_num == 0)
return Error("invalid line number: '%s'.", option_arg);
break;
case 'b':
m_line_offset = Args::StringToSInt32 (option_arg, 0, 0, &success);
m_line_offset = StringConvert::ToSInt32 (option_arg, 0, 0, &success);
if (!success)
return Error("invalid line offset: '%s'.", option_arg);
break;
@ -2120,7 +2121,7 @@ public:
}
bool success;
uint32_t thread_plan_idx = Args::StringToUInt32(args.GetArgumentAtIndex(0), 0, 0, &success);
uint32_t thread_plan_idx = StringConvert::ToUInt32(args.GetArgumentAtIndex(0), 0, 0, &success);
if (!success)
{
result.AppendErrorWithFormat("Invalid thread index: \"%s\" - should be unsigned int.",

View File

@ -21,6 +21,7 @@
#include "lldb/Core/StreamString.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectVariable.h"
#include "lldb/Host/StringConvert.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/CommandCompletions.h"
@ -639,7 +640,7 @@ public:
{
case 'i':
{
m_ignore_count = Args::StringToUInt32(option_arg, UINT32_MAX, 0);
m_ignore_count = StringConvert::ToUInt32(option_arg, UINT32_MAX, 0);
if (m_ignore_count == UINT32_MAX)
error.SetErrorStringWithFormat ("invalid ignore count '%s'", option_arg);
}

View File

@ -19,6 +19,7 @@
#include "lldb/Core/Stream.h"
#include "lldb/Core/StreamString.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Host/StringConvert.h"
using namespace lldb;
using namespace lldb_private;
@ -467,7 +468,7 @@ RegisterValue::SetValueFromCString (const RegisterInfo *reg_info, const char *va
case eEncodingUint:
if (byte_size <= sizeof (uint64_t))
{
uint64_t uval64 = Args::StringToUInt64(value_str, UINT64_MAX, 0, &success);
uint64_t uval64 = StringConvert::ToUInt64(value_str, UINT64_MAX, 0, &success);
if (!success)
error.SetErrorStringWithFormat ("'%s' is not a valid unsigned integer string value", value_str);
else if (!Args::UInt64ValueIsValidForByteSize (uval64, byte_size))
@ -488,7 +489,7 @@ RegisterValue::SetValueFromCString (const RegisterInfo *reg_info, const char *va
case eEncodingSint:
if (byte_size <= sizeof (long long))
{
uint64_t sval64 = Args::StringToSInt64(value_str, INT64_MAX, 0, &success);
uint64_t sval64 = StringConvert::ToSInt64(value_str, INT64_MAX, 0, &success);
if (!success)
error.SetErrorStringWithFormat ("'%s' is not a valid signed integer string value", value_str);
else if (!Args::SInt64ValueIsValidForByteSize (sval64, byte_size))

View File

@ -17,6 +17,7 @@
#include "lldb/Core/Stream.h"
#include "lldb/Core/DataExtractor.h"
#include "lldb/Host/Endian.h"
#include "lldb/Host/StringConvert.h"
#include "Plugins/Process/Utility/InstructionUtils.h"
@ -1790,7 +1791,7 @@ Scalar::SetValueFromCString (const char *value_str, Encoding encoding, size_t by
case eEncodingUint:
if (byte_size <= sizeof (unsigned long long))
{
uint64_t uval64 = Args::StringToUInt64(value_str, UINT64_MAX, 0, &success);
uint64_t uval64 = StringConvert::ToUInt64(value_str, UINT64_MAX, 0, &success);
if (!success)
error.SetErrorStringWithFormat ("'%s' is not a valid unsigned integer string value", value_str);
else if (!UIntValueIsValidForSize (uval64, byte_size))
@ -1819,7 +1820,7 @@ Scalar::SetValueFromCString (const char *value_str, Encoding encoding, size_t by
case eEncodingSint:
if (byte_size <= sizeof (long long))
{
uint64_t sval64 = Args::StringToSInt64(value_str, INT64_MAX, 0, &success);
uint64_t sval64 = StringConvert::ToSInt64(value_str, INT64_MAX, 0, &success);
if (!success)
error.SetErrorStringWithFormat ("'%s' is not a valid signed integer string value", value_str);
else if (!SIntValueIsValidForSize (sval64, byte_size))

View File

@ -26,6 +26,7 @@ add_host_subdirectory(common
common/Socket.cpp
common/SocketAddress.cpp
common/SoftwareBreakpoint.cpp
common/StringConvert.cpp
common/Symbols.cpp
common/Terminal.cpp
common/ThisThread.cpp

View File

@ -15,8 +15,8 @@
#include "lldb/Host/FileSystem.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/SocketAddress.h"
#include "lldb/Host/StringConvert.h"
#include "lldb/Host/TimeValue.h"
#include "lldb/Interpreter/Args.h"
#ifdef __ANDROID_NDK__
#include <linux/tcp.h>
@ -533,7 +533,7 @@ Socket::DecodeHostAndPort(llvm::StringRef host_and_port,
if (regex_match.GetMatchAtIndex (host_and_port.data(), 1, host_str) &&
regex_match.GetMatchAtIndex (host_and_port.data(), 2, port_str))
{
port = Args::StringToSInt32 (port_str.c_str(), INT32_MIN);
port = StringConvert::ToSInt32 (port_str.c_str(), INT32_MIN);
if (port != INT32_MIN)
{
if (error_ptr)
@ -547,7 +547,7 @@ Socket::DecodeHostAndPort(llvm::StringRef host_and_port,
// a port with an empty host.
host_str.clear();
port_str.clear();
port = Args::StringToSInt32(host_and_port.data(), INT32_MIN);
port = StringConvert::ToSInt32(host_and_port.data(), INT32_MIN);
if (port != INT32_MIN)
{
port_str = host_and_port;

View File

@ -0,0 +1,93 @@
//===-- StringConvert.cpp ---------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// C Includes
#include <stdlib.h>
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "lldb/Host/StringConvert.h"
namespace lldb_private {
namespace StringConvert {
int32_t
ToSInt32 (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
ToUInt32 (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
ToSInt64 (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
ToUInt64 (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;
}
}
}

View File

@ -19,6 +19,7 @@
#include "lldb/Host/IOObject.h"
#include "lldb/Host/SocketAddress.h"
#include "lldb/Host/Socket.h"
#include "lldb/Host/StringConvert.h"
// C Includes
#include <errno.h>
@ -173,7 +174,7 @@ ConnectionFileDescriptor::Connect(const char *s, Error *error_ptr)
// that is already opened (possibly from a service or other source).
s += strlen("fd://");
bool success = false;
int fd = Args::StringToSInt32(s, -1, 0, &success);
int fd = StringConvert::ToSInt32(s, -1, 0, &success);
if (success)
{

View File

@ -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)
{

View File

@ -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())

View File

@ -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);
}

View File

@ -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)
{

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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;

View File

@ -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:

View File

@ -15,7 +15,7 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "lldb/Interpreter/Args.h"
#include "lldb/Host/StringConvert.h"
#include "lldb/Core/RegularExpression.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/DataFormatters/FormatManager.h"
@ -158,8 +158,8 @@ DynamicRegisterInfo::SetRegisterInfo (const lldb_private::PythonDictionary &dict
regex_match.GetMatchAtIndex(slice_cstr, 2, msbit_str) &&
regex_match.GetMatchAtIndex(slice_cstr, 3, lsbit_str))
{
const uint32_t msbit = Args::StringToUInt32(msbit_str.c_str(), UINT32_MAX);
const uint32_t lsbit = Args::StringToUInt32(lsbit_str.c_str(), UINT32_MAX);
const uint32_t msbit = StringConvert::ToUInt32(msbit_str.c_str(), UINT32_MAX);
const uint32_t lsbit = StringConvert::ToUInt32(lsbit_str.c_str(), UINT32_MAX);
if (msbit != UINT32_MAX && lsbit != UINT32_MAX)
{
if (msbit > lsbit)

View File

@ -26,6 +26,7 @@
#include "lldb/Host/HostInfo.h"
#include "lldb/Host/Pipe.h"
#include "lldb/Host/Socket.h"
#include "lldb/Host/StringConvert.h"
#include "lldb/Host/ThreadLauncher.h"
#include "lldb/Host/TimeValue.h"
#include "lldb/Target/Process.h"
@ -887,7 +888,7 @@ GDBRemoteCommunication::StartDebugserverProcess (const char *hostname,
if (error.Success())
{
assert (num_bytes > 0 && port_cstr[num_bytes-1] == '\0');
out_port = Args::StringToUInt32(port_cstr, 0);
out_port = StringConvert::ToUInt32(port_cstr, 0);
if (log)
log->Printf("GDBRemoteCommunication::%s() debugserver listens %u port", __FUNCTION__, out_port);
}

View File

@ -28,6 +28,7 @@
#include "lldb/Host/Endian.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Host/StringConvert.h"
#include "lldb/Host/TimeValue.h"
#include "lldb/Target/Target.h"
@ -1559,7 +1560,7 @@ GDBRemoteCommunicationClient::GetGDBServerVersion()
size_t dot_pos = value.find('.');
if (dot_pos != std::string::npos)
value[dot_pos] = '\0';
const uint32_t version = Args::StringToUInt32(value.c_str(), UINT32_MAX, 0);
const uint32_t version = StringConvert::ToUInt32(value.c_str(), UINT32_MAX, 0);
if (version != UINT32_MAX)
{
success = true;
@ -1625,14 +1626,14 @@ GDBRemoteCommunicationClient::GetHostInfo (bool force)
if (name.compare("cputype") == 0)
{
// exception type in big endian hex
cpu = Args::StringToUInt32 (value.c_str(), LLDB_INVALID_CPUTYPE, 0);
cpu = StringConvert::ToUInt32 (value.c_str(), LLDB_INVALID_CPUTYPE, 0);
if (cpu != LLDB_INVALID_CPUTYPE)
++num_keys_decoded;
}
else if (name.compare("cpusubtype") == 0)
{
// exception count in big endian hex
sub = Args::StringToUInt32 (value.c_str(), 0, 0);
sub = StringConvert::ToUInt32 (value.c_str(), 0, 0);
if (sub != 0)
++num_keys_decoded;
}
@ -1700,7 +1701,7 @@ GDBRemoteCommunicationClient::GetHostInfo (bool force)
}
else if (name.compare("ptrsize") == 0)
{
pointer_byte_size = Args::StringToUInt32 (value.c_str(), 0, 0);
pointer_byte_size = StringConvert::ToUInt32 (value.c_str(), 0, 0);
if (pointer_byte_size != 0)
++num_keys_decoded;
}
@ -1725,7 +1726,7 @@ GDBRemoteCommunicationClient::GetHostInfo (bool force)
}
else if (name.compare("default_packet_timeout") == 0)
{
m_default_packet_timeout = Args::StringToUInt32(value.c_str(), 0);
m_default_packet_timeout = StringConvert::ToUInt32(value.c_str(), 0);
if (m_default_packet_timeout > 0)
{
SetPacketTimeout(m_default_packet_timeout);
@ -2006,13 +2007,13 @@ GDBRemoteCommunicationClient::GetMemoryRegionInfo (lldb::addr_t addr,
{
if (name.compare ("start") == 0)
{
addr_value = Args::StringToUInt64(value.c_str(), LLDB_INVALID_ADDRESS, 16, &success);
addr_value = StringConvert::ToUInt64(value.c_str(), LLDB_INVALID_ADDRESS, 16, &success);
if (success)
region_info.GetRange().SetRangeBase(addr_value);
}
else if (name.compare ("size") == 0)
{
addr_value = Args::StringToUInt64(value.c_str(), 0, 16, &success);
addr_value = StringConvert::ToUInt64(value.c_str(), 0, 16, &success);
if (success)
region_info.GetRange().SetByteSize (addr_value);
}
@ -2107,7 +2108,7 @@ GDBRemoteCommunicationClient::GetWatchpointSupportInfo (uint32_t &num)
{
if (name.compare ("num") == 0)
{
num = Args::StringToUInt32(value.c_str(), 0, 0);
num = StringConvert::ToUInt32(value.c_str(), 0, 0);
m_num_supported_hardware_watchpoints = num;
}
}
@ -2309,27 +2310,27 @@ GDBRemoteCommunicationClient::DecodeProcessInfoResponse (StringExtractorGDBRemot
{
if (name.compare("pid") == 0)
{
process_info.SetProcessID (Args::StringToUInt32 (value.c_str(), LLDB_INVALID_PROCESS_ID, 0));
process_info.SetProcessID (StringConvert::ToUInt32 (value.c_str(), LLDB_INVALID_PROCESS_ID, 0));
}
else if (name.compare("ppid") == 0)
{
process_info.SetParentProcessID (Args::StringToUInt32 (value.c_str(), LLDB_INVALID_PROCESS_ID, 0));
process_info.SetParentProcessID (StringConvert::ToUInt32 (value.c_str(), LLDB_INVALID_PROCESS_ID, 0));
}
else if (name.compare("uid") == 0)
{
process_info.SetUserID (Args::StringToUInt32 (value.c_str(), UINT32_MAX, 0));
process_info.SetUserID (StringConvert::ToUInt32 (value.c_str(), UINT32_MAX, 0));
}
else if (name.compare("euid") == 0)
{
process_info.SetEffectiveUserID (Args::StringToUInt32 (value.c_str(), UINT32_MAX, 0));
process_info.SetEffectiveUserID (StringConvert::ToUInt32 (value.c_str(), UINT32_MAX, 0));
}
else if (name.compare("gid") == 0)
{
process_info.SetGroupID (Args::StringToUInt32 (value.c_str(), UINT32_MAX, 0));
process_info.SetGroupID (StringConvert::ToUInt32 (value.c_str(), UINT32_MAX, 0));
}
else if (name.compare("egid") == 0)
{
process_info.SetEffectiveGroupID (Args::StringToUInt32 (value.c_str(), UINT32_MAX, 0));
process_info.SetEffectiveGroupID (StringConvert::ToUInt32 (value.c_str(), UINT32_MAX, 0));
}
else if (name.compare("triple") == 0)
{
@ -2351,11 +2352,11 @@ GDBRemoteCommunicationClient::DecodeProcessInfoResponse (StringExtractorGDBRemot
}
else if (name.compare("cputype") == 0)
{
cpu = Args::StringToUInt32 (value.c_str(), LLDB_INVALID_CPUTYPE, 16);
cpu = StringConvert::ToUInt32 (value.c_str(), LLDB_INVALID_CPUTYPE, 16);
}
else if (name.compare("cpusubtype") == 0)
{
sub = Args::StringToUInt32 (value.c_str(), 0, 16);
sub = StringConvert::ToUInt32 (value.c_str(), 0, 16);
}
else if (name.compare("vendor") == 0)
{
@ -2441,13 +2442,13 @@ GDBRemoteCommunicationClient::GetCurrentProcessInfo ()
{
if (name.compare("cputype") == 0)
{
cpu = Args::StringToUInt32 (value.c_str(), LLDB_INVALID_CPUTYPE, 16);
cpu = StringConvert::ToUInt32 (value.c_str(), LLDB_INVALID_CPUTYPE, 16);
if (cpu != LLDB_INVALID_CPUTYPE)
++num_keys_decoded;
}
else if (name.compare("cpusubtype") == 0)
{
sub = Args::StringToUInt32 (value.c_str(), 0, 16);
sub = StringConvert::ToUInt32 (value.c_str(), 0, 16);
if (sub != 0)
++num_keys_decoded;
}
@ -2483,13 +2484,13 @@ GDBRemoteCommunicationClient::GetCurrentProcessInfo ()
}
else if (name.compare("ptrsize") == 0)
{
pointer_byte_size = Args::StringToUInt32 (value.c_str(), 0, 16);
pointer_byte_size = StringConvert::ToUInt32 (value.c_str(), 0, 16);
if (pointer_byte_size != 0)
++num_keys_decoded;
}
else if (name.compare("pid") == 0)
{
pid = Args::StringToUInt64(value.c_str(), 0, 16);
pid = StringConvert::ToUInt64(value.c_str(), 0, 16);
if (pid != LLDB_INVALID_PROCESS_ID)
++num_keys_decoded;
}
@ -2857,9 +2858,9 @@ GDBRemoteCommunicationClient::LaunchGDBserverAndGetPort (lldb::pid_t &pid, const
while (response.GetNameColonValue(name, value))
{
if (name.compare("port") == 0)
port = Args::StringToUInt32(value.c_str(), 0, 0);
port = StringConvert::ToUInt32(value.c_str(), 0, 0);
else if (name.compare("pid") == 0)
pid = Args::StringToUInt64(value.c_str(), LLDB_INVALID_PROCESS_ID, 0);
pid = StringConvert::ToUInt64(value.c_str(), LLDB_INVALID_PROCESS_ID, 0);
}
return port;
}

View File

@ -34,6 +34,7 @@
#include "lldb/Host/FileSystem.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Host/StringConvert.h"
#include "lldb/Host/TimeValue.h"
#include "lldb/Target/FileAction.h"
#include "lldb/Target/Platform.h"
@ -1512,27 +1513,27 @@ GDBRemoteCommunicationServer::Handle_qfProcessInfo (StringExtractorGDBRemote &pa
}
else if (key.compare("pid") == 0)
{
match_info.GetProcessInfo().SetProcessID (Args::StringToUInt32(value.c_str(), LLDB_INVALID_PROCESS_ID, 0, &success));
match_info.GetProcessInfo().SetProcessID (StringConvert::ToUInt32(value.c_str(), LLDB_INVALID_PROCESS_ID, 0, &success));
}
else if (key.compare("parent_pid") == 0)
{
match_info.GetProcessInfo().SetParentProcessID (Args::StringToUInt32(value.c_str(), LLDB_INVALID_PROCESS_ID, 0, &success));
match_info.GetProcessInfo().SetParentProcessID (StringConvert::ToUInt32(value.c_str(), LLDB_INVALID_PROCESS_ID, 0, &success));
}
else if (key.compare("uid") == 0)
{
match_info.GetProcessInfo().SetUserID (Args::StringToUInt32(value.c_str(), UINT32_MAX, 0, &success));
match_info.GetProcessInfo().SetUserID (StringConvert::ToUInt32(value.c_str(), UINT32_MAX, 0, &success));
}
else if (key.compare("gid") == 0)
{
match_info.GetProcessInfo().SetGroupID (Args::StringToUInt32(value.c_str(), UINT32_MAX, 0, &success));
match_info.GetProcessInfo().SetGroupID (StringConvert::ToUInt32(value.c_str(), UINT32_MAX, 0, &success));
}
else if (key.compare("euid") == 0)
{
match_info.GetProcessInfo().SetEffectiveUserID (Args::StringToUInt32(value.c_str(), UINT32_MAX, 0, &success));
match_info.GetProcessInfo().SetEffectiveUserID (StringConvert::ToUInt32(value.c_str(), UINT32_MAX, 0, &success));
}
else if (key.compare("egid") == 0)
{
match_info.GetProcessInfo().SetEffectiveGroupID (Args::StringToUInt32(value.c_str(), UINT32_MAX, 0, &success));
match_info.GetProcessInfo().SetEffectiveGroupID (StringConvert::ToUInt32(value.c_str(), UINT32_MAX, 0, &success));
}
else if (key.compare("all_users") == 0)
{
@ -1627,7 +1628,7 @@ GDBRemoteCommunicationServer::Handle_qSpeedTest (StringExtractorGDBRemote &packe
bool success = packet.GetNameColonValue(key, value);
if (success && key.compare("response_size") == 0)
{
uint32_t response_size = Args::StringToUInt32(value.c_str(), 0, 0, &success);
uint32_t response_size = StringConvert::ToUInt32(value.c_str(), 0, 0, &success);
if (success)
{
if (response_size == 0)
@ -1901,7 +1902,7 @@ GDBRemoteCommunicationServer::Handle_qLaunchGDBServer (StringExtractorGDBRemote
if (name.compare ("host") == 0)
hostname.swap(value);
else if (name.compare ("port") == 0)
port = Args::StringToUInt32(value.c_str(), 0, 0);
port = StringConvert::ToUInt32(value.c_str(), 0, 0);
}
if (port == UINT16_MAX)
port = GetNextAvailablePort();

View File

@ -42,6 +42,7 @@
#include "lldb/Core/Timer.h"
#include "lldb/Core/Value.h"
#include "lldb/Host/HostThread.h"
#include "lldb/Host/StringConvert.h"
#include "lldb/Host/Symbols.h"
#include "lldb/Host/ThreadLauncher.h"
#include "lldb/Host/TimeValue.h"
@ -431,11 +432,11 @@ ProcessGDBRemote::BuildDynamicRegisterInfo (bool force)
}
else if (name.compare("bitsize") == 0)
{
reg_info.byte_size = Args::StringToUInt32(value.c_str(), 0, 0) / CHAR_BIT;
reg_info.byte_size = StringConvert::ToUInt32(value.c_str(), 0, 0) / CHAR_BIT;
}
else if (name.compare("offset") == 0)
{
uint32_t offset = Args::StringToUInt32(value.c_str(), UINT32_MAX, 0);
uint32_t offset = StringConvert::ToUInt32(value.c_str(), UINT32_MAX, 0);
if (reg_offset != offset)
{
reg_offset = offset;
@ -483,11 +484,11 @@ ProcessGDBRemote::BuildDynamicRegisterInfo (bool force)
}
else if (name.compare("gcc") == 0)
{
reg_info.kinds[eRegisterKindGCC] = Args::StringToUInt32(value.c_str(), LLDB_INVALID_REGNUM, 0);
reg_info.kinds[eRegisterKindGCC] = StringConvert::ToUInt32(value.c_str(), LLDB_INVALID_REGNUM, 0);
}
else if (name.compare("dwarf") == 0)
{
reg_info.kinds[eRegisterKindDWARF] = Args::StringToUInt32(value.c_str(), LLDB_INVALID_REGNUM, 0);
reg_info.kinds[eRegisterKindDWARF] = StringConvert::ToUInt32(value.c_str(), LLDB_INVALID_REGNUM, 0);
}
else if (name.compare("generic") == 0)
{
@ -502,7 +503,7 @@ ProcessGDBRemote::BuildDynamicRegisterInfo (bool force)
value_pair = value_pair.second.split(',');
if (!value_pair.first.empty())
{
uint32_t reg = Args::StringToUInt32 (value_pair.first.str().c_str(), LLDB_INVALID_REGNUM, 16);
uint32_t reg = StringConvert::ToUInt32 (value_pair.first.str().c_str(), LLDB_INVALID_REGNUM, 16);
if (reg != LLDB_INVALID_REGNUM)
value_regs.push_back (reg);
}
@ -517,7 +518,7 @@ ProcessGDBRemote::BuildDynamicRegisterInfo (bool force)
value_pair = value_pair.second.split(',');
if (!value_pair.first.empty())
{
uint32_t reg = Args::StringToUInt32 (value_pair.first.str().c_str(), LLDB_INVALID_REGNUM, 16);
uint32_t reg = StringConvert::ToUInt32 (value_pair.first.str().c_str(), LLDB_INVALID_REGNUM, 16);
if (reg != LLDB_INVALID_REGNUM)
invalidate_regs.push_back (reg);
}
@ -1656,17 +1657,17 @@ ProcessGDBRemote::SetThreadStopInfo (StringExtractor& stop_packet)
if (name.compare("metype") == 0)
{
// exception type in big endian hex
exc_type = Args::StringToUInt32 (value.c_str(), 0, 16);
exc_type = StringConvert::ToUInt32 (value.c_str(), 0, 16);
}
else if (name.compare("medata") == 0)
{
// exception data in big endian hex
exc_data.push_back(Args::StringToUInt64 (value.c_str(), 0, 16));
exc_data.push_back(StringConvert::ToUInt64 (value.c_str(), 0, 16));
}
else if (name.compare("thread") == 0)
{
// thread in big endian hex
lldb::tid_t tid = Args::StringToUInt64 (value.c_str(), LLDB_INVALID_THREAD_ID, 16);
lldb::tid_t tid = StringConvert::ToUInt64 (value.c_str(), LLDB_INVALID_THREAD_ID, 16);
// m_thread_list_real does have its own mutex, but we need to
// hold onto the mutex between the call to m_thread_list_real.FindThreadByID(...)
// and the m_thread_list_real.AddThread(...) so it doesn't change on us
@ -1702,12 +1703,12 @@ ProcessGDBRemote::SetThreadStopInfo (StringExtractor& stop_packet)
{
value[comma_pos] = '\0';
// thread in big endian hex
tid = Args::StringToUInt64 (value.c_str(), LLDB_INVALID_THREAD_ID, 16);
tid = StringConvert::ToUInt64 (value.c_str(), LLDB_INVALID_THREAD_ID, 16);
if (tid != LLDB_INVALID_THREAD_ID)
m_thread_ids.push_back (tid);
value.erase(0, comma_pos + 1);
}
tid = Args::StringToUInt64 (value.c_str(), LLDB_INVALID_THREAD_ID, 16);
tid = StringConvert::ToUInt64 (value.c_str(), LLDB_INVALID_THREAD_ID, 16);
if (tid != LLDB_INVALID_THREAD_ID)
m_thread_ids.push_back (tid);
}
@ -1726,7 +1727,7 @@ ProcessGDBRemote::SetThreadStopInfo (StringExtractor& stop_packet)
}
else if (name.compare("qaddr") == 0)
{
thread_dispatch_qaddr = Args::StringToUInt64 (value.c_str(), 0, 16);
thread_dispatch_qaddr = StringConvert::ToUInt64 (value.c_str(), 0, 16);
}
else if (name.compare("reason") == 0)
{
@ -1747,7 +1748,7 @@ ProcessGDBRemote::SetThreadStopInfo (StringExtractor& stop_packet)
// so it won't have to go and read it.
if (gdb_thread)
{
uint32_t reg = Args::StringToUInt32 (name.c_str(), UINT32_MAX, 16);
uint32_t reg = StringConvert::ToUInt32 (name.c_str(), UINT32_MAX, 16);
if (reg != UINT32_MAX)
{

View File

@ -13,6 +13,7 @@
#include "lldb/Core/Module.h"
#include "lldb/Core/Stream.h"
#include "lldb/Core/Timer.h"
#include "lldb/Host/StringConvert.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/LineTable.h"
#include "lldb/Symbol/ObjectFile.h"
@ -992,11 +993,11 @@ DWARFCompileUnit::ParseProducerInfo ()
{
std::string str;
if (regex_match.GetMatchAtIndex (producer_cstr, 1, str))
m_producer_version_major = Args::StringToUInt32(str.c_str(), UINT32_MAX, 10);
m_producer_version_major = StringConvert::ToUInt32(str.c_str(), UINT32_MAX, 10);
if (regex_match.GetMatchAtIndex (producer_cstr, 2, str))
m_producer_version_minor = Args::StringToUInt32(str.c_str(), UINT32_MAX, 10);
m_producer_version_minor = StringConvert::ToUInt32(str.c_str(), UINT32_MAX, 10);
if (regex_match.GetMatchAtIndex (producer_cstr, 3, str))
m_producer_version_update = Args::StringToUInt32(str.c_str(), UINT32_MAX, 10);
m_producer_version_update = StringConvert::ToUInt32(str.c_str(), UINT32_MAX, 10);
}
m_producer = eProducerClang;
}

View File

@ -13,7 +13,7 @@
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Host/Host.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Host/StringConvert.h"
#include "lldb/Symbol/Block.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/CompileUnit.h"
@ -778,12 +778,12 @@ SymbolContextSpecifier::AddSpecification (const char *spec_string, Specification
m_type |= eFileSpecified;
break;
case eLineStartSpecified:
m_start_line = Args::StringToSInt32(spec_string, 0, 0, &return_value);
m_start_line = StringConvert::ToSInt32(spec_string, 0, 0, &return_value);
if (return_value)
m_type |= eLineStartSpecified;
break;
case eLineEndSpecified:
m_end_line = Args::StringToSInt32(spec_string, 0, 0, &return_value);
m_end_line = StringConvert::ToSInt32(spec_string, 0, 0, &return_value);
if (return_value)
m_type |= eLineEndSpecified;
break;

View File

@ -13,7 +13,7 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "lldb/Interpreter/Args.h"
#include "lldb/Host/StringConvert.h"
using namespace lldb_private;
@ -148,7 +148,7 @@ UnixSignals::GetSignalNumberFromName (const char *name) const
return pos->first;
}
const int32_t signo = Args::StringToSInt32(name, LLDB_INVALID_SIGNAL_NUMBER, 0);
const int32_t signo = StringConvert::ToSInt32(name, LLDB_INVALID_SIGNAL_NUMBER, 0);
if (signo != LLDB_INVALID_SIGNAL_NUMBER)
return signo;
return LLDB_INVALID_SIGNAL_NUMBER;

View File

@ -34,6 +34,7 @@
#include "lldb/Host/Pipe.h"
#include "lldb/Host/OptionParser.h"
#include "lldb/Host/Socket.h"
#include "lldb/Host/StringConvert.h"
#include "lldb/Host/ThreadLauncher.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
@ -347,7 +348,7 @@ ConnectToRemote (GDBRemoteCommunicationServer &gdb_server, bool reverse_connect,
{
connection_host = final_host_and_port.substr (0, colon_pos);
connection_port = final_host_and_port.substr (colon_pos + 1);
connection_portno = Args::StringToUInt32 (connection_port.c_str (), 0);
connection_portno = StringConvert::ToUInt32 (connection_port.c_str (), 0);
}
else
{