Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* RFC: completion for "set cp-abi"
@ 2013-01-08 16:42 Tom Tromey
  2013-01-17 16:25 ` Tom Tromey
  0 siblings, 1 reply; 4+ messages in thread
From: Tom Tromey @ 2013-01-08 16:42 UTC (permalink / raw)
  To: gdb-patches

This patch adds a completion function for "set cp-abi".

Built and regtested on x86-64 Fedora 16.
New test case included.

Tom

	* cp-abi.c (cp_abi_completer): New function.
	(_initialize_cp_abi): Set completer for "set cp-abi".

	* gdb.base/completion.exp: Add "set cp-abi" completion test.
---
 gdb/cp-abi.c                          |   28 ++++++++++++++++++++++++++--
 gdb/testsuite/gdb.base/completion.exp |    3 +++
 2 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/gdb/cp-abi.c b/gdb/cp-abi.c
index 37cf9c9..39da11a 100644
--- a/gdb/cp-abi.c
+++ b/gdb/cp-abi.c
@@ -314,6 +314,27 @@ set_cp_abi_cmd (char *args, int from_tty)
     error (_("Could not find \"%s\" in ABI list"), args);
 }
 
+/* A completion function for "set cp-abi".  */
+
+static VEC (char_ptr) *
+cp_abi_completer (struct cmd_list_element *ignore,
+		  char *text, char *word)
+{
+  static const char **cp_abi_names;
+
+  if (cp_abi_names == NULL)
+    {
+      int i;
+
+      cp_abi_names = XNEWVEC (const char *, num_cp_abis + 1);
+      for (i = 0; i < num_cp_abis; ++i)
+	cp_abi_names[i] = cp_abis[i]->shortname;
+      cp_abis[i] = NULL;
+    }
+
+  return complete_on_enum (cp_abi_names, text, word);
+}
+
 /* Show the currently selected C++ ABI.  */
 
 static void
@@ -334,13 +355,16 @@ extern initialize_file_ftype _initialize_cp_abi; /* -Wmissing-prototypes */
 void
 _initialize_cp_abi (void)
 {
+  struct cmd_list_element *c;
+
   register_cp_abi (&auto_cp_abi);
   switch_to_cp_abi ("auto");
 
-  add_cmd ("cp-abi", class_obscure, set_cp_abi_cmd, _("\
+  c = add_cmd ("cp-abi", class_obscure, set_cp_abi_cmd, _("\
 Set the ABI used for inspecting C++ objects.\n\
 \"set cp-abi\" with no arguments will list the available ABIs."),
-	   &setlist);
+	       &setlist);
+  set_cmd_completer (c, cp_abi_completer);
 
   add_cmd ("cp-abi", class_obscure, show_cp_abi_cmd,
 	   _("Show the ABI used for inspecting C++ objects."),
diff --git a/gdb/testsuite/gdb.base/completion.exp b/gdb/testsuite/gdb.base/completion.exp
index 566f5e0..2492226 100644
--- a/gdb/testsuite/gdb.base/completion.exp
+++ b/gdb/testsuite/gdb.base/completion.exp
@@ -707,6 +707,9 @@ gdb_test "complete ptype struct some_" "ptype struct some_struct"
 gdb_test "complete ptype enum some_" "ptype enum some_enum"
 gdb_test "complete ptype union some_" "ptype union some_union"
 
+
+gdb_test "complete set cp-abi aut" "set cp-abi auto"
+
 # Restore globals modified in this test...
 set timeout $oldtimeout1
 
-- 
1.7.7.6


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

* Re: RFC: completion for "set cp-abi"
  2013-01-08 16:42 RFC: completion for "set cp-abi" Tom Tromey
@ 2013-01-17 16:25 ` Tom Tromey
  2013-01-17 20:03   ` Regression for gdb.base/completion.exp [Re: RFC: completion for "set cp-abi"] Jan Kratochvil
  0 siblings, 1 reply; 4+ messages in thread
From: Tom Tromey @ 2013-01-17 16:25 UTC (permalink / raw)
  To: gdb-patches

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

Tom> This patch adds a completion function for "set cp-abi".
Tom> Built and regtested on x86-64 Fedora 16.

Tom> 	* cp-abi.c (cp_abi_completer): New function.
Tom> 	(_initialize_cp_abi): Set completer for "set cp-abi".

Tom> 	* gdb.base/completion.exp: Add "set cp-abi" completion test.

I am checking this in now.

Tom


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

* Regression for gdb.base/completion.exp  [Re: RFC: completion for "set cp-abi"]
  2013-01-17 16:25 ` Tom Tromey
@ 2013-01-17 20:03   ` Jan Kratochvil
  2013-01-17 20:23     ` Tom Tromey
  0 siblings, 1 reply; 4+ messages in thread
From: Jan Kratochvil @ 2013-01-17 20:03 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

Hi Tom,

3174fd02b667571ba97f88f6d48705dc0b009a86 is the first bad commit
commit 3174fd02b667571ba97f88f6d48705dc0b009a86
Author: Tom Tromey <tromey@redhat.com>
Date:   Thu Jan 17 16:27:26 2013 +0000

    	* cp-abi.c (cp_abi_completer): New function.
    	(_initialize_cp_abi): Set completer for "set cp-abi".
    gdb/testsuite
    	* gdb.base/completion.exp: Add "set cp-abi" completion test.

regressing on {x86_64,x86_64-m32,i686}-fedora18-linux-gnu (-lmcheck in use).

Program received signal SIGSEGV, Segmentation fault.
__strncmp_sse42 () at ../sysdeps/x86_64/multiarch/strcmp-sse42.S:162
162		movdqu	(%rdi), %xmm1
(gdb) bt
#0  __strncmp_sse42 () at ../sysdeps/x86_64/multiarch/strcmp-sse42.S:162
#1  0x000000000062e3ed in complete_on_enum (enumlist=0x29afb50, text=0x7fffffffd50b "aut", word=0x7fffffffd50b "aut") at ./cli/cli-decode.c:1822
#2  0x000000000084bf72 in cp_abi_completer (ignore=0x2139070, text=0x7fffffffd50b "aut", word=0x7fffffffd50b "aut") at cp-abi.c:335
#3  0x00000000007419b6 in complete_line_internal (text=0x1edd744 "aut", line_buffer=0x1edd739 "set cp-abi aut", point=14, reason=handle_completions) at completer.c:749
#4  0x00000000007419fc in complete_line (text=0x1edd744 "aut", line_buffer=0x1edd739 "set cp-abi aut", point=14) at completer.c:771
#5  0x00000000006319e0 in complete_command (arg=0x1edd739 "set cp-abi aut", from_tty=1) at ./cli/cli-cmds.c:274
#6  0x000000000062b446 in do_cfunc (c=0x2145c50, args=0x1edd739 "set cp-abi aut", from_tty=1) at ./cli/cli-decode.c:113
#7  0x000000000062e582 in cmd_func (cmd=0x2145c50, args=0x1edd739 "set cp-abi aut", from_tty=1) at ./cli/cli-decode.c:1861
#8  0x00000000008365a5 in execute_command (p=0x1edd739 "set cp-abi aut", from_tty=1) at top.c:484


Jan


On Thu, 17 Jan 2013 17:25:35 +0100, Tom Tromey wrote:
> >>>>> "Tom" == Tom Tromey <tromey@redhat.com> writes:
> 
> Tom> This patch adds a completion function for "set cp-abi".
> Tom> Built and regtested on x86-64 Fedora 16.
> 
> Tom> 	* cp-abi.c (cp_abi_completer): New function.
> Tom> 	(_initialize_cp_abi): Set completer for "set cp-abi".
> 
> Tom> 	* gdb.base/completion.exp: Add "set cp-abi" completion test.
> 
> I am checking this in now.
> 
> Tom


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

* Re: Regression for gdb.base/completion.exp  [Re: RFC: completion for "set cp-abi"]
  2013-01-17 20:03   ` Regression for gdb.base/completion.exp [Re: RFC: completion for "set cp-abi"] Jan Kratochvil
@ 2013-01-17 20:23     ` Tom Tromey
  0 siblings, 0 replies; 4+ messages in thread
From: Tom Tromey @ 2013-01-17 20:23 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches

>>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:

Jan> regressing on {x86_64,x86_64-m32,i686}-fedora18-linux-gnu (-lmcheck
Jan> in use).

Sorry about that.
It was a typo in the new function.

Here is the fix I am checking in.
I verified it using valgrind.

Tom

2013-01-17  Tom Tromey  <tromey@redhat.com>

	* cp-abi.c (cp_abi_completer): Fix typo in assignment.

Index: cp-abi.c
===================================================================
RCS file: /cvs/src/src/gdb/cp-abi.c,v
retrieving revision 1.38
diff -u -r1.38 cp-abi.c
--- cp-abi.c	17 Jan 2013 16:27:33 -0000	1.38
+++ cp-abi.c	17 Jan 2013 20:21:41 -0000
@@ -329,7 +329,7 @@
       cp_abi_names = XNEWVEC (const char *, num_cp_abis + 1);
       for (i = 0; i < num_cp_abis; ++i)
 	cp_abi_names[i] = cp_abis[i]->shortname;
-      cp_abis[i] = NULL;
+      cp_abi_names[i] = NULL;
     }
 
   return complete_on_enum (cp_abi_names, text, word);


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

end of thread, other threads:[~2013-01-17 20:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-08 16:42 RFC: completion for "set cp-abi" Tom Tromey
2013-01-17 16:25 ` Tom Tromey
2013-01-17 20:03   ` Regression for gdb.base/completion.exp [Re: RFC: completion for "set cp-abi"] Jan Kratochvil
2013-01-17 20:23     ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox