nemiver r882 - in trunk: . src/dbgengine src/persp/dbgperspective



Author: dodji
Date: Sat Jul  5 01:18:32 2008
New Revision: 882
URL: http://svn.gnome.org/viewvc/nemiver?rev=882&view=rev

Log:
fix #396277 - implement lazy evaluation of status widgets

	* src/persp/dbgperspective/nmv-breakpoints-view.cc:
	  Make this widget behave with lazyness. That is, when the debugger
	  stops, the widget does not query the debugger engine for data if
	  it's hidden. When the widget becomes visible though, it updates
	  itself if necessary.
	* src/persp/dbgperspective/nmv-call-stack.cc: Likewise.
	* src/persp/dbgperspective/nmv-local-vars-inspector.cc: Likewise.
	* src/persp/dbgperspective/nmv-memory-view.cc: Likewise.
	* src/persp/dbgperspective/nmv-registers-view.cc: Likewise.
	* src/persp/dbgperspective/nmv-thread-list.cc: Likewise.
	* src/persp/dbgperspective/nmv-dbg-perspective.cc:
	  (DBGPerspective::init_perspective_menu_entries): make the terminal
	  widget be the one visible by default, so that the other ones can be
	  hidden by default and thus not query the debugger engine.


Modified:
   trunk/ChangeLog
   trunk/src/dbgengine/nmv-i-debugger.h
   trunk/src/persp/dbgperspective/nmv-breakpoints-view.cc
   trunk/src/persp/dbgperspective/nmv-call-stack.cc
   trunk/src/persp/dbgperspective/nmv-dbg-perspective.cc
   trunk/src/persp/dbgperspective/nmv-local-vars-inspector.cc
   trunk/src/persp/dbgperspective/nmv-memory-view.cc
   trunk/src/persp/dbgperspective/nmv-registers-view.cc
   trunk/src/persp/dbgperspective/nmv-thread-list.cc

Modified: trunk/src/dbgengine/nmv-i-debugger.h
==============================================================================
--- trunk/src/dbgengine/nmv-i-debugger.h	(original)
+++ trunk/src/dbgengine/nmv-i-debugger.h	Sat Jul  5 01:18:32 2008
@@ -824,14 +824,11 @@
 
     virtual void list_files (const UString &a_cookie="") = 0;
 
-    // register functions
     virtual void list_register_names (const UString &a_cookie="") = 0;
     virtual void list_changed_registers (const UString &a_cookie="") = 0;
     virtual void list_register_values (const UString &a_cookie="") = 0;
-
     virtual void list_register_values (std::list<register_id_t> a_registers,
                                        const UString &a_cookie="") = 0;
-
     virtual void set_register_value (const UString& a_reg_name,
                                      const UString& a_value,
                                      const UString& a_cookie="") = 0;

Modified: trunk/src/persp/dbgperspective/nmv-breakpoints-view.cc
==============================================================================
--- trunk/src/persp/dbgperspective/nmv-breakpoints-view.cc	(original)
+++ trunk/src/persp/dbgperspective/nmv-breakpoints-view.cc	Sat Jul  5 01:18:32 2008
@@ -78,6 +78,7 @@
     IWorkbench& workbench;
     IPerspective& perspective;
     IDebuggerSafePtr& debugger;
+    bool is_up2date;
 
     Priv (IWorkbench& a_workbench,
           IPerspective& a_perspective,
@@ -85,26 +86,14 @@
         breakpoints_menu(0),
         workbench(a_workbench),
         perspective(a_perspective),
-        debugger(a_debugger)
+        debugger(a_debugger),
+        is_up2date (true)
     {
         init_actions ();
         build_tree_view () ;
         void set_breakpoints
                 (const std::map<int, IDebugger::BreakPoint> &a_breakpoints);
 
-        // we must handle the button press event before the default button
-        // handler since there are cases when we need to prevent the default
-        // handler from running
-        tree_view->signal_button_press_event ().connect
-            (sigc::mem_fun (*this,
-                            &Priv::on_breakpoints_view_button_press_signal),
-             false /*connect before*/);
-        tree_view->get_selection ()->signal_changed ().connect (
-                sigc::mem_fun (*this, &Priv::on_treeview_selection_changed));
-
-        tree_view->signal_key_press_event ().connect (sigc::mem_fun (*this,
-                    &Priv::on_key_press_event));
-
         // update breakpoint list when debugger indicates that the list of
         // breakpoints has changed.
         debugger->breakpoint_deleted_signal ().connect (sigc::mem_fun
@@ -141,6 +130,30 @@
             enabled_toggle->signal_toggled ().connect (sigc::mem_fun (*this,
                         &BreakpointsView::Priv::on_breakpoint_enable_toggled));
         }
+
+        // we must handle the button press event before the default button
+        // handler since there are cases when we need to prevent the default
+        // handler from running
+        tree_view->signal_button_press_event ().connect
+                (sigc::mem_fun
+                     (*this, &Priv::on_breakpoints_view_button_press_signal),
+                      false /*connect before*/);
+        tree_view->get_selection ()->signal_changed ().connect (sigc::mem_fun
+                (*this, &Priv::on_treeview_selection_changed));
+
+        tree_view->signal_key_press_event ().connect (sigc::mem_fun
+              (*this, &Priv::on_key_press_event));
+        tree_view->signal_expose_event ().connect_notify (sigc::mem_fun
+               (*this, &Priv::on_expose_event));
+    }
+
+    bool should_process_now ()
+    {
+        LOG_FUNCTION_SCOPE_NORMAL_DD;
+        THROW_IF_FAIL (tree_view);
+        bool is_visible = tree_view->is_drawable ();
+        LOG_DD ("is visible: " << is_visible);
+        return is_visible;
     }
 
     void on_breakpoint_enable_toggled (const Glib::ustring& path)
@@ -256,6 +269,12 @@
         return tree_iter;
     }
 
