Fix PR cli/18053
authorTom Tromey <tom@tromey.com>
Mon, 2 Mar 2015 03:33:00 +0000 (20:33 -0700)
committerTom Tromey <tom@tromey.com>
Wed, 13 Jul 2016 18:57:20 +0000 (12:57 -0600)
PR cli/18053 concerns a couple of minor bugs in the JIT debuginfo
support.  First, jit-reader-load should use filename completion and
support tilde expansion.  Second, the help for jit-reader-unload is
incorrect.  While working on this I also realized that
jit-reader-unload should use the no-op completer, so I've included
that as well.

Built and regtested on x86-64 Fedora 23.  A completer test for
jit-reader-load is included, but not a tilde-expansion test, as I
couldn't think of a reliable way to test that.

2016-07-13  Tom Tromey  <tom@tromey.com>

PR cli/18053:
* jit.c (jit_reader_load_command): Use tilde_expand.
(_initialize_jit): Fix help for jit-reader-unload.  Set completer
for new commands.

2016-07-13  Tom Tromey  <tom@tromey.com>

PR cli/18053:
* gdb.base/jit-so.exp (one_jit_test): Add jit-reader-load
completion test.

gdb/ChangeLog
gdb/jit.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/jit-so.exp

index 4139a293f4c59b106e342736e6f49b410d967e7b..65adae17bc873fa425fde2e252cf50f937280f14 100644 (file)
@@ -1,3 +1,10 @@
+2016-07-13  Tom Tromey  <tom@tromey.com>
+
+       PR cli/18053:
+       * jit.c (jit_reader_load_command): Use tilde_expand.
+       (_initialize_jit): Fix help for jit-reader-unload.  Set completer
+       for new commands.
+
 2016-07-12  Tom Tromey  <tom@tromey.com>
 
        PR python/19293:
index 2b6cf77f08aa201dbdd464c794857afd83ea23d6..1b772ab175c4b25df5bd6d06359cfff70ae03f30 100644 (file)
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -39,6 +39,8 @@
 #include "gdb-dlfcn.h"
 #include <sys/stat.h>
 #include "gdb_bfd.h"
+#include "readline/tilde.h"
+#include "completer.h"
 
 static const char *jit_reader_dir = NULL;
 
@@ -208,15 +210,19 @@ jit_reader_load_command (char *args, int from_tty)
 
   if (args == NULL)
     error (_("No reader name provided."));
+  args = tilde_expand (args);
+  prev_cleanup = make_cleanup (xfree, args);
 
   if (loaded_jit_reader != NULL)
     error (_("JIT reader already loaded.  Run jit-reader-unload first."));
 
   if (IS_ABSOLUTE_PATH (args))
-    so_name = xstrdup (args);
+    so_name = args;
   else
-    so_name = xstrprintf ("%s%s%s", jit_reader_dir, SLASH_STRING, args);
-  prev_cleanup = make_cleanup (xfree, so_name);
+    {
+      so_name = xstrprintf ("%s%s%s", jit_reader_dir, SLASH_STRING, args);
+      make_cleanup (xfree, so_name);
+    }
 
   loaded_jit_reader = jit_reader_load (so_name);
   reinit_frame_cache ();
@@ -1529,15 +1535,21 @@ _initialize_jit (void)
   jit_gdbarch_data = gdbarch_data_register_pre_init (jit_gdbarch_data_init);
   if (is_dl_available ())
     {
-      add_com ("jit-reader-load", no_class, jit_reader_load_command, _("\
+      struct cmd_list_element *c;
+
+      c = add_com ("jit-reader-load", no_class, jit_reader_load_command, _("\
 Load FILE as debug info reader and unwinder for JIT compiled code.\n\
 Usage: jit-reader-load FILE\n\
 Try to load file FILE as a debug info reader (and unwinder) for\n\
 JIT compiled code.  The file is loaded from " JIT_READER_DIR ",\n\
 relocated relative to the GDB executable if required."));
-      add_com ("jit-reader-unload", no_class, jit_reader_unload_command, _("\
+      set_cmd_completer (c, filename_completer);
+
+      c = add_com ("jit-reader-unload", no_class,
+                  jit_reader_unload_command, _("\
 Unload the currently loaded JIT debug info reader.\n\
-Usage: jit-reader-unload FILE\n\n\
+Usage: jit-reader-unload\n\n\
 Do \"help jit-reader-load\" for info on loading debug info readers."));
+      set_cmd_completer (c, noop_completer);
     }
 }
index 7ab1228a7d6875aec40c03710c0aa884ba7656bf..b404db4443d5c52c741b8550ac4bfccab9b202e7 100644 (file)
@@ -1,3 +1,9 @@
+2016-07-13  Tom Tromey  <tom@tromey.com>
+
+       PR cli/18053:
+       * gdb.base/jit-so.exp (one_jit_test): Add jit-reader-load
+       completion test.
+
 2016-07-13  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
        * gdb.dwarf2/atomic-type.exp: Use function_range for low_pc and high_pc.
index 0db325962ec204be24198751e32296757cc571fa..9fadd868a4061811e23c3aaffd2aff0f3497bd57 100644 (file)
@@ -117,3 +117,10 @@ proc one_jit_test {count match_str} {
 
 one_jit_test 1 "${hex}  jit_function_0000"
 one_jit_test 2 "${hex}  jit_function_0000\[\r\n\]+${hex}  jit_function_0001"
+
+# We don't intend to load the .so as a JIT debuginfo reader, but we
+# need some handy file name for a completion test.
+gdb_test \
+    "complete jit-reader-load [standard_output_file ${solib_testfile}.s]" \
+    "jit-reader-load $solib_binfile" \
+    "test jit-reader-load filename completion"
This page took 0.037725 seconds and 4 git commands to generate.