public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 3/5] Make program_space::deleted_solibs a vector of std::string
  2018-02-25 16:32 [PATCH 1/5] Make delim_string_to_char_ptr_vec return an std::vector Simon Marchi
  2018-02-25 16:32 ` [PATCH 4/5] C++ify charsets Simon Marchi
@ 2018-02-25 16:32 ` Simon Marchi
  2018-02-25 16:33 ` [PATCH 5/5] Remove free_char_ptr_vec Simon Marchi
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Simon Marchi @ 2018-02-25 16:32 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

This allows removing a usage of free_char_ptr_vec.

gdb/ChangeLog:

	* progspace.h (struct program_space) <deleted_solibs>: Change
	type to std::vector<std::string>.
	* progspace.c (clear_program_space_solib_cache): Adjust.
	* breakpoint.c (print_solib_event): Adjust.
	(check_status_catch_solib): Adjust.
	* solib.c (update_solib_list): Adjust.
	* ui-out.h (class ui_out) <field_string>: New overload.
	* ui-out.c (ui_out::field_string): New overload.
---
 gdb/breakpoint.c | 25 +++++++------------------
 gdb/progspace.c  |  3 +--
 gdb/progspace.h  |  2 +-
 gdb/solib.c      |  3 +--
 gdb/ui-out.c     |  6 ++++++
 gdb/ui-out.h     |  1 +
 6 files changed, 17 insertions(+), 23 deletions(-)

diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index c56084cce3..454fda7684 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -4604,8 +4604,7 @@ print_bp_stop_message (bpstat bs)
 static void
 print_solib_event (int is_catchpoint)
 {
-  int any_deleted
-    = !VEC_empty (char_ptr, current_program_space->deleted_solibs);
+  bool any_deleted = !current_program_space->deleted_solibs.empty ();
   int any_added
     = !VEC_empty (so_list_ptr, current_program_space->added_solibs);
 
@@ -4624,16 +4623,12 @@ print_solib_event (int is_catchpoint)
 
   if (any_deleted)
     {
-      char *name;
-      int ix;
-
       current_uiout->text (_("  Inferior unloaded "));
       ui_out_emit_list list_emitter (current_uiout, "removed");
-      for (ix = 0;
-	   VEC_iterate (char_ptr, current_program_space->deleted_solibs,
-			ix, name);
-	   ++ix)
+      for (int ix = 0; ix < current_program_space->deleted_solibs.size (); ix++)
 	{
+	  const std::string &name = current_program_space->deleted_solibs[ix];
+
 	  if (ix > 0)
 	    current_uiout->text ("    ");
 	  current_uiout->field_string ("library", name);
@@ -8050,13 +8045,12 @@ check_status_catch_solib (struct bpstats *bs)
 {
   struct solib_catchpoint *self
     = (struct solib_catchpoint *) bs->breakpoint_at;
-  int ix;
 
   if (self->is_load)
     {
       struct so_list *iter;
 
-      for (ix = 0;
+      for (int ix = 0;
 	   VEC_iterate (so_list_ptr, current_program_space->added_solibs,
 			ix, iter);
 	   ++ix)
@@ -8068,15 +8062,10 @@ check_status_catch_solib (struct bpstats *bs)
     }
   else
     {
-      char *iter;
-
-      for (ix = 0;
-	   VEC_iterate (char_ptr, current_program_space->deleted_solibs,
-			ix, iter);
-	   ++ix)
+      for (const std::string &iter : current_program_space->deleted_solibs)
 	{
 	  if (!self->regex
-	      || self->compiled->exec (iter, 0, NULL, 0) == 0)
+	      || self->compiled->exec (iter.c_str (), 0, NULL, 0) == 0)
 	    return;
 	}
     }
diff --git a/gdb/progspace.c b/gdb/progspace.c
index f6da7e7da2..e0bcc5a18d 100644
--- a/gdb/progspace.c
+++ b/gdb/progspace.c
@@ -401,8 +401,7 @@ clear_program_space_solib_cache (struct program_space *pspace)
 {
   VEC_free (so_list_ptr, pspace->added_solibs);
 
-  free_char_ptr_vec (pspace->deleted_solibs);
-  pspace->deleted_solibs = NULL;
+  pspace->deleted_solibs.clear ();
 }
 
 \f
diff --git a/gdb/progspace.h b/gdb/progspace.h
index c64209c5df..67c0a240da 100644
--- a/gdb/progspace.h
+++ b/gdb/progspace.h
@@ -207,7 +207,7 @@ struct program_space
 
   /* When an solib is removed, its name is added to this vector.
      This is so we can properly report solib changes to the user.  */
-  VEC (char_ptr) *deleted_solibs = NULL;
+  std::vector<std::string> deleted_solibs;
 
   /* Per pspace data-pointers required by other GDB modules.  */
   REGISTRY_FIELDS {};
diff --git a/gdb/solib.c b/gdb/solib.c
index f3eea399e0..1c78845938 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -828,8 +828,7 @@ update_solib_list (int from_tty)
 	     unloaded before we remove it from GDB's tables.  */
 	  observer_notify_solib_unloaded (gdb);
 
-	  VEC_safe_push (char_ptr, current_program_space->deleted_solibs,
-			 xstrdup (gdb->so_name));
+	  current_program_space->deleted_solibs.push_back (gdb->so_name);
 
 	  *gdb_link = gdb->next;
 
diff --git a/gdb/ui-out.c b/gdb/ui-out.c
index 8785bfbfa6..0340a44a83 100644
--- a/gdb/ui-out.c
+++ b/gdb/ui-out.c
@@ -552,6 +552,12 @@ ui_out::field_string (const char *fldname, const char *string)
   do_field_string (fldno, width, align, fldname, string);
 }
 
+void
+ui_out::field_string (const char *fldname, const std::string &string)
+{
+  field_string (fldname, string.c_str ());
+}
+
 /* VARARGS */
 void
 ui_out::field_fmt (const char *fldname, const char *format, ...)
diff --git a/gdb/ui-out.h b/gdb/ui-out.h
index ce224ed225..1708542e7e 100644
--- a/gdb/ui-out.h
+++ b/gdb/ui-out.h
@@ -104,6 +104,7 @@ class ui_out
   void field_core_addr (const char *fldname, struct gdbarch *gdbarch,
 			CORE_ADDR address);
   void field_string (const char *fldname, const char *string);
+  void field_string (const char *fldname, const std::string &string);
   void field_stream (const char *fldname, string_file &stream);
   void field_skip (const char *fldname);
   void field_fmt (const char *fldname, const char *format, ...)
-- 
2.16.1

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

* [PATCH 1/5] Make delim_string_to_char_ptr_vec return an std::vector
@ 2018-02-25 16:32 Simon Marchi
  2018-02-25 16:32 ` [PATCH 4/5] C++ify charsets Simon Marchi
                   ` (5 more replies)
  0 siblings, 6 replies; 10+ messages in thread
From: Simon Marchi @ 2018-02-25 16:32 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

This patch makes delim_string_to_char_ptr_vec and all related functions
use std::vector of gdb::unique_xmalloc_ptr.  This allows getting rid of
make_cleanup_free_char_ptr_vec.  Returning a vector of
unique_xmalloc_ptr instead of std::string allows to minimize the impacts
on the calling code.  We can evaluate later whether we could/should
return a vector of std::strings instead.

gdb/ChangeLog:

	* common/gdb_vecs.h (make_cleanup_free_char_ptr_vec): Remove.
	(delim_string_to_char_ptr_vec): Return std::vector of
	gdb::unique_xmalloc_ptr.
	(dirnames_to_char_ptr_vec_append): Take std::vector of
	gdb::unique_xmalloc_ptr.
	(dirnames_to_char_ptr_vec): Return std::vector of
	gdb::unique_xmalloc_ptr.
	* common/gdb_vecs.c (delim_string_to_char_ptr_vec_append):
	Take std::vector of gdb::unique_xmalloc_ptr, adjust the code.
	(delim_string_to_char_ptr_vec): Return an std::vector of
	gdb::unique_xmalloc_ptr, adjust the code.
	(dirnames_to_char_ptr_vec_append): Take an std::vector of
	gdb::unique_xmalloc_ptr, adjust the code.
	(dirnames_to_char_ptr_vec): Return an std::vector of
	gdb::unique_xmalloc_ptr, adjust the code.
	* auto-load.c (auto_load_safe_path_vec): Change type to
	std::vector of gdb::unique_xmalloc_ptr.
	(auto_load_expand_dir_vars): Return an std::vector of
	gdb::unique_xmalloc_ptr, adjust the code.
	(auto_load_safe_path_vec_update): Adjust.
	(filename_is_in_auto_load_safe_path_vec): Adjust.
	(auto_load_objfile_script_1): Adjust.
	* build-id.c (build_id_to_debug_bfd): Adjust.
	* linux-thread-db.c (thread_db_load_search): Adjust.
	* source.c (add_path): Adjust.
	(openp): Adjust.
	* symfile.c (find_separate_debug_file): Adjust.
	* utils.c (do_free_char_ptr_vec): Remove.
	(make_cleanup_free_char_ptr_vec): Remove.

gdb/gdbserver/ChangeLog:

	* server.c (parse_debug_format_options): Adjust to
	delim_string_to_char_ptr_vec changes.
	* thread-db.c (thread_db_load_search): Adjust to
	dirnames_to_char_ptr_vec changes.
---
 gdb/auto-load.c           | 81 ++++++++++++++++++++++-------------------------
 gdb/build-id.c            | 13 +++-----
 gdb/common/gdb_vecs.c     | 36 ++++++++-------------
 gdb/common/gdb_vecs.h     | 24 ++++++++++----
 gdb/gdbserver/server.c    | 29 ++++++-----------
 gdb/gdbserver/thread-db.c | 11 +++----
 gdb/linux-thread-db.c     | 13 +++-----
 gdb/source.c              | 24 ++++++--------
 gdb/symfile.c             | 25 ++++-----------
 gdb/utils.c               | 24 --------------
 10 files changed, 109 insertions(+), 171 deletions(-)

diff --git a/gdb/auto-load.c b/gdb/auto-load.c
index b79341faf6..b0fd626d91 100644
--- a/gdb/auto-load.c
+++ b/gdb/auto-load.c
@@ -168,19 +168,15 @@ static char *auto_load_safe_path;
 /* Vector of directory elements of AUTO_LOAD_SAFE_PATH with each one normalized
    by tilde_expand and possibly each entries has added its gdb_realpath
    counterpart.  */
-static VEC (char_ptr) *auto_load_safe_path_vec;
+std::vector<gdb::unique_xmalloc_ptr<char>> auto_load_safe_path_vec;
 
 /* Expand $datadir and $debugdir in STRING according to the rules of
-   substitute_path_component.  Return vector from dirnames_to_char_ptr_vec,
-   this vector must be freed by free_char_ptr_vec by the caller.  */
+   substitute_path_component.  */
 
-static VEC (char_ptr) *
+static std::vector<gdb::unique_xmalloc_ptr<char>>
 auto_load_expand_dir_vars (const char *string)
 {
-  VEC (char_ptr) *dir_vec;
-  char *s;
-
-  s = xstrdup (string);
+  char *s = xstrdup (string);
   substitute_path_component (&s, "$datadir", gdb_datadir);
   substitute_path_component (&s, "$debugdir", debug_file_directory);
 
@@ -188,7 +184,8 @@ auto_load_expand_dir_vars (const char *string)
     fprintf_unfiltered (gdb_stdlog,
 			_("auto-load: Expanded $-variables to \"%s\".\n"), s);
 
-  dir_vec = dirnames_to_char_ptr_vec (s);
+  std::vector<gdb::unique_xmalloc_ptr<char>> dir_vec
+    = dirnames_to_char_ptr_vec (s);
   xfree(s);
 
   return dir_vec;
@@ -207,46 +204,42 @@ auto_load_safe_path_vec_update (void)
 			_("auto-load: Updating directories of \"%s\".\n"),
 			auto_load_safe_path);
 
-  free_char_ptr_vec (auto_load_safe_path_vec);
-
   auto_load_safe_path_vec = auto_load_expand_dir_vars (auto_load_safe_path);
-  len = VEC_length (char_ptr, auto_load_safe_path_vec);
 
   /* Apply tilde_expand and gdb_realpath to each AUTO_LOAD_SAFE_PATH_VEC
      element.  */
-  for (ix = 0; ix < len; ix++)
+  for (gdb::unique_xmalloc_ptr<char> &in_vec : auto_load_safe_path_vec)
     {
-      char *dir = VEC_index (char_ptr, auto_load_safe_path_vec, ix);
-      char *expanded = tilde_expand (dir);
-      gdb::unique_xmalloc_ptr<char> real_path = gdb_realpath (expanded);
+      gdb::unique_xmalloc_ptr<char> expanded (tilde_expand (in_vec.get ()));
+      gdb::unique_xmalloc_ptr<char> real_path = gdb_realpath (expanded.get ());
 
-      /* Ensure the current entry is at least tilde_expand-ed.  */
-      VEC_replace (char_ptr, auto_load_safe_path_vec, ix, expanded);
+      /* Ensure the current entry is at least tilde_expand-ed.  ORIGINAL makes
+	 sure we free the original string.  */
+      gdb::unique_xmalloc_ptr<char> original = std::move (in_vec);
+      in_vec = std::move (expanded);
 
       if (debug_auto_load)
 	{
-	  if (strcmp (expanded, dir) == 0)
+	  if (strcmp (in_vec.get (), original.get ()) == 0)
 	    fprintf_unfiltered (gdb_stdlog,
 				_("auto-load: Using directory \"%s\".\n"),
-				expanded);
+				in_vec.get ());
 	  else
 	    fprintf_unfiltered (gdb_stdlog,
 				_("auto-load: Resolved directory \"%s\" "
 				  "as \"%s\".\n"),
-				dir, expanded);
+				original.get (), in_vec.get ());
 	}
-      xfree (dir);
 
       /* If gdb_realpath returns a different content, append it.  */
-      if (strcmp (real_path.get (), expanded) != 0)
+      if (strcmp (real_path.get (), in_vec.get ()) != 0)
 	{
 	  if (debug_auto_load)
 	    fprintf_unfiltered (gdb_stdlog,
 				_("auto-load: And canonicalized as \"%s\".\n"),
 				real_path.get ());
 
-	  VEC_safe_push (char_ptr, auto_load_safe_path_vec,
-			 real_path.release ());
+	  auto_load_safe_path_vec.push_back (std::move (real_path));
 	}
     }
 }
@@ -425,13 +418,14 @@ static int
 filename_is_in_auto_load_safe_path_vec (const char *filename,
 					gdb::unique_xmalloc_ptr<char> *filename_realp)
 {
-  char *pattern;
-  int ix;
+  const char *pattern = NULL;
 
-  for (ix = 0; VEC_iterate (char_ptr, auto_load_safe_path_vec, ix, pattern);
-       ++ix)
-    if (*filename_realp == NULL && filename_is_in_pattern (filename, pattern))
-      break;
+  for (const gdb::unique_xmalloc_ptr<char> &p : auto_load_safe_path_vec)
+    if (*filename_realp == NULL && filename_is_in_pattern (filename, p.get ()))
+      {
+	pattern = p.get ();
+	break;
+      }
   
   if (pattern == NULL)
     {
@@ -446,10 +440,12 @@ filename_is_in_auto_load_safe_path_vec (const char *filename,
 	}
 
       if (strcmp (filename_realp->get (), filename) != 0)
-	for (ix = 0;
-	     VEC_iterate (char_ptr, auto_load_safe_path_vec, ix, pattern); ++ix)
-	  if (filename_is_in_pattern (filename_realp->get (), pattern))
-	    break;
+	for (const gdb::unique_xmalloc_ptr<char> &p : auto_load_safe_path_vec)
+	  if (filename_is_in_pattern (filename_realp->get (), p.get ()))
+	    {
+	      pattern = p.get ();
+	      break;
+	    }
     }
 
   if (pattern != NULL)
@@ -792,25 +788,22 @@ auto_load_objfile_script_1 (struct objfile *objfile, const char *realname,
 
   if (!input)
     {
-      VEC (char_ptr) *vec;
-      int ix;
-      char *dir;
-
       /* Also try the same file in a subdirectory of gdb's data
 	 directory.  */
 
-      vec = auto_load_expand_dir_vars (auto_load_dir);
-      make_cleanup_free_char_ptr_vec (vec);
+      std::vector<gdb::unique_xmalloc_ptr<char>> vec
+	= auto_load_expand_dir_vars (auto_load_dir);
 
       if (debug_auto_load)
 	fprintf_unfiltered (gdb_stdlog, _("auto-load: Searching 'set auto-load "
 					  "scripts-directory' path \"%s\".\n"),
 			    auto_load_dir);
 
-      for (ix = 0; VEC_iterate (char_ptr, vec, ix, dir); ++ix)
+      for (const gdb::unique_xmalloc_ptr<char> &dir : vec)
 	{
-	  debugfile = (char *) xmalloc (strlen (dir) + strlen (filename) + 1);
-	  strcpy (debugfile, dir);
+	  debugfile = (char *) xmalloc (strlen (dir.get ())
+					+ strlen (filename) + 1);
+	  strcpy (debugfile, dir.get ());
 
 	  /* FILENAME is absolute, so we don't need a "/" here.  */
 	  strcat (debugfile, filename);
diff --git a/gdb/build-id.c b/gdb/build-id.c
index 685a2b0370..57d98c9618 100644
--- a/gdb/build-id.c
+++ b/gdb/build-id.c
@@ -71,8 +71,6 @@ gdb_bfd_ref_ptr
 build_id_to_debug_bfd (size_t build_id_len, const bfd_byte *build_id)
 {
   char *link, *debugdir;
-  VEC (char_ptr) *debugdir_vec;
-  struct cleanup *back_to;
   int ix;
   gdb_bfd_ref_ptr abfd;
   int alloc_len;
@@ -86,17 +84,17 @@ build_id_to_debug_bfd (size_t build_id_len, const bfd_byte *build_id)
   /* Keep backward compatibility so that DEBUG_FILE_DIRECTORY being "" will
      cause "/.build-id/..." lookups.  */
 
-  debugdir_vec = dirnames_to_char_ptr_vec (debug_file_directory);
-  back_to = make_cleanup_free_char_ptr_vec (debugdir_vec);
+  std::vector<gdb::unique_xmalloc_ptr<char>> debugdir_vec
+    = dirnames_to_char_ptr_vec (debug_file_directory);
 
-  for (ix = 0; VEC_iterate (char_ptr, debugdir_vec, ix, debugdir); ++ix)
+  for (const gdb::unique_xmalloc_ptr<char> &debugdir : debugdir_vec)
     {
-      size_t debugdir_len = strlen (debugdir);
+      size_t debugdir_len = strlen (debugdir.get ());
       const gdb_byte *data = build_id;
       size_t size = build_id_len;
       char *s;
 
-      memcpy (link, debugdir, debugdir_len);
+      memcpy (link, debugdir.get (), debugdir_len);
       s = &link[debugdir_len];
       s += sprintf (s, "/.build-id/");
       if (size > 0)
@@ -133,7 +131,6 @@ build_id_to_debug_bfd (size_t build_id_len, const bfd_byte *build_id)
       abfd.release ();
     }
 
-  do_cleanups (back_to);
   return abfd;
 }
 
diff --git a/gdb/common/gdb_vecs.c b/gdb/common/gdb_vecs.c
index a221460625..a19d238b3e 100644
--- a/gdb/common/gdb_vecs.c
+++ b/gdb/common/gdb_vecs.c
@@ -40,11 +40,12 @@ free_char_ptr_vec (VEC (char_ptr) *char_ptr_vec)
 }
 
 /* Worker function to split character delimiter separated string of fields
-   STR into a CHAR_PTR_VEC.  */
+   STR into a char pointer vector.  */
 
 static void
-delim_string_to_char_ptr_vec_append (VEC (char_ptr) **vecp,
-				     const char *str, char delimiter)
+delim_string_to_char_ptr_vec_append
+  (std::vector<gdb::unique_xmalloc_ptr<char>> *vecp, const char *str,
+   char delimiter)
 {
   do
     {
@@ -64,49 +65,40 @@ delim_string_to_char_ptr_vec_append (VEC (char_ptr) **vecp,
       this_field = (char *) xmalloc (this_len + 1);
       memcpy (this_field, str, this_len);
       this_field[this_len] = '\0';
-      VEC_safe_push (char_ptr, *vecp, this_field);
+      vecp->emplace_back (this_field);
 
       str = next_field;
     }
   while (str != NULL);
 }
 
-/* Split STR, a list of DELIMITER-separated fields, into a CHAR_PTR_VEC.
+/* See gdb_vecs.h.  */
 
-   You may modify the returned strings.
-   Read free_char_ptr_vec for its cleanup.  */
-
-VEC (char_ptr) *
+std::vector<gdb::unique_xmalloc_ptr<char>>
 delim_string_to_char_ptr_vec (const char *str, char delimiter)
 {
-  VEC (char_ptr) *retval = NULL;
+  std::vector<gdb::unique_xmalloc_ptr<char>> retval;
   
   delim_string_to_char_ptr_vec_append (&retval, str, delimiter);
 
   return retval;
 }
 
-/* Extended version of dirnames_to_char_ptr_vec - additionally if *VECP is
-   non-NULL the new list elements from DIRNAMES are appended to the existing
-   *VECP list of entries.  *VECP address will be updated by this call.  */
+/* See gdb_vecs.h.  */
 
 void
-dirnames_to_char_ptr_vec_append (VEC (char_ptr) **vecp, const char *dirnames)
+dirnames_to_char_ptr_vec_append
+  (std::vector<gdb::unique_xmalloc_ptr<char>> *vecp, const char *dirnames)
 {
   delim_string_to_char_ptr_vec_append (vecp, dirnames, DIRNAME_SEPARATOR);
 }
 
-/* Split DIRNAMES by DIRNAME_SEPARATOR delimiter and return a list of all the
-   elements in their original order.  For empty string ("") DIRNAMES return
-   list of one empty string ("") element.
-   
-   You may modify the returned strings.
-   Read free_char_ptr_vec for its cleanup.  */
+/* See gdb_vecs.h.  */
 
-VEC (char_ptr) *
+std::vector<gdb::unique_xmalloc_ptr<char>>
 dirnames_to_char_ptr_vec (const char *dirnames)
 {
-  VEC (char_ptr) *retval = NULL;
+  std::vector<gdb::unique_xmalloc_ptr<char>> retval;
   
   dirnames_to_char_ptr_vec_append (&retval, dirnames);
 
diff --git a/gdb/common/gdb_vecs.h b/gdb/common/gdb_vecs.h
index 75caf59c00..17ed06c253 100644
--- a/gdb/common/gdb_vecs.h
+++ b/gdb/common/gdb_vecs.h
@@ -31,15 +31,25 @@ DEF_VEC_P (const_char_ptr);
 
 extern void free_char_ptr_vec (VEC (char_ptr) *char_ptr_vec);
 
-extern struct cleanup *
-  make_cleanup_free_char_ptr_vec (VEC (char_ptr) *char_ptr_vec);
+/* Split STR, a list of DELIMITER-separated fields, into a char pointer vector.
 
-extern VEC (char_ptr) *delim_string_to_char_ptr_vec (const char *str,
-						     char delimiter);
+   You may modify the returned strings.  */
 
-extern void dirnames_to_char_ptr_vec_append (VEC (char_ptr) **vecp,
-					     const char *dirnames);
+extern std::vector<gdb::unique_xmalloc_ptr<char>>
+  delim_string_to_char_ptr_vec (const char *str, char delimiter);
 
-extern VEC (char_ptr) *dirnames_to_char_ptr_vec (const char *dirnames);
+/* Like dirnames_to_char_ptr_vec, but append the directories to *VECP.  */
+
+extern void dirnames_to_char_ptr_vec_append
+  (std::vector<gdb::unique_xmalloc_ptr<char>> *vecp, const char *dirnames);
+
+/* Split DIRNAMES by DIRNAME_SEPARATOR delimiter and return a list of all the
+   elements in their original order.  For empty string ("") DIRNAMES return
+   list of one empty string ("") element.
+
+   You may modify the returned strings.  */
+
+extern std::vector<gdb::unique_xmalloc_ptr<char>>
+  dirnames_to_char_ptr_vec (const char *dirnames);
 
 #endif /* GDB_VECS_H */
diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index cb02b58507..bfb639570f 100644
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -1275,8 +1275,8 @@ handle_detach (char *own_buf)
    ARG is the text after "--debug-format=" or "monitor set debug-format".
    IS_MONITOR is non-zero if we're invoked via "monitor set debug-format".
    This triggers calls to monitor_output.
-   The result is NULL if all options were parsed ok, otherwise an error
-   message which the caller must free.
+   The result is an empty string if all options were parsed ok, otherwise an
+   error message which the caller must free.
 
    N.B. These commands affect all debug format settings, they are not
    cumulative.  If a format is not specified, it is turned off.
@@ -1291,10 +1291,6 @@ handle_detach (char *own_buf)
 static std::string
 parse_debug_format_options (const char *arg, int is_monitor)
 {
-  VEC (char_ptr) *options;
-  int ix;
-  char *option;
-
   /* First turn all debug format options off.  */
   debug_timestamp = 0;
 
@@ -1302,23 +1298,24 @@ parse_debug_format_options (const char *arg, int is_monitor)
   while (isspace (*arg))
     ++arg;
 
-  options = delim_string_to_char_ptr_vec (arg, ',');
+  std::vector<gdb::unique_xmalloc_ptr<char>> options
+    = delim_string_to_char_ptr_vec (arg, ',');
 
-  for (ix = 0; VEC_iterate (char_ptr, options, ix, option); ++ix)
+  for (const gdb::unique_xmalloc_ptr<char> &option : options)
     {
-      if (strcmp (option, "all") == 0)
+      if (strcmp (option.get (), "all") == 0)
 	{
 	  debug_timestamp = 1;
 	  if (is_monitor)
 	    monitor_output ("All extra debug format options enabled.\n");
 	}
-      else if (strcmp (option, "none") == 0)
+      else if (strcmp (option.get (), "none") == 0)
 	{
 	  debug_timestamp = 0;
 	  if (is_monitor)
 	    monitor_output ("All extra debug format options disabled.\n");
 	}
-      else if (strcmp (option, "timestamp") == 0)
+      else if (strcmp (option.get (), "timestamp") == 0)
 	{
 	  debug_timestamp = 1;
 	  if (is_monitor)
@@ -1330,16 +1327,10 @@ parse_debug_format_options (const char *arg, int is_monitor)
 	  continue;
 	}
       else
-	{
-	  std::string msg
-	    = string_printf ("Unknown debug-format argument: \"%s\"\n", option);
-
-	  free_char_ptr_vec (options);
-	  return msg;
-	}
+	return string_printf ("Unknown debug-format argument: \"%s\"\n",
+			      option.get ());
     }
 
-  free_char_ptr_vec (options);
   return std::string ();
 }
 
diff --git a/gdb/gdbserver/thread-db.c b/gdb/gdbserver/thread-db.c
index 812aa0f61f..7dda2edba0 100644
--- a/gdb/gdbserver/thread-db.c
+++ b/gdb/gdbserver/thread-db.c
@@ -683,17 +683,17 @@ try_thread_db_load_from_dir (const char *dir, size_t dir_len)
 static int
 thread_db_load_search (void)
 {
-  VEC (char_ptr) *dir_vec;
-  char *this_dir;
-  int i, rc = 0;
+  int rc = 0;
 
   if (libthread_db_search_path == NULL)
     libthread_db_search_path = xstrdup (LIBTHREAD_DB_SEARCH_PATH);
 
-  dir_vec = dirnames_to_char_ptr_vec (libthread_db_search_path);
+  std::vector<gdb::unique_xmalloc_ptr<char>> dir_vec
+    = dirnames_to_char_ptr_vec (libthread_db_search_path);
 
-  for (i = 0; VEC_iterate (char_ptr, dir_vec, i, this_dir); ++i)
+  for (const gdb::unique_xmalloc_ptr<char> &this_dir_up : dir_vec)
     {
+      char *this_dir = this_dir_up.get ();
       const int pdir_len = sizeof ("$pdir") - 1;
       size_t this_dir_len;
 
@@ -725,7 +725,6 @@ thread_db_load_search (void)
 	}
     }
 
-  free_char_ptr_vec (dir_vec);
   if (debug_threads)
     debug_printf ("thread_db_load_search returning %d\n", rc);
   return rc;
diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c
index 5ba4c03df6..8217201fe5 100644
--- a/gdb/linux-thread-db.c
+++ b/gdb/linux-thread-db.c
@@ -803,16 +803,14 @@ try_thread_db_load_from_dir (const char *dir, size_t dir_len)
 static int
 thread_db_load_search (void)
 {
-  VEC (char_ptr) *dir_vec;
-  struct cleanup *cleanups;
-  char *this_dir;
-  int i, rc = 0;
+  int rc = 0;
 
-  dir_vec = dirnames_to_char_ptr_vec (libthread_db_search_path);
-  cleanups = make_cleanup_free_char_ptr_vec (dir_vec);
+  std::vector<gdb::unique_xmalloc_ptr<char>> dir_vec
+    = dirnames_to_char_ptr_vec (libthread_db_search_path);
 
-  for (i = 0; VEC_iterate (char_ptr, dir_vec, i, this_dir); ++i)
+  for (const gdb::unique_xmalloc_ptr<char> &this_dir_up : dir_vec)
     {
+      const char *this_dir = this_dir_up.get ();
       const int pdir_len = sizeof ("$pdir") - 1;
       size_t this_dir_len;
 
@@ -852,7 +850,6 @@ thread_db_load_search (void)
 	}
     }
 
-  do_cleanups (cleanups);
   if (libthread_db_debug)
     fprintf_unfiltered (gdb_stdlog,
 			_("thread_db_load_search returning %d\n"), rc);
diff --git a/gdb/source.c b/gdb/source.c
index 8a27b2e666..cea613cb31 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -461,10 +461,7 @@ add_path (const char *dirname, char **which_path, int parse_separators)
 {
   char *old = *which_path;
   int prefix = 0;
-  VEC (char_ptr) *dir_vec = NULL;
-  struct cleanup *back_to;
-  int ix;
-  char *name;
+  std::vector<gdb::unique_xmalloc_ptr<char>> dir_vec;
 
   if (dirname == 0)
     return;
@@ -479,11 +476,13 @@ add_path (const char *dirname, char **which_path, int parse_separators)
 	dirnames_to_char_ptr_vec_append (&dir_vec, arg);
     }
   else
-    VEC_safe_push (char_ptr, dir_vec, xstrdup (dirname));
-  back_to = make_cleanup_free_char_ptr_vec (dir_vec);
+    dir_vec.emplace_back (xstrdup (dirname));
 
-  for (ix = 0; VEC_iterate (char_ptr, dir_vec, ix, name); ++ix)
+  struct cleanup *back_to = make_cleanup (null_cleanup, NULL);
+
+  for (const gdb::unique_xmalloc_ptr<char> &name_up : dir_vec)
     {
+      char *name = name_up.get ();
       char *p;
       struct stat st;
 
@@ -742,13 +741,10 @@ openp (const char *path, openp_flags opts, const char *string,
   int fd;
   char *filename;
   int alloclen;
-  VEC (char_ptr) *dir_vec;
-  struct cleanup *back_to;
-  int ix;
-  char *dir;
   /* The errno set for the last name we tried to open (and
      failed).  */
   int last_errno = 0;
+  std::vector<gdb::unique_xmalloc_ptr<char>> dir_vec;
 
   /* The open syscall MODE parameter is not specified.  */
   gdb_assert ((mode & O_CREAT) == 0);
@@ -816,10 +812,10 @@ openp (const char *path, openp_flags opts, const char *string,
   last_errno = ENOENT;
 
   dir_vec = dirnames_to_char_ptr_vec (path);
-  back_to = make_cleanup_free_char_ptr_vec (dir_vec);
 
-  for (ix = 0; VEC_iterate (char_ptr, dir_vec, ix, dir); ++ix)
+  for (const gdb::unique_xmalloc_ptr<char> &dir_up : dir_vec)
     {
+      char *dir = dir_up.get ();
       size_t len = strlen (dir);
       int reg_file_errno;
 
@@ -889,8 +885,6 @@ openp (const char *path, openp_flags opts, const char *string,
 	last_errno = reg_file_errno;
     }
 
-  do_cleanups (back_to);
-
 done:
   if (filename_opened)
     {
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 699d9e6fe0..866e533723 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -1439,12 +1439,8 @@ find_separate_debug_file (const char *dir,
 			  const char *debuglink,
 			  unsigned long crc32, struct objfile *objfile)
 {
-  char *debugdir;
   char *debugfile;
   int i;
-  VEC (char_ptr) *debugdir_vec;
-  struct cleanup *back_to;
-  int ix;
 
   if (separate_debug_file_debug)
     printf_unfiltered (_("\nLooking for separate debug info (debug link) for "
@@ -1484,21 +1480,18 @@ find_separate_debug_file (const char *dir,
      Keep backward compatibility so that DEBUG_FILE_DIRECTORY being "" will
      cause "/..." lookups.  */
 
-  debugdir_vec = dirnames_to_char_ptr_vec (debug_file_directory);
-  back_to = make_cleanup_free_char_ptr_vec (debugdir_vec);
+  std::vector<gdb::unique_xmalloc_ptr<char>> debugdir_vec
+    = dirnames_to_char_ptr_vec (debug_file_directory);
 
-  for (ix = 0; VEC_iterate (char_ptr, debugdir_vec, ix, debugdir); ++ix)
+  for (const gdb::unique_xmalloc_ptr<char> &debugdir : debugdir_vec)
     {
-      strcpy (debugfile, debugdir);
+      strcpy (debugfile, debugdir.get ());
       strcat (debugfile, "/");
       strcat (debugfile, dir);
       strcat (debugfile, debuglink);
 
       if (separate_debug_file_exists (debugfile, crc32, objfile))
-	{
-	  do_cleanups (back_to);
-	  return debugfile;
-	}
+	return debugfile;
 
       /* If the file is in the sysroot, try using its base path in the
 	 global debugfile directory.  */
@@ -1507,20 +1500,16 @@ find_separate_debug_file (const char *dir,
 			    strlen (gdb_sysroot)) == 0
 	  && IS_DIR_SEPARATOR (canon_dir[strlen (gdb_sysroot)]))
 	{
-	  strcpy (debugfile, debugdir);
+	  strcpy (debugfile, debugdir.get ());
 	  strcat (debugfile, canon_dir + strlen (gdb_sysroot));
 	  strcat (debugfile, "/");
 	  strcat (debugfile, debuglink);
 
 	  if (separate_debug_file_exists (debugfile, crc32, objfile))
-	    {
-	      do_cleanups (back_to);
-	      return debugfile;
-	    }
+	    return debugfile;
 	}
     }
 
-  do_cleanups (back_to);
   xfree (debugfile);
   return NULL;
 }
diff --git a/gdb/utils.c b/gdb/utils.c
index c531748fe4..269b8803d1 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -3170,30 +3170,6 @@ make_bpstat_clear_actions_cleanup (void)
   return make_cleanup (do_bpstat_clear_actions_cleanup, NULL);
 }
 
-
-/* Helper for make_cleanup_free_char_ptr_vec.  */
-
-static void
-do_free_char_ptr_vec (void *arg)
-{
-  VEC (char_ptr) *char_ptr_vec = (VEC (char_ptr) *) arg;
-
-  free_char_ptr_vec (char_ptr_vec);
-}
-
-/* Make cleanup handler calling xfree for each element of CHAR_PTR_VEC and
-   final VEC_free for CHAR_PTR_VEC itself.
-
-   You must not modify CHAR_PTR_VEC after this cleanup registration as the
-   CHAR_PTR_VEC base address may change on its updates.  Contrary to VEC_free
-   this function does not (cannot) clear the pointer.  */
-
-struct cleanup *
-make_cleanup_free_char_ptr_vec (VEC (char_ptr) *char_ptr_vec)
-{
-  return make_cleanup (do_free_char_ptr_vec, char_ptr_vec);
-}
-
 /* Substitute all occurences of string FROM by string TO in *STRINGP.  *STRINGP
    must come from xrealloc-compatible allocator and it may be updated.  FROM
    needs to be delimited by IS_DIR_SEPARATOR or DIRNAME_SEPARATOR (or be
-- 
2.16.1

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

* [PATCH 4/5] C++ify charsets
  2018-02-25 16:32 [PATCH 1/5] Make delim_string_to_char_ptr_vec return an std::vector Simon Marchi
@ 2018-02-25 16:32 ` Simon Marchi
  2018-02-25 16:32 ` [PATCH 3/5] Make program_space::deleted_solibs a vector of std::string Simon Marchi
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Simon Marchi @ 2018-02-25 16:32 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

This patch makes the charset list an std::vector instead of a VEC.
Because we must have access to the raw pointers as a simple array, we
can't use a vector of unique_ptr/unique_xmalloc_ptr.  Therefore, wrap
the vector in a simple class to facilitate the cleanup.  This allows
removing one usage of free_char_ptr_vec.

gdb/ChangeLog:

	* charset.c (struct charset_vector): New.
	(charsets): Change type to charset_vector.
	(find_charset_names): Adjust.
	(add_one): Adjust.
	(_initialize_charset): Adjust.
---
 gdb/charset.c | 46 +++++++++++++++++++++++++++++-----------------
 1 file changed, 29 insertions(+), 17 deletions(-)

diff --git a/gdb/charset.c b/gdb/charset.c
index 98a51794fb..fcb24a4882 100644
--- a/gdb/charset.c
+++ b/gdb/charset.c
@@ -705,21 +705,33 @@ wchar_iterator::iterate (enum wchar_iterate_result *out_result,
   return -1;
 }
 
-/* The charset.c module initialization function.  */
+struct charset_vector
+{
+  ~charset_vector ()
+  {
+    clear ();
+  }
+
+  void clear ()
+  {
+    for (char *c : charsets)
+      xfree (c);
 
-static VEC (char_ptr) *charsets;
+    charsets.clear ();
+  }
+
+  std::vector<char *> charsets;
+};
+
+static charset_vector charsets;
 
 #ifdef PHONY_ICONV
 
 static void
 find_charset_names (void)
 {
-  /* Cast is fine here, because CHARSETS is never released.  Note that
-     the vec does not hold "const char *" pointers instead of "char *"
-     because the non-phony version stores heap-allocated strings in
-     it.  */
-  VEC_safe_push (char_ptr, charsets, (char *) GDB_DEFAULT_HOST_CHARSET);
-  VEC_safe_push (char_ptr, charsets, NULL);
+  charsets.charsets.push_back (xstrdup (GDB_DEFAULT_HOST_CHARSET));
+  charsets.charsets.push_back (NULL);
 }
 
 #else /* PHONY_ICONV */
@@ -740,7 +752,7 @@ add_one (unsigned int count, const char *const *names, void *data)
   unsigned int i;
 
   for (i = 0; i < count; ++i)
-    VEC_safe_push (char_ptr, charsets, xstrdup (names[i]));
+    charsets.charsets.push_back (xstrdup (names[i]));
 
   return 0;
 }
@@ -749,7 +761,8 @@ static void
 find_charset_names (void)
 {
   iconvlist (add_one, NULL);
-  VEC_safe_push (char_ptr, charsets, NULL);
+
+  charsets.charsets.push_back (NULL);
 }
 
 #else
@@ -879,7 +892,7 @@ find_charset_names (void)
 		break;
 	      keep_going = *p;
 	      *p = '\0';
-	      VEC_safe_push (char_ptr, charsets, xstrdup (start));
+	      charsets.charsets.push_back (xstrdup (start));
 	      if (!keep_going)
 		break;
 	      /* Skip any extra spaces.  */
@@ -900,11 +913,10 @@ find_charset_names (void)
   if (fail)
     {
       /* Some error occurred, so drop the vector.  */
-      free_char_ptr_vec (charsets);
-      charsets = NULL;
+      charsets.clear ();
     }
   else
-    VEC_safe_push (char_ptr, charsets, NULL);
+    charsets.charsets.push_back (NULL);
 }
 
 #endif /* HAVE_ICONVLIST || HAVE_LIBICONVLIST */
@@ -994,11 +1006,11 @@ void
 _initialize_charset (void)
 {
   /* The first element is always "auto".  */
-  VEC_safe_push (char_ptr, charsets, xstrdup ("auto"));
+  charsets.charsets.push_back (xstrdup ("auto"));
   find_charset_names ();
 
-  if (VEC_length (char_ptr, charsets) > 1)
-    charset_enum = (const char **) VEC_address (char_ptr, charsets);
+  if (charsets.charsets.size () > 1)
+    charset_enum = (const char **) charsets.charsets.data ();
   else
     charset_enum = default_charset_names;
 
-- 
2.16.1

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

* [PATCH 5/5] Remove free_char_ptr_vec
  2018-02-25 16:32 [PATCH 1/5] Make delim_string_to_char_ptr_vec return an std::vector Simon Marchi
  2018-02-25 16:32 ` [PATCH 4/5] C++ify charsets Simon Marchi
  2018-02-25 16:32 ` [PATCH 3/5] Make program_space::deleted_solibs a vector of std::string Simon Marchi
@ 2018-02-25 16:33 ` Simon Marchi
  2018-02-25 16:47 ` [PATCH 2/5] C++ify program_space Simon Marchi
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Simon Marchi @ 2018-02-25 16:33 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

Nothing is using it anymore.

gdb/ChangeLog:

	* common/gdb_vecs.c (free_char_ptr_vec): Remove.
	* common/gdb_vecs.h (free_char_ptr_vec): Remove.
---
 gdb/common/gdb_vecs.c | 18 ------------------
 gdb/common/gdb_vecs.h |  2 --
 2 files changed, 20 deletions(-)

diff --git a/gdb/common/gdb_vecs.c b/gdb/common/gdb_vecs.c
index a19d238b3e..445793e420 100644
--- a/gdb/common/gdb_vecs.c
+++ b/gdb/common/gdb_vecs.c
@@ -21,24 +21,6 @@
 #include "gdb_vecs.h"
 #include "host-defs.h"
 
-/* Call xfree for each element of CHAR_PTR_VEC and final VEC_free for
-   CHAR_PTR_VEC itself.
-
-   You must not modify CHAR_PTR_VEC after it got registered with this function
-   by make_cleanup as the CHAR_PTR_VEC base address may change on its updates.
-   Contrary to VEC_free this function does not (cannot) clear the pointer.  */
-
-void
-free_char_ptr_vec (VEC (char_ptr) *char_ptr_vec)
-{
-  int ix;
-  char *name;
-
-  for (ix = 0; VEC_iterate (char_ptr, char_ptr_vec, ix, name); ++ix)
-    xfree (name);
-  VEC_free (char_ptr, char_ptr_vec);
-}
-
 /* Worker function to split character delimiter separated string of fields
    STR into a char pointer vector.  */
 
diff --git a/gdb/common/gdb_vecs.h b/gdb/common/gdb_vecs.h
index 17ed06c253..29db27a892 100644
--- a/gdb/common/gdb_vecs.h
+++ b/gdb/common/gdb_vecs.h
@@ -29,8 +29,6 @@ DEF_VEC_P (char_ptr);
 
 DEF_VEC_P (const_char_ptr);
 
-extern void free_char_ptr_vec (VEC (char_ptr) *char_ptr_vec);
-
 /* Split STR, a list of DELIMITER-separated fields, into a char pointer vector.
 
    You may modify the returned strings.  */
-- 
2.16.1

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

* [PATCH 2/5] C++ify program_space
  2018-02-25 16:32 [PATCH 1/5] Make delim_string_to_char_ptr_vec return an std::vector Simon Marchi
                   ` (2 preceding siblings ...)
  2018-02-25 16:33 ` [PATCH 5/5] Remove free_char_ptr_vec Simon Marchi
@ 2018-02-25 16:47 ` Simon Marchi
  2018-03-03  4:23 ` [PATCH 1/5] Make delim_string_to_char_ptr_vec return an std::vector Simon Marchi
  2018-04-10 19:58 ` Regression with -D_GLIBCXX_DEBUG [Re: [PATCH 1/5] Make delim_string_to_char_ptr_vec return an std::vector] Jan Kratochvil
  5 siblings, 0 replies; 10+ messages in thread
