[Lldb-commits] [lldb] r331004 - [debugserver] Fix handling of the 'g' packet

Frederic Riss via lldb-commits lldb-commits at lists.llvm.org
Thu Apr 26 17:09:04 PDT 2018


Author: friss
Date: Thu Apr 26 17:09:04 2018
New Revision: 331004

URL: http://llvm.org/viewvc/llvm-project?rev=331004&view=rev
Log:
[debugserver] Fix handling of the 'g' packet

LLDB doesn't use this packet so we never hit this, but it looks like
some other projects talk to debugserver and are hitting an assert
(https://github.com/derekparker/delve/issues/1015).

We had an off by 1 in the accounting of the FPU structure sizes.
I added a test that basically just check that 'g' doesn't return
an error (currently it assert in debug builds). I didn't make
it an lldb-server test because it looks like lldb-server doesn't
implement the g packet.

Added:
    lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteGPacket.py
Modified:
    lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp

Added: lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteGPacket.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteGPacket.py?rev=331004&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteGPacket.py (added)
+++ lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteGPacket.py Thu Apr 26 17:09:04 2018
@@ -0,0 +1,30 @@
+from __future__ import print_function
+
+
+import gdbremote_testcase
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestGdbRemoteGPacket(gdbremote_testcase.GdbRemoteTestCaseBase):
+
+    mydir = TestBase.compute_mydir(__file__)
+
+    def run_test_g_packet(self):
+        self.build()
+        self.prep_debug_monitor_and_inferior()
+        self.test_sequence.add_log_lines(
+            ["read packet: $g#67",
+             {"direction": "send", "regex": r"^\$(.+)#[0-9a-fA-F]{2}$",
+              "capture": {1: "register_bank"}}],
+            True)
+        self.connect_to_debug_monitor()
+        context = self.expect_gdbremote_sequence()
+        register_bank = context.get("register_bank")
+        self.assertTrue(register_bank[0] != 'E')
+
+    @debugserver_test
+    def test_g_packet_debugserver(self):
+        self.init_debugserver_test()
+        self.run_test_g_packet()

Modified: lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp?rev=331004&r1=331003&r2=331004&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp Thu Apr 26 17:09:04 2018
@@ -2633,7 +2633,9 @@ nub_size_t DNBArchImplX86_64::GetRegiste
 
       // Walk around the gaps in the FPU regs
       memcpy(p, &m_state.context.fpu.no_avx.__fpu_fcw, 5);
-      p += 5;
+      // We read 5 bytes, but we skip 6 to account for __fpu_rsrv1
+      // to match the g_fpu_registers_* tables.
+      p += 6;
       memcpy(p, &m_state.context.fpu.no_avx.__fpu_fop, 8);
       p += 8;
       memcpy(p, &m_state.context.fpu.no_avx.__fpu_dp, 6);




More information about the lldb-commits mailing list