Author: Michał Górny Date: 2022-01-28T10:15:52+01:00 New Revision: 59a3f65f5ed6b25b584d504fe4cf8473d4029ff3
URL: https://github.com/llvm/llvm-project/commit/59a3f65f5ed6b25b584d504fe4cf8473d4029ff3 DIFF: https://github.com/llvm/llvm-project/commit/59a3f65f5ed6b25b584d504fe4cf8473d4029ff3.diff LOG: Revert "[lldb] [gdb-remote] Support getting siginfo via API" This reverts commit 1a8f60f5f5b8638a3e8e7fb31ba7ae9e17a7ff2d. The API requires further work. Added: Modified: lldb/bindings/interface/SBThread.i lldb/include/lldb/API/SBPlatform.h lldb/include/lldb/API/SBTarget.h lldb/include/lldb/API/SBThread.h lldb/include/lldb/API/SBType.h lldb/include/lldb/Target/Thread.h lldb/source/API/SBThread.cpp lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py Removed: ################################################################################ diff --git a/lldb/bindings/interface/SBThread.i b/lldb/bindings/interface/SBThread.i index ba7f5b3fdf765..d847d38f0d66e 100644 --- a/lldb/bindings/interface/SBThread.i +++ b/lldb/bindings/interface/SBThread.i @@ -405,12 +405,6 @@ public: bool SafeToCallFunctions (); - %feature("autodoc"," - Retruns a SBValue object representing the siginfo for the current signal. - ") GetSiginfo; - lldb::SBValue - GetSiginfo(SBError &error); - STRING_EXTENSION(SBThread) #ifdef SWIGPYTHON diff --git a/lldb/include/lldb/API/SBPlatform.h b/lldb/include/lldb/API/SBPlatform.h index 4f5d04a24e95e..dcc8a14ff0c1f 100644 --- a/lldb/include/lldb/API/SBPlatform.h +++ b/lldb/include/lldb/API/SBPlatform.h @@ -172,7 +172,6 @@ class LLDB_API SBPlatform { protected: friend class SBDebugger; friend class SBTarget; - friend class SBThread; lldb::PlatformSP GetSP() const; diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h index 9e75b5e503a8c..abd9ebf074076 100644 --- a/lldb/include/lldb/API/SBTarget.h +++ b/lldb/include/lldb/API/SBTarget.h @@ -875,7 +875,6 @@ class LLDB_API SBTarget { friend class SBSection; friend class SBSourceManager; friend class SBSymbol; - friend class SBThread; friend class SBValue; friend class SBVariablesOptions; diff --git a/lldb/include/lldb/API/SBThread.h b/lldb/include/lldb/API/SBThread.h index 76f794c25d9e8..ac1b8407a2200 100644 --- a/lldb/include/lldb/API/SBThread.h +++ b/lldb/include/lldb/API/SBThread.h @@ -208,8 +208,6 @@ class LLDB_API SBThread { bool SafeToCallFunctions(); - SBValue GetSiginfo(SBError &error); - private: friend class SBBreakpoint; friend class SBBreakpointLocation; diff --git a/lldb/include/lldb/API/SBType.h b/lldb/include/lldb/API/SBType.h index 5885432d06243..529b4d0eeffc4 100644 --- a/lldb/include/lldb/API/SBType.h +++ b/lldb/include/lldb/API/SBType.h @@ -225,7 +225,6 @@ class SBType { friend class SBFunction; friend class SBModule; friend class SBTarget; - friend class SBThread; friend class SBTypeEnumMember; friend class SBTypeEnumMemberList; friend class SBTypeNameSpecifier; diff --git a/lldb/include/lldb/Target/Thread.h b/lldb/include/lldb/Target/Thread.h index f1d4e6c7ef01a..587b29eb4c661 100644 --- a/lldb/include/lldb/Target/Thread.h +++ b/lldb/include/lldb/Target/Thread.h @@ -22,7 +22,6 @@ #include "lldb/Utility/CompletionRequest.h" #include "lldb/Utility/Event.h" #include "lldb/Utility/StructuredData.h" -#include "lldb/Utility/UnimplementedError.h" #include "lldb/Utility/UserID.h" #include "lldb/lldb-private.h" @@ -1185,11 +1184,6 @@ class Thread : public std::enable_shared_from_this<Thread>, lldb::ThreadSP GetCurrentExceptionBacktrace(); - virtual llvm::Expected<std::unique_ptr<llvm::MemoryBuffer>> - GetSiginfo(size_t max_size) const { - return llvm::make_error<UnimplementedError>(); - } - protected: friend class ThreadPlan; friend class ThreadList; diff --git a/lldb/source/API/SBThread.cpp b/lldb/source/API/SBThread.cpp index dcc2a6ed3d18f..46a6c2759140b 100644 --- a/lldb/source/API/SBThread.cpp +++ b/lldb/source/API/SBThread.cpp @@ -1317,50 +1317,3 @@ lldb_private::Thread *SBThread::operator->() { lldb_private::Thread *SBThread::get() { return m_opaque_sp->GetThreadSP().get(); } - -SBValue SBThread::GetSiginfo(SBError &error) { - LLDB_INSTRUMENT_VA(this, error); - - SBValue value; - SBProcess process = GetProcess(); - if (!process.IsValid()) { - error.SetErrorString("no process"); - return value; - } - SBTarget target = process.GetTarget(); - if (!target.IsValid()) { - error.SetErrorString("unable to get target"); - return value; - } - SBPlatform platform = target.GetPlatform(); - if (!platform.IsValid()) { - error.SetErrorString("unable to get platform"); - return value; - } - CompilerType type = platform.GetSP()->GetSiginfoType( - target.GetSP()->GetArchitecture().GetTriple()); - if (!type.IsValid()) { - error.SetErrorString("no siginfo_t for the platform"); - return value; - } - llvm::Optional<uint64_t> type_size = type.GetByteSize(nullptr); - assert(type_size); - ThreadSP thread_sp = m_opaque_sp->GetThreadSP(); - if (!thread_sp) { - error.SetErrorString("unable to get thread"); - return value; - } - llvm::Expected<std::unique_ptr<llvm::MemoryBuffer>> data = - thread_sp->GetSiginfo(type_size.getValue()); - if (!data) { - error.SetErrorString(llvm::toString(data.takeError()).c_str()); - return value; - } - SBData sb_data; - sb_data.SetData(error, data.get()->getBufferStart(), - data.get()->getBufferSize(), process.GetByteOrder(), 0); - if (!sb_data.IsValid()) - return value; - - return target.CreateValueFromData("siginfo", sb_data, type); -} diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp index f6526d03863bb..b5b105351de5d 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -173,13 +173,6 @@ bool GDBRemoteCommunicationClient::GetQXferMemoryMapReadSupported() { return m_supports_qXfer_memory_map_read == eLazyBoolYes; } -bool GDBRemoteCommunicationClient::GetQXferSigInfoReadSupported() { - if (m_supports_qXfer_siginfo_read == eLazyBoolCalculate) { - GetRemoteQSupported(); - } - return m_supports_qXfer_siginfo_read == eLazyBoolYes; -} - uint64_t GDBRemoteCommunicationClient::GetRemoteMaxPacketSize() { if (m_max_packet_size == 0) { GetRemoteQSupported(); @@ -280,7 +273,6 @@ void GDBRemoteCommunicationClient::ResetDiscoverableSettings(bool did_exec) { m_supports_qXfer_libraries_svr4_read = eLazyBoolCalculate; m_supports_qXfer_features_read = eLazyBoolCalculate; m_supports_qXfer_memory_map_read = eLazyBoolCalculate; - m_supports_qXfer_siginfo_read = eLazyBoolCalculate; m_supports_augmented_libraries_svr4_read = eLazyBoolCalculate; m_uses_native_signals = eLazyBoolCalculate; m_supports_qProcessInfoPID = true; @@ -328,7 +320,6 @@ void GDBRemoteCommunicationClient::GetRemoteQSupported() { m_supports_augmented_libraries_svr4_read = eLazyBoolNo; m_supports_qXfer_features_read = eLazyBoolNo; m_supports_qXfer_memory_map_read = eLazyBoolNo; - m_supports_qXfer_siginfo_read = eLazyBoolNo; m_supports_multiprocess = eLazyBoolNo; m_supports_qEcho = eLazyBoolNo; m_supports_QPassSignals = eLazyBoolNo; @@ -371,8 +362,6 @@ void GDBRemoteCommunicationClient::GetRemoteQSupported() { m_supports_qXfer_features_read = eLazyBoolYes; else if (x == "qXfer:memory-map:read+") m_supports_qXfer_memory_map_read = eLazyBoolYes; - else if (x == "qXfer:siginfo:read+") - m_supports_qXfer_siginfo_read = eLazyBoolYes; else if (x == "qEcho") m_supports_qEcho = eLazyBoolYes; else if (x == "QPassSignals+") diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h index 58ed22187747f..c69c33bb1c153 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h @@ -337,8 +337,6 @@ class GDBRemoteCommunicationClient : public GDBRemoteClientBase { bool GetQXferMemoryMapReadSupported(); - bool GetQXferSigInfoReadSupported(); - LazyBool SupportsAllocDeallocMemory() // const { // Uncomment this to have lldb pretend the debug server doesn't respond to @@ -553,7 +551,6 @@ class GDBRemoteCommunicationClient : public GDBRemoteClientBase { LazyBool m_supports_qXfer_libraries_svr4_read = eLazyBoolCalculate; LazyBool m_supports_qXfer_features_read = eLazyBoolCalculate; LazyBool m_supports_qXfer_memory_map_read = eLazyBoolCalculate; - LazyBool m_supports_qXfer_siginfo_read = eLazyBoolCalculate; LazyBool m_supports_augmented_libraries_svr4_read = eLazyBoolCalculate; LazyBool m_supports_jThreadExtendedInfo = eLazyBoolCalculate; LazyBool m_supports_jLoadedDynamicLibrariesInfos = eLazyBoolCalculate; diff --git a/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp index 3d23c074c1be3..ba73115e4ad60 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp @@ -346,23 +346,3 @@ bool ThreadGDBRemote::CalculateStopInfo() { ->CalculateThreadStopInfo(this); return false; } - -llvm::Expected<std::unique_ptr<llvm::MemoryBuffer>> -ThreadGDBRemote::GetSiginfo(size_t max_size) const { - ProcessSP process_sp(GetProcess()); - if (!process_sp) - return llvm::createStringError(llvm::inconvertibleErrorCode(), - "no process"); - ProcessGDBRemote *gdb_process = - static_cast<ProcessGDBRemote *>(process_sp.get()); - if (!gdb_process->m_gdb_comm.GetQXferSigInfoReadSupported()) - return llvm::createStringError(llvm::inconvertibleErrorCode(), - "qXfer:siginfo:read not supported"); - - llvm::Expected<std::string> response = - gdb_process->m_gdb_comm.ReadExtFeature("siginfo", ""); - if (!response) - return response.takeError(); - - return llvm::MemoryBuffer::getMemBufferCopy(response.get()); -} diff --git a/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h index fb83c74fd2c53..b7d75021c062d 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h +++ b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h @@ -90,9 +90,6 @@ class ThreadGDBRemote : public Thread { StructuredData::ObjectSP FetchThreadExtendedInfo() override; - llvm::Expected<std::unique_ptr<llvm::MemoryBuffer>> - GetSiginfo(size_t max_size) const override; - protected: friend class ProcessGDBRemote; diff --git a/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py b/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py index 0c7ba64920827..16cf4b4547c39 100644 --- a/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py +++ b/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py @@ -490,99 +490,3 @@ def cont(self): lldb.eStopReasonSignal) self.assertEqual(process.threads[0].GetStopDescription(100), 'signal SIGUSR1') - - def do_siginfo_test(self, platform, target_yaml, raw_data, expected): - class MyResponder(MockGDBServerResponder): - def qSupported(self, client_supported): - return "PacketSize=3fff;QStartNoAckMode+;qXfer:siginfo:read+" - - def qXferRead(self, obj, annex, offset, length): - if obj == "siginfo": - return raw_data, False - else: - return None, False - - def haltReason(self): - return "T02" - - def cont(self): - return self.haltReason() - - self.server.responder = MyResponder() - - self.runCmd("platform select " + platform) - target = self.createTarget(target_yaml) - process = self.connect(target) - - error = lldb.SBError() - siginfo = process.threads[0].GetSiginfo(error) - self.assertTrue(siginfo, error) - - for key, value in expected.items(): - self.assertEqual(siginfo.GetValueForExpressionPath("." + key) - .GetValueAsUnsigned(), - value) - - - def test_siginfo_linux_amd64(self): - data = ( - # si_signo si_errno si_code - "\x11\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00" - # __pad0 si_pid si_uid - "\x00\x00\x00\x00\xbf\xf7\x0b\x00\xe8\x03\x00\x00" - # si_status - "\x0c\x00\x00\x00" + "\x00" * 100) - expected = { - "si_signo": 17, # SIGCHLD - "si_errno": 0, - "si_code": 1, # CLD_EXITED - "_sifields._sigchld.si_pid": 784319, - "_sifields._sigchld.si_uid": 1000, - "_sifields._sigchld.si_status": 12, - "_sifields._sigchld.si_utime": 0, - "_sifields._sigchld.si_stime": 0, - } - self.do_siginfo_test("remote-linux", "basic_eh_frame.yaml", - data, expected) - - def test_siginfo_linux_i386(self): - data = ( - # si_signo si_errno si_code - "\x11\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00" - # si_pid si_uid si_status - "\x49\x43\x07\x00\xe8\x03\x00\x00\x0c\x00\x00\x00" - + "\x00" * 104) - expected = { - "si_signo": 17, # SIGCHLD - "si_errno": 0, - "si_code": 1, # CLD_EXITED - "_sifields._sigchld.si_pid": 475977, - "_sifields._sigchld.si_uid": 1000, - "_sifields._sigchld.si_status": 12, - "_sifields._sigchld.si_utime": 0, - "_sifields._sigchld.si_stime": 0, - } - self.do_siginfo_test("remote-linux", "basic_eh_frame-i386.yaml", - data, expected) - - def test_siginfo_freebsd_amd64(self): - data = ( - # si_signo si_errno si_code - "\x0b\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00" - # si_pid si_uid si_status - "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" - # si_addr - "\x76\x98\xba\xdc\xfe\x00\x00\x00" - # si_status si_trapno - "\x00\x00\x00\x00\x00\x00\x00\x00\x0c\x00\x00\x00" - + "\x00" * 36) - - expected = { - "si_signo": 11, # SIGSEGV - "si_errno": 0, - "si_code": 1, # SEGV_MAPERR - "si_addr": 0xfedcba9876, - "_reason._fault._trapno": 12, - } - self.do_siginfo_test("remote-freebsd", "basic_eh_frame.yaml", - data, expected) _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits