* Running testsuite with /proc/sys/kernel/core_uses_pid set, avoiding leaving core dump files behind
@ 2011-09-07 16:28 Pedro Alves
2011-09-08 14:15 ` Jan Kratochvil
2011-09-08 19:54 ` Jan Kratochvil
0 siblings, 2 replies; 6+ messages in thread
From: Pedro Alves @ 2011-09-07 16:28 UTC (permalink / raw)
To: gdb-patches
I run the testsuite with /proc/sys/kernel/core_uses_pid set,
so that if I get gdb dumping core more than once in a testrun,
I still get a core file per crash (the Linux kernel dumps
core files named core.PID instead). Unfortunately, this
means I always get a few extra core dump files left behind
on each test run (4 to be precise).
There are a couple of annotations tests that let the tested
program dump core, and then look for a file named "core" -- if the
file exists, it gets deleted. This of course fails to find
the core file if /proc/sys/kernel/core_uses_pid is set.
I'm fixing this by making the tests look for core.PID as well.
While at it, use the remote_file commands instead of running
`ls' directly. And do it on the host, where gdb and the
program runs (these tests are native only), not on the build,
for remote host testing without a shared filesystem.
The valgrind-db-attach.exp test runs a program under valgrind
that double-frees, and has valgrind setup to have gdb auto-attach to
the valgrind process when the double-free is detected. Since gdb is
attached (instead of having spawned the process), "(gdb) quit" detaches
(instead of killing), and that ends up with the inferior
aborting / dumping core, always leaving a core file behind.
The solution is to do an explicit "kill" before leaving.
I now only end up with a single unexpected core dump after a
testrun, generated by the typeddwarf binary of typeddwarf.exp
(a SIGSEGV). I'm not sure what's going on here. Looking at
the .c file, there doesn't seem to be anything that should crash.
But just running the typeddwarf binary directly always dumps
core. What I find strange is that the typeddwarf-amd64.S
file claims to be generated by
"gcc -S -g -O2 typeddwarf.c -o typeddwarf-amd64.S"
but typeddwarf-amd64.S doesn't contain a main label, it
has a _start label instead, so it looks like it got hand
massaged a bit. Indeed, if I compile typeddwarf.c
directly, I get a binary that does not crash.
Anyway, I don't supposed there are any objections to this
patch?
--
Pedro Alves
2011-09-07 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-04-27 18:53:19.000000000 +0100
+++ src/gdb/testsuite/gdb.base/annota1.exp 2011-09-07 15:49:38.314338788 +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-01-13 15:07:59.000000000 +0000
+++ src/gdb/testsuite/gdb.base/annota3.exp 2011-09-07 15:52:04.534338814 +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-01-13 15:08:03.000000000 +0000
+++ src/gdb/testsuite/gdb.base/valgrind-db-attach.exp 2011-09-07 16:16:35.794339071 +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"
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: Running testsuite with /proc/sys/kernel/core_uses_pid set, avoiding leaving core dump files behind
2011-09-07 16:28 Running testsuite with /proc/sys/kernel/core_uses_pid set, avoiding leaving core dump files behind Pedro Alves
@ 2011-09-08 14:15 ` Jan Kratochvil
2011-09-08 14:34 ` Pedro Alves
2011-09-08 19:54 ` Jan Kratochvil
1 sibling, 1 reply; 6+ messages in thread
From: Jan Kratochvil @ 2011-09-08 14:15 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
On Wed, 07 Sep 2011 18:18:38 +0200, Pedro Alves wrote:
> I'm fixing this by making the tests look for core.PID as well.
Do you have anything against using lib/gdb.exp core_find instead?
> Anyway, I don't supposed there are any objections to this
> patch?
While I agree that leaving a bunch of "anonymous" core files is definitely bad
the advantage of lib/gdb.exp core_find is that it keeps the intermediate files
for later problems investigations - identifiable with names "$binfile.core".
Thanks,
Jan
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Running testsuite with /proc/sys/kernel/core_uses_pid set, avoiding leaving core dump files behind
2011-09-08 14:15 ` Jan Kratochvil
@ 2011-09-08 14:34 ` Pedro Alves
2011-09-08 14:56 ` Jan Kratochvil
0 siblings, 1 reply; 6+ messages in thread
From: Pedro Alves @ 2011-09-08 14:34 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: gdb-patches
On Thursday 08 September 2011 14:08:33, Jan Kratochvil wrote:
> On Wed, 07 Sep 2011 18:18:38 +0200, Pedro Alves wrote:
> > I'm fixing this by making the tests look for core.PID as well.
>
> Do you have anything against using lib/gdb.exp core_find instead?
Nothing personal, no. :-) core_find is meant for a different scenario.
core_find runs a program that dumps core by itself, and such produced core
file is then used on subsequent gdb tests, as the inferior to debug.
The annota*.exp tests run a program that doesn't normally crash,
debug it normally (do some next/steps, etc., with annotations enabled),
and then force a signal on the inferior we know is not t handled
("(gdb) signal SIGTRAP"). The purpose of the test is not to generate the
core dump per se, but to check the annotations around sending a
signal that is not handled by the program. The core itself it totally
uninteresting, and is a byproduct. If you were investigating a annota*.exp
fail, you'd not need the core dump for anything.
On light of that, do you agree?
> > Anyway, I don't supposed there are any objections to this
> > patch?
>
> While I agree that leaving a bunch of "anonymous" core files is definitely bad
> the advantage of lib/gdb.exp core_find is that it keeps the intermediate files
> for later problems investigations - identifiable with names "$binfile.core".
Right, that's useful when we have tests that used the core as inferior, so
keeping it around is useful, as that way you still have the exact same
inferior handy to be able to reproduce the crash. But that's not the case of
these tests.
--
Pedro Alves
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: Running testsuite with /proc/sys/kernel/core_uses_pid set, avoiding leaving core dump files behind
2011-09-08 14:34 ` Pedro Alves
@ 2011-09-08 14:56 ` Jan Kratochvil
2011-09-08 15:25 ` Pedro Alves
0 siblings, 1 reply; 6+ messages in thread
From: Jan Kratochvil @ 2011-09-08 14:56 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
On Thu, 08 Sep 2011 16:15:15 +0200, Pedro Alves wrote:
> core_find is meant for a different scenario.
> core_find runs a program that dumps core by itself, and such produced core
> file is then used on subsequent gdb tests, as the inferior to debug.
OK, I see I was too quick.
> On light of that, do you agree?
I agree.
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$" {
Thanks,
Jan
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: Running testsuite with /proc/sys/kernel/core_uses_pid set, avoiding leaving core dump files behind
2011-09-08 14:56 ` Jan Kratochvil
@ 2011-09-08 15:25 ` Pedro Alves
0 siblings, 0 replies; 6+ messages in thread
From: Pedro Alves @ 2011-09-08 15:25 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: gdb-patches
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"
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Running testsuite with /proc/sys/kernel/core_uses_pid set, avoiding leaving core dump files behind
2011-09-07 16:28 Running testsuite with /proc/sys/kernel/core_uses_pid set, avoiding leaving core dump files behind Pedro Alves
2011-09-08 14:15 ` Jan Kratochvil
@ 2011-09-08 19:54 ` Jan Kratochvil
1 sibling, 0 replies; 6+ messages in thread
From: Jan Kratochvil @ 2011-09-08 19:54 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches, Tom Tromey
On Wed, 07 Sep 2011 18:18:38 +0200, Pedro Alves wrote:
> I now only end up with a single unexpected core dump after a
> testrun, generated by the typeddwarf binary of typeddwarf.exp
> (a SIGSEGV). I'm not sure what's going on here. Looking at
> the .c file, there doesn't seem to be anything that should crash.
It is linked from .exp with -nostdlib, therefore there is no _exit syscall but
ret, jumping into a garbage.
> What I find strange is that the typeddwarf-amd64.S
> file claims to be generated by
>
> "gcc -S -g -O2 typeddwarf.c -o typeddwarf-amd64.S"
>
> but typeddwarf-amd64.S doesn't contain a main label, it
> has a _start label instead, so it looks like it got hand
> massaged a bit.
I agree.
> Indeed, if I compile typeddwarf.c
> directly, I get a binary that does not crash.
As you did not use -nostdlib:
if { [prepare_for_testing "${test}.exp" "${test}" ${sfile} {nodebug additional_flags=-nostdlib}] } {
The reason for -nostdlib is:
Re: Regression: Re: RFC: implement typed DWARF stack
http://sourceware.org/ml/gdb-patches/2011-05/msg00325.html
to be able to run it with -m32 even on system without 32-bit devel libraries
installed.
Still I do not get any core file from this testcase, either with linux-nat or
with gdbserver, in both cases the program gets properly killed before it
crashes.
Thanks,
Jan
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-09-08 19:13 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-07 16:28 Running testsuite with /proc/sys/kernel/core_uses_pid set, avoiding leaving core dump files behind 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
2011-09-08 19:54 ` Jan Kratochvil
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox