Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [patch 1/3] Code cleanup: gdb.threads/gcore-thread.exp
@ 2011-02-24  5:14 Jan Kratochvil
  2011-02-24  7:34 ` Joel Brobecker
  0 siblings, 1 reply; 4+ messages in thread
From: Jan Kratochvil @ 2011-02-24  5:14 UTC (permalink / raw)
  To: gdb-patches

Hi,

proc load_core is later used by patch 2/3.

I will check it in when the other two patches are considered ready.

No regressions on {x86_64,x86_64-m32,i686}-fedora15-linux-gnu.


Thanks,
Jan


gdb/testsuite/
2011-02-24  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* gdb.threads/gcore-thread.exp ($testfile): Match it the .exp
	filename.
	($srcfile): Preserve the original value.
	($testfile): Match it the .exp filename.
	($corefile): New variable.  Substitute it around.
	Use clean_restart.  Substitute 
	(load_core): Move core loading into this proc.
	Fix restore of $timeout if load_core fails.

--- a/gdb/testsuite/gdb.threads/gcore-thread.exp
+++ b/gdb/testsuite/gdb.threads/gcore-thread.exp
@@ -21,11 +21,11 @@ if $tracelevel then {
 	strace $tracelevel
 }
 
-
 # Single-threaded test case
-set testfile "pthreads"
-set srcfile  ${testfile}.c
-set binfile  ${objdir}/${subdir}/gcore-${testfile}
+set testfile "gcore-thread"
+set srcfile  pthreads.c
+set binfile  ${objdir}/${subdir}/${testfile}
+set corefile ${objdir}/${subdir}/${testfile}.test
 
 if [istarget "*-*-linux"] then {
     set target_cflags "-D_MIT_POSIX_THREADS"
@@ -41,10 +41,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab
 
 # Start with a fresh gdb.
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${testfile}
 
 # regexp for "horizontal" text (i.e. doesn't include newline or
 # carriage return)
@@ -92,10 +89,9 @@ delete_breakpoints
 gdb_breakpoint "thread2"
 gdb_test "continue" "Continuing.*Breakpoint.* thread2 .*" "thread 2 is running"
 
-set escapedfilename [string_to_regexp ${objdir}/${subdir}/gcore.test]
+set escapedfilename [string_to_regexp $corefile]
 # Drop corefile
-gdb_test_multiple "gcore ${objdir}/${subdir}/gcore.test" \
-	"save a corefile" \
+gdb_test_multiple "gcore $corefile" "save a corefile" \
 {
   -re "Saved corefile ${escapedfilename}\[\r\n\]+$gdb_prompt $" {
     pass "save a corefile"
@@ -114,31 +110,39 @@ if {!$core_supported} {
   return -1
 }
 
+
 # Now restart gdb and load the corefile.
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
-gdb_test_multiple "core ${objdir}/${subdir}/gcore.test" \
-    "re-load generated corefile" {
-	-re ".* is not a core dump:.*$gdb_prompt $" {
-	    fail "re-load generated corefile (bad file format)"
-	    # No use proceeding from here.
-	    return;
-	}
-	-re ".*: No such file or directory.*$gdb_prompt $" {
-	    fail "re-load generated corefile (file not found)"
-	    # No use proceeding from here.
-	    return;
-	}
-	-re ".*Couldn't find .* registers in core file.*$gdb_prompt $" {
-	    fail "re-load generated corefile (incomplete note section)"
-	}
-	-re "Core was generated by .*$gdb_prompt $" {
-	    pass "re-load generated corefile"
+clean_restart ${testfile}
+
+proc load_core { corefile } {
+    global gdb_prompt
+
+    gdb_test_multiple "core $corefile" \
+	"re-load generated corefile" {
+	    -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"
+	    }
 	}
-    }
+    return 1
+}
+
+if ![load_core $corefile] {
+    set timeout $prev_timeout
+    return
+}
 
 # FIXME: now what can we test about the thread state?
 # We do not know for certain that there should be at least 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch 1/3] Code cleanup: gdb.threads/gcore-thread.exp
  2011-02-24  5:14 [patch 1/3] Code cleanup: gdb.threads/gcore-thread.exp Jan Kratochvil
@ 2011-02-24  7:34 ` Joel Brobecker
  2011-02-24  7:35   ` Jan Kratochvil
  0 siblings, 1 reply; 4+ messages in thread
From: Joel Brobecker @ 2011-02-24  7:34 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches

> +if ![load_core $corefile] {
> +    set timeout $prev_timeout
> +    return
> +}

Just a thought: Do we really need to worry about restoring
the timeout at the end of the testcase, given that this is
automatically done at the start of each testcase (see gdb.exp:
gdb_init)?

-- 
Joel


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch 1/3] Code cleanup: gdb.threads/gcore-thread.exp
  2011-02-24  7:34 ` Joel Brobecker
@ 2011-02-24  7:35   ` Jan Kratochvil
  2011-04-17 19:05     ` [commit] " Jan Kratochvil
  0 siblings, 1 reply; 4+ messages in thread
From: Jan Kratochvil @ 2011-02-24  7:35 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

On Thu, 24 Feb 2011 08:20:09 +0100, Joel Brobecker wrote:
> Just a thought: Do we really need to worry about restoring
> the timeout at the end of the testcase, given that this is
> automatically done at the start of each testcase (see gdb.exp:
> gdb_init)?

I see now:
	Re: [RFA/testsuite] Reset the timeout duration at the start of each testcase.
	http://sourceware.org/ml/gdb-patches/2010-02/msg00202.html
	commit 501c57da40fd27c8036a5fc995f750b0559272ad

Patch updated.


Thanks,
Jan


gdb/testsuite/
2011-02-24  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* gdb.threads/gcore-thread.exp ($testfile): Match it the .exp
	filename.
	($srcfile): Preserve the original value.
	($testfile): Match it the .exp filename.
	($corefile): New variable.  Substitute it around.
	Use clean_restart.
	($prev_timeout): Remove.
	(load_core): Move core loading into this proc.
	Fix restore of $timeout if load_core fails.

--- a/gdb/testsuite/gdb.threads/gcore-thread.exp
+++ b/gdb/testsuite/gdb.threads/gcore-thread.exp
@@ -21,11 +21,11 @@ if $tracelevel then {
 	strace $tracelevel
 }
 
-
 # Single-threaded test case
-set testfile "pthreads"
-set srcfile  ${testfile}.c
-set binfile  ${objdir}/${subdir}/gcore-${testfile}
+set testfile "gcore-thread"
+set srcfile  pthreads.c
+set binfile  ${objdir}/${subdir}/${testfile}
+set corefile ${objdir}/${subdir}/${testfile}.test
 
 if [istarget "*-*-linux"] then {
     set target_cflags "-D_MIT_POSIX_THREADS"
@@ -41,10 +41,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab
 
 # Start with a fresh gdb.
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${testfile}
 
 # regexp for "horizontal" text (i.e. doesn't include newline or
 # carriage return)
@@ -53,7 +50,6 @@ set horiz "\[^\n\r\]*"
 # regexp for newline
 set nl "\[\r\n\]+"
 
-set prev_timeout $timeout
 set timeout 30
 
 gdb_test_multiple "help gcore" "help gcore" {
@@ -92,10 +88,9 @@ delete_breakpoints
 gdb_breakpoint "thread2"
 gdb_test "continue" "Continuing.*Breakpoint.* thread2 .*" "thread 2 is running"
 
-set escapedfilename [string_to_regexp ${objdir}/${subdir}/gcore.test]
+set escapedfilename [string_to_regexp $corefile]
 # Drop corefile
-gdb_test_multiple "gcore ${objdir}/${subdir}/gcore.test" \
-	"save a corefile" \
+gdb_test_multiple "gcore $corefile" "save a corefile" \
 {
   -re "Saved corefile ${escapedfilename}\[\r\n\]+$gdb_prompt $" {
     pass "save a corefile"
@@ -114,31 +109,38 @@ if {!$core_supported} {
   return -1
 }
 
+
 # Now restart gdb and load the corefile.
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
-gdb_test_multiple "core ${objdir}/${subdir}/gcore.test" \
-    "re-load generated corefile" {
-	-re ".* is not a core dump:.*$gdb_prompt $" {
-	    fail "re-load generated corefile (bad file format)"
-	    # No use proceeding from here.
-	    return;
-	}
-	-re ".*: No such file or directory.*$gdb_prompt $" {
-	    fail "re-load generated corefile (file not found)"
-	    # No use proceeding from here.
-	    return;
-	}
-	-re ".*Couldn't find .* registers in core file.*$gdb_prompt $" {
-	    fail "re-load generated corefile (incomplete note section)"
-	}
-	-re "Core was generated by .*$gdb_prompt $" {
-	    pass "re-load generated corefile"
+clean_restart ${testfile}
+
+proc load_core { corefile } {
+    global gdb_prompt
+
+    gdb_test_multiple "core $corefile" \
+	"re-load generated corefile" {
+	    -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"
+	    }
 	}
-    }
+    return 1
+}
+
+if ![load_core $corefile] {
+    return
+}
 
 # FIXME: now what can we test about the thread state?
 # We do not know for certain that there should be at least 
@@ -158,5 +160,3 @@ gdb_test "info threads" ".* thread2 .*" \
 
 gdb_test "info threads" ".*${nl}\\* ${horiz} thread2 .*" \
 	"thread2 is current thread in corefile"
-
-set timeout $prev_timeout


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [commit] [patch 1/3] Code cleanup: gdb.threads/gcore-thread.exp
  2011-02-24  7:35   ` Jan Kratochvil
@ 2011-04-17 19:05     ` Jan Kratochvil
  0 siblings, 0 replies; 4+ messages in thread
From: Jan Kratochvil @ 2011-04-17 19:05 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

On Thu, 24 Feb 2011 08:34:21 +0100, Jan Kratochvil wrote:
> gdb/testsuite/
> 2011-02-24  Jan Kratochvil  <jan.kratochvil@redhat.com>
> 
> 	* gdb.threads/gcore-thread.exp ($testfile): Match it the .exp
> 	filename.
> 	($srcfile): Preserve the original value.
> 	($testfile): Match it the .exp filename.
> 	($corefile): New variable.  Substitute it around.
> 	Use clean_restart.
> 	($prev_timeout): Remove.
> 	(load_core): Move core loading into this proc.
> 	Fix restore of $timeout if load_core fails.

Checked in:
	http://sourceware.org/ml/gdb-cvs/2011-04/msg00105.html


Thanks,
Jan


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-04-17 19:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-24  5:14 [patch 1/3] Code cleanup: gdb.threads/gcore-thread.exp Jan Kratochvil
2011-02-24  7:34 ` Joel Brobecker
2011-02-24  7:35   ` Jan Kratochvil
2011-04-17 19:05     ` [commit] " Jan Kratochvil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox