Revert r280137 and 280139 and subsequent build fixes

The rewrite of StringExtractor::GetHexMaxU32 changes functionality in a way which makes
lldb-server crash. The crash (assert) happens when parsing the "qRegisterInfo0" packet, because
the function tries to drop_front more bytes than the packet contains. It's not clear to me
whether we should consider this a bug in the caller or the callee, but it any case, it worked
before, so I am reverting this until we can figure out what the proper interface should be.

llvm-svn: 280207
diff --git a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
index 17f136c..49d57c0 100644
--- a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
+++ b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
@@ -1620,7 +1620,7 @@
 {
     memory_region_info.Clear();
 
-    StringExtractor line_extractor (maps_line);
+    StringExtractor line_extractor (maps_line.c_str ());
 
     // Format: {address_start_hex}-{address_end_hex} perms offset  dev   inode   pathname
     // perms: rwxp   (letter is present if set, '-' if not, final character is p=private, s=shared).
@@ -1687,7 +1687,9 @@
     line_extractor.GetU64(0, 10);          // Read the inode number
 
     line_extractor.SkipSpaces();
-    memory_region_info.SetName(line_extractor.Peek().str().c_str());
+    const char* name = line_extractor.Peek();
+    if (name)
+        memory_region_info.SetName(name);
 
     return Error ();
 }
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
index 40279fe..555ae46 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -3240,7 +3240,7 @@
         uint32_t retcode = response.GetHexMaxU32(false, UINT32_MAX);
         if (retcode == UINT32_MAX)
             return retcode;
-        const char next = (response.GetBytesLeft() ? response.PeekChar() : 0);
+        const char next = (response.Peek() ? *response.Peek() : 0);
         if (next == ',')
             return 0;
         if (next == ';')
@@ -3428,7 +3428,7 @@
             return false;
         if (response.GetChar() != ',')
             return false;
-        if (response.GetBytesLeft() && response.PeekChar() == 'x')
+        if (response.Peek() && *response.Peek() == 'x')
             return false;
         low = response.GetHexMaxU64(false, UINT64_MAX);
         high = response.GetHexMaxU64(false, UINT64_MAX);
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
index 5641b22..3361ffa 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
@@ -966,7 +966,7 @@
     {
         std::string str;
         packet.GetHexByteString(str);
-        m_process_launch_info.GetEnvironmentEntries().AppendArgument(str);
+        m_process_launch_info.GetEnvironmentEntries().AppendArgument(str.c_str());
         return SendOKResponse();
     }
     return SendErrorResponse(12);
@@ -979,7 +979,8 @@
     const uint32_t bytes_left = packet.GetBytesLeft();
     if (bytes_left > 0)
     {
-        ArchSpec arch_spec(packet.Peek(), nullptr);
+        const char* arch_triple = packet.Peek();
+        ArchSpec arch_spec(arch_triple,NULL);
         m_process_launch_info.SetArchitecture(arch_spec);
         return SendOKResponse();
     }
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
index 44566c8..81c54ed 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -1186,7 +1186,7 @@
     if (packet.GetBytesLeft () > 0)
     {
         // FIXME add continue at address support for $C{signo}[;{continue-address}].
-        if (packet.PeekChar() == ';')
+        if (*packet.Peek () == ';')
             return SendUnimplementedResponse (packet.GetStringRef().c_str());
         else
             return SendIllFormedResponse (packet, "unexpected content after $C{signal-number}");
@@ -1257,8 +1257,7 @@
     if (has_continue_address)
     {
         if (log)
-            log->Printf("GDBRemoteCommunicationServerLLGS::%s not implemented for c{address} variant [%s remains]",
-                        __FUNCTION__, packet.Peek().str().c_str());
+            log->Printf ("GDBRemoteCommunicationServerLLGS::%s not implemented for c{address} variant [%s remains]", __FUNCTION__, packet.Peek ());
         return SendUnimplementedResponse (packet.GetStringRef().c_str());
     }
 
@@ -1319,13 +1318,13 @@
     }
 
     // Check if this is all continue (no options or ";c").
-    if (packet.Peek() == ";c")
+    if (::strcmp (packet.Peek (), ";c") == 0)
     {
         // Move past the ';', then do a simple 'c'.
         packet.SetFilePos (packet.GetFilePos () + 1);
         return Handle_c (packet);
     }
-    else if (packet.Peek() == ";s")
+    else if (::strcmp (packet.Peek (), ";s") == 0)
     {
         // Move past the ';', then do a simple 's'.
         packet.SetFilePos (packet.GetFilePos () + 1);
@@ -1342,7 +1341,7 @@
 
     ResumeActionList thread_actions;
 
-    while (packet.GetBytesLeft() && packet.PeekChar() == ';')
+    while (packet.GetBytesLeft () && *packet.Peek () == ';')
     {
         // Skip the semi-colon.
         packet.GetChar ();
@@ -1384,7 +1383,7 @@
         }
 
         // Parse out optional :{thread-id} value.
-        if (packet.GetBytesLeft() && packet.PeekChar() == ':')
+        if (packet.GetBytesLeft () && (*packet.Peek () == ':'))
         {
             // Consume the separator.
             packet.GetChar ();
@@ -2927,7 +2926,7 @@
         return thread_sp;
 
     // Parse out thread: portion.
-    if (packet.Peek().startswith("thread:"))
+    if (strncmp (packet.Peek (), "thread:", strlen("thread:")) != 0)
     {
         if (log)
             log->Printf ("GDBRemoteCommunicationServerLLGS::%s gdb-remote parse error: expected 'thread:' but not found, packet contents = '%s'", __FUNCTION__, packet.GetStringRef ().c_str ());