[lldb] Move StringConvert inside debugserver
The StringConvert API is no longer used anywhere but in debugserver. Since debugserver does not use LLVM API, we cannot replace it with llvm::to_integer() and llvm::to_float() there. Let's just move the sources into debugserver. Differential Revision: https://reviews.llvm.org/D110478
This commit is contained in:
1 parent
b1695c2eb8
commit
9da2fa277e
6 files changed
+8
-56
No files matched your search
@@ -48,7 +48,6 @@ module lldb_Host {
|
||||
module SafeMachO { header "Host/SafeMachO.h" export * }
|
||||
module SocketAddress { header "Host/SocketAddress.h" export * }
|
||||
module Socket { header "Host/Socket.h" export * }
|
||||
module StringConvert { textual header "Host/StringConvert.h" export * }
|
||||
module Terminal { header "Host/Terminal.h" export * }
|
||||
module ThreadLauncher { header "Host/ThreadLauncher.h" export * }
|
||||
module Time { header "Host/Time.h" export * }
|
||||
|
||||
@@ -37,7 +37,6 @@ add_host_subdirectory(common
|
||||
common/PseudoTerminal.cpp
|
||||
common/SocketAddress.cpp
|
||||
common/Socket.cpp
|
||||
common/StringConvert.cpp
|
||||
common/TCPSocket.cpp
|
||||
common/Terminal.cpp
|
||||
common/ThreadLauncher.cpp
|
||||
|
||||
@@ -206,8 +206,8 @@ set(lldbDebugserverCommonSources
|
||||
DNBThreadResumeActions.cpp
|
||||
JSON.cpp
|
||||
StdStringExtractor.cpp
|
||||
StringConvert.cpp
|
||||
# JSON reader depends on the following LLDB-common files
|
||||
${LLDB_SOURCE_DIR}/source/Host/common/StringConvert.cpp
|
||||
${LLDB_SOURCE_DIR}/source/Host/common/SocketAddress.cpp
|
||||
# end JSON reader dependencies
|
||||
libdebugserver.cpp
|
||||
|
||||
@@ -13,12 +13,10 @@
|
||||
#include <climits>
|
||||
|
||||
// C++ includes
|
||||
#include "lldb/Host/StringConvert.h"
|
||||
#include "StringConvert.h"
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
|
||||
using namespace lldb_private;
|
||||
|
||||
std::string JSONString::json_string_quote_metachars(const std::string &s) {
|
||||
if (s.find('"') == std::string::npos)
|
||||
return s;
|
||||
|
||||
+3
-36
@@ -8,43 +8,10 @@
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "lldb/Host/StringConvert.h"
|
||||
#include "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]) {
|
||||
@@ -91,5 +58,5 @@ double ToDouble(const char *s, double fail_value, bool *success_ptr) {
|
||||
*success_ptr = false;
|
||||
return fail_value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace StringConvert
|
||||
+3
-14
@@ -6,24 +6,13 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLDB_HOST_STRINGCONVERT_H
|
||||
#define LLDB_HOST_STRINGCONVERT_H
|
||||
#ifndef LLDB_TOOLS_DEBUGSERVER_SOURCE_STRINGCONVERT_H
|
||||
#define LLDB_TOOLS_DEBUGSERVER_SOURCE_STRINGCONVERT_H
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace lldb_private {
|
||||
|
||||
namespace StringConvert {
|
||||
|
||||
/// \namespace StringConvert StringConvert.h "lldb/Host/StringConvert.h"
|
||||
/// 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);
|
||||
|
||||
@@ -32,7 +21,7 @@ uint64_t ToUInt64(const char *s, uint64_t fail_value = 0, int base = 0,
|
||||
|
||||
double ToDouble(const char *s, double fail_value = 0.0,
|
||||
bool *success_ptr = nullptr);
|
||||
|
||||
} // namespace StringConvert
|
||||
} // namespace lldb_private
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user