2008-07-29 Pedro Alves * infcmd.c (post_create_inferior): Rename to ... (post_create_inferior_1): ... this and make static. (fix_running_state): New. (post_create_inferior): New. --- gdb/infcmd.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) Index: src/gdb/infcmd.c =================================================================== --- src.orig/gdb/infcmd.c 2008-07-29 13:40:22.000000000 +0100 +++ src/gdb/infcmd.c 2008-07-29 13:44:02.000000000 +0100 @@ -408,8 +408,8 @@ tty_command (char *file, int from_tty) means (running, attaching, connecting, et cetera). The target should be stopped. */ -void -post_create_inferior (struct target_ops *target, int from_tty) +static void +post_create_inferior_1 (struct target_ops *target, int from_tty) { /* Be sure we own the terminal in case write operations are performed. */ target_terminal_ours (); @@ -445,6 +445,28 @@ post_create_inferior (struct target_ops observer_notify_inferior_created (target, from_tty); } +/* If an error happened, propagate GDB's knowledge of the executing + state to the frontend/user running state. */ + +static void +fix_running_state (void *arg) +{ + if (is_exited (inferior_ptid)) + return; + set_running (inferior_ptid, + is_executing (inferior_ptid)); +} + +/* See post_create_inferior_1 for description. */ + +void +post_create_inferior (struct target_ops *target, int from_tty) +{ + struct cleanup *old_chain = make_cleanup (fix_running_state, NULL); + post_create_inferior_1 (target, from_tty); + discard_cleanups (old_chain); +} + /* Kill the inferior if already running. This function is designed to be called when we are about to start the execution of the program from the beginning. Ask the user to confirm that he wants to restart