Add -file-list-shared-libraries MI command
[deliverable/binutils-gdb.git] / gdb / mi / mi-cmd-file.c
index 71e2845a413807cc64f99c48f76db2552890c067..a2ad392c9fdc6fe75047dab46383ed5b29777706 100644 (file)
 #include "defs.h"
 #include "mi-cmds.h"
 #include "mi-getopt.h"
+#include "mi-interp.h"
 #include "ui-out.h"
 #include "symtab.h"
 #include "source.h"
 #include "objfiles.h"
 #include "psymtab.h"
+#include "solib.h"
+#include "solist.h"
+#include "gdb_regex.h"
 
 /* Return to the client the absolute path and line number of the 
    current file being executed.  */
@@ -106,3 +110,56 @@ mi_cmd_file_list_exec_source_files (char *command, char **argv, int argc)
 
   uiout->end (ui_out_type_list);
 }
+
+/* See mi-cmds.h.  */
+
+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]"));
+    }
+
+  if (pattern != NULL)
+    {
+      const char *re_err = re_comp (pattern);
+
+      if (re_err != NULL)
+       error (_("Invalid regexp: %s"), re_err);
+    }
+
+  update_solib_list (1);
+
+  /* Print the table header.  */
+  struct cleanup *cleanup
+    = make_cleanup_ui_out_list_begin_end (uiout, "shared-libraries");
+
+  ALL_SO_LIBS (so)
+    {
+      if (so->so_name[0] == '\0')
+       continue;
+      if (pattern != NULL && !re_exec (so->so_name))
+       continue;
+
+      struct cleanup *tuple_clean_up
+        = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
+      mi_output_solib_attribs (uiout, so);
+
+      do_cleanups (tuple_clean_up);
+    }
+
+  do_cleanups (cleanup);
+}
This page took 0.027746 seconds and 4 git commands to generate.