public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [RFA 2/4] Move some declarations to source.h
  2018-02-13 23:39 Remove a few more cleanups: solib and openp Tom Tromey
                   ` (2 preceding siblings ...)
  2018-02-13 23:39 ` [RFA 3/4] Change openp et al to use a unique_xmalloc_ptr Tom Tromey
@ 2018-02-13 23:39 ` Tom Tromey
  2018-02-14 13:55 ` Remove a few more cleanups: solib and openp Pedro Alves
  4 siblings, 0 replies; 7+ messages in thread
From: Tom Tromey @ 2018-02-13 23:39 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

I noticed a few declarations in defs.h that really could be put into
source.h.  I think it's generally preferable to something out of
defs.h unless it is needed by most of the files in gdb.

2018-02-13  Tom Tromey  <tom@tromey.com>

	* solib.c: Include source.h.
	* nto-tdep.c: Include source.h.
	* mi/mi-cmd-env.c: Include source.h.
	* infcmd.c: Include source.h.
	* exec.c: Include source.h.
	* defs.h (enum openp_flag, openp, source_full_path_of, mod_path)
	(add_path, directory_switch, source_path, init_source_path): Move
	declarations...
	* source.h (enum openp_flag, openp, source_full_path_of, mod_path)
	(add_path, directory_switch, source_path, init_source_path):
	...here.
---
 gdb/ChangeLog       | 14 ++++++++++++++
 gdb/defs.h          | 27 ---------------------------
 gdb/exec.c          |  1 +
 gdb/infcmd.c        |  1 +
 gdb/mi/mi-cmd-env.c |  1 +
 gdb/nto-tdep.c      |  1 +
 gdb/solib.c         |  1 +
 gdb/source.h        | 25 +++++++++++++++++++++++++
 8 files changed, 44 insertions(+), 27 deletions(-)

