Author: Jim Ingham Date: 2023-07-11T12:33:22-07:00 New Revision: 8402ad23104b6b20f07596738b02a4ab101a8af9
URL: https://github.com/llvm/llvm-project/commit/8402ad23104b6b20f07596738b02a4ab101a8af9 DIFF: https://github.com/llvm/llvm-project/commit/8402ad23104b6b20f07596738b02a4ab101a8af9.diff LOG: Add a generic Process method to dump plugin history. I need to call this to figure out why the assert in StopInfoMachException::CreateStopReasonWithMachException is triggering, but it isn't appropriate to directly access the GDBRemoteCommunication there. And dumping whatever history the process plugin has collected during the run isn't gdb-remote specific... Differential Revision: https://reviews.llvm.org/D154992 Added: Modified: lldb/include/lldb/Target/Process.h lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h Removed: ################################################################################ diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h index dfed3659432df0..affd3fbc37b07a 100644 --- a/lldb/include/lldb/Target/Process.h +++ b/lldb/include/lldb/Target/Process.h @@ -575,6 +575,10 @@ class Process : public std::enable_shared_from_this<Process>, /// of CommandObject like CommandObjectRaw, CommandObjectParsed, /// or CommandObjectMultiword. virtual CommandObject *GetPluginCommandObject() { return nullptr; } + + /// The underlying plugin might store the low-level communication history for + /// this session. Dump it into the provided stream. + virtual void DumpPluginHistory(Stream &s) { return; } /// Launch a new process. /// diff --git a/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp b/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp index b4301f21ac1032..d60e6250c7c0ac 100644 --- a/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp +++ b/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp @@ -744,6 +744,7 @@ StopInfoSP StopInfoMachException::CreateStopReasonWithMachException( } } } + thread.GetProcess()->DumpPluginHistory(s); llvm::report_fatal_error(s.GetData()); lldbassert( false && diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp index 8ea93655d6bbf2..e8606ddae5674a 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp @@ -457,7 +457,7 @@ bool GDBRemoteRegisterContext::WriteRegisterBytes(const RegisterInfo *reg_info, if (log) { if (log->GetVerbose()) { StreamString strm; - gdb_comm.DumpHistory(strm); + process->DumpPluginHistory(strm); LLDB_LOGF(log, "error: failed to get packet sequence mutex, not sending " "write register for \"%s\":\n%s", @@ -566,7 +566,7 @@ bool GDBRemoteRegisterContext::ReadAllRegisterValues( if (log) { if (log->GetVerbose()) { StreamString strm; - gdb_comm.DumpHistory(strm); + process->DumpPluginHistory(strm); LLDB_LOGF(log, "error: failed to get packet sequence mutex, not sending " "read all registers:\n%s", @@ -741,7 +741,7 @@ bool GDBRemoteRegisterContext::WriteAllRegisterValues( if (log) { if (log->GetVerbose()) { StreamString strm; - gdb_comm.DumpHistory(strm); + process->DumpPluginHistory(strm); LLDB_LOGF(log, "error: failed to get packet sequence mutex, not sending " "write all registers:\n%s", diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index 522dee9f768620..b6f146fd872e80 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -113,7 +113,7 @@ void DumpProcessGDBRemotePacketHistory(void *p, const char *path) { return; } StreamFile stream(std::move(file.get())); - ((ProcessGDBRemote *)p)->GetGDBRemote().DumpHistory(stream); + ((Process *)p)->DumpPluginHistory(stream); } } // namespace lldb @@ -205,6 +205,11 @@ lldb::ProcessSP ProcessGDBRemote::CreateInstance( return process_sp; } +void ProcessGDBRemote::DumpPluginHistory(Stream &s) { + GDBRemoteCommunicationClient &gdb_comm(GetGDBRemote()); + gdb_comm.DumpHistory(s); +} + std::chrono::seconds ProcessGDBRemote::GetPacketTimeout() { return std::chrono::seconds(GetGlobalPluginProperties().GetPacketTimeout()); } @@ -5217,7 +5222,7 @@ class CommandObjectProcessGDBRemotePacketHistory : public CommandObjectParsed { ProcessGDBRemote *process = (ProcessGDBRemote *)m_interpreter.GetExecutionContext().GetProcessPtr(); if (process) { - process->GetGDBRemote().DumpHistory(result.GetOutputStream()); + process->DumpPluginHistory(result.GetOutputStream()); result.SetStatus(eReturnStatusSuccessFinishResult); return true; } diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h index aec3a8dfb9867a..f0ead4c38c237a 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h @@ -77,6 +77,8 @@ class ProcessGDBRemote : public Process, bool plugin_specified_by_name) override; CommandObject *GetPluginCommandObject() override; + + void DumpPluginHistory(Stream &s) override; // Creating a new process, or attaching to an existing one Status DoWillLaunch(Module *module) override; _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits