public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [RFA] target record_core -> target record-core?
@ 2010-04-19  6:47 Doug Evans
  2010-04-19 18:01 ` Michael Snyder
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Doug Evans @ 2010-04-19  6:47 UTC (permalink / raw)
  To: msnyder, gdb-patches

I realize this is a nit but is it possible to rename
target record_core to target record-core?
Or is it too late ...

All other targets (that I know of) use dashes in shortname, and having
to remember which use dashes and which use underscores is, umm, blechy.
[Unless we have and enforce a convention, it can only get worse,
so might as well establish one now - if it doesn't exist already.]

2010-04-18  Doug Evans  <dje@sebabeach.org>

	* record.c (init_record_core_ops): Rename record_core to record_core.

Index: record.c
===================================================================
RCS file: /cvs/src/src/gdb/record.c,v
retrieving revision 1.44
diff -u -p -r1.44 record.c
--- record.c	8 Mar 2010 13:34:38 -0000	1.44
+++ record.c	19 Apr 2010 06:44:51 -0000
@@ -1863,7 +1863,7 @@ record_core_has_execution (struct target
 static void
 init_record_core_ops (void)
 {
-  record_core_ops.to_shortname = "record_core";
+  record_core_ops.to_shortname = "record-core";
   record_core_ops.to_longname = "Process record and replay target";
   record_core_ops.to_doc =
     "Log program while executing and replay execution from log.";

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

* Re: [RFA] target record_core -> target record-core?
  2010-04-19  6:47 [RFA] target record_core -> target record-core? Doug Evans
@ 2010-04-19 18:01 ` Michael Snyder
  2010-04-20  9:56 ` Pedro Alves
  2010-04-20 18:06 ` Tom Tromey
  2 siblings, 0 replies; 8+ messages in thread
From: Michael Snyder @ 2010-04-19 18:01 UTC (permalink / raw)
  To: Doug Evans; +Cc: gdb-patches, Hui Zhu

Doug Evans wrote:
> I realize this is a nit but is it possible to rename
> target record_core to target record-core?
> Or is it too late ...
> 
> All other targets (that I know of) use dashes in shortname, and having
> to remember which use dashes and which use underscores is, umm, blechy.
> [Unless we have and enforce a convention, it can only get worse,
> so might as well establish one now - if it doesn't exist already.]

I don't think anybody uses it, so this should be ok.

Hui?

> 
> 2010-04-18  Doug Evans  <dje@sebabeach.org>
> 
> 	* record.c (init_record_core_ops): Rename record_core to record_core.
> 
> Index: record.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/record.c,v
> retrieving revision 1.44
> diff -u -p -r1.44 record.c
> --- record.c	8 Mar 2010 13:34:38 -0000	1.44
> +++ record.c	19 Apr 2010 06:44:51 -0000
> @@ -1863,7 +1863,7 @@ record_core_has_execution (struct target
>  static void
>  init_record_core_ops (void)
>  {
> -  record_core_ops.to_shortname = "record_core";
> +  record_core_ops.to_shortname = "record-core";
>    record_core_ops.to_longname = "Process record and replay target";
>    record_core_ops.to_doc =
>      "Log program while executing and replay execution from log.";

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

* Re: [RFA] target record_core -> target record-core?
  2010-04-19  6:47 [RFA] target record_core -> target record-core? Doug Evans
  2010-04-19 18:01 ` Michael Snyder
@ 2010-04-20  9:56 ` Pedro Alves
  2010-04-20 12:24   ` Hui Zhu
  2010-04-20 18:06 ` Tom Tromey
  2 siblings, 1 reply; 8+ messages in thread
From: Pedro Alves @ 2010-04-20  9:56 UTC (permalink / raw)
  To: gdb-patches; +Cc: Doug Evans, msnyder

FWIW, I agree with this,

On Monday 19 April 2010 07:47:17, Doug Evans wrote:
> 2010-04-18  Doug Evans  <dje@sebabeach.org>
> 
>         * record.c (init_record_core_ops): Rename record_core to record_core.

though the log entry mentions a nop.  :-)

-- 
Pedro Alves

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

* Re: [RFA] target record_core -> target record-core?
  2010-04-20  9:56 ` Pedro Alves
@ 2010-04-20 12:24   ` Hui Zhu
  0 siblings, 0 replies; 8+ messages in thread
From: Hui Zhu @ 2010-04-20 12:24 UTC (permalink / raw)
  To: Pedro Alves, Doug Evans, msnyder; +Cc: gdb-patches

On Tue, Apr 20, 2010 at 17:56, Pedro Alves <pedro@codesourcery.com> wrote:
>
> FWIW, I agree with this,
>
> On Monday 19 April 2010 07:47:17, Doug Evans wrote:
> > 2010-04-18  Doug Evans  <dje@sebabeach.org>
> >
> >         * record.c (init_record_core_ops): Rename record_core to record_core.
>
> though the log entry mentions a nop.  :-)
>
> --
> Pedro Alves

Thanks guys,  If it doesn't affect the testsuite (Sorry I didn't have
gdb close to me), I agree with this patch.

Regards,
Hui

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

* Re: [RFA] target record_core -> target record-core?
  2010-04-19  6:47 [RFA] target record_core -> target record-core? Doug Evans
  2010-04-19 18:01 ` Michael Snyder
  2010-04-20  9:56 ` Pedro Alves
@ 2010-04-20 18:06 ` Tom Tromey
  2010-04-20 18:11   ` Joel Brobecker
  2 siblings, 1 reply; 8+ messages in thread
From: Tom Tromey @ 2010-04-20 18:06 UTC (permalink / raw)
  To: Doug Evans; +Cc: msnyder, gdb-patches

>>>>> "Doug" == Doug Evans <dje@sebabeach.org> writes:

Doug> I realize this is a nit but is it possible to rename
Doug> target record_core to target record-core?
Doug> Or is it too late ...

Thanks for catching this.

Doug> All other targets (that I know of) use dashes in shortname, and having
Doug> to remember which use dashes and which use underscores is, umm, blechy.

Additionally, I prefer dashes because they are simpler to type.

I think we can retroactively fix mistakes here by adding deprecated
aliases.

One more thing I've wanted is also making it so deprecated commands
don't show up in completion when there is a non-deprecated completion
available.  Any comments on that?

Tom

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

* Re: [RFA] target record_core -> target record-core?
  2010-04-20 18:06 ` Tom Tromey
@ 2010-04-20 18:11   ` Joel Brobecker
  2010-04-23 20:40     ` Patch: completion -vs- deprecated commands (Was: [RFA] target record_core -> target record-core?) Tom Tromey
  0 siblings, 1 reply; 8+ messages in thread
From: Joel Brobecker @ 2010-04-20 18:11 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Doug Evans, msnyder, gdb-patches

> One more thing I've wanted is also making it so deprecated commands
> don't show up in completion when there is a non-deprecated completion
> available.  Any comments on that?

I think that would be useful indeed.

-- 
Joel

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

* Patch: completion -vs- deprecated commands (Was: [RFA] target record_core -> target record-core?)
  2010-04-20 18:11   ` Joel Brobecker
@ 2010-04-23 20:40     ` Tom Tromey
  2010-04-26 18:37       ` Patch: completion -vs- deprecated commands Tom Tromey
  0 siblings, 1 reply; 8+ messages in thread
From: Tom Tromey @ 2010-04-23 20:40 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: Doug Evans, msnyder, gdb-patches

Tom> One more thing I've wanted is also making it so deprecated commands
Tom> don't show up in completion when there is a non-deprecated completion
Tom> available.  Any comments on that?

Joel> I think that would be useful indeed.

Here's the patch.  It looks big because I had to reindent a loop.

I plan to commit this early next week, barring objections or comments.

Built and regtested on x86-64 (compile farm).
New tests included.

Tom

2010-04-23  Tom Tromey  <tromey@redhat.com>

	* cli/cli-decode.c (complete_on_cmdlist): Make two passes over the
	command list.

2010-04-23  Tom Tromey  <tromey@redhat.com>

	* gdb.base/completion.exp: Add tests for completion and deprecated
	commands.

Index: cli/cli-decode.c
===================================================================
RCS file: /cvs/src/src/gdb/cli/cli-decode.c,v
retrieving revision 1.86
diff -u -r1.86 cli-decode.c
--- cli/cli-decode.c	1 Jan 2010 07:31:46 -0000	1.86
+++ cli/cli-decode.c	23 Apr 2010 20:17:41 -0000
@@ -1597,43 +1597,65 @@
   int sizeof_matchlist;
   int matches;
   int textlen = strlen (text);
+  int pass;
+  int saw_deprecated_match = 0;
 
   sizeof_matchlist = 10;
   matchlist = (char **) xmalloc (sizeof_matchlist * sizeof (char *));
   matches = 0;
 
