[nemiver] Handle assembly buffer when deleting breakpoints



commit b39fdfa1979b4c1190180a6ce9e8e84047d9e069
Author: Dodji Seketeli <dodji gnome org>
Date:   Sat Aug 7 16:02:58 2010 +0200

    Handle assembly buffer when deleting breakpoints
    
    	* src/uicommon/nmv-source-editor.h
    	(SourceEditor::remove_visual_breakpoint_from_line): Change
    	declaration to return a boolean.
    	(SourceEditor::remove_visual_breakpoint_from_address): New
    	function declaration.
    	* src/uicommon/nmv-source-editor.cc
    	(SourceEditor::remove_visual_breakpoint_from_line): Return a
    	boolean.
    	(SourceEditor::remove_visual_breakpoint_from_address): New
    	function.
    	* src/persp/dbgperspective/nmv-dbg-perspective.cc
    	(DBGPerspective::delete_visual_breakpoint): Handle assembly buffer.

 src/persp/dbgperspective/nmv-dbg-perspective.cc |   16 ++++++++++-
 src/uicommon/nmv-source-editor.cc               |   30 +++++++++++++++++++---
 src/uicommon/nmv-source-editor.h                |    3 +-
 3 files changed, 42 insertions(+), 7 deletions(-)
---
diff --git a/src/persp/dbgperspective/nmv-dbg-perspective.cc b/src/persp/dbgperspective/nmv-dbg-perspective.cc
index 1afaaf7..65df7bf 100644
--- a/src/persp/dbgperspective/nmv-dbg-perspective.cc
+++ b/src/persp/dbgperspective/nmv-dbg-perspective.cc
@@ -7244,8 +7244,20 @@ DBGPerspective::delete_visual_breakpoint (int a_breakpoint_num)
                                      true);
     }
     THROW_IF_FAIL (source_editor);
-    source_editor->remove_visual_breakpoint_from_line
-                                                (iter->second.line ()-1);
+    switch (source_editor->get_buffer_type ()) {
+    case SourceEditor::BUFFER_TYPE_ASSEMBLY:
+        source_editor->remove_visual_breakpoint_from_address
+            (iter->second.address ());
+        break;
+    case SourceEditor::BUFFER_TYPE_SOURCE:
+        source_editor->remove_visual_breakpoint_from_line
+            (iter->second.line ());
+        break;
+    case SourceEditor::BUFFER_TYPE_UNDEFINED:
+        THROW ("should not be reached");
+        break;
+    }
+
     m_priv->breakpoints.erase (iter);
     LOG_DD ("erased breakpoint number " << (int) a_breakpoint_num);
 }
diff --git a/src/uicommon/nmv-source-editor.cc b/src/uicommon/nmv-source-editor.cc
index 9532532..a82c242 100644
--- a/src/uicommon/nmv-source-editor.cc
+++ b/src/uicommon/nmv-source-editor.cc
@@ -793,22 +793,30 @@ SourceEditor::set_visual_breakpoint_at_line (int a_line, bool enabled)
     return true;
 }
 
-void
+/// Remove the marker that represent a breakpoint
+/// \param a_line the line to remove the breakpoint marker from.
+/// Note that a_line starts at 1. Gtk assumes that line numbers start
+/// at 0 but in Nemiver we assume -- by convention -- that they start
+/// at 1 mostly to comply with GDB.
+/// \return true upon successful completion, false otherwise.
+bool
 SourceEditor::remove_visual_breakpoint_from_line (int a_line)
 {
     std::map<int, Glib::RefPtr<gtksourceview::SourceMark> > *markers;
 
-    if ((markers = m_priv->get_markers ()) == 0)
-        return;
+    if ((markers = m_priv->get_markers ()) == 0 || a_line < 1)
+        return false;
 
+    --a_line;
     std::map<int, Glib::RefPtr<gtksourceview::SourceMark> >::iterator iter;
     iter = markers->find (a_line);
     if (iter == markers->end ()) {
-        return;
+        return false;
     }
     if (!iter->second->get_deleted ())
         source_view ().get_source_buffer ()->delete_mark (iter->second);
     markers->erase (iter);
+    return true;
 }
 
 void
@@ -1117,6 +1125,20 @@ SourceEditor::set_visual_breakpoint_at_address (const Address &a_address,
 
 }
 
+/// Remove the marker that represents a breakpoint at a given machine
+/// address.
+/// \param a_address the address from which to remove the breakpoint
+/// marker.
+/// \return true upon successful completion, false otherwise.
+bool
+SourceEditor::remove_visual_breakpoint_from_address (const Address &a_address)
+{
+    int line = -1;
+    if (!assembly_buf_addr_to_line (a_address, line))
+        return false;
+    return remove_visual_breakpoint_from_line (line);
+}
+
 bool
 SourceEditor::scroll_to_address (const Address &a_address)
 {
diff --git a/src/uicommon/nmv-source-editor.h b/src/uicommon/nmv-source-editor.h
index 5349bcb..8a9163d 100644
--- a/src/uicommon/nmv-source-editor.h
+++ b/src/uicommon/nmv-source-editor.h
@@ -82,7 +82,7 @@ public:
     bool move_where_marker_to_line (int a_line, bool a_do_scroll = true);
     void unset_where_marker ();
     bool set_visual_breakpoint_at_line (int a_line, bool enabled = true);
-    void remove_visual_breakpoint_from_line (int a_line);
+    bool remove_visual_breakpoint_from_line (int a_line);
     void clear_decorations ();
     bool is_visual_breakpoint_set_at_line (int a_line) const;
     bool scroll_to_line (int a_line);
@@ -145,6 +145,7 @@ public:
     bool place_cursor_at_address (const Address &);
     bool set_visual_breakpoint_at_address (const Address &a_address,
                                            bool enabled = true);
+    bool remove_visual_breakpoint_from_address (const Address &);
     bool scroll_to_address (const Address &a_address);
 
     /// @}



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