+    void finish_handling_debugger_stopped_event ()
+    {
+        LOG_FUNCTION_SCOPE_NORMAL_DD;
+        debugger->list_breakpoints ();
+    }
+
     void on_debugger_breakpoints_set_signal
                             (const map<int, IDebugger::BreakPoint> &a_breaks,
                              const UString &a_cookie)
@@ -275,8 +294,11 @@
     {
         NEMIVER_TRY
         if (a_reason == IDebugger::BREAKPOINT_HIT) {
-            LOG_DD ("listing breakpoints ...");
-            debugger->list_breakpoints ();
+            if (should_process_now ()) {
+                finish_handling_debugger_stopped_event ();
+            } else {
+                is_up2date = false;
+            }
         }
         NEMIVER_CATCH
     }
@@ -305,35 +327,6 @@
         NEMIVER_CATCH
     }
 
-    Gtk::Widget* load_menu (UString a_filename, UString a_widget_name)
-    {
-        NEMIVER_TRY
-        string relative_path = Glib::build_filename ("menus", a_filename) ;
-        string absolute_path ;
-        THROW_IF_FAIL (perspective.build_absolute_resource_path
-                (Glib::locale_to_utf8 (relative_path), absolute_path)) ;
-
-        workbench.get_ui_manager ()->add_ui_from_file
-                                        (Glib::locale_to_utf8 (absolute_path)) ;
-        NEMIVER_CATCH
-        return workbench.get_ui_manager ()->get_widget (a_widget_name);
-    }
-
-    Gtk::Widget* get_breakpoints_menu ()
-    {
-        THROW_IF_FAIL (breakpoints_menu);
-        return breakpoints_menu;
-    }
-
-    void popup_breakpoints_view_menu (GdkEventButton *a_event)
-    {
-        THROW_IF_FAIL (a_event) ;
-        THROW_IF_FAIL (tree_view) ;
-        Gtk::Menu *menu = dynamic_cast<Gtk::Menu*> (get_breakpoints_menu ()) ;
-        THROW_IF_FAIL (menu) ;
-        menu->popup (a_event->button, a_event->time) ;
-    }
-
     bool on_breakpoints_view_button_press_signal (GdkEventButton *a_event)
     {
         LOG_FUNCTION_SCOPE_NORMAL_DD ;
@@ -432,6 +425,46 @@
         }
     }
 
+    void on_expose_event (GdkEventExpose *)
+    {
+        LOG_FUNCTION_SCOPE_NORMAL_DD;
+        NEMIVER_TRY
+        if (!is_up2date) {
+            finish_handling_debugger_stopped_event ();
+            is_up2date = true;
+        }
+        NEMIVER_CATCH
+    }
+
+    Gtk::Widget* load_menu (UString a_filename, UString a_widget_name)
+    {
+        NEMIVER_TRY
+        string relative_path = Glib::build_filename ("menus", a_filename) ;
+        string absolute_path ;
+        THROW_IF_FAIL (perspective.build_absolute_resource_path
+                (Glib::locale_to_utf8 (relative_path), absolute_path)) ;
+
+        workbench.get_ui_manager ()->add_ui_from_file
+                                        (Glib::locale_to_utf8 (absolute_path)) ;
+        NEMIVER_CATCH
+        return workbench.get_ui_manager ()->get_widget (a_widget_name);
+    }
+
+    Gtk::Widget* get_breakpoints_menu ()
+    {
+        THROW_IF_FAIL (breakpoints_menu);
+        return breakpoints_menu;
+    }
+
+    void popup_breakpoints_view_menu (GdkEventButton *a_event)
+    {
+        THROW_IF_FAIL (a_event) ;
+        THROW_IF_FAIL (tree_view) ;
+        Gtk::Menu *menu = dynamic_cast<Gtk::Menu*> (get_breakpoints_menu ()) ;
+        THROW_IF_FAIL (menu) ;
+        menu->popup (a_event->button, a_event->time) ;
+    }
+
     void init_actions()
     {
         static ui_utils::ActionEntry s_breakpoints_action_entries [] = {

Modified: trunk/src/persp/dbgperspective/nmv-call-stack.cc
==============================================================================
--- trunk/src/persp/dbgperspective/nmv-call-stack.cc	(original)
+++ trunk/src/persp/dbgperspective/nmv-call-stack.cc	Sat Jul  5 01:18:32 2008
@@ -108,6 +108,7 @@
     sigc::connection on_selection_changed_connection ;
     Gtk::Widget *callstack_menu ;
     Glib::RefPtr<Gtk::ActionGroup> call_stack_action_group;
+    bool is_up2date;
 
     Priv (IDebuggerSafePtr a_dbg,
           IWorkbench& a_workbench,
@@ -120,7 +121,8 @@
         cur_frame_index (-1),
         nb_frames_expansion_chunk (5),
         max_frames_to_show (nb_frames_expansion_chunk),
-        callstack_menu (0)
+        callstack_menu (0),
+        is_up2date (true)
     {
         connect_debugger_signals () ;
         init_actions ();
@@ -180,6 +182,15 @@
                                                 (call_stack_action_group);
     }
 
+    bool should_process_now ()
+    {
+        LOG_FUNCTION_SCOPE_NORMAL_DD;
+        THROW_IF_FAIL (widget);
+        bool is_visible = widget->is_drawable ();
+        LOG_DD ("is visible: " << is_visible);
+        return is_visible;
+    }
+
     Gtk::Widget* load_menu (UString a_filename, UString a_widget_name)
     {
         NEMIVER_TRY
@@ -230,29 +241,35 @@
         debugger->select_frame (cur_frame_index) ;
     }
 
+    void finish_handling_debugger_stopped_event ()
+    {
+        THROW_IF_FAIL (debugger) ;
+        debugger->list_frames () ;
+    }
+
     void on_debugger_stopped_signal (IDebugger::StopReason a_reason,
-                                     bool a_has_frame,
-                                     const IDebugger::Frame &a_frame,
-                                     int a_thread_id,
-                                     int a_bp_num,
-                                     const UString &a_cookie)
+                                     bool /*a_has_frame*/,
+                                     const IDebugger::Frame &/*a_frame*/,
+                                     int /*a_thread_id*/,
+                                     int /*a_bp_num*/,
+                                     const UString &/*a_cookie*/)
     {
         LOG_FUNCTION_SCOPE_NORMAL_DD ;
 
         NEMIVER_TRY
         LOG_DD ("stopped, reason: " << a_reason) ;
 
-        if (a_has_frame || a_frame.line () || a_thread_id
-            || a_bp_num || a_cookie.empty ()) {}
-
         if (a_reason == IDebugger::EXITED_SIGNALLED
             || a_reason == IDebugger::EXITED_NORMALLY
             || a_reason == IDebugger::EXITED) {
             return ;
         }
 
-        THROW_IF_FAIL (debugger) ;
-        debugger->list_frames () ;
+        if (should_process_now ()) {
+            finish_handling_debugger_stopped_event ();
+        } else {
+            is_up2date = false;
+        }
 
         NEMIVER_CATCH
     }
@@ -354,6 +371,18 @@
         NEMIVER_CATCH
     }
 
+    void on_expose_event_signal (GdkEventExpose *)
+    {
+        LOG_FUNCTION_SCOPE_NORMAL_DD;
+
+        NEMIVER_TRY
+        if (!is_up2date) {
+            finish_handling_debugger_stopped_event ();
+            is_up2date = true;
+        }
+        NEMIVER_CATCH
+    }
+
     void on_config_value_changed_signal (const UString &a_key,
                                          IConfMgr::Value &a_val)
     {
@@ -483,6 +512,11 @@
              (sigc::mem_fun (*this,
                              &CallStack::Priv::on_row_activated_signal))));
 
+        tree_view->signal_expose_event ().connect_notify
+            (sigc::mem_fun (this, &Priv::on_expose_event_signal));
+
+        tree_view->set_events (Gdk::EXPOSURE_MASK);
+
         Gtk::TreeViewColumn* column =
                             tree_view->get_column (CallStackCols::FUNCTION_NAME) ;
         THROW_IF_FAIL (column) ;

Modified: trunk/src/persp/dbgperspective/nmv-dbg-perspective.cc
==============================================================================
--- trunk/src/persp/dbgperspective/nmv-dbg-perspective.cc	(original)
+++ trunk/src/persp/dbgperspective/nmv-dbg-perspective.cc	Sat Jul  5 01:18:32 2008
@@ -2500,9 +2500,9 @@
     set_show_command_view (false) ;
     set_show_target_output_view (false) ;
     set_show_log_view (false) ;
+    set_show_terminal_view (true) ;
     set_show_call_stack_view (true) ;
     set_show_variables_editor_view (true) ;
-    set_show_terminal_view (true) ;
     set_show_breakpoints_view (true) ;
     set_show_registers_view (true) ;
 #ifdef WITH_MEMORYVIEW

Modified: trunk/src/persp/dbgperspective/nmv-local-vars-inspector.cc
==============================================================================
--- trunk/src/persp/dbgperspective/nmv-local-vars-inspector.cc	(original)
+++ trunk/src/persp/dbgperspective/nmv-local-vars-inspector.cc	Sat Jul  5 01:18:32 2008
@@ -67,6 +67,10 @@
     UString previous_function_name;
     Glib::RefPtr<Gtk::ActionGroup> var_inspector_action_group;
     bool is_new_frame;
+    bool is_up2date;
+    IDebugger::StopReason saved_reason;
+    bool saved_has_frame;
+    IDebugger::Frame saved_frame;
 
     Priv (IDebuggerSafePtr &a_debugger,
           IWorkbench &a_workbench,
@@ -76,7 +80,10 @@
         tree_view (VarsTreeView::create ()),
         dereference_mi (0),
         context_menu (0),
-        is_new_frame (false)
+        is_new_frame (false),
+        is_up2date (true),
+        saved_reason (IDebugger::UNDEFINED_REASON),
+        saved_has_frame (false)
     {
         LOG_FUNCTION_SCOPE_NORMAL_DD;
 
@@ -177,6 +184,15 @@
                             (function_arguments_row_ref->get_path ());
     }
 
+    bool should_process_now ()
+    {
+        LOG_FUNCTION_SCOPE_NORMAL_DD;
+        THROW_IF_FAIL (tree_view);
+        bool is_visible = tree_view->is_drawable ();
+        LOG_DD ("is visible: " << is_visible);
+        return is_visible;
+    }
+
     bool is_function_arguments_subtree_empty () const
     {
         Gtk::TreeModel::iterator it;
@@ -283,6 +299,8 @@
                             &Priv::on_tree_view_row_activated_signal));
         tree_view->signal_button_press_event ().connect_notify
             (sigc::mem_fun (this, &Priv::on_button_press_signal));
+        tree_view->signal_expose_event ().connect_notify
+            (sigc::mem_fun (this, &Priv::on_expose_event_signal));
     }
 
     void set_local_variables
@@ -359,7 +377,6 @@
                                   tree_store,
                                   parent_row_it);
         tree_view->expand_row (tree_store->get_path (parent_row_it), false);
-
     }
 
     void append_a_function_argument (const IDebugger::VariableSafePtr a_var)
@@ -415,6 +432,7 @@
 
         Gtk::TreeModel::iterator parent_row_it;
         get_function_arguments_row_iterator (parent_row_it);
+
         return vutil::update_a_variable (a_var, *tree_view, parent_row_it,
                                          true, false);
     }
@@ -499,19 +517,51 @@
         debugger->dereference_variable (variable);
     }
 
