* PR7580 - Command to force abort when internal error
@ 2008-12-29 3:35 Pedro Alves
2008-12-29 4:41 ` Joel Brobecker
0 siblings, 1 reply; 21+ messages in thread
From: Pedro Alves @ 2008-12-29 3:35 UTC (permalink / raw)
To: gdb-patches
[-- 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,
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: PR7580 - Command to force abort when internal error 2008-12-29 3:35 PR7580 - Command to force abort when internal error Pedro Alves @ 2008-12-29 4:41 ` Joel Brobecker 2008-12-29 14:27 ` Pedro Alves 0 siblings, 1 reply; 21+ messages in thread From: Joel Brobecker @ 2008-12-29 4:41 UTC (permalink / raw) To: Pedro Alves; +Cc: gdb-patches > maint set internal-error quit [on|off|auto] > maint set internal-error corefile [on|off|auto] Using "on|off|auto" allows us to re-use the tri-state boolean set/show commands, but I do find the "auto" value to be confusing. How about using "on|off|ask" instead? -- Joel ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: PR7580 - Command to force abort when internal error 2008-12-29 4:41 ` Joel Brobecker @ 2008-12-29 14:27 ` Pedro Alves 2008-12-31 3:57 ` Joel Brobecker 0 siblings, 1 reply; 21+ messages in thread From: Pedro Alves @ 2008-12-29 14:27 UTC (permalink / raw) To: gdb-patches; +Cc: Joel Brobecker [-- Attachment #1: Type: text/plain, Size: 1020 bytes --] On Monday 29 December 2008 04:40:11, Joel Brobecker wrote: > > maint set internal-error quit [on|off|auto] > > maint set internal-error corefile [on|off|auto] > > Using "on|off|auto" allows us to re-use the tri-state boolean set/show > commands, but I do find the "auto" value to be confusing. How about > using "on|off|ask" instead? I agree that it is confusing. It seemed at since the variable was already auto_boolean, it was already established that "auto" could mean "ask" in some contexts. "set breakpoint pending" command is using "auto" in a similar way, though, surprisingly, there aren't that many setshow_auto_boolean commands; and we don't need to make the same mistake here. I looked around for other three-state commands, and didn't find reusable patterns, which made me drop the idea of generalizing this, but there's a chance I didn't look right. I think the best is to make this an enum command with the three options ask|on|off, or perhaps better yet, ask|yes|no, as attached? -- Pedro Alves [-- Attachment #2: pr7580.diff --] [-- Type: text/x-diff, Size: 8927 bytes --] gdb/ 2008-12-29 Pedro Alves <pedro@codesourcery.com> Add "maint set|show internal-error|internal-warning quit|corefile ask|yes|no" commands. PR gdb/7580: * utils.c (internal_problem_ask, internal_problem_yes) (internal_problem_no, internal_problem_modes): New. (struct internal_problem): Remove FIXME. Make should_quit and should_dump_core types to char *. (internal_vproblem, internal_error_problem) (internal_warning_problem): Adjust. (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 ask|yes|no". --- gdb/doc/gdb.texinfo | 23 ++++++++ gdb/utils.c | 149 +++++++++++++++++++++++++++++++++++++++++----------- 2 files changed, 141 insertions(+), 31 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 14:02:27.000000000 +0000 @@ -825,6 +825,21 @@ error_stream (struct ui_file *stream) error (("%s"), message); } +/* Allow the user to configure the debugger behavior with respect to + what to do when an internal problem is detected. */ + +const char internal_problem_ask[] = "ask"; +const char internal_problem_yes[] = "yes"; +const char internal_problem_no[] = "no"; +static const char *internal_problem_modes[] = +{ + internal_problem_ask, + internal_problem_yes, + internal_problem_no, + NULL +}; +static const char *internal_problem_mode = internal_problem_ask; + /* Print a message reporting an internal error/warning. Ask the user if they want to continue, dump core, or just exit. Return something to indicate a quit. */ @@ -832,10 +847,8 @@ 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; + const char *should_quit; + const char *should_dump_core; }; /* Report a problem, internal to GDB, to the user. Once the problem @@ -890,42 +903,33 @@ further debugging may prove unreliable." make_cleanup (xfree, reason); } - switch (problem->should_quit) + if (problem->should_quit == internal_problem_ask) { - case AUTO_BOOLEAN_AUTO: /* Default (yes/batch case) is to quit GDB. When in batch mode - this lessens the likelhood of GDB going into an infinate - loop. */ + this lessens the likelihood of GDB going into an infinite + loop. */ quit_p = query (_("%s\nQuit this debugging session? "), reason); - break; - case AUTO_BOOLEAN_TRUE: - quit_p = 1; - break; - case AUTO_BOOLEAN_FALSE: - quit_p = 0; - break; - default: - internal_error (__FILE__, __LINE__, _("bad switch")); } + else if (problem->should_quit == internal_problem_yes) + quit_p = 1; + else if (problem->should_quit == internal_problem_no) + quit_p = 0; + else + internal_error (__FILE__, __LINE__, _("bad switch")); - switch (problem->should_dump_core) + if (problem->should_dump_core == internal_problem_ask) { - case AUTO_BOOLEAN_AUTO: /* 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 (_("%s\nCreate a core file of GDB? "), reason); - break; - break; - case AUTO_BOOLEAN_TRUE: - dump_core_p = 1; - break; - case AUTO_BOOLEAN_FALSE: - dump_core_p = 0; - break; - default: - internal_error (__FILE__, __LINE__, _("bad switch")); } + else if (problem->should_dump_core == internal_problem_yes) + dump_core_p = 1; + else if (problem->should_dump_core == internal_problem_no) + dump_core_p = 0; + else + internal_error (__FILE__, __LINE__, _("bad switch")); if (quit_p) { @@ -949,7 +953,7 @@ further debugging may prove unreliable." } static struct internal_problem internal_error_problem = { - "internal-error", AUTO_BOOLEAN_AUTO, AUTO_BOOLEAN_AUTO + "internal-error", internal_problem_ask, internal_problem_ask }; NORETURN void @@ -969,7 +973,7 @@ internal_error (const char *file, int li } static struct internal_problem internal_warning_problem = { - "internal-warning", AUTO_BOOLEAN_AUTO, AUTO_BOOLEAN_AUTO + "internal-warning", internal_problem_ask, internal_problem_ask }; void @@ -987,6 +991,82 @@ 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 will quit when an %s is detected"), + problem->name); + add_setshow_enum_cmd ("quit", class_maintenance, + internal_problem_modes, + &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_enum_cmd ("corefile", class_maintenance, + internal_problem_modes, + &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 +3521,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 13:09:09.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 [ask|yes|no] +@itemx maint show internal-error quit +@itemx maint set internal-error corefile [ask|yes|no] +@itemx maint show internal-error corefile +@itemx maint set internal-warning quit [ask|yes|no] +@itemx maint show internal-warning quit +@itemx maint set internal-warning corefile [ask|yes|no] +@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 (ask) of prompting the user. You can specify +that @value{GDBN} should always (yes) or never (no) 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, ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: PR7580 - Command to force abort when internal error 2008-12-29 14:27 ` Pedro Alves @ 2008-12-31 3:57 ` Joel Brobecker 2009-01-07 21:59 ` Pedro Alves 0 siblings, 1 reply; 21+ messages in thread From: Joel Brobecker @ 2008-12-31 3:57 UTC (permalink / raw) To: Pedro Alves; +Cc: gdb-patches > I looked around for other three-state commands, and didn't find > reusable patterns, which made me drop the idea of > generalizing this, but there's a chance I didn't look right. I couldn't come up with other examples where this would be useful either. But it's always easy to factorize it if we find some later. > I think the best is to make this an enum command with > the three options ask|on|off, or perhaps better yet, ask|yes|no, as > attached? Sounds good to me. > (set_internal_problem_cmd, show_internal_problem_cmd): New dummy > functions. > (add_internal_problem_command): New. > (_initialize_utils): New. Just to be consistent: We try to add a short description as a comment for all new functions introduced. I think it's OK to lose the comment in the case of the dummy functions, but it'd be nice to have a small description for add_internal_problem_command... Other than this nit picking, the patch looked OK to me. -- Joel ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: PR7580 - Command to force abort when internal error 2008-12-31 3:57 ` Joel Brobecker @ 2009-01-07 21:59 ` Pedro Alves 2009-01-09 14:25 ` Eli Zaretskii 0 siblings, 1 reply; 21+ messages in thread From: Pedro Alves @ 2009-01-07 21:59 UTC (permalink / raw) To: Joel Brobecker; +Cc: gdb-patches, Eli Zaretskii [-- Attachment #1: Type: text/plain, Size: 471 bytes --] On Wednesday 31 December 2008 03:57:05, Joel Brobecker wrote: > Just to be consistent: We try to add a short description as a comment > for all new functions introduced. I think it's OK to lose the comment > in the case of the dummy functions, but it'd be nice to have a small > description for add_internal_problem_command... Other than this nit > picking, the patch looked OK to me. Thanks! I've added comments. Eli, is the documentation piece OK? -- Pedro Alves [-- Attachment #2: pr7580.diff --] [-- Type: text/x-diff, Size: 9589 bytes --] gdb/ 2009-01-07 Pedro Alves <pedro@codesourcery.com> Add "maint set|show internal-error|internal-warning quit|corefile ask|yes|no" commands. PR gdb/7580: * utils.c (internal_problem_ask, internal_problem_yes) (internal_problem_no, internal_problem_modes): New. (struct internal_problem): Remove FIXME. Make should_quit and should_dump_core types to char *. (internal_vproblem, internal_error_problem) (internal_warning_problem): Adjust. (set_internal_problem_cmd, show_internal_problem_cmd): New dummy functions. (add_internal_problem_command): New. (_initialize_utils): New. gdb/doc/ 2009-01-07 Pedro Alves <pedro@codesourcery.com> PR gdb/7580: * gdb.texinfo (Maintenance Commands): Document "maint set|show internal-error|internal-warning quit|corefile ask|yes|no". --- gdb/doc/gdb.texinfo | 23 +++++++ gdb/utils.c | 166 ++++++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 158 insertions(+), 31 deletions(-) Index: src/gdb/utils.c =================================================================== --- src.orig/gdb/utils.c 2009-01-07 21:54:55.000000000 +0000 +++ src/gdb/utils.c 2009-01-07 21:55:40.000000000 +0000 @@ -825,6 +825,21 @@ error_stream (struct ui_file *stream) error (("%s"), message); } +/* Allow the user to configure the debugger behavior with respect to + what to do when an internal problem is detected. */ + +const char internal_problem_ask[] = "ask"; +const char internal_problem_yes[] = "yes"; +const char internal_problem_no[] = "no"; +static const char *internal_problem_modes[] = +{ + internal_problem_ask, + internal_problem_yes, + internal_problem_no, + NULL +}; +static const char *internal_problem_mode = internal_problem_ask; + /* Print a message reporting an internal error/warning. Ask the user if they want to continue, dump core, or just exit. Return something to indicate a quit. */ @@ -832,10 +847,8 @@ 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; + const char *should_quit; + const char *should_dump_core; }; /* Report a problem, internal to GDB, to the user. Once the problem @@ -896,42 +909,33 @@ further debugging may prove unreliable." make_cleanup (xfree, reason); } - switch (problem->should_quit) + if (problem->should_quit == internal_problem_ask) { - case AUTO_BOOLEAN_AUTO: /* Default (yes/batch case) is to quit GDB. When in batch mode - this lessens the likelhood of GDB going into an infinate - loop. */ + this lessens the likelihood of GDB going into an infinite + loop. */ quit_p = query (_("%s\nQuit this debugging session? "), reason); - break; - case AUTO_BOOLEAN_TRUE: - quit_p = 1; - break; - case AUTO_BOOLEAN_FALSE: - quit_p = 0; - break; - default: - internal_error (__FILE__, __LINE__, _("bad switch")); } + else if (problem->should_quit == internal_problem_yes) + quit_p = 1; + else if (problem->should_quit == internal_problem_no) + quit_p = 0; + else + internal_error (__FILE__, __LINE__, _("bad switch")); - switch (problem->should_dump_core) + if (problem->should_dump_core == internal_problem_ask) { - case AUTO_BOOLEAN_AUTO: /* 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 (_("%s\nCreate a core file of GDB? "), reason); - break; - break; - case AUTO_BOOLEAN_TRUE: - dump_core_p = 1; - break; - case AUTO_BOOLEAN_FALSE: - dump_core_p = 0; - break; - default: - internal_error (__FILE__, __LINE__, _("bad switch")); } + else if (problem->should_dump_core == internal_problem_yes) + dump_core_p = 1; + else if (problem->should_dump_core == internal_problem_no) + dump_core_p = 0; + else + internal_error (__FILE__, __LINE__, _("bad switch")); if (quit_p) { @@ -955,7 +959,7 @@ further debugging may prove unreliable." } static struct internal_problem internal_error_problem = { - "internal-error", AUTO_BOOLEAN_AUTO, AUTO_BOOLEAN_AUTO + "internal-error", internal_problem_ask, internal_problem_ask }; NORETURN void @@ -975,7 +979,7 @@ internal_error (const char *file, int li } static struct internal_problem internal_warning_problem = { - "internal-warning", AUTO_BOOLEAN_AUTO, AUTO_BOOLEAN_AUTO + "internal-warning", internal_problem_ask, internal_problem_ask }; void @@ -993,6 +997,99 @@ internal_warning (const char *file, int va_end (ap); } +/* Dummy functions to keep add_prefix_cmd happy. */ + +static void +set_internal_problem_cmd (char *args, int from_tty) +{ +} + +static void +show_internal_problem_cmd (char *args, int from_tty) +{ +} + +/* When GDB reports an internal problem (error or warning) it gives + the user the opportunity to quit GDB and/or create a core file of + the current debug session. This function registers a few commands + that make it possible to specify that GDB should always or never + quit or create a core file, without asking. The commands look + like: + + maint set PROBLEM-NAME quit ask|yes|no + maint show PROBLEM-NAME quit + maint set PROBLEM-NAME corefile ask|yes|no + maint show PROBLEM-NAME corefile + + Where PROBLEM-NAME is currently "internal-error" or + "internal-warning". */ + +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 will quit when an %s is detected"), + problem->name); + add_setshow_enum_cmd ("quit", class_maintenance, + internal_problem_modes, + &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_enum_cmd ("corefile", class_maintenance, + internal_problem_modes, + &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. */ @@ -3446,3 +3543,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 2009-01-07 21:54:57.000000000 +0000 +++ src/gdb/doc/gdb.texinfo 2009-01-07 21:55:40.000000000 +0000 @@ -24795,6 +24795,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 [ask|yes|no] +@itemx maint show internal-error quit +@itemx maint set internal-error corefile [ask|yes|no] +@itemx maint show internal-error corefile +@itemx maint set internal-warning quit [ask|yes|no] +@itemx maint show internal-warning quit +@itemx maint set internal-warning corefile [ask|yes|no] +@itemx maint show internal-warning corefile +When @value{GDBN} reports an internal problem (error or warning) it +gives the user the opportunity to both quit @value{GDBN} and create a +core file of the current @value{GDBN} session. These commands let you +override the default (ask) of prompting the user. You can specify +that @value{GDBN} should always (yes) or never (no) 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, ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: PR7580 - Command to force abort when internal error 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:29 ` Joel Brobecker 0 siblings, 2 replies; 21+ messages in thread From: Eli Zaretskii @ 2009-01-09 14:25 UTC (permalink / raw) To: Pedro Alves; +Cc: brobecker, gdb-patches > From: Pedro Alves <pedro@codesourcery.com> > Date: Wed, 7 Jan 2009 21:59:29 +0000 > Cc: gdb-patches@sourceware.org, > Eli Zaretskii <eliz@gnu.org> > > Eli, is the documentation piece OK? Yes, but I have a few comments. See below. > +const char internal_problem_ask[] = "ask"; > +const char internal_problem_yes[] = "yes"; > +const char internal_problem_no[] = "no"; Don't we want these strings to be translatable? The questions we ask about what to do are. > +/* When GDB reports an internal problem (error or warning) it gives > + the user the opportunity to quit GDB and/or create a core file of > + the current debug session. This function registers a few commands > + that make it possible to specify that GDB should always or never > + quit or create a core file, without asking. The commands look > + like: > + > + maint set PROBLEM-NAME quit ask|yes|no > + maint show PROBLEM-NAME quit > + maint set PROBLEM-NAME corefile ask|yes|no > + maint show PROBLEM-NAME corefile > + > + Where PROBLEM-NAME is currently "internal-error" or > + "internal-warning". */ I'd love to have this important infrastructure documented in gdbint.texinfo. > + 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); I would lose the "an" part: this is general infrastructure, so even if all the currently known problem names fit "an", we cannot guarantee that to be so in the future. There's no need here for an article, anyway, as something like Show what GDB does when FOO is detected. sounds perfectly correct English to me. > + set_doc = xstrprintf (_("\ > +Set whether GDB should quit when an %s is detected"), > + problem->name); > + show_doc = xstrprintf (_("\ > +Show whether GDB will quit when an %s is detected"), > + problem->name); Same here. > + 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); And here. > +@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 [ask|yes|no] > +@itemx maint show internal-error quit > +@itemx maint set internal-error corefile [ask|yes|no] > +@itemx maint show internal-error corefile > +@itemx maint set internal-warning quit [ask|yes|no] > +@itemx maint show internal-warning quit > +@itemx maint set internal-warning corefile [ask|yes|no] > +@itemx maint show internal-warning corefile There's no need for listing all the possible ACTIONs here. It is enough to say @kindex maint set internal-error @kindex maint show internal-error @item maint set internal-error @var{action} [ask|yes|no] @itemx maint show internal-error @var{action} and then list all the possible values of @var{action} and explain them. As a nice side-effect, this will always make the index less cluttered. I would also add here another index entry, for those who don't remember or don't know the command's name, but are still looking for this information. How about @cindex @value{GDBN} internal error @cindex internal errors, control of @value{GDBN} behavior ? Other than that, this is fine; thanks. ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: PR7580 - Command to force abort when internal error 2009-01-09 14:25 ` Eli Zaretskii @ 2009-01-09 15:33 ` Andreas Schwab 2009-01-09 18:16 ` Eli Zaretskii 2009-01-09 18:29 ` Joel Brobecker 1 sibling, 1 reply; 21+ messages in thread From: Andreas Schwab @ 2009-01-09 15:33 UTC (permalink / raw) To: Eli Zaretskii; +Cc: Pedro Alves, brobecker, gdb-patches Eli Zaretskii <eliz@gnu.org> writes: >> + 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); > > I would lose the "an" part: this is general infrastructure, so even if > all the currently known problem names fit "an", we cannot guarantee > that to be so in the future. There's no need here for an article, > anyway, as something like > > Show what GDB does when FOO is detected. > > sounds perfectly correct English to me. In any case it is still impossible to properly translate, as it may depend on what FOO actually is. Andreas. -- Andreas Schwab, SuSE Labs, schwab@suse.de SuSE Linux Products GmbH, MaxfeldstraÃe 5, 90409 Nürnberg, Germany PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different." ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: PR7580 - Command to force abort when internal error 2009-01-09 15:33 ` Andreas Schwab @ 2009-01-09 18:16 ` Eli Zaretskii 2009-01-09 20:01 ` Andreas Schwab 0 siblings, 1 reply; 21+ messages in thread From: Eli Zaretskii @ 2009-01-09 18:16 UTC (permalink / raw) To: Andreas Schwab; +Cc: pedro, brobecker, gdb-patches > From: Andreas Schwab <schwab@suse.de> > Cc: Pedro Alves <pedro@codesourcery.com>, brobecker@adacore.com, > gdb-patches@sourceware.org > Date: Fri, 09 Jan 2009 16:33:21 +0100 > > >> + show_doc = xstrprintf (_("Show what GDB does when an %s is detected."), > >> + problem->name); > > > > I would lose the "an" part: this is general infrastructure, so even if > > all the currently known problem names fit "an", we cannot guarantee > > that to be so in the future. There's no need here for an article, > > anyway, as something like > > > > Show what GDB does when FOO is detected. > > > > sounds perfectly correct English to me. > > In any case it is still impossible to properly translate, as it may > depend on what FOO actually is. You mean the original phrase with an "an" or what I suggested? If the latter, please tell why it cannot be properly translated, because I'm probably missing something. ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: PR7580 - Command to force abort when internal error 2009-01-09 18:16 ` Eli Zaretskii @ 2009-01-09 20:01 ` Andreas Schwab 2009-01-09 20:07 ` Eli Zaretskii 0 siblings, 1 reply; 21+ messages in thread From: Andreas Schwab @ 2009-01-09 20:01 UTC (permalink / raw) To: Eli Zaretskii; +Cc: pedro, brobecker, gdb-patches Eli Zaretskii <eliz@gnu.org> writes: > You mean the original phrase with an "an" or what I suggested? Both. > If the latter, please tell why it cannot be properly translated, > because I'm probably missing something. The translation of the context depends on the particular word being substituted. Andreas. -- Andreas Schwab, SuSE Labs, schwab@suse.de SuSE Linux Products GmbH, MaxfeldstraÃe 5, 90409 Nürnberg, Germany PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different." ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: PR7580 - Command to force abort when internal error 2009-01-09 20:01 ` Andreas Schwab @ 2009-01-09 20:07 ` Eli Zaretskii 2009-01-09 20:15 ` Andreas Schwab 0 siblings, 1 reply; 21+ messages in thread From: Eli Zaretskii @ 2009-01-09 20:07 UTC (permalink / raw) To: Andreas Schwab; +Cc: pedro, brobecker, gdb-patches > From: Andreas Schwab <schwab@suse.de> > Cc: pedro@codesourcery.com, brobecker@adacore.com, > gdb-patches@sourceware.org > Date: Fri, 09 Jan 2009 21:01:00 +0100 > > Eli Zaretskii <eliz@gnu.org> writes: > > > You mean the original phrase with an "an" or what I suggested? > > Both. > > > If the latter, please tell why it cannot be properly translated, > > because I'm probably missing something. > > The translation of the context depends on the particular word being > substituted. Sorry, I still don't follow. The phrase we are talking about is translated as a whole. What is/are the problem(s) with translating "Show what GDB does when %s is detected."? ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: PR7580 - Command to force abort when internal error 2009-01-09 20:07 ` Eli Zaretskii @ 2009-01-09 20:15 ` Andreas Schwab 2009-01-09 20:26 ` Eli Zaretskii 0 siblings, 1 reply; 21+ messages in thread From: Andreas Schwab @ 2009-01-09 20:15 UTC (permalink / raw) To: Eli Zaretskii; +Cc: pedro, brobecker, gdb-patches Eli Zaretskii <eliz@gnu.org> writes: > Sorry, I still don't follow. The phrase we are talking about is > translated as a whole. What is/are the problem(s) with translating > "Show what GDB does when %s is detected."? How do you translate that properly when you don't know what %s is? Andreas. -- Andreas Schwab, SuSE Labs, schwab@suse.de SuSE Linux Products GmbH, MaxfeldstraÃe 5, 90409 Nürnberg, Germany PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different." ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: PR7580 - Command to force abort when internal error 2009-01-09 20:15 ` Andreas Schwab @ 2009-01-09 20:26 ` Eli Zaretskii 2009-01-09 21:37 ` Andreas Schwab 0 siblings, 1 reply; 21+ messages in thread From: Eli Zaretskii @ 2009-01-09 20:26 UTC (permalink / raw) To: Andreas Schwab; +Cc: pedro, brobecker, gdb-patches > From: Andreas Schwab <schwab@suse.de> > Cc: pedro@codesourcery.com, brobecker@adacore.com, > gdb-patches@sourceware.org > Date: Fri, 09 Jan 2009 21:15:34 +0100 > > Eli Zaretskii <eliz@gnu.org> writes: > > > Sorry, I still don't follow. The phrase we are talking about is > > translated as a whole. What is/are the problem(s) with translating > > "Show what GDB does when %s is detected."? > > How do you translate that properly when you don't know what %s is? I just do. Look, it doesn't help when you respond assuming that the problems you see are evident to everyone else. If you don't want to explain your concerns, then I can only conclude that they are null and void, since I see no problems with translating that phrase into any of the languages I command. ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: PR7580 - Command to force abort when internal error 2009-01-09 20:26 ` Eli Zaretskii @ 2009-01-09 21:37 ` Andreas Schwab 2009-01-10 9:04 ` Eli Zaretskii 0 siblings, 1 reply; 21+ messages in thread From: Andreas Schwab @ 2009-01-09 21:37 UTC (permalink / raw) To: Eli Zaretskii; +Cc: pedro, brobecker, gdb-patches Eli Zaretskii <eliz@gnu.org> writes: >> From: Andreas Schwab <schwab@suse.de> >> Cc: pedro@codesourcery.com, brobecker@adacore.com, >> gdb-patches@sourceware.org >> Date: Fri, 09 Jan 2009 21:15:34 +0100 >> >> Eli Zaretskii <eliz@gnu.org> writes: >> >> > Sorry, I still don't follow. The phrase we are talking about is >> > translated as a whole. What is/are the problem(s) with translating >> > "Show what GDB does when %s is detected."? >> >> How do you translate that properly when you don't know what %s is? > > I just do. How do you know which gender to use? Andreas. -- Andreas Schwab, SuSE Labs, schwab@suse.de SuSE Linux Products GmbH, MaxfeldstraÃe 5, 90409 Nürnberg, Germany PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different." ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: PR7580 - Command to force abort when internal error 2009-01-09 21:37 ` Andreas Schwab @ 2009-01-10 9:04 ` Eli Zaretskii 2009-01-25 23:19 ` Pedro Alves 0 siblings, 1 reply; 21+ messages in thread From: Eli Zaretskii @ 2009-01-10 9:04 UTC (permalink / raw) To: Andreas Schwab; +Cc: pedro, brobecker, gdb-patches > From: Andreas Schwab <schwab@suse.de> > Cc: pedro@codesourcery.com, brobecker@adacore.com, > gdb-patches@sourceware.org > Date: Fri, 09 Jan 2009 22:37:17 +0100 > > How do you know which gender to use? In every language I know, there's some way of saying this in a gender-neutral way. But if you can suggest how to rephrase this to avoid this particular problem, please do. ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: PR7580 - Command to force abort when internal error 2009-01-10 9:04 ` Eli Zaretskii @ 2009-01-25 23:19 ` Pedro Alves 2009-01-26 3:53 ` Eli Zaretskii 0 siblings, 1 reply; 21+ messages in thread From: Pedro Alves @ 2009-01-25 23:19 UTC (permalink / raw) To: gdb-patches, Eli Zaretskii; +Cc: Andreas Schwab, brobecker [-- Attachment #1: Type: text/plain, Size: 1282 bytes --] Hi guys, Sorry, it seems I dropped the ball on this. I'm not sure if we reached a consensus or not, but I've tried to address your comments in this new version. I've dropped the "an" article from GDB's help strings, as Eli suggested. On Friday 09 January 2009 14:25:29, Eli Zaretskii wrote: > There's no need for listing all the possible ACTIONs here. It is > enough to say > > @kindex maint set internal-error > @kindex maint show internal-error > @item maint set internal-error @var{action} [ask|yes|no] > @itemx maint show internal-error @var{action} > > and then list all the possible values of @var{action} and explain > them. As a nice side-effect, this will always make the index less > cluttered. > > I would also add here another index entry, for those who don't > remember or don't know the command's name, but are still looking for > this information. How about > > @cindex @value{GDBN} internal error > @cindex internal errors, control of @value{GDBN} behavior > > ? Thanks, I tried to address this one too. There's also internal-warning in the mix, but we do get less clutter. I didn't think we'd want a @var internal-error|warning --- too many indirections are not nice in documentation, IMHO. What do you think of this version? -- Pedro Alves [-- Attachment #2: pr7580.diff --] [-- Type: text/x-diff, Size: 9569 bytes --] gdb/ 2009-01-25 Pedro Alves <pedro@codesourcery.com> Add "maint set|show internal-error|internal-warning quit|corefile ask|yes|no" commands. PR gdb/7580: * utils.c (internal_problem_ask, internal_problem_yes) (internal_problem_no, internal_problem_modes): New. (struct internal_problem): Remove FIXME. Make should_quit and should_dump_core types to char *. (internal_vproblem, internal_error_problem) (internal_warning_problem): Adjust. (set_internal_problem_cmd, show_internal_problem_cmd): New dummy functions. (add_internal_problem_command): New. (_initialize_utils): New. gdb/doc/ 2009-01-25 Pedro Alves <pedro@codesourcery.com> PR gdb/7580: * gdb.texinfo (Maintenance Commands): Document "maint set|show internal-error|internal-warning quit|corefile ask|yes|no". --- gdb/doc/gdb.texinfo | 27 ++++++++ gdb/utils.c | 166 ++++++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 162 insertions(+), 31 deletions(-) Index: src/gdb/utils.c =================================================================== --- src.orig/gdb/utils.c 2009-01-14 13:37:58.000000000 +0000 +++ src/gdb/utils.c 2009-01-25 22:43:28.000000000 +0000 @@ -825,6 +825,21 @@ error_stream (struct ui_file *stream) error (("%s"), message); } +/* Allow the user to configure the debugger behavior with respect to + what to do when an internal problem is detected. */ + +const char internal_problem_ask[] = "ask"; +const char internal_problem_yes[] = "yes"; +const char internal_problem_no[] = "no"; +static const char *internal_problem_modes[] = +{ + internal_problem_ask, + internal_problem_yes, + internal_problem_no, + NULL +}; +static const char *internal_problem_mode = internal_problem_ask; + /* Print a message reporting an internal error/warning. Ask the user if they want to continue, dump core, or just exit. Return something to indicate a quit. */ @@ -832,10 +847,8 @@ 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; + const char *should_quit; + const char *should_dump_core; }; /* Report a problem, internal to GDB, to the user. Once the problem @@ -896,42 +909,33 @@ further debugging may prove unreliable." make_cleanup (xfree, reason); } - switch (problem->should_quit) + if (problem->should_quit == internal_problem_ask) { - case AUTO_BOOLEAN_AUTO: /* Default (yes/batch case) is to quit GDB. When in batch mode - this lessens the likelhood of GDB going into an infinate - loop. */ + this lessens the likelihood of GDB going into an infinite + loop. */ quit_p = query (_("%s\nQuit this debugging session? "), reason); - break; - case AUTO_BOOLEAN_TRUE: - quit_p = 1; - break; - case AUTO_BOOLEAN_FALSE: - quit_p = 0; - break; - default: - internal_error (__FILE__, __LINE__, _("bad switch")); } + else if (problem->should_quit == internal_problem_yes) + quit_p = 1; + else if (problem->should_quit == internal_problem_no) + quit_p = 0; + else + internal_error (__FILE__, __LINE__, _("bad switch")); - switch (problem->should_dump_core) + if (problem->should_dump_core == internal_problem_ask) { - case AUTO_BOOLEAN_AUTO: /* 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 (_("%s\nCreate a core file of GDB? "), reason); - break; - break; - case AUTO_BOOLEAN_TRUE: - dump_core_p = 1; - break; - case AUTO_BOOLEAN_FALSE: - dump_core_p = 0; - break; - default: - internal_error (__FILE__, __LINE__, _("bad switch")); } + else if (problem->should_dump_core == internal_problem_yes) + dump_core_p = 1; + else if (problem->should_dump_core == internal_problem_no) + dump_core_p = 0; + else + internal_error (__FILE__, __LINE__, _("bad switch")); if (quit_p) { @@ -955,7 +959,7 @@ further debugging may prove unreliable." } static struct internal_problem internal_error_problem = { - "internal-error", AUTO_BOOLEAN_AUTO, AUTO_BOOLEAN_AUTO + "internal-error", internal_problem_ask, internal_problem_ask }; NORETURN void @@ -975,7 +979,7 @@ internal_error (const char *file, int li } static struct internal_problem internal_warning_problem = { - "internal-warning", AUTO_BOOLEAN_AUTO, AUTO_BOOLEAN_AUTO + "internal-warning", internal_problem_ask, internal_problem_ask }; void @@ -993,6 +997,99 @@ internal_warning (const char *file, int va_end (ap); } +/* Dummy functions to keep add_prefix_cmd happy. */ + +static void +set_internal_problem_cmd (char *args, int from_tty) +{ +} + +static void +show_internal_problem_cmd (char *args, int from_tty) +{ +} + +/* When GDB reports an internal problem (error or warning) it gives + the user the opportunity to quit GDB and/or create a core file of + the current debug session. This function registers a few commands + that make it possible to specify that GDB should always or never + quit or create a core file, without asking. The commands look + like: + + maint set PROBLEM-NAME quit ask|yes|no + maint show PROBLEM-NAME quit + maint set PROBLEM-NAME corefile ask|yes|no + maint show PROBLEM-NAME corefile + + Where PROBLEM-NAME is currently "internal-error" or + "internal-warning". */ + +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 %s is detected."), + problem->name); + + show_doc = xstrprintf (_("Show what GDB does when %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 will quit when an %s is detected"), + problem->name); + add_setshow_enum_cmd ("quit", class_maintenance, + internal_problem_modes, + &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 %s is detected"), + problem->name); + show_doc = xstrprintf (_("\ +Show whether GDB will create a core file of GDB when %s is detected"), + problem->name); + add_setshow_enum_cmd ("corefile", class_maintenance, + internal_problem_modes, + &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. */ @@ -3443,3 +3540,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 2009-01-25 21:03:20.000000000 +0000 +++ src/gdb/doc/gdb.texinfo 2009-01-25 23:08:58.000000000 +0000 @@ -24798,6 +24798,33 @@ Create a core file? (y or n) @kbd{n} (@value{GDBP}) @end smallexample +@cindex @value{GDBN} internal error +@cindex internal errors, control of @value{GDBN} behavior + +@kindex maint set internal-error +@kindex maint show internal-error +@kindex maint set internal-warning +@kindex maint show internal-warning +@item maint set internal-error @var{action} [ask|yes|no] +@itemx maint show internal-error @var{action} +@itemx maint set internal-warning @var{action} [ask|yes|no] +@itemx maint show internal-warning @var{action} +When @value{GDBN} reports an internal problem (error or warning) it +gives the user the opportunity to both quit @value{GDBN} and create a +core file of the current @value{GDBN} session. These commands let you +override the default behaviour for each particular @var{action}, +described in the table below. + +@table @samp +@item quit +You can specify that @value{GDBN} should always (yes) or never (no) +quit. The default is to ask the user what to do. + +@item corefile +You can specify that @value{GDBN} should always (yes) or never (no) +create a core file. The default is to ask the user what to do. +@end table + @kindex maint packet @item maint packet @var{text} If @value{GDBN} is talking to an inferior via the serial protocol, ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: PR7580 - Command to force abort when internal error 2009-01-25 23:19 ` Pedro Alves @ 2009-01-26 3:53 ` Eli Zaretskii 2009-01-26 16:27 ` Pedro Alves 0 siblings, 1 reply; 21+ messages in thread From: Eli Zaretskii @ 2009-01-26 3:53 UTC (permalink / raw) To: Pedro Alves; +Cc: gdb-patches, schwab, brobecker > From: Pedro Alves <pedro@codesourcery.com> > Date: Sun, 25 Jan 2009 23:20:13 +0000 > Cc: Andreas Schwab <schwab@suse.de>, > brobecker@adacore.com > > What do you think of this version? Fine with me. ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: PR7580 - Command to force abort when internal error 2009-01-26 3:53 ` Eli Zaretskii @ 2009-01-26 16:27 ` Pedro Alves 0 siblings, 0 replies; 21+ messages in thread From: Pedro Alves @ 2009-01-26 16:27 UTC (permalink / raw) To: gdb-patches On Monday 26 January 2009 03:52:32, Eli Zaretskii wrote: > Fine with me. I've checked this one in then. Thanks. -- Pedro Alves ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: PR7580 - Command to force abort when internal error 2009-01-09 14:25 ` Eli Zaretskii 2009-01-09 15:33 ` Andreas Schwab @ 2009-01-09 18:29 ` Joel Brobecker 2009-01-09 20:11 ` Eli Zaretskii 2009-01-09 20:36 ` Pedro Alves 1 sibling, 2 replies; 21+ messages in thread From: Joel Brobecker @ 2009-01-09 18:29 UTC (permalink / raw) To: Eli Zaretskii; +Cc: Pedro Alves, gdb-patches > > +const char internal_problem_ask[] = "ask"; > > +const char internal_problem_yes[] = "yes"; > > +const char internal_problem_no[] = "no"; > > Don't we want these strings to be translatable? The questions we ask > about what to do are. I would say no. These are arguments used in a command - if we start translating pieces of GDB commands, I think it's going to make it harder for us to document the command, as well harder for the user to use it. For instance, some of our machines in the Paris office have system configuration files that force the locale to "fr". So, on these machines that I use only very seldomly, having to remember to use "oui" instead of "yes" (whereas the rest of the comment isn't translated) would certainly cause a certain amount of grief on my end. It also becomes harder to share some commands between users because every has to be careful of the locale... -- Joel ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: PR7580 - Command to force abort when internal error 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 1 sibling, 1 reply; 21+ messages in thread From: Eli Zaretskii @ 2009-01-09 20:11 UTC (permalink / raw) To: Joel Brobecker; +Cc: pedro, gdb-patches > Date: Fri, 9 Jan 2009 22:29:14 +0400 > From: Joel Brobecker <brobecker@adacore.com> > Cc: Pedro Alves <pedro@codesourcery.com>, gdb-patches@sourceware.org > > > > +const char internal_problem_ask[] = "ask"; > > > +const char internal_problem_yes[] = "yes"; > > > +const char internal_problem_no[] = "no"; > > > > Don't we want these strings to be translatable? The questions we ask > > about what to do are. > > I would say no. These are arguments used in a command Then why use a string for that purpose? Someone, some day might be tempted to use that string in some prompt or message, at which point we lose. ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: PR7580 - Command to force abort when internal error 2009-01-09 20:11 ` Eli Zaretskii @ 2009-01-10 6:34 ` Daniel Jacobowitz 0 siblings, 0 replies; 21+ messages in thread From: Daniel Jacobowitz @ 2009-01-10 6:34 UTC (permalink / raw) To: Eli Zaretskii; +Cc: Joel Brobecker, pedro, gdb-patches On Fri, Jan 09, 2009 at 10:10:55PM +0200, Eli Zaretskii wrote: > > Date: Fri, 9 Jan 2009 22:29:14 +0400 > > From: Joel Brobecker <brobecker@adacore.com> > > Cc: Pedro Alves <pedro@codesourcery.com>, gdb-patches@sourceware.org > > > > > > +const char internal_problem_ask[] = "ask"; > > > > +const char internal_problem_yes[] = "yes"; > > > > +const char internal_problem_no[] = "no"; > > > > > > Don't we want these strings to be translatable? The questions we ask > > > about what to do are. > > > > I would say no. These are arguments used in a command > > Then why use a string for that purpose? Someone, some day might be > tempted to use that string in some prompt or message, at which point > we lose. That's how all enum commands in GDB are implemented at present; see e.g. always_inserted_enums. -- Daniel Jacobowitz CodeSourcery ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: PR7580 - Command to force abort when internal error 2009-01-09 18:29 ` Joel Brobecker 2009-01-09 20:11 ` Eli Zaretskii @ 2009-01-09 20:36 ` Pedro Alves 1 sibling, 0 replies; 21+ messages in thread From: Pedro Alves @ 2009-01-09 20:36 UTC (permalink / raw) To: gdb-patches; +Cc: Joel Brobecker, Eli Zaretskii On Friday 09 January 2009 18:29:14, Joel Brobecker wrote: > > > +const char internal_problem_ask[] = "ask"; > > > +const char internal_problem_yes[] = "yes"; > > > +const char internal_problem_no[] = "no"; > > > > Don't we want these strings to be translatable? The questions we ask > > about what to do are. > > I would say no. These are arguments used in a command - if we start > translating pieces of GDB commands, I think it's going to make it harder > for us to document the command, as well harder for the user to use it. > For instance, some of our machines in the Paris office have system > configuration files that force the locale to "fr". So, on these machines > that I use only very seldomly, having to remember to use "oui" instead > of "yes" (whereas the rest of the comment isn't translated) would > certainly cause a certain amount of grief on my end. It also becomes > harder to share some commands between users because every has to be > careful of the locale... I was going to say pretty much the same. The whole command in this case is "maintenance set internal-error on". There doesn't seem to be any gain in just translating the last word of it, and translating all of it, is something I hope we're not aiming to do. -- Pedro Alves ^ permalink raw reply [flat|nested] 21+ messages in thread
end of thread, other threads:[~2009-01-26 16:27 UTC | newest] Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2008-12-29 3:35 PR7580 - Command to force abort when internal error Pedro Alves 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
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox