[Lldb-commits] [lldb] r154239 - in /lldb/trunk/source/Utility: StringExtractor.cpp StringExtractor.h
Greg Clayton
gclayton at apple.com
Fri Apr 6 17:42:54 PDT 2012
Author: gclayton
Date: Fri Apr 6 19:42:53 2012
New Revision: 154239
URL: http://llvm.org/viewvc/llvm-project?rev=154239&view=rev
Log:
Removed redundant isxdigit checks and added the ability to GetHexU8() so it can extract an 8 bit hex value if one is available. It will set EOF if "set_eof_on_fail" is true or if out of data. This allows a string decoder to grab a string without losing the last part of the packet with a packet like "414243,abc" (it can extract "ABC" and leave the file position set to the comma).
Modified:
lldb/trunk/source/Utility/StringExtractor.cpp
lldb/trunk/source/Utility/StringExtractor.h
Modified: lldb/trunk/source/Utility/StringExtractor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/StringExtractor.cpp?rev=154239&r1=154238&r2=154239&view=diff
==============================================================================
--- lldb/trunk/source/Utility/StringExtractor.cpp (original)
+++ lldb/trunk/source/Utility/StringExtractor.cpp Fri Apr 6 19:42:53 2012
@@ -121,14 +121,10 @@
{
char hi_nibble_char = m_packet[m_index];
char lo_nibble_char = m_packet[m_index+1];
-
- if (isxdigit(hi_nibble_char) && isxdigit(lo_nibble_char))
- {
- char hi_nibble = xdigit_to_sint (hi_nibble_char);
- char lo_nibble = xdigit_to_sint (lo_nibble_char);
- m_index += 2;
- return (hi_nibble << 4) + lo_nibble;
- }
+ char hi_nibble = xdigit_to_sint (hi_nibble_char);
+ char lo_nibble = xdigit_to_sint (lo_nibble_char);
+ m_index += 2;
+ return (hi_nibble << 4) + lo_nibble;
}
m_index = UINT32_MAX;
return fail_value;
@@ -139,22 +135,19 @@
// string
//----------------------------------------------------------------------
uint8_t
-StringExtractor::GetHexU8 (uint8_t fail_value)
+StringExtractor::GetHexU8 (uint8_t fail_value, bool set_eof_on_fail)
{
if (GetNumHexASCIICharsAtFilePos(2))
{
uint8_t hi_nibble_char = m_packet[m_index];
uint8_t lo_nibble_char = m_packet[m_index+1];
-
- if (isxdigit(hi_nibble_char) && isxdigit(lo_nibble_char))
- {
- uint8_t hi_nibble = xdigit_to_uint (hi_nibble_char);
- uint8_t lo_nibble = xdigit_to_uint (lo_nibble_char);
- m_index += 2;
- return (hi_nibble << 4) + lo_nibble;
- }
+ uint8_t hi_nibble = xdigit_to_uint (hi_nibble_char);
+ uint8_t lo_nibble = xdigit_to_uint (lo_nibble_char);
+ m_index += 2;
+ return (hi_nibble << 4) + lo_nibble;
}
- m_index = UINT32_MAX;
+ if (set_eof_on_fail || m_index >= m_packet.size())
+ m_index = UINT32_MAX;
return fail_value;
}
Modified: lldb/trunk/source/Utility/StringExtractor.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/StringExtractor.h?rev=154239&r1=154238&r2=154239&view=diff
==============================================================================
--- lldb/trunk/source/Utility/StringExtractor.h (original)
+++ lldb/trunk/source/Utility/StringExtractor.h Fri Apr 6 19:42:53 2012
@@ -93,7 +93,7 @@
GetHexS8 (int8_t fail_value = 0);
uint8_t
- GetHexU8 (uint8_t fail_value = 0);
+ GetHexU8 (uint8_t fail_value = 0, bool set_eof_on_fail = true);
bool
GetNameColonValue (std::string &name, std::string &value);
More information about the lldb-commits
mailing list