[PATCH] Simplify logic in nmv-local-vars-inspector.cc



Hello,

While working on something else, it occurred to me that the logic used
in LocalVarsInspector::Priv::on_stopped_signal to detect that the
current frame is new or not could use some simplification.  For that,
I needed to add a new IDebugger::Frame::operator!= operator.

Tested and applied to master.

commit 58161ee4dace56619151dc77c0acd8781b6b207f
Author: Dodji Seketeli <dodji seketeli org>
Date:   Sun Nov 13 15:02:56 2011 +0100

    Simplify logic in nmv-local-vars-inspector.cc
    
    	* src/persp/dbgperspective/nmv-local-vars-inspector.cc
    	(on_stopped_signal):  Simplify logic.
    	* src/dbgengine/nmv-i-debugger.h (IDebugger::operator==): Make
    	this const.
    	(IDebugger::operator!=): New.

diff --git a/src/dbgengine/nmv-i-debugger.h b/src/dbgengine/nmv-i-debugger.h
index 1576a1f..b204c3e 100644
--- a/src/dbgengine/nmv-i-debugger.h
+++ b/src/dbgengine/nmv-i-debugger.h
@@ -286,7 +286,7 @@ public:
         /// \operators
         /// @{
 
-        bool operator== (const Frame &a)
+        bool operator== (const Frame &a) const
         {
             return (address () == a.address ()
                     && level () == a.level ()
@@ -296,6 +296,8 @@ public:
                     && library () == a.library ());
         }
 
+        bool operator!= (const Frame &a) const {return !(operator== (a));}
+
         /// @}
         /// \name accessors
 
diff --git a/src/persp/dbgperspective/nmv-local-vars-inspector.cc b/src/persp/dbgperspective/nmv-local-vars-inspector.cc
index 069687d..05659c3 100644
--- a/src/persp/dbgperspective/nmv-local-vars-inspector.cc
+++ b/src/persp/dbgperspective/nmv-local-vars-inspector.cc
@@ -715,34 +715,23 @@ public:
         LOG_DD ("stopped, reason: " << a_reason);
         if (a_reason == IDebugger::EXITED_SIGNALLED
             || a_reason == IDebugger::EXITED_NORMALLY
-            || a_reason == IDebugger::EXITED) {
+            || a_reason == IDebugger::EXITED
+            || !a_has_frame) {
             return;
         }
 
         THROW_IF_FAIL (debugger);
-        if (a_has_frame) {
-            saved_frame = a_frame;
-            LOG_DD ("prev frame address: '"
-                    << previous_function_name
-                    << "'");
-            LOG_DD ("cur frame address: "
-                    << a_frame.function_name ()
-                    << "'");
-            if (previous_function_name == a_frame.function_name ()) {
-                is_new_frame = false;
-            } else {
-                is_new_frame = true;
-            }
+        is_new_frame = (saved_frame != a_frame);
+        saved_frame = a_frame;
 
-            if (should_process_now ()) {
-                finish_handling_debugger_stopped_event (a_reason,
-                                                        a_has_frame,
-                                                        a_frame);
-            } else {
-                saved_reason = a_reason;
-                saved_has_frame = a_has_frame;
-                is_up2date = false;
-            }
+        if (should_process_now ()) {
+            finish_handling_debugger_stopped_event (a_reason,
+                                                    a_has_frame,
+                                                    a_frame);
+        } else {
+            saved_reason = a_reason;
+            saved_has_frame = a_has_frame;
+            is_up2date = false;
         }
 
         NEMIVER_CATCH

-- 
		Dodji


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