[nemiver] Add a new IDebugger::re_run entry point



commit a763073b4e98fe2e58ca2956819de8735c73d1df
Author: Dodji Seketeli <dodji seketeli org>
Date:   Sun Jun 10 22:01:43 2012 +0200

    Add a new IDebugger::re_run entry point
    
    	* src/dbgengine/nmv-i-debugger.h
    	(IDebugger::inferior_re_run_signal, IDebugger::re_run): New entry
    	points.
    	* src/dbgengine/nmv-gdb-engine.h
    	(GDBEngine::inferior_re_run_signal, GDBEngine::re_run): New
    	functions.
    	* src/dbgengine/nmv-gdb-engine.cc
    	(GDBEngine::Priv::inferior_re_run_signal): New member.
    	(OnRunningHandler::do_handle): Handle new "re-run" command.
    	(GDBEngine::inferior_re_run_signal, GDBEngine::re_run): New
    	function.
    	* src/persp/dbgperspective/nmv-dbg-perspective.cc
    	(DBGPerspective::on_debugger_inferior_re_run_signal): New
    	function.
    	(DBGPerspective::restart_local_inferior): Use the new
    	IDebugger::re_run function.

 src/dbgengine/nmv-gdb-engine.cc                 |   44 +++++++++++++++++++++++
 src/dbgengine/nmv-gdb-engine.h                  |    6 +++-
 src/dbgengine/nmv-i-debugger.h                  |    6 +++
 src/persp/dbgperspective/nmv-dbg-perspective.cc |   26 +++++++++----
 4 files changed, 73 insertions(+), 9 deletions(-)
---
diff --git a/src/dbgengine/nmv-gdb-engine.cc b/src/dbgengine/nmv-gdb-engine.cc
index 1c281fb..ebee5eb 100644
--- a/src/dbgengine/nmv-gdb-engine.cc
+++ b/src/dbgengine/nmv-gdb-engine.cc
@@ -60,6 +60,7 @@ using nemiver::debugger_utils::null_const_variable_list_slot;
 using nemiver::debugger_utils::null_frame_vector_slot;
 using nemiver::debugger_utils::null_frame_args_slot;
 using nemiver::debugger_utils::null_disass_slot;
+using nemiver::debugger_utils::null_default_slot;
 using nemiver::debugger_utils::null_breakpoints_slot;
 
 static const char* GDBMI_OUTPUT_DOMAIN = "gdbmi-output-domain";
@@ -257,6 +258,8 @@ public:
     mutable sigc::signal<void> connected_to_server_signal;
 
     mutable sigc::signal<void> detached_from_target_signal;
+    
+    mutable sigc::signal<void> inferior_re_run_signal;
 
     mutable sigc::signal<void,
                          const map<int, IDebugger::Breakpoint>&,
@@ -1855,6 +1858,16 @@ struct OnRunningHandler : OutputHandler {
             IDebugger::DefaultSlot s = c.get_slot<IDebugger::DefaultSlot> ();
             s ();
         }
+
+        if (a_in.command ().name () == "re-run") {
+            if (a_in.command ().has_slot ()) {
+                typedef sigc::slot<void> SlotType;
+                SlotType slot = a_in.command ().get_slot<SlotType> ();
+                slot ();
+            }
+            m_engine->inferior_re_run_signal ().emit ();
+        }
+
         m_engine->running_signal ().emit ();
     }
 };//struct OnRunningHandler
@@ -3497,6 +3510,13 @@ GDBEngine::detached_from_target_signal () const
     return m_priv->detached_from_target_signal;
 }
 
+/// Return a reference on the IDebugger::inferior_re_run_signal.
+sigc::signal<void>&
+GDBEngine::inferior_re_run_signal () const
+{
+    return m_priv->inferior_re_run_signal;
+}
+
 sigc::signal<void, const IDebugger::Breakpoint&, int, const UString&>&
 GDBEngine::breakpoint_deleted_signal () const
 {
@@ -4198,6 +4218,30 @@ GDBEngine::run (const UString &a_cookie)
     queue_command (command);
 }
 
+/// Re-run the inferior.  That is, if the inferior is running, stop
+/// it, and re-start it.
+///
+/// \param a_slot the callback slot to invoke upon re-starting
+/// successful restarting of the inferior.  Note that this function
+/// also triggers the emitting of the
+/// IDebugger::inferior_re_run_signal signal.
+void
+GDBEngine::re_run (const DefaultSlot &a_slot)
+{
+    LOG_FUNCTION_SCOPE_NORMAL_DD;
+
+    if (is_attached_to_target ()
+        && get_state () == IDebugger::RUNNING)
+    {
+        stop_target ();
+        LOG_DD ("Requested to stop GDB");
+    }
+
+    Command command ("re-run", "-exec-run");
+    command.set_slot (a_slot);
+    queue_command (command);
+}
+
 void
 GDBEngine::get_target_info (const UString &a_cookie)
 {
diff --git a/src/dbgengine/nmv-gdb-engine.h b/src/dbgengine/nmv-gdb-engine.h
index 88a5816..8eb1233 100644
--- a/src/dbgengine/nmv-gdb-engine.h
+++ b/src/dbgengine/nmv-gdb-engine.h
@@ -69,6 +69,8 @@ public:
 
     sigc::signal<void>& detached_from_target_signal () const;
 
+    sigc::signal<void>& inferior_re_run_signal () const;
+
     sigc::signal<void, const map<int, IDebugger::Breakpoint>&, const UString&>&
                                             breakpoints_list_signal () const;
 
@@ -327,7 +329,9 @@ public:
 
     void do_continue (const UString &a_cookie);
 
-    void run (const UString &a_cookie) ;
+    void run (const UString &a_cookie);
+
+    void re_run (const DefaultSlot &);
 
     void get_target_info (const UString &a_cookie);
 
diff --git a/src/dbgengine/nmv-i-debugger.h b/src/dbgengine/nmv-i-debugger.h
index 711feb6..4b48dbd 100644
--- a/src/dbgengine/nmv-i-debugger.h
+++ b/src/dbgengine/nmv-i-debugger.h
@@ -992,6 +992,10 @@ public:
 
     virtual sigc::signal<void>& detached_from_target_signal () const=0;
 
+    /// Signal emitted whenever the inferior is re-run, using the
+    /// function IDebugger::re_run.
+    virtual sigc::signal<void>& inferior_re_run_signal () const = 0;
+
     virtual sigc::signal<void,
                         const IDebugger::Breakpoint&,
                         int /*breakpoint command*/,
@@ -1267,6 +1271,8 @@ public:
 
     virtual void run (const UString &a_cookie="") = 0;
 
+    virtual void re_run (const DefaultSlot &) = 0;
+
     virtual IDebugger::State get_state () const = 0;
 
     virtual int get_current_frame_level () const = 0;
diff --git a/src/persp/dbgperspective/nmv-dbg-perspective.cc b/src/persp/dbgperspective/nmv-dbg-perspective.cc
index 7c905af..905a67f 100644
--- a/src/persp/dbgperspective/nmv-dbg-perspective.cc
+++ b/src/persp/dbgperspective/nmv-dbg-perspective.cc
@@ -335,6 +335,8 @@ private:
 
     void on_debugger_connected_to_remote_target_signal ();
 
+    void on_debugger_inferior_re_run_signal ();
+
     void on_debugger_detached_from_target_signal ();
 
     void on_debugger_got_target_info_signal (int a_pid,
@@ -2310,6 +2312,19 @@ DBGPerspective::on_debugger_connected_to_remote_target_signal ()
 }
 
 void
+DBGPerspective::on_debugger_inferior_re_run_signal ()
+{
+    LOG_FUNCTION_SCOPE_NORMAL_DD;
+    
+    NEMIVER_TRY;
+
+    m_priv->debugger_has_just_run = true;
+    attached_to_target_signal ().emit (true);
+
+    NEMIVER_CATCH;
+}
+
+void
 DBGPerspective::on_debugger_detached_from_target_signal ()
 {
     LOG_FUNCTION_SCOPE_NORMAL_DD;
@@ -5857,15 +5872,10 @@ DBGPerspective::restart_local_inferior ()
         // restart; in which case, we can't just simply call debugger
         // ()->run ().
         && debugger ()->get_target_path () == m_priv->prog_path) {
-        // if the engine is running, stop it.
-        if (debugger ()->get_state () == IDebugger::RUNNING) {
-            debugger ()->stop_target ();
-            LOG_DD ("stopped dbg_engine");
-        }
         going_to_run_target_signal ().emit ();
-        debugger ()->run ();
-        m_priv->debugger_has_just_run = true;
-        attached_to_target_signal ().emit (true);
+        debugger ()->re_run
+            (sigc::mem_fun
+             (*this, &DBGPerspective::on_debugger_inferior_re_run_signal));
     } else {
         vector<IDebugger::Breakpoint> bps;
         execute_program (m_priv->prog_path, m_priv->prog_args,



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