public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH v2 2/6] Move make_temp_filename to common/pathstuff.c
Date: Thu, 18 Oct 2018 22:31:00 -0000	[thread overview]
Message-ID: <20181018223100.20693-3-tom@tromey.com> (raw)
In-Reply-To: <20181018223100.20693-1-tom@tromey.com>

Currently make_temp_filename is a function local to
write_psymtabs_to_index.  This patch moves it to pathstuff.c so that
it can be used from other places in gdb.

gdb/ChangeLog
2018-10-18  Tom Tromey  <tom@tromey.com>

	* dwarf-index-write.c (write_psymtabs_to_index): Move
	make_temp_filename to common/pathstuff.c.
	* common/pathstuff.h (make_temp_filename): Declare.
	* common/pathstuff.c (make_temp_filename): New function, moved
	from dwarf-index-write.c.
---
 gdb/ChangeLog           |  8 ++++++++
 gdb/common/pathstuff.c  | 11 +++++++++++
 gdb/common/pathstuff.h  |  7 +++++++
 gdb/dwarf-index-write.c | 11 +----------
 4 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/gdb/common/pathstuff.c b/gdb/common/pathstuff.c
index 6d8e53f4e1..48ff861eda 100644
--- a/gdb/common/pathstuff.c
+++ b/gdb/common/pathstuff.c
@@ -202,3 +202,14 @@ get_shell ()
 
   return ret;
 }
+
+/* See common/pathstuff.h.  */
+
+gdb::char_vector
+make_temp_filename (const std::string &f)
+{
+  gdb::char_vector filename_temp (f.length () + 8);
+  strcpy (filename_temp.data (), f.c_str ());
+  strcat (filename_temp.data () + f.size (), "-XXXXXX");
+  return filename_temp;
+}
diff --git a/gdb/common/pathstuff.h b/gdb/common/pathstuff.h
index 40fbda8d85..14fab04805 100644
--- a/gdb/common/pathstuff.h
+++ b/gdb/common/pathstuff.h
@@ -20,6 +20,8 @@
 #ifndef PATHSTUFF_H
 #define PATHSTUFF_H
 
+#include "common/byte-vector.h"
+
 /* Path utilities.  */
 
 /* Return the real path of FILENAME, expanding all the symbolic links.
@@ -68,4 +70,9 @@ extern std::string get_standard_cache_dir ();
 
 extern const char *get_shell ();
 
+/* Make a filename suitable to pass to mkstemp based on F (e.g.
+   /tmp/foo -> /tmp/foo-XXXXXX).  */
+
+extern gdb::char_vector make_temp_filename (const std::string &f);
+
 #endif /* PATHSTUFF_H */
diff --git a/gdb/dwarf-index-write.c b/gdb/dwarf-index-write.c
index d4585af837..4335c39074 100644
--- a/gdb/dwarf-index-write.c
+++ b/gdb/dwarf-index-write.c
@@ -24,6 +24,7 @@
 #include "common/byte-vector.h"
 #include "common/filestuff.h"
 #include "common/gdb_unlinker.h"
+#include "common/pathstuff.h"
 #include "common/scoped_fd.h"
 #include "complaints.h"
 #include "dwarf-index-common.h"
@@ -1560,16 +1561,6 @@ write_psymtabs_to_index (struct dwarf2_per_objfile *dwarf2_per_objfile,
   if (stat (objfile_name (objfile), &st) < 0)
     perror_with_name (objfile_name (objfile));
 
-  /* Make a filename suitable to pass to mkstemp based on F (e.g.
-     /tmp/foo -> /tmp/foo-XXXXXX).  */
-  auto make_temp_filename = [] (const std::string &f) -> gdb::char_vector
-    {
-      gdb::char_vector filename_temp (f.length () + 8);
-      strcpy (filename_temp.data (), f.c_str ());
-      strcat (filename_temp.data () + f.size (), "-XXXXXX");
-      return filename_temp;
-    };
-
   std::string filename (std::string (dir) + SLASH_STRING + basename
 			+ (index_kind == dw_index_kind::DEBUG_NAMES
 			   ? INDEX5_SUFFIX : INDEX4_SUFFIX));
-- 
2.17.1

  parent reply	other threads:[~2018-10-18 22:31 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-18 22:31 [PATCH v2 0/6] A different approach to startup-with-shell on macOS Tom Tromey
2018-10-18 22:31 ` [PATCH v2 3/6] Move mkdir_recursive to common/filestuff.c Tom Tromey
2018-10-29 16:01   ` Simon Marchi
2018-10-29 22:16     ` Simon Marchi
2018-10-30 20:55       ` Tom Tromey
2018-10-30 21:04         ` Simon Marchi
2018-10-31 15:03           ` Tom Tromey
2018-11-01 19:44             ` Simon Marchi
2018-10-18 22:31 ` [PATCH v2 1/6] Unify shell-finding logic Tom Tromey
2018-10-19 23:27   ` Sergio Durigan Junior
2018-10-27 17:41     ` Tom Tromey
2018-10-18 22:31 ` [PATCH v2 4/6] Use mkostemp, not mkstemp Tom Tromey
2018-10-18 22:31 ` Tom Tromey [this message]
2018-10-18 22:31 ` [PATCH v2 5/6] Do not reopen temporary files Tom Tromey
2018-10-18 22:31 ` [PATCH v2 6/6] Cache a copy of the user's shell on macOS Tom Tromey
2018-10-20  2:35   ` Simon Marchi
2018-10-27 17:43     ` Tom Tromey
2018-10-19 23:41 ` [PATCH v2 0/6] A different approach to startup-with-shell " Sergio Durigan Junior
2018-10-27 17:58   ` Tom Tromey
  -- strict thread matches above, loose matches on Subject: below --
2018-10-03 21:02 [PATCH 2 0/6] A different approach to starutp-with-shell " Tom Tromey
2018-10-03 21:02 ` [PATCH v2 2/6] Move make_temp_filename to common/pathstuff.c Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181018223100.20693-3-tom@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).