[Lldb-commits] [PATCH] D100256: [gdb-remote server] Abstract away getting current process
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rGf1812a284f28: [lldb] [gdb-remote server] Abstract away getting current process (authored by mgorny). Herald added a project: LLDB. Changed prior to commit: https://reviews.llvm.org/D100256?vs=337188=337194#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D100256/new/ https://reviews.llvm.org/D100256 Files: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h === --- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h +++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h @@ -86,6 +86,8 @@ const NativeProcessProtocol::Factory _process_factory; lldb::tid_t m_current_tid = LLDB_INVALID_THREAD_ID; lldb::tid_t m_continue_tid = LLDB_INVALID_THREAD_ID; + NativeProcessProtocol *m_current_process; + NativeProcessProtocol *m_continue_process; std::recursive_mutex m_debugged_process_mutex; std::unique_ptr m_debugged_process_up; @@ -254,7 +256,7 @@ // In any case, the function assumes that exactly one inferior is being // debugged and rejects pid values that do no match that inferior. llvm::Expected ReadTid(StringExtractorGDBRemote , - bool allow_all = false); + bool allow_all, lldb::pid_t default_pid); // For GDBRemoteCommunicationServerLLGS only GDBRemoteCommunicationServerLLGS(const GDBRemoteCommunicationServerLLGS &) = Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp === --- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp +++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp @@ -70,6 +70,7 @@ : GDBRemoteCommunicationServerCommon("gdb-remote.server", "gdb-remote.server.rx_packet"), m_mainloop(mainloop), m_process_factory(process_factory), + m_current_process(nullptr), m_continue_process(nullptr), m_stdio_communication("process.stdio") { RegisterPacketHandlers(); } @@ -249,6 +250,7 @@ if (!process_or) return Status(process_or.takeError()); m_debugged_process_up = std::move(*process_or); +m_continue_process = m_current_process = m_debugged_process_up.get(); } // Handle mirroring of inferior stdout/stderr over the gdb-remote protocol as @@ -318,6 +320,7 @@ return status; } m_debugged_process_up = std::move(*process_or); + m_continue_process = m_current_process = m_debugged_process_up.get(); // Setup stdout/stderr mapping from inferior. auto terminal_fd = m_debugged_process_up->GetTerminalFileDescriptor(); @@ -735,15 +738,15 @@ Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_THREAD)); // Ensure we have a debugged process. - if (!m_debugged_process_up || - (m_debugged_process_up->GetID() == LLDB_INVALID_PROCESS_ID)) + if (!m_current_process || + (m_current_process->GetID() == LLDB_INVALID_PROCESS_ID)) return SendErrorResponse(50); LLDB_LOG(log, "preparing packet for pid {0} tid {1}", - m_debugged_process_up->GetID(), tid); + m_current_process->GetID(), tid); // Ensure we can get info on the given thread. - NativeThreadProtocol *thread = m_debugged_process_up->GetThreadByID(tid); + NativeThreadProtocol *thread = m_current_process->GetThreadByID(tid); if (!thread) return SendErrorResponse(51); @@ -766,7 +769,7 @@ LLDB_LOG( log, "pid {0}, tid {1}, got signal signo = {2}, reason = {3}, exc_type = {4}", - m_debugged_process_up->GetID(), tid, signum, int(tid_stop_info.reason), + m_current_process->GetID(), tid, signum, int(tid_stop_info.reason), tid_stop_info.details.exception.type); // Print the signal number. @@ -804,9 +807,9 @@ uint32_t thread_index = 0; NativeThreadProtocol *listed_thread; -for (listed_thread = m_debugged_process_up->GetThreadAtIndex(thread_index); +for (listed_thread = m_current_process->GetThreadAtIndex(thread_index); listed_thread; ++thread_index, -listed_thread = m_debugged_process_up->GetThreadAtIndex(thread_index)) { +listed_thread = m_current_process->GetThreadAtIndex(thread_index)) { if (thread_index > 0) response.PutChar(','); response.Printf("%" PRIx64, listed_thread->GetID()); @@ -821,7 +824,7 @@ if (thread_index > 1) { const bool threads_with_valid_stop_info_only = true; llvm::Expected threads_info = GetJSONThreadsInfo( -
[Lldb-commits] [PATCH] D100256: [gdb-remote server] Abstract away getting current process
mgorny updated this revision to Diff 337188. mgorny added a comment. Rebase and make linter happier. Now let's re-test and push. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D100256/new/ https://reviews.llvm.org/D100256 Files: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h === --- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h +++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h @@ -86,6 +86,8 @@ const NativeProcessProtocol::Factory _process_factory; lldb::tid_t m_current_tid = LLDB_INVALID_THREAD_ID; lldb::tid_t m_continue_tid = LLDB_INVALID_THREAD_ID; + NativeProcessProtocol *m_current_process; + NativeProcessProtocol *m_continue_process; std::recursive_mutex m_debugged_process_mutex; std::unique_ptr m_debugged_process_up; @@ -254,7 +256,7 @@ // In any case, the function assumes that exactly one inferior is being // debugged and rejects pid values that do no match that inferior. llvm::Expected ReadTid(StringExtractorGDBRemote , - bool allow_all = false); + bool allow_all, lldb::pid_t default_pid); // For GDBRemoteCommunicationServerLLGS only GDBRemoteCommunicationServerLLGS(const GDBRemoteCommunicationServerLLGS &) = Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp === --- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp +++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp @@ -70,6 +70,7 @@ : GDBRemoteCommunicationServerCommon("gdb-remote.server", "gdb-remote.server.rx_packet"), m_mainloop(mainloop), m_process_factory(process_factory), + m_current_process(nullptr), m_continue_process(nullptr), m_stdio_communication("process.stdio") { RegisterPacketHandlers(); } @@ -249,6 +250,7 @@ if (!process_or) return Status(process_or.takeError()); m_debugged_process_up = std::move(*process_or); +m_continue_process = m_current_process = m_debugged_process_up.get(); } // Handle mirroring of inferior stdout/stderr over the gdb-remote protocol as @@ -318,6 +320,7 @@ return status; } m_debugged_process_up = std::move(*process_or); + m_continue_process = m_current_process = m_debugged_process_up.get(); // Setup stdout/stderr mapping from inferior. auto terminal_fd = m_debugged_process_up->GetTerminalFileDescriptor(); @@ -735,15 +738,15 @@ Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_THREAD)); // Ensure we have a debugged process. - if (!m_debugged_process_up || - (m_debugged_process_up->GetID() == LLDB_INVALID_PROCESS_ID)) + if (!m_current_process || + (m_current_process->GetID() == LLDB_INVALID_PROCESS_ID)) return SendErrorResponse(50); LLDB_LOG(log, "preparing packet for pid {0} tid {1}", - m_debugged_process_up->GetID(), tid); + m_current_process->GetID(), tid); // Ensure we can get info on the given thread. - NativeThreadProtocol *thread = m_debugged_process_up->GetThreadByID(tid); + NativeThreadProtocol *thread = m_current_process->GetThreadByID(tid); if (!thread) return SendErrorResponse(51); @@ -766,7 +769,7 @@ LLDB_LOG( log, "pid {0}, tid {1}, got signal signo = {2}, reason = {3}, exc_type = {4}", - m_debugged_process_up->GetID(), tid, signum, int(tid_stop_info.reason), + m_current_process->GetID(), tid, signum, int(tid_stop_info.reason), tid_stop_info.details.exception.type); // Print the signal number. @@ -804,9 +807,9 @@ uint32_t thread_index = 0; NativeThreadProtocol *listed_thread; -for (listed_thread = m_debugged_process_up->GetThreadAtIndex(thread_index); +for (listed_thread = m_current_process->GetThreadAtIndex(thread_index); listed_thread; ++thread_index, -listed_thread = m_debugged_process_up->GetThreadAtIndex(thread_index)) { +listed_thread = m_current_process->GetThreadAtIndex(thread_index)) { if (thread_index > 0) response.PutChar(','); response.Printf("%" PRIx64, listed_thread->GetID()); @@ -821,7 +824,7 @@ if (thread_index > 1) { const bool threads_with_valid_stop_info_only = true; llvm::Expected threads_info = GetJSONThreadsInfo( - *m_debugged_process_up, threads_with_valid_stop_info_only); + *m_current_process, threads_with_valid_stop_info_only); if (threads_info) { response.PutCString("jstopinfo:"); StreamString unescaped_response; @@ -831,7 +834,7 @@
[Lldb-commits] [PATCH] D100256: [gdb-remote server] Abstract away getting current process
labath accepted this revision. labath added a comment. This revision is now accepted and ready to land. Looks about right. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D100256/new/ https://reviews.llvm.org/D100256 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D100256: [gdb-remote server] Abstract away getting current process
mgorny updated this revision to Diff 337154. mgorny retitled this revision from "[lldb] [gdb-remote server] Abstract away getting current process" to "[gdb-remote server] Abstract away getting current process". mgorny edited the summary of this revision. mgorny added a comment. Switched to using two pointers instead of a function. Made `ReadTid()` accept a default PID instead of playing with bools. Corrected `Hc` PID to apply only to c/C/s/vCont packets, similarly to how GDB does it. @labath, I've left the `GetID()` asserts in place because I've just did a big search/replace, and replacing them would be non-trivial and I can't really spend much more time on this. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D100256/new/ https://reviews.llvm.org/D100256 Files: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h === --- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h +++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h @@ -86,6 +86,8 @@ const NativeProcessProtocol::Factory _process_factory; lldb::tid_t m_current_tid = LLDB_INVALID_THREAD_ID; lldb::tid_t m_continue_tid = LLDB_INVALID_THREAD_ID; + NativeProcessProtocol *m_current_process; + NativeProcessProtocol *m_continue_process; std::recursive_mutex m_debugged_process_mutex; std::unique_ptr m_debugged_process_up; @@ -254,7 +256,8 @@ // In any case, the function assumes that exactly one inferior is being // debugged and rejects pid values that do no match that inferior. llvm::Expected ReadTid(StringExtractorGDBRemote , - bool allow_all = false); + bool allow_all, + lldb::pid_t default_pid); // For GDBRemoteCommunicationServerLLGS only GDBRemoteCommunicationServerLLGS(const GDBRemoteCommunicationServerLLGS &) = Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp === --- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp +++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp @@ -70,6 +70,7 @@ : GDBRemoteCommunicationServerCommon("gdb-remote.server", "gdb-remote.server.rx_packet"), m_mainloop(mainloop), m_process_factory(process_factory), + m_current_process(nullptr), m_continue_process(nullptr), m_stdio_communication("process.stdio") { RegisterPacketHandlers(); } @@ -249,6 +250,7 @@ if (!process_or) return Status(process_or.takeError()); m_debugged_process_up = std::move(*process_or); +m_continue_process = m_current_process = m_debugged_process_up.get(); } // Handle mirroring of inferior stdout/stderr over the gdb-remote protocol as @@ -318,6 +320,7 @@ return status; } m_debugged_process_up = std::move(*process_or); + m_continue_process = m_current_process = m_debugged_process_up.get(); // Setup stdout/stderr mapping from inferior. auto terminal_fd = m_debugged_process_up->GetTerminalFileDescriptor(); @@ -735,15 +738,15 @@ Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_THREAD)); // Ensure we have a debugged process. - if (!m_debugged_process_up || - (m_debugged_process_up->GetID() == LLDB_INVALID_PROCESS_ID)) + if (!m_current_process || + (m_current_process->GetID() == LLDB_INVALID_PROCESS_ID)) return SendErrorResponse(50); LLDB_LOG(log, "preparing packet for pid {0} tid {1}", - m_debugged_process_up->GetID(), tid); + m_current_process->GetID(), tid); // Ensure we can get info on the given thread. - NativeThreadProtocol *thread = m_debugged_process_up->GetThreadByID(tid); + NativeThreadProtocol *thread = m_current_process->GetThreadByID(tid); if (!thread) return SendErrorResponse(51); @@ -766,7 +769,7 @@ LLDB_LOG( log, "pid {0}, tid {1}, got signal signo = {2}, reason = {3}, exc_type = {4}", - m_debugged_process_up->GetID(), tid, signum, int(tid_stop_info.reason), + m_current_process->GetID(), tid, signum, int(tid_stop_info.reason), tid_stop_info.details.exception.type); // Print the signal number. @@ -804,9 +807,9 @@ uint32_t thread_index = 0; NativeThreadProtocol *listed_thread; -for (listed_thread = m_debugged_process_up->GetThreadAtIndex(thread_index); +for (listed_thread = m_current_process->GetThreadAtIndex(thread_index); listed_thread; ++thread_index, -listed_thread = m_debugged_process_up->GetThreadAtIndex(thread_index)) { +listed_thread =