[Lldb-commits] [lldb] ed1a83b - [lldb/gdb-remote] Remove ancient debugserver workaround
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Thu Mar 10 11:27:00 PST 2022
Author: Pavel Labath
Date: 2022-03-10T20:26:54+01:00
New Revision: ed1a83befe6569e8bc67846a98dcf3eaa6dd978a
URL: https://github.com/llvm/llvm-project/commit/ed1a83befe6569e8bc67846a98dcf3eaa6dd978a
DIFF: https://github.com/llvm/llvm-project/commit/ed1a83befe6569e8bc67846a98dcf3eaa6dd978a.diff
LOG: [lldb/gdb-remote] Remove ancient debugserver workaround
This workaround is the source of an awkwared Process->Platform
dependency. While this could be solved in various ways (the only thing
we really use is the plugin name), it may be better to just remove it --
the workaround was added 10 years ago (43c555dfc), and the affected
debugservers were "old" even then, so hopefully they are not in use
anymore.
Differential Revision: https://reviews.llvm.org/D121305
Added:
Modified:
lldb/source/Plugins/Process/gdb-remote/CMakeLists.txt
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
Removed:
################################################################################
diff --git a/lldb/source/Plugins/Process/gdb-remote/CMakeLists.txt b/lldb/source/Plugins/Process/gdb-remote/CMakeLists.txt
index e0c798187bd5b..b68bf5e740a12 100644
--- a/lldb/source/Plugins/Process/gdb-remote/CMakeLists.txt
+++ b/lldb/source/Plugins/Process/gdb-remote/CMakeLists.txt
@@ -8,7 +8,6 @@ lldb_tablegen(ProcessGDBRemotePropertiesEnum.inc -gen-lldb-property-enum-defs
set(LLDB_PLUGINS
lldbPluginProcessUtility
- lldbPluginPlatformMacOSX
)
if(HAVE_LIBCOMPRESSION)
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index ed72fb8ab670b..57be71e83adc0 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -74,7 +74,6 @@
#include "GDBRemoteRegisterContext.h"
#include "GDBRemoteRegisterFallback.h"
-#include "Plugins/Platform/MacOSX/PlatformRemoteiOS.h"
#include "Plugins/Process/Utility/GDBRemoteSignals.h"
#include "Plugins/Process/Utility/InferiorCallPOSIX.h"
#include "Plugins/Process/Utility/StopInfoMachException.h"
@@ -253,7 +252,7 @@ ProcessGDBRemote::ProcessGDBRemote(lldb::TargetSP target_sp,
m_continue_C_tids(), m_continue_s_tids(), m_continue_S_tids(),
m_max_memory_size(0), m_remote_stub_max_memory_size(0),
m_addr_to_mmap_size(), m_thread_create_bp_sp(),
- m_waiting_for_attach(false), m_destroy_tried_resuming(false),
+ m_waiting_for_attach(false),
m_command_sp(), m_breakpoint_pc_offset(0),
m_initial_tid(LLDB_INVALID_THREAD_ID), m_allow_flash_writes(false),
m_erased_flash_ranges(), m_vfork_in_progress(false) {
@@ -2380,109 +2379,6 @@ Status ProcessGDBRemote::DoDestroy() {
Log *log = GetLog(GDBRLog::Process);
LLDB_LOGF(log, "ProcessGDBRemote::DoDestroy()");
- // There is a bug in older iOS debugservers where they don't shut down the
- // process they are debugging properly. If the process is sitting at a
- // breakpoint or an exception, this can cause problems with restarting. So
- // we check to see if any of our threads are stopped at a breakpoint, and if
- // so we remove all the breakpoints, resume the process, and THEN destroy it
- // again.
- //
- // Note, we don't have a good way to test the version of debugserver, but I
- // happen to know that the set of all the iOS debugservers which don't
- // support GetThreadSuffixSupported() and that of the debugservers with this
- // bug are equal. There really should be a better way to test this!
- //
- // We also use m_destroy_tried_resuming to make sure we only do this once, if
- // we resume and then halt and get called here to destroy again and we're
- // still at a breakpoint or exception, then we should just do the straight-
- // forward kill.
- //
- // And of course, if we weren't able to stop the process by the time we get
- // here, it isn't necessary (or helpful) to do any of this.
-
- if (!m_gdb_comm.GetThreadSuffixSupported() &&
- m_public_state.GetValue() != eStateRunning) {
- PlatformSP platform_sp = GetTarget().GetPlatform();
-
- if (platform_sp && platform_sp->GetPluginName() ==
- PlatformRemoteiOS::GetPluginNameStatic()) {
- if (m_destroy_tried_resuming) {
- if (log)
- log->PutCString("ProcessGDBRemote::DoDestroy() - Tried resuming to "
- "destroy once already, not doing it again.");
- } else {
- // At present, the plans are discarded and the breakpoints disabled
- // Process::Destroy, but we really need it to happen here and it
- // doesn't matter if we do it twice.
- m_thread_list.DiscardThreadPlans();
- DisableAllBreakpointSites();
-
- bool stop_looks_like_crash = false;
- ThreadList &threads = GetThreadList();
-
- {
- std::lock_guard<std::recursive_mutex> guard(threads.GetMutex());
-
- size_t num_threads = threads.GetSize();
- for (size_t i = 0; i < num_threads; i++) {
- ThreadSP thread_sp = threads.GetThreadAtIndex(i);
- StopInfoSP stop_info_sp = thread_sp->GetPrivateStopInfo();
- StopReason reason = eStopReasonInvalid;
- if (stop_info_sp)
- reason = stop_info_sp->GetStopReason();
- if (reason == eStopReasonBreakpoint ||
- reason == eStopReasonException) {
- LLDB_LOGF(log,
- "ProcessGDBRemote::DoDestroy() - thread: 0x%4.4" PRIx64
- " stopped with reason: %s.",
- thread_sp->GetProtocolID(),
- stop_info_sp->GetDescription());
- stop_looks_like_crash = true;
- break;
- }
- }
- }
-
- if (stop_looks_like_crash) {
- if (log)
- log->PutCString("ProcessGDBRemote::DoDestroy() - Stopped at a "
- "breakpoint, continue and then kill.");
- m_destroy_tried_resuming = true;
-
- // If we are going to run again before killing, it would be good to
- // suspend all the threads before resuming so they won't get into
- // more trouble. Sadly, for the threads stopped with the breakpoint
- // or exception, the exception doesn't get cleared if it is
- // suspended, so we do have to run the risk of letting those threads
- // proceed a bit.
-
- {
- std::lock_guard<std::recursive_mutex> guard(threads.GetMutex());
-
- size_t num_threads = threads.GetSize();
- for (size_t i = 0; i < num_threads; i++) {
- ThreadSP thread_sp = threads.GetThreadAtIndex(i);
- StopInfoSP stop_info_sp = thread_sp->GetPrivateStopInfo();
- StopReason reason = eStopReasonInvalid;
- if (stop_info_sp)
- reason = stop_info_sp->GetStopReason();
- if (reason != eStopReasonBreakpoint &&
- reason != eStopReasonException) {
- LLDB_LOGF(log,
- "ProcessGDBRemote::DoDestroy() - Suspending "
- "thread: 0x%4.4" PRIx64 " before running.",
- thread_sp->GetProtocolID());
- thread_sp->SetResumeState(eStateSuspended);
- }
- }
- }
- Resume();
- return Destroy(false);
- }
- }
- }
- }
-
// Interrupt if our inferior is running...
int exit_status = SIGABRT;
std::string exit_string;
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
index 2a5e43124958f..d8f185073e3c4 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
@@ -281,7 +281,6 @@ class ProcessGDBRemote : public Process,
MMapMap m_addr_to_mmap_size;
lldb::BreakpointSP m_thread_create_bp_sp;
bool m_waiting_for_attach;
- bool m_destroy_tried_resuming;
lldb::CommandObjectSP m_command_sp;
int64_t m_breakpoint_pc_offset;
lldb::tid_t m_initial_tid; // The initial thread ID, given by stub on attach
More information about the lldb-commits
mailing list