summaryrefslogtreecommitdiffstats
path: root/lldb/source/Utility/StringExtractor.cpp
diff options
context:
space:
mode:
authorDaniel Malea <daniel.malea@intel.com>2013-08-26 23:57:52 +0000
committerDaniel Malea <daniel.malea@intel.com>2013-08-26 23:57:52 +0000
commite0f8f574c7f41f5b61ec01aa290d52fc55a3f3c9 (patch)
treec519b347e7428c3b28956c9165b661b11b468470 /lldb/source/Utility/StringExtractor.cpp
parent6b16b43ef95d2ffbad889601f26786ecdbd914b4 (diff)
downloadbcm5719-llvm-e0f8f574c7f41f5b61ec01aa290d52fc55a3f3c9.tar.gz
bcm5719-llvm-e0f8f574c7f41f5b61ec01aa290d52fc55a3f3c9.zip
merge lldb-platform-work branch (and assorted fixes) into trunk
Summary: This merge brings in the improved 'platform' command that knows how to interface with remote machines; that is, query OS/kernel information, push and pull files, run shell commands, etc... and implementation for the new communication packets that back that interface, at least on Darwin based operating systems via the POSIXPlatform class. Linux support is coming soon. Verified the test suite runs cleanly on Linux (x86_64), build OK on Mac OS X Mountain Lion. Additional improvements (not in the source SVN branch 'lldb-platform-work'): - cmake build scripts for lldb-platform - cleanup test suite - documentation stub for qPlatform_RunCommand - use log class instead of printf() directly - reverted work-in-progress-looking changes from test/types/TestAbstract.py that work towards running the test suite remotely. - add new logging category 'platform' Reviewers: Matt Kopec, Greg Clayton Review: http://llvm-reviews.chandlerc.com/D1493 llvm-svn: 189295
Diffstat (limited to 'lldb/source/Utility/StringExtractor.cpp')
-rw-r--r--lldb/source/Utility/StringExtractor.cpp78
1 files changed, 75 insertions, 3 deletions
diff --git a/lldb/source/Utility/StringExtractor.cpp b/lldb/source/Utility/StringExtractor.cpp
index 2f4bcecda8f..d4ce470d56f 100644
--- a/lldb/source/Utility/StringExtractor.cpp
+++ b/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)
{
OpenPOWER on IntegriCloud