Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@codesourcery.com>
To: gdb-patches@sourceware.org
Subject: PR7580 - Command to force abort when internal error
Date: Mon, 29 Dec 2008 03:35:00 -0000	[thread overview]
Message-ID: <200812290335.09199.pedro@codesourcery.com> (raw)

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

I've wanted what Cagney proposed here before:

 http://sourceware.org/ml/gdb/2002-08/msg00166.html
 http://sourceware.org/bugzilla/show_bug.cgi?id=7580

In a nutshell, these new commands:

 maint set internal-error quit [on|off|auto]
 maint set internal-error corefile [on|off|auto]

The reaction seemed to be good at the time.

I've wanted it for slightly different reasons for this, though.  I find that
running the testsuite and collecting a bunch of core dumps of GDB (using sysctl
kernel.core_pattern), instead of looking at internal_errors in log files
helps find issues faster when I'm developing new features, or reworking
some all-affecting component.

So, here's a patch that adds those new commands so I don't have to
keep patching GDB whenever I want this behaviour.  :-)

Comments?  Eli, is the documentation proper?

-- 
Pedro Alves

[-- Attachment #2: pr7580.diff --]
[-- Type: text/x-diff, Size: 5439 bytes --]

gdb/
2008-12-29  Pedro Alves  <pedro@codesourcery.com>

	Add "maint set|show internal-error|internal-warning quit|corefile
	on|off|auto".
	
	PR gdb/7580:
	* utils.c (struct internal_problem): Remove FIXME.
	(set_internal_problem_cmd, show_internal_problem_cmd): New dummy
	functions.
	(add_internal_problem_command): New.
	(_initialize_utils): New.

gdb/doc/
2008-12-29  Pedro Alves  <pedro@codesourcery.com>

	PR gdb/7580:
	* gdb.texinfo (Maintenance Commands): Document "maint set|show
	internal-error|internal-warning quit|corefile on|off|auto".

---
 gdb/doc/gdb.texinfo |   23 +++++++++++++
 gdb/utils.c         |   86 ++++++++++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 107 insertions(+), 2 deletions(-)

Index: src/gdb/utils.c
===================================================================
--- src.orig/gdb/utils.c	2008-12-29 02:26:03.000000000 +0000
+++ src/gdb/utils.c	2008-12-29 03:30:18.000000000 +0000
@@ -832,8 +832,6 @@ error_stream (struct ui_file *stream)
 struct internal_problem
 {
   const char *name;
-  /* FIXME: cagney/2002-08-15: There should be ``maint set/show''
-     commands available for controlling these variables.  */
   enum auto_boolean should_quit;
   enum auto_boolean should_dump_core;
 };
@@ -987,6 +985,83 @@ internal_warning (const char *file, int 
   va_end (ap);
 }
 
+static void
+set_internal_problem_cmd (char *args, int from_tty)
+{
+}
+
+static void
+show_internal_problem_cmd (char *args, int from_tty)
+{
+}
+
+static void
+add_internal_problem_command (struct internal_problem *problem)
+{
+  struct cmd_list_element **set_cmd_list;
+  struct cmd_list_element **show_cmd_list;
+  char *set_doc;
+  char *show_doc;
+
+  set_cmd_list = xmalloc (sizeof (*set_cmd_list));
+  show_cmd_list = xmalloc (sizeof (*set_cmd_list));
+  *set_cmd_list = NULL;
+  *show_cmd_list = NULL;
+
+  set_doc = xstrprintf (_("Configure what GDB does when an %s is detected."),
+			problem->name);
+
+  show_doc = xstrprintf (_("Show what GDB does when an %s is detected."),
+			 problem->name);
+
+  add_prefix_cmd ((char*) problem->name,
+		  class_maintenance, set_internal_problem_cmd, set_doc,
+		  set_cmd_list,
+		  concat ("maintenance set ", problem->name, " ", NULL),
+		  0/*allow-unknown*/, &maintenance_set_cmdlist);
+
+  add_prefix_cmd ((char*) problem->name,
+		  class_maintenance, show_internal_problem_cmd, show_doc,
+		  show_cmd_list,
+		  concat ("maintenance show ", problem->name, " ", NULL),
+		  0/*allow-unknown*/, &maintenance_show_cmdlist);
+
+  set_doc = xstrprintf (_("\
+Set whether GDB should quit when an %s is detected"),
+			problem->name);
+  show_doc = xstrprintf (_("\
+Show whether GDB should quit when an %s is detected"),
+			 problem->name);
+
+  add_setshow_auto_boolean_cmd ("quit",
+				class_maintenance,
+				&problem->should_quit,
+				set_doc,
+				show_doc,
+				NULL, /* help_doc */
+				NULL, /* setfunc */
+				NULL, /* showfunc */
+				set_cmd_list,
+				show_cmd_list);
+
+  set_doc = xstrprintf (_("\
+Set whether GDB should create a core file of GDB when an %s is detected"),
+			problem->name);
+  show_doc = xstrprintf (_("\
+Show whether GDB will create a core file of GDB when an %s is detected"),
+			 problem->name);
+  add_setshow_auto_boolean_cmd ("corefile",
+				class_maintenance,
+				&problem->should_dump_core,
+				set_doc,
+				show_doc,
+				NULL, /* help_doc */
+				NULL, /* setfunc */
+				NULL, /* showfunc */
+				set_cmd_list,
+				show_cmd_list);
+}
+
 /* Print the system error message for errno, and also mention STRING
    as the file name for which the error was encountered.
    Then return to command level.  */
@@ -3441,3 +3516,10 @@ gdb_buildargv (const char *s)
     nomem (0);
   return argv;
 }