From: Simon Marchi @ 2018-02-25 16:47 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

This patch makes program_space a C++ object by adding a
constructor/destructor, giving default values to fields, and using
new/delete.

gdb/ChangeLog:

	* progspace.h (struct program_space): Add constructor and
	destructor, initialize fields.
	(add_program_space): Remove.
	* progspace.c (add_program_space): Rename to...
	(program_space::program_space): ... this.
	(release_program_space): Rename to...
	(program_space::~program_space): ... this.
	(delete_program_space): Use delete to delete program_space.
	(initialize_progspace): Use new to allocate program_space.
	* inferior.c (add_inferior_with_spaces): Likewise.
	(clone_inferior_command): Likewise.
	* infrun.c (follow_fork_inferior): Likewise.
	(handle_vfork_child_exec_or_exit): Likewise.
---
 gdb/inferior.c  |   4 +-
 gdb/infrun.c    |   8 +--
 gdb/progspace.c |  41 ++++++---------
 gdb/progspace.h | 155 ++++++++++++++++++++++++++++----------------------------
 4 files changed, 98 insertions(+), 110 deletions(-)

diff --git a/gdb/inferior.c b/gdb/inferior.c
index 880f25df0e..c88a23c241 100644
--- a/gdb/inferior.c
+++ b/gdb/inferior.c
@@ -784,7 +784,7 @@ add_inferior_with_spaces (void)
      doesn't really return a new address space; otherwise, it
      really does.  */
   aspace = maybe_new_address_space ();
-  pspace = add_program_space (aspace);
+  pspace = new program_space (aspace);
   inf = add_inferior (0);
   inf->pspace = pspace;
   inf->aspace = pspace->aspace;
@@ -928,7 +928,7 @@ clone_inferior_command (const char *args, int from_tty)
 	 doesn't really return a new address space; otherwise, it
 	 really does.  */
       aspace = maybe_new_address_space ();
-      pspace = add_program_space (aspace);
+      pspace = new program_space (aspace);
       inf = add_inferior (0);
       inf->pspace = pspace;
       inf->aspace = pspace->aspace;
diff --git a/gdb/infrun.c b/gdb/infrun.c
index c663908568..5aeafef08b 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -511,7 +511,7 @@ holding the child stopped.  Try \"set detach-on-fork\" or \
 	  else
 	    {
 	      child_inf->aspace = new_address_space ();
-	      child_inf->pspace = add_program_space (child_inf->aspace);
+	      child_inf->pspace = new program_space (child_inf->aspace);
 	      child_inf->removable = 1;
 	      set_current_program_space (child_inf->pspace);
 	      clone_program_space (child_inf->pspace, parent_inf->pspace);
@@ -630,7 +630,7 @@ holding the child stopped.  Try \"set detach-on-fork\" or \
       else
 	{
 	  child_inf->aspace = new_address_space ();
-	  child_inf->pspace = add_program_space (child_inf->aspace);
+	  child_inf->pspace = new program_space (child_inf->aspace);
 	  child_inf->removable = 1;
 	  child_inf->symfile_flags = SYMFILE_NO_READ;
 	  set_current_program_space (child_inf->pspace);
@@ -986,7 +986,7 @@ handle_vfork_child_exec_or_exit (int exec)
 	{
 	  /* We're staying attached to the parent, so, really give the
 	     child a new address space.  */
-	  inf->pspace = add_program_space (maybe_new_address_space ());
+	  inf->pspace = new program_space (maybe_new_address_space ());
 	  inf->aspace = inf->pspace->aspace;
 	  inf->removable = 1;
 	  set_current_program_space (inf->pspace);
@@ -1020,7 +1020,7 @@ handle_vfork_child_exec_or_exit (int exec)
 	     program space resets breakpoints).  */
 	  inf->aspace = NULL;
 	  inf->pspace = NULL;
-	  pspace = add_program_space (maybe_new_address_space ());
+	  pspace = new program_space (maybe_new_address_space ());
 	  set_current_program_space (pspace);
 	  inf->removable = 1;
 	  inf->symfile_flags = SYMFILE_NO_READ;
diff --git a/gdb/progspace.c b/gdb/progspace.c
index 08a8a7a88e..f6da7e7da2 100644
--- a/gdb/progspace.c
+++ b/gdb/progspace.c
@@ -109,30 +109,21 @@ init_address_spaces (void)
 /* Adds a new empty program space to the program space list, and binds
    it to ASPACE.  Returns the pointer to the new object.  */
 
-struct program_space *
-add_program_space (struct address_space *aspace)
+program_space::program_space (address_space *aspace_)
+: num (++last_program_space_num), aspace (aspace_)
 {
-  struct program_space *pspace;
-
-  pspace = XCNEW (struct program_space);
-
-  pspace->num = ++last_program_space_num;
-  pspace->aspace = aspace;
-
-  program_space_alloc_data (pspace);
+  program_space_alloc_data (this);
 
   if (program_spaces == NULL)
-    program_spaces = pspace;
+    program_spaces = this;
   else
     {
       struct program_space *last;
 
       for (last = program_spaces; last->next != NULL; last = last->next)
 	;
-      last->next = pspace;
+      last->next = this;
     }
-
-  return pspace;
 }
 
 /* Releases program space PSPACE, and all its contents (shared
@@ -141,26 +132,24 @@ add_program_space (struct address_space *aspace)
    is the current program space, since there should always be a
    program space.  */
 
-static void
-release_program_space (struct program_space *pspace)
+program_space::~program_space ()
 {
-  gdb_assert (pspace != current_program_space);
+  gdb_assert (this != current_program_space);
 
   scoped_restore_current_program_space restore_pspace;
 
-  set_current_program_space (pspace);
+  set_current_program_space (this);
 
-  breakpoint_program_space_exit (pspace);
+  breakpoint_program_space_exit (this);
   no_shared_libraries (NULL, 0);
   exec_close ();
   free_all_objfiles ();
   if (!gdbarch_has_shared_address_space (target_gdbarch ()))
-    free_address_space (pspace->aspace);
-  clear_section_table (&pspace->target_sections);
-  clear_program_space_solib_cache (pspace);
+    free_address_space (this->aspace);
+  clear_section_table (&this->target_sections);
+  clear_program_space_solib_cache (this);
     /* Discard any data modules have associated with the PSPACE.  */
-  program_space_free_data (pspace);
-  xfree (pspace);
+  program_space_free_data (this);
 }
 
 /* Copies program space SRC to DEST.  Copies the main executable file,
@@ -235,7 +224,7 @@ delete_program_space (struct program_space *pspace)
       ss = *ss_link;
     }
 
-  release_program_space (pspace);
+  delete pspace;
 }
 
 /* Prints the list of program spaces and their details on UIOUT.  If
@@ -433,5 +422,5 @@ initialize_progspace (void)
      modules have done that.  Do this before
      initialize_current_architecture, because that accesses exec_bfd,
      which in turn dereferences current_program_space.  */
-  current_program_space = add_program_space (new_address_space ());
+  current_program_space = new program_space (new_address_space ());
 }
diff --git a/gdb/progspace.h b/gdb/progspace.h
index 73929c9e96..c64209c5df 100644
--- a/gdb/progspace.h
+++ b/gdb/progspace.h
@@ -135,80 +135,83 @@ DEF_VEC_P (so_list_ptr);
 /* The program space structure.  */
 
 struct program_space
-  {
-    /* Pointer to next in linked list.  */
-    struct program_space *next;
-
-    /* Unique ID number.  */
-    int num;
-
-    /* The main executable loaded into this program space.  This is
-       managed by the exec target.  */
-
-    /* The BFD handle for the main executable.  */
-    bfd *ebfd;
-    /* The last-modified time, from when the exec was brought in.  */
-    long ebfd_mtime;
-    /* Similar to bfd_get_filename (exec_bfd) but in original form given
-       by user, without symbolic links and pathname resolved.
-       It needs to be freed by xfree.  It is not NULL iff EBFD is not NULL.  */
-    char *pspace_exec_filename;
-
-    /* The address space attached to this program space.  More than one
-       program space may be bound to the same address space.  In the
-       traditional unix-like debugging scenario, this will usually
-       match the address space bound to the inferior, and is mostly
-       used by the breakpoints module for address matches.  If the
-       target shares a program space for all inferiors and breakpoints
-       are global, then this field is ignored (we don't currently
-       support inferiors sharing a program space if the target doesn't
-       make breakpoints global).  */
-    struct address_space *aspace;
-
-    /* True if this program space's section offsets don't yet represent
-       the final offsets of the "live" address space (that is, the
-       section addresses still require the relocation offsets to be
-       applied, and hence we can't trust the section addresses for
-       anything that pokes at live memory).  E.g., for qOffsets
-       targets, or for PIE executables, until we connect and ask the
-       target for the final relocation offsets, the symbols we've used
-       to set breakpoints point at the wrong addresses.  */
-    int executing_startup;
-
-    /* True if no breakpoints should be inserted in this program
-       space.  */
-    int breakpoints_not_allowed;
-
-    /* The object file that the main symbol table was loaded from
-       (e.g. the argument to the "symbol-file" or "file" command).  */
-    struct objfile *symfile_object_file;
-
-    /* All known objfiles are kept in a linked list.  This points to
-       the head of this list.  */
-    struct objfile *objfiles;
-
-    /* The set of target sections matching the sections mapped into
-       this program space.  Managed by both exec_ops and solib.c.  */
-    struct target_section_table target_sections;
-
-    /* List of shared objects mapped into this space.  Managed by
-       solib.c.  */
-    struct so_list *so_list;
-
-    /* Number of calls to solib_add.  */
-    unsigned solib_add_generation;
-
-    /* When an solib is added, it is also added to this vector.  This
-       is so we can properly report solib changes to the user.  */
-    VEC (so_list_ptr) *added_solibs;
-
-    /* When an solib is removed, its name is added to this vector.
-       This is so we can properly report solib changes to the user.  */
-    VEC (char_ptr) *deleted_solibs;
-
-    /* Per pspace data-pointers required by other GDB modules.  */
-    REGISTRY_FIELDS;
-  };
+{
+  program_space (address_space *aspace_);
+  ~program_space ();
+
+  /* Pointer to next in linked list.  */
+  struct program_space *next = NULL;
+
+  /* Unique ID number.  */
+  int num = 0;
+
+  /* The main executable loaded into this program space.  This is
+     managed by the exec target.  */
+
+  /* The BFD handle for the main executable.  */
+  bfd *ebfd = NULL;
+  /* The last-modified time, from when the exec was brought in.  */
+  long ebfd_mtime = 0;
+  /* Similar to bfd_get_filename (exec_bfd) but in original form given
+     by user, without symbolic links and pathname resolved.
+     It needs to be freed by xfree.  It is not NULL iff EBFD is not NULL.  */
+  char *pspace_exec_filename = NULL;
+
+  /* The address space attached to this program space.  More than one
+     program space may be bound to the same address space.  In the
+     traditional unix-like debugging scenario, this will usually
+     match the address space bound to the inferior, and is mostly
+     used by the breakpoints module for address matches.  If the
+     target shares a program space for all inferiors and breakpoints
+     are global, then this field is ignored (we don't currently
+     support inferiors sharing a program space if the target doesn't
+     make breakpoints global).  */
+  struct address_space *aspace = NULL;
+
+  /* True if this program space's section offsets don't yet represent
+     the final offsets of the "live" address space (that is, the
+     section addresses still require the relocation offsets to be
+     applied, and hence we can't trust the section addresses for
+     anything that pokes at live memory).  E.g., for qOffsets
+     targets, or for PIE executables, until we connect and ask the
+     target for the final relocation offsets, the symbols we've used
+     to set breakpoints point at the wrong addresses.  */
+  int executing_startup = 0;
+
+  /* True if no breakpoints should be inserted in this program
+     space.  */
+  int breakpoints_not_allowed = 0;
+
+  /* The object file that the main symbol table was loaded from
+     (e.g. the argument to the "symbol-file" or "file" command).  */
+  struct objfile *symfile_object_file = NULL;
+
+  /* All known objfiles are kept in a linked list.  This points to
+     the head of this list.  */
+  struct objfile *objfiles = NULL;
+
+  /* The set of target sections matching the sections mapped into
+     this program space.  Managed by both exec_ops and solib.c.  */
+  struct target_section_table target_sections {};
+
+  /* List of shared objects mapped into this space.  Managed by
+     solib.c.  */
+  struct so_list *so_list = NULL;
+
+  /* Number of calls to solib_add.  */
+  unsigned int solib_add_generation = 0;
+
+  /* When an solib is added, it is also added to this vector.  This
+     is so we can properly report solib changes to the user.  */
+  VEC (so_list_ptr) *added_solibs = NULL;
+
+  /* When an solib is removed, its name is added to this vector.
+     This is so we can properly report solib changes to the user.  */
+  VEC (char_ptr) *deleted_solibs = NULL;
+
+  /* Per pspace data-pointers required by other GDB modules.  */
+  REGISTRY_FIELDS {};
+};
 
 /* An address space.  It is used for comparing if
    pspaces/inferior/threads see the same address space and for
@@ -243,10 +246,6 @@ extern struct program_space *current_program_space;
 #define ALL_PSPACES(pspace) \
   for ((pspace) = program_spaces; (pspace) != NULL; (pspace) = (pspace)->next)
 
-/* Add a new empty program space, and assign ASPACE to it.  Returns the
-   pointer to the new object.  */
-extern struct program_space *add_program_space (struct address_space *aspace);
-
 /* Remove a program space from the program spaces list and release it.  It is
    an error to call this function while PSPACE is the current program space. */
 extern void delete_program_space (struct program_space *pspace);
-- 
2.16.1

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

* Re: [PATCH 1/5] Make delim_string_to_char_ptr_vec return an std::vector
  2018-02-25 16:32 [PATCH 1/5] Make delim_string_to_char_ptr_vec return an std::vector Simon Marchi
                   ` (3 preceding siblings ...)
  2018-02-25 16:47 ` [PATCH 2/5] C++ify program_space Simon Marchi
@ 2018-03-03  4:23 ` Simon Marchi
  2018-04-10 19:58 ` Regression with -D_GLIBCXX_DEBUG [Re: [PATCH 1/5] Make delim_string_to_char_ptr_vec return an std::vector] Jan Kratochvil
  5 siblings, 0 replies; 10+ messages in thread
From: Simon Marchi @ 2018-03-03  4:23 UTC (permalink / raw)
  To: gdb-patches

On 2018-02-25 11:32 AM, Simon Marchi wrote:
> This patch makes delim_string_to_char_ptr_vec and all related functions
> use std::vector of gdb::unique_xmalloc_ptr.  This allows getting rid of
> make_cleanup_free_char_ptr_vec.  Returning a vector of
> unique_xmalloc_ptr instead of std::string allows to minimize the impacts
> on the calling code.  We can evaluate later whether we could/should
> return a vector of std::strings instead.

This series is now pushed.

Simon

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

* Regression with -D_GLIBCXX_DEBUG  [Re: [PATCH 1/5] Make delim_string_to_char_ptr_vec return an std::vector]
  2018-02-25 16:32 [PATCH 1/5] Make delim_string_to_char_ptr_vec return an std::vector Simon Marchi
                   ` (4 preceding siblings ...)
  2018-03-03  4:23 ` [PATCH 1/5] Make delim_string_to_char_ptr_vec return an std::vector Simon Marchi
@ 2018-04-10 19:58 ` Jan Kratochvil
  2018-04-10 20:33   ` Simon Marchi
  5 siblings, 1 reply; 10+ messages in thread
From: Jan Kratochvil @ 2018-04-10 19:58 UTC (permalink / raw)
  To: Simon Marchi; +Cc: gdb-patches

Hi,

commit e80aaf6183c6692ecc167bf26cbdc53f8f1a55f0 (HEAD)
Author: Simon Marchi <simon.marchi@polymtl.ca>
Date:   Fri Mar 2 23:22:06 2018 -0500
    Make delim_string_to_char_ptr_vec return an std::vector

/usr/include/c++/7/debug/safe_iterator.h:297:
Error: attempt to increment a singular iterator.
Objects involved in the operation:
    iterator "this" @ 0x0x7fffffffd140 {
      type = __gnu_debug::_Safe_iterator<__gnu_cxx::__normal_iterator<std::unique_ptr<char, gdb::xfree_deleter<char> >*, std::__cxx1998::vector<std::unique_ptr<char, gdb::xfree_deleter<char> >, std::allocator<std::unique_ptr<char, gdb::xfree_deleter<char> > > > >, std::__debug::vector<std::unique_ptr<char, gdb::xfree_deleter<char> >, std::allocator<std::unique_ptr<char, gdb::xfree_deleter<char> > > > > (mutable iterator);
      state = singular;
      references sequence with type 'std::__debug::vector<std::unique_ptr<char, gdb::xfree_deleter<char> >, std::allocator<std::unique_ptr<char, gdb::xfree_deleter<char> > > >' @ 0x0x265db40
    }
#4  0x000000000078f893 in auto_load_safe_path_vec_update () at auto-load.c:212


On Sun, 25 Feb 2018 17:32:43 +0100, Simon Marchi wrote:
>    /* Apply tilde_expand and gdb_realpath to each AUTO_LOAD_SAFE_PATH_VEC
>       element.  */
> -  for (ix = 0; ix < len; ix++)
> +  for (gdb::unique_xmalloc_ptr<char> &in_vec : auto_load_safe_path_vec)
>      {
...
> -	  VEC_safe_push (char_ptr, auto_load_safe_path_vec,
> -			 real_path.release ());
> +	  auto_load_safe_path_vec.push_back (std::move (real_path));
>  	}
>      }
>  }

