blarsen / rpms / gdb

Forked from rpms/gdb 2 years ago
Clone
Jan Kratochvil 89365c2
http://sourceware.org/ml/gdb-patches/2011-02/msg00679.html
Jan Kratochvil 89365c2
Subject: Re: [patch 1/3] Code cleanup: gdb.threads/gcore-thread.exp
Jan Kratochvil 89365c2
Jan Kratochvil 89365c2
On Thu, 24 Feb 2011 08:20:09 +0100, Joel Brobecker wrote:
Jan Kratochvil 89365c2
> Just a thought: Do we really need to worry about restoring
Jan Kratochvil 89365c2
> the timeout at the end of the testcase, given that this is
Jan Kratochvil 89365c2
> automatically done at the start of each testcase (see gdb.exp:
Jan Kratochvil 89365c2
> gdb_init)?
Jan Kratochvil 89365c2
Jan Kratochvil 89365c2
I see now:
Jan Kratochvil 89365c2
	Re: [RFA/testsuite] Reset the timeout duration at the start of each testcase.
Jan Kratochvil 89365c2
	http://sourceware.org/ml/gdb-patches/2010-02/msg00202.html
Jan Kratochvil 89365c2
	commit 501c57da40fd27c8036a5fc995f750b0559272ad
Jan Kratochvil 89365c2
Jan Kratochvil 89365c2
Patch updated.
Jan Kratochvil 89365c2
Jan Kratochvil 89365c2
Jan Kratochvil 89365c2
Thanks,
Jan Kratochvil 89365c2
Jan
Jan Kratochvil 89365c2
Jan Kratochvil 89365c2
Jan Kratochvil 89365c2
gdb/testsuite/
Jan Kratochvil 89365c2
2011-02-24  Jan Kratochvil  <jan.kratochvil@redhat.com>
Jan Kratochvil 89365c2
Jan Kratochvil 89365c2
	* gdb.threads/gcore-thread.exp ($testfile): Match it the .exp
Jan Kratochvil 89365c2
	filename.
Jan Kratochvil 89365c2
	($srcfile): Preserve the original value.
Jan Kratochvil 89365c2
	($testfile): Match it the .exp filename.
Jan Kratochvil 89365c2
	($corefile): New variable.  Substitute it around.
Jan Kratochvil 89365c2
	Use clean_restart.
Jan Kratochvil 89365c2
	($prev_timeout): Remove.
Jan Kratochvil 89365c2
	(load_core): Move core loading into this proc.
Jan Kratochvil 89365c2
	Fix restore of $timeout if load_core fails.
Jan Kratochvil 89365c2
Jan Kratochvil 89365c2
Index: gdb-7.2/gdb/testsuite/gdb.threads/gcore-thread.exp
Jan Kratochvil 89365c2
===================================================================
Jan Kratochvil 89365c2
--- gdb-7.2.orig/gdb/testsuite/gdb.threads/gcore-thread.exp	2011-02-24 09:56:04.000000000 +0100
Jan Kratochvil 89365c2
+++ gdb-7.2/gdb/testsuite/gdb.threads/gcore-thread.exp	2011-02-24 09:56:57.000000000 +0100
Jan Kratochvil 89365c2
@@ -21,11 +21,11 @@ if $tracelevel then {
Jan Kratochvil 89365c2
 	strace $tracelevel
Jan Kratochvil 89365c2
 }
Jan Kratochvil 89365c2
 
Jan Kratochvil 89365c2
-
Jan Kratochvil 89365c2
 # Single-threaded test case
Jan Kratochvil 89365c2
-set testfile "pthreads"
Jan Kratochvil 89365c2
-set srcfile  ${testfile}.c
Jan Kratochvil 89365c2
-set binfile  ${objdir}/${subdir}/gcore-${testfile}
Jan Kratochvil 89365c2
+set testfile "gcore-thread"
Jan Kratochvil 89365c2
+set srcfile  pthreads.c
Jan Kratochvil 89365c2
+set binfile  ${objdir}/${subdir}/${testfile}
Jan Kratochvil 89365c2
+set corefile ${objdir}/${subdir}/${testfile}.test
Jan Kratochvil 89365c2
 