+    void finish_handling_debugger_stopped_event
+                                    (IDebugger::StopReason /*a_reason*/,
+                                     bool /*a_has_frame*/,
+                                     const IDebugger::Frame &a_frame)
+    {
+        LOG_FUNCTION_SCOPE_NORMAL_DD;
+
+        NEMIVER_TRY
+
+            THROW_IF_FAIL (tree_store);
+            if (is_new_frame) {
+                LOG_DD ("init tree view");
+                re_init_tree_view ();
+                LOG_DD ("list local variables");
+                debugger->list_local_variables ();
+                LOG_DD ("list frames arguments");
+                debugger->list_frames_arguments ();
+            } else {
+                IVarListWalkerSafePtr walker_list =
+                                    get_local_vars_walker_list ();
+                THROW_IF_FAIL (walker_list);
+                walker_list->do_walk_variables ();
+                walker_list = get_function_args_vars_walker_list ();
+                THROW_IF_FAIL (walker_list);
+                walker_list->do_walk_variables ();
+                walker_list = get_derefed_variables_walker_list ();
+                THROW_IF_FAIL (walker_list);
+                walker_list->do_walk_variables ();
+            }
+            previous_function_name = a_frame.function_name ();
+
+        NEMIVER_CATCH
+    }
+
     //****************************
     //<debugger signal handlers>
     //****************************
     void on_stopped_signal (IDebugger::StopReason a_reason,
                             bool a_has_frame,
                             const IDebugger::Frame &a_frame,
-                            int a_thread_id,
-                            int a_bp_num,
-                            const UString &a_cookie)
+                            int /*a_thread_id*/,
+                            int /*a_bp_num*/,
+                            const UString &/*a_cookie*/)
     {
         LOG_FUNCTION_SCOPE_NORMAL_DD;
-        if (a_frame.line () || a_thread_id
-            || a_bp_num || a_cookie.empty ()) {}
 
         NEMIVER_TRY
 
@@ -535,24 +585,17 @@
             } else {
                 is_new_frame = true;
             }
-            THROW_IF_FAIL (tree_store);
-            if (is_new_frame) {
-                LOG_DD ("init tree view");
-                re_init_tree_view ();
-                debugger->list_local_variables ();
+
+            if (should_process_now ()) {
+                finish_handling_debugger_stopped_event (a_reason,
+                                                        a_has_frame,
+                                                        a_frame);
             } else {
-                IVarListWalkerSafePtr walker_list =
-                                    get_local_vars_walker_list ();
-                THROW_IF_FAIL (walker_list);
-                walker_list->do_walk_variables ();
-                walker_list = get_function_args_vars_walker_list ();
-                THROW_IF_FAIL (walker_list);
-                walker_list->do_walk_variables ();
-                walker_list = get_derefed_variables_walker_list ();
-                THROW_IF_FAIL (walker_list);
-                walker_list->do_walk_variables ();
+                saved_reason = a_reason;
+                saved_has_frame = a_has_frame;
+                saved_frame = a_frame;
+                is_up2date = false;
             }
-            previous_function_name = a_frame.function_name ();
         }
 
         NEMIVER_CATCH
@@ -592,7 +635,11 @@
 
         map<int, list<IDebugger::VariableSafePtr> >::const_iterator it;
         it = a_frames_params.find (0);
-        if (it == a_frames_params.end ()) {return;}
+        if (it == a_frames_params.end ()) {
+            LOG_DD ("no frame params found");
+            return;
+        }
+        LOG_DD ("got: " << (int) it->second.size () << " function parameters");
 
         walker_list->remove_variables ();
         walker_list->append_variables (it->second);
@@ -756,13 +803,27 @@
         NEMIVER_CATCH
     }
 
