[Lldb-commits] [lldb] r325701 - llgs-tests: Fix r325511 for debugserver

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Wed Feb 21 09:38:39 PST 2018


Author: labath
Date: Wed Feb 21 09:38:38 2018
New Revision: 325701

URL: http://llvm.org/viewvc/llvm-project?rev=325701&view=rev
Log:
llgs-tests: Fix r325511 for debugserver

Debugserver sends the thread-pcs field with leading zeroes omitted. Teach
parseRegisterValue to pad these as necessary.

Modified:
    lldb/trunk/unittests/tools/lldb-server/tests/MessageObjects.cpp
    lldb/trunk/unittests/tools/lldb-server/tests/MessageObjects.h

Modified: lldb/trunk/unittests/tools/lldb-server/tests/MessageObjects.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/tools/lldb-server/tests/MessageObjects.cpp?rev=325701&r1=325700&r2=325701&view=diff
==============================================================================
--- lldb/trunk/unittests/tools/lldb-server/tests/MessageObjects.cpp (original)
+++ lldb/trunk/unittests/tools/lldb-server/tests/MessageObjects.cpp Wed Feb 21 09:38:38 2018
@@ -203,7 +203,15 @@ Expected<RegisterInfo> RegisterInfoParse
 
 Expected<RegisterValue> parseRegisterValue(const RegisterInfo &Info,
                                            StringRef HexValue,
-                                           llvm::support::endianness Endian) {
+                                           llvm::support::endianness Endian,
+                                           bool ZeroPad) {
+  SmallString<128> Storage;
+  if (ZeroPad && HexValue.size() < Info.byte_size * 2) {
+    Storage.insert(Storage.begin(), Info.byte_size * 2 - HexValue.size(), '0');
+    Storage += HexValue;
+    HexValue = Storage;
+  }
+
   SmallVector<uint8_t, 64> Bytes(HexValue.size() / 2);
   StringExtractor(HexValue).GetHexBytes(Bytes, '\xcc');
   RegisterValue Value;
@@ -301,7 +309,8 @@ StopReplyStop::create(StringRef Response
       return make_parsing_error("StopReply: Thread id '{0}'",
                                 std::get<0>(ThreadPc));
 
-    auto PcOr = parseRegisterValue(*PcInfo, std::get<1>(ThreadPc), Endian);
+    auto PcOr = parseRegisterValue(*PcInfo, std::get<1>(ThreadPc), Endian,
+                                   /*ZeroPad*/ true);
     if (!PcOr)
       return PcOr.takeError();
     ThreadPcs[Id] = std::move(*PcOr);

Modified: lldb/trunk/unittests/tools/lldb-server/tests/MessageObjects.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/tools/lldb-server/tests/MessageObjects.h?rev=325701&r1=325700&r2=325701&view=diff
==============================================================================
--- lldb/trunk/unittests/tools/lldb-server/tests/MessageObjects.h (original)
+++ lldb/trunk/unittests/tools/lldb-server/tests/MessageObjects.h Wed Feb 21 09:38:38 2018
@@ -87,7 +87,8 @@ struct RegisterInfoParser : public Parse
 
 llvm::Expected<lldb_private::RegisterValue>
 parseRegisterValue(const lldb_private::RegisterInfo &Info,
-                   llvm::StringRef HexValue, llvm::support::endianness Endian);
+                   llvm::StringRef HexValue, llvm::support::endianness Endian,
+                   bool ZeroPad = false);
 
 class StopReply {
 public:




More information about the lldb-commits mailing list