[nemiver/better-variable-format] Reset command queue on restart GDB after a crash



commit 63bc7ec3fb579d72213981b5af324ce6a20e23c7
Author: Dodji Seketeli <dodji seketeli org>
Date:   Wed Mar 2 22:57:26 2011 +0100

    Reset command queue on restart GDB after a crash
    
    	* src/dbgengine/nmv-gdb-engine.cc
    	(GDBEngine::Priv::reset_command_queue): New function.
    	(GDBEngine::load_program): When launching a fresh GDB (e.g after
    	the previous one crashed) make sure to reset the command queue in
    	case the previous GDB vanished in the middle of a command
    	submitting process -- and so the command queue is left in a stuck
    	state.

 src/dbgengine/nmv-gdb-engine.cc |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
---
diff --git a/src/dbgengine/nmv-gdb-engine.cc b/src/dbgengine/nmv-gdb-engine.cc
index 4d05b41..815ffcf 100644
--- a/src/dbgengine/nmv-gdb-engine.cc
+++ b/src/dbgengine/nmv-gdb-engine.cc
@@ -794,6 +794,21 @@ public:
         return result;
     }
 
+    /// Resets the GDB command queue so that it is in its initial
+    /// state.  Just as is the GDBEngine object has just been
+    /// instantiated.  This is useful when we are about to launch a
+    /// new GDB just after the previous one crashed "during flight".
+    /// Use this with great care.
+    void
+    reset_command_queue (void)
+    {
+        LOG_FUNCTION_SCOPE_NORMAL_DD;
+
+        started_commands.clear ();
+        queued_commands.clear ();
+        line_busy = false;
+    }
+
     void set_debugger_parameter (const UString &a_name,
                                  const UString &a_value)
     {
@@ -2854,6 +2869,10 @@ GDBEngine::load_program (const UString &a_prog,
 
         Command command;
 
+        // In case we are restarting GDB after a crash, the command
+        // queue might be stuck.  Let's restart it.
+        m_priv->reset_command_queue ();
+
         queue_command (Command ("set breakpoint pending on"));
 
         // tell gdb not to pass the SIGINT signal to the target.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]