From patchwork Tue Feb 13 23:39:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 25931 Received: (qmail 35642 invoked by alias); 13 Feb 2018 23:39:19 -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 35536 invoked by uid 89); 13 Feb 2018 23:39:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: gateway30.websitewelcome.com Received: from gateway30.websitewelcome.com (HELO gateway30.websitewelcome.com) (192.185.160.12) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 13 Feb 2018 23:39:17 +0000 Received: from cm13.websitewelcome.com (cm13.websitewelcome.com [100.42.49.6]) by gateway30.websitewelcome.com (Postfix) with ESMTP id 509AA158E3 for ; Tue, 13 Feb 2018 17:39:16 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id lkAOeXkB9BUMKlkAOeZnlv; Tue, 13 Feb 2018 17:39:16 -0600 Received: from 174-29-60-18.hlrn.qwest.net ([174.29.60.18]:52440 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1elkAO-004Amp-2L; Tue, 13 Feb 2018 17:39:16 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA 4/4] Constify target_so_ops::bfd_open Date: Tue, 13 Feb 2018 16:39:07 -0700 Message-Id: <20180213233907.11259-5-tom@tromey.com> In-Reply-To: <20180213233907.11259-1-tom@tromey.com> References: <20180213233907.11259-1-tom@tromey.com> X-BWhitelist: no X-Source-L: No X-Exim-ID: 1elkAO-004Amp-2L X-Source-Sender: 174-29-60-18.hlrn.qwest.net (bapiya.Home) [174.29.60.18]:52440 X-Source-Auth: tom+tromey.com X-Email-Count: 5 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes This constifies the bfd_open method of struct target_so_ops. gdb/ChangeLog 2018-02-13 Tom Tromey * solist.h (struct target_so_ops) : 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 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;