public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [patch] Forbid run with a core file loaded
@ 2010-05-21 14:47 Jan Kratochvil
  2010-05-21 15:02 ` Mark Kettenis
                   ` (2 more replies)
  0 siblings, 3 replies; 26+ messages in thread
From: Jan Kratochvil @ 2010-05-21 14:47 UTC (permalink / raw)
  To: gdb-patches

Hi,

there is already a protection against loading a core file when a program is
running.

But one still can now run a program when a core file is loaded.  Moreover GDB
then crashes on `quit'.

(gdb) file sleep
[...]
(gdb) start
[...]
(gdb) core-file core.5841 
A program is being debugged already.  Kill it? (y or n) y
[...]
Program terminated with signal 11, Segmentation fault.
[...]
(gdb) start
Starting program: /bin/sleep 
^^^^^^^^^^^^^^^^ !!!
[...]
(gdb) quit
A debugging session is active.
	Inferior 1 [process 13887] will be killed.
Quit anyway? (y or n) y
inferior.c:362: internal-error: find_inferior_pid: Assertion `pid != 0' failed.


Forbid even the latter case.

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


Thanks,
Jan


gdb/
2010-05-21  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Forbid run with a core file loaded.
	* infcmd.c (run_command_1) <core_bfd>: New.

gdb/testsuite/
2010-05-21  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Forbid run with a core file loaded.
	* gdb.base/corefile.exp (load core again, start with core)
	(started with core): New tests.

--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -483,6 +483,15 @@ run_command_1 (char *args, int from_tty, int tbreak_at_main)
 
   dont_repeat ();
 
+  if (core_bfd)
+    {
+      if (!from_tty
+	  || query (_("Core file is already loaded.  Unload it? ")))
+	core_file_command (NULL, from_tty);
+      if (core_bfd)
+	error (_("Core file not unloaded."));
+    }
+
   kill_if_already_running (from_tty);
 
   init_wait_for_inferior ();
--- a/gdb/testsuite/gdb.base/corefile.exp
+++ b/gdb/testsuite/gdb.base/corefile.exp
@@ -180,3 +180,15 @@ gdb_load ${binfile}
 gdb_test "up" "#\[0-9\]* *\[0-9xa-fH'\]* in .* \\(.*\\).*" "up in corefile.exp (reinit)"
 
 gdb_test "core" "No core file now."
+
+# Test a run (start) command will clear any loaded core file.
+
+gdb_test "core-file $corefile" "Core was generated by .*" "load core again"
+
+set test "start with core"
+gdb_test_multiple "start" $test {
+    -re {Core file is already loaded.  Unload it[?] [(]y or n[)] } {
+	pass $test
+    }
+}
+gdb_test "y" {No core file now\..*reakpoint [0-9]+, main.*} "started with core"

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

end of thread, other threads:[~2010-07-27 16:00 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-21 14:47 [patch] Forbid run with a core file loaded Jan Kratochvil
2010-05-21 15:02 ` Mark Kettenis
2010-05-21 15:05   ` Pedro Alves
2010-05-21 15:54     ` Mark Kettenis
2010-05-21 16:08       ` Pedro Alves
2010-05-21 15:05   ` Joel Brobecker
2010-05-21 15:40     ` Mark Kettenis
2010-05-23 19:38       ` Jan Kratochvil
2010-05-23 21:08         ` Eli Zaretskii
2010-06-06 19:51           ` Jan Kratochvil
2010-06-06 23:08             ` Eli Zaretskii
2010-06-07 11:21             ` Pedro Alves
2010-06-08  2:33               ` Tom Tromey
2010-06-08 11:03                 ` Pedro Alves
2010-07-08 17:17               ` Jan Kratochvil
2010-07-08 18:28                 ` Eli Zaretskii
2010-07-19 18:02                   ` Jan Kratochvil
2010-07-19 18:05                     ` Eli Zaretskii
2010-07-19 18:16                       ` Jan Kratochvil
2010-07-27 16:00                     ` Joel Brobecker
2010-07-19 14:37                 ` Pedro Alves
2010-05-23 21:16         ` Pedro Alves
2010-05-21 15:07   ` Jan Kratochvil
2010-05-21 15:04 ` Joel Brobecker
2010-05-21 15:06 ` Pedro Alves
2010-05-21 15:15   ` Joel Brobecker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).