Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@codesourcery.com>
To: Jan Kratochvil <jan.kratochvil@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: Running testsuite with /proc/sys/kernel/core_uses_pid set, avoiding leaving core dump files behind
Date: Thu, 08 Sep 2011 15:25:00 -0000	[thread overview]
Message-ID: <201109081558.53929.pedro@codesourcery.com> (raw)
In-Reply-To: <20110908143311.GA19256@host1.jankratochvil.net>

On Thursday 08 September 2011 15:33:11, Jan Kratochvil wrote:
> On Thu, 08 Sep 2011 16:15:15 +0200, Pedro Alves wrote:

> > On light of that, do you agree?
> 
> I agree.

Great, thanks.

> On Wed, 07 Sep 2011 18:18:38 +0200, Pedro Alves wrote:
> > +    -re "process (\[-\]*\[0-9\]*).*$gdb_prompt$" {
> 
> why not just (twice):
>   +    -re "process (-*\[0-9\]*).*$gdb_prompt$" {
> 

Good question.  I just copied it from elsewhere, and didn't
pay close enough attention -- It could be -? even, but
actually, we don't care for negative numbers here.  I've removed
the match for -.

Here's what I applied.  Thanks!

-- 
Pedro Alves

2011-09-08  Pedro Alves  <pedro@codesourcery.com>

	gdb/testsuite/
	* gdb.base/annota1.exp, gdb.base/annota3.exp: Extract the
	inferior's pid and look for a core dump named core.$pid.  Use
	`remote_file' commands on the host instead of hand coding shell
	commands on the build.
	* gdb.base/valgrind-db-attach.exp: Kill the program before
	finishing the test.

---
 gdb/testsuite/gdb.base/annota1.exp            |   29 ++++++++++++++++----------
 gdb/testsuite/gdb.base/annota3.exp            |   28 ++++++++++++++++---------
 gdb/testsuite/gdb.base/valgrind-db-attach.exp |    3 ++
 3 files changed, 39 insertions(+), 21 deletions(-)

Index: src/gdb/testsuite/gdb.base/annota1.exp
===================================================================
--- src.orig/gdb/testsuite/gdb.base/annota1.exp	2011-09-07 19:03:17.000000000 +0100
+++ src/gdb/testsuite/gdb.base/annota1.exp	2011-09-08 15:48:56.567212655 +0100
@@ -392,6 +392,17 @@ gdb_test_multiple "next" "breakpoint ign
     }
 }
 
+# Get the inferior's PID for later.
+
+set test "get inferior pid"
+set pid -1
+gdb_test_multiple "info inferior 1" "$test" {
+    -re "process (\[0-9\]*).*$gdb_prompt$" {
+	set pid $expect_out(1,string)
+	pass "$test"
+    }
+}
+
 #
 # Send a signal that is not handled; test:
 # annotate-signalled
@@ -422,21 +433,17 @@ if [target_info exists gdb,nosignals] {
     }
 }
 
-
 # Check for production of a core file and remove it!
 
-set exec_output [remote_exec build "ls core"]
-
 set test "cleanup core file"
-if [ regexp "core not found" $exec_output]  {
-    pass "$test (not dumped)"
+if { [remote_file host exists core] } {
+    remote_file host delete core
+    pass "$test (removed)"
+} elseif { $pid != -1 && [remote_file host exists core.$pid] } {
+    remote_file host delete core.$pid
+    pass "$test (removed)"
 } else {
-    if [ regexp "No such file or directory" $exec_output] {
-	pass "$test (not dumped)"
-    } else {
-	remote_exec build "rm -f core"
-	pass "$test (removed)"
-    }
+    pass "$test (not dumped)"
 }
 
 proc thread_test {} {
Index: src/gdb/testsuite/gdb.base/annota3.exp
===================================================================
--- src.orig/gdb/testsuite/gdb.base/annota3.exp	2011-09-07 19:03:17.000000000 +0100
+++ src/gdb/testsuite/gdb.base/annota3.exp	2011-09-08 15:48:56.567212655 +0100
@@ -365,6 +365,17 @@ gdb_expect_list "breakpoint ignore count
     "\r\n\032\032stopped\r\n"
 }
 
+# Get the inferior's PID for later.
+
+set test "get inferior pid"
+set pid -1
+gdb_test_multiple "info inferior 1" "$test" {
+    -re "process (\[0-9\]*).*$gdb_prompt$" {
+	set pid $expect_out(1,string)
+	pass "$test"
+    }
+}
+
 #
 # Send a signal that is not handled
 #
@@ -396,18 +407,15 @@ if [target_info exists gdb,nosignals] {
 
 # Check for production of a core file and remove it!
 
-set exec_output [remote_exec build "ls core"]
-
 set test "cleanup core file"
-if [ regexp "core not found" $exec_output]  {
-    pass "$test (not dumped)"
+if { [remote_file host exists core] } {
+    remote_file host delete core
+    pass "$test (removed)"
+} elseif { $pid != -1 && [remote_file host exists core.$pid] } {
+    remote_file host delete core.$pid
+    pass "$test (removed)"
 } else {
-    if [ regexp "No such file or directory" $exec_output] {
-	pass "$test (not dumped)"
-    } else {
-	remote_exec build "rm -f core"
-	pass "$test (removed)"
-    }
+    pass "$test (not dumped)"
 }
 
 # restore the original prompt for the rest of the testsuite
Index: src/gdb/testsuite/gdb.base/valgrind-db-attach.exp
===================================================================
--- src.orig/gdb/testsuite/gdb.base/valgrind-db-attach.exp	2011-09-07 19:03:17.000000000 +0100
+++ src/gdb/testsuite/gdb.base/valgrind-db-attach.exp	2011-09-07 19:11:59.394340911 +0100
@@ -83,3 +83,6 @@ gdb_test_no_output "set height 0"
 gdb_test_no_output "set width 0"
 
 gdb_test "bt" "in main \\(.*\\) at .*${srcfile}:$double_free"
+
+# Explicitly kill the program so it doesn't dump core when we quit->detach.
+gdb_test "kill" "" "kill program" "Kill the program being debugged.*y or n. $" "y"


  reply	other threads:[~2011-09-08 14:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-07 16:28 Pedro Alves
2011-09-08 14:15 ` Jan Kratochvil
2011-09-08 14:34   ` Pedro Alves
2011-09-08 14:56     ` Jan Kratochvil
2011-09-08 15:25       ` Pedro Alves [this message]
2011-09-08 19:54 ` Jan Kratochvil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201109081558.53929.pedro@codesourcery.com \
    --to=pedro@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    --cc=jan.kratochvil@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox