This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] Fix gdb.mi internal_error on killing inferior


On Wed, 20 May 2009 22:43:17 +0200, Pedro Alves wrote:
> Weird, I don't see this happening.

Another reproducer + a backtrace below:
	echo -e '#include <unistd.h>\nint main(void){pause();return 0;}'|gcc -Wall -o pauset -x c -pthread -;echo -e '-gdb-set target-async 1\n-exec-run &\n-target-attach\ny' >cmd;../gdb -nx -i=mi ./pauset <./cmd


> And I think that if this legitimate, we should still
> restore our process group, terminal settings and signal handlers.

That looks right.


Regression tested on x86_64-unknown-linux-gnu (incomplete due to the
gdb.mi/*.exp ERRORs from elsewhere).


Thanks,
Jan



#0  internal_error (file=0xcad6af "inferior.c", line=42, string=0xcad690 "%s: Assertion `%s' failed.") at utils.c:995
#1  0x00000000004884ea in current_inferior () at inferior.c:42
#2  0x0000000000489112 in terminal_ours_1 (output_only=0) at inflow.c:369
#3  0x00000000004890f1 in terminal_ours () at inflow.c:349
#4  0x0000000000576abf in linux_nat_terminal_ours () at linux-nat.c:4400
#5  0x00000000005a9573 in mi_thread_exit (t=0x3472810, silent=0) at .././gdb/mi/mi-interp.c:304
#6  0x0000000000476349 in observer_thread_exit_notification_stub (data=0x5a954c, args_data=0x7fffffffc600) at observer.inc:344
#7  0x0000000000475c06 in generic_observer_notify (subject=0x1c0e530, args=0x7fffffffc600) at observer.c:166
#8  0x00000000004763e4 in observer_notify_thread_exit (t=0x3472810, silent=0) at observer.inc:369
#9  0x000000000063021a in delete_thread_1 (ptid={pid = 23878, lwp = 23878, tid = 0}, silent=0) at thread.c:270
#10 0x000000000063025a in delete_thread (ptid={pid = 23878, lwp = 23878, tid = 0}) at thread.c:282
#11 0x00000000004886ed in delete_thread_of_inferior (tp=0x3472810, data=0x7fffffffc740) at inferior.c:119
#12 0x000000000063037b in iterate_over_threads (callback=0x488655 <delete_thread_of_inferior>, data=0x7fffffffc740) at thread.c:339
#13 0x0000000000488770 in delete_inferior_1 (pid=23878, silent=0) at inferior.c:145
#14 0x00000000004887ca in delete_inferior (pid=23878) at inferior.c:162
#15 0x0000000000658a3d in generic_mourn_inferior () at target.c:2492
#16 0x00000000006fc7cf in inf_ptrace_mourn_inferior (ops=0x1b48fe0) at inf-ptrace.c:206
#17 0x00000000005735f6 in linux_nat_mourn_inferior (ops=0x1b48fe0) at linux-nat.c:3221
#18 0x0000000000657d5f in target_mourn_inferior () at target.c:1941
#19 0x0000000000573599 in linux_nat_kill (ops=0x1b48fe0) at linux-nat.c:3211
#20 0x0000000000654984 in target_kill () at target.c:268
#21 0x0000000000621299 in attach_command (args=0x0, from_tty=0) at infcmd.c:2261
#22 0x000000000059abe1 in do_cfunc (c=0x1b8b910, args=0x0, from_tty=0) at .././gdb/cli/cli-decode.c:67
#23 0x000000000059dc49 in cmd_func (cmd=0x1b8b910, args=0x0, from_tty=0) at .././gdb/cli/cli-decode.c:1734
#24 0x0000000000479979 in execute_command (p=0x3472537 "", from_tty=0) at top.c:441
#25 0x00000000005ac7d3 in mi_execute_cli_command (cmd=0xcdae16 "attach", args_p=1, args=0x34723f0 "") at .././gdb/mi/mi-main.c:1411
#26 0x00000000005ac6bd in mi_cmd_execute (parse=0x3471fc0) at .././gdb/mi/mi-main.c:1371
#27 0x00000000005abf5f in captured_mi_execute_command (uiout=0x1bb5080, data=0x3471fc0) at .././gdb/mi/mi-main.c:1172
#28 0x000000000063326f in catch_exception (uiout=0x1bb5080, func=0x5abe8d <captured_mi_execute_command>, func_args=0x3471fc0, mask=6) at exceptions.c:462
#29 0x00000000005ac1e5 in mi_execute_command (cmd=0x3471f30 "-target-attach", from_tty=1) at .././gdb/mi/mi-main.c:1266
#30 0x00000000005a948c in mi_execute_command_wrapper (cmd=0x3471f30 "-target-attach") at .././gdb/mi/mi-interp.c:251
#31 0x000000000063ba9c in gdb_readline2 (client_data=0x0) at event-top.c:820
#32 0x000000000063b0b7 in stdin_event_handler (error=0, client_data=0x0) at event-top.c:433
#33 0x000000000063974c in handle_file_event (data={ptr = 0x0, integer = 0}) at event-loop.c:812
#34 0x0000000000638e47 in process_event () at event-loop.c:394
#35 0x0000000000638eec in gdb_do_one_event (data=0x0) at event-loop.c:447
#36 0x000000000063343c in catch_errors (func=0x638e55 <gdb_do_one_event>, func_args=0x0, errstring=0xd05528 "", mask=6) at exceptions.c:510
#37 0x0000000000638f4a in start_event_loop () at event-loop.c:483
#38 0x00000000005a94fb in mi_command_loop (mi_version=2) at .././gdb/mi/mi-interp.c:281
#39 0x00000000005a94ac in mi2_command_loop () at .././gdb/mi/mi-interp.c:263
#40 0x0000000000633a45 in current_interp_command_loop () at interps.c:288
#41 0x0000000000471647 in captured_command_loop (data=0x0) at .././gdb/main.c:226
#42 0x000000000063343c in catch_errors (func=0x471636 <captured_command_loop>, func_args=0x0, errstring=0xca7647 "", mask=6) at exceptions.c:510
#43 0x00000000004726bc in captured_main (data=0x7fffffffd120) at .././gdb/main.c:902
#44 0x000000000063343c in catch_errors (func=0x47167b <captured_main>, func_args=0x7fffffffd120, errstring=0xca7647 "", mask=6) at exceptions.c:510
#45 0x00000000004726f2 in gdb_main (args=0x7fffffffd120) at .././gdb/main.c:911
#46 0x0000000000471356 in main (argc=4, argv=0x7fffffffd228) at gdb.c:33



gdb/
2009-05-20  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* target.c (generic_mourn_inferior): Remove variables `ptid' and `pid'.
	Call delete_inferior on active INFERIOR_PTID.
	* inferior.c (delete_inferior_1): Clear INFERIOR_PTID if this function
	has just deleted it.

gdb/testsuite/
2009-05-20  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* lib/mi-support.exp (mi_uncatched_gdb_exit): Explicitly terminate the
	inferior.

--- gdb/target.c	19 May 2009 00:23:49 -0000	1.208
+++ gdb/target.c	20 May 2009 21:12:37 -0000
@@ -2481,16 +2481,10 @@ find_target_beneath (struct target_ops *
 void
 generic_mourn_inferior (void)
 {
-  ptid_t ptid;
+  if (!ptid_equal (inferior_ptid, null_ptid))
+    delete_inferior (ptid_get_pid (inferior_ptid));
 
-  ptid = inferior_ptid;
-  inferior_ptid = null_ptid;
-
-  if (!ptid_equal (ptid, null_ptid))
-    {
-      int pid = ptid_get_pid (ptid);
-      delete_inferior (pid);
-    }
+  gdb_assert (ptid_equal (inferior_ptid, null_ptid));
 
   breakpoint_init_inferior (inf_exited);
   registers_changed ();
--- gdb/inferior.c	18 May 2009 00:58:37 -0000	1.8
+++ gdb/inferior.c	20 May 2009 21:08:54 -0000
@@ -153,6 +153,9 @@ delete_inferior_1 (int pid, int silent)
   else
     inferior_list = inf->next;
 
+  if (ptid_get_pid (inferior_ptid) == pid)
+    inferior_ptid = null_ptid;
+
   free_inferior (inf);
 }
 
--- gdb/testsuite/lib/mi-support.exp	2 Apr 2009 15:43:10 -0000	1.83
+++ gdb/testsuite/lib/mi-support.exp	20 May 2009 20:00:31 -0000
@@ -61,6 +61,28 @@ proc mi_uncatched_gdb_exit {} {
 
     verbose "Quitting $GDB $INTERNAL_GDBFLAGS $GDBFLAGS $MIFLAGS"
 
+    # Test successful termination of the inferior.  It is an optional check,
+    # inferior would get also terminated by -gdb-exit or remote_close below.
+
+    if { [board_info host exists fileid] } {
+	send_gdb "998-target-attach\n";
+	gdb_expect 10 {
+	    -re "y or n" {
+		send_gdb "y\n";
+		exp_continue;
+	    }
+	    -re "Undefined command.*$gdb_prompt $" {
+		send_gdb "quit\n"
+		exp_continue;
+	    }
+	    -re "998\\^error,msg=\"Argument required \\(process-id to attach\\).\".*$gdb_prompt \r\n$" {
+	    }
+	    default {
+		perror "Error terminating the inferior."
+	    }
+	}
+    }
+
     if { [is_remote host] && [board_info host exists fileid] } {
 	send_gdb "999-gdb-exit\n";
 	gdb_expect 10 {


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]