[nemiver] Reset command queue on restart GDB after a crash



commit 8fec0f1abeaca26eea2dee4dae489c43e6af2a6e
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 09dfdd3..a124aaa 100644
--- a/src/dbgengine/nmv-gdb-engine.cc
+++ b/src/dbgengine/nmv-gdb-engine.cc
@@ -769,6 +769,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)
     {
@@ -2756,6 +2771,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]