The iterator breaks when moving its std::vector data underneath it.
This is why the original C code did not use a pointer there.


Jan

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

* Re: Regression with -D_GLIBCXX_DEBUG [Re: [PATCH 1/5] Make delim_string_to_char_ptr_vec return an std::vector]
  2018-04-10 19:58 ` Regression with -D_GLIBCXX_DEBUG [Re: [PATCH 1/5] Make delim_string_to_char_ptr_vec return an std::vector] Jan Kratochvil
@ 2018-04-10 20:33   ` Simon Marchi
  2018-04-10 20:39     ` Jan Kratochvil
  0 siblings, 1 reply; 10+ messages in thread
From: Simon Marchi @ 2018-04-10 20:33 UTC (permalink / raw)
  To: Jan Kratochvil, Simon Marchi; +Cc: gdb-patches

On 2018-04-10 03:58 PM, Jan Kratochvil wrote:
> Hi,
> 
> commit e80aaf6183c6692ecc167bf26cbdc53f8f1a55f0 (HEAD)
> Author: Simon Marchi <simon.marchi@polymtl.ca>
> Date:   Fri Mar 2 23:22:06 2018 -0500
>     Make delim_string_to_char_ptr_vec return an std::vector
> 
> /usr/include/c++/7/debug/safe_iterator.h:297:
> Error: attempt to increment a singular iterator.
> Objects involved in the operation:
>     iterator "this" @ 0x0x7fffffffd140 {
>       type = __gnu_debug::_Safe_iterator<__gnu_cxx::__normal_iterator<std::unique_ptr<char, gdb::xfree_deleter<char> >*, std::__cxx1998::vector<std::unique_ptr<char, gdb::xfree_deleter<char> >, std::allocator<std::unique_ptr<char, gdb::xfree_deleter<char> > > > >, std::__debug::vector<std::unique_ptr<char, gdb::xfree_deleter<char> >, std::allocator<std::unique_ptr<char, gdb::xfree_deleter<char> > > > > (mutable iterator);
>       state = singular;
>       references sequence with type 'std::__debug::vector<std::unique_ptr<char, gdb::xfree_deleter<char> >, std::allocator<std::unique_ptr<char, gdb::xfree_deleter<char> > > >' @ 0x0x265db40
>     }
> #4  0x000000000078f893 in auto_load_safe_path_vec_update () at auto-load.c:212
> 
> 
> On Sun, 25 Feb 2018 17:32:43 +0100, Simon Marchi wrote:
>>    /* Apply tilde_expand and gdb_realpath to each AUTO_LOAD_SAFE_PATH_VEC
>>       element.  */
>> -  for (ix = 0; ix < len; ix++)
>> +  for (gdb::unique_xmalloc_ptr<char> &in_vec : auto_load_safe_path_vec)
>>      {
> ...
>> -	  VEC_safe_push (char_ptr, auto_load_safe_path_vec,
>> -			 real_path.release ());
>> +	  auto_load_safe_path_vec.push_back (std::move (real_path));
>>  	}
>>      }
>>  }
> 
> The iterator breaks when moving its std::vector data underneath it.
> This is why the original C code did not use a pointer there.
> 
> 
> Jan
> 

Of course, thanks for reporting.  Does this fix it?

From fddee555819b2631920bf4a86854bb0d76ac121f Mon Sep 17 00:00:00 2001
From: Simon Marchi <simon.marchi@ericsson.com>
Date: Tue, 10 Apr 2018 16:31:52 -0400
Subject: [PATCH] Iterate by index

---
 gdb/auto-load.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/gdb/auto-load.c b/gdb/auto-load.c
index e426468..33d282a 100644
--- a/gdb/auto-load.c
+++ b/gdb/auto-load.c
@@ -197,20 +197,19 @@ auto_load_expand_dir_vars (const char *string)
 static void
 auto_load_safe_path_vec_update (void)
 {
-  unsigned len;
-  int ix;
-
   if (debug_auto_load)
     fprintf_unfiltered (gdb_stdlog,
 			_("auto-load: Updating directories of \"%s\".\n"),
 			auto_load_safe_path);

   auto_load_safe_path_vec = auto_load_expand_dir_vars (auto_load_safe_path);
+  size_t len = auto_load_safe_path_vec.size ();

   /* Apply tilde_expand and gdb_realpath to each AUTO_LOAD_SAFE_PATH_VEC
      element.  */
-  for (gdb::unique_xmalloc_ptr<char> &in_vec : auto_load_safe_path_vec)
+  for (size_t i = 0; i < len; i++)
     {
+      gdb::unique_xmalloc_ptr<char> &in_vec = auto_load_safe_path_vec[i];
       gdb::unique_xmalloc_ptr<char> expanded (tilde_expand (in_vec.get ()));
       gdb::unique_xmalloc_ptr<char> real_path = gdb_realpath (expanded.get ());

-- 
2.7.4

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

* Re: Regression with -D_GLIBCXX_DEBUG [Re: [PATCH 1/5] Make delim_string_to_char_ptr_vec return an std::vector]
  2018-04-10 20:33   ` Simon Marchi
@ 2018-04-10 20:39     ` Jan Kratochvil
  2018-04-10 20:52       ` Simon Marchi
  0 siblings, 1 reply; 10+ messages in thread
From: Jan Kratochvil @ 2018-04-10 20:39 UTC (permalink / raw)
  To: Simon Marchi; +Cc: Simon Marchi, gdb-patches

On Tue, 10 Apr 2018 22:32:46 +0200, Simon Marchi wrote:
> Of course, thanks for reporting.  Does this fix it?
> 
> >From fddee555819b2631920bf4a86854bb0d76ac121f Mon Sep 17 00:00:00 2001
> From: Simon Marchi <simon.marchi@ericsson.com>
> Date: Tue, 10 Apr 2018 16:31:52 -0400
> Subject: [PATCH] Iterate by index

Yes.


Jan

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

* Re: Regression with -D_GLIBCXX_DEBUG [Re: [PATCH 1/5] Make delim_string_to_char_ptr_vec return an std::vector]
  2018-04-10 20:39     ` Jan Kratochvil
@ 2018-04-10 20:52       ` Simon Marchi
  0 siblings, 0 replies; 10+ messages in thread
From: Simon Marchi @ 2018-04-10 20:52 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: Simon Marchi, gdb-patches

On 2018-04-10 04:39 PM, Jan Kratochvil wrote:
> On Tue, 10 Apr 2018 22:32:46 +0200, Simon Marchi wrote:
>> Of course, thanks for reporting.  Does this fix it?
>>
>> >From fddee555819b2631920bf4a86854bb0d76ac121f Mon Sep 17 00:00:00 2001
>> From: Simon Marchi <simon.marchi@ericsson.com>
>> Date: Tue, 10 Apr 2018 16:31:52 -0400
>> Subject: [PATCH] Iterate by index
> 
> Yes.

