[nemiver/varobjs-support] Parse the result of -var-info-path-expression
- From: Dodji Seketeli <dodji src gnome org>
- To: svn-commits-list gnome org
- Subject: [nemiver/varobjs-support] Parse the result of -var-info-path-expression
- Date: Mon, 25 May 2009 05:35:40 -0400 (EDT)
commit 5908aba26ea7bb9d4200918c196e9113a007e9c1
Author: Dodji Seketeli <dodji redhat com>
Date: Sat May 23 23:13:59 2009 +0200
Parse the result of -var-info-path-expression
* src/dbgengine/nmv-dbg-common.h:
(Output::ResultRecord::m_path_expression,
Output::ResultRecord::m_has_path_expression): New members.
(Output::ResultRecord::clear): Clear the new members we just added.
(Output::ResultRecord::path_expression,
Output::ResultRecord::has_path_expression): New accessor for the new
members.
* src/dbgengine/nmv-gdbmi-parser.h:
(GDBMIParser::parse_var_path_expression): Declare ...
* src/dbgengine/nmv-gdbmi-parser.cc:
(GDBMIParser::parse_var_path_expression): ... function.
(GDBMIParser::parse_result_record): Wire the parsing of variable
path expression here, in ^DONE records.
---
src/dbgengine/nmv-dbg-common.h | 26 ++++++++++++++
src/dbgengine/nmv-gdbmi-parser.cc | 66 +++++++++++++++++++++++++++++++++++-
src/dbgengine/nmv-gdbmi-parser.h | 4 ++
3 files changed, 94 insertions(+), 2 deletions(-)
diff --git a/src/dbgengine/nmv-dbg-common.h b/src/dbgengine/nmv-dbg-common.h
index 3e69c93..92ea578 100644
--- a/src/dbgengine/nmv-dbg-common.h
+++ b/src/dbgengine/nmv-dbg-common.h
@@ -410,6 +410,10 @@ public:
list<IDebugger::VariableSafePtr> m_changed_var_list;
bool m_has_changed_var_list;
+ // The path expression of a variable object.
+ UString m_path_expression;
+ bool m_has_path_expression;
+
public:
ResultRecord () {clear () ;}
@@ -448,6 +452,8 @@ public:
m_nb_variable_deleted = 0;
m_has_variable_children = false;
m_has_changed_var_list = false;
+ m_path_expression.clear ();
+ m_has_path_expression = false;
}
/// \name accessors
@@ -677,6 +683,26 @@ public:
has_changed_var_list (true);
}
+ const UString& path_expression () const
+ {
+ return m_path_expression;
+ }
+ void path_expression (const UString &a_str)
+ {
+ m_path_expression = a_str;
+ if (!a_str.empty ())
+ has_path_expression (true);
+ }
+
+ bool has_path_expression () const
+ {
+ return m_has_path_expression;
+ }
+ void has_path_expression (bool a)
+ {
+ m_has_path_expression = a;
+ }
+
/// @}
};//end class ResultRecord
diff --git a/src/dbgengine/nmv-gdbmi-parser.cc b/src/dbgengine/nmv-gdbmi-parser.cc
index 71848fc..0c7f134 100644
--- a/src/dbgengine/nmv-gdbmi-parser.cc
+++ b/src/dbgengine/nmv-gdbmi-parser.cc
@@ -186,6 +186,8 @@ const char* PREFIX_NUMCHILD = "numchild=\"";
const char* NUMCHILD = "numchild";
const char* PREFIX_VARIABLES_CHANGED_LIST = "changelist=[";
const char* CHANGELIST = "changelist";
+const char* PREFIX_PATH_EXPR = "path_expr=";
+const char* PATH_EXPR = "path_expr";
static bool
is_string_start (gunichar a_c)
@@ -1845,6 +1847,15 @@ fetch_gdbmi_result:
} else {
LOG_PARSING_ERROR2 (cur);
}
+ } else if (!RAW_INPUT.compare (cur,
+ strlen (PREFIX_PATH_EXPR),
+ PREFIX_PATH_EXPR)) {
+ UString var_expr;
+ if (parse_var_path_expression (cur, cur, var_expr)) {
+ result_record.path_expression (var_expr);
+ } else {
+ LOG_PARSING_ERROR2 (cur);
+ }
} else {
GDBMIResultSafePtr result;
if (!parse_gdbmi_result (cur, cur, result)
@@ -1884,7 +1895,11 @@ fetch_gdbmi_result:
PREFIX_CONNECTED)) {
result_record.kind (Output::ResultRecord::CONNECTED);
cur += 10;
- for (; !m_priv->index_passed_end (cur) && RAW_CHAR_AT (cur) != '\n';++cur) {}
+ for (;
+ !m_priv->index_passed_end (cur)
+ && RAW_CHAR_AT (cur) != '\n';
+ ++cur) {
+ }
} else if (!m_priv->input.raw ().compare (cur, strlen (PREFIX_ERROR),
PREFIX_ERROR)) {
result_record.kind (Output::ResultRecord::ERROR);
@@ -1903,7 +1918,11 @@ fetch_gdbmi_result:
} else {
LOG_ERROR ("weird, got error with no attribute. continuing.");
}
- for (; !m_priv->index_passed_end (cur) && RAW_CHAR_AT (cur) != '\n';++cur) {}
+ for (;
+ !m_priv->index_passed_end (cur)
+ && RAW_CHAR_AT (cur) != '\n';
+ ++cur) {
+ }
} else {
LOG_PARSING_ERROR2 (cur);
return false;
@@ -3380,6 +3399,49 @@ GDBMIParser::parse_var_changed_list (UString::size_type a_from,
return true;
}
+/// Parse the result of -var-info-path-expression.
+/// It's basically a RESULT of the form:
+/// path_expr="((Base)c).m_size)"
+bool
+GDBMIParser::parse_var_path_expression (UString::size_type a_from,
+ UString::size_type &a_to,
+ UString &a_expression)
+{
+ LOG_FUNCTION_SCOPE_NORMAL_D (GDBMI_PARSING_DOMAIN);
+ UString::size_type cur = a_from;
+ CHECK_END2 (cur);
+
+ if (RAW_INPUT.compare (cur, strlen (PREFIX_PATH_EXPR),
+ PREFIX_PATH_EXPR)) {
+ LOG_PARSING_ERROR2 (cur);
+ return false;
+ }
+
+ GDBMIResultSafePtr result;
+ if (!parse_gdbmi_result (cur, cur, result) || !result) {
+ LOG_PARSING_ERROR2 (cur);
+ return false;
+ }
+ // The name of RESULT must be PATH_EXPR
+ if (result->variable () != PATH_EXPR) {
+ LOG_ERROR ("expected gdbmi variable " << PATH_EXPR<< ", got: "
+ << result->variable () << "\'");
+ return false;
+ }
+ // The value of the RESULT must be a STRING
+ if (!result->value ()
+ || result->value ()->content_type () != GDBMIValue::STRING_TYPE
+ || result->value ()->get_string_content ().empty ()) {
+ LOG_ERROR ("expected a STRING value for the GDBMI variable "
+ << PATH_EXPR);
+ return false;
+ }
+
+ a_expression = result->value ()->get_string_content ();
+ a_to = cur;
+ return true;
+}
+
bool
GDBMIParser::parse_register_names (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 0b2d19f..e069129 100644
--- a/src/dbgengine/nmv-gdbmi-parser.h
+++ b/src/dbgengine/nmv-gdbmi-parser.h
@@ -605,6 +605,10 @@ public:
UString::size_type &a_to,
list<IDebugger::VariableSafePtr> &a_vars);
+ bool parse_var_path_expression (UString::size_type a_from,
+ UString::size_type &a_to,
+ UString &a_expression);
+
bool parse_result_record (UString::size_type a_from,
UString::size_type &a_to,
Output::ResultRecord &a_record);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]