-  for (ptr = list; ptr; ptr = ptr->next)
-    if (!strncmp (ptr->name, text, textlen)
-	&& !ptr->abbrev_flag
-	&& (ptr->func
-	    || ptr->prefixlist))
-      {
-	if (matches == sizeof_matchlist)
-	  {
-	    sizeof_matchlist *= 2;
-	    matchlist = (char **) xrealloc ((char *) matchlist,
-					    (sizeof_matchlist
-					     * sizeof (char *)));
-	  }
-
-	matchlist[matches] = (char *)
-	  xmalloc (strlen (word) + strlen (ptr->name) + 1);
-	if (word == text)
-	  strcpy (matchlist[matches], ptr->name);
-	else if (word > text)
-	  {
-	    /* Return some portion of ptr->name.  */
-	    strcpy (matchlist[matches], ptr->name + (word - text));
-	  }
-	else
-	  {
-	    /* Return some of text plus ptr->name.  */
-	    strncpy (matchlist[matches], word, text - word);
-	    matchlist[matches][text - word] = '\0';
-	    strcat (matchlist[matches], ptr->name);
-	  }
-	++matches;
-      }
+  /* We do one or two passes.  In the first pass, we skip deprecated
+     commands.  If we see no matching commands in the first pass, and
+     if we did happen to see a matching deprecated command, we do
+     another loop to collect those.  */
+  for (pass = 0; matches == 0 && pass < 2; ++pass)
+    {
+      for (ptr = list; ptr; ptr = ptr->next)
+	if (!strncmp (ptr->name, text, textlen)
+	    && !ptr->abbrev_flag
+	    && (ptr->func
+		|| ptr->prefixlist))
+	  {
+	    if (pass == 0)
+	      {
+		if ((ptr->flags & CMD_DEPRECATED) != 0)
+		  {
+		    saw_deprecated_match = 1;
+		    continue;
+		  }
+	      }
+
+	    if (matches == sizeof_matchlist)
+	      {
+		sizeof_matchlist *= 2;
+		matchlist = (char **) xrealloc ((char *) matchlist,
+						(sizeof_matchlist
+						 * sizeof (char *)));
+	      }
+
+	    matchlist[matches] = (char *)
+	      xmalloc (strlen (word) + strlen (ptr->name) + 1);
+	    if (word == text)
+	      strcpy (matchlist[matches], ptr->name);
+	    else if (word > text)
+	      {
+		/* Return some portion of ptr->name.  */
+		strcpy (matchlist[matches], ptr->name + (word - text));
+	      }
+	    else
+	      {
+		/* Return some of text plus ptr->name.  */
+		strncpy (matchlist[matches], word, text - word);
+		matchlist[matches][text - word] = '\0';
+		strcat (matchlist[matches], ptr->name);
+	      }
+	    ++matches;
+	  }
+      /* If we saw no matching deprecated commands in the first pass,
+	 just bail out.  */
+      if (!saw_deprecated_match)
+	break;
+    }
 
   if (matches == 0)
     {
Index: testsuite/gdb.base/completion.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/completion.exp,v
retrieving revision 1.44
diff -u -r1.44 completion.exp
--- testsuite/gdb.base/completion.exp	4 Apr 2010 23:47:16 -0000	1.44
+++ testsuite/gdb.base/completion.exp	23 Apr 2010 20:17:43 -0000
@@ -847,6 +847,12 @@
         eof             { fail "(eof) Completing non-existing component #2" }
         }
 
+# If there is a non-deprecated completion, it should be returned.
+gdb_test "complete sav" "save" "test non-deprecated completion"
+# If there is only a deprecated completion, then it should be returned.
+gdb_test "complete save-t" "save-tracepoints" "test deprecated completion"
+
+
 # Restore globals modified in this test...
 set timeout $oldtimeout1
 

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

* Re: Patch: completion -vs- deprecated commands
  2010-04-23 20:40     ` Patch: completion -vs- deprecated commands (Was: [RFA] target record_core -> target record-core?) Tom Tromey
@ 2010-04-26 18:37       ` Tom Tromey
  0 siblings, 0 replies; 8+ messages in thread
From: Tom Tromey @ 2010-04-26 18:37 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: Doug Evans, msnyder, gdb-patches

>>>>> "Tom" == Tom Tromey <tromey@redhat.com> writes:

Tom> Here's the patch.  It looks big because I had to reindent a loop.

Tom> I plan to commit this early next week, barring objections or comments.

I've checked this in.

Tom

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

end of thread, other threads:[~2010-04-26 18:37 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-19  6:47 [RFA] target record_core -> target record-core? Doug Evans
2010-04-19 18:01 ` Michael Snyder
2010-04-20  9:56 ` Pedro Alves
2010-04-20 12:24   ` Hui Zhu
2010-04-20 18:06 ` Tom Tromey
2010-04-20 18:11   ` Joel Brobecker
2010-04-23 20:40     ` Patch: completion -vs- deprecated commands (Was: [RFA] target record_core -> target record-core?) Tom Tromey
2010-04-26 18:37       ` Patch: completion -vs- deprecated commands Tom Tromey

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