diff options
author | Chris Lattner <sabre@nondot.org> | 2010-06-08 16:52:24 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-06-08 16:52:24 +0000 |
commit | 30fdc8d841c9d24ac5f3d452b6ece84ee0ac991c (patch) | |
tree | f70013106f6a461a14abcd71c65f48a95a2979a6 /lldb/source/Utility/StringExtractorGDBRemote.cpp | |
parent | 312c4c799da215b337f790fda330f70c4aa757cf (diff) | |
download | bcm5719-llvm-30fdc8d841c9d24ac5f3d452b6ece84ee0ac991c.tar.gz bcm5719-llvm-30fdc8d841c9d24ac5f3d452b6ece84ee0ac991c.zip |
Initial checkin of lldb code from internal Apple repo.
llvm-svn: 105619
Diffstat (limited to 'lldb/source/Utility/StringExtractorGDBRemote.cpp')
-rw-r--r-- | lldb/source/Utility/StringExtractorGDBRemote.cpp | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/lldb/source/Utility/StringExtractorGDBRemote.cpp b/lldb/source/Utility/StringExtractorGDBRemote.cpp new file mode 100644 index 00000000000..f7dcc4181f3 --- /dev/null +++ b/lldb/source/Utility/StringExtractorGDBRemote.cpp @@ -0,0 +1,89 @@ +//===-- StringExtractorGDBRemote.cpp ----------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "StringExtractorGDBRemote.h" + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes + + + +StringExtractorGDBRemote::Type +StringExtractorGDBRemote::GetType () const +{ + if (m_packet.empty()) + return eUnsupported; + + switch (m_packet[0]) + { + case 'E': + if (m_packet.size() == 3 && + isxdigit(m_packet[1]) && + isxdigit(m_packet[2])) + return eError; + break; + + case 'O': + if (m_packet.size() == 2 && m_packet[1] == 'K') + return eOK; + break; + + case '+': + if (m_packet.size() == 1) + return eAck; + break; + + case '-': + if (m_packet.size() == 1) + return eNack; + break; + } + return eResponse; +} + +bool +StringExtractorGDBRemote::IsOKPacket() const +{ + return GetType () == eOK; +} + + +bool +StringExtractorGDBRemote::IsUnsupportedPacket() const +{ + return GetType () == eUnsupported; +} + +bool +StringExtractorGDBRemote::IsNormalPacket() const +{ + return GetType () == eResponse; +} + +bool +StringExtractorGDBRemote::IsErrorPacket() const +{ + return GetType () == eError && + m_packet.size() == 3 && + isxdigit(m_packet[1]) && + isxdigit(m_packet[2]); +} + +uint8_t +StringExtractorGDBRemote::GetError () +{ + if (GetType() == eError) + { + SetFilePos(1); + return GetHexU8(255); + } + return 0; +} |