@@ -31401,26 +31401,35 @@ The @value{GDBN} equivalent is @samp{info sources}.
 (gdb)
 @end smallexample
Â
-@ignore
 @subheading The @code{-file-list-shared-libraries} Command
 @findex -file-list-shared-libraries
Â
 @subsubheading Synopsis
Â
 @smallexample
- -file-list-shared-libraries
+ -file-list-shared-libraries [ @var{regexp} ]
 @end smallexample
Â
 List the shared libraries in the program.
+With a regular expression @var{regexp}, only those libraries whose
+names match @var{regexp} are listed.
Â
 @subsubheading @value{GDBN} Command
Â
 The corresponding @value{GDBN} command is @samp{info shared}.
Â
 @subsubheading Example
-N.A.
+@smallexample
+(gdb)
+-file-list-exec-source-files
+^done,shared-libraries=[
+@{from="0x72815989",to="0x728162c0",syms-read="1",name="/lib/libfoo.so"@},
+@{from="0x76ee48c0",to="0x76ee9160",syms-read="1",name="/lib/libbar.so"@}]
+(gdb)
+@end smallexample
Â
Â
+@ignore
 @subheading The @code{-file-list-symbol-files} Command
 @findex -file-list-symbol-files
Â
@@ -25,6 +25,9 @@
 #include "source.h"
 #include "objfiles.h"
 #include "psymtab.h"
+#include "solib.h"
+#include "solist.h"
+#include "xregex.h"
Â
 /* Return to the client the absolute path and line number of the
   current file being executed. */
@@ -108,3 +111,67 @@ mi_cmd_file_list_exec_source_files (char *command, char **argv, int argc)
Â
  ui_out_end (uiout, ui_out_type_list);
 }
+
+void
+mi_cmd_file_list_shared_libraries (char *command, char **argv, int argc)
+{
+Â struct ui_out *uiout = current_uiout;
+Â const char *pattern;
+Â struct so_list *so = NULL;
+Â struct gdbarch *gdbarch = target_gdbarch ();
+
+Â switch (argc)
+Â Â Â {
+Â Â Â case 0:
+Â Â Â Â Â pattern = NULL;
+Â Â Â Â Â break;
+Â Â Â case 1:
+Â Â Â Â Â pattern = argv[0];
+Â Â Â Â Â break;
+Â Â Â default:
+Â Â Â Â Â error (_("Usage: -file-list-shared-libraries [REGEXP]"));
+Â Â Â Â Â break;
+Â Â Â }
+
+Â if (pattern != NULL)
+Â Â Â {
+Â Â Â Â Â char *re_err = re_comp (pattern);
+
+Â Â Â Â Â if (re_err != NULL)
+Â Â Â Â Â Â error (_("Invalid regexp: %s"), re_err);
+Â Â Â }
+
+Â update_solib_list (1);
+
+ /* Print the table header. */
+Â ui_out_begin (uiout, ui_out_type_list, "shared-libraries");
+
+Â ALL_SO_LIBS (so)
+Â Â Â {
+Â Â Â Â Â if (so->so_name[0] == '\0')
+Â Â Â Â Â Â continue;
+Â Â Â Â Â if (pattern != NULL && !re_exec (so->so_name))
+Â Â Â Â Â Â continue;
+
+Â Â Â Â Â ui_out_begin (uiout, ui_out_type_tuple, NULL);
+
+Â Â Â Â Â if (so->addr_high != 0)
+Â Â Â Â Â Â {
+Â Â Â Â Â Â Â Â ui_out_field_core_addr (uiout, "from", gdbarch, so->addr_low);
+Â Â Â Â Â Â Â Â ui_out_field_core_addr (uiout, "to", gdbarch, so->addr_high);
+Â Â Â Â Â Â }
+Â Â Â Â Â else
+Â Â Â Â Â Â {
+Â Â Â Â Â Â Â Â ui_out_field_skip (uiout, "from");
+Â Â Â Â Â Â Â Â ui_out_field_skip (uiout, "to");
+Â Â Â Â Â Â }
+
+Â Â Â Â Â ui_out_field_int (uiout, "syms-read", so->symbols_loaded ? 1 : 0);
+
+Â Â Â Â Â ui_out_field_string (uiout, "name", so->so_name);
+
+Â Â Â Â Â ui_out_end (uiout, ui_out_type_tuple);
+Â Â Â }
+
+Â ui_out_end (uiout, ui_out_type_list);
+}
@@ -115,6 +115,8 @@ static struct mi_cmd mi_cmds[] =
                 mi_cmd_file_list_exec_source_file),
  DEF_MI_CMD_MI ("file-list-exec-source-files",
                 mi_cmd_file_list_exec_source_files),
+Â DEF_MI_CMD_MI ("file-list-shared-libraries",
+Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â mi_cmd_file_list_shared_libraries),
  DEF_MI_CMD_CLI ("file-symbol-file", "symbol-file", 1),
  DEF_MI_CMD_MI ("gdb-exit", mi_cmd_gdb_exit),
  DEF_MI_CMD_CLI_1 ("gdb-set", "set", 1,
@@ -70,6 +70,7 @@ extern mi_cmd_argv_ftype mi_cmd_exec_step;
 extern mi_cmd_argv_ftype mi_cmd_exec_step_instruction;
 extern mi_cmd_argv_ftype mi_cmd_file_list_exec_source_file;
 extern mi_cmd_argv_ftype mi_cmd_file_list_exec_source_files;
+extern mi_cmd_argv_ftype mi_cmd_file_list_shared_libraries;
 extern mi_cmd_argv_ftype mi_cmd_gdb_exit;
 extern mi_cmd_argv_ftype mi_cmd_inferior_tty_set;
 extern mi_cmd_argv_ftype mi_cmd_inferior_tty_show;
@@ -737,21 +737,7 @@ solib_used (const struct so_list *const known)
  return 0;
 }
Â
-/* Synchronize GDB's shared object list with inferior's.
-
-Â Â Extract the list of currently loaded shared objects from the
-Â Â inferior, and compare it with the list of shared objects currently
-  in GDB's so_list_head list. Edit so_list_head to bring it in sync
-Â Â with the inferior's new list.
-
-Â Â If we notice that the inferior has unloaded some shared objects,
-Â Â free any symbolic info GDB had read about those shared objects.
-
-Â Â Don't load symbolic info for any new shared objects; just add them
-Â Â to the list, and leave their symbols_loaded flag clear.
-
-Â Â If FROM_TTY is non-null, feel free to print messages about what
-  we're doing. */
+/* See solib.h. */
Â
 void
 update_solib_list (int from_tty)
@@ -1096,7 +1082,7 @@ info_sharedlibrary_command (char *pattern, int from_tty)
Â
  ui_out_table_body (uiout);
Â
-Â for (so = so_list_head; so; so = so->next)
+Â ALL_SO_LIBS (so)
    {
      struct cleanup *lib_cleanup;
Â
@@ -73,6 +73,24 @@ extern void no_shared_libraries (char *ignored, int from_tty);
 extern void set_solib_ops (struct gdbarch *gdbarch,
                           const struct target_so_ops *new_ops);
Â
+/* Synchronize GDB's shared object list with inferior's.
+
+Â Â Extract the list of currently loaded shared objects from the
+Â Â inferior, and compare it with the list of shared objects currently
+  in GDB's so_list_head list. Edit so_list_head to bring it in sync
+Â Â with the inferior's new list.
+
+Â Â If we notice that the inferior has unloaded some shared objects,
+Â Â free any symbolic info GDB had read about those shared objects.
+
+Â Â Don't load symbolic info for any new shared objects; just add them
+Â Â to the list, and leave their symbols_loaded flag clear.
+
+Â Â If FROM_TTY is non-null, feel free to print messages about what
+  we're doing. */
+
+extern void update_solib_list (int from_tty);
+
 /* Return non-zero if NAME is the libpthread shared library. */
Â
 extern int libpthread_name_p (const char *name);
@@ -23,6 +23,11 @@
 /* For domain_enum domain. */
 #include "symtab.h"
Â
+#define ALL_SO_LIBS(so) \
+Â Â Â for (so = current_program_space->so_list; \
+Â Â Â Â Â Â Â so; \
+Â Â Â Â Â Â Â so = so->next)
+
 /* Forward declaration for target specific link map information. This
   struct is opaque to all but the target specific file. */
 struct lm_info;
@@ -48,27 +48,47 @@ if { [gdb_compile_shlib ${srcfile_lib} ${binfile_lib} $lib_flags] != ""
Â
 mi_delete_breakpoints
 mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_reinitialize_dir $srcdir/$subdir
 mi_gdb_load ${binfile}
Â
 mi_load_shlibs $binfile_lib
Â
-mi_gdb_test "777-gdb-set stop-on-solib-events 1" "777\\^done" \
-Â Â Â "set stop-on-solib-events"
+proc test_stop_on_solib_events {} {
+Â Â Â mi_gdb_test "777-gdb-set stop-on-solib-events 1" "777\\^done" \
+Â Â Â Â Â Â "set stop-on-solib-events"
Â
-# We use "run" rather than "-exec-run" here in order to test that CLI
-# commands still cause the correct MI output to be generated.
-mi_run_with_cli
+Â Â Â # We use "run" rather than "-exec-run" here in order to test that CLI
+Â Â Â # commands still cause the correct MI output to be generated.
+Â Â Â mi_run_with_cli
Â
-# Also test that the CLI solib event note is output.
-set test "CLI prints solib event"
-gdb_expect {
-Â Â Â -re "~\"Stopped due to shared library event \\(no libraries added or removed\\)\\\\n" {
-Â Â Â Â Â Â pass "$test"
-Â Â Â }
-Â Â Â timeout {
-Â Â Â Â Â Â fail "$test (timeout)"
+Â Â Â # Also test that the CLI solib event note is output.
+Â Â Â set test "CLI prints solib event"
+Â Â Â gdb_expect {
+Â Â Â Â Â Â -re "~\"Stopped due to shared library event \\(no libraries added or removed\\)\\\\n" {
+Â Â Â Â Â Â Â Â Â Â pass "$test"
+Â Â Â Â Â Â }
+Â Â Â Â Â Â timeout {
+Â Â Â Â Â Â Â Â Â Â fail "$test (timeout)"
+Â Â Â Â Â Â }
    }
+
+Â Â Â mi_expect_stop solib-event .* .* .* .* .* "check for solib event"
+
+Â Â Â # Unset solib events to avoid interfering with other tests.
+Â Â Â mi_gdb_test "778-gdb-set stop-on-solib-events 0" "778\\^done" \
+Â Â Â Â Â Â "unset stop-on-solib-events"
+}
+
+proc test_file_list_shared_libraries {} {
+Â Â Â global libname
+Â Â Â global binfile
+
+Â Â Â mi_continue_to main
+
+Â Â Â mi_gdb_test "222-file-list-shared-libraries" \
+Â Â Â Â Â Â "222\\^done,shared-libraries=\\\[.*\{from=\".*\",to=\".*\",syms-read=\"1\",name=\".*${libname}.so\"\}.*]" \
+Â Â Â Â Â Â "Getting a list of shared libraries."
 }
Â
-mi_expect_stop solib-event .* .* .* .* .* "check for solib event"
+test_stop_on_solib_events
+test_file_list_shared_libraries
+mi_gdb_exit