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]

fix jmisc.exp failure with target-async


I'm seeing a new failure in async mode:

Breakpoint 4, *__GI_exit (status=0) at exit.c:99
99      exit.c: No such file or directory.
(gdb) PASS: gdb.java/jmisc.exp: continue to exit
set breakpoint pending off
Warning: the current language does not match this frame.
(gdb) FAIL: gdb.java/jmisc.exp: set breakpoint pending off

compared to sync:

Breakpoint 4, *__GI_exit (status=0) at exit.c:99
99      exit.c: No such file or directory.
Warning: the current language does not match this frame.
(gdb) PASS: gdb.java/jmisc.exp: continue to exit
set breakpoint pending off
(gdb) PASS: gdb.java/jmisc.exp: set breakpoint pending off

The problem is that on async the frame language check is
done differently compared to sync.  In async, we're only
printing the warning at the end of the next command;
we return early from execute_command when we run an
execution command (back to the event loop), instead of
blocking, and later when the execution command ends, we're
not doing the exact same thing the tail of execute_command
does.  This makes sync and async behave the same.

Tested on x86_64-linux and applied.

-- 
Pedro Alves

2011-12-16  Pedro Alves  <pedro@codesourcery.com>

	* inf-loop.c: Include top.h.
	(inferior_event_handler): Call check_frame_language.
	* top.c (check_frame_language_change): New, factored out from ...
	(execute_command): ... this.  Use check_frame_language_change.
	* top.h (check_frame_language_change): Declare.
---
 gdb/inf-loop.c |    6 ++---
 gdb/top.c      |   74 ++++++++++++++++++++++++++++++++------------------------
 gdb/top.h      |    2 ++
 3 files changed, 46 insertions(+), 36 deletions(-)

diff --git a/gdb/inf-loop.c b/gdb/inf-loop.c
index 8e49e91..c768400 100644
--- a/gdb/inf-loop.c
+++ b/gdb/inf-loop.c
@@ -30,6 +30,7 @@
 #include "gdbthread.h"
 #include "continuations.h"
 #include "interps.h"
+#include "top.h"
 
 static int fetch_inferior_event_wrapper (gdb_client_data client_data);
 
@@ -107,10 +108,7 @@ inferior_event_handler (enum inferior_event_type event_type,
 	{
 	  volatile struct gdb_exception e;
 
-	  if (info_verbose
-	      && current_language != expected_language
-	      && language_mode == language_mode_auto)
-	    language_info (1);	/* Print what changed.  */
+	  check_frame_language_change ();
 
 	  /* Don't propagate breakpoint commands errors.  Either we're
 	     stopping or some command resumes the inferior.  The user will
diff --git a/gdb/top.c b/gdb/top.c
index ec475a8..f1b8b3c 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -362,6 +362,47 @@ prepare_execute_command (void)
   return cleanup;
 }
 
+/* Tell the user if the language has changed (except first time) after
+   executing a command.  */
+
+void
+check_frame_language_change (void)
+{
+  static int warned = 0;
+
+  /* First make sure that a new frame has been selected, in case the
+     command or the hooks changed the program state.  */
+  deprecated_safe_get_selected_frame ();
+  if (current_language != expected_language)
+    {
+      if (language_mode == language_mode_auto && info_verbose)
+	{
+	  language_info (1);	/* Print what changed.  */
+	}
+      warned = 0;
+    }
+
+  /* Warn the user if the working language does not match the language
+     of the current frame.  Only warn the user if we are actually
+     running the program, i.e. there is a stack.  */
+  /* FIXME: This should be cacheing the frame and only running when
+     the frame changes.  */
+
+  if (has_stack_frames ())
+    {
+      enum language flang;
+
+      flang = get_frame_language ();
+      if (!warned
+	  && flang != language_unknown
+	  && flang != current_language->la_language)
+	{
+	  printf_filtered ("%s\n", lang_frame_mismatch_warn);
+	  warned = 1;
+	}
+    }
+}
+
 /* Execute the line P as a command, in the current user context.
    Pass FROM_TTY as second argument to the defining function.  */
 
@@ -370,8 +411,6 @@ execute_command (char *p, int from_tty)
 {
   struct cleanup *cleanup_if_error, *cleanup;
   struct cmd_list_element *c;
-  enum language flang;
-  static int warned = 0;
   char *line;
 
   cleanup_if_error = make_bpstat_clear_actions_cleanup ();
@@ -458,36 +497,7 @@ execute_command (char *p, int from_tty)
 
     }
 
-  /* Tell the user if the language has changed (except first time).
-     First make sure that a new frame has been selected, in case this
-     command or the hooks changed the program state.  */
-  deprecated_safe_get_selected_frame ();
-  if (current_language != expected_language)
-    {
-      if (language_mode == language_mode_auto && info_verbose)
-	{
-	  language_info (1);	/* Print what changed.  */
-	}
-      warned = 0;
-    }
-
-  /* Warn the user if the working language does not match the
-     language of the current frame.  Only warn the user if we are
-     actually running the program, i.e. there is a stack.  */
-  /* FIXME:  This should be cacheing the frame and only running when
-     the frame changes.  */
-
-  if (has_stack_frames ())
-    {
-      flang = get_frame_language ();
-      if (!warned
-	  && flang != language_unknown
-	  && flang != current_language->la_language)
-	{
-	  printf_filtered ("%s\n", lang_frame_mismatch_warn);
-	  warned = 1;
-	}
-    }
+  check_frame_language_change ();
 
   do_cleanups (cleanup);
   discard_cleanups (cleanup_if_error);
diff --git a/gdb/top.h b/gdb/top.h
index 3e6679c..8806402 100644
--- a/gdb/top.h
+++ b/gdb/top.h
@@ -44,6 +44,8 @@ extern void quit_command (char *, int);
 extern void quit_cover (void);
 extern void execute_command (char *, int);
 
+extern void check_frame_language_change (void);
+
 /* Prepare for execution of a command.
    Call this before every command, CLI or MI.
    Returns a cleanup to be run after the command is completed.  */


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