[Lldb-commits] [PATCH] D126614: [lldb] [gdb-remote] Client support for using the non-stop protocol
mgorny updated this revision to Diff 443427. mgorny edited the summary of this revision. mgorny added a comment. Good news, everyone! It turns out that the private/public state is not needed anymore — I guess fixing the races in tests resolved that. Did some final cleanup of tests as well. I guess this covers everything except for grabbing the "OK" response to "vCtrlC" interrupt. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D126614/new/ https://reviews.llvm.org/D126614 Files: lldb/packages/Python/lldbsuite/test/gdbclientutils.py lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.h lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteProperties.td lldb/test/API/functionalities/gdb_remote_client/TestNonStop.py Index: lldb/test/API/functionalities/gdb_remote_client/TestNonStop.py === --- /dev/null +++ lldb/test/API/functionalities/gdb_remote_client/TestNonStop.py @@ -0,0 +1,151 @@ +import lldb +from lldbsuite.test.lldbtest import * +from lldbsuite.test.decorators import * +from lldbsuite.test.gdbclientutils import * +from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase + + +class TestNonStop(GDBRemoteTestBase): +def test_run(self): +class MyResponder(MockGDBServerResponder): +vStopped_counter = 0 + +def qSupported(self, client_supported): +return "QNonStop+;" + super().qSupported(client_supported) + +def QNonStop(self, val): +return "OK" + +def qfThreadInfo(self): +return "m10,12" + +def qsThreadInfo(self): +return "l" + +def vStopped(self): +self.vStopped_counter += 1 +return ("OK" if self.vStopped_counter > 1 +else "T00;thread:10") + +def cont(self): +self.vStopped_counter = 0 +return ["OK", "%Stop:T02;thread:12"] + +self.dbg.HandleCommand( +"settings set plugin.process.gdb-remote.use-non-stop-protocol true") +self.addTearDownHook(lambda: +self.runCmd( +"settings set plugin.process.gdb-remote.use-non-stop-protocol " +"false")) +self.server.responder = MyResponder() +target = self.dbg.CreateTarget("") +process = self.connect(target) +self.assertPacketLogContains(["QNonStop:1"]) + +process.Continue() +self.assertPacketLogContains(["vStopped"]) +self.assertEqual(process.GetSelectedThread().GetStopReason(), + lldb.eStopReasonSignal) +self.assertEqual(process.GetSelectedThread().GetStopDescription(100), + "signal SIGINT") + +def test_stdio(self): +class MyResponder(MockGDBServerResponder): +vStdio_counter = 0 +vStopped_counter = 0 + +def qSupported(self, client_supported): +return "QNonStop+;" + super().qSupported(client_supported) + +def QNonStop(self, val): +return "OK" + +def qfThreadInfo(self): +return "m10,12" + +def qsThreadInfo(self): +return "l" + +def vStdio(self): +self.vStdio_counter += 1 +# intersperse notifications with replies for better testing +return ("OK" if self.vStdio_counter > 1 +else ["%Stop:T02;thread:12", + "O7365636f6e64206c696e650d0a"]) + +def vStopped(self): +self.vStopped_counter += 1 +return ("OK" if self.vStopped_counter > 1 +else "T00;thread:10") + +def cont(self): +self.vStopped_counter = 0 +self.vStdio_counter = 0 +return ["OK", +"%Stdio:O6669727374206c696e650d0a",] + +self.dbg.HandleCommand( +"settings set plugin.process.gdb-remote.use-non-stop-protocol true") +self.addTearDownHook(lambda: +self.runCmd( +"settings set plugin.process.gdb-remote.use-non-stop-protocol " +"false")) +self.server.responder = MyResponder() +target = self.dbg.CreateTarget("") +process = self.connect(target) +self.assertPacketLogContains(["QNonStop:1"]) + +process.Continue() +self.assertPacketLogC
[Lldb-commits] [PATCH] D126614: [lldb] [gdb-remote] Client support for using the non-stop protocol
mgorny updated this revision to Diff 443428. mgorny added a comment. Move common parts of the mock responder into a base class. Include PIDs in responses, and add trailing `;` to `T` packets. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D126614/new/ https://reviews.llvm.org/D126614 Files: lldb/packages/Python/lldbsuite/test/gdbclientutils.py lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.h lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteProperties.td lldb/test/API/functionalities/gdb_remote_client/TestNonStop.py Index: lldb/test/API/functionalities/gdb_remote_client/TestNonStop.py === --- /dev/null +++ lldb/test/API/functionalities/gdb_remote_client/TestNonStop.py @@ -0,0 +1,132 @@ +import lldb +from lldbsuite.test.lldbtest import * +from lldbsuite.test.decorators import * +from lldbsuite.test.gdbclientutils import * +from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase + + +class NonStopResponder(MockGDBServerResponder): +def qSupported(self, client_supported): +return "QNonStop+;" + super().qSupported(client_supported) + +def QNonStop(self, val): +return "OK" + +def qfThreadInfo(self): +return "mp10.10,p10.12" + +def qsThreadInfo(self): +return "l" + + +class TestNonStop(GDBRemoteTestBase): +def test_run(self): +class MyResponder(NonStopResponder): +vStopped_counter = 0 + +def vStopped(self): +self.vStopped_counter += 1 +return ("OK" if self.vStopped_counter > 1 +else "T00thread:p10.10;") + +def cont(self): +self.vStopped_counter = 0 +return ["OK", "%Stop:T02thread:p10.12;"] + +self.dbg.HandleCommand( +"settings set plugin.process.gdb-remote.use-non-stop-protocol true") +self.addTearDownHook(lambda: +self.runCmd( +"settings set plugin.process.gdb-remote.use-non-stop-protocol " +"false")) +self.server.responder = MyResponder() +target = self.dbg.CreateTarget("") +process = self.connect(target) +self.assertPacketLogContains(["QNonStop:1"]) + +process.Continue() +self.assertPacketLogContains(["vStopped"]) +self.assertEqual(process.GetSelectedThread().GetStopReason(), + lldb.eStopReasonSignal) +self.assertEqual(process.GetSelectedThread().GetStopDescription(100), + "signal SIGINT") + +def test_stdio(self): +class MyResponder(NonStopResponder): +vStdio_counter = 0 +vStopped_counter = 0 + +def vStdio(self): +self.vStdio_counter += 1 +# intersperse notifications with replies for better testing +return ("OK" if self.vStdio_counter > 1 +else ["%Stop:T02thread:p10.12;", + "O7365636f6e64206c696e650d0a"]) + +def vStopped(self): +self.vStopped_counter += 1 +return ("OK" if self.vStopped_counter > 1 +else "T00thread:p10.10;") + +def cont(self): +self.vStopped_counter = 0 +self.vStdio_counter = 0 +return ["OK", +"%Stdio:O6669727374206c696e650d0a",] + +self.dbg.HandleCommand( +"settings set plugin.process.gdb-remote.use-non-stop-protocol true") +self.addTearDownHook(lambda: +self.runCmd( +"settings set plugin.process.gdb-remote.use-non-stop-protocol " +"false")) +self.server.responder = MyResponder() +target = self.dbg.CreateTarget("") +process = self.connect(target) +self.assertPacketLogContains(["QNonStop:1"]) + +process.Continue() +self.assertPacketLogContains(["vStdio", "vStopped"]) +self.assertEqual(process.GetSelectedThread().GetStopReason(), + lldb.eStopReasonSignal) +self.assertEqual(process.GetSelectedThread().GetStopDescription(100), + "signal SIGINT") + +def test_vCtrlC(self): +class MyResponder(NonStopResponder): +vStopped_counter = 0 + +def vStopped(self): +self.vStopped_counter += 1 +return ("OK" if self.vStopped_counter % 2 == 0 +
[Lldb-commits] [PATCH] D129364: [LLDB][DataFormatter] Add data formatter for libcxx std::unordered_map iterator
Michael137 updated this revision to Diff 443430. Michael137 added a comment. - Fixed test case for const bucket iterator Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D129364/new/ https://reviews.llvm.org/D129364 Files: lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp lldb/source/Plugins/Language/CPlusPlus/LibCxx.h lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered_map/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered_map/TestDataFormatterLibccUnorderedMap.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered_map/main.cpp Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered_map/main.cpp === --- /dev/null +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered_map/main.cpp @@ -0,0 +1,28 @@ +#include +#include +#include + +using StringMapT = std::unordered_map; + +int main() { + StringMapT string_map; + { +auto empty_iter = string_map.begin(); +auto const_empty_iter = string_map.cbegin(); +std::printf("Break here"); + } + string_map["Foo"] = "Bar"; + string_map["Baz"] = "Qux"; + + { +auto foo = string_map.find("Foo"); +auto invalid = string_map.find("Invalid"); + +StringMapT::const_iterator const_baz = string_map.find("Baz"); +auto bucket_it = string_map.begin(string_map.bucket("Baz")); +auto const_bucket_it = string_map.cbegin(string_map.bucket("Baz")); +std::printf("Break here"); + } + + return 0; +} Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered_map/TestDataFormatterLibccUnorderedMap.py === --- /dev/null +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered_map/TestDataFormatterLibccUnorderedMap.py @@ -0,0 +1,53 @@ +""" +Test formatting of std::unordered_map related structures. +""" + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class LibcxxUnorderedMapDataFormatterTestCase(TestBase): + +@add_test_categories(['libc++']) +def test_with_run_command(self): +"""Test that std::unordered_map related structures are formatted correctly when printed. + Currently only tests format of std::unordered_map iterators. +""" +self.build() +(self.target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint( +self, 'Break here', lldb.SBFileSpec('main.cpp', False)) + +# Test empty iterators +self.expect_expr('empty_iter', '') +self.expect_expr('const_empty_iter', '') + +lldbutil.continue_to_breakpoint(process, bkpt) + +# Check that key/value is correctly formatted +self.expect_expr('foo', result_children=[ + ValueCheck(name='first', summary='"Foo"'), + ValueCheck(name='second', summary='"Bar"') +]) + +# Check invalid iterator is empty +self.expect_expr('invalid', '') + +# Const key/val iterator +self.expect_expr('const_baz', result_children=[ + ValueCheck(name='first', summary='"Baz"'), + ValueCheck(name='second', summary='"Qux"') +]) + +# Bucket iterators +# I.e., std::__hash_map_const_iterator> +# and std::__hash_map_iterator> +self.expect_expr('bucket_it', result_children=[ + ValueCheck(name='first', summary='"Baz"'), + ValueCheck(name='second', summary='"Qux"') +]) + +self.expect_expr('const_bucket_it', result_children=[ + ValueCheck(name='first', summary='"Baz"'), + ValueCheck(name='second', summary='"Qux"') +]) Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered_map/Makefile === --- /dev/null +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered_map/Makefile @@ -0,0 +1,6 @@ +CXX_SOURCES := main.cpp + +USE_LIBCPP := 1 + +CXXFLAGS_EXTRAS := -O0 +include Makefile.rules Index: lldb/source/Plugins/Language/CPlusPlus/LibCxx.h === --- lldb/source/Plugins/Language/CPlusPlus/LibCxx.h +++ lldb/source/Plugins/Language/CPlusPlus/LibCxx.h @@ -103,6 +103,56 @@ LibCxxMapIteratorSyntheticFrontEndCreator(CXXSyntheticChildren *, lldb::ValueObjectSP); +/// Formats libcxx's std::unordered_map iterators +/// +/// In raw form a std::unordered_map::iterator is represented as follows: +/// +/// (lldb) var it --raw --ptr-depth 1 +///