Thanks, here's what I pushed:

From 6e22e10d63addd60f39114cef81ade290b15b2c8 Mon Sep 17 00:00:00 2001
From: Simon Marchi <simon.marchi@ericsson.com>
Date: Tue, 10 Apr 2018 16:50:59 -0400
Subject: [PATCH] Iterate by index in auto_load_safe_path_vec_update

As reported by Jan, we get this error when building with -D_GLIBCXX_DEBUG:

/usr/include/c++/7/debug/safe_iterator.h:297:
Error: attempt to increment a singular iterator.
Objects involved in the operation:
    iterator "this" @ 0x0x7fffffffd140 {
      type = __gnu_debug::_Safe_iterator<__gnu_cxx::__normal_iterator<std::unique_ptr<char, gdb::xfree_deleter<char> >*, std::__cxx1998::vector<std::unique_ptr<char, gdb::xfree_deleter<char> >, std::allocator<std::unique_ptr<char, gdb::xfree_deleter<char> > > > >, std::__debug::vector<std::unique_ptr<char, gdb::xfree_deleter<char> >, std::allocator<std::unique_ptr<char, gdb::xfree_deleter<char> > > > > (mutable iterator);
      state = singular;
      references sequence with type 'std::__debug::vector<std::unique_ptr<char, gdb::xfree_deleter<char> >, std::allocator<std::unique_ptr<char, gdb::xfree_deleter<char> > > >' @ 0x0x265db40
    }

