jingham created this revision.
jingham added reviewers: jasonmolenda, JDevlieghere.
Herald added a project: All.
jingham requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

I need to dump the gdb-remote communication history when we fail the "stepping 
or not" assertion Jason added to StopInfoMachException a week or so ago.  But 
that's a feature of GDBRemoteCommunication, or at best ProcessGDBRemote, and it 
really doesn't make sense to include that in StopInfoMachException.

However the notion of "dumping the low level plugin history for a process" 
seems like a generally useful one.  So I made a Process API for this, and then 
routed the other uses through that, and added dumping this when the assert is 
triggered.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154992

Files:
  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

Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
===================================================================
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
@@ -77,6 +77,8 @@
                 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;
Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===================================================================
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -113,7 +113,7 @@
     return;
   }
   StreamFile stream(std::move(file.get()));
-  ((ProcessGDBRemote *)p)->GetGDBRemote().DumpHistory(stream);
+  ((Process *)p)->DumpPluginHistory(stream);
 }
 } // namespace lldb
 
@@ -205,6 +205,11 @@
   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 @@
     ProcessGDBRemote *process =
         (ProcessGDBRemote *)m_interpreter.GetExecutionContext().GetProcessPtr();
     if (process) {
-      process->GetGDBRemote().DumpHistory(result.GetOutputStream());
+      process->DumpPluginHistory(result.GetOutputStream());
       result.SetStatus(eReturnStatusSuccessFinishResult);
       return true;
     }
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
===================================================================
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
@@ -457,7 +457,7 @@
       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 @@
     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 @@
     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",
Index: lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
===================================================================
--- lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
+++ lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
@@ -744,6 +744,7 @@
               }
             }
           }
+          thread.GetProcess()->DumpPluginHistory(s);
           llvm::report_fatal_error(s.GetData());
           lldbassert(
               false &&
Index: lldb/include/lldb/Target/Process.h
===================================================================
--- lldb/include/lldb/Target/Process.h
+++ lldb/include/lldb/Target/Process.h
@@ -575,6 +575,10 @@
   ///     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.
   ///
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to