# Copyright (C) 1998 Cygnus Solutions # # 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 # This file was written by Keith Seitz (keiths@cygnus.com) # Read in the standard defs file if {![gdbtk_read_defs]} { break } global objdir test_ran ##### ##### # # # Helper functions for this module # # # ##### ##### # Set the search expression proc set_regexp {exp} { global Regexp $Regexp delete 0 end $Regexp insert 0 $exp } # Do the search; attempts to filter out compiler noise # like _DYNAMIC_ and __bss_start. proc do_search {} { global browser Funcs $browser search set m [$Funcs get 0 end] # Bogus -- we could get things like _DYNAMIC, __bss_start, etc... set matches {} foreach a $m { if {![regexp ^_.* $a]} { lappend matches $a } } return $matches } # Set search on static functions only. proc set_static_only {on} { if {$on} { pref set gdb/search/static 1 } else { pref set gdb/search/static 0 } } # Set search to use regular expressions. proc set_use_regexp {on} { if {$on} { pref set gdb/search/use_regexp 1 } else { pref set gdb/search/use_regexp 0 } } ##### ##### # # # BROWSER TESTS # # # ##### ##### # Load the test executable set file [file join $objdir stack] gdb_cmd "file $file" # Open a browser set browser [manage open browser] set Files [$browser test_get FilesLB] set Funcs [$browser test_get FuncsLB] set Regexp [$browser test_get Regexp] # Test: browser-1.1 # Desc: Check file listbox contents gdbtk_test browser-1.1 {file listbox contents} { $Files get 0 end } {stack1.c stack2.c} # Test: browser-2.1 # Desc: Check all files/all funcs gdbtk_test browser-2.1 {all files/all funcs} { set_regexp "" do_search } {extern_func1_1 extern_func1_10 extern_func1_11 extern_func1_12 extern_func1_13 extern_func1_14 extern_func1_15 extern_func1_2 extern_func1_3 extern_func1_4 extern_func1_5 extern_func1_6 extern_func1_7 extern_func1_8 extern_func1_9 func_1 func_10 func_11 func_12 func_13 func_14 func_15 func_2 func_3 func_4 func_5 func_6 func_7 func_8 func_9 main static_func_1 static_func_10 static_func_11 static_func_12 static_func_13 static_func_14 static_func_15 static_func_2 static_func_3 static_func_4 static_func_5 static_func_6 static_func_7 static_func_8 static_func_9} # Test: browser-2.2 # Desc: Check all functions in stack1.c gdbtk_test browser-2.2 {all functions in stack1.c} { set_regexp "" $Files selection set 0 do_search } {func_1 func_10 func_11 func_12 func_13 func_14 func_15 func_2 func_3 func_4 func_5 func_6 func_7 func_8 func_9 main static_func_1 static_func_10 static_func_11 static_func_12 static_func_13 static_func_14 static_func_15 static_func_2 static_func_3 static_func_4 static_func_5 static_func_6 static_func_7 static_func_8 static_func_9} if {$test_ran} { $Files selection clear 0 end } # Test: browser-2.3 # Desc: Check all functions in stack2.c gdbtk_test browser-2.3 {all functions in stack2.c} { set_regexp "" $Files selection set 1 do_search } {extern_func1_1 extern_func1_10 extern_func1_11 extern_func1_12 extern_func1_13 extern_func1_14 extern_func1_15 extern_func1_2 extern_func1_3 extern_func1_4 extern_func1_5 extern_func1_6 extern_func1_7 extern_func1_8 extern_func1_9} if {$test_ran} { $Files selection clear 0 end } # Test: browser-2.4 # Desc: Check for all functions matching "func" gdbtk_test browser-2.4 {all functions matching "func"} { set_regexp func do_search } {func_1 func_10 func_11 func_12 func_13 func_14 func_15 func_2 func_3 func_4 func_5 func_6 func_7 func_8 func_9} # Test: browser-2.5 # Desc: Check all functions matching "func" in stack1.c gdbtk_test browser-2.5 {all functions matching "func" in stack1.c} { set_regexp func $Files selection set 0 do_search } {func_1 func_10 func_11 func_12 func_13 func_14 func_15 func_2 func_3 func_4 func_5 func_6 func_7 func_8 func_9} if {$test_ran} { $Files selection clear 0 end } # Test: browser-2.6 # Desc: Check all functions matching "funcs" in stack2.c gdbtk_test browser-2.6 {all functions matching "func" in stack2.c} { set_regexp func $Files selection set 1 do_search } {} if {$test_ran} { $Files selection clear 0 end } # Test: browser-2.7 # Desc: Check all functions matching "foobar" gdbtk_test browser-2.7 {all functions matching "foobar"} { set_regexp foobar do_search } {} # Test: browser-2.8 # Desc: Check all functions matching "foobar" in stack1.c gdbtk_test browser-2.8 {functions matching "foobar" in stack1.c} { set_regexp foobar $Files selection set 0 do_search } {} if {$test_ran} { $Files selection clear 0 end } # Test: browser-2.9 # Desc: Check all functions matching "foobar" in stack2.c gdbtk_test browser-2.9 {functions matching "foobar" in stack2.c} { set_regexp foobar $Files selection set 1 do_search } {} if {$test_ran} { $Files selection clear 0 end } # Test: browser-2.10 # Desc: Check all functions matching regexp "func" gdbtk_test browser-2.10 {all functions matching regexp "func"} { set_regexp func set_use_regexp 1 do_search } {extern_func1_1 extern_func1_10 extern_func1_11 extern_func1_12 extern_func1_13 extern_func1_14 extern_func1_15 extern_func1_2 extern_func1_3 extern_func1_4 extern_func1_5 extern_func1_6 extern_func1_7 extern_func1_8 extern_func1_9 func_1 func_10 func_11 func_12 func_13 func_14 func_15 func_2 func_3 func_4 func_5 func_6 func_7 func_8 func_9 static_func_1 static_func_10 static_func_11 static_func_12 static_func_13 static_func_14 static_func_15 static_func_2 static_func_3 static_func_4 static_func_5 static_func_6 static_func_7 static_func_8 static_func_9} if {$test_ran} { set_use_regexp 0 } # Test: browser-2.11 # Desc: Check all functions matching regexp "func" in stack1.c gdbtk_test browser-2.11 {all functions matching regexp "func" in stack1.c} { set_regexp func set_use_regexp 1 $Files selection set 0 do_search } {func_1 func_10 func_11 func_12 func_13 func_14 func_15 func_2 func_3 func_4 func_5 func_6 func_7 func_8 func_9 static_func_1 static_func_10 static_func_11 static_func_12 static_func_13 static_func_14 static_func_15 static_func_2 static_func_3 static_func_4 static_func_5 static_func_6 static_func_7 static_func_8 static_func_9} if {$test_ran} { set_use_regexp 0 $Files selection clear 0 end } # Test: browser-2.12 # Desc: Check all functions matching regexp "func" in stack2.c gdbtk_test browser-2.12 {all functions matching regexp "func" in stack2.c} { set_regexp func set_use_regexp 1 $Files selection set 1 do_search } {extern_func1_1 extern_func1_10 extern_func1_11 extern_func1_12 extern_func1_13 extern_func1_14 extern_func1_15 extern_func1_2 extern_func1_3 extern_func1_4 extern_func1_5 extern_func1_6 extern_func1_7 extern_func1_8 extern_func1_9} if {$test_ran} { set_use_regexp 0 $Files selection clear 0 end } # Test: browser-2.13 # Desc: Check all functions matching regexp "\_1$" gdbtk_test browser-2.13 {all functions matching regexp "\_1$"} { set_regexp {\_1$} set_use_regexp 1 do_search } {extern_func1_1 func_1 static_func_1} if {$test_ran} { set_use_regexp 0 } # Test: browser-2.14 # Desc: Check all functions matching regexp "\_1$" in stack1.c gdbtk_test browser-2.14 {all functions matching regexp "\_1$" in stack1.c} { set_regexp {\_1$} set_use_regexp 1 $Files selection set 0 do_search } {func_1 static_func_1} if {$test_ran} { $Files selection clear 0 end set_use_regexp 0 } # Test: browser-2.15 # Desc: Check all functions matching regexp "\_1$" in stack2.c gdbtk_test browser-2.15 {all functions matching regexp "\_1$" in stack2.c} { set_regexp {\_1$} set_use_regexp 1 $Files selection set 1 do_search } {extern_func1_1} if {$test_ran} { $Files selection clear 0 end set_use_regexp 0 } # Test: browser-2.16 # Desc: Check all functions matching regexp "foobar" gdbtk_test browser-2.16 {all functions matching regexp "foobar"} { set_regexp foobar set_use_regexp 1 do_search } {} if {$test_ran} { set_use_regexp 0 } # Test: browser-2.17 # Desc: Check all functions matching regexp "foobar" in stack1.c gdbtk_test browser-2.17 {all functions matching regexp "foobar" in stack1.c} { set_regexp foobar set_use_regexp 1 $Files selection set 0 do_search } {} if {$test_ran} { set_use_regexp 0 $Files selection clear 0 end } # Test: browser-2.18 # Desc: Check all functions matching regexp "foobar" gdbtk_test browser-2.18 {all functions matching regexp "foobar"} { set_regexp foobar set_use_regexp 1 $Files selection set 1 do_search } {} if {$test_ran} { set_use_regexp 0 $Files selection clear 0 end } # Test: browser-3.1 # Desc: Check all static funcs gdbtk_test browser-3.1 {all static funcs} { set_static_only 1 set_regexp "" do_search } {static_func_1 static_func_10 static_func_11 static_func_12 static_func_13 static_func_14 static_func_15 static_func_2 static_func_3 static_func_4 static_func_5 static_func_6 static_func_7 static_func_8 static_func_9} if {$test_ran} { set_static_only 0 } # Test: browser-3.2 # Desc: Check all static functions in stack1.c gdbtk_test browser-3.2 {all static functions in stack1.c} { set_regexp "" $Files selection set 0 set_static_only 1 do_search } {static_func_1 static_func_10 static_func_11 static_func_12 static_func_13 static_func_14 static_func_15 static_func_2 static_func_3 static_func_4 static_func_5 static_func_6 static_func_7 static_func_8 static_func_9} if {$test_ran} { $Files selection clear 0 end set_static_only 0 } # Test: browser-3.3 # Desc: Check all static functions in stack2.c gdbtk_test browser-3.3 {all static functions in stack2.c} { set_regexp "" set_static_only 1 $Files selection set 1 do_search } {} if {$test_ran} { set_static_only 0 $Files selection clear 0 end } # Test: browser-3.4 # Desc: Check for all static functions matching "func" gdbtk_test browser-3.4 {all static functions matching "func"} { set_regexp func set_static_only 1 do_search } {} if {$test_ran} { set_static_only 0 } # Test: browser-3.5 # Desc: Check for all static functions matching "func" in stack1.c gdbtk_test browser-3.5 {all static functions matching "func" in stack1.c} { set_regexp func set_static_only 1 $Files selection set 0 do_search } {} if {$test_ran} { set_static_only 0 $Files selection clear 0 end } # Test: browser-3.6 # Desc: Check all static functions matching "func" in stack2.c gdbtk_test browser-3.6 {all static functions matching "func" in stack2.c} { set_regexp func set_static_only 1 $Files selection set 1 do_search } {} if {$test_ran} { set_static_only 0 $Files selection clear 0 end } # Test: browser-3.7 # Desc: Check all static functions matching "foobar" gdbtk_test browser-3.7 {all static functions matching "foobar"} { set_regexp foobar set_static_only 1 do_search } {} if {$test_ran} { set_static_only 0 } # Test: browser-3.8 # Desc: Check all static functions matching "foobar" in stack1.c gdbtk_test browser-3.8 {all static functions matching "foobar" in stack1.c} { set_regexp foobar set_static_only 1 $Files selection set 0 do_search } {} if {$test_ran} { set_static_only 0 $Files selection clear 0 end } # Test: browser-3.9 # Desc: Check all static functions matching "foobar" in stack2.c gdbtk_test browser-3.9 {all static functions matching "foobar" stack2.c} { set_regexp foobar set_static_only 1 $Files selection set 1 do_search } {} if {$test_ran} { set_static_only 0 $Files selection clear 0 end } # Test: browser-3.10 # Desc: Check all static functions matching regexp "func" gdbtk_test browser-3.10 {all static functions matching regexp "func"} { set_regexp func set_static_only 1 set_use_regexp 1 do_search } {static_func_1 static_func_10 static_func_11 static_func_12 static_func_13 static_func_14 static_func_15 static_func_2 static_func_3 static_func_4 static_func_5 static_func_6 static_func_7 static_func_8 static_func_9} if {$test_ran} { set_use_regexp 0 set_static_only 0 } # Test: browser-3.11 # Desc: Check all static functions matching regexp "func" in stack1.c gdbtk_test browser-3.11 {all static functions matching regexp "func" in stack1.c} { set_regexp func set_static_only 1 set_use_regexp 1 $Files selection set 0 do_search } {static_func_1 static_func_10 static_func_11 static_func_12 static_func_13 static_func_14 static_func_15 static_func_2 static_func_3 static_func_4 static_func_5 static_func_6 static_func_7 static_func_8 static_func_9} if {$test_ran} { set_use_regexp 0 set_static_only 0 $Files selection clear 0 end } # Test: browser-3.12 # Desc: Check all static functions matching regexp "func" in stack2.c gdbtk_test browser-3.12 {all static functions matching regexp "func" in stack2.c} { set_regexp func set_static_only 1 set_use_regexp 1 $Files selection set 1 do_search } {} if {$test_ran} { set_use_regexp 0 set_static_only 0 $Files selection clear 0 end } # Test: browser-3.13 # Desc: Check all static functions matching regexp "\_1$" gdbtk_test browser-3.13 {all static functions matching regexp "\_1$"} { set_regexp {\_1$} set_static_only 1 set_use_regexp 1 do_search } {static_func_1} if {$test_ran} { set_static_only 0 set_use_regexp 0 } # Test: browser-3.14 # Desc: Check all static functions matching regexp "\_1$" in stack1.c gdbtk_test browser-3.14 {all static functions matching regexp "\_1$" in stack1.c} { set_regexp {\_1$} set_static_only 1 set_use_regexp 1 $Files selection set 0 do_search } {static_func_1} if {$test_ran} { set_use_regexp 0 set_static_only 0 $Files selection clear 0 end } # Test: browser-3.15 # Desc: Check all static functions matching regexp "\_1$" in stack2.c gdbtk_test browser-3.15 {all static functions matching regexp "\_1$" in stack2.c} { set_regexp {\_1$} set_static_only 1 set_use_regexp 1 $Files selection set 1 do_search } {} if {$test_ran} { set_use_regexp 0 set_static_only 0 $Files selection clear 0 end } # Test: browser-3.16 # Desc: Check all static functions matching regexp "foobar" gdbtk_test browser-3.16 {all static functions matching regexp "foobar"} { set_regexp foobar set_use_regexp 1 set_static_only 1 do_search } {} if {$test_ran} { set_static_only 0 set_use_regexp 0 } # Test: browser-3.17 # Desc: Check all static functions matching regexp "foobar" in stack1.c gdbtk_test browser-3.17 {all static functions matching regexp "foobar" in stack1.c} { set_regexp foobar set_use_regexp 1 set_static_only 1 $Files selection set 0 do_search } {} if {$test_ran} { set_static_only 0 set_use_regexp 0 $Files selection clear 0 end } # Test: browser-3.18 # Desc: Check all static functions matching regexp "foobar" in stack2.c gdbtk_test browser-3.18 {all static functions matching regexp "foobar" in stack2.c} { set_regexp foobar set_static_only 1 set_use_regexp 1 $Files selection set 1 do_search } {} if {$test_ran} { set_static_only 0 set_use_regexp 0 $Files selection clear 0 end } set select [$browser test_get Select] # Test: browser-4.1 # Desc: Check select button text initial gdbtk_test browser-4.1 {select all files button initial text} { $select cget -text } {Select All} # Test: browser-4.2 # Desc: Check select button function gdbtk_test browser-4.2 {select button - select all} { $select invoke $Files curselection } {0 1} if {$test_ran} { $Files selection clear 0 end $select invoke } # Test: browser-4.3 # Desc: Check select button text gdbtk_test browser-4.3 {select button text - select none} { $select invoke $select cget -text } {Select None} if {$test_ran} { $select invoke } # Test: browser-4.4 # Desc: Check select button function gdbtk_test browser-4.4 {select button - select none} { $select invoke $select invoke $Files curselection } {} # Test: browser-4.5 # Desc: Check select button text gdbtk_test browser-4.5 {select button text - flip} { $select invoke $select invoke $select cget -text } {Select All} # Test: browser-5.1 # Desc: Toggle all bps on gdbtk_test browser-5.1 {toggle_all_bp on} { set_regexp {\_1$} set_use_regexp 1 do_search $browser toggle_all_bp set_regexp .* set funcs [do_search] set bps {} foreach f $funcs { if {[bp_exists [gdb_loc $f]] != -1} { lappend bps 1 } else { lappend bps 0 } } set bps } {1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0} if {$test_ran} { set_use_regexp 0 for {set i 0} {$i < 20} {incr i} { catch {gdb_cmd "delete $i"} } } # Test: browser-5.2 # Desc: Toggle all bps off gdbtk_test browser-5.2 {toggle_all_bp off} { set_regexp {\_1$} set_use_regexp 1 do_search $browser toggle_all_bp # Turn on bps set_regexp .* set funcs [do_search] # Turn off all static bps set_regexp {\_1$} set_static_only 1 do_search $browser toggle_all_bp set bps {} foreach f $funcs { if {[bp_exists [gdb_loc $f]] != -1} { lappend bps 1 } else { lappend bps 0 } } set bps } {1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0} if {$test_ran} { set_static_only 0 set_use_regexp 0 for {set i 0} {$i < 20} {incr i} { catch {gdb_cmd "delete $i"} } } # Test: browser-6.1 # Desc: Check that search expressions are saved gdbtk_test browser-6.1 {save last search expression} { set_regexp hello do_search pref get gdb/search/last_symbol } {hello} # # Exit # gdbtk_test_done