From patchwork Wed Sep 26 11:11:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 29543 Received: (qmail 92901 invoked by alias); 26 Sep 2018 11:12:33 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 92865 invoked by uid 89); 26 Sep 2018 11:12:32 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: gateway22.websitewelcome.com Received: from gateway22.websitewelcome.com (HELO gateway22.websitewelcome.com) (192.185.47.179) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 26 Sep 2018 11:12:31 +0000 Received: from cm15.websitewelcome.com (cm15.websitewelcome.com [100.42.49.9]) by gateway22.websitewelcome.com (Postfix) with ESMTP id B6F4A12263 for ; Wed, 26 Sep 2018 06:12:29 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id 57jHgH5p28YaU57jlglBKK; Wed, 26 Sep 2018 06:12:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=qlcu7QsTgU6KnExfjrs9dI5j3TcPRFV7rf+/44SNx3E=; b=G1AdrcjwYwV/B2b36hZKsVA1J6 nZgzZPCBj0moovauduaK06fDE9XeXzdSQ+vSUAgQ271t3VSfrw6XJfBXpPhrOwvJ+TLi4HA8/wKZj RqrlUvhOWJn5gbkPL/UuavOUs; Received: from 97-122-190-66.hlrn.qwest.net ([97.122.190.66]:44312 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1g57jH-0014pw-Fm; Wed, 26 Sep 2018 06:11:39 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFC 2/6] Move make_temp_filename to common/pathstuff.c Date: Wed, 26 Sep 2018 05:11:26 -0600 Message-Id: <20180926111130.18956-3-tom@tromey.com> In-Reply-To: <20180926111130.18956-1-tom@tromey.com> References: <20180926111130.18956-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-09-26 Tom Tromey * 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 252032161f..dc8660e734 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" @@ -1559,16 +1560,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));