Jan Kratochvil 89365c2
 if [istarget "*-*-linux"] then {
Jan Kratochvil 89365c2
     set target_cflags "-D_MIT_POSIX_THREADS"
Jan Kratochvil 89365c2
@@ -41,10 +41,7 @@ if {[gdb_compile_pthreads "${srcdir}/${s
Jan Kratochvil 89365c2
 
Jan Kratochvil 89365c2
 # Start with a fresh gdb.
Jan Kratochvil 89365c2
 
Jan Kratochvil 89365c2
-gdb_exit
Jan Kratochvil 89365c2
-gdb_start
Jan Kratochvil 89365c2
-gdb_reinitialize_dir $srcdir/$subdir
Jan Kratochvil 89365c2
-gdb_load ${binfile}
Jan Kratochvil 89365c2
+clean_restart ${testfile}
Jan Kratochvil 89365c2
 
Jan Kratochvil 89365c2
 # regexp for "horizontal" text (i.e. doesn't include newline or
Jan Kratochvil 89365c2
 # carriage return)
Jan Kratochvil 89365c2
@@ -66,7 +63,6 @@ proc pthread_self {name} {
Jan Kratochvil 89365c2
     return ""
Jan Kratochvil 89365c2
 }
Jan Kratochvil 89365c2
 
Jan Kratochvil 89365c2
-set prev_timeout $timeout
Jan Kratochvil 89365c2
 set timeout 30
Jan Kratochvil 89365c2
 
Jan Kratochvil 89365c2
 gdb_test_multiple "help gcore" "help gcore" {
Jan Kratochvil 89365c2
@@ -109,10 +105,9 @@ gdb_breakpoint "thread2"
Jan Kratochvil 89365c2
 gdb_test "continue" "Continuing.*Breakpoint.* thread2 .*" "thread 2 is running"
Jan Kratochvil 89365c2
 set thread2_self [pthread_self thread2]
Jan Kratochvil 89365c2
 
Jan Kratochvil 89365c2
-set escapedfilename [string_to_regexp ${objdir}/${subdir}/gcore.test]
Jan Kratochvil 89365c2
+set escapedfilename [string_to_regexp $corefile]
Jan Kratochvil 89365c2
 # Drop corefile
Jan Kratochvil 89365c2
-gdb_test_multiple "gcore ${objdir}/${subdir}/gcore.test" \
Jan Kratochvil 89365c2
-	"save a corefile" \
Jan Kratochvil 89365c2
+gdb_test_multiple "gcore $corefile" "save a corefile" \
Jan Kratochvil 89365c2
 {
Jan Kratochvil 89365c2
   -re "Saved corefile ${escapedfilename}\[\r\n\]+$gdb_prompt $" {
Jan Kratochvil 89365c2
     pass "save a corefile"
Jan Kratochvil 89365c2
@@ -131,31 +126,38 @@ if {!$core_supported} {
Jan Kratochvil 89365c2
   return -1
Jan Kratochvil 89365c2
 }
Jan Kratochvil 89365c2
 
Jan Kratochvil 89365c2
+
Jan Kratochvil 89365c2
 # Now restart gdb and load the corefile.
Jan Kratochvil 89365c2
-gdb_exit
Jan Kratochvil 89365c2
-gdb_start
Jan Kratochvil 89365c2
-gdb_reinitialize_dir $srcdir/$subdir
Jan Kratochvil 89365c2
-gdb_load ${binfile}
Jan Kratochvil 89365c2
-
Jan Kratochvil 89365c2
-gdb_test_multiple "core ${objdir}/${subdir}/gcore.test" \
Jan Kratochvil 89365c2
-    "re-load generated corefile" {
Jan Kratochvil 89365c2
-	-re ".* is not a core dump:.*$gdb_prompt $" {
Jan Kratochvil 89365c2
-	    fail "re-load generated corefile (bad file format)"
Jan Kratochvil 89365c2
-	    # No use proceeding from here.
Jan Kratochvil 89365c2
-	    return;
Jan Kratochvil 89365c2
-	}
Jan Kratochvil 89365c2
-	-re ".*: No such file or directory.*$gdb_prompt $" {
Jan Kratochvil 89365c2
-	    fail "re-load generated corefile (file not found)"
Jan Kratochvil 89365c2
-	    # No use proceeding from here.
Jan Kratochvil 89365c2
-	    return;
Jan Kratochvil 89365c2
-	}
Jan Kratochvil 89365c2
-	-re ".*Couldn't find .* registers in core file.*$gdb_prompt $" {
Jan Kratochvil 89365c2
-	    fail "re-load generated corefile (incomplete note section)"
Jan Kratochvil 89365c2
-	}
Jan Kratochvil 89365c2
-	-re "Core was generated by .*$gdb_prompt $" {
Jan Kratochvil 89365c2
-	    pass "re-load generated corefile"
Jan Kratochvil 89365c2
+clean_restart ${testfile}
Jan Kratochvil 89365c2
+
Jan Kratochvil 89365c2
+proc load_core { corefile } {
Jan Kratochvil 89365c2
+    global gdb_prompt
Jan Kratochvil 89365c2
+
Jan Kratochvil 89365c2
+    gdb_test_multiple "core $corefile" \
Jan Kratochvil 89365c2
+	"re-load generated corefile" {
Jan Kratochvil 89365c2
+	    -re " is not a core dump:.*\r\n$gdb_prompt $" {
Jan Kratochvil 89365c2
+		fail "re-load generated corefile (bad file format)"
Jan Kratochvil 89365c2
+		# No use proceeding from here.
Jan Kratochvil 89365c2
+		return 0;
Jan Kratochvil 89365c2
+	    }
Jan Kratochvil 89365c2
+	    -re ": No such file or directory.*\r\n$gdb_prompt $" {
Jan Kratochvil 89365c2
+		fail "re-load generated corefile (file not found)"
Jan Kratochvil 89365c2
+		# No use proceeding from here.
Jan Kratochvil 89365c2
+		return 0;
Jan Kratochvil 89365c2
+	    }
Jan Kratochvil 89365c2
+	    -re "Couldn't find .* registers in core file.*\r\n$gdb_prompt $" {
Jan Kratochvil 89365c2
+		fail "re-load generated corefile (incomplete note section)"
Jan Kratochvil 89365c2
+	    }
Jan Kratochvil 89365c2
+	    -re "Core was generated by .*\r\n$gdb_prompt $" {
Jan Kratochvil 89365c2
+		pass "re-load generated corefile"
Jan Kratochvil 89365c2
+	    }
Jan Kratochvil 89365c2
 	}
Jan Kratochvil 89365c2
-    }
Jan Kratochvil 89365c2
+    return 1
Jan Kratochvil 89365c2
+}
Jan Kratochvil 89365c2
+
Jan Kratochvil 89365c2
+if ![load_core $corefile] {
Jan Kratochvil 89365c2
+    return
Jan Kratochvil 89365c2
+}
Jan Kratochvil 89365c2
 
Jan Kratochvil 89365c2
 # FIXME: now what can we test about the thread state?
Jan Kratochvil 89365c2
 # We do not know for certain that there should be at least 
Jan Kratochvil 89365c2
@@ -181,5 +183,3 @@ if [istarget "*-*-linux*"] then {
Jan Kratochvil 89365c2
     gdb_test "info threads" "Thread $thread1_self .*" "thread1 pthread_self found"
Jan Kratochvil 89365c2
     gdb_test "info threads" "Thread $thread2_self .*" "thread2 pthread_self found"
Jan Kratochvil 89365c2
 }
Jan Kratochvil 89365c2
-
Jan Kratochvil 89365c2
-set timeout $prev_timeout