# 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 # # 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 # 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\^done,statics=\[\{name="static_int"\},\{name="static_doesnt_match"\}\]} \ {-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\^done,statics=\[\{name="static_int"\},\{name="static_doesnt_match"\}\]} \ {-file-list-statics: supply file and shlib, no values} mi_gdb_test {21-file-list-statics -file file-statics.c -shlib "" --no-values} \ {21\^done,statics=\[\{name="static_int"\},\{name="static_doesnt_match"\}\]} \ {-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\^done,statics=\[\{name="static_int"\},\{name="static_doesnt_match"\}\]} \ {-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} mi_gdb_test {21-file-list-statics -file file-statics.c -shlib file-statics --simple-values} \ {21\^done,statics=\[\{name="static_int",type="int",value="7"\},\{name="static_doesnt_match",type="int",value="8"\}\]} \ {-file-list-statics: supply file and shlib, no simple} mi_gdb_test {21-file-list-statics -file file-statics.c -shlib file-statics --make-varobjs} \ {21\^done,statics=\[varobj=\{exp="static_int",value="7",name="var1",numchild="0",type="int",typecode="INT",dynamic_type="",in_scope="true",block_start_addr="no block",block_end_addr="no block"\},varobj=\{exp="static_doesnt_match",value="8",name="var2",numchild="0",type="int",typecode="INT",dynamic_type="",in_scope="true",block_start_addr="no block",block_end_addr="no block"\}\]} \ {-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 {50-file-list-globals file-statics.c file-statics --no-values} \ {50\^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_int"\},\{name="const_char"\},\{name="const_doesnt_match"\},\{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_char"\},\{name="const_doesnt_match"\}\]} \ {-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_int"\},\{name="const_char"\},\{name="const_doesnt_match"\},\{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_int",type="const int",value="5"\},\{name="const_char",type="const char \*",value="0x([0-9a-f]+) \\"I am a constant\\""\},\{name="const_doesnt_match",type="const int",value="6"\},\{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_int"\},\{name="const_char"\},\{name="const_doesnt_match"\},\{name="global_int"\}\]\].*} \ {-file-list-globals: all files, supply shlib, no values} #mi_run_cmd # The running part has been checked already by mi_run_cmd #mi_get_bp_stopped "3" "\[01\]" "" "main" "objc-prog.m" ".*" "run to main"