From patchwork Wed May 22 19:42:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 32799 Received: (qmail 121296 invoked by alias); 22 May 2019 19:42:55 -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 121271 invoked by uid 89); 22 May 2019 19:42:55 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=rebuilding, HContent-Transfer-Encoding:8bit X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 22 May 2019 19:42:53 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 0295D1165BD; Wed, 22 May 2019 15:42:52 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id d2EYBCbIoEF4; Wed, 22 May 2019 15:42:51 -0400 (EDT) Received: from murgatroyd.gnat.com (unknown [IPv6:2620:20:4000:40:60aa:25d0:ef41:54b6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPSA id DB5511164E0; Wed, 22 May 2019 15:42:51 -0400 (EDT) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [FYI] Constify target_ops::follow_exec Date: Wed, 22 May 2019 15:42:50 -0400 Message-Id: <20190522194250.15865-1-tromey@adacore.com> MIME-Version: 1.0 I noticed that target_ops::follow_exec took a "char *" parameter, where "const char *" would be more correct. This patch changes this (and related functions) to be constified. Tested by rebuilding. gdb/ChangeLog 2019-05-22 Tom Tromey * target.c (target_follow_exec): Constify parameter. * target-delegates.c: Rebuild. * remote.c (remote_target::follow_exec): Constify parameter. * infrun.c (follow_exec): Constify parameter. * target.h (struct target_ops) : Constify parameter. (target_follow_exec): Likewise. --- gdb/ChangeLog | 9 +++++++++ gdb/infrun.c | 2 +- gdb/remote.c | 4 ++-- gdb/target-delegates.c | 12 ++++++------ gdb/target.c | 2 +- gdb/target.h | 4 ++-- 6 files changed, 21 insertions(+), 12 deletions(-) diff --git a/gdb/infrun.c b/gdb/infrun.c index 37df561de0b..4fd92f1bac2 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -1078,7 +1078,7 @@ show_follow_exec_mode_string (struct ui_file *file, int from_tty, /* EXEC_FILE_TARGET is assumed to be non-NULL. */ static void -follow_exec (ptid_t ptid, char *exec_file_target) +follow_exec (ptid_t ptid, const char *exec_file_target) { struct inferior *inf = current_inferior (); int pid = ptid.pid (); diff --git a/gdb/remote.c b/gdb/remote.c index dc734723d14..124d254478e 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -667,7 +667,7 @@ public: const struct btrace_config *btrace_conf (const struct btrace_target_info *) override; bool augmented_libraries_svr4_read () override; int follow_fork (int, int) override; - void follow_exec (struct inferior *, char *) override; + void follow_exec (struct inferior *, const char *) override; int insert_fork_catchpoint (int) override; int remove_fork_catchpoint (int) override; int insert_vfork_catchpoint (int) override; @@ -5751,7 +5751,7 @@ remote_target::follow_fork (int follow_child, int detach_fork) follow-exec-mode is "new". */ void -remote_target::follow_exec (struct inferior *inf, char *execd_pathname) +remote_target::follow_exec (struct inferior *inf, const char *execd_pathname) { /* We know that this is a target file name, so if it has the "target:" prefix we strip it off before saving it in the program space. */ diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c index cfc0ce06e99..52034fe4360 100644 --- a/gdb/target-delegates.c +++ b/gdb/target-delegates.c @@ -59,7 +59,7 @@ struct dummy_target : public target_ops int follow_fork (int arg0, int arg1) override; int insert_exec_catchpoint (int arg0) override; int remove_exec_catchpoint (int arg0) override; - void follow_exec (struct inferior *arg0, char *arg1) override; + void follow_exec (struct inferior *arg0, const char *arg1) override; int set_syscall_catchpoint (int arg0, bool arg1, int arg2, gdb::array_view arg3) override; void mourn_inferior () override; void pass_signals (gdb::array_view arg0) override; @@ -227,7 +227,7 @@ struct debug_target : public target_ops int follow_fork (int arg0, int arg1) override; int insert_exec_catchpoint (int arg0) override; int remove_exec_catchpoint (int arg0) override; - void follow_exec (struct inferior *arg0, char *arg1) override; + void follow_exec (struct inferior *arg0, const char *arg1) override; int set_syscall_catchpoint (int arg0, bool arg1, int arg2, gdb::array_view arg3) override; void mourn_inferior () override; void pass_signals (gdb::array_view arg0) override; @@ -1585,25 +1585,25 @@ debug_target::remove_exec_catchpoint (int arg0) } void -target_ops::follow_exec (struct inferior *arg0, char *arg1) +target_ops::follow_exec (struct inferior *arg0, const char *arg1) { this->beneath ()->follow_exec (arg0, arg1); } void -dummy_target::follow_exec (struct inferior *arg0, char *arg1) +dummy_target::follow_exec (struct inferior *arg0, const char *arg1) { } void -debug_target::follow_exec (struct inferior *arg0, char *arg1) +debug_target::follow_exec (struct inferior *arg0, const char *arg1) { fprintf_unfiltered (gdb_stdlog, "-> %s->follow_exec (...)\n", this->beneath ()->shortname ()); this->beneath ()->follow_exec (arg0, arg1); fprintf_unfiltered (gdb_stdlog, "<- %s->follow_exec (", this->beneath ()->shortname ()); target_debug_print_struct_inferior_p (arg0); fputs_unfiltered (", ", gdb_stdlog); - target_debug_print_char_p (arg1); + target_debug_print_const_char_p (arg1); fputs_unfiltered (")\n", gdb_stdlog); } diff --git a/gdb/target.c b/gdb/target.c index f492102b6d4..752e62b022f 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -2175,7 +2175,7 @@ target_follow_fork (int follow_child, int detach_fork) /* Target wrapper for follow exec hook. */ void -target_follow_exec (struct inferior *inf, char *execd_pathname) +target_follow_exec (struct inferior *inf, const char *execd_pathname) { current_top_target ()->follow_exec (inf, execd_pathname); } diff --git a/gdb/target.h b/gdb/target.h index 9078a420018..323357ca550 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -622,7 +622,7 @@ struct target_ops TARGET_DEFAULT_RETURN (1); virtual int remove_exec_catchpoint (int) TARGET_DEFAULT_RETURN (1); - virtual void follow_exec (struct inferior *, char *) + virtual void follow_exec (struct inferior *, const char *) TARGET_DEFAULT_IGNORE (); virtual int set_syscall_catchpoint (int, bool, int, gdb::array_view) @@ -1637,7 +1637,7 @@ int target_follow_fork (int follow_child, int detach_fork); /* Handle the target-specific bookkeeping required when the inferior makes an exec call. INF is the exec'd inferior. */ -void target_follow_exec (struct inferior *inf, char *execd_pathname); +void target_follow_exec (struct inferior *inf, const char *execd_pathname); /* On some targets, we can catch an inferior exec event when it occurs. These functions insert/remove an already-created