gdb/
authorYao Qi <yao@codesourcery.com>
Fri, 29 Mar 2013 15:21:23 +0000 (15:21 +0000)
committerYao Qi <yao@codesourcery.com>
Fri, 29 Mar 2013 15:21:23 +0000 (15:21 +0000)
2013-03-29  Yao Qi  <yao@codesourcery.com>

* corelow.c: Include "completer.h".
(_initialize_corelow): Call add_target_with_completer with
argument 'filename_completer'.
* tracepoint.c: Likewise.
* exec.c (_initialize_exec): Likewise.
* target.c (add_target): Rename to ...
(add_target_with_completer): ... this.  Call set_cmd_completer
if parameter completer is not NULL.
(add_target): New.
* target.h: Include "command.h".
(add_target_with_completer): Declare it.

gdb/testsuite:

2013-03-29  Yao Qi  <yao@codesourcery.com>

* gdb.base/completion.exp: Test completion of commands
"target core", "target tfile" and "target exec".
* gdb.trace/tfile.exp: Test completion of command
"target tfile".

gdb/ChangeLog
gdb/corelow.c
gdb/exec.c
gdb/target.c
gdb/target.h
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/completion.exp
gdb/testsuite/gdb.trace/tfile.exp
gdb/tracepoint.c

index 3b7926adb1b330bb46fcb528da8baf7011ac2101..58251edd43985f5360ca6190fc2cdd2636e20ada 100644 (file)
@@ -1,3 +1,17 @@
+2013-03-29  Yao Qi  <yao@codesourcery.com>
+
+       * corelow.c: Include "completer.h".
+       (_initialize_corelow): Call add_target_with_completer with
+       argument 'filename_completer'.
+       * tracepoint.c: Likewise.
+       * exec.c (_initialize_exec): Likewise.
+       * target.c (add_target): Rename to ...
+       (add_target_with_completer): ... this.  Call set_cmd_completer
+       if parameter completer is not NULL.
+       (add_target): New.
+       * target.h: Include "command.h".
+       (add_target_with_completer): Declare it.
+
 2013-03-28  Joel Brobecker  <brobecker@adacore.com>
 
        * coffread.c (is_import_fixup_symbol): New function.
index 77bab82fa8a64bb1369e0923754c6a36e93bd59d..fa489410d99c7bcb1aa67a0bf4f14c85f50f99ed 100644 (file)
@@ -46,6 +46,7 @@
 #include "progspace.h"
 #include "objfiles.h"
 #include "gdb_bfd.h"
+#include "completer.h"
 
 #ifndef O_LARGEFILE
 #define O_LARGEFILE 0
@@ -977,5 +978,5 @@ _initialize_corelow (void)
 {
   init_core_ops ();
 
-  add_target (&core_ops);
+  add_target_with_completer (&core_ops, filename_completer);
 }
index f550194b18ff012bb7a9f6812362b9739ae66f8c..3386b60d18625d04a8e5ab19fea8770d9faaec5c 100644 (file)
@@ -943,7 +943,7 @@ Show writing into executable and core files."), NULL,
                           show_write_files,
                           &setlist, &showlist);
 
-  add_target (&exec_ops);
+  add_target_with_completer (&exec_ops, filename_completer);
 }
 
 static char *
index 9193c97ea149f3ec82bc6fb6c46386607af9fb1b..24cc79d4c068243c94bcdf94d2217458d5444c44 100644 (file)
@@ -384,11 +384,16 @@ target_has_execution_current (void)
   return target_has_execution_1 (inferior_ptid);
 }
 
-/* Add a possible target architecture to the list.  */
+/* Add possible target architecture T to the list and add a new
+   command 'target T->to_shortname'.  Set COMPLETER as the command's
+   completer if not NULL.  */
 
 void
-add_target (struct target_ops *t)
+add_target_with_completer (struct target_ops *t,
+                          completer_ftype *completer)
 {
+  struct cmd_list_element *c;
+
   /* Provide default values for all "must have" methods.  */
   if (t->to_xfer_partial == NULL)
     t->to_xfer_partial = default_xfer_partial;
@@ -431,7 +436,18 @@ Remaining arguments are interpreted by the target protocol.  For more\n\
 information on the arguments for a particular protocol, type\n\
 `help target ' followed by the protocol name."),
                    &targetlist, "target ", 0, &cmdlist);
-  add_cmd (t->to_shortname, no_class, t->to_open, t->to_doc, &targetlist);
+  c = add_cmd (t->to_shortname, no_class, t->to_open, t->to_doc,
+              &targetlist);
+  if (completer != NULL)
+    set_cmd_completer (c, completer);
+}
+
+/* Add a possible target architecture to the list.  */
+
+void
+add_target (struct target_ops *t)
+{
+  add_target_with_completer (t, NULL);
 }
 
 /* See target.h.  */
index ee3fbff4b0c54a619840c0a9d07367eba0da817e..4f8520cee9ba7966c9f8c20136c0599af475fa35 100644 (file)
@@ -63,6 +63,7 @@ struct expression;
 #include "vec.h"
 #include "gdb_signals.h"
 #include "btrace.h"
+#include "command.h"
 
 enum strata
   {
@@ -1841,6 +1842,9 @@ int target_verify_memory (const gdb_byte *data,
 
 extern void add_target (struct target_ops *);
 
+extern void add_target_with_completer (struct target_ops *t,
+                                      completer_ftype *completer);
+
 /* Adds a command ALIAS for target T and marks it deprecated.  This is useful
    for maintaining backwards compatibility when renaming targets.  */
 
index 9c835f2efa5bddf51e5857f7eba2abc42cbb22b0..20a19fc0770aaf6da41863f6fdcedfbb9a50d607 100644 (file)
@@ -1,3 +1,10 @@
+2013-03-29  Yao Qi  <yao@codesourcery.com>
+
+       * gdb.base/completion.exp: Test completion of commands
+       "target core", "target tfile" and "target exec".
+       * gdb.trace/tfile.exp: Test completion of command
+       "target tfile".
+
 2013-03-28  Joel Brobecker  <brobecker@adacore.com>
 
        * gdb.ada/win_fu_syms: New testcase.
index cddc54898ad4684ace43469648838d144c92d52b..7b664bfc25638e16ce0fa721eb5943f5301f300b 100644 (file)
@@ -713,6 +713,13 @@ gdb_test "complete set gnutarget aut" "set gnutarget auto"
 
 gdb_test "complete set cp-abi aut" "set cp-abi auto"
 
+# Test that completion of commands 'target FOO' works well.
+
+foreach target_name { "core" "tfile" "exec" } {
+    gdb_test "complete target ${target_name} ./gdb.base/completion" \
+       "target ${target_name} ./gdb.base/completion\\.exp.*"
+}
+
 # Restore globals modified in this test...
 set timeout $oldtimeout1
 
index 56e2a799041764e7e9ec9abbe283e3aa8ce050c9..f259952640e79b5a551e330c30f307904db41d46 100644 (file)
@@ -125,3 +125,8 @@ gdb_test \
 gdb_test "interpreter-exec mi \"-trace-status\"" \
     "\\^done,supported=\"file\",trace-file=\".*basic.tf\",running=\"0\",stop-reason=\"request\",frames=\"${decimal}\",frames-created=\"${decimal}\",buffer-size=\"${decimal}\",buffer-free=\"${decimal}\",disconnected=\".*\",circular=\".*\",user-name=\"\",notes=\"\",start-time=\".*\",stop-time=\".*\"" \
     "-trace-status"
+
+# Test completion works well.
+
+gdb_test "target tfile basic\t" "Assuming tracepoint.*" \
+    "complete-command 'target tfile'"
index 9a2425b5215273341ad66695cdb10fa69786c25d..009db82c901d4c31448b9697ee0fdcd8f072afde 100644 (file)
@@ -54,6 +54,7 @@
 #include "cli/cli-utils.h"
 #include "probe.h"
 #include "ctf.h"
+#include "completer.h"
 
 /* readline include files */
 #include "readline/readline.h"
@@ -5904,5 +5905,5 @@ Show the notes string to use for future tstop commands"), NULL,
 
   init_tfile_ops ();
 
-  add_target (&tfile_ops);
+  add_target_with_completer (&tfile_ops, filename_completer);
 }
This page took 0.0405 seconds and 4 git commands to generate.