[nemiver/follow-fork-mode] Skip unknown output records.



commit acab9cf79291db50b3fbe9c4ce62620fffad4917
Author: Dodji Seketeli <dodji redhat com>
Date:   Sat Jun 19 18:45:29 2010 +0200

    Skip unknown output records.
    
    	* src/dbgengine/nmv-gdbmi-parser.h
    	(GDBMIParser::skip_output_record): Declare new fn.
    	* src/dbgengine/nmv-gdbmi-parser.cc
    	(GDBMIParser::skip_output_record): Define it.
    	* src/dbgengine/nmv-gdb-engine.cc
    	(GDBEngine::Priv::on_gdb_stdout_signal): Use it.

 src/dbgengine/nmv-gdb-engine.cc   |   18 +++++++++-------
 src/dbgengine/nmv-gdbmi-parser.cc |   40 +++++++++++++++++++++++++++++++++++++
 src/dbgengine/nmv-gdbmi-parser.h  |    3 ++
 3 files changed, 53 insertions(+), 8 deletions(-)
---
diff --git a/src/dbgengine/nmv-gdb-engine.cc b/src/dbgengine/nmv-gdb-engine.cc
index 6d4fb28..2bcd070 100644
--- a/src/dbgengine/nmv-gdb-engine.cc
+++ b/src/dbgengine/nmv-gdb-engine.cc
@@ -382,16 +382,18 @@ public:
                         << "\nfrom: " << (int) from
                         << "\nto: " << (int) to << "\n"
                         << "\nstrlen: " << (int) a_buf.size ());
-                break;
+                gdbmi_parser.skip_output_record (from, to);
+                output.parsing_succeeded (false);
+            } else {
+                output.parsing_succeeded (true);
             }
 
-            //parsing GDB/MI output succeeded.
-            //Check if the output contains the result to a command issued by
-            //the user. If yes, build the CommandAndResult, update the
-            //command queue and notify the user that the command it issued
-            //has a result.
-            //
-            output.parsing_succeeded (true);
+
+            // Check if the output contains the result to a command issued by
+            // the user. If yes, build the CommandAndResult, update the
+            // command queue and notify the user that the command it issued
+            // has a result.
+
             UString output_value;
             output_value.assign (a_buf, from, to - from +1);
             output.raw_value (output_value);
diff --git a/src/dbgengine/nmv-gdbmi-parser.cc b/src/dbgengine/nmv-gdbmi-parser.cc
index 68342f3..b65181d 100644
--- a/src/dbgengine/nmv-gdbmi-parser.cc
+++ b/src/dbgengine/nmv-gdbmi-parser.cc
@@ -1610,6 +1610,46 @@ GDBMIParser::parse_output_record (UString::size_type a_from,
     return true;
 }
 
+/// Skip everything from the current output report until the next
+/// "(gdb)" marker, meaning the start of the next output record.
+/// \param a_from the index where to start skipping from
+/// \param a_to output parameter. If the function returns true this
+/// parameter is set to the index of the character that comes right
+/// after the "(gdb)" mark. Otherwise, it's set right after the end of
+/// the stream.
+/// \return true if "(gdb)" was found, false if we reached end of
+/// stream before.
+bool
+GDBMIParser::skip_output_record (UString::size_type a_from,
+				 UString::size_type &a_to)
+{
+    LOG_FUNCTION_SCOPE_NORMAL_D (GDBMI_PARSING_DOMAIN);
+    UString::size_type cur = a_from;
+
+    if (m_priv->index_passed_end (cur)) {
+        LOG_PARSING_ERROR2 (cur);
+        return false;
+    }
+
+    bool found = false;
+    while (!found) {
+        if (m_priv->index_passed_end (cur + 5)) {
+            while (!m_priv->index_passed_end (cur))
+                ++cur;
+            break;
+        }
+        if (RAW_CHAR_AT (cur) == '('
+            && RAW_CHAR_AT (cur + 1) == 'g'
+            && RAW_CHAR_AT (cur + 2) == 'd'
+            && RAW_CHAR_AT (cur + 3) == 'b'
+            && RAW_CHAR_AT (cur + 4) == ')')
+            found = true;
+        cur += 5;
+    }
+    a_to = cur;
+    return found;
+}
+
 bool
 GDBMIParser::parse_out_of_band_record (UString::size_type a_from,
                                        UString::size_type &a_to,
diff --git a/src/dbgengine/nmv-gdbmi-parser.h b/src/dbgengine/nmv-gdbmi-parser.h
index 096fead..3eba502 100644
--- a/src/dbgengine/nmv-gdbmi-parser.h
+++ b/src/dbgengine/nmv-gdbmi-parser.h
@@ -647,6 +647,9 @@ public:
                               UString::size_type &a_to,
                               Output &a_output);
 
+    bool skip_output_record (UString::size_type a_from,
+			     UString::size_type &a_to);
+
     //*********************
     //</Parsing entry points.>
     //*********************



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