From patchwork Wed Jul 23 21:27:22 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 2154 Received: (qmail 15773 invoked by alias); 23 Jul 2014 21:27:30 -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 15748 invoked by uid 89); 23 Jul 2014 21:27:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.8 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 23 Jul 2014 21:27:28 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s6NLRR6x021983 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 23 Jul 2014 17:27:27 -0400 Received: from barimba.redhat.com (ovpn-113-154.phx2.redhat.com [10.3.113.154]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s6NLRPUR012780; Wed, 23 Jul 2014 17:27:26 -0400 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 1/3] constify exec_file_attach Date: Wed, 23 Jul 2014 15:27:22 -0600 Message-Id: <1406150844-17134-2-git-send-email-tromey@redhat.com> In-Reply-To: <1406150844-17134-1-git-send-email-tromey@redhat.com> References: <1406150844-17134-1-git-send-email-tromey@redhat.com> This constifies exec_file_attach and updates the rest of gdb. Insight will need some minor tweaks after this, though it's worth noting that I think all that hook stuff can actually just go away. I sent a patch to this effect once, but since the Insight source repository situation isn't currently resolved there wasn't a convenient way to test it. 2014-07-22 Tom Tromey * corefile.c (hook_type, call_extra_exec_file_hooks) (specify_exec_file_hook): Constify. * exec.c (exec_file_attach): Make "filename" const. * gdbcore.h (deprecated_exec_file_display_hook) (specify_exec_file_hook, exec_file_attach): Constify. * main.c (call_exec_file_attach): New function. (captured_main): Use it. --- gdb/ChangeLog | 10 ++++++++++ gdb/corefile.c | 7 +++---- gdb/exec.c | 2 +- gdb/gdbcore.h | 6 +++--- gdb/main.c | 12 ++++++++++-- 5 files changed, 27 insertions(+), 10 deletions(-) diff --git a/gdb/corefile.c b/gdb/corefile.c index 8a96d75..89d9e19 100644 --- a/gdb/corefile.c +++ b/gdb/corefile.c @@ -39,7 +39,6 @@ /* Local function declarations. */ extern void _initialize_core (void); -static void call_extra_exec_file_hooks (char *filename); /* You can have any number of hooks for `exec_file_command' command to call. If there's only one hook, it is set in exec_file_display @@ -50,7 +49,7 @@ static void call_extra_exec_file_hooks (char *filename); only one hook could be set, and which called deprecated_exec_file_display_hook directly. */ -typedef void (*hook_type) (char *); +typedef void (*hook_type) (const char *); hook_type deprecated_exec_file_display_hook; /* The original hook. */ static hook_type *exec_file_extra_hooks; /* Array of additional @@ -87,7 +86,7 @@ core_file_command (char *filename, int from_tty) functions. */ static void -call_extra_exec_file_hooks (char *filename) +call_extra_exec_file_hooks (const char *filename) { int i; @@ -99,7 +98,7 @@ call_extra_exec_file_hooks (char *filename) This is called from the x-window display code. */ void -specify_exec_file_hook (void (*hook) (char *)) +specify_exec_file_hook (void (*hook) (const char *)) { hook_type *new_array; diff --git a/gdb/exec.c b/gdb/exec.c index 087c122..e42ef20 100644 --- a/gdb/exec.c +++ b/gdb/exec.c @@ -161,7 +161,7 @@ exec_file_clear (int from_tty) we're supplying the exec pathname late for good reason.) */ void -exec_file_attach (char *filename, int from_tty) +exec_file_attach (const char *filename, int from_tty) { struct cleanup *cleanups; diff --git a/gdb/gdbcore.h b/gdb/gdbcore.h index 3f81791..0950859 100644 --- a/gdb/gdbcore.h +++ b/gdb/gdbcore.h @@ -127,14 +127,14 @@ extern void write_memory_signed_integer (CORE_ADDR addr, int len, /* Hook for `exec_file_command' command to call. */ -extern void (*deprecated_exec_file_display_hook) (char *filename); +extern void (*deprecated_exec_file_display_hook) (const char *filename); /* Hook for "file_command", which is more useful than above (because it is invoked AFTER symbols are read, not before). */ extern void (*deprecated_file_changed_hook) (char *filename); -extern void specify_exec_file_hook (void (*hook) (char *filename)); +extern void specify_exec_file_hook (void (*hook) (const char *filename)); /* Binary File Diddler for the core file. */ @@ -148,7 +148,7 @@ extern int write_files; extern void core_file_command (char *filename, int from_tty); -extern void exec_file_attach (char *filename, int from_tty); +extern void exec_file_attach (const char *filename, int from_tty); extern void exec_file_clear (int from_tty); diff --git a/gdb/main.c b/gdb/main.c index b51ff89..c5309b6 100644 --- a/gdb/main.c +++ b/gdb/main.c @@ -420,6 +420,14 @@ typedef struct cmdarg { /* Define type VEC (cmdarg_s). */ DEF_VEC_O (cmdarg_s); +/* A wrapper for exec_file_attach that has the correct type. */ + +static void +call_exec_file_attach (char *arg, int from_tty) +{ + exec_file_attach (arg, from_tty); +} + static int captured_main (void *data) { @@ -1068,7 +1076,7 @@ captured_main (void *data) /* The exec file and the symbol-file are the same. If we can't open it, better only print one error message. catch_command_errors returns non-zero on success! */ - if (catch_command_errors (exec_file_attach, execarg, + if (catch_command_errors (call_exec_file_attach, execarg, !batch_flag, RETURN_MASK_ALL)) catch_command_errors_const (symbol_file_add_main, symarg, !batch_flag, RETURN_MASK_ALL); @@ -1076,7 +1084,7 @@ captured_main (void *data) else { if (execarg != NULL) - catch_command_errors (exec_file_attach, execarg, + catch_command_errors (call_exec_file_attach, execarg, !batch_flag, RETURN_MASK_ALL); if (symarg != NULL) catch_command_errors_const (symbol_file_add_main, symarg,