[nemiver/el6-branch] Emit one IDebugger::breakpoint_set_signal per BP



commit 6a109f8bd30541c3c8626150f81ea2f2fd5a7a27
Author: Dodji Seketeli <dodji gnome org>
Date:   Thu Apr 21 19:17:52 2011 +0200

    Emit one IDebugger::breakpoint_set_signal per BP
    
    	* src/dbgengine/nmv-i-debugger.h
    	(IDebugger::breakpoints_list_signal): Renamed
    	IDebugger::breakpoints_set_signal into this.
    	(IDebugger::breakpoint_set_signal): New interface.
    	(IDebugger::BreakpointSlot): Renamed IDebugger::BreakpointsSlot
    	typedef into this.
    	(IDebugger::set_breakpoint): Change signature of the callback slot
    	to pass just one breakpoint, instead of all the breakpoints.
    	* src/dbgengine/nmv-gdb-engine.h
    	(GDBEngine::breakpoints_list_signal): Renamed
    	GDBEngine::breakpoint_set_signal into this.
    	(GDBEngine::breakpoint_set_signal): New interface.
    	(GDBEngine::set_breakpoint): Change signature of the callback slot
    	to pass just one breakpoint, instead of all the breakpoints.
    	* src/dbgengine/nmv-gdb-engine.cc
    	(GDBEngine::breakpoints_list_signal): Renamed
    	GDBEngine::breakpoints_set_signal into this.
    	(GDBEngine::breakpoint_set_signal): New definition.
    	(GDBEngine::set_breakpoint): Change signature of the callback slot
    	to pass just one breakpoint, instead of all the breakpoints.
    	(OnBreakpointHandler::do_handle): Emit
    	IDebugger::breakpoint_set_signal whenever a breakpoint is set.
    	Avoid emitting IDebugger::breakpoints_list_signal when a
    	breakpoint is set.  Also, adjust to call the close of
    	IDebugger::set_breakpoint back with only one breakpoint.
    	* src/persp/dbgperspective/nmv-breakpoints-view.cc
    	(BreakpointView::Priv::Priv): Update for rename to
    	IDebugger::breakpoints_list_signal.  Connect to the new
    	IDebugger::breakpoint_set_signal.
    	(BreakpointView::Priv::on_debugger_breakpoint_set_signal): New
    	definition.
    	(BreakpointView::Priv::on_debugger_breakpoints_list_signal):
    	Renamed BreakpointView::Priv::on_debugger_breakpoints_set_signal
    	into this.
    	* src/persp/dbgperspective/nmv-dbg-perspective.cc
    	(DBGPerspective::on_debugger_breakpoint_set_signal): New
    	definition.
    	(DBGPerspective::on_debugger_breakpoints_list_signal): Renamed
    	DBGPerspective::on_debugger_breakpoints_set_signal into this.
    	(DBGPerspective::append_breakpoint): Remove useless first
    	parameter from this.
    	(DBGPerspective::init_debugger_signals): Connect to the new
    	IDebugger::breakpoint_set_signal.  Update for renaming into
    	IDebugger::breakpoints_list_signal.
    	* tests/test-breakpoint.cc (test_main): Update for renaming into
    	IDebugger::breakpoints_list_signal.
    	* tests/test-var-path-expr.cc (test_main): Likewise.
    	* tests/test-watchpoint.cc (test_main): Likewise.

 src/dbgengine/nmv-gdb-engine.cc                  |   56 +++++++++++++++++-----
 src/dbgengine/nmv-gdb-engine.h                   |    9 +++-
 src/dbgengine/nmv-i-debugger.h                   |   13 ++++-
 src/persp/dbgperspective/nmv-breakpoints-view.cc |   29 +++++++++--
 src/persp/dbgperspective/nmv-dbg-perspective.cc  |   34 +++++++++----
 tests/test-breakpoint.cc                         |    2 +-
 tests/test-var-path-expr.cc                      |    2 +-
 tests/test-watchpoint.cc                         |    4 +-
 8 files changed, 110 insertions(+), 39 deletions(-)
