public inbox for insight@sourceware.org
 help / color / mirror / Atom feed
* [patch/rfc] Output the internal-error msg via query
@ 2003-06-22 21:37 Andrew Cagney
  2003-06-26 17:27 ` Andrew Cagney
  0 siblings, 1 reply; 2+ messages in thread
From: Andrew Cagney @ 2003-06-22 21:37 UTC (permalink / raw)
  To: gdb-patches, insight

[-- Attachment #1: Type: text/plain, Size: 631 bytes --]

Hello,

Try running up insight and then, in the console window, typing:

	maint internal-error my message

A totally meaningless pop-up containing:

	Do you want to quit gdb?

appears.  Now imagine this poping up when you weren't expecting it. 
Helpful?  Not.

The attached modifies the internal-error code so that the entire problem 
string is passed into query().  By doing this insight, and MI have the 
full problem text, and not just the meaningless final line.

It does mean that, for the CLI, the problem text appears twice.  Given 
how distasterious an internal error is, I don't think that is a problem.

thoughts?
Andrew

[-- Attachment #2: diffs --]
[-- Type: text/plain, Size: 3472 bytes --]

2003-06-22  Andrew Cagney  <cagney@redhat.com>

	* utils.c (internal_vproblem): Print the problem to a reason
	buffer and then pass to query.  Make the msg variable more local.

Index: utils.c
===================================================================
RCS file: /cvs/src/src/gdb/utils.c,v
retrieving revision 1.101
diff -u -r1.101 utils.c
--- utils.c	16 Apr 2003 14:43:03 -0000	1.101
+++ utils.c	22 Jun 2003 21:30:52 -0000
@@ -689,42 +689,49 @@
 internal_vproblem (struct internal_problem *problem,
 		   const char *file, int line, const char *fmt, va_list ap)
 {
-  static char msg[] = "Recursive internal problem.\n";
   static int dejavu;
   int quit_p;
   int dump_core_p;
+  char *reason;
 
   /* Don't allow infinite error/warning recursion.  */
-  switch (dejavu)
-    {
-    case 0:
-      dejavu = 1;
-      break;
-    case 1:
-      dejavu = 2;
-      fputs_unfiltered (msg, gdb_stderr);
-      abort ();			/* NOTE: GDB has only three calls to abort().  */
-    default:
-      dejavu = 3;
-      write (STDERR_FILENO, msg, sizeof (msg));
-      exit (1);
-    }
+  {
+    static char msg[] = "Recursive internal problem.\n";
+    switch (dejavu)
+      {
+      case 0:
+	dejavu = 1;
+	break;
+      case 1:
+	dejavu = 2;
+	fputs_unfiltered (msg, gdb_stderr);
+	abort ();	/* NOTE: GDB has only three calls to abort().  */
+      default:
+	dejavu = 3;
+	write (STDERR_FILENO, msg, sizeof (msg));
+	exit (1);
+      }
+  }
 
   /* Try to get the message out and at the start of a new line.  */
   target_terminal_ours ();
   begin_line ();
 
-  /* The error/warning message.  Format using a style similar to a
-     compiler error message.  */
-  fprintf_unfiltered (gdb_stderr, "%s:%d: %s: ", file, line, problem->name);
-  vfprintf_unfiltered (gdb_stderr, fmt, ap);
-  fputs_unfiltered ("\n", gdb_stderr);
-
-  /* Provide more details so that the user knows that they are living
-     on the edge.  */
-  fprintf_unfiltered (gdb_stderr, "\
-A problem internal to GDB has been detected.  Further\n\
-debugging may prove unreliable.\n");
+  /* Create a string containing the full error/warning message.  Need
+     to call query with this full string, as otherwize the reason
+     (error/warning) and question become separated.  Format using a
+     style similar to a compiler error message.  Include extra detail
+     so that the user knows that they are living on the edge.  */
+  {
+    char *msg;
+    xvasprintf (&msg, fmt, ap);
+    xasprintf (&reason, "\
+%s:%d: %s: %s\n\
+A problem internal to GDB has been detected,\n\
+further debugging may prove unreliable.", file, line, problem->name, msg);
+    xfree (msg);
+    make_cleanup (xfree, reason);
+  }
 
   switch (problem->should_quit)
     {
@@ -732,7 +739,7 @@
       /* Default (yes/batch case) is to quit GDB.  When in batch mode
          this lessens the likelhood of GDB going into an infinate
          loop.  */
-      quit_p = query ("Quit this debugging session? ");
+      quit_p = query ("%s\nQuit this debugging session? ", reason);
       break;
     case AUTO_BOOLEAN_TRUE:
       quit_p = 1;
@@ -750,7 +757,7 @@
       /* Default (yes/batch case) is to dump core.  This leaves a GDB
          `dropping' so that it is easier to see that something went
          wrong in GDB.  */
-      dump_core_p = query ("Create a core file of GDB? ");
+      dump_core_p = query ("%s\nCreate a core file of GDB? ", reason);
       break;
       break;
     case AUTO_BOOLEAN_TRUE:

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

* Re: [patch/rfc] Output the internal-error msg via query
  2003-06-22 21:37 [patch/rfc] Output the internal-error msg via query Andrew Cagney
@ 2003-06-26 17:27 ` Andrew Cagney
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Cagney @ 2003-06-26 17:27 UTC (permalink / raw)
  To: gdb-patches, insight

> Hello,
> 
> Try running up insight and then, in the console window, typing:
> 
>     maint internal-error my message
> 
> A totally meaningless pop-up containing:
> 
>     Do you want to quit gdb?
> 
> appears.  Now imagine this poping up when you weren't expecting it. Helpful?  Not.
> 
> The attached modifies the internal-error code so that the entire problem string is passed into query().  By doing this insight, and MI have the full problem text, and not just the meaningless final line.
> 
> It does mean that, for the CLI, the problem text appears twice.  Given how distasterious an internal error is, I don't think that is a problem.

I've checked this in.  Trunk and 6 branch.  At least now insight users 
will know why GDB died.

Andrew


> 2003-06-22  Andrew Cagney  <cagney@redhat.com>
> 
> 	* utils.c (internal_vproblem): Print the problem to a reason
> 	buffer and then pass to query.  Make the msg variable more local.


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

end of thread, other threads:[~2003-06-26 17:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-06-22 21:37 [patch/rfc] Output the internal-error msg via query Andrew Cagney
2003-06-26 17:27 ` Andrew Cagney

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).