From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26854 invoked by alias); 3 Oct 2018 21:02:19 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 26837 invoked by uid 89); 3 Oct 2018 21:02:18 -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=filename_temp X-HELO: gateway21.websitewelcome.com Received: from gateway21.websitewelcome.com (HELO gateway21.websitewelcome.com) (192.185.45.2) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 03 Oct 2018 21:02:17 +0000 Received: from cm11.websitewelcome.com (cm11.websitewelcome.com [100.42.49.5]) by gateway21.websitewelcome.com (Postfix) with ESMTP id 4F86840100FF3 for ; Wed, 3 Oct 2018 16:02:15 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id 7oHfgS3kgRPoj7oHfglPC6; Wed, 03 Oct 2018 16:02:15 -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=Bi7dud9jge97x7WI+K/YskqaaoTrbQd+jVIEuIvpK00=; b=vwDZyrR+mM3nhKEU00kwqxNZmX A3APOYW+3WQpuNKFeQsiLBTKgIhlG593RWu7Iy7O0r2locG3JuNJ6QXE5sUKJv+utUJ3MiOTwUSm0 FiazDA27jHFBvsr8BsfHMzci+; Received: from 97-122-190-66.hlrn.qwest.net ([97.122.190.66]:35478 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1g7oHe-0005d2-W9; Wed, 03 Oct 2018 16:02:15 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH v2 2/6] Move make_temp_filename to common/pathstuff.c Date: Wed, 03 Oct 2018 21:02:00 -0000 Message-Id: <20181003210212.18181-3-tom@tromey.com> In-Reply-To: <20181003210212.18181-1-tom@tromey.com> References: <20181003210212.18181-1-tom@tromey.com> X-SW-Source: 2018-10/txt/msg00086.txt.bz2 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-03 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)); -- 2.17.1