From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17662 invoked by alias); 29 Dec 2008 03:35:44 -0000 Received: (qmail 17542 invoked by uid 22791); 29 Dec 2008 03:35:42 -0000 X-SWARE-Spam-Status: No, hits=-1.5 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_34,J_CHICKENPOX_37,J_CHICKENPOX_48,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 29 Dec 2008 03:34:52 +0000 Received: (qmail 18676 invoked from network); 29 Dec 2008 03:34:50 -0000 Received: from unknown (HELO orlando.local) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 29 Dec 2008 03:34:50 -0000 From: Pedro Alves To: gdb-patches@sourceware.org Subject: PR7580 - Command to force abort when internal error Date: Mon, 29 Dec 2008 03:35:00 -0000 User-Agent: KMail/1.9.10 MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_tVEWJKXm9g5Bq8W" Message-Id: <200812290335.09199.pedro@codesourcery.com> X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-12/txt/msg00433.txt.bz2 --Boundary-00=_tVEWJKXm9g5Bq8W Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Content-length: 847 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 --Boundary-00=_tVEWJKXm9g5Bq8W Content-Type: text/x-diff; charset="iso 8859-15"; name="pr7580.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="pr7580.diff" Content-length: 5439 gdb/ 2008-12-29 Pedro Alves 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 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, --Boundary-00=_tVEWJKXm9g5Bq8W--