| # Copyright (C) 2004 Free Software Foundation, Inc. |
| # |
| # This Program Is Free software; you can redistribute it and/or modify |
| # it under the terms of the GNU General Public License as published by |
| # the Free Software Foundation; either version 2 of the License, or |
| # (at your option) any later version. |
| # |
| # This program is distributed in the hope that it will be useful, |
| # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| # GNU General Public License for more details. |
| # |
| # You should have received a copy of the GNU General Public License |
| # along with this program; if not, write to the Free Software |
| # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| |
| # Please email any bugs, comments, and/or additions to this file to: |
| # bug-gdb@prep.ai.mit.edu |
| |
| # Test Apple local commands -file-list-statics and -file-list-globals. |
| # |
| # Written by Jim Ingham <jingham@apple.com> |
| # |
| # This only tests the "new style" -file, -shlib, etc. form and not the original one. |
| # Consts are handled differently between C & C++, so we test both languages. |
| |
| load_lib mi-support.exp |
| set MIFLAGS "-i=mi1" |
| |
| gdb_exit |
| if [mi_gdb_start] { |
| continue |
| } |
| |
| set testfile "file-statics" |
| set srcfile ${testfile}.c |
| set second_srcfile more-statics.c |
| |
| set binfile ${objdir}/${subdir}/${testfile} |
| if { [gdb_compile "$srcdir/$subdir/$srcfile $srcdir/$subdir/$second_srcfile" "${binfile}" executable debug] != "" } { |
| gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." |
| } |
| |
| mi_delete_breakpoints |
| mi_gdb_reinitialize_dir $srcdir/$subdir |
| mi_gdb_load ${binfile} |
| |
| # First test some error conditions: |
| |
| proc test_errors {command} { |
| append usage_error {\^error,msg="} mi_cmd_ [regsub -all -- - $command _] \ |
| {: Usage: -file FILE -shlib SHLIB VALUES \[-filter FILTER\] \[-constants 0/1\]"} |
| |
| mi_gdb_test "10-$command" \ |
| "10$usage_error" \ |
| "$command no arguments error" |
| |
| mi_gdb_test "11-$command -file nofile" \ |
| "11$usage_error" \ |
| "$command only file error" |
| |
| mi_gdb_test "12-$command -file nofile -shlib noshlib" \ |
| "12$usage_error" \ |
| "$command no values error" |
| |
| mi_gdb_test "13-$command -file nofile -shlib noshlib -filter nofilter" \ |
| "13$usage_error" \ |
| "$command no values plus filter error" |
| |
| mi_gdb_test "14-$command -file nofile --no-values -filter nofilter" \ |
| "14$usage_error" \ |
| "$command no shlib error" |
| |
| mi_gdb_test "15-$command -file --no-values -shlib noshlib -filter nofilter" \ |
| "15$usage_error" \ |
| "$command file argument missing error" |
| |
| } |
| |
| # Test file-list-statics |
| |
| test_errors file-list-statics |
| |
| # This is annoying, but DWARF lists the statics in the reverse order from stabs |
| # so we have to test the return in either order. |
| |
| proc either_way {first second {third {}} {fourth {}}} { |
| if {[string equal $third ""]} { |
| return [format {\^done,statics=\[(%s,%s|%s,%s)\]} $first $second $second $first] |
| } else { |
| return [format {\^done,statics=\[(%s,%s|%s,%s)\]} $first $second $third $fourth] |
| } |
| } |
| |
| set either_way [either_way {\{name="static_doesnt_match"\}} {\{name="static_int"\}}] |
| |
| # One test of the old style just to make sure we don't totally break it till we remove it: |
| |
| mi_gdb_test {30-file-list-statics file-statics.c file-statics --no-values} \ |
| "30$either_way" \ |
| {-file-list-statics: Old style - supply file and shlib, no values} |
| |
| # These are the new style: |
| |
| mi_gdb_test {20-file-list-statics -file file-statics.c -shlib file-statics --no-values} \ |
| "20$either_way" \ |
| {-file-list-statics: supply file and shlib, no values} |
| |
| mi_gdb_test {21-file-list-statics -file file-statics.c -shlib "" --no-values} \ |
| "21$either_way" \ |
| {-file-list-statics: supply file and shlib, no values} |
| |
| mi_gdb_test {22-file-list-statics -file file-statics.c -shlib file-statics --no-values -filter _int} \ |
| {22\^done,statics=\[\{name="static_doesnt_match"\}\]} \ |
| {-file-list-statics: supply file and shlib, no values, with filter} |
| |
| mi_gdb_test {23-file-list-statics -file file-statics.c -shlib file-statics --no-values -constants 0} \ |
| "23$either_way" \ |
| {-file-list-statics: supply file and shlib, no values, no constants} |
| |
| mi_gdb_test {24-file-list-statics -file "" -shlib file-statics --no-values} \ |
| {24\^done,statics=\[]} \ |
| {-file-list-statics: empty file and shlib, no values} |
| |
| set static_doesnt_match {\{name="static_doesnt_match",type="int",value="8"\}} |
| set static_int {\{name="static_int",type="int",value="7"\}} |
| set either_way [either_way $static_doesnt_match $static_int] |
| |
| mi_gdb_test {21-file-list-statics -file file-statics.c -shlib file-statics --simple-values} \ |
| "21$either_way" \ |
| {-file-list-statics: supply file and shlib, no simple} |
| |
| set static_doesnt_match {varobj=\{exp="static_doesnt_match",value="8",name="var%d",numchild="0",type="int",typecode="INT",dynamic_type="",resolved_type="int",in_scope="true",block_start_addr="no block",block_end_addr="no block"\}} |
| set static_int {varobj=\{exp="static_int",value="7",name="var%d",numchild="0",type="int",typecode="INT",dynamic_type="",resolved_type="int",in_scope="true",block_start_addr="no block",block_end_addr="no block"\}} |
| set static_doesnt_match_1 [format $static_doesnt_match 1] |
| set static_doesnt_match_2 [format $static_doesnt_match 2] |
| set static_int_1 [format $static_int 1] |
| set static_int_2 [format $static_int 2] |
| |
| set either_way [either_way $static_doesnt_match_1 $static_int_2 $static_int_1 $static_doesnt_match_2] |
| |
| mi_gdb_test {21-file-list-statics -file file-statics.c -shlib file-statics --make-varobjs} \ |
| "21$either_way" \ |
| {-file-list-statics: supply file and shlib, make varobj} |
| |
| |
| # Now test file-list-globals |
| |
| test_errors file-list-globals |
| |
| # This is the old style again: |
| |
| mi_gdb_test {49-file-list-globals file-statics.c file-statics --no-values} \ |
| {49\^done,globals=\[\{name="const_char"\},\{name="global_int"\}\]} \ |
| {-file-list-globals: Old style - supply file and shlib, no values} |
| |
| # These are the new style: |
| |
| mi_gdb_test {50-file-list-globals -file file-statics.c -shlib file-statics --no-values} \ |
| {50\^done,globals=\[\{name="const_doesnt_match"\},\{name="const_int"\},\{name="const_char"\},\{name="global_int"\}\]} \ |
| {-file-list-globals: supply file and shlib, no values} |
| |
| mi_gdb_test {51-file-list-globals -file file-statics.c -shlib file-statics --no-values -filter _int} \ |
| {51\^done,globals=\[\{name="const_doesnt_match"\},\{name="const_char"\}\]} \ |
| {-file-list-globals: supply file and shlib, no values} |
| |
| mi_gdb_test {52-file-list-globals -file file-statics.c -shlib file-statics --no-values -constants 0} \ |
| {52\^done,globals=\[\{name="const_char"\},\{name="global_int"\}\]} \ |
| {-file-list-globals: supply file and shlib, no values, no constants} |
| |
| mi_gdb_test {53-file-list-globals -file file-statics.c -shlib file-statics --no-values} \ |
| {53\^done,globals=\[\{name="const_doesnt_match"\},\{name="const_int"\},\{name="const_char"\},\{name="global_int"\}\]} \ |
| {-file-list-globals: supply file and shlib, no values} |
| |
| mi_gdb_test {54-file-list-globals -file file-statics.c -shlib file-statics --simple-values} \ |
| {54\^done,globals=\[\{name="const_doesnt_match",type="const int",value="6"\},\{name="const_int",type="const int",value="5"\},\{name="const_char",type="const char \*",value="0x([0-9a-f]+) \\"I am a constant\\""\},\{name="global_int",type="int",value="6"\}\]} \ |
| {-file-list-globals: supply file and shlib, simple values} |
| |
| mi_gdb_test {55-file-list-globals -file "" -shlib file-statics --no-values} \ |
| {55\^done,.*file=\[filename=".*/more-statics.c",globals=\[\{name="second_const_int"\},\{name="second_const_char"\},\{name="second_const_doesnt_match"\},\{name="second_global_int"\}\]\],.*file=\[filename=".*/file-statics.c",globals=\[\{name="const_doesnt_match"\},\{name="const_int"\},\{name="const_char"\},\{name="global_int"\}\]\].*} \ |
| {-file-list-globals: all files, supply shlib, no values} |
| |
| # Now test a few C++ cases. |
| |
| gdb_exit |
| if [mi_gdb_start] { |
| continue |
| } |
| |
| set testfile "file-statics-cpp" |
| set srcfile ${testfile}.cpp |
| |
| set binfile ${objdir}/${subdir}/${testfile} |
| if { [gdb_compile "$srcdir/$subdir/$srcfile" "${binfile}" executable {debug c++}] != "" } { |
| gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." |
| } |
| |
| mi_delete_breakpoints |
| mi_gdb_reinitialize_dir $srcdir/$subdir |
| mi_gdb_load ${binfile} |
| |
| mi_gdb_test {61-file-list-globals -file file-statics-cpp.cpp -shlib file-statics-cpp --simple-values} \ |
| {61\^done,globals=\[\{name=\"Test::myVar\",type=\"int\",value=\"0\"\}\]} \ |
| {-file-list-globals: c++ - supply file and shlib, simple values} |
| |
| mi_gdb_test {62-file-list-globals -file file-statics-cpp.cpp -shlib file-statics-cpp --make-varobjs} \ |
| {62\^done,globals=\[varobj={exp=\"Test::myVar\",value=\"0\",name=\"var1\",numchild=\"0\",type=\"int\",typecode=\"INT\",dynamic_type=\"\",resolved_type=\"int\",in_scope=\"true\",block_start_addr=\"no block\",block_end_addr=\"no block\"}\]} \ |
| {-file-list-globals: c++ - supply file and shlib, make varobjs} |
| |
| mi_gdb_test {71-file-list-statics -file file-statics-cpp.cpp -shlib file-statics-cpp --simple-values} \ |
| {71\^done,statics=\[\{name=\"const_int\",type=\"const int\",value=\"5\"\}\]} \ |
| {-file-list-statics: c++ - supply file and shlib, simple values} |
| |
| mi_gdb_test {72-file-list-statics -file file-statics-cpp.cpp -shlib file-statics-cpp --make-varobjs} \ |
| {72\^done,statics=\[varobj={exp=\"const_int\",value=\"5\",name=\"var2\",numchild=\"0\",type=\"const int\",typecode=\"INT\",dynamic_type=\"\",resolved_type=\"const int\",in_scope=\"true\",block_start_addr=\"no block\",block_end_addr=\"no block\"}\]} \ |
| {-file-list-statics: c++ - supply file and shlib, make varobjs} |