Fix indentation for printing Fortran types with pointers
[deliverable/binutils-gdb.git] / gdb / solib.c
index 491c18a685b0c3531a55cd9685e9ca2c3a8b8b6e..c8fe4d2cc701ad8764dd5df18f582f8d3bd7b2d0 100644 (file)
@@ -350,16 +350,15 @@ solib_find_1 (const char *in_pathname, int *fd, int is_solib)
 
   /* If not found, next search the inferior's $PATH environment variable.  */
   if (found_file < 0 && sysroot == NULL)
-    found_file = openp (get_in_environ (current_inferior ()->environment,
-                                       "PATH"),
+    found_file = openp (current_inferior ()->environment.get ("PATH"),
                        OPF_TRY_CWD_FIRST | OPF_RETURN_REALPATH, in_pathname,
                        O_RDONLY | O_BINARY, &temp_pathname);
 
   /* If not found, and we're looking for a solib, next search the
      inferior's $LD_LIBRARY_PATH environment variable.  */
   if (is_solib && found_file < 0 && sysroot == NULL)
-    found_file = openp (get_in_environ (current_inferior ()->environment,
-                                       "LD_LIBRARY_PATH"),
+    found_file = openp (current_inferior ()->environment.get
+                       ("LD_LIBRARY_PATH"),
                        OPF_TRY_CWD_FIRST | OPF_RETURN_REALPATH, in_pathname,
                        O_RDONLY | O_BINARY, &temp_pathname);
 
@@ -547,14 +546,10 @@ static int
 solib_map_sections (struct so_list *so)
 {
   const struct target_so_ops *ops = solib_ops (target_gdbarch ());
-  char *filename;
   struct target_section *p;
-  struct cleanup *old_chain;
 
-  filename = tilde_expand (so->so_name);
-  old_chain = make_cleanup (xfree, filename);
-  gdb_bfd_ref_ptr abfd (ops->bfd_open (filename));
-  do_cleanups (old_chain);
+  gdb::unique_xmalloc_ptr<char> filename (tilde_expand (so->so_name));
+  gdb_bfd_ref_ptr abfd (ops->bfd_open (filename.get ()));
 
   if (abfd == NULL)
     return 0;
@@ -1046,7 +1041,6 @@ info_sharedlibrary_command (char *pattern, int from_tty)
   int so_missing_debug_info = 0;
   int addr_width;
   int nr_libs;
-  struct cleanup *table_cleanup;
   struct gdbarch *gdbarch = target_gdbarch ();
   struct ui_out *uiout = current_uiout;
 
@@ -1063,8 +1057,8 @@ info_sharedlibrary_command (char *pattern, int from_tty)
 
   update_solib_list (from_tty);
 
-  /* make_cleanup_ui_out_table_begin_end needs to know the number of
-     rows, so we need to make two passes over the libs.  */
+  /* ui_out_emit_table table_emitter needs to know the number of rows,
+     so we need to make two passes over the libs.  */
 
   for (nr_libs = 0, so = so_list_head; so; so = so->next)
     {
@@ -1076,54 +1070,52 @@ info_sharedlibrary_command (char *pattern, int from_tty)
        }
     }
 
-  table_cleanup =
-    make_cleanup_ui_out_table_begin_end (uiout, 4, nr_libs,
-                                        "SharedLibraryTable");
-
-  /* The "- 1" is because ui_out adds one space between columns.  */
-  uiout->table_header (addr_width - 1, ui_left, "from", "From");
-  uiout->table_header (addr_width - 1, ui_left, "to", "To");
-  uiout->table_header (12 - 1, ui_left, "syms-read", "Syms Read");
-  uiout->table_header (0, ui_noalign, "name", "Shared Object Library");
-
-  uiout->table_body ();
-
-  ALL_SO_LIBS (so)
-    {
-      if (! so->so_name[0])
-       continue;
-      if (pattern && ! re_exec (so->so_name))
-       continue;
-
-      ui_out_emit_tuple tuple_emitter (uiout, "lib");
-
-      if (so->addr_high != 0)
-       {
-         uiout->field_core_addr ("from", gdbarch, so->addr_low);
-         uiout->field_core_addr ("to", gdbarch, so->addr_high);
-       }
-      else
-       {
-         uiout->field_skip ("from");
-         uiout->field_skip ("to");
-       }
-
-      if (! interp_ui_out (top_level_interpreter ())->is_mi_like_p ()
-         && so->symbols_loaded
-         && !objfile_has_symbols (so->objfile))
-       {
-         so_missing_debug_info = 1;
-         uiout->field_string ("syms-read", "Yes (*)");
-       }
-      else
-       uiout->field_string ("syms-read", so->symbols_loaded ? "Yes" : "No");
+  {
+    ui_out_emit_table table_emitter (uiout, 4, nr_libs, "SharedLibraryTable");
 
-      uiout->field_string ("name", so->so_name);
+    /* The "- 1" is because ui_out adds one space between columns.  */
+    uiout->table_header (addr_width - 1, ui_left, "from", "From");
+    uiout->table_header (addr_width - 1, ui_left, "to", "To");
+    uiout->table_header (12 - 1, ui_left, "syms-read", "Syms Read");
+    uiout->table_header (0, ui_noalign, "name", "Shared Object Library");
 
-      uiout->text ("\n");
-    }
+    uiout->table_body ();
 
-  do_cleanups (table_cleanup);
+    ALL_SO_LIBS (so)
+      {
+       if (! so->so_name[0])
+         continue;
+       if (pattern && ! re_exec (so->so_name))
+         continue;
+
+       ui_out_emit_tuple tuple_emitter (uiout, "lib");
+
+       if (so->addr_high != 0)
+         {
+           uiout->field_core_addr ("from", gdbarch, so->addr_low);
+           uiout->field_core_addr ("to", gdbarch, so->addr_high);
+         }
+       else
+         {
+           uiout->field_skip ("from");
+           uiout->field_skip ("to");
+         }
+
+       if (! interp_ui_out (top_level_interpreter ())->is_mi_like_p ()
+           && so->symbols_loaded
+           && !objfile_has_symbols (so->objfile))
+         {
+           so_missing_debug_info = 1;
+           uiout->field_string ("syms-read", "Yes (*)");
+         }
+       else
+         uiout->field_string ("syms-read", so->symbols_loaded ? "Yes" : "No");
+
+       uiout->field_string ("name", so->so_name);
+
+       uiout->text ("\n");
+      }
+  }
 
   if (nr_libs == 0)
     {
@@ -1305,28 +1297,24 @@ static void
 reload_shared_libraries_1 (int from_tty)
 {
   struct so_list *so;
-  struct cleanup *old_chain = make_cleanup (null_cleanup, NULL);
 
   if (print_symbol_loading_p (from_tty, 0, 0))
     printf_unfiltered (_("Loading symbols for shared libraries.\n"));
 
   for (so = so_list_head; so != NULL; so = so->next)
     {
-      char *filename, *found_pathname = NULL;
+      char *found_pathname = NULL;
       int was_loaded = so->symbols_loaded;
       symfile_add_flags add_flags = SYMFILE_DEFER_BP_RESET;
 
       if (from_tty)
        add_flags |= SYMFILE_VERBOSE;
 
-      filename = tilde_expand (so->so_original_name);
-      make_cleanup (xfree, filename);
-      gdb_bfd_ref_ptr abfd (solib_bfd_open (filename));
+      gdb::unique_xmalloc_ptr<char> filename
+       (tilde_expand (so->so_original_name));
+      gdb_bfd_ref_ptr abfd (solib_bfd_open (filename.get ()));
       if (abfd != NULL)
-       {
-         found_pathname = xstrdup (bfd_get_filename (abfd.get ()));
-         make_cleanup (xfree, found_pathname);
-       }
+       found_pathname = bfd_get_filename (abfd.get ());
 
       /* If this shared library is no longer associated with its previous
         symbol file, close that.  */
@@ -1368,8 +1356,6 @@ reload_shared_libraries_1 (int from_tty)
              solib_read_symbols (so, add_flags);
        }
     }
-
-  do_cleanups (old_chain);
 }
 
 static void
This page took 0.043794 seconds and 4 git commands to generate.