From 02142340a06871b1c75a1849438adc62aaffebbd Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Fri, 31 Aug 2007 18:52:05 +0000 Subject: 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. --- gdb/testsuite/ChangeLog | 6 +++ gdb/testsuite/gdb.mi/mi-var-cp.cc | 86 ++++++++++++++++++++++++++++++++++++++ gdb/testsuite/gdb.mi/mi-var-cp.exp | 1 + 3 files changed, 93 insertions(+) (limited to 'gdb/testsuite') diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 54d4776..c4d0887 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2007-08-31 Vladimir Prus + + * gdb.mi/mi-var-cp.cc (path_expression): New + function. + * gdb.mi/mi-var-cp.exp: Run path exression tests. + 2007-08-27 Markus Deuling * gdb.cp/cp-relocate.exp (add-symbol-file): Change addresses diff --git a/gdb/testsuite/gdb.mi/mi-var-cp.cc b/gdb/testsuite/gdb.mi/mi-var-cp.cc index ad8e75a..3faadc3 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; } diff --git a/gdb/testsuite/gdb.mi/mi-var-cp.exp b/gdb/testsuite/gdb.mi/mi-var-cp.exp index 0933cfe..1e331b9 100644 --- a/gdb/testsuite/gdb.mi/mi-var-cp.exp +++ b/gdb/testsuite/gdb.mi/mi-var-cp.exp @@ -44,6 +44,7 @@ mi_run_inline_test reference_update mi_run_inline_test base_in_reference mi_run_inline_test reference_to_pointer mi_run_inline_test reference_to_struct +mi_run_inline_test path_expression mi_gdb_exit return 0 -- cgit v1.1