+
+void
+_initialize_utils (void)
+{
+  add_internal_problem_command (&internal_error_problem);
+  add_internal_problem_command (&internal_warning_problem);
+}
Index: src/gdb/doc/gdb.texinfo
===================================================================
--- src.orig/gdb/doc/gdb.texinfo	2008-12-29 02:33:57.000000000 +0000
+++ src/gdb/doc/gdb.texinfo	2008-12-29 03:03:54.000000000 +0000
@@ -24796,6 +24796,29 @@ Create a core file? (y or n) @kbd{n}
 (@value{GDBP})
 @end smallexample
 
+@kindex maint set internal-error quit
+@kindex maint show internal-error quit
+@kindex maint set internal-error corefile
+@kindex maint show internal-error corefile
+@kindex maint set internal-warning quit
+@kindex maint show internal-warning quit
+@kindex maint set internal-warning corefile
+@kindex maint show internal-warning corefile
+@item maint set internal-error quit [on|off|auto]
+@itemx maint show internal-error quit
+@itemx maint set internal-error corefile [on|off|auto]
+@itemx maint show internal-error corefile
+@itemx maint set internal-warning quit [on|off|auto]
+@itemx maint show internal-warning quit
+@itemx maint set internal-warning corefile [on|off|auto]
+@itemx maint show internal-warning corefile
+When @value{GDBN} reports an internal problem (error or warning) it
+gives the user the oportunity to both quit @value{GDBN} and create a
+core file of the current @value{GDBN} session.  These commands let you
+override the default (auto) of prompting the user.  You can specify
+that @value{GDBN} should always (on) or never (off) quit or create a
+core file.
+
 @kindex maint packet
 @item maint packet @var{text}
 If @value{GDBN} is talking to an inferior via the serial protocol,

             reply	other threads:[~2008-12-29  3:35 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-29  3:35 Pedro Alves [this message]
2008-12-29  4:41 ` Joel Brobecker
2008-12-29 14:27   ` Pedro Alves
2008-12-31  3:57     ` Joel Brobecker
2009-01-07 21:59       ` Pedro Alves
2009-01-09 14:25         ` Eli Zaretskii
2009-01-09 15:33           ` Andreas Schwab
2009-01-09 18:16             ` Eli Zaretskii
2009-01-09 20:01               ` Andreas Schwab
2009-01-09 20:07                 ` Eli Zaretskii
2009-01-09 20:15                   ` Andreas Schwab
2009-01-09 20:26                     ` Eli Zaretskii
2009-01-09 21:37                       ` Andreas Schwab
2009-01-10  9:04                         ` Eli Zaretskii
2009-01-25 23:19                           ` Pedro Alves
2009-01-26  3:53                             ` Eli Zaretskii
2009-01-26 16:27                               ` Pedro Alves
2009-01-09 18:29           ` Joel Brobecker
2009-01-09 20:11             ` Eli Zaretskii
2009-01-10  6:34               ` Daniel Jacobowitz
2009-01-09 20:36             ` Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200812290335.09199.pedro@codesourcery.com \
    --to=pedro@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox