nemiver r955 - in trunk: . src/dbgengine tests
- From: dodji svn gnome org
- To: svn-commits-list gnome org
- Subject: nemiver r955 - in trunk: . src/dbgengine tests
- Date: Sun, 30 Nov 2008 13:48:29 +0000 (UTC)
Author: dodji
Date: Sun Nov 30 13:48:29 2008
New Revision: 955
URL: http://svn.gnome.org/viewvc/nemiver?rev=955&view=rev
Log:
Fix 560662 - Support singular RESULT parsing.
Modified:
trunk/ChangeLog
trunk/src/dbgengine/nmv-gdbmi-parser.cc
trunk/src/dbgengine/nmv-gdbmi-parser.h
trunk/tests/test-gdbmi.cc
Modified: trunk/src/dbgengine/nmv-gdbmi-parser.cc
==============================================================================
--- trunk/src/dbgengine/nmv-gdbmi-parser.cc (original)
+++ trunk/src/dbgengine/nmv-gdbmi-parser.cc Sun Nov 30 13:48:29 2008
@@ -3625,8 +3625,9 @@
|| ch == '>'
|| ch == '<') {
++cur;
- CHECK_END2 (cur);
- continue;
+ if (!m_priv->index_passed_end (cur)) {
+ continue;
+ }
}
str_end = cur - 1;
break;
@@ -3894,6 +3895,16 @@
return true;
}
+/// parse a GDB/MI RESULT data structure.
+/// A result basically has the form:
+/// VARIABLE=VALUE, where VALUE is either a CONST, a LIST, or a TUPLE.
+/// So that's what the MI spec says. In practise, GDB can send RESULT
+/// constructs that have the form VARIABLE. No =VALUE part there. So we
+/// ought to be able to parse that as well, in GDBMIParser::BROKEN_MODE
+// parsing mode. Let's call that variant of RESULT a "SINGULAR RESULT".
+///
+/// Beware value is more complicated than what it looks like :-)
+/// Look at the GDB/MI spec for more.
bool
GDBMIParser::parse_gdbmi_result (UString::size_type a_from,
UString::size_type &a_to,
@@ -3904,10 +3915,27 @@
CHECK_END2 (cur);
UString variable;
- if (!parse_string (cur, cur, variable)) {
+ GDBMIValueSafePtr value;
+ bool is_singular = false;
+
+ if (get_mode () == BROKEN_MODE
+ && RAW_CHAR_AT (cur) == '"') {
+ if (!parse_c_string (cur, cur, variable)) {
+ LOG_PARSING_ERROR2 (cur);
+ return false;
+ }
+ } else if (!parse_string (cur, cur, variable)) {
LOG_PARSING_ERROR2 (cur);
return false;
}
+
+ if (get_mode () == BROKEN_MODE
+ && (m_priv->index_passed_end (cur)
+ || RAW_CHAR_AT (cur) != '=')) {
+ is_singular = true;
+ goto end;
+ }
+
CHECK_END2 (cur);
SKIP_BLANK2 (cur);
if (RAW_CHAR_AT (cur) != '=') {
@@ -3918,14 +3946,14 @@
++cur;
CHECK_END2 (cur);
- GDBMIValueSafePtr value;
if (!parse_gdbmi_value (cur, cur, value)) {
LOG_PARSING_ERROR2 (cur);
return false;
}
THROW_IF_FAIL (value);
- GDBMIResultSafePtr result (new GDBMIResult (variable, value));
+end:
+ GDBMIResultSafePtr result (new GDBMIResult (variable, value, is_singular));
THROW_IF_FAIL (result);
a_to = cur;
a_value = result;
Modified: trunk/src/dbgengine/nmv-gdbmi-parser.h
==============================================================================
--- trunk/src/dbgengine/nmv-gdbmi-parser.h (original)
+++ trunk/src/dbgengine/nmv-gdbmi-parser.h Sun Nov 30 13:48:29 2008
@@ -150,20 +150,25 @@
UString m_variable ;
GDBMIValueSafePtr m_value ;
+ bool m_is_singular;
public:
GDBMIResult () {}
GDBMIResult (const UString &a_variable,
- const GDBMIValueSafePtr &a_value) :
+ const GDBMIValueSafePtr &a_value,
+ bool is_singular=false) :
m_variable (a_variable),
- m_value (a_value)
+ m_value (a_value),
+ m_is_singular (is_singular)
{}
virtual ~GDBMIResult () {}
const UString& variable () const {return m_variable;}
void variable (const UString& a_in) {m_variable = a_in;}
const GDBMIValueSafePtr& value () const {return m_value;}
void value (const GDBMIValueSafePtr &a_in) {m_value = a_in;}
+ bool is_singular () const {return m_is_singular;}
+ void set_is_singular (bool a_singular) {m_is_singular = a_singular;}
};//end class GDBMIResult
/// A GDB/MI LIST. It can be a list of either GDB/MI Result or GDB/MI Value.
Modified: trunk/tests/test-gdbmi.cc
==============================================================================
--- trunk/tests/test-gdbmi.cc (original)
+++ trunk/tests/test-gdbmi.cc Sun Nov 30 13:48:29 2008
@@ -104,6 +104,8 @@
"addr=\"0x000013a0\",nr-bytes=\"32\",total-bytes=\"32\",next-row=\"0x000013c0\",prev-row=\"0x0000139c\",next-page=\"0x000013c0\",prev-page=\"0x00001380\",memory=[{addr=\"0x000013a0\",data=[\"0x10\",\"0x11\",\"0x12\",\"0x13\"],ascii=\"xxxx\"}]";
static const char* gv_gdbmi_result0 = "variable=[\"foo\", \"bar\"]";
+static const char* gv_gdbmi_result1 = "variable";
+static const char* gv_gdbmi_result2 = "\"variable\"";
static const char* gv_breakpoint_table0 =
"BreakpointTable={nr_rows=\"1\",nr_cols=\"6\",hdr=[{width=\"3\",alignment=\"-1\",col_name=\"number\",colhdr=\"Num\"},{width=\"14\",alignment=\"-1\",col_name=\"type\",colhdr=\"Type\"},{width=\"4\",alignment=\"-1\",col_name=\"disp\",colhdr=\"Disp\"},{width=\"3\",alignment=\"-1\",col_name=\"enabled\",colhdr=\"Enb\"},{width=\"10\",alignment=\"-1\",col_name=\"addr\",colhdr=\"Address\"},{width=\"40\",alignment=\"2\",col_name=\"what\",colhdr=\"What\"}],body=[bkpt={number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"0x08081566\",func=\"main\",file=\"main.cc\",fullname=\"/home/jonathon/Projects/agave.git/src/main.cc\",line=\"70\",times=\"0\"}]}";
@@ -115,6 +117,8 @@
static const char* gv_breakpoint_table2 =
"BreakpointTable={nr_rows=\"5\",nr_cols=\"6\",hdr=[{width=\"3\",alignment=\"-1\",col_name=\"number\",colhdr=\"Num\"},{width=\"14\",alignment=\"-1\",col_name=\"type\",colhdr=\"Type\"},{width=\"4\",alignment=\"-1\",col_name=\"disp\",colhdr=\"Disp\"},{width=\"3\",alignment=\"-1\",col_name=\"enabled\",colhdr=\"Enb\"},{width=\"10\",alignment=\"-1\",col_name=\"addr\",colhdr=\"Address\"},{width=\"40\",alignment=\"2\",col_name=\"what\",colhdr=\"What\"}],body=[bkpt={number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"0x0806f8f8\",func=\"main\",file=\"main.cc\",fullname=\"/home/jonathon/Projects/agave.git/src/main.cc\",line=\"73\",times=\"1\"},bkpt={number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"<PENDING>\",pending=\"gcs::MainWindow::MainWindow()\",times=\"0\"},bkpt={number=\"3\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"0x0805f91e\",func=\"gcs::MainWindow::Instance()\",file=\"gcs-mainwindow.cc\",fullname=\"/home/jonathon/Projects/agav
e.git/src/gcs-mainwindow.cc\",line=\"70\",times=\"1\"},bkpt={number=\"4\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"0x0805f91e\",func=\"gcs::MainWindow::Instance()\",file=\"gcs-mainwindow.cc\",fullname=\"/home/jonathon/Projects/agave.git/src/gcs-mainwindow.cc\",line=\"70\",times=\"1\"},bkpt={number=\"5\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"0x0805db44\",func=\"MainWindow\",file=\"gcs-mainwindow.cc\",fullname=\"/home/jonathon/Projects/agave.git/src/gcs-mainwindow.cc\",line=\"95\",times=\"0\"}]}";
+static const char* gv_breakpoint_table3 =
+"BreakpointTable={nr_rows=\"3\",nr_cols=\"6\",hdr=[{width=\"7\",alignment=\"-1\",col_name=\"number\",colhdr=\"Num\"},{width=\"14\",alignment=\"-1\",col_name=\"type\",colhdr=\"Type\"},{width=\"4\",alignment=\"-1\",col_name=\"disp\",colhdr=\"Disp\"},{width=\"3\",alignment=\"-1\",col_name=\"enabled\",colhdr=\"Enb\"},{width=\"18\",alignment=\"-1\",col_name=\"addr\",colhdr=\"Address\"},{width=\"40\",alignment=\"2\",col_name=\"what\",colhdr=\"What\"}],body=[bkpt={number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"0x000000000044f7d0\",func=\"internal_error\",file=\"utils.c\",fullname=\"/home/dodji/devel/git/archer.git/gdb/utils.c\",line=\"964\",times=\"0\"},bkpt={number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"0x000000000048ec10\",func=\"info_command\",file=\".././gdb/cli/cli-cmds.c\",fullname=\"/home/dodji/devel/git/archer.git/gdb/cli/cli-cmds.c\",line=\"198\",times=\"0\",script={\"silent\",\"return\"}},bkpt={number=\"3\",type=\"breakpoint\",di
sp=\"keep\",enabled=\"y\",addr=\"0x0000000000446ec0\",func=\"main\",file=\"gdb.c\",fullname=\"/home/dodji/devel/git/archer.git/gdb/gdb.c\",line=\"26\",times=\"1\"}]}";
void
test_str0 ()
@@ -579,7 +583,24 @@
GDBMIParser parser (gv_gdbmi_result0);
bool is_ok = parser.parse_gdbmi_result (cur, cur, result);
- BOOST_REQUIRE (is_ok && result);
+ BOOST_REQUIRE (is_ok && result && !result->is_singular ());
+
+ parser.push_input (gv_gdbmi_result1);
+ parser.set_mode (GDBMIParser::BROKEN_MODE);
+ cur = 0;
+ is_ok = parser.parse_gdbmi_result (cur, cur, result);
+ BOOST_REQUIRE (is_ok
+ && result
+ && result->is_singular ()
+ && result->variable () == "variable");
+
+ parser.push_input (gv_gdbmi_result2);
+ cur = 0;
+ is_ok = parser.parse_gdbmi_result (cur, cur, result);
+ BOOST_REQUIRE (is_ok
+ && result
+ && result->is_singular ()
+ && result->variable () == "variable");
}
void
@@ -610,6 +631,11 @@
cur = 0, cur = 0, breakpoints.clear();
parser.push_input (gv_breakpoint_table2);
BOOST_REQUIRE (parser.parse_breakpoint_table (cur, cur, breakpoints));
+
+ cur = 0, cur = 0, breakpoints.clear();
+ parser.push_input (gv_breakpoint_table3);
+ parser.set_mode (GDBMIParser::BROKEN_MODE);
+ BOOST_REQUIRE (parser.parse_breakpoint_table (cur, cur, breakpoints));
}
using boost::unit_test::test_suite ;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]