+    void on_expose_event_signal (GdkEventExpose *)
+    {
+        LOG_FUNCTION_SCOPE_NORMAL_DD;
+        NEMIVER_TRY
+        if (!is_up2date) {
+            finish_handling_debugger_stopped_event (saved_reason,
+                                                    saved_has_frame,
+                                                    saved_frame);
+            is_up2date = true;
+        }
+        NEMIVER_CATCH
+    }
+
     void show_variable_type_in_dialog ()
     {
         LOG_FUNCTION_SCOPE_NORMAL_DD;
 
         if (!cur_selected_row) {return;}
         UString type =
-            (Glib::ustring) (*cur_selected_row)[vutil::get_variable_columns ().type];
+            (Glib::ustring)
+                    (*cur_selected_row)[vutil::get_variable_columns ().type];
         UString message;
         message.printf (_("Variable type is: \n %s"), type.c_str ());
 

Modified: trunk/src/persp/dbgperspective/nmv-memory-view.cc
==============================================================================
--- trunk/src/persp/dbgperspective/nmv-memory-view.cc	(original)
+++ trunk/src/persp/dbgperspective/nmv-memory-view.cc	Sat Jul  5 01:18:32 2008
@@ -1,26 +1,27 @@
-/*******************************************************************************
- *  PROJECT: Nemiver
+//Author: Jonathon Jongsma
+/*
+ *This file is part of the Nemiver project
  *
- *  AUTHOR: Jonathon Jongsma
- *  See COPYRIGHT file copyright information.
+ *Nemiver is free software; you can redistribute
+ *it and/or modify it under the terms of
+ *the GNU General Public License as published by the
+ *Free Software Foundation; either version 2,
+ *or (at your option) any later version.
  *
- *  License:
- *    This program is free software; you can redistribute it and/or modify
- *    it under the terms of the GNU General Public License as published by
- *    the Free Software Foundation; either version 2 of the License, or
- *    (at your option) any later version.
+ *Nemiver is distributed in the hope that it will
+ *be useful, but WITHOUT ANY WARRANTY;
+ *without even the implied warranty of
+ *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *See the GNU General Public License for more details.
  *
- *    This program is distributed in the hope that it will be useful,
- *    but WITHOUT ANY WARRANTY; without even the implied warranty of
- *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *    GNU General Public License for more details.
+ *You should have received a copy of the
+ *GNU General Public License along with Nemiver;
+ *see the file COPYING.
+ *If not, write to the Free Software Foundation,
+ *Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  *
- *    You should have received a copy of the GNU General Public License
- *    along with this program; if not, write to the
- *    Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- *    Boston, MA  02111-1307  USA
- *
- *******************************************************************************/
+ *See COPYRIGHT file copyright information.
+ */
 #include <sstream>
 #include <bitset>
 #include <iomanip>
@@ -60,8 +61,7 @@
         guint get_group_type () const
         {
             Gtk::TreeModel::iterator iter = get_active ();
-            if (iter)
-            {
+            if (iter) {
                 return (*iter)[m_cols.group_type];
             }
             else return GROUP_BYTE;
@@ -153,8 +153,7 @@
         LOG_FUNCTION_SCOPE_NORMAL_DD;
         NEMIVER_TRY
         THROW_IF_FAIL (m_address_entry);
-        switch (a_state)
-        {
+        switch (a_state) {
             case IDebugger::READY:
                 set_widgets_sensitive (true);
                 break;
@@ -173,8 +172,7 @@
         int editor_cpl, editor_lines;
         m_editor->get_geometry (editor_cpl, editor_lines);
         size_t addr = get_address ();
-        if (validate_address (addr))
-        {
+        if (validate_address (addr)) {
             LOG_DD ("Fetching " << editor_cpl * editor_lines << " bytes");
             // read as much memory as will fill the hex editor widget
             m_debugger->read_memory (addr, editor_cpl * editor_lines);
@@ -223,8 +221,7 @@
     {
         LOG_FUNCTION_SCOPE_NORMAL_DD;
         // FIXME: implement validation
-        if (a_addr)
-        {
+        if (a_addr) {
             return true;
         }
         return false;
@@ -273,12 +270,11 @@
         LOG_FUNCTION_SCOPE_NORMAL_DD;
         size_t length = a_change_data->end - a_change_data->start + 1;
         guchar* new_data = m_document->get_data (a_change_data->start, length);
-        if (new_data)
-        {
+        if (new_data) {
             std::vector<uint8_t> data(new_data, new_data + length);
             // set data in the debugger
-            m_debugger->set_memory(static_cast<size_t> (get_address () + a_change_data->start),
-                    data);
+            m_debugger->set_memory(static_cast<size_t>
+                                   (get_address () + a_change_data->start), data);
         }
     }
 
@@ -315,3 +311,4 @@
 }
 
 } // namespace nemiver
+

Modified: trunk/src/persp/dbgperspective/nmv-registers-view.cc
==============================================================================
--- trunk/src/persp/dbgperspective/nmv-registers-view.cc	(original)
+++ trunk/src/persp/dbgperspective/nmv-registers-view.cc	Sat Jul  5 01:18:32 2008
@@ -60,9 +60,11 @@
     SafePtr<Gtk::TreeView> tree_view ;
     Glib::RefPtr<Gtk::ListStore> list_store ;
     IDebuggerSafePtr& debugger;
+    bool is_up2date;
 
     Priv (IDebuggerSafePtr& a_debugger) :
-        debugger(a_debugger)
+        debugger(a_debugger),
+        is_up2date (true)
     {
         build_tree_view () ;
 
@@ -99,8 +101,32 @@
         Gtk::CellRendererText* renderer = dynamic_cast<Gtk::CellRendererText*>
             (col->get_first_cell_renderer ());
         THROW_IF_FAIL (renderer);
-        renderer->signal_edited ().connect (sigc::mem_fun (this,
-                    &Priv::on_register_value_edited));
+        renderer->signal_edited ().connect (sigc::mem_fun
+                    (*this, &Priv::on_register_value_edited));
+        tree_view->signal_expose_event ().connect_notify (sigc::mem_fun
+                    (*this, &Priv::on_expose_event_signal));
+    }
+
+    bool should_process_now ()
+    {
+        LOG_FUNCTION_SCOPE_NORMAL_DD;
+        THROW_IF_FAIL (tree_view);
+        bool is_visible = tree_view->is_drawable ();
+        LOG_DD ("is visible: " << is_visible);
+        return is_visible;
+    }
+
+    void finish_handling_debugger_stopped_event ()
+    {
+        LOG_FUNCTION_SCOPE_NORMAL_DD;
+        static bool first_run = true;
+        if (first_run) {
+            first_run = false;
+            debugger->list_register_names ();
+        }
+        else {
+            debugger->list_changed_registers ();
+        }
     }
 
     void on_debugger_stopped (IDebugger::StopReason a_reason,
@@ -110,19 +136,18 @@
                               int,
                               const UString&)
     {
+        LOG_FUNCTION_SCOPE_NORMAL_DD;
         if (a_reason == IDebugger::EXITED_SIGNALLED
             || a_reason == IDebugger::EXITED_NORMALLY
             || a_reason == IDebugger::EXITED) {
             return ;
         }
-        static bool first_run = true;
-        if (first_run) {
-            first_run = false;
-            debugger->list_register_names ();
-        }
-        else {
-            debugger->list_changed_registers ();
+        if (should_process_now ()) {
+            finish_handling_debugger_stopped_event ();
+        } else {
+            is_up2date = false;
         }
+
     }
 
     void on_debugger_registers_listed
@@ -135,8 +160,8 @@
         if (a_cookie.empty ()) {}
         list_store->clear ();
         LOG_DD ("got num registers: " << (int)a_regs.size ());
-        for (std::map<IDebugger::register_id_t, UString>::const_iterator reg_iter = a_regs.begin ();
-                reg_iter != a_regs.end (); ++reg_iter) {
+        std::map<IDebugger::register_id_t, UString>::const_iterator reg_iter;
+        for (reg_iter = a_regs.begin (); reg_iter != a_regs.end (); ++reg_iter) {
             Gtk::TreeModel::iterator tree_iter = list_store->append ();
             (*tree_iter)[get_columns ().id] = reg_iter->first;
             (*tree_iter)[get_columns ().name] = reg_iter->second;
@@ -161,26 +186,24 @@
     }
 
     void on_debugger_register_values_listed
-                            (const map<IDebugger::register_id_t, UString> &a_reg_values,
-                             const UString &a_cookie)
+                    (const map<IDebugger::register_id_t, UString> &a_reg_values,
+                     const UString &a_cookie)
     {
         LOG_FUNCTION_SCOPE_NORMAL_DD;
         NEMIVER_TRY
         for (Gtk::TreeModel::iterator tree_iter = list_store->children ().begin ();
                 tree_iter != list_store->children ().end (); ++tree_iter) {
             IDebugger::register_id_t id = (*tree_iter)[get_columns ().id];
-            std::map<IDebugger::register_id_t, UString>::const_iterator value_iter = a_reg_values.find (id);
-            if (value_iter != a_reg_values.end ())
-            {
+            std::map<IDebugger::register_id_t, UString>::const_iterator value_iter
+                                                    = a_reg_values.find (id);
+            if (value_iter != a_reg_values.end ()) {
                 (*tree_iter)[get_columns ().value] = value_iter->second;
                 if (a_cookie != "first-time") {
                     set_changed (tree_iter);
                 } else {
                     set_changed (tree_iter, false);
                 }
-            }
-            else
-            {
+            } else {
                 set_changed (tree_iter, false);
             }
         }
@@ -209,16 +232,16 @@
         debugger->list_register_values (regs);
     }
 
-    void on_debugger_register_value_changed (const Glib::ustring& a_register_name,
-                                    const Glib::ustring& a_new_value,
-                                    const Glib::ustring& a_cookie)
+    void on_debugger_register_value_changed (const Glib::ustring &a_register_name,
+                                             const Glib::ustring &a_new_value,
+                                             const Glib::ustring &/*a_cookie*/)
     {
         LOG_FUNCTION_SCOPE_NORMAL_DD;
-        if (a_cookie.empty ()) {}
-        for (Gtk::TreeModel::iterator tree_iter = list_store->children ().begin ();
-                tree_iter != list_store->children ().end (); ++tree_iter) {
-            if ((*tree_iter)[get_columns ().name] == a_register_name)
-            {
+        Gtk::TreeModel::iterator tree_iter;
+        for (tree_iter = list_store->children ().begin ();
+             tree_iter != list_store->children ().end ();
+             ++tree_iter) {
+            if ((*tree_iter)[get_columns ().name] == a_register_name) {
                 // no need to update if the value is the same as last time
                 if ((*tree_iter)[get_columns ().value] == a_new_value) {
                     (*tree_iter)[get_columns ().value] = a_new_value;
@@ -229,16 +252,25 @@
         }
     }
 
+    void on_expose_event_signal (GdkEventExpose *)
+    {
+        LOG_FUNCTION_SCOPE_NORMAL_DD;
+
+        NEMIVER_TRY
+        if (!is_up2date) {
+            finish_handling_debugger_stopped_event ();
+            is_up2date = true;
+        }
+        NEMIVER_CATCH
+    }
+
     // helper function which highlights a row in red or returns the text to
     // normal color to indicate whether it has changed since last update
     void set_changed (Gtk::TreeModel::iterator& iter, bool changed = true)
     {
-        if (changed)
-        {
+        if (changed) {
             (*iter)[get_columns ().fg_color]  = Gdk::Color ("red");
-        }
-        else
-        {
+        } else {
             (*iter)[get_columns ().fg_color] =
                 tree_view->get_style ()->get_text (Gtk::STATE_NORMAL);
         }

Modified: trunk/src/persp/dbgperspective/nmv-thread-list.cc
==============================================================================
--- trunk/src/persp/dbgperspective/nmv-thread-list.cc	(original)
+++ trunk/src/persp/dbgperspective/nmv-thread-list.cc	Sat Jul  5 01:18:32 2008
@@ -34,73 +34,93 @@
 NEMIVER_BEGIN_NAMESPACE (nemiver)
 
 struct ThreadListColumns : public Gtk::TreeModelColumnRecord {
-    Gtk::TreeModelColumn<int> thread_id ;
+    Gtk::TreeModelColumn<int> thread_id;
 
     ThreadListColumns ()
     {
-        add (thread_id) ;
+        add (thread_id);
     }
 };//end class ThreadListColumns
 
 static ThreadListColumns&
 thread_list_columns ()
 {
-    static ThreadListColumns s_thread_list_columns ;
-    return s_thread_list_columns ;
+    static ThreadListColumns s_thread_list_columns;
+    return s_thread_list_columns;
 }
 
 struct ThreadList::Priv {
-    IDebuggerSafePtr debugger ;
-    std::list<int> thread_ids ;
-    int current_thread ;
-    SafePtr<Gtk::TreeView> tree_view ;
-    Glib::RefPtr<Gtk::ListStore> list_store ;
-    sigc::signal<void, int> thread_selected_signal ;
+    IDebuggerSafePtr debugger;
+    std::list<int> thread_ids;
+    int current_thread;
+    SafePtr<Gtk::TreeView> tree_view;
+    Glib::RefPtr<Gtk::ListStore> list_store;
+    sigc::signal<void, int> thread_selected_signal;
     int current_thread_id;
-    sigc::connection tree_view_selection_changed_connection ;
+    sigc::connection tree_view_selection_changed_connection;
+    bool is_up2date;
 
     Priv (IDebuggerSafePtr &a_debugger) :
         debugger (a_debugger),
         current_thread (0),
-        current_thread_id (0)
+        current_thread_id (0),
+        is_up2date (true)
     {
-        build_widget () ;
-        connect_to_debugger_signals () ;
-        connect_to_widget_signals () ;
+        build_widget ();
+        connect_to_debugger_signals ();
+        connect_to_widget_signals ();
+    }
+
+    void finish_handling_debugger_stopped_event ()
+    {
+        LOG_FUNCTION_SCOPE_NORMAL_DD;
+        debugger->list_threads ();
+    }
+
+    bool should_process_now ()
+    {
+        LOG_FUNCTION_SCOPE_NORMAL_DD;
+        THROW_IF_FAIL (tree_view);
+        bool is_visible = tree_view->is_drawable ();
+        LOG_DD ("is visible: " << is_visible);
+        return is_visible;
     }
 
     void on_debugger_stopped_signal (IDebugger::StopReason a_reason,
-                                     bool a_has_frame,
-                                     const IDebugger::Frame &a_frame,
+                                     bool /*a_has_frame*/,
+                                     const IDebugger::Frame &/*a_frame*/,
                                      int a_thread_id,
                                      int /*bp_num*/,
-                                     const UString &a_cookie)
+                                     const UString &/*a_cookie*/)
     {
-        LOG_FUNCTION_SCOPE_NORMAL_DD ;
+        LOG_FUNCTION_SCOPE_NORMAL_DD;
         NEMIVER_TRY
-        if (a_has_frame || a_frame.level () || a_cookie.empty ()) {}
 
         if (a_reason == IDebugger::EXITED_SIGNALLED
             || a_reason == IDebugger::EXITED_NORMALLY) {
-            return ;
+            return;
+        }
+        current_thread_id = a_thread_id;
+        if (should_process_now ()) {
+            finish_handling_debugger_stopped_event ();
+        } else {
+            is_up2date = false;
         }
-        current_thread_id = a_thread_id ;
-        debugger->list_threads () ;
         NEMIVER_CATCH
     }
 
     void on_debugger_threads_listed_signal (const std::list<int> &a_threads,
                                             const UString &a_cookie)
     {
-        LOG_FUNCTION_SCOPE_NORMAL_DD ;
+        LOG_FUNCTION_SCOPE_NORMAL_DD;
 
         if (a_cookie.empty ()) {}
 
         NEMIVER_TRY
 
-        clear_threads () ;
-        set_thread_id_list (a_threads) ;
-        select_thread_id (current_thread_id, false) ;
+        clear_threads ();
+        set_thread_id_list (a_threads);
+        select_thread_id (current_thread_id, false);
 
         NEMIVER_CATCH
     }
@@ -109,117 +129,131 @@
                                              const IDebugger::Frame &a_frame,
                                              const UString &a_cookie)
     {
-        LOG_FUNCTION_SCOPE_NORMAL_DD ;
+        LOG_FUNCTION_SCOPE_NORMAL_DD;
 
         if (a_frame.level () || a_cookie.empty ()) {}
 
         NEMIVER_TRY
 
-        select_thread_id (a_tid, false) ;
-        thread_selected_signal.emit (a_tid) ;
+        select_thread_id (a_tid, false);
+        thread_selected_signal.emit (a_tid);
 
         NEMIVER_CATCH
     }
 
+    void on_expose_event_signal (GdkEventExpose *)
+    {
+        LOG_FUNCTION_SCOPE_NORMAL_DD;
+
+        NEMIVER_TRY
+        if (!is_up2date) {
+            finish_handling_debugger_stopped_event ();
+            is_up2date = true;
+        }
+        NEMIVER_CATCH
+    }
+
     void on_tree_view_selection_changed_signal ()
     {
-        LOG_FUNCTION_SCOPE_NORMAL_DD ;
+        LOG_FUNCTION_SCOPE_NORMAL_DD;
         NEMIVER_TRY
 
         if (!tree_view) {return;}
         if (!tree_view->get_selection ()) {return;}
 
         Gtk::TreeModel::iterator it =
-                                tree_view->get_selection ()->get_selected () ;
+                                tree_view->get_selection ()->get_selected ();
         if (!it) {return;}
 
         int thread_id = (int) it->get_value (thread_list_columns ().thread_id);
         if (thread_id <= 0) {return;}
 
-        THROW_IF_FAIL (debugger) ;
+        THROW_IF_FAIL (debugger);
 
-        debugger->select_thread (thread_id) ;
+        debugger->select_thread (thread_id);
 
         NEMIVER_CATCH
     }
 
     void build_widget ()
     {
-        list_store = Gtk::ListStore::create (thread_list_columns ()) ;
-        tree_view.reset (new Gtk::TreeView ()) ;
-        tree_view->set_model (list_store) ;
-        tree_view->get_selection ()->set_mode (Gtk::SELECTION_SINGLE) ;
+        list_store = Gtk::ListStore::create (thread_list_columns ());
+        tree_view.reset (new Gtk::TreeView ());
+        tree_view->set_model (list_store);
+        tree_view->get_selection ()->set_mode (Gtk::SELECTION_SINGLE);
         tree_view->append_column (_("Thread ID"),
-                                  thread_list_columns ().thread_id) ;
-        Gtk::TreeViewColumn *column = tree_view->get_column (0) ;
-        THROW_IF_FAIL (column) ;
-        column->set_clickable (false) ;
-        column->set_reorderable (false) ;
+                                  thread_list_columns ().thread_id);
+        Gtk::TreeViewColumn *column = tree_view->get_column (0);
+        THROW_IF_FAIL (column);
+        column->set_clickable (false);
+        column->set_reorderable (false);
     }
 
     void connect_to_debugger_signals ()
     {
-        THROW_IF_FAIL (debugger) ;
+        THROW_IF_FAIL (debugger);
 
         debugger->stopped_signal ().connect (sigc::mem_fun
-            (*this, &Priv::on_debugger_stopped_signal)) ;
+            (*this, &Priv::on_debugger_stopped_signal));
 
         debugger->threads_listed_signal ().connect (sigc::mem_fun
-            (*this, &Priv::on_debugger_threads_listed_signal)) ;
+            (*this, &Priv::on_debugger_threads_listed_signal));
 
         debugger->thread_selected_signal ().connect (sigc::mem_fun
-            (*this, &Priv::on_debugger_thread_selected_signal)) ;
+            (*this, &Priv::on_debugger_thread_selected_signal));
     }
 
     void connect_to_widget_signals ()
     {
-        THROW_IF_FAIL (debugger) ;
-        THROW_IF_FAIL (tree_view && tree_view->get_selection ()) ;
+        THROW_IF_FAIL (debugger);
+        THROW_IF_FAIL (tree_view && tree_view->get_selection ());
         tree_view_selection_changed_connection =
             tree_view->get_selection ()->signal_changed ().connect (sigc::mem_fun
-                (*this, &Priv::on_tree_view_selection_changed_signal)) ;
+                (*this, &Priv::on_tree_view_selection_changed_signal));
+        tree_view->signal_expose_event ().connect_notify (sigc::mem_fun
+                (*this, &Priv::on_expose_event_signal));
     }
 
     void set_a_thread_id (int a_id)
     {
-        THROW_IF_FAIL (list_store) ;
-        Gtk::TreeModel::iterator iter = list_store->append () ;
-        iter->set_value (thread_list_columns ().thread_id, a_id) ;
+        THROW_IF_FAIL (list_store);
+        Gtk::TreeModel::iterator iter = list_store->append ();
+        iter->set_value (thread_list_columns ().thread_id, a_id);
     }
 
     void set_thread_id_list (const std::list<int> &a_list)
     {
-        std::list<int>::const_iterator it ;
-        for (it = a_list.begin () ; it != a_list.end () ; ++it) {
-            set_a_thread_id (*it) ;
+        std::list<int>::const_iterator it;
+        for (it = a_list.begin (); it != a_list.end (); ++it) {
+            set_a_thread_id (*it);
         }
     }
 
     void clear_threads ()
     {
-        THROW_IF_FAIL (list_store) ;
-        list_store->clear () ;
+        THROW_IF_FAIL (list_store);
+        list_store->clear ();
     }
 
     void select_thread_id (int a_tid, bool a_emit_signal)
     {
-        THROW_IF_FAIL (list_store) ;
+        THROW_IF_FAIL (list_store);
 
-        Gtk::TreeModel::iterator it  ;
-        for (it = list_store->children ().begin () ;
-             it != list_store->children ().end () ;
+        Gtk::TreeModel::iterator it ;
+        for (it = list_store->children ().begin ();
+             it != list_store->children ().end ();
              ++it) {
-            LOG_DD ("testing list row") ;
+            LOG_DD ("testing list row");
             if ((int)(*it)->get_value (thread_list_columns ().thread_id) == a_tid) {
                 if (!a_emit_signal) {
-                    tree_view_selection_changed_connection.block (true) ;
+                    tree_view_selection_changed_connection.block (true);
                 }
-                tree_view->get_selection ()->select (it) ;
-                tree_view_selection_changed_connection.block (false) ;
+                tree_view->get_selection ()->select (it);
+                tree_view_selection_changed_connection.block (false);
             }
-            LOG_DD ("tested list row") ;
+            LOG_DD ("tested list row");
         }
-        current_thread_id = a_tid ;
+        current_thread_id = a_tid;
     }
 };//end ThreadList::Priv
 
@@ -235,47 +269,47 @@
 const list<int>&
 ThreadList::thread_ids () const
 {
-    LOG_FUNCTION_SCOPE_NORMAL_DD ;
+    LOG_FUNCTION_SCOPE_NORMAL_DD;
 
-    THROW_IF_FAIL (m_priv) ;
-    return m_priv->thread_ids ;
+    THROW_IF_FAIL (m_priv);
+    return m_priv->thread_ids;
 }
 
 int
 ThreadList::current_thread_id () const
 {
-    LOG_FUNCTION_SCOPE_NORMAL_DD ;
+    LOG_FUNCTION_SCOPE_NORMAL_DD;
 
-    THROW_IF_FAIL (m_priv) ;
-    return m_priv->current_thread ;
+    THROW_IF_FAIL (m_priv);
+    return m_priv->current_thread;
 }
 
 Gtk::Widget&
 ThreadList::widget () const
 {
-    LOG_FUNCTION_SCOPE_NORMAL_DD ;
+    LOG_FUNCTION_SCOPE_NORMAL_DD;
 
-    THROW_IF_FAIL (m_priv) ;
-    return *m_priv->tree_view ;
+    THROW_IF_FAIL (m_priv);
+    return *m_priv->tree_view;
 }
 
 void
 ThreadList::clear ()
 {
-    LOG_FUNCTION_SCOPE_NORMAL_DD ;
+    LOG_FUNCTION_SCOPE_NORMAL_DD;
 
-    THROW_IF_FAIL (m_priv) ;
+    THROW_IF_FAIL (m_priv);
     if (m_priv->list_store) {
-        m_priv->list_store->clear () ;
+        m_priv->list_store->clear ();
     }
-    m_priv->current_thread_id = -1 ;
+    m_priv->current_thread_id = -1;
 }
 
 sigc::signal<void, int>&
 ThreadList::thread_selected_signal () const
 {
-    THROW_IF_FAIL (m_priv) ;
-    return m_priv->thread_selected_signal ;
+    THROW_IF_FAIL (m_priv);
+    return m_priv->thread_selected_signal;
 }
 
 NEMIVER_END_NAMESPACE (nemiver)



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