diff --git a/gdb/defs.h b/gdb/defs.h
index 70389ad745..c85bf2cf11 100644
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -339,33 +339,6 @@ extern int build_address_symbolic (struct gdbarch *,
 extern void print_address (struct gdbarch *, CORE_ADDR, struct ui_file *);
 extern const char *pc_prefix (CORE_ADDR);
 
-/* From source.c */
-
-/* See openp function definition for their description.  */
-
-enum openp_flag
-{
-  OPF_TRY_CWD_FIRST = 0x01,
-  OPF_SEARCH_IN_PATH = 0x02,
-  OPF_RETURN_REALPATH = 0x04,
-};
-
-DEF_ENUM_FLAGS_TYPE(openp_flag, openp_flags);
-
-extern int openp (const char *, openp_flags, const char *, int, char **);
-
-extern int source_full_path_of (const char *, char **);
-
-extern void mod_path (const char *, char **);
-
-extern void add_path (const char *, char **, int);
-
-extern void directory_switch (const char *, int);
-
-extern char *source_path;
-
-extern void init_source_path (void);
-
 /* From exec.c */
 
 /* * Process memory area starting at ADDR with length SIZE.  Area is
diff --git a/gdb/exec.c b/gdb/exec.c
index 15f85a278f..79baf9c5fb 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -35,6 +35,7 @@
 #include "progspace.h"
 #include "gdb_bfd.h"
 #include "gcore.h"
+#include "source.h"
 
 #include <fcntl.h>
 #include "readline/readline.h"
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 3879df3f5a..331fd8751b 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -59,6 +59,7 @@
 #include "top.h"
 #include "interps.h"
 #include "common/gdb_optional.h"
+#include "source.h"
 
 /* Local functions: */
 
diff --git a/gdb/mi/mi-cmd-env.c b/gdb/mi/mi-cmd-env.c
index e7c41dd7bd..2f5b803d5b 100644
--- a/gdb/mi/mi-cmd-env.c
+++ b/gdb/mi/mi-cmd-env.c
@@ -31,6 +31,7 @@
 #include "ui-out.h"
 #include "top.h"
 #include <sys/stat.h>
+#include "source.h"
 
 static const char path_var_name[] = "PATH";
 static char *orig_path = NULL;
diff --git a/gdb/nto-tdep.c b/gdb/nto-tdep.c
index 03b2d1e96d..30db99c759 100644
--- a/gdb/nto-tdep.c
+++ b/gdb/nto-tdep.c
@@ -31,6 +31,7 @@
 #include "solib-svr4.h"
 #include "gdbcore.h"
 #include "objfiles.h"
+#include "source.h"
 
 #define QNX_NOTE_NAME	"QNX"
 #define QNX_INFO_SECT_NAME "QNX_info"
diff --git a/gdb/solib.c b/gdb/solib.c
index 46f2324c48..c732df6150 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -46,6 +46,7 @@
 #include "filesystem.h"
 #include "gdb_bfd.h"
 #include "filestuff.h"
+#include "source.h"
 
 /* Architecture-specific operations.  */
 
diff --git a/gdb/source.h b/gdb/source.h
index 77fd4cdaba..a21e919b28 100644
--- a/gdb/source.h
+++ b/gdb/source.h
@@ -21,6 +21,31 @@
 
 struct symtab;
 
+/* See openp function definition for their description.  */
+
+enum openp_flag
+{
+  OPF_TRY_CWD_FIRST = 0x01,
+  OPF_SEARCH_IN_PATH = 0x02,
+  OPF_RETURN_REALPATH = 0x04,
+};
+
+DEF_ENUM_FLAGS_TYPE(openp_flag, openp_flags);
+
+extern int openp (const char *, openp_flags, const char *, int, char **);
+
+extern int source_full_path_of (const char *, char **);
+
+extern void mod_path (const char *, char **);
+
+extern void add_path (const char *, char **, int);
+
+extern void directory_switch (const char *, int);
+
+extern char *source_path;
+
+extern void init_source_path (void);
+
 /* This function is capable of finding the absolute path to a
    source file, and opening it, provided you give it a FILENAME.  Both the
    DIRNAME and FULLNAME are only added suggestions on where to find the file.
-- 
2.13.6

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [RFA 4/4] Constify target_so_ops::bfd_open
  2018-02-13 23:39 Remove a few more cleanups: solib and openp Tom Tromey
@ 2018-02-13 23:39 ` Tom Tromey
  2018-02-13 23:39 ` [RFA 1/4] Return unique_xmalloc_ptr from some solib.c functions Tom Tromey
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Tom Tromey @ 2018-02-13 23:39 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This constifies the bfd_open method of struct target_so_ops.

gdb/ChangeLog
2018-02-13  Tom Tromey  <tom@tromey.com>

	* solist.h (struct target_so_ops) <bfd_open>: Make pathname
	const.
	(solib_bfd_open): Make pathname const.
	* solib.c (solib_bfd_open): Make pathname const.
	* solib-spu.c (spu_bfd_fopen): Make name const.
	(spu_bfd_open): Make pathname const.
	* solib-darwin.c (darwin_bfd_open): Make pathname const.
	* solib-aix.c (solib_aix_bfd_open): Make pathname const.
---
 gdb/ChangeLog      | 11 +++++++++++
 gdb/solib-aix.c    |  4 ++--
 gdb/solib-darwin.c |  2 +-
 gdb/solib-spu.c    |  6 +++---
 gdb/solib.c        |  2 +-
 gdb/solist.h       |  4 ++--
 6 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/gdb/solib-aix.c b/gdb/solib-aix.c
index aa0e0d2dfb..f11cbcd243 100644
--- a/gdb/solib-aix.c
+++ b/gdb/solib-aix.c
@@ -602,7 +602,7 @@ solib_aix_in_dynsym_resolve_code (CORE_ADDR pc)
 /* Implement the "bfd_open" target_so_ops method.  */
 
 static gdb_bfd_ref_ptr
-solib_aix_bfd_open (char *pathname)
+solib_aix_bfd_open (const char *pathname)
 {
   /* The pathname is actually a synthetic filename with the following
      form: "/path/to/sharedlib(member.o)" (double-quotes excluded).
@@ -611,7 +611,7 @@ solib_aix_bfd_open (char *pathname)
      FIXME: This is a little hacky.  Perhaps we should provide access
      to the solib's lm_info here?  */
   const int path_len = strlen (pathname);
-  char *sep;
+  const char *sep;
   int filename_len;
   int found_file;
 
diff --git a/gdb/solib-darwin.c b/gdb/solib-darwin.c
index ed8f9da257..cf15148c36 100644
--- a/gdb/solib-darwin.c
+++ b/gdb/solib-darwin.c
@@ -617,7 +617,7 @@ darwin_lookup_lib_symbol (struct objfile *objfile,
 }
 
 static gdb_bfd_ref_ptr
-darwin_bfd_open (char *pathname)
+darwin_bfd_open (const char *pathname)
 {
   int found_file;
 
diff --git a/gdb/solib-spu.c b/gdb/solib-spu.c
index d0d63b5ef5..943ebf5ee3 100644
--- a/gdb/solib-spu.c
+++ b/gdb/solib-spu.c
@@ -320,7 +320,7 @@ spu_bfd_iovec_stat (bfd *abfd, void *stream, struct stat *sb)
 }
 
 static gdb_bfd_ref_ptr
-spu_bfd_fopen (char *name, CORE_ADDR addr)
+spu_bfd_fopen (const char *name, CORE_ADDR addr)
 {
   CORE_ADDR *open_closure = XNEW (CORE_ADDR);
 
@@ -342,9 +342,9 @@ spu_bfd_fopen (char *name, CORE_ADDR addr)
 
 /* Open shared library BFD.  */
 static gdb_bfd_ref_ptr
-spu_bfd_open (char *pathname)
+spu_bfd_open (const char *pathname)
 {
-  char *original_name = strrchr (pathname, '@');
+  const char *original_name = strrchr (pathname, '@');
   asection *spu_name;
   unsigned long long addr;
   int fd;
diff --git a/gdb/solib.c b/gdb/solib.c
index c1bb227d3f..e356fedeb8 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -482,7 +482,7 @@ solib_bfd_fopen (const char *pathname, int fd)
 /* Find shared library PATHNAME and open a BFD for it.  */
 
 gdb_bfd_ref_ptr
-solib_bfd_open (char *pathname)
+solib_bfd_open (const char *pathname)
 {
   int found_file;
   const struct bfd_arch_info *b;
diff --git a/gdb/solist.h b/gdb/solist.h
index 1df45e4d93..6875d1be12 100644
--- a/gdb/solist.h
+++ b/gdb/solist.h
@@ -129,7 +129,7 @@ struct target_so_ops
     int (*in_dynsym_resolve_code) (CORE_ADDR pc);
 
     /* Find and open shared library binary file.  */
-    gdb_bfd_ref_ptr (*bfd_open) (char *pathname);
+    gdb_bfd_ref_ptr (*bfd_open) (const char *pathname);
 
     /* Optional extra hook for finding and opening a solib.
        If TEMP_PATHNAME is non-NULL: If the file is successfully opened a
@@ -204,7 +204,7 @@ extern gdb::unique_xmalloc_ptr<char> solib_find (const char *in_pathname,
 extern gdb_bfd_ref_ptr solib_bfd_fopen (const char *pathname, int fd);
 
 /* Find solib binary file and open it.  */
-extern gdb_bfd_ref_ptr solib_bfd_open (char *in_pathname);
+extern gdb_bfd_ref_ptr solib_bfd_open (const char *in_pathname);
 
 /* FIXME: gdbarch needs to control this variable.  */
 extern struct target_so_ops *current_target_so_ops;
-- 
2.13.6

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [RFA 1/4] Return unique_xmalloc_ptr from some solib.c functions
  2018-02-13 23:39 Remove a few more cleanups: solib and openp Tom Tromey
  2018-02-13 23:39 ` [RFA 4/4] Constify target_so_ops::bfd_open Tom Tromey
@ 2018-02-13 23:39 ` Tom Tromey
  2018-02-13 23:39 ` [RFA 3/4] Change openp et al to use a unique_xmalloc_ptr Tom Tromey
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Tom Tromey @ 2018-02-13 23:39 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes a couple of solib.c functions -- exec_file_find and
solib_find -- to return a unique_xmalloc_ptr, and then fixes up the
users.  This allows the removal of some cleanups.

This also changes solib_bfd_open to not take ownership of its
argument.  I think this change is somewhat cleaner.

gdb/ChangeLog
2018-02-13  Tom Tromey  <tom@tromey.com>

	* solist.h (exec_file_find, solib_find): Return
	unique_xmalloc_ptr.
	(solib_bfd_fopen): Take a const char *.
	* solib.c (solib_find_1): Return unique_xmalloc_ptr.
	(exec_file_find, solib_find): Likewise.
	(solib_bfd_fopen): Do not take ownership of "pathname".
	(solib_bfd_open): Use unique_xmalloc_ptr.
	* solib-darwin.c (darwin_bfd_open): Use unique_xmalloc_ptr.
	* solib-aix.c (solib_aix_bfd_open): Use unique_xmalloc_ptr.
	* infrun.c (follow_exec): Use unique_xmalloc_ptr.
	* exec.c (exec_file_locate_attach): Use unique_xmalloc_ptr.
---
 gdb/ChangeLog      | 14 ++++++++++++++
 gdb/exec.c         | 10 ++++------
 gdb/infrun.c       | 10 +++-------
 gdb/solib-aix.c    |  7 ++++---
 gdb/solib-darwin.c |  6 +++---
 gdb/solib.c        | 34 ++++++++++++++++------------------
 gdb/solist.h       |  8 +++++---
 7 files changed, 49 insertions(+), 40 deletions(-)

diff --git a/gdb/exec.c b/gdb/exec.c
index c8c32ecc27..15f85a278f 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -190,8 +190,7 @@ try_open_exec_file (const char *exec_file_host, struct inferior *inf,
 void
 exec_file_locate_attach (int pid, int defer_bp_reset, int from_tty)
 {
-  char *exec_file_target, *exec_file_host;
-  struct cleanup *old_chain;
+  char *exec_file_target;
   symfile_add_flags add_flags = 0;
 
   /* Do nothing if we already have an executable filename.  */
@@ -209,8 +208,8 @@ exec_file_locate_attach (int pid, int defer_bp_reset, int from_tty)
       return;
     }
 
-  exec_file_host = exec_file_find (exec_file_target, NULL);
-  old_chain = make_cleanup (xfree, exec_file_host);
+  gdb::unique_xmalloc_ptr<char> exec_file_host
+    = exec_file_find (exec_file_target, NULL);
 
   if (defer_bp_reset)
     add_flags |= SYMFILE_DEFER_BP_RESET;
@@ -219,8 +218,7 @@ exec_file_locate_attach (int pid, int defer_bp_reset, int from_tty)
     add_flags |= SYMFILE_VERBOSE;
 
   /* Attempt to open the exec file.  */
-  try_open_exec_file (exec_file_host, current_inferior (), add_flags);
-  do_cleanups (old_chain);
+  try_open_exec_file (exec_file_host.get (), current_inferior (), add_flags);
 }
 
 /* Set FILENAME as the new exec file.
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 45fe36a717..1bc860b6f3 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -1081,8 +1081,6 @@ follow_exec (ptid_t ptid, char *exec_file_target)
   struct inferior *inf = current_inferior ();
   int pid = ptid_get_pid (ptid);
   ptid_t process_ptid;
-  char *exec_file_host;
-  struct cleanup *old_chain;
 
   /* This is an exec event that we actually wish to pay attention to.
      Refresh our symbol table to the newly exec'd program, remove any
@@ -1161,8 +1159,8 @@ follow_exec (ptid_t ptid, char *exec_file_target)
 
   breakpoint_init_inferior (inf_execd);
 
-  exec_file_host = exec_file_find (exec_file_target, NULL);
-  old_chain = make_cleanup (xfree, exec_file_host);
+  gdb::unique_xmalloc_ptr<char> exec_file_host
+    = exec_file_find (exec_file_target, NULL);
 
   /* If we were unable to map the executable target pathname onto a host
      pathname, tell the user that.  Otherwise GDB's subsequent behavior
@@ -1216,9 +1214,7 @@ follow_exec (ptid_t ptid, char *exec_file_target)
      Executable) main symbol file will only be computed by
      solib_create_inferior_hook below.  breakpoint_re_set would fail
      to insert the breakpoints with the zero displacement.  */
-  try_open_exec_file (exec_file_host, inf, SYMFILE_DEFER_BP_RESET);
-
-  do_cleanups (old_chain);
+  try_open_exec_file (exec_file_host.get (), inf, SYMFILE_DEFER_BP_RESET);
 
   /* If the target can specify a description, read it.  Must do this
      after flipping to the new executable (because the target supplied
diff --git a/gdb/solib-aix.c b/gdb/solib-aix.c
index 463f060845..aa0e0d2dfb 100644
--- a/gdb/solib-aix.c
+++ b/gdb/solib-aix.c
@@ -614,7 +614,6 @@ solib_aix_bfd_open (char *pathname)
   char *sep;
   int filename_len;
   int found_file;
-  char *found_pathname;
 
   if (pathname[path_len - 1] != ')')
     return solib_bfd_open (pathname);
@@ -638,10 +637,12 @@ solib_aix_bfd_open (char *pathname)
   /* Calling solib_find makes certain that sysroot path is set properly
      if program has a dependency on .a archive and sysroot is set via
      set sysroot command.  */
-  found_pathname = solib_find (filename.c_str (), &found_file);
+  gdb::unique_xmalloc_ptr<char> found_pathname
+    = solib_find (filename.c_str (), &found_file);
   if (found_pathname == NULL)
       perror_with_name (pathname);
-  gdb_bfd_ref_ptr archive_bfd (solib_bfd_fopen (found_pathname, found_file));
+  gdb_bfd_ref_ptr archive_bfd (solib_bfd_fopen (found_pathname.get (),
+						found_file));
   if (archive_bfd == NULL)
     {
       warning (_("Could not open `%s' as an executable file: %s"),
diff --git a/gdb/solib-darwin.c b/gdb/solib-darwin.c
index 121a7135c0..ed8f9da257 100644
--- a/gdb/solib-darwin.c
+++ b/gdb/solib-darwin.c
@@ -619,16 +619,16 @@ darwin_lookup_lib_symbol (struct objfile *objfile,
 static gdb_bfd_ref_ptr
 darwin_bfd_open (char *pathname)
 {
-  char *found_pathname;
   int found_file;
 
   /* Search for shared library file.  */
-  found_pathname = solib_find (pathname, &found_file);
+  gdb::unique_xmalloc_ptr<char> found_pathname
+    = solib_find (pathname, &found_file);
   if (found_pathname == NULL)
     perror_with_name (pathname);
 
   /* Open bfd for shared library.  */
-  gdb_bfd_ref_ptr abfd (solib_bfd_fopen (found_pathname, found_file));
+  gdb_bfd_ref_ptr abfd (solib_bfd_fopen (found_pathname.get (), found_file));
 
   gdb_bfd_ref_ptr res
     (gdb_bfd_mach_o_fat_extract (abfd.get (), bfd_object,
diff --git a/gdb/solib.c b/gdb/solib.c
index 40fdfc59e6..46f2324c48 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -148,7 +148,7 @@ show_solib_search_path (struct ui_file *file, int from_tty,
    * machines since a sysroot will almost always be set.
 */
 
-static char *
+static gdb::unique_xmalloc_ptr<char>
 solib_find_1 (const char *in_pathname, int *fd, int is_solib)
 {
   const struct target_so_ops *ops = solib_ops (target_gdbarch ());
@@ -251,7 +251,7 @@ solib_find_1 (const char *in_pathname, int *fd, int is_solib)
     {
       if (fd != NULL)
 	*fd = -1;
-      return temp_pathname;
+      return gdb::unique_xmalloc_ptr<char> (temp_pathname);
     }
 
   /* Now see if we can open it.  */
@@ -367,7 +367,7 @@ solib_find_1 (const char *in_pathname, int *fd, int is_solib)
   else
     *fd = found_file;
 
-  return temp_pathname;
+  return gdb::unique_xmalloc_ptr<char> (temp_pathname);
 }
 
 /* Return the full pathname of the main executable, or NULL if not
@@ -375,10 +375,10 @@ solib_find_1 (const char *in_pathname, int *fd, int is_solib)
    the caller.  If FD is non-NULL, *FD is set to either -1 or an open
    file handle for the main executable.  */
 
-char *
+gdb::unique_xmalloc_ptr<char>
 exec_file_find (const char *in_pathname, int *fd)
 {
-  char *result;
+  gdb::unique_xmalloc_ptr<char> result;
   const char *fskind = effective_target_file_system_kind ();
 
   if (in_pathname == NULL)
@@ -409,8 +409,11 @@ exec_file_find (const char *in_pathname, int *fd)
 	 (If that fails, we'll just fall back on the original
 	 filename.  Not much more we can do...)  */
 
-      if (!source_full_path_of (in_pathname, &result))
-	result = xstrdup (in_pathname);
+      char *full_path = NULL;
+      if (source_full_path_of (in_pathname, &full_path))
+	result.reset (full_path);
+      else
+	result.reset (xstrdup (in_pathname));
       if (fd != NULL)
 	*fd = -1;
     }
@@ -426,7 +429,7 @@ exec_file_find (const char *in_pathname, int *fd)
    The search algorithm used is described in solib_find_1's comment
    above.  */
 
-char *
+gdb::unique_xmalloc_ptr<char>
 solib_find (const char *in_pathname, int *fd)
 {
   const char *solib_symbols_extension
@@ -463,12 +466,10 @@ solib_find (const char *in_pathname, int *fd)
    it is used as file handle to open the file.  Throws an error if the file
    could not be opened.  Handles both local and remote file access.
 
-   PATHNAME must be malloc'ed by the caller.  It will be freed by this
-   function.  If unsuccessful, the FD will be closed (unless FD was
-   -1).  */
+   If unsuccessful, the FD will be closed (unless FD was -1).  */
 
 gdb_bfd_ref_ptr
-solib_bfd_fopen (char *pathname, int fd)
+solib_bfd_fopen (const char *pathname, int fd)
 {
   gdb_bfd_ref_ptr abfd (gdb_bfd_open (pathname, gnutarget, fd));
 
@@ -478,13 +479,10 @@ solib_bfd_fopen (char *pathname, int fd)
   if (abfd == NULL)
     {
       /* Arrange to free PATHNAME when the error is thrown.  */
-      gdb::unique_xmalloc_ptr<char> free_pathname (pathname);
       error (_("Could not open `%s' as an executable file: %s"),
 	     pathname, bfd_errmsg (bfd_get_error ()));
     }
 
-  xfree (pathname);
-
   return abfd;
 }
 
@@ -493,12 +491,12 @@ solib_bfd_fopen (char *pathname, int fd)
 gdb_bfd_ref_ptr
 solib_bfd_open (char *pathname)
 {
-  char *found_pathname;
   int found_file;
   const struct bfd_arch_info *b;
 
   /* Search for shared library file.  */
-  found_pathname = solib_find (pathname, &found_file);
+  gdb::unique_xmalloc_ptr<char> found_pathname
+    = solib_find (pathname, &found_file);
   if (found_pathname == NULL)
     {
       /* Return failure if the file could not be found, so that we can
@@ -510,7 +508,7 @@ solib_bfd_open (char *pathname)
     }
 
   /* Open bfd for shared library.  */
-  gdb_bfd_ref_ptr abfd (solib_bfd_fopen (found_pathname, found_file));
+  gdb_bfd_ref_ptr abfd (solib_bfd_fopen (found_pathname.get (), found_file));
 
   /* Check bfd format.  */
   if (!bfd_check_format (abfd.get (), bfd_object))
diff --git a/gdb/solist.h b/gdb/solist.h
index 14459139e5..aba00ebb21 100644
--- a/gdb/solist.h
+++ b/gdb/solist.h
@@ -192,13 +192,15 @@ typedef std::unique_ptr<so_list, so_deleter> so_list_up;
 struct so_list *master_so_list (void);
 
 /* Find main executable binary file.  */
-extern char *exec_file_find (const char *in_pathname, int *fd);
+extern gdb::unique_xmalloc_ptr<char> exec_file_find (const char *in_pathname,
+						     int *fd);
 
 /* Find shared library binary file.  */
-extern char *solib_find (const char *in_pathname, int *fd);
+extern gdb::unique_xmalloc_ptr<char> solib_find (const char *in_pathname,
+						 int *fd);
 
 /* Open BFD for shared library file.  */
-extern gdb_bfd_ref_ptr solib_bfd_fopen (char *pathname, int fd);
+extern gdb_bfd_ref_ptr solib_bfd_fopen (const char *pathname, int fd);
 
 /* Find solib binary file and open it.  */
 extern gdb_bfd_ref_ptr solib_bfd_open (char *in_pathname);
-- 
2.13.6

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [RFA 3/4] Change openp et al to use a unique_xmalloc_ptr
  2018-02-13 23:39 Remove a few more cleanups: solib and openp Tom Tromey
  2018-02-13 23:39 ` [RFA 4/4] Constify target_so_ops::bfd_open Tom Tromey
  2018-02-13 23:39 ` [RFA 1/4] Return unique_xmalloc_ptr from some solib.c functions Tom Tromey
@ 2018-02-13 23:39 ` Tom Tromey
  2018-02-13 23:39 ` [RFA 2/4] Move some declarations to source.h Tom Tromey
  2018-02-14 13:55 ` Remove a few more cleanups: solib and openp Pedro Alves
  4 siblings, 0 replies; 7+ messages in thread
From: Tom Tromey @ 2018-02-13 23:39 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes openp, source_full_path_of, and find_and_open_source to
take a unique_xmalloc_ptr, rather than a char*, as an outgoing
argument type.  This simplifies the API, ownership-wise, and allows
for the removal of some cleanups.

2018-02-13  Tom Tromey  <tom@tromey.com>

	* symfile.c (symfile_bfd_open): Update.
	* source.h (openp, source_full_path_of, find_and_open_source):
	Change argument type to unique_xmalloc_ptr.
	* source.c (openp): Take a unique_xmalloc_ptr.
	(source_full_path_of, find_and_open_source): Likewise.
	(open_source_file, symtab_to_fullname): Update.
	* solist.h (struct target_so_ops) <find_and_open_solib>: Take a
	unique_xmalloc_ptr.
	* solib.c (solib_find_1): Use unique_xmalloc_ptr.
	(exec_file_find): Update.
	* psymtab.c (psymtab_to_fullname): Update.
	* nto-tdep.h (nto_find_and_open_solib): Update.
	* nto-tdep.c (nto_find_and_open_solib): Change temp_path to a
	unique_xmalloc_ptr.
	* exec.c (exec_file_attach): Update.
	* dwarf2read.c (try_open_dwop_file): Use unique_xmalloc_ptr.
	* cli/cli-cmds.c (find_and_open_script): Use unique_xmalloc_ptr.
---
 gdb/ChangeLog      | 20 +++++++++++++++++++
 gdb/cli/cli-cmds.c |  5 ++---
 gdb/dwarf2read.c   | 23 +++++++++++++---------
 gdb/exec.c         |  9 +++------
 gdb/nto-tdep.c     |  6 +++---
 gdb/nto-tdep.h     |  3 ++-
 gdb/psymtab.c      |  6 +++---
 gdb/solib.c        | 56 +++++++++++++++++++++++-------------------------------
 gdb/solist.h       |  3 ++-
 gdb/source.c       | 41 ++++++++++++++++++---------------------
 gdb/source.h       |  7 ++++---
 gdb/symfile.c      |  9 ++-------
 12 files changed, 98 insertions(+), 90 deletions(-)

diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index c3962e939e..95bd58ce54 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -506,10 +506,9 @@ find_and_open_script (const char *script_file, int search_path)
 
   /* Search for and open 'file' on the search path used for source
      files.  Put the full location in *FULL_PATHP.  */
-  char *temp_path;
+  gdb::unique_xmalloc_ptr<char> full_path;
   fd = openp (source_path, search_flags,
-	      file.get (), O_RDONLY, &temp_path);
-  gdb::unique_xmalloc_ptr<char> full_path (temp_path);
+	      file.get (), O_RDONLY, &full_path);
 
   if (fd == -1)
     return opened;
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 93453431c1..d6d3d4a20f 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -12881,35 +12881,40 @@ try_open_dwop_file (struct dwarf2_per_objfile *dwarf2_per_objfile,
 		    const char *file_name, int is_dwp, int search_cwd)
 {
   int desc;
-  char *absolute_name;
   /* Blech.  OPF_TRY_CWD_FIRST also disables searching the path list if
      FILE_NAME contains a '/'.  So we can't use it.  Instead prepend "."
      to debug_file_directory.  */
-  char *search_path;
+  const char *search_path;
   static const char dirname_separator_string[] = { DIRNAME_SEPARATOR, '\0' };
 
+  gdb::unique_xmalloc_ptr<char> search_path_holder;
   if (search_cwd)
     {
       if (*debug_file_directory != '\0')
-	search_path = concat (".", dirname_separator_string,
-			      debug_file_directory, (char *) NULL);
+	{
+	  search_path_holder.reset (concat (".", dirname_separator_string,
+					    debug_file_directory,
+					    (char *) NULL));
+	  search_path = search_path_holder.get ();
+	}
       else
-	search_path = xstrdup (".");
+	search_path = ".";
     }
   else
-    search_path = xstrdup (debug_file_directory);
+    search_path = debug_file_directory;
 
   openp_flags flags = OPF_RETURN_REALPATH;
   if (is_dwp)
     flags |= OPF_SEARCH_IN_PATH;
+
+  gdb::unique_xmalloc_ptr<char> absolute_name;
   desc = openp (search_path, flags, file_name,
 		O_RDONLY | O_BINARY, &absolute_name);
-  xfree (search_path);
   if (desc < 0)
     return NULL;
 
-  gdb_bfd_ref_ptr sym_bfd (gdb_bfd_open (absolute_name, gnutarget, desc));
-  xfree (absolute_name);
+  gdb_bfd_ref_ptr sym_bfd (gdb_bfd_open (absolute_name.get (),
+					 gnutarget, desc));
   if (sym_bfd == NULL)
     return NULL;
   bfd_set_cacheable (sym_bfd.get (), 1);
diff --git a/gdb/exec.c b/gdb/exec.c
index 79baf9c5fb..0b4237ff63 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -290,12 +290,10 @@ exec_file_attach (const char *filename, int from_tty)
 	}
       else
 	{
-	  char *temp_pathname;
-
 	  scratch_chan = openp (getenv ("PATH"), OPF_TRY_CWD_FIRST,
 				filename, write_files ?
 				O_RDWR | O_BINARY : O_RDONLY | O_BINARY,
-				&temp_pathname);
+				&scratch_storage);
 #if defined(__GO32__) || defined(_WIN32) || defined(__CYGWIN__)
 	  if (scratch_chan < 0)
 	    {
@@ -306,14 +304,13 @@ exec_file_attach (const char *filename, int from_tty)
 				    exename, write_files ?
 				    O_RDWR | O_BINARY
 				    : O_RDONLY | O_BINARY,
-				    &temp_pathname);
+				    &scratch_storage);
 	    }
 #endif
 	  if (scratch_chan < 0)
 	    perror_with_name (filename);
 
-	  scratch_storage.reset (temp_pathname);
-	  scratch_pathname = temp_pathname;
+	  scratch_pathname = scratch_storage.get ();
 
 	  /* gdb_bfd_open (and its variants) prefers canonicalized
 	     pathname for better BFD caching.  */
diff --git a/gdb/nto-tdep.c b/gdb/nto-tdep.c
index 30db99c759..8eb864b871 100644
--- a/gdb/nto-tdep.c
+++ b/gdb/nto-tdep.c
@@ -89,7 +89,7 @@ nto_map_arch_to_cputype (const char *arch)
 
 int
 nto_find_and_open_solib (const char *solib, unsigned o_flags,
-			 char **temp_pathname)
+			 gdb::unique_xmalloc_ptr<char> *temp_pathname)
 {
   char *buf, *arch_path, *nto_root;
   const char *endian;
@@ -143,9 +143,9 @@ nto_find_and_open_solib (const char *solib, unsigned o_flags,
       if (temp_pathname)
 	{
 	  if (ret >= 0)
-	    *temp_pathname = gdb_realpath (arch_path).release ();
+	    *temp_pathname = gdb_realpath (arch_path);
 	  else
-	    *temp_pathname = NULL;
+	    temp_pathname->reset (NULL);
 	}
     }
   return ret;
diff --git a/gdb/nto-tdep.h b/gdb/nto-tdep.h
index 4eaea48c5d..f82cad1306 100644
--- a/gdb/nto-tdep.h
+++ b/gdb/nto-tdep.h
@@ -170,7 +170,8 @@ void nto_relocate_section_addresses (struct so_list *,
 
 int nto_map_arch_to_cputype (const char *);
 
-int nto_find_and_open_solib (const char *, unsigned, char **);
+int nto_find_and_open_solib (const char *, unsigned,
+			     gdb::unique_xmalloc_ptr<char> *);
 
 enum gdb_osabi nto_elf_osabi_sniffer (bfd *abfd);
 
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index dc13fd560d..ac0ee0a5a6 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -1203,14 +1203,14 @@ psymtab_to_fullname (struct partial_symtab *ps)
      to handle cases like the file being moved.  */
   if (ps->fullname == NULL)
     {
-      int fd = find_and_open_source (ps->filename, ps->dirname, &ps->fullname);
+      gdb::unique_xmalloc_ptr<char> fullname;
+      int fd = find_and_open_source (ps->filename, ps->dirname, &fullname);
+      ps->fullname = fullname.release ();
 
       if (fd >= 0)
 	close (fd);
       else
 	{
-	  gdb::unique_xmalloc_ptr<char> fullname;
-
 	  /* rewrite_source_path would be applied by find_and_open_source, we
 	     should report the pathname where GDB tried to find the file.  */
 
diff --git a/gdb/solib.c b/gdb/solib.c
index c732df6150..c1bb227d3f 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -154,7 +154,7 @@ solib_find_1 (const char *in_pathname, int *fd, int is_solib)
 {
   const struct target_so_ops *ops = solib_ops (target_gdbarch ());
   int found_file = -1;
-  char *temp_pathname = NULL;
+  gdb::unique_xmalloc_ptr<char> temp_pathname;
   const char *fskind = effective_target_file_system_kind ();
   const char *sysroot = gdb_sysroot;
   int prefix_len, orig_prefix_len;
@@ -216,7 +216,7 @@ solib_find_1 (const char *in_pathname, int *fd, int is_solib)
   */
 
   if (!IS_TARGET_ABSOLUTE_PATH (fskind, in_pathname) || sysroot == NULL)
-    temp_pathname = xstrdup (in_pathname);
+    temp_pathname.reset (xstrdup (in_pathname));
   else
     {
       int need_dir_separator;
@@ -242,23 +242,21 @@ solib_find_1 (const char *in_pathname, int *fd, int is_solib)
 			     || strcmp (TARGET_SYSROOT_PREFIX, sysroot) == 0);
 
       /* Cat the prefixed pathname together.  */
-      temp_pathname = concat (sysroot,
-			      need_dir_separator ? SLASH_STRING : "",
-			      in_pathname, (char *) NULL);
+      temp_pathname.reset (concat (sysroot,
+				   need_dir_separator ? SLASH_STRING : "",
+				   in_pathname, (char *) NULL));
     }
 
   /* Handle files to be accessed via the target.  */
-  if (is_target_filename (temp_pathname))
+  if (is_target_filename (temp_pathname.get ()))
     {
       if (fd != NULL)
 	*fd = -1;
-      return gdb::unique_xmalloc_ptr<char> (temp_pathname);
+      return temp_pathname;
     }
 
   /* Now see if we can open it.  */
-  found_file = gdb_open_cloexec (temp_pathname, O_RDONLY | O_BINARY, 0);
-  if (found_file < 0)
-    xfree (temp_pathname);
+  found_file = gdb_open_cloexec (temp_pathname.get (), O_RDONLY | O_BINARY, 0);
 
   /* If the search in gdb_sysroot failed, and the path name has a
      drive spec (e.g, c:/foo), try stripping ':' from the drive spec,
@@ -270,33 +268,30 @@ solib_find_1 (const char *in_pathname, int *fd, int is_solib)
       && HAS_TARGET_DRIVE_SPEC (fskind, in_pathname))
     {
       int need_dir_separator = !IS_DIR_SEPARATOR (in_pathname[2]);
-      char *drive = savestring (in_pathname, 1);
+      char drive[2] = { in_pathname[0], '\0' };
 
-      temp_pathname = concat (sysroot,
-			      SLASH_STRING,
-			      drive,
-			      need_dir_separator ? SLASH_STRING : "",
-			      in_pathname + 2, (char *) NULL);
-      xfree (drive);
+      temp_pathname.reset (concat (sysroot,
+				   SLASH_STRING,
+				   drive,
+				   need_dir_separator ? SLASH_STRING : "",
+				   in_pathname + 2, (char *) NULL));
 
-      found_file = gdb_open_cloexec (temp_pathname, O_RDONLY | O_BINARY, 0);
+      found_file = gdb_open_cloexec (temp_pathname.get (),
+				     O_RDONLY | O_BINARY, 0);
       if (found_file < 0)
 	{
-	  xfree (temp_pathname);
-
 	  /* If the search in gdb_sysroot still failed, try fully
 	     stripping the drive spec, and trying once more in the
 	     sysroot before giving up.
 
 	     c:/foo/bar.dll ==> /sysroot/foo/bar.dll.  */
 
-	  temp_pathname = concat (sysroot,
-				  need_dir_separator ? SLASH_STRING : "",
-				  in_pathname + 2, (char *) NULL);
+	  temp_pathname.reset (concat (sysroot,
+				       need_dir_separator ? SLASH_STRING : "",
+				       in_pathname + 2, (char *) NULL));
 
-	  found_file = gdb_open_cloexec (temp_pathname, O_RDONLY | O_BINARY, 0);
-	  if (found_file < 0)
-	    xfree (temp_pathname);
+	  found_file = gdb_open_cloexec (temp_pathname.get (),
+					 O_RDONLY | O_BINARY, 0);
 	}
     }
 
@@ -306,7 +301,7 @@ solib_find_1 (const char *in_pathname, int *fd, int is_solib)
      needs to be freed.  */
 
   if (found_file < 0)
-    temp_pathname = NULL;
+    temp_pathname.reset (NULL);
 
   /* If the search in gdb_sysroot failed, and the path name is
      absolute at this point, make it relative.  (openp will try and open the
@@ -368,7 +363,7 @@ solib_find_1 (const char *in_pathname, int *fd, int is_solib)
   else
     *fd = found_file;
 
-  return gdb::unique_xmalloc_ptr<char> (temp_pathname);
+  return temp_pathname;
 }
 
 /* Return the full pathname of the main executable, or NULL if not
@@ -410,10 +405,7 @@ exec_file_find (const char *in_pathname, int *fd)
 	 (If that fails, we'll just fall back on the original
 	 filename.  Not much more we can do...)  */
 
-      char *full_path = NULL;
-      if (source_full_path_of (in_pathname, &full_path))
-	result.reset (full_path);
-      else
+      if (!source_full_path_of (in_pathname, &result))
 	result.reset (xstrdup (in_pathname));
       if (fd != NULL)
 	*fd = -1;
diff --git a/gdb/solist.h b/gdb/solist.h
index aba00ebb21..1df45e4d93 100644
--- a/gdb/solist.h
+++ b/gdb/solist.h
@@ -136,7 +136,8 @@ struct target_so_ops
        pointer to a malloc'd and realpath'd copy of SONAME is stored there,
        otherwise NULL is stored there.  */
     int (*find_and_open_solib) (const char *soname,
-        unsigned o_flags, char **temp_pathname);
+				unsigned o_flags,
+				gdb::unique_xmalloc_ptr<char> *temp_pathname);
 
     /* Hook for looking up global symbols in a library-specific way.  */
     struct block_symbol (*lookup_lib_global_symbol)
diff --git a/gdb/source.c b/gdb/source.c
index eba06f6e6b..8a27b2e666 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -737,7 +737,7 @@ is_regular_file (const char *name, int *errno_ptr)
     >>>>  eg executable, non-directory.  */
 int
 openp (const char *path, openp_flags opts, const char *string,
-       int mode, char **filename_opened)
+       int mode, gdb::unique_xmalloc_ptr<char> *filename_opened)
 {
   int fd;
   char *filename;
@@ -896,11 +896,11 @@ done:
     {
       /* If a file was opened, canonicalize its filename.  */
       if (fd < 0)
-	*filename_opened = NULL;
+	filename_opened->reset (NULL);
       else if ((opts & OPF_RETURN_REALPATH) != 0)
-	*filename_opened = gdb_realpath (filename).release ();
+	*filename_opened = gdb_realpath (filename);
       else
-	*filename_opened = gdb_abspath (filename).release ();
+	*filename_opened = gdb_abspath (filename);
     }
 
   errno = last_errno;
@@ -920,7 +920,8 @@ done:
 
    Else, this functions returns 0, and FULL_PATHNAME is set to NULL.  */
 int
-source_full_path_of (const char *filename, char **full_pathname)
+source_full_path_of (const char *filename,
+		     gdb::unique_xmalloc_ptr<char> *full_pathname)
 {
   int fd;
 
@@ -929,7 +930,7 @@ source_full_path_of (const char *filename, char **full_pathname)
 	      filename, O_RDONLY, full_pathname);
   if (fd < 0)
     {
-      *full_pathname = NULL;
+      full_pathname->reset (NULL);
       return 0;
     }
 
@@ -1011,7 +1012,7 @@ rewrite_source_path (const char *path)
 int
 find_and_open_source (const char *filename,
 		      const char *dirname,
-		      char **fullname)
+		      gdb::unique_xmalloc_ptr<char> *fullname)
 {
   char *path = source_path;
   const char *p;
@@ -1024,27 +1025,21 @@ find_and_open_source (const char *filename,
       /* The user may have requested that source paths be rewritten
          according to substitution rules he provided.  If a substitution
          rule applies to this path, then apply it.  */
-      char *rewritten_fullname = rewrite_source_path (*fullname).release ();
+      gdb::unique_xmalloc_ptr<char> rewritten_fullname
+	= rewrite_source_path (fullname->get ());
 
       if (rewritten_fullname != NULL)
-        {
-          xfree (*fullname);
-          *fullname = rewritten_fullname;
-        }
+	*fullname = std::move (rewritten_fullname);
 
-      result = gdb_open_cloexec (*fullname, OPEN_MODE, 0);
+      result = gdb_open_cloexec (fullname->get (), OPEN_MODE, 0);
       if (result >= 0)
 	{
-	  char *lpath = gdb_realpath (*fullname).release ();
-
-	  xfree (*fullname);
-	  *fullname = lpath;
+	  *fullname = gdb_realpath (fullname->get ());
 	  return result;
 	}
 
       /* Didn't work -- free old one, try again.  */
-      xfree (*fullname);
-      *fullname = NULL;
+      fullname->reset (NULL);
     }
 
   gdb::unique_xmalloc_ptr<char> rewritten_dirname;
@@ -1115,7 +1110,10 @@ open_source_file (struct symtab *s)
   if (!s)
     return -1;
 
-  return find_and_open_source (s->filename, SYMTAB_DIRNAME (s), &s->fullname);
+  gdb::unique_xmalloc_ptr<char> fullname;
+  int fd = find_and_open_source (s->filename, SYMTAB_DIRNAME (s), &fullname);
+  s->fullname = fullname.release ();
+  return fd;
 }
 
 /* Finds the fullname that a symtab represents.
@@ -1135,8 +1133,7 @@ symtab_to_fullname (struct symtab *s)
      to handle cases like the file being moved.  */
   if (s->fullname == NULL)
     {
-      int fd = find_and_open_source (s->filename, SYMTAB_DIRNAME (s),
-				     &s->fullname);
+      int fd = open_source_file (s);
 
       if (fd >= 0)
 	close (fd);
diff --git a/gdb/source.h b/gdb/source.h
index a21e919b28..a8769506a0 100644
--- a/gdb/source.h
+++ b/gdb/source.h
@@ -32,9 +32,10 @@ enum openp_flag
 
 DEF_ENUM_FLAGS_TYPE(openp_flag, openp_flags);
 
-extern int openp (const char *, openp_flags, const char *, int, char **);
+extern int openp (const char *, openp_flags, const char *, int,
+		  gdb::unique_xmalloc_ptr<char> *);
 
-extern int source_full_path_of (const char *, char **);
+extern int source_full_path_of (const char *, gdb::unique_xmalloc_ptr<char> *);
 
 extern void mod_path (const char *, char **);
 
@@ -67,7 +68,7 @@ extern void init_source_path (void);
      FULLNAME is set to NULL.  */
 extern int find_and_open_source (const char *filename,
 				 const char *dirname,
-				 char **fullname);
+				 gdb::unique_xmalloc_ptr<char> *fullname);
 
 /* Open a source file given a symtab S.  Returns a file descriptor or
    negative number for error.  */
diff --git a/gdb/symfile.c b/gdb/symfile.c
index ab6ec1cdad..699d9e6fe0 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -1719,12 +1719,10 @@ gdb_bfd_ref_ptr
 symfile_bfd_open (const char *name)
 {
   int desc = -1;
-  struct cleanup *back_to = make_cleanup (null_cleanup, 0);
 
+  gdb::unique_xmalloc_ptr<char> absolute_name;
   if (!is_target_filename (name))
     {
-      char *absolute_name;
-
       gdb::unique_xmalloc_ptr<char> expanded_name (tilde_expand (name));
 
       /* Look down path for it, allocate 2nd new malloc'd copy.  */
@@ -1745,8 +1743,7 @@ symfile_bfd_open (const char *name)
       if (desc < 0)
 	perror_with_name (expanded_name.get ());
 
-      make_cleanup (xfree, absolute_name);
-      name = absolute_name;
+      name = absolute_name.get ();
     }
 
   gdb_bfd_ref_ptr sym_bfd (gdb_bfd_open (name, gnutarget, desc));
@@ -1761,8 +1758,6 @@ symfile_bfd_open (const char *name)
     error (_("`%s': can't read symbols: %s."), name,
 	   bfd_errmsg (bfd_get_error ()));
 
-  do_cleanups (back_to);
-
   return sym_bfd;
 }
 
-- 
2.13.6

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Remove a few more cleanups: solib and openp
@ 2018-02-13 23:39 Tom Tromey
  2018-02-13 23:39 ` [RFA 4/4] Constify target_so_ops::bfd_open Tom Tromey
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Tom Tromey @ 2018-02-13 23:39 UTC (permalink / raw)
  To: gdb-patches

This series removes a few cleanups by using unique_xmalloc_ptr.  This
also helps clarify the ownership rules of a few APIs.  This series
also includes a couple of minor (non-cleanup-related) code clarity
improvements in related areas: moving some declarations out of defs.h,
and a constification.

Regression tested by the buildbot.

Tom

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Remove a few more cleanups: solib and openp
  2018-02-13 23:39 Remove a few more cleanups: solib and openp Tom Tromey
                   ` (3 preceding siblings ...)
  2018-02-13 23:39 ` [RFA 2/4] Move some declarations to source.h Tom Tromey
@ 2018-02-14 13:55 ` Pedro Alves
  2018-02-14 15:03   ` Tom Tromey
  4 siblings, 1 reply; 7+ messages in thread
From: Pedro Alves @ 2018-02-14 13:55 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 02/13/2018 11:39 PM, Tom Tromey wrote:
> This series removes a few cleanups by using unique_xmalloc_ptr.  This
> also helps clarify the ownership rules of a few APIs.  This series
> also includes a couple of minor (non-cleanup-related) code clarity
> improvements in related areas: moving some declarations out of defs.h,
> and a constification.
> 
> Regression tested by the buildbot.

Nice!  LGTM.  Please push.

I was wondering whether you'd write patch #1 the other day you
touched some of that code.  :-)  On that patch, you may want to remove
the  "The returned pathname is malloc'ed and must be freed by the caller."
remarks from the intro comments of (at least) solib_find_1,
exec_file_find and solib_find (in solib.c).

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Remove a few more cleanups: solib and openp
  2018-02-14 13:55 ` Remove a few more cleanups: solib and openp Pedro Alves
@ 2018-02-14 15:03   ` Tom Tromey
  0 siblings, 0 replies; 7+ messages in thread
From: Tom Tromey @ 2018-02-14 15:03 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Tom Tromey, gdb-patches

>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:

Pedro> I was wondering whether you'd write patch #1 the other day you
Pedro> touched some of that code.  :-)

What happened is that I did that, it tweaked a memory, and I dug up
these patches from a branch I had lying around.

Pedro> On that patch, you may want to remove
Pedro> the  "The returned pathname is malloc'ed and must be freed by the caller."
Pedro> remarks from the intro comments of (at least) solib_find_1,
Pedro> exec_file_find and solib_find (in solib.c).

Will do, thanks.

Tom

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-02-14 15:03 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-13 23:39 Remove a few more cleanups: solib and openp Tom Tromey
2018-02-13 23:39 ` [RFA 4/4] Constify target_so_ops::bfd_open Tom Tromey
2018-02-13 23:39 ` [RFA 1/4] Return unique_xmalloc_ptr from some solib.c functions Tom Tromey
2018-02-13 23:39 ` [RFA 3/4] Change openp et al to use a unique_xmalloc_ptr Tom Tromey
2018-02-13 23:39 ` [RFA 2/4] Move some declarations to source.h Tom Tromey
2018-02-14 13:55 ` Remove a few more cleanups: solib and openp Pedro Alves
2018-02-14 15:03   ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).