[nemiver/count-point: 4/14] Handle continguous out-of-band-records better



commit 1e712b16e017a59eb40fa857e30305a3bfab3ce1
Author: Dodji Seketeli <dodji seketeli org>
Date:   Sat Oct 9 12:59:29 2010 +0200

    Handle continguous out-of-band-records better
    
    	* src/dbgengine/nmv-dbg-common.h
    	(Output::OutOfBandRecord::is_running): New accessor.
    	* src/dbgengine/nmv-gdbmi-parser.cc
    	(GDBMIParser::parse_out_of_band_record): Mark EXEC-ASYNC-OUTPUT of
    	ASSYNC-CLASS running as a "running" out-of-band-record.
    	* src/dbgengine/nmv-gdb-engine.cc (OnStoppedHandler::can_handle):
    	When multiple contiguous out-of-band-records are emitted in the
    	same output record, detect when an ASYNC-RECORD says the target is
    	stopped, then another one says the target is running. In such
    	cases, the target is considered to be running.  Such cases cases
    	can arise when a "continu" command is attached to a break
    	point. In that case when the breakpoint is hit, the execution then
    	continues straight away. So we get an output record containing two
    	out-of-band-records; one saying the target is stopped and the next
    	one saying the target is running.

 src/dbgengine/nmv-dbg-common.h    |    5 +++++
 src/dbgengine/nmv-gdb-engine.cc   |   19 ++++++++++++++++---
 src/dbgengine/nmv-gdbmi-parser.cc |    1 +
 3 files changed, 22 insertions(+), 3 deletions(-)
---
diff --git a/src/dbgengine/nmv-dbg-common.h b/src/dbgengine/nmv-dbg-common.h
index 0cbe9ea..3885e3d 100644
--- a/src/dbgengine/nmv-dbg-common.h
+++ b/src/dbgengine/nmv-dbg-common.h
@@ -210,6 +210,7 @@ public:
         bool m_has_stream_record;
         StreamRecord m_stream_record;
         bool m_is_stopped;
+	bool m_is_running;
         IDebugger::StopReason m_stop_reason;
         bool m_has_frame;
         IDebugger::Frame m_frame;
@@ -284,6 +285,9 @@ public:
         bool is_stopped () const {return m_is_stopped;}
         void is_stopped (bool a_in) {m_is_stopped = a_in;}
 
+	bool is_running () const {return m_is_running;}
+        void is_running (bool a) {m_is_running = a;}
+
         IDebugger::StopReason stop_reason () const {return m_stop_reason;}
         UString stop_reason_as_str () const
         {
@@ -319,6 +323,7 @@ public:
             m_has_stream_record = false;
             m_stream_record.clear ();
             m_is_stopped = false;
+            m_is_running = false;
             m_stop_reason = IDebugger::UNDEFINED_REASON;
             m_has_frame = false;
             m_frame.clear ();
diff --git a/src/dbgengine/nmv-gdb-engine.cc b/src/dbgengine/nmv-gdb-engine.cc
index 5711fe3..f776b28 100644
--- a/src/dbgengine/nmv-gdb-engine.cc
+++ b/src/dbgengine/nmv-gdb-engine.cc
@@ -1280,9 +1280,22 @@ struct OnStoppedHandler: OutputHandler {
         }
         list<Output::OutOfBandRecord>::iterator iter;
 
-        for (iter = a_in.output ().out_of_band_records ().begin ();
-                iter != a_in.output ().out_of_band_records ().end ();
-                ++iter) {
+        // We want to detect the last out-of-band-record that would
+        // possibly tell us if the target was stopped somewhere. As we
+        // can have multiple contiguous OOBRs sent by GDB (e.g, when a
+        // countpoint is hit multiple times, each time it's hit we get
+        // an OOBR saying the target is stopped, followed by another
+        // one saying the target is running). So we need to start
+        // walking the OOBRs from the end, and stop at the first OOBR
+        // that tells us that the target has stopped. Then if before
+        // that we saw an OOBR telling us that that the target was
+        // running, then the target is running; otherwise it's stopped
+        iter = a_in.output ().out_of_band_records ().end ();
+        for (--iter;
+             iter != a_in.output ().out_of_band_records ().end ();
+             --iter) {
+            if (iter->is_running ())
+                break;
             if (iter->is_stopped ()) {
                 m_is_stopped = true;
                 m_out_of_band_record = *iter;
diff --git a/src/dbgengine/nmv-gdbmi-parser.cc b/src/dbgengine/nmv-gdbmi-parser.cc
index ce4236d..156a73e 100644
--- a/src/dbgengine/nmv-gdbmi-parser.cc
+++ b/src/dbgengine/nmv-gdbmi-parser.cc
@@ -1734,6 +1734,7 @@ GDBMIParser::parse_out_of_band_record (UString::size_type a_from,
             return false;
         }
         record.thread_id (thread_id);
+        record.is_running (true);
         goto end;
     }
 



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