This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH] Add completer to 'target ctf'.
- From: Yao Qi <yao at codesourcery dot com>
- To: <gdb-patches at sourceware dot org>
- Date: Thu, 11 Apr 2013 13:40:51 +0800
- Subject: [PATCH] Add completer to 'target ctf'.
Hello,
This patch adds a filename completer to command 'target ctf'.
Ideally, it needs a 'directory name' completer, since CTF data
is always saved in a directory. However, filename completer is
sufficient in this case.
Is it OK?
gdb:
2013-04-11 Yao Qi <yao@codesourcery.com>
* ctf.c (_initialize_ctf): Include "completer.h".
Call add_target_with_completer instead of add_target.
gdb/testsuite:
2013-04-11 Yao Qi <yao@codesourcery.com>
* gdb.base/completion.exp: Test completion of command
'target ctf' if target ctf is supported.
---
gdb/ctf.c | 3 ++-
gdb/testsuite/gdb.base/completion.exp | 13 ++++++++++++-
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/gdb/ctf.c b/gdb/ctf.c
index 5170a92..20506f2 100644
--- a/gdb/ctf.c
+++ b/gdb/ctf.c
@@ -25,6 +25,7 @@
#include "regcache.h"
#include "gdb_stat.h"
#include "exec.h"
+#include "completer.h"
#include <ctype.h>
@@ -1849,6 +1850,6 @@ _initialize_ctf (void)
#if HAVE_LIBBABELTRACE
init_ctf_ops ();
- add_target (&ctf_ops);
+ add_target_with_completer (&ctf_ops, filename_completer);
#endif
}
diff --git a/gdb/testsuite/gdb.base/completion.exp b/gdb/testsuite/gdb.base/completion.exp
index 008cb0a..80cfbff 100644
--- a/gdb/testsuite/gdb.base/completion.exp
+++ b/gdb/testsuite/gdb.base/completion.exp
@@ -714,8 +714,19 @@ 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.
+set targets [list "core" "tfile" "exec"]
-foreach target_name { "core" "tfile" "exec" } {
+# Test that completion of command 'target ctf' if GDB supports ctf
+# target.
+gdb_test_multiple "target ctf" "" {
+ -re "Undefined target command: \"ctf\"\. Try \"help target\"\.\r\n$gdb_prompt $" {
+ }
+ -re "No CTF directory specified.*\r\n$gdb_prompt $" {
+ lappend targets "ctf"
+ }
+}
+
+foreach target_name ${targets} {
gdb_test "complete target ${target_name} ./gdb.base/completion" \
"target ${target_name} ./gdb.base/completion\\.exp.*"
}
--
1.7.7.6