---
diff --git a/src/dbgengine/nmv-gdb-engine.cc b/src/dbgengine/nmv-gdb-engine.cc
index 4f89c5f..a68645a 100644
--- a/src/dbgengine/nmv-gdb-engine.cc
+++ b/src/dbgengine/nmv-gdb-engine.cc
@@ -242,7 +242,11 @@ public:
 
     mutable sigc::signal<void,
                          const map<int, IDebugger::Breakpoint>&,
-                         const UString&> breakpoints_set_signal;
+                         const UString&> breakpoints_list_signal;
+
+    mutable sigc::signal<void,
+                         const std::pair<int, const IDebugger::Breakpoint&>&,
+                         const UString& /*cookie*/> breakpoint_set_signal;
 
     mutable sigc::signal<void,
                          const vector<OverloadsChoiceEntry>&,
@@ -1383,7 +1387,31 @@ struct OnBreakpointHandler: OutputHandler {
             has_breaks = true;
         }
 
-        if (a_in.output ().has_result_record ()
+        if (has_breaks
+            && (a_in.command ().name () == "set-breakpoint"
+                || a_in.command ().name () == "set-countpoint")) {
+            // If we are getting this reply b/c we did set a
+            // breakpoint, then only one breakpoint should be reported
+            // back to us from GDB.
+            const map<int, IDebugger::Breakpoint> &bps =
+                a_in.output ().result_record ().breakpoints ();
+            THROW_IF_FAIL (bps.size () == 1);
+
+            std::pair<int,
+                      const IDebugger::Breakpoint&> p (bps.begin ()->first,
+                                                       bps.begin ()->second);
+
+            Command &c = a_in.command ();
+            if (c.name () == "set-breakpoint"
+                && c.has_slot ()) {
+                IDebugger::BreakpointSlot slot =
+                    c.get_slot<IDebugger::BreakpointSlot> ();
+                slot (p);
+            }
+            m_engine->breakpoint_set_signal ().emit
+                (p, a_in.command ().cookie ());
+            m_engine->set_state (IDebugger::READY);
+        } else if (a_in.output ().has_result_record ()
             && a_in.output ().result_record ().kind ()
             == Output::ResultRecord::DONE
             && a_in.command ().value ().find ("-break-delete")
@@ -1414,13 +1442,7 @@ struct OnBreakpointHandler: OutputHandler {
             }
         } else if (has_breaks) {
             LOG_DD ("firing IDebugger::breakpoint_set_signal()");
-            Command &c = a_in.command ();
-            if (c.name () == "set-breakpoint"
-                && c.has_slot ()) {
-                IDebugger::BreakpointsSlot slot = c.get_slot<IDebugger::BreakpointsSlot> ();
-                slot (m_engine->get_cached_breakpoints ());
-            }
-            m_engine->breakpoints_set_signal ().emit
+            m_engine->breakpoints_list_signal ().emit
                 (m_engine->get_cached_breakpoints (),
                  a_in.command ().cookie ());
             m_engine->set_state (IDebugger::READY);
@@ -1681,7 +1703,7 @@ struct OnCommandDoneHandler : OutputHandler {
                 flag_breakpoint_as_countpoint (a_in.command ().tag2 (), false);
             }
 
-            m_engine->breakpoints_set_signal ().emit
+            m_engine->breakpoints_list_signal ().emit
                 (m_engine->get_cached_breakpoints (),
                  a_in.command ().cookie ());
         }
@@ -3252,9 +3274,17 @@ GDBEngine::breakpoint_deleted_signal () const
 }
 
 sigc::signal<void, const map<int, IDebugger::Breakpoint>&, const UString&>&
-GDBEngine::breakpoints_set_signal () const
+GDBEngine::breakpoints_list_signal () const
+{
+    return m_priv->breakpoints_list_signal;
+}
+
+sigc::signal<void,
+             const std::pair<int, const IDebugger::Breakpoint&>&,
+             const UString& /*cookie*/>&
+GDBEngine::breakpoint_set_signal () const
 {
-    return m_priv->breakpoints_set_signal;
+    return m_priv->breakpoint_set_signal;
 }
 
 sigc::signal<void, const vector<IDebugger::OverloadsChoiceEntry>&, const UString&>&
