summaryrefslogtreecommitdiffstats
path: root/contrib/llvm/tools/lldb/source/Utility
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm/tools/lldb/source/Utility')
-rw-r--r--contrib/llvm/tools/lldb/source/Utility/PseudoTerminal.cpp15
-rw-r--r--contrib/llvm/tools/lldb/source/Utility/RefCounter.cpp25
-rw-r--r--contrib/llvm/tools/lldb/source/Utility/SharingPtr.cpp12
-rw-r--r--contrib/llvm/tools/lldb/source/Utility/StringExtractor.cpp78
-rw-r--r--contrib/llvm/tools/lldb/source/Utility/StringExtractor.h13
-rw-r--r--contrib/llvm/tools/lldb/source/Utility/StringExtractorGDBRemote.cpp45
-rw-r--r--contrib/llvm/tools/lldb/source/Utility/StringExtractorGDBRemote.h19
7 files changed, 174 insertions, 33 deletions
diff --git a/contrib/llvm/tools/lldb/source/Utility/PseudoTerminal.cpp b/contrib/llvm/tools/lldb/source/Utility/PseudoTerminal.cpp
index e4b444c..98d581d 100644
--- a/contrib/llvm/tools/lldb/source/Utility/PseudoTerminal.cpp
+++ b/contrib/llvm/tools/lldb/source/Utility/PseudoTerminal.cpp
@@ -17,6 +17,21 @@
#include <sys/ioctl.h>
#endif
+#ifdef _WIN32
+#include "lldb/Host/windows/win32.h"
+// empty functions
+int posix_openpt(int flag) { return 0; }
+
+int strerror_r(int errnum, char *buf, size_t buflen) { return 0; }
+
+int unlockpt(int fd) { return 0; }
+int grantpt(int fd) { return 0; }
+char *ptsname(int fd) { return 0; }
+
+pid_t fork(void) { return 0; }
+pid_t setsid(void) { return 0; }
+#endif
+
using namespace lldb_utility;
//----------------------------------------------------------------------
diff --git a/contrib/llvm/tools/lldb/source/Utility/RefCounter.cpp b/contrib/llvm/tools/lldb/source/Utility/RefCounter.cpp
deleted file mode 100644
index c3acedd..0000000
--- a/contrib/llvm/tools/lldb/source/Utility/RefCounter.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-//===---------------------RefCounter.cpp ------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "lldb/Utility/RefCounter.h"
-
-namespace lldb_utility {
-
-RefCounter::RefCounter(RefCounter::value_type* ctr):
-m_counter(ctr)
-{
- increment(m_counter);
-}
-
-RefCounter::~RefCounter()
-{
- decrement(m_counter);
-}
-
-} // namespace lldb_utility
diff --git a/contrib/llvm/tools/lldb/source/Utility/SharingPtr.cpp b/contrib/llvm/tools/lldb/source/Utility/SharingPtr.cpp
index f64d7e3..be237ce 100644
--- a/contrib/llvm/tools/lldb/source/Utility/SharingPtr.cpp
+++ b/contrib/llvm/tools/lldb/source/Utility/SharingPtr.cpp
@@ -138,13 +138,21 @@ namespace imp
void
shared_count::add_shared()
{
- increment(shared_owners_);
+#ifdef _MSC_VER
+ _InterlockedIncrement(&shared_owners_);
+#else
+ ++shared_owners_;
+#endif
}
void
shared_count::release_shared()
{
- if (decrement(shared_owners_) == -1)
+#ifdef _MSC_VER
+ if (_InterlockedDecrement(&shared_owners_) == -1)
+#else
+ if (--shared_owners_ == -1)
+#endif
{
on_zero_shared();
delete this;
diff --git a/contrib/llvm/tools/lldb/source/Utility/StringExtractor.cpp b/contrib/llvm/tools/lldb/source/Utility/StringExtractor.cpp
index 2f4bcec..d4ce470 100644
--- a/contrib/llvm/tools/lldb/source/Utility/StringExtractor.cpp
+++ b/contrib/llvm/tools/lldb/source/Utility/StringExtractor.cpp
@@ -168,10 +168,68 @@ StringExtractor::GetU32 (uint32_t fail_value, int base)
{
char *end = NULL;
const char *start = m_packet.c_str();
- const char *uint_cstr = start + m_index;
- uint32_t result = ::strtoul (uint_cstr, &end, base);
+ const char *cstr = start + m_index;
+ uint32_t result = ::strtoul (cstr, &end, base);
- if (end && end != uint_cstr)
+ if (end && end != cstr)
+ {
+ m_index = end - start;
+ return result;
+ }
+ }
+ return fail_value;
+}
+
+int32_t
+StringExtractor::GetS32 (int32_t fail_value, int base)
+{
+ if (m_index < m_packet.size())
+ {
+ char *end = NULL;
+ const char *start = m_packet.c_str();
+ const char *cstr = start + m_index;
+ int32_t result = ::strtol (cstr, &end, base);
+
+ if (end && end != cstr)
+ {
+ m_index = end - start;
+ return result;
+ }
+ }
+ return fail_value;
+}
+
+
+uint64_t
+StringExtractor::GetU64 (uint64_t fail_value, int base)
+{
+ if (m_index < m_packet.size())
+ {
+ char *end = NULL;
+ const char *start = m_packet.c_str();
+ const char *cstr = start + m_index;
+ uint64_t result = ::strtoull (cstr, &end, base);
+
+ if (end && end != cstr)
+ {
+ m_index = end - start;
+ return result;
+ }
+ }
+ return fail_value;
+}
+
+int64_t
+StringExtractor::GetS64 (int64_t fail_value, int base)
+{
+ if (m_index < m_packet.size())
+ {
+ char *end = NULL;
+ const char *start = m_packet.c_str();
+ const char *cstr = start + m_index;
+ int64_t result = ::strtoll (cstr, &end, base);
+
+ if (end && end != cstr)
{
m_index = end - start;
return result;
@@ -371,6 +429,20 @@ StringExtractor::GetHexByteString (std::string &str)
return str.size();
}
+size_t
+StringExtractor::GetHexByteStringTerminatedBy (std::string &str,
+ char terminator)
+{
+ str.clear();
+ char ch;
+ while ((ch = GetHexU8(0,false)) != '\0')
+ str.append(1, ch);
+ if (Peek() && *Peek() == terminator)
+ return str.size();
+ str.clear();
+ return str.size();
+}
+
bool
StringExtractor::GetNameColonValue (std::string &name, std::string &value)
{
diff --git a/contrib/llvm/tools/lldb/source/Utility/StringExtractor.h b/contrib/llvm/tools/lldb/source/Utility/StringExtractor.h
index 0ded310..2aab3b0 100644
--- a/contrib/llvm/tools/lldb/source/Utility/StringExtractor.h
+++ b/contrib/llvm/tools/lldb/source/Utility/StringExtractor.h
@@ -101,9 +101,18 @@ public:
bool
GetNameColonValue (std::string &name, std::string &value);
+ int32_t
+ GetS32 (int32_t fail_value, int base = 0);
+
uint32_t
GetU32 (uint32_t fail_value, int base = 0);
+ int64_t
+ GetS64 (int64_t fail_value, int base = 0);
+
+ uint64_t
+ GetU64 (uint64_t fail_value, int base = 0);
+
uint32_t
GetHexMaxU32 (bool little_endian, uint32_t fail_value);
@@ -119,6 +128,10 @@ public:
size_t
GetHexByteString (std::string &str);
+ size_t
+ GetHexByteStringTerminatedBy (std::string &str,
+ char terminator);
+
const char *
Peek ()
{
diff --git a/contrib/llvm/tools/lldb/source/Utility/StringExtractorGDBRemote.cpp b/contrib/llvm/tools/lldb/source/Utility/StringExtractorGDBRemote.cpp
index 7e06a0f..6e32481 100644
--- a/contrib/llvm/tools/lldb/source/Utility/StringExtractorGDBRemote.cpp
+++ b/contrib/llvm/tools/lldb/source/Utility/StringExtractorGDBRemote.cpp
@@ -94,6 +94,9 @@ StringExtractorGDBRemote::GetServerPacketType () const
else if (PACKET_STARTS_WITH ("QSetSTDERR:")) return eServerPacketType_QSetSTDERR;
else if (PACKET_STARTS_WITH ("QSetWorkingDir:")) return eServerPacketType_QSetWorkingDir;
break;
+ case 'L':
+ if (PACKET_STARTS_WITH ("QLaunchArch:")) return eServerPacketType_QLaunchArch;
+ break;
}
break;
@@ -120,14 +123,21 @@ StringExtractorGDBRemote::GetServerPacketType () const
if (PACKET_MATCHES ("qHostInfo")) return eServerPacketType_qHostInfo;
break;
+ case 'K':
+ if (PACKET_STARTS_WITH ("qKillSpawnedProcess")) return eServerPacketType_qKillSpawnedProcess;
+ break;
+
case 'L':
- if (PACKET_MATCHES ("qLaunchGDBServer")) return eServerPacketType_qLaunchGDBServer;
+ if (PACKET_STARTS_WITH ("qLaunchGDBServer")) return eServerPacketType_qLaunchGDBServer;
if (PACKET_MATCHES ("qLaunchSuccess")) return eServerPacketType_qLaunchSuccess;
break;
case 'P':
- if (PACKET_STARTS_WITH ("qProcessInfoPID:")) return eServerPacketType_qProcessInfoPID;
+ if (PACKET_STARTS_WITH ("qProcessInfoPID:")) return eServerPacketType_qProcessInfoPID;
+ if (PACKET_STARTS_WITH ("qPlatform_RunCommand:")) return eServerPacketType_qPlatform_RunCommand;
+ if (PACKET_STARTS_WITH ("qPlatform_IO_MkDir:")) return eServerPacketType_qPlatform_IO_MkDir;
break;
+
case 'S':
if (PACKET_STARTS_WITH ("qSpeedTest:")) return eServerPacketType_qSpeedTest;
@@ -138,6 +148,21 @@ StringExtractorGDBRemote::GetServerPacketType () const
break;
}
break;
+ case 'v':
+ if (PACKET_STARTS_WITH("vFile:"))
+ {
+ if (PACKET_STARTS_WITH("vFile:open:")) return eServerPacketType_vFile_Open;
+ else if (PACKET_STARTS_WITH("vFile:close:")) return eServerPacketType_vFile_Close;
+ else if (PACKET_STARTS_WITH("vFile:pread")) return eServerPacketType_vFile_pRead;
+ else if (PACKET_STARTS_WITH("vFile:pwrite")) return eServerPacketType_vFile_pWrite;
+ else if (PACKET_STARTS_WITH("vFile:size")) return eServerPacketType_vFile_Size;
+ else if (PACKET_STARTS_WITH("vFile:exists")) return eServerPacketType_vFile_Exists;
+ else if (PACKET_STARTS_WITH("vFile:stat")) return eServerPacketType_vFile_Stat;
+ else if (PACKET_STARTS_WITH("vFile:mode")) return eServerPacketType_vFile_Mode;
+ else if (PACKET_STARTS_WITH("vFile:MD5")) return eServerPacketType_vFile_MD5;
+
+ }
+ break;
}
return eServerPacketType_unimplemented;
}
@@ -180,3 +205,19 @@ StringExtractorGDBRemote::GetError ()
}
return 0;
}
+
+size_t
+StringExtractorGDBRemote::GetEscapedBinaryData (std::string &str)
+{
+ str.clear();
+ char ch;
+ while (GetBytesLeft())
+ {
+ ch = GetChar();
+ if (ch == 0x7d)
+ ch = (GetChar() ^ 0x20);
+ str.append(1,ch);
+ }
+ return str.size();
+}
+
diff --git a/contrib/llvm/tools/lldb/source/Utility/StringExtractorGDBRemote.h b/contrib/llvm/tools/lldb/source/Utility/StringExtractorGDBRemote.h
index 5a24d89..fe500ec 100644
--- a/contrib/llvm/tools/lldb/source/Utility/StringExtractorGDBRemote.h
+++ b/contrib/llvm/tools/lldb/source/Utility/StringExtractorGDBRemote.h
@@ -53,17 +53,30 @@ public:
eServerPacketType_qGroupName,
eServerPacketType_qHostInfo,
eServerPacketType_qLaunchGDBServer,
+ eServerPacketType_qKillSpawnedProcess,
eServerPacketType_qLaunchSuccess,
eServerPacketType_qProcessInfoPID,
eServerPacketType_qSpeedTest,
eServerPacketType_qUserName,
eServerPacketType_QEnvironment,
+ eServerPacketType_QLaunchArch,
eServerPacketType_QSetDisableASLR,
eServerPacketType_QSetSTDIN,
eServerPacketType_QSetSTDOUT,
eServerPacketType_QSetSTDERR,
eServerPacketType_QSetWorkingDir,
- eServerPacketType_QStartNoAckMode
+ eServerPacketType_QStartNoAckMode,
+ eServerPacketType_qPlatform_RunCommand,
+ eServerPacketType_qPlatform_IO_MkDir,
+ eServerPacketType_vFile_Open,
+ eServerPacketType_vFile_Close,
+ eServerPacketType_vFile_pRead,
+ eServerPacketType_vFile_pWrite,
+ eServerPacketType_vFile_Size,
+ eServerPacketType_vFile_Mode,
+ eServerPacketType_vFile_Exists,
+ eServerPacketType_vFile_MD5,
+ eServerPacketType_vFile_Stat
};
ServerPacketType
@@ -98,6 +111,10 @@ public:
// digits. Otherwise the error encoded in XX is returned.
uint8_t
GetError();
+
+ size_t
+ GetEscapedBinaryData (std::string &str);
+
};
#endif // utility_StringExtractorGDBRemote_h_
OpenPOWER on IntegriCloud