| # usrthbasic.exp -- Expect script to test gdb with user threads |
| # Copyright (C) 1992 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 |
| |
| # use this to debug: |
| # |
| #log_user 1 |
| |
| if $tracelevel { |
| strace $tracelevel |
| } |
| |
| if { [skip_hp_tests] } { continue } |
| |
| if { ![istarget "hppa*-*-hpux*"] || [istarget "hppa2.0w-*-*"] } { |
| verbose "HPUX thread test ignored for non-hppa or PA64 targets." |
| return 0 |
| } |
| |
| set testfile usrthbasic |
| set srcfile ${srcdir}/${subdir}/${testfile}.c |
| set binfile ${srcdir}/${subdir}/${testfile} |
| |
| # To build the executable we need to link against the thread library. |
| # |
| # /opt/ansic/bin/cc -Ae +DAportable -g -o usrthbasic -lcma usrthbasic.c |
| # |
| ## we have trouble building it on 11.0, so we use the prebuilt |
| ## executable instead. |
| ## |
| ##if { [gdb_compile "${srcdir}/${subdir}/${testfile}.c" "${binfile}" executable {debug additional_flags=-Ae ldflags=-lcma}] != "" } { |
| ## gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." |
| ##} |
| |
| # We don't really seem to need longer waits. |
| # |
| ##set oldtimeout $timeout |
| ##set timeout [expr "$timeout + 0"] |
| ##set oldverbose $verbose |
| ##set verbose 40 |
| |
| #========================= |
| # |
| # Test looking at threads. |
| # |
| gdb_exit |
| gdb_start |
| gdb_reinitialize_dir $srcdir/$subdir |
| gdb_load ${binfile} |
| |
| gdb_test "b main" ".*Breakpoint 1.*" "b main" |
| gdb_test "run" "Breakpoint 1, main.*:119.*" "run to main" |
| gdb_test "b thread1" ".*Breakpoint 2.*" "b thread1" |
| gdb_test "info threads" "\\* 1 system thread.*:119\[^(\]*" \ |
| "info threads at main" |
| gdb_test "c" "Breakpoint 2, thread1.*" "continue to thread1" |
| gdb_test "info threads" \ |
| "\\* 3 system thread.*thread1.*libcma.1.*libcma.1\[^(\]*" \ |
| "info threads at main" |
| gdb_test "b 165" "Breakpoint 3.*165.*" "break at main counter" |
| gdb_test "c" "Breakpoint 3, main.*" "continue to main counter" |
| gdb_test "info threads" " 4 system thread.*\\* 1 system thread.*main.*" \ |
| "info threads at main counter" |
| gdb_test "b 97" "Breakpoint 4.*97.*" "break at thread2 counter" |
| gdb_test "b 81" "Breakpoint 5.*81.*" "break at thread1 counter" |
| gdb_test "bt" "#0 main.* at \[^(\]*" "backtrace at main counter" |
| |
| # After switching to thread 4, the cma scheduler should schedule it next |
| # and we should hit its breakpoint in thread2. |
| gdb_test "thread 4" ".Switching to thread 4.*cma__dispatch.*" \ |
| "switch to thread 4" |
| gdb_test "bt" "#0 .*thread2.*" "backtrace at thread 4" |
| sleep 1 |
| gdb_test "c" ".*Breakpoint 4, thread2.*" "continue and get to thread 4" |
| |
| # After switching to thread 1, the cma scheduler should schedule it next |
| # and we should hit its breakpoint (in main). |
| gdb_test "thread 1" ".*Switching to thread 1.*cma__dispatch.*" \ |
| "switch to thread 1" |
| sleep 1 |
| gdb_test "c" ".*Breakpoint 3, main.*usrthbasic.c:165.*" \ |
| "continue and get to thread 1" |
| |
| # Done! |
| # |
| gdb_exit |
| |
| ##set timeout $oldtimeout |
| ##set verbose $oldverbose |
| |
| return 0 |