@@ -3892,7 +3922,7 @@ void
 GDBEngine::set_breakpoint (const Loc &a_loc,
                            const UString &a_condition,
                            gint a_ignore_count,
-                           const BreakpointsSlot &a_slot,
+                           const BreakpointSlot &a_slot,
                            const UString &a_cookie)
 {
     LOG_FUNCTION_SCOPE_NORMAL_DD;
diff --git a/src/dbgengine/nmv-gdb-engine.h b/src/dbgengine/nmv-gdb-engine.h
index da48b39..f907081 100644
--- a/src/dbgengine/nmv-gdb-engine.h
+++ b/src/dbgengine/nmv-gdb-engine.h
@@ -70,7 +70,12 @@ public:
     sigc::signal<void>& detached_from_target_signal () const;
 
     sigc::signal<void, const map<int, IDebugger::Breakpoint>&, const UString&>&
-                                            breakpoints_set_signal () const;
+                                            breakpoints_list_signal () const;
+
+    sigc::signal<void,
+                const std::pair<int, const IDebugger::Breakpoint&>&,
+                const UString& /*cookie*/>&
+        breakpoint_set_signal () const;
 
     sigc::signal<void, const vector<OverloadsChoiceEntry>&, const UString&>&
                                     got_overloads_choice_signal () const;
@@ -331,7 +336,7 @@ public:
     void set_breakpoint (const Loc &a_loc,
 			 const UString &a_condition,
 			 gint a_ignore_count,
-			 const BreakpointsSlot &a_slot,
+			 const BreakpointSlot &a_slot,
 			 const UString &a_cookie);
 
     void set_breakpoint (const UString &a_path,
diff --git a/src/dbgengine/nmv-i-debugger.h b/src/dbgengine/nmv-i-debugger.h
index eb75fbd..a2dbac9 100644
--- a/src/dbgengine/nmv-i-debugger.h
+++ b/src/dbgengine/nmv-i-debugger.h
@@ -822,7 +822,9 @@ public:
     }
 
     typedef sigc::slot<void> DefaultSlot;
-    typedef sigc::slot<void, const map<int, IDebugger::Breakpoint>&> BreakpointsSlot;
+    typedef sigc::slot<void,
+                       const std::pair<int, const IDebugger::Breakpoint&>&>
+        BreakpointSlot;
     typedef sigc::slot<void, Loc&> LocSlot;
     
     virtual ~IDebugger () {}
@@ -866,7 +868,12 @@ public:
     virtual sigc::signal<void,
                          const map<int, IDebugger::Breakpoint>&,
                          const UString& /*cookie*/>&
-                                         breakpoints_set_signal () const=0;
+                                         breakpoints_list_signal () const=0;
+
+    virtual sigc::signal<void,
+                        const std::pair<int, const IDebugger::Breakpoint&>&,
+                        const UString& /*cookie*/>&
+                        breakpoint_set_signal () const = 0;
 
     virtual sigc::signal<void,
                          const vector<OverloadsChoiceEntry>&,
@@ -1124,7 +1131,7 @@ public:
     virtual void set_breakpoint (const common::Loc &a_loc,
                                  const UString &a_condition,
                                  gint a_ignore_count,
-                                 const BreakpointsSlot &a_slot,
+                                 const BreakpointSlot &a_slot,
                                  const UString &a_cookie = "") = 0;
 
     virtual void set_breakpoint (const UString &a_path,
diff --git a/src/persp/dbgperspective/nmv-breakpoints-view.cc b/src/persp/dbgperspective/nmv-breakpoints-view.cc
index 641f1ac..cffb97e 100644
--- a/src/persp/dbgperspective/nmv-breakpoints-view.cc
+++ b/src/persp/dbgperspective/nmv-breakpoints-view.cc
@@ -117,15 +117,15 @@ public:
     {
         init_actions ();
         build_tree_view ();
-        void set_breakpoints
-                (const std::map<int, IDebugger::Breakpoint> &a_breakpoints);
 
         // update breakpoint list when debugger indicates that the list of
         // breakpoints has changed.
         debugger->breakpoint_deleted_signal ().connect (sigc::mem_fun
                 (*this, &Priv::on_debugger_breakpoint_deleted_signal));
-        debugger->breakpoints_set_signal ().connect (sigc::mem_fun
-                (*this, &Priv::on_debugger_breakpoints_set_signal));
+        debugger->breakpoint_set_signal ().connect
+            (sigc::mem_fun (*this, &Priv::on_debugger_breakpoint_set_signal));
+        debugger->breakpoints_list_signal ().connect (sigc::mem_fun
+                (*this, &Priv::on_debugger_breakpoints_list_signal));
         debugger->stopped_signal ().connect (sigc::mem_fun
                 (*this, &Priv::on_debugger_stopped_signal));
         breakpoints_menu = load_menu ("breakpointspopup.xml",
@@ -451,7 +451,8 @@ public:
         }
     }
 
-    void on_debugger_breakpoints_set_signal
+    void 
+    on_debugger_breakpoints_list_signal
                             (const map<int, IDebugger::Breakpoint> &a_breaks,
                              const UString &a_cookie)
     {
@@ -515,7 +516,23 @@ public:
         NEMIVER_CATCH
     }
 
-    bool on_breakpoints_view_button_press_signal (GdkEventButton *a_event)
+    void
+    on_debugger_breakpoint_set_signal
+    (const std::pair<int, const IDebugger::Breakpoint&> &a,
+     const UString &)
+    {
+        NEMIVER_TRY;
+
+        LOG_DD ("Adding breakpoint "
+                << a.second.number ());
+
+        append_breakpoint (a.second);
+
+        NEMIVER_CATCH;
+    }
+
+    bool
+    on_breakpoints_view_button_press_signal (GdkEventButton *a_event)
     {
         LOG_FUNCTION_SCOPE_NORMAL_DD;
         bool handled = false;
diff --git a/src/persp/dbgperspective/nmv-dbg-perspective.cc b/src/persp/dbgperspective/nmv-dbg-perspective.cc
index 30d00a5..3d71db9 100644
--- a/src/persp/dbgperspective/nmv-dbg-perspective.cc
+++ b/src/persp/dbgperspective/nmv-dbg-perspective.cc
@@ -326,7 +326,10 @@ private:
     void on_debugger_command_done_signal (const UString &a_command_name,
                                           const UString &a_cookie);
 
-    void on_debugger_breakpoints_set_signal
+    void on_debugger_breakpoint_set_signal
+    (const std::pair<int, const IDebugger::Breakpoint&>&, const UString&);
+
+    void on_debugger_breakpoints_list_signal
                                 (const map<int, IDebugger::Breakpoint> &,
                                  const UString &a_cookie);
 
@@ -609,8 +612,7 @@ public:
     void set_breakpoint (const Address &a_address,
                          bool a_is_count_point);
     void set_breakpoint (const IDebugger::Breakpoint &a_breakpoint);
-    void append_breakpoint (int a_bp_num,
-                            const IDebugger::Breakpoint &a_breakpoint);
+    void append_breakpoint (const IDebugger::Breakpoint &a_breakpoint);
     void append_breakpoints
                     (const map<int, IDebugger::Breakpoint> &a_breaks);
 
@@ -2497,7 +2499,15 @@ DBGPerspective::on_debugger_command_done_signal (const UString &a_command,
 }
 
 void
-DBGPerspective::on_debugger_breakpoints_set_signal
+DBGPerspective::on_debugger_breakpoint_set_signal
+(const std::pair<int, const IDebugger::Breakpoint&> &a,
+ const UString&)
+{
+    append_breakpoint (a.second);
+}
+
+void
+DBGPerspective::on_debugger_breakpoints_list_signal
                             (const map<int, IDebugger::Breakpoint> &a_breaks,
                              const UString &a_cookie)
 {
@@ -4061,8 +4071,11 @@ DBGPerspective::init_debugger_signals ()
     debugger ()->command_done_signal ().connect (sigc::mem_fun
             (*this, &DBGPerspective::on_debugger_command_done_signal));
 
-    debugger ()->breakpoints_set_signal ().connect (sigc::mem_fun
-            (*this, &DBGPerspective::on_debugger_breakpoints_set_signal));
+    debugger ()->breakpoint_set_signal ().connect (sigc::mem_fun
+            (*this, &DBGPerspective::on_debugger_breakpoint_set_signal));
+
+    debugger ()->breakpoints_list_signal ().connect (sigc::mem_fun
+            (*this, &DBGPerspective::on_debugger_breakpoints_list_signal));
 
     debugger ()->breakpoint_deleted_signal ().connect (sigc::mem_fun
             (*this, &DBGPerspective::on_debugger_breakpoint_deleted_signal));
@@ -6775,8 +6788,7 @@ DBGPerspective::set_breakpoint (const IDebugger::Breakpoint &a_breakpoint)
 }
 
 void
-DBGPerspective::append_breakpoint (int a_bp_num,
-                                   const IDebugger::Breakpoint &a_breakpoint)
+DBGPerspective::append_breakpoint (const IDebugger::Breakpoint &a_breakpoint)
 {
     LOG_FUNCTION_SCOPE_NORMAL_DD;
 
@@ -6791,8 +6803,8 @@ DBGPerspective::append_breakpoint (int a_bp_num,
         file_path = a_breakpoint.file_name ();
     }
 
-    m_priv->breakpoints[a_bp_num] = a_breakpoint;
-    m_priv->breakpoints[a_bp_num].file_full_name (file_path);
+    m_priv->breakpoints[a_breakpoint.number ()] = a_breakpoint;
+    m_priv->breakpoints[a_breakpoint.number ()].file_full_name (file_path);
 
     // We don't know how to graphically represent non-standard
     // breakpoints (e.g watchpoints) at this moment.
@@ -6855,7 +6867,7 @@ DBGPerspective::append_breakpoints
 
     map<int, IDebugger::Breakpoint>::const_iterator iter;
     for (iter = a_breaks.begin (); iter != a_breaks.end (); ++iter)
-        append_breakpoint (iter->first, iter->second);
+        append_breakpoint (iter->second);
 }
 
 const IDebugger::Breakpoint*
diff --git a/tests/test-breakpoint.cc b/tests/test-breakpoint.cc
index 2ad77c0..e65345a 100644
--- a/tests/test-breakpoint.cc
+++ b/tests/test-breakpoint.cc
@@ -216,7 +216,7 @@ test_main (int argc, char *argv[])
 
     debugger->command_done_signal ().connect (&on_command_done_signal);
 
-    debugger->breakpoints_set_signal ().connect
+    debugger->breakpoints_list_signal ().connect
                                             (&on_breakpoints_set_signal);
 
     debugger->running_signal ().connect (&on_running_signal);
diff --git a/tests/test-var-path-expr.cc b/tests/test-var-path-expr.cc
index 870d694..b96baff 100644
--- a/tests/test-var-path-expr.cc
+++ b/tests/test-var-path-expr.cc
@@ -132,7 +132,7 @@ test_main (int argc, char *argv[])
     debugger->program_finished_signal ().connect
                                             (&on_program_finished_signal);
 
-    debugger->breakpoints_set_signal ().connect
+    debugger->breakpoints_list_signal ().connect
                                             (&on_breakpoints_set_signal);
 
     debugger->stopped_signal ().connect (sigc::bind (&on_stopped_signal,
diff --git a/tests/test-watchpoint.cc b/tests/test-watchpoint.cc
index c3e8785..5b04360 100644
--- a/tests/test-watchpoint.cc
+++ b/tests/test-watchpoint.cc
@@ -94,8 +94,8 @@ test_main (int, char **)
     debugger->program_finished_signal ().connect
                                             (&on_program_finished_signal);
 
-    debugger->breakpoints_set_signal ().connect
-                                            (&on_breakpoints_set_signal);
+    debugger->breakpoints_list_signal ().connect
+        (&on_breakpoints_set_signal);
 
     debugger->stopped_signal ().connect
                             (sigc::bind (&on_stopped_signal, debugger));



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