[nemiver] Skip unknown output records.
- From: Dodji Seketeli <dodji src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nemiver] Skip unknown output records.
- Date: Sat, 19 Jun 2010 16:50:41 +0000 (UTC)
commit 946ee17da34dd981dc901531bc52e6e8b920fad7
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 dd534c5..5653890 100644
--- a/src/dbgengine/nmv-gdb-engine.cc
+++ b/src/dbgengine/nmv-gdb-engine.cc
@@ -385,16 +385,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 3fbf341..22444ac 100644
--- a/src/dbgengine/nmv-gdbmi-parser.cc
+++ b/src/dbgengine/nmv-gdbmi-parser.cc
@@ -1608,6 +1608,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 03cb3db..f3b4909 100644
--- a/src/dbgengine/nmv-gdbmi-parser.h
+++ b/src/dbgengine/nmv-gdbmi-parser.h
@@ -633,6 +633,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]