The bug was introduced by commit

commit e80aaf6183c6692ecc167bf26cbdc53f8f1a55f0
Author: Simon Marchi <simon.marchi@polymtl.ca>
Date:   Fri Mar 2 23:22:06 2018 -0500
Make delim_string_to_char_ptr_vec return an std::vector

The problem is that we iterate using a range-based for on a vector to
which we push in the loop.  Pushing to the vector invalidates the
iterator used in the loop.  Instead, change the code to iterate by index
as was done in the previous code.

gdb/ChangeLog:

	* auto-load.c (auto_load_safe_path_vec_update): Iterate by
	index.
---
 gdb/ChangeLog   | 5 +++++
 gdb/auto-load.c | 7 +++----
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index d46ecdd..6ed9d6c 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2018-04-10  Simon Marchi  <simon.marchi@ericsson.com>
+
+	* auto-load.c (auto_load_safe_path_vec_update): Iterate by
+	index.
+
 2018-04-10  Pedro Alves  <palves@redhat.com>

 	* gdbthread.h (finish_thread_state_cleanup): Delete declaration.
diff --git a/gdb/auto-load.c b/gdb/auto-load.c
index e426468..33d282a 100644
--- a/gdb/auto-load.c
+++ b/gdb/auto-load.c
@@ -197,20 +197,19 @@ auto_load_expand_dir_vars (const char *string)
 static void
 auto_load_safe_path_vec_update (void)
 {
-  unsigned len;
-  int ix;
-
   if (debug_auto_load)
     fprintf_unfiltered (gdb_stdlog,
 			_("auto-load: Updating directories of \"%s\".\n"),
 			auto_load_safe_path);

   auto_load_safe_path_vec = auto_load_expand_dir_vars (auto_load_safe_path);
+  size_t len = auto_load_safe_path_vec.size ();

   /* Apply tilde_expand and gdb_realpath to each AUTO_LOAD_SAFE_PATH_VEC
      element.  */
-  for (gdb::unique_xmalloc_ptr<char> &in_vec : auto_load_safe_path_vec)
+  for (size_t i = 0; i < len; i++)
     {
+      gdb::unique_xmalloc_ptr<char> &in_vec = auto_load_safe_path_vec[i];
       gdb::unique_xmalloc_ptr<char> expanded (tilde_expand (in_vec.get ()));
       gdb::unique_xmalloc_ptr<char> real_path = gdb_realpath (expanded.get ());

-- 
2.7.4


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

end of thread, other threads:[~2018-04-10 20:52 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-25 16:32 [PATCH 1/5] Make delim_string_to_char_ptr_vec return an std::vector Simon Marchi
2018-02-25 16:32 ` [PATCH 4/5] C++ify charsets Simon Marchi
2018-02-25 16:32 ` [PATCH 3/5] Make program_space::deleted_solibs a vector of std::string Simon Marchi
2018-02-25 16:33 ` [PATCH 5/5] Remove free_char_ptr_vec Simon Marchi
2018-02-25 16:47 ` [PATCH 2/5] C++ify program_space Simon Marchi
2018-03-03  4:23 ` [PATCH 1/5] Make delim_string_to_char_ptr_vec return an std::vector Simon Marchi
2018-04-10 19:58 ` Regression with -D_GLIBCXX_DEBUG [Re: [PATCH 1/5] Make delim_string_to_char_ptr_vec return an std::vector] Jan Kratochvil
2018-04-10 20:33   ` Simon Marchi
2018-04-10 20:39     ` Jan Kratochvil
2018-04-10 20:52       ` Simon Marchi

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).