summaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.mi/mi-var-cp.cc
diff options
context:
space:
mode:
authorVladimir Prus <vladimir@codesourcery.com>2007-08-31 18:52:05 +0000
committerVladimir Prus <vladimir@codesourcery.com>2007-08-31 18:52:05 +0000
commit344198aa709d216b65db833c92e15157046dcc47 (patch)
treea155ea4aa0cd7bbaa5a58442ed12d0d72b098ccf /gdb/testsuite/gdb.mi/mi-var-cp.cc
parent6dc9852768604fe923b51e2306c87ffd7802d352 (diff)
downloadgdb-344198aa709d216b65db833c92e15157046dcc47.tar.gz
Implement -var-info-path-expression.
* mi/mi-cmds.h (mi_cmd_var_info_path_expression): Declare. * mi/mi-cmds.c (mi_cmds): Register var-info-path-expression. * mi/mi-cmd-var.c (mi_cmd_var_info_path_expression): New. * varobj.c (struct varobj): New field 'path_expr'. (c_path_expr_of_child, cplus_path_expr_of_child) (java_path_expr_of_child): New. (struct language_specific): New field path_expr_of_child. (varobj_create): Initialize the path_expr field. (varobj_get_path_expr): New. (new_variable): Initialize the path_expr field. (free_variable): Free the path_expr field. (adjust_value_for_children_access): New parameter WAS_TYPE. (c_number_of_children): Adjust. (c_describe_child): New parameter CFULL_EXPRESSION. Compute full expression. (c_value_of_child, c_type_of_child): Adjust. (cplus_number_of_children): Adjust. (cplus_describe_child): New parameter CFULL_EXPRESSION. Compute full expression. (cplus_name_of_child, cplus_value_of_child) (cplus_type_of_child): Adjust. * varobj.h (varobj_get_path_expr): Declare.
Diffstat (limited to 'gdb/testsuite/gdb.mi/mi-var-cp.cc')
-rw-r--r--gdb/testsuite/gdb.mi/mi-var-cp.cc86
1 files changed, 86 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.mi/mi-var-cp.cc b/gdb/testsuite/gdb.mi/mi-var-cp.cc
index ad8e75ae289..3faadc36de7 100644
--- a/gdb/testsuite/gdb.mi/mi-var-cp.cc
+++ b/gdb/testsuite/gdb.mi/mi-var-cp.cc
@@ -120,11 +120,97 @@ int reference_to_struct ()
/*: END: reference_to_struct :*/
}
+struct Base1
+{
+ int i;
+};
+
+struct Base2
+{
+ int i;
+};
+
+struct Derived : public Base1, public Base2
+{
+ int i;
+};
+
+/* Test for the -var-info-path-expression command. Although
+ said command is not specific to C++, it's of more importance
+ to C++ than to C, so we test it in mi-var-cp test. */
+int path_expression ()
+{
+ /*: BEGIN: path_expression :*/
+ int i = 10;
+ int *ip = &i;
+ /*: mi_create_varobj IP ip "create varobj for ip"
+ mi_list_varobj_children IP {{IP.\\*ip \\*ip 0 int}} "list children of IP"
+ mi_gdb_test "-var-info-path-expression IP.*ip" \
+ "\\^done,path_expr=\"\\*\\(ip\\)\"" \
+ "-var-info-path-expression IP.*ip"
+ :*/
+ Derived d;
+ Derived *dp = &d;
+ /*: mi_create_varobj DP dp "create varobj for dp"
+ mi_list_varobj_children DP \
+ {{DP.Base1 Base1 1 Base1} \
+ {DP.Base2 Base2 1 Base2} \
+ {DP.public public 1}} "list children of DP"
+ mi_gdb_test "-var-info-path-expression DP.Base1" \
+ "\\^done,path_expr=\"\\(\\*\\(Base1\\*\\) dp\\)\"" \
+ "-var-info-path-expression DP.Base1"
+ mi_list_varobj_children DP.public { \
+ {DP.public.i i 0 int} \
+ } "list children of DP.public"
+ mi_gdb_test "-var-info-path-expression DP.public.i" \
+ "\\^done,path_expr=\"\\(\\(dp\\)->i\\)\"" \
+ "-var-info-path-expression DP.public.i"
+ mi_list_varobj_children DP.Base1 { \
+ {DP.Base1.public public 1} \
+ } "list children of DP.Base1"
+ mi_list_varobj_children DP.Base1.public { \
+ {DP.Base1.public.i i 0 int} \
+ } "list children of DP.Base1.public"
+ mi_gdb_test "-var-info-path-expression DP.Base1.public.i" \
+ "\\^done,path_expr=\"\\(\\(\\(\\*\\(Base1\\*\\) dp\\)\\).i\\)\"" \
+ "-var-info-path-expression DP.Base1.public.i"
+
+ mi_gdb_test "-var-info-path-expression DP.public" \
+ "\\^done,path_expr=\"\"" \
+ "-var-info-path-expression DP.public"
+
+ mi_create_varobj D d "create varobj for d"
+ mi_list_varobj_children D \
+ {{D.Base1 Base1 1 Base1} \
+ {D.Base2 Base2 1 Base2} \
+ {D.public public 1}} "list children of D"
+ mi_gdb_test "-var-info-path-expression D.Base1" \
+ "\\^done,path_expr=\"\\(\\(Base1\\) d\\)\"" \
+ "-var-info-path-expression D.Base1"
+ :*/
+ int array[4] = {1,2,3};
+ array[3] = 10;
+ /*: mi_create_varobj A array "create varobj for array"
+ mi_list_varobj_children A { \
+ {A.0 0 0 int}
+ {A.1 1 0 int}
+ {A.2 2 0 int}
+ {A.3 3 0 int}} "list children of A"
+ mi_gdb_test "-var-info-path-expression A.2" \
+ "\\^done,path_expr=\"\\(array\\)\\\[2\\\]\"" \
+ "-var-info-path-expression A.2"
+ :*/
+
+ return 99;
+ /*: END: path_expression :*/
+}
+
int main ()
{
reference_update_tests ();
base_in_reference_test_main ();
reference_to_pointer ();
reference_to_struct ();
+ path_expression ();
return 0;
}