Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Yao Qi <yao@codesourcery.com>
To: <gdb-patches@sourceware.org>
Subject: [PATCH] use add_setshow_auto_boolean_cmd for 'always-inserted' and 'displaced-stepping'.
Date: Tue, 26 Jun 2012 15:02:00 -0000	[thread overview]
Message-ID: <1340722929-11666-1-git-send-email-yao@codesourcery.com> (raw)

Hi,
I happen to see that command 'always-inserted' and 'displaced-stepping' are added
by add_setshow_enum_cmd, however, it is more simple to use add_setshow_auto_boolean_cmd
for them.  This is what this patch tries to do.

It is obvious, and I'll check it in in two days.

gdb:

2012-06-26  Yao Qi  <yao@codesourcery.com>

	* breakpoint.c: Removed always_inserted_auto, always_inserted_on,
	always_inserted_off, and always_inserted_enums.
	Change always_inserted_mode's type to 'enum auto_boolean'.
	(show_always_inserted_mode, breakpoint_always_inserted_mode): Update
	callers.
	(_initialize_breakpoint): Call add_setshow_auto_boolean_cmd instead
	of add_setshow_enum_cmd.
	* infrun.c: Remove can_use_displaced_stepping_auto,
	can_use_displaced_stepping_on, can_use_displaced_stepping_off, and
	can_use_displaced_stepping_enum.
	Change can_use_displaced_stepping's type to 'enum auto_boolean'.
	(show_can_use_displaced_stepping, use_displaced_stepping): Update callers.
	(_initialize_infrun): Call add_setshow_auto_boolean_cmd instead of
	add_setshow_enum_cmd.
---
 gdb/breakpoint.c |   30 +++++++++++-------------------
 gdb/infrun.c     |   34 +++++++++-------------------------
 2 files changed, 20 insertions(+), 44 deletions(-)

diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 12ab271..227be14 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -387,21 +387,13 @@ show_automatic_hardware_breakpoints (struct ui_file *file, int from_tty,
    will remove breakpoints upon stop.  If auto, GDB will behave as ON
    if in non-stop mode, and as OFF if all-stop mode.*/
 
-static const char always_inserted_auto[] = "auto";
-static const char always_inserted_on[] = "on";
-static const char always_inserted_off[] = "off";
-static const char *const always_inserted_enums[] = {
-  always_inserted_auto,
-  always_inserted_off,
-  always_inserted_on,
-  NULL
-};
-static const char *always_inserted_mode = always_inserted_auto;
+static enum auto_boolean always_inserted_mode = AUTO_BOOLEAN_AUTO;
+
 static void
 show_always_inserted_mode (struct ui_file *file, int from_tty,
 		     struct cmd_list_element *c, const char *value)
 {
-  if (always_inserted_mode == always_inserted_auto)
+  if (always_inserted_mode == AUTO_BOOLEAN_AUTO)
     fprintf_filtered (file,
 		      _("Always inserted breakpoint "
 			"mode is %s (currently %s).\n"),
@@ -415,8 +407,8 @@ show_always_inserted_mode (struct ui_file *file, int from_tty,
 int
 breakpoints_always_inserted_mode (void)
 {
-  return (always_inserted_mode == always_inserted_on
-	  || (always_inserted_mode == always_inserted_auto && non_stop));
+  return (always_inserted_mode == AUTO_BOOLEAN_TRUE
+	  || (always_inserted_mode == AUTO_BOOLEAN_AUTO && non_stop));
 }
 
 static const char condition_evaluation_both[] = "host or target";
@@ -16178,8 +16170,8 @@ a warning will be emitted for such breakpoints."),
 			   &breakpoint_set_cmdlist,
 			   &breakpoint_show_cmdlist);
 
-  add_setshow_enum_cmd ("always-inserted", class_support,
-			always_inserted_enums, &always_inserted_mode, _("\
+  add_setshow_auto_boolean_cmd ("always-inserted", class_support,
+				&always_inserted_mode, _("\
 Set mode for inserting breakpoints."), _("\
 Show mode for inserting breakpoints."), _("\
 When this mode is off, breakpoints are inserted in inferior when it is\n\
@@ -16190,10 +16182,10 @@ the behaviour depends on the non-stop setting (see help set non-stop).\n\
 In this case, if gdb is controlling the inferior in non-stop mode, gdb\n\
 behaves as if always-inserted mode is on; if gdb is controlling the\n\
 inferior in all-stop mode, gdb behaves as if always-inserted mode is off."),
-			   NULL,
-			   &show_always_inserted_mode,
-			   &breakpoint_set_cmdlist,
-			   &breakpoint_show_cmdlist);
+				NULL,
+				&show_always_inserted_mode,
+				&breakpoint_set_cmdlist,
+				&breakpoint_show_cmdlist);
 
   add_setshow_enum_cmd ("condition-evaluation", class_breakpoint,
 			condition_evaluation_enums,
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 53db335..b5e7d58 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -1185,19 +1185,6 @@ infrun_inferior_exit (struct inferior *inf)
   remove_displaced_stepping_state (inf->pid);
 }
 
-/* Enum strings for "set|show displaced-stepping".  */
-
-static const char can_use_displaced_stepping_auto[] = "auto";
-static const char can_use_displaced_stepping_on[] = "on";
-static const char can_use_displaced_stepping_off[] = "off";
-static const char *const can_use_displaced_stepping_enum[] =
-{
-  can_use_displaced_stepping_auto,
-  can_use_displaced_stepping_on,
-  can_use_displaced_stepping_off,
-  NULL,
-};
-
 /* If ON, and the architecture supports it, GDB will use displaced
    stepping to step over breakpoints.  If OFF, or if the architecture
    doesn't support it, GDB will instead use the traditional
@@ -1206,15 +1193,14 @@ static const char *const can_use_displaced_stepping_enum[] =
    which of all-stop or non-stop mode is active --- displaced stepping
    in non-stop mode; hold-and-step in all-stop mode.  */
 
-static const char *can_use_displaced_stepping =
-  can_use_displaced_stepping_auto;
+static enum auto_boolean can_use_displaced_stepping = AUTO_BOOLEAN_AUTO;
 
 static void
 show_can_use_displaced_stepping (struct ui_file *file, int from_tty,
 				 struct cmd_list_element *c,
 				 const char *value)
 {
-  if (can_use_displaced_stepping == can_use_displaced_stepping_auto)
+  if (can_use_displaced_stepping == AUTO_BOOLEAN_AUTO)
     fprintf_filtered (file,
 		      _("Debugger's willingness to use displaced stepping "
 			"to step over breakpoints is %s (currently %s).\n"),
@@ -1231,9 +1217,8 @@ show_can_use_displaced_stepping (struct ui_file *file, int from_tty,
 static int
 use_displaced_stepping (struct gdbarch *gdbarch)
 {
-  return (((can_use_displaced_stepping == can_use_displaced_stepping_auto
-	    && non_stop)
-	   || can_use_displaced_stepping == can_use_displaced_stepping_on)
+  return (((can_use_displaced_stepping == AUTO_BOOLEAN_AUTO && non_stop)
+	   || can_use_displaced_stepping == AUTO_BOOLEAN_TRUE)
 	  && gdbarch_displaced_step_copy_insn_p (gdbarch)
 	  && !RECORD_IS_USED);
 }
@@ -7296,9 +7281,8 @@ function is skipped and the step command stops at a different source line."),
 			   show_step_stop_if_no_debug,
 			   &setlist, &showlist);
 
-  add_setshow_enum_cmd ("displaced-stepping", class_run,
-			can_use_displaced_stepping_enum,
-			&can_use_displaced_stepping, _("\
+  add_setshow_auto_boolean_cmd ("displaced-stepping", class_run,
+				&can_use_displaced_stepping, _("\
 Set debugger's willingness to use displaced stepping."), _("\
 Show debugger's willingness to use displaced stepping."), _("\
 If on, gdb will use displaced stepping to step over breakpoints if it is\n\
@@ -7307,9 +7291,9 @@ stepping to step over breakpoints, even if such is supported by the target\n\
 architecture.  If auto (which is the default), gdb will use displaced stepping\n\
 if the target architecture supports it and non-stop mode is active, but will not\n\
 use it in all-stop mode (see help set non-stop)."),
-			NULL,
-			show_can_use_displaced_stepping,
-			&setlist, &showlist);
+				NULL,
+				show_can_use_displaced_stepping,
+				&setlist, &showlist);
 
   add_setshow_enum_cmd ("exec-direction", class_run, exec_direction_names,
 			&exec_direction, _("Set direction of execution.\n\
-- 
1.7.7.6


             reply	other threads:[~2012-06-26 15:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-26 15:02 Yao Qi [this message]
2012-06-26 16:48 ` Tom Tromey

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=1340722929-11666-1-git-send-email-yao@codesourcery.com \
    --to=yao@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