2012-01-04 08:28:28 +00:00
|
|
|
# Copyright 2002-2004, 2007-2012 Free Software Foundation, Inc.
|
2002-01-09 00:37:41 +00:00
|
|
|
|
|
|
|
# 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
|
2007-08-23 18:14:19 +00:00
|
|
|
# the Free Software Foundation; either version 3 of the License, or
|
2002-01-09 00:37:41 +00:00
|
|
|
# (at your option) any later version.
|
2007-08-23 18:14:19 +00:00
|
|
|
#
|
2002-01-09 00:37:41 +00:00
|
|
|
# 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.
|
2007-08-23 18:14:19 +00:00
|
|
|
#
|
2002-01-09 00:37:41 +00:00
|
|
|
# You should have received a copy of the GNU General Public License
|
2007-08-23 18:14:19 +00:00
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2002-01-09 00:37:41 +00:00
|
|
|
|
|
|
|
# This file was written by Michael Snyder (msnyder@redhat.com)
|
|
|
|
# This is a test for the gdb command "generate-core-file".
|
|
|
|
|
|
|
|
# Single-threaded test case
|
* gdb.threads/watchpoint-fork.exp (test): Use
standard_output_file. Don't declare objdir.
* gdb.threads/attach-into-signal.exp: Use standard_testfile,
standard_output_file.
* gdb.threads/attach-stopped.exp: Use standard_testfile.
* gdb.threads/bp_in_thread.exp: Use standard_testfile,
clean_restart. Remove incdir.
* gdb.threads/corethreads.exp: Use standard_testfile.
* gdb.threads/execl.exp: Use standard_testfile,
standard_output_file, clean_restart.
* gdb.threads/fork-child-threads.exp: Use standard_testfile,
clean_restart.
* gdb.threads/fork-thread-pending.exp: Use standard_testfile,
clean_restart.
* gdb.threads/gcore-thread.exp: Use standard_testfile. Remove
incdir.
* gdb.threads/hand-call-in-threads.exp: Use standard_testfile,
clean_restart. Remove incdir.
* gdb.threads/ia64-sigill.exp: Use standard_testfile.
* gdb.threads/interrupted-hand-call.exp: Use standard_testfile,
clean_restart. Remove incdir.
* gdb.threads/killed.exp: Use standard_testfile, clean_restart.
Remove incdir.
* gdb.threads/leader-exit.exp: Use standard_testfile.
* gdb.threads/linux-dp.exp: Use standard_testfile, clean_restart.
* gdb.threads/local-watch-wrong-thread.exp: Use standard_testfile,
clean_restart.
* gdb.threads/manythreads.exp: Use standard_testfile,
clean_restart. Remove incdir.
* gdb.threads/multi-create.exp: Use standard_testfile,
clean_restart.
* gdb.threads/no-unwaited-for-left.exp: Use standard_testfile.
* gdb.threads/non-ldr-exc-1.exp: Use standard_testfile.
* gdb.threads/non-ldr-exc-2.exp: Use standard_testfile.
* gdb.threads/non-ldr-exc-3.exp: Use standard_testfile.
* gdb.threads/non-ldr-exc-4.exp: Use standard_testfile.
* gdb.threads/pending-step.exp: Use standard_testfile,
clean_restart. Remove incdir.
* gdb.threads/print-threads.exp: Use standard_testfile,
clean_restart. Remove incdir.
* gdb.threads/pthread_cond_wait.exp: Use standard_testfile,
clean_restart. Remove incdir.
* gdb.threads/pthreads.exp: Use standard_testfile, clean_restart.
Remove incdir.
* gdb.threads/schedlock.exp: Use standard_testfile. Remove
incdir.
* gdb.threads/sigthread.exp: Use standard_testfile,
clean_restart.
* gdb.threads/staticthreads.exp: Use standard_testfile,
clean_restart. Remove incdir.
* gdb.threads/switch-threads.exp: Use standard_testfile,
clean_restart. Remove incdir.
* gdb.threads/thread-execl.exp: Use standard_testfile,
clean_restart. Remove incdir.
* gdb.threads/thread-find.exp: Use standard_testfile,
clean_restart.
* gdb.threads/thread-specific.exp: Use standard_testfile,
clean_restart. Remove incdir.
* gdb.threads/thread-unwindonsignal.exp: Use standard_testfile,
clean_restart. Remove incdir.
* gdb.threads/thread_check.exp: Use standard_testfile,
clean_restart. Remove incdir.
* gdb.threads/thread_events.exp: Use standard_testfile. Remove
incdir.
* gdb.threads/threadapply.exp: Use standard_testfile,
clean_restart. Remove incdir.
* gdb.threads/threxit-hop-specific.exp: Use standard_testfile,
clean_restart. Remove incdir.
* gdb.threads/tls-nodebug.exp: Use standard_testfile,
clean_restart.
* gdb.threads/tls-shared.exp: Use standard_testfile,
clean_restart, standard_output_file.
* gdb.threads/tls-var.exp: Use standard_testfile,
standard_output_file.
* gdb.threads/tls.exp: Use standard_testfile, clean_restart.
Remove incdir.
* gdb.threads/watchthreads-reorder.exp: Use standard_testfile.
* gdb.threads/watchthreads.exp: Use standard_testfile. Remove
incdir.
* gdb.threads/watchthreads2.exp: Use standard_testfile,
clean_restart. Remove incdir.
2012-06-26 19:23:20 +00:00
|
|
|
standard_testfile pthreads.c
|
|
|
|
set objfile $binfile.o
|
|
|
|
set corefile $binfile.test
|
|
|
|
set core0file ${binfile}0.test
|
2002-01-09 00:37:41 +00:00
|
|
|
|
|
|
|
if [istarget "*-*-linux"] then {
|
|
|
|
set target_cflags "-D_MIT_POSIX_THREADS"
|
|
|
|
} else {
|
|
|
|
set target_cflags ""
|
|
|
|
}
|
2003-01-04 23:05:05 +00:00
|
|
|
|
2011-05-06 16:01:40 +00:00
|
|
|
# Attempt to prevent -Wl,-z,relro which happens by default at least on
|
|
|
|
# Kubuntu-10.10. Due to PR corefiles/11804 will then GDB be unable to find
|
|
|
|
# libpthread, therefore libthread_db will not fail as expected
|
|
|
|
# on the test `zeroed-threads cannot be listed'.
|
|
|
|
|
* gdb.threads/watchpoint-fork.exp (test): Use
standard_output_file. Don't declare objdir.
* gdb.threads/attach-into-signal.exp: Use standard_testfile,
standard_output_file.
* gdb.threads/attach-stopped.exp: Use standard_testfile.
* gdb.threads/bp_in_thread.exp: Use standard_testfile,
clean_restart. Remove incdir.
* gdb.threads/corethreads.exp: Use standard_testfile.
* gdb.threads/execl.exp: Use standard_testfile,
standard_output_file, clean_restart.
* gdb.threads/fork-child-threads.exp: Use standard_testfile,
clean_restart.
* gdb.threads/fork-thread-pending.exp: Use standard_testfile,
clean_restart.
* gdb.threads/gcore-thread.exp: Use standard_testfile. Remove
incdir.
* gdb.threads/hand-call-in-threads.exp: Use standard_testfile,
clean_restart. Remove incdir.
* gdb.threads/ia64-sigill.exp: Use standard_testfile.
* gdb.threads/interrupted-hand-call.exp: Use standard_testfile,
clean_restart. Remove incdir.
* gdb.threads/killed.exp: Use standard_testfile, clean_restart.
Remove incdir.
* gdb.threads/leader-exit.exp: Use standard_testfile.
* gdb.threads/linux-dp.exp: Use standard_testfile, clean_restart.
* gdb.threads/local-watch-wrong-thread.exp: Use standard_testfile,
clean_restart.
* gdb.threads/manythreads.exp: Use standard_testfile,
clean_restart. Remove incdir.
* gdb.threads/multi-create.exp: Use standard_testfile,
clean_restart.
* gdb.threads/no-unwaited-for-left.exp: Use standard_testfile.
* gdb.threads/non-ldr-exc-1.exp: Use standard_testfile.
* gdb.threads/non-ldr-exc-2.exp: Use standard_testfile.
* gdb.threads/non-ldr-exc-3.exp: Use standard_testfile.
* gdb.threads/non-ldr-exc-4.exp: Use standard_testfile.
* gdb.threads/pending-step.exp: Use standard_testfile,
clean_restart. Remove incdir.
* gdb.threads/print-threads.exp: Use standard_testfile,
clean_restart. Remove incdir.
* gdb.threads/pthread_cond_wait.exp: Use standard_testfile,
clean_restart. Remove incdir.
* gdb.threads/pthreads.exp: Use standard_testfile, clean_restart.
Remove incdir.
* gdb.threads/schedlock.exp: Use standard_testfile. Remove
incdir.
* gdb.threads/sigthread.exp: Use standard_testfile,
clean_restart.
* gdb.threads/staticthreads.exp: Use standard_testfile,
clean_restart. Remove incdir.
* gdb.threads/switch-threads.exp: Use standard_testfile,
clean_restart. Remove incdir.
* gdb.threads/thread-execl.exp: Use standard_testfile,
clean_restart. Remove incdir.
* gdb.threads/thread-find.exp: Use standard_testfile,
clean_restart.
* gdb.threads/thread-specific.exp: Use standard_testfile,
clean_restart. Remove incdir.
* gdb.threads/thread-unwindonsignal.exp: Use standard_testfile,
clean_restart. Remove incdir.
* gdb.threads/thread_check.exp: Use standard_testfile,
clean_restart. Remove incdir.
* gdb.threads/thread_events.exp: Use standard_testfile. Remove
incdir.
* gdb.threads/threadapply.exp: Use standard_testfile,
clean_restart. Remove incdir.
* gdb.threads/threxit-hop-specific.exp: Use standard_testfile,
clean_restart. Remove incdir.
* gdb.threads/tls-nodebug.exp: Use standard_testfile,
clean_restart.
* gdb.threads/tls-shared.exp: Use standard_testfile,
clean_restart, standard_output_file.
* gdb.threads/tls-var.exp: Use standard_testfile,
standard_output_file.
* gdb.threads/tls.exp: Use standard_testfile, clean_restart.
Remove incdir.
* gdb.threads/watchthreads-reorder.exp: Use standard_testfile.
* gdb.threads/watchthreads.exp: Use standard_testfile. Remove
incdir.
* gdb.threads/watchthreads2.exp: Use standard_testfile,
clean_restart. Remove incdir.
2012-06-26 19:23:20 +00:00
|
|
|
set opts [list debug]
|
2011-05-06 16:01:40 +00:00
|
|
|
if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${objfile}" object $opts] != ""
|
|
|
|
|| ([gdb_compile_pthreads "${objfile}" "${binfile}" executable [concat $opts {additional_flags=-Wl,-z,norelro}] ] != ""
|
|
|
|
&& [gdb_compile_pthreads "${objfile}" "${binfile}" executable $opts] != "") } {
|
2002-01-09 00:37:41 +00:00
|
|
|
return -1
|
|
|
|
}
|
|
|
|
|
|
|
|
# Now we can proceed with the real testing.
|
|
|
|
|
|
|
|
# Start with a fresh gdb.
|
|
|
|
|
2011-04-17 19:04:07 +00:00
|
|
|
clean_restart ${testfile}
|
2002-01-09 00:37:41 +00:00
|
|
|
|
|
|
|
# regexp for "horizontal" text (i.e. doesn't include newline or
|
|
|
|
# carriage return)
|
|
|
|
set horiz "\[^\n\r\]*"
|
|
|
|
|
|
|
|
# regexp for newline
|
|
|
|
set nl "\[\r\n\]+"
|
|
|
|
|
|
|
|
set timeout 30
|
|
|
|
|
2010-06-02 19:58:21 +00:00
|
|
|
gdb_test_multiple "help gcore" "help gcore" {
|
2002-01-09 00:37:41 +00:00
|
|
|
-re "Undefined command: .gcore.*$gdb_prompt $" {
|
|
|
|
# gcore command not supported -- nothing to test here.
|
|
|
|
unsupported "gdb does not support gcore on this target"
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
-re "Save a core file .*$gdb_prompt $" {
|
|
|
|
pass "help gcore"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-02-02 05:15:27 +00:00
|
|
|
if { ! [ runto_main ] } then {
|
2006-08-10 05:27:22 +00:00
|
|
|
untested gcore-thread.exp
|
|
|
|
return -1
|
2002-01-09 00:37:41 +00:00
|
|
|
}
|
|
|
|
|
2010-06-02 19:58:21 +00:00
|
|
|
gdb_test_multiple "info threads" "threads are supported" {
|
2002-01-09 00:37:41 +00:00
|
|
|
-re ".* main .*$gdb_prompt $" {
|
|
|
|
# OK, threads are supported.
|
|
|
|
}
|
|
|
|
-re "${nl}$gdb_prompt $" {
|
|
|
|
unsupported "gdb does not support threads on this target"
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Make sure thread 1 is running
|
|
|
|
delete_breakpoints
|
|
|
|
gdb_breakpoint "thread1"
|
|
|
|
gdb_test "continue" "Continuing.*Breakpoint.* thread1 .*" "thread 1 is running"
|
|
|
|
|
|
|
|
# Make sure thread 2 is running
|
|
|
|
delete_breakpoints
|
|
|
|
gdb_breakpoint "thread2"
|
|
|
|
gdb_test "continue" "Continuing.*Breakpoint.* thread2 .*" "thread 2 is running"
|
|
|
|
|
2011-04-17 19:04:07 +00:00
|
|
|
set escapedfilename [string_to_regexp $corefile]
|
2002-01-09 00:37:41 +00:00
|
|
|
# Drop corefile
|
2011-09-02 19:21:02 +00:00
|
|
|
set core_supported 0
|
2011-04-17 19:04:07 +00:00
|
|
|
gdb_test_multiple "gcore $corefile" "save a corefile" \
|
2003-10-13 16:30:45 +00:00
|
|
|
{
|
|
|
|
-re "Saved corefile ${escapedfilename}\[\r\n\]+$gdb_prompt $" {
|
|
|
|
pass "save a corefile"
|
|
|
|
global core_supported
|
|
|
|
set core_supported 1
|
|
|
|
}
|
|
|
|
-re "Can't create a corefile\[\r\n\]+$gdb_prompt $" {
|
|
|
|
unsupported "save a corefile"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if {!$core_supported} {
|
|
|
|
return -1
|
|
|
|
}
|
2002-01-09 00:37:41 +00:00
|
|
|
|
2011-04-17 19:04:07 +00:00
|
|
|
|
2011-04-17 19:11:07 +00:00
|
|
|
# Test the uninitialized thread list.
|
|
|
|
# Provide the case of glibc td_thr_get_info handling of:
|
|
|
|
# /* Special case for the main thread before initialization. */
|
|
|
|
|
|
|
|
foreach symbol {__stack_user stack_used} {
|
|
|
|
set test "clear ${symbol}.next"
|
|
|
|
gdb_test_multiple "p *(void **) &${symbol} = 0" $test {
|
|
|
|
-re " = \\(void \\*\\) 0x0\r\n$gdb_prompt $" {
|
|
|
|
pass $test
|
|
|
|
}
|
|
|
|
-re "No symbol \"${symbol}\" in current context\\.\r\n$gdb_prompt $" {
|
|
|
|
xfail $test
|
|
|
|
# Do not do the verification.
|
|
|
|
set core0file ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if {"$core0file" != ""} {
|
|
|
|
gdb_test "gcore $core0file" "Saved corefile .*" "save a zeroed-threads corefile"
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-01-09 00:37:41 +00:00
|
|
|
# Now restart gdb and load the corefile.
|
2011-04-17 19:04:07 +00:00
|
|
|
clean_restart ${testfile}
|
|
|
|
|
|
|
|
proc load_core { corefile } {
|
|
|
|
global gdb_prompt
|
2011-05-06 16:01:40 +00:00
|
|
|
global libthread_db_seen
|
2011-04-17 19:04:07 +00:00
|
|
|
|
|
|
|
gdb_test_multiple "core $corefile" \
|
|
|
|
"re-load generated corefile" {
|
2011-05-06 16:01:40 +00:00
|
|
|
-re "\\\[Thread debugging using \[^ \r\n\]* enabled\\\]\r\n" {
|
|
|
|
exp_continue
|
|
|
|
}
|
2011-04-17 19:04:07 +00:00
|
|
|
-re " is not a core dump:.*\r\n$gdb_prompt $" {
|
|
|
|
fail "re-load generated corefile (bad file format)"
|
|
|
|
# No use proceeding from here.
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
-re ": No such file or directory.*\r\n$gdb_prompt $" {
|
|
|
|
fail "re-load generated corefile (file not found)"
|
|
|
|
# No use proceeding from here.
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
-re "Couldn't find .* registers in core file.*\r\n$gdb_prompt $" {
|
|
|
|
fail "re-load generated corefile (incomplete note section)"
|
|
|
|
}
|
|
|
|
-re "Core was generated by .*\r\n$gdb_prompt $" {
|
|
|
|
pass "re-load generated corefile"
|
|
|
|
}
|
2010-06-02 19:58:21 +00:00
|
|
|
}
|
2011-04-17 19:04:07 +00:00
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
2012-07-02 20:28:38 +00:00
|
|
|
foreach name { corefile core0file } { with_test_prefix $name {
|
|
|
|
if ![load_core [subst $$name]] {
|
|
|
|
continue
|
|
|
|
}
|
2002-01-09 00:37:41 +00:00
|
|
|
|
2012-07-02 20:28:38 +00:00
|
|
|
# FIXME: now what can we test about the thread state?
|
|
|
|
# We do not know for certain that there should be at least
|
|
|
|
# three threads, because who knows what kind of many-to-one
|
|
|
|
# mapping various OS's may do? Let's assume that there must
|
|
|
|
# be at least two threads:
|
2002-01-09 00:37:41 +00:00
|
|
|
|
2012-07-02 20:28:38 +00:00
|
|
|
gdb_test "info threads" ".*${nl} 2 ${horiz}${nl}\\* 1 .*" \
|
|
|
|
"corefile contains at least two threads"
|
2011-04-17 19:11:07 +00:00
|
|
|
|
2012-07-02 20:28:38 +00:00
|
|
|
# One thread in the corefile should be in the "thread2" function.
|
2011-04-17 19:11:07 +00:00
|
|
|
|
2012-07-02 20:28:38 +00:00
|
|
|
gdb_test "info threads" ".* thread2 .*" \
|
|
|
|
"a corefile thread is executing thread2"
|
2011-04-17 19:11:07 +00:00
|
|
|
|
2012-07-02 20:28:38 +00:00
|
|
|
# The thread2 thread should be marked as the current thread.
|
2011-04-17 19:11:07 +00:00
|
|
|
|
2012-07-02 20:28:38 +00:00
|
|
|
gdb_test "info threads" ".*${nl}\\* ${horiz} thread2 .*" \
|
|
|
|
"thread2 is current thread in corefile"
|
|
|
|
}}
|