From patchwork Mon Jun 9 14:15:54 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 1374 Received: (qmail 7861 invoked by alias); 9 Jun 2014 14:16:04 -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 7735 invoked by uid 89); 9 Jun 2014 14:16:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.1 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 ESMTP; Mon, 09 Jun 2014 14:16:02 +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 s59EG0na032509 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 9 Jun 2014 10:16:00 -0400 Received: from barimba.redhat.com (ovpn-113-103.phx2.redhat.com [10.3.113.103]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s59EFwZx023035; Mon, 9 Jun 2014 10:16:00 -0400 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 3/3] constify to_info_proc and friends Date: Mon, 9 Jun 2014 08:15:54 -0600 Message-Id: <1402323354-27308-4-git-send-email-tromey@redhat.com> In-Reply-To: <1402323354-27308-1-git-send-email-tromey@redhat.com> References: <1402323354-27308-1-git-send-email-tromey@redhat.com> This makes a parameter of to_info_proc const and then fixes up some fallout, including parameters in a couple of gdbarch methods. I could not test the procfs.c change. I verified it by inspection. If this causes an error here, it will be trivial to fix. 2014-06-09 Tom Tromey * target.h (struct target_ops) : Make parameter const. (target_info_proc): Update. * target.c (target_info_proc): Make "args" const. * procfs.c (procfs_info_proc): Update. * linux-tdep.c (linux_info_proc): Update. (linux_core_info_proc_mappings): Make "args" const. (linux_core_info_proc): Update. * gdbarch.sh (info_proc, core_info_proc): Make "args" const. * gdbarch.c: Rebuild. * gdbarch.h: Rebuild. * corelow.c (core_info_proc): Update. --- gdb/ChangeLog | 15 +++++++++++++++ gdb/corelow.c | 3 ++- gdb/gdbarch.c | 4 ++-- gdb/gdbarch.h | 8 ++++---- gdb/gdbarch.sh | 4 ++-- gdb/linux-tdep.c | 15 ++++++++++----- gdb/procfs.c | 4 ++-- gdb/target.c | 2 +- gdb/target.h | 5 +++-- 9 files changed, 41 insertions(+), 19 deletions(-) diff --git a/gdb/corelow.c b/gdb/corelow.c index e6a5cb1..1775a66 100644 --- a/gdb/corelow.c +++ b/gdb/corelow.c @@ -979,7 +979,8 @@ core_has_registers (struct target_ops *ops) /* Implement the to_info_proc method. */ static void -core_info_proc (struct target_ops *ops, char *args, enum info_proc_what request) +core_info_proc (struct target_ops *ops, const char *args, + enum info_proc_what request) { struct gdbarch *gdbarch = get_current_arch (); diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c index 4f82095..fe49987 100644 --- a/gdb/gdbarch.c +++ b/gdb/gdbarch.c @@ -4257,7 +4257,7 @@ gdbarch_info_proc_p (struct gdbarch *gdbarch) } void -gdbarch_info_proc (struct gdbarch *gdbarch, char *args, enum info_proc_what what) +gdbarch_info_proc (struct gdbarch *gdbarch, const char *args, enum info_proc_what what) { gdb_assert (gdbarch != NULL); gdb_assert (gdbarch->info_proc != NULL); @@ -4281,7 +4281,7 @@ gdbarch_core_info_proc_p (struct gdbarch *gdbarch) } void -gdbarch_core_info_proc (struct gdbarch *gdbarch, char *args, enum info_proc_what what) +gdbarch_core_info_proc (struct gdbarch *gdbarch, const char *args, enum info_proc_what what) { gdb_assert (gdbarch != NULL); gdb_assert (gdbarch->core_info_proc != NULL); diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h index c621091..5388e6e 100644 --- a/gdb/gdbarch.h +++ b/gdb/gdbarch.h @@ -1250,8 +1250,8 @@ extern void set_gdbarch_gen_return_address (struct gdbarch *gdbarch, gdbarch_gen extern int gdbarch_info_proc_p (struct gdbarch *gdbarch); -typedef void (gdbarch_info_proc_ftype) (struct gdbarch *gdbarch, char *args, enum info_proc_what what); -extern void gdbarch_info_proc (struct gdbarch *gdbarch, char *args, enum info_proc_what what); +typedef void (gdbarch_info_proc_ftype) (struct gdbarch *gdbarch, const char *args, enum info_proc_what what); +extern void gdbarch_info_proc (struct gdbarch *gdbarch, const char *args, enum info_proc_what what); extern void set_gdbarch_info_proc (struct gdbarch *gdbarch, gdbarch_info_proc_ftype *info_proc); /* Implement the "info proc" command for core files. Noe that there @@ -1260,8 +1260,8 @@ extern void set_gdbarch_info_proc (struct gdbarch *gdbarch, gdbarch_info_proc_ft extern int gdbarch_core_info_proc_p (struct gdbarch *gdbarch); -typedef void (gdbarch_core_info_proc_ftype) (struct gdbarch *gdbarch, char *args, enum info_proc_what what); -extern void gdbarch_core_info_proc (struct gdbarch *gdbarch, char *args, enum info_proc_what what); +typedef void (gdbarch_core_info_proc_ftype) (struct gdbarch *gdbarch, const char *args, enum info_proc_what what); +extern void gdbarch_core_info_proc (struct gdbarch *gdbarch, const char *args, enum info_proc_what what); extern void set_gdbarch_core_info_proc (struct gdbarch *gdbarch, gdbarch_core_info_proc_ftype *core_info_proc); /* Iterate over all objfiles in the order that makes the most sense diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh index 9f357b6..13db4d4 100755 --- a/gdb/gdbarch.sh +++ b/gdb/gdbarch.sh @@ -990,12 +990,12 @@ v:int:has_dos_based_file_system:::0:0::0 m:void:gen_return_address:struct agent_expr *ax, struct axs_value *value, CORE_ADDR scope:ax, value, scope::default_gen_return_address::0 # Implement the "info proc" command. -M:void:info_proc:char *args, enum info_proc_what what:args, what +M:void:info_proc:const char *args, enum info_proc_what what:args, what # Implement the "info proc" command for core files. Noe that there # are two "info_proc"-like methods on gdbarch -- one for core files, # one for live targets. -M:void:core_info_proc:char *args, enum info_proc_what what:args, what +M:void:core_info_proc:const char *args, enum info_proc_what what:args, what # Iterate over all objfiles in the order that makes the most sense # for the architecture to make global symbol searches. diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c index c10b8ee..ca19cf4 100644 --- a/gdb/linux-tdep.c +++ b/gdb/linux-tdep.c @@ -315,7 +315,7 @@ read_mapping (const char *line, /* Implement the "info proc" command. */ static void -linux_info_proc (struct gdbarch *gdbarch, char *args, +linux_info_proc (struct gdbarch *gdbarch, const char *args, enum info_proc_what what) { /* A long is used for pid instead of an int to avoid a loss of precision @@ -332,7 +332,12 @@ linux_info_proc (struct gdbarch *gdbarch, char *args, int target_errno; if (args && isdigit (args[0])) - pid = strtoul (args, &args, 10); + { + char *tem; + + pid = strtoul (args, &tem, 10); + args = tem; + } else { if (!target_has_execution) @@ -343,7 +348,7 @@ linux_info_proc (struct gdbarch *gdbarch, char *args, pid = current_inferior ()->pid; } - args = skip_spaces (args); + args = skip_spaces_const (args); if (args && args[0]) error (_("Too many parameters: %s"), args); @@ -603,7 +608,7 @@ linux_info_proc (struct gdbarch *gdbarch, char *args, /* Implement "info proc mappings" for a corefile. */ static void -linux_core_info_proc_mappings (struct gdbarch *gdbarch, char *args) +linux_core_info_proc_mappings (struct gdbarch *gdbarch, const char *args) { asection *section; ULONGEST count, page_size; @@ -706,7 +711,7 @@ linux_core_info_proc_mappings (struct gdbarch *gdbarch, char *args) /* Implement "info proc" for a corefile. */ static void -linux_core_info_proc (struct gdbarch *gdbarch, char *args, +linux_core_info_proc (struct gdbarch *gdbarch, const char *args, enum info_proc_what what) { int exe_f = (what == IP_MINIMAL || what == IP_EXE || what == IP_ALL); diff --git a/gdb/procfs.c b/gdb/procfs.c index 6a2aef8..cbb44ce 100644 --- a/gdb/procfs.c +++ b/gdb/procfs.c @@ -148,7 +148,7 @@ static char * procfs_make_note_section (struct target_ops *self, static int procfs_can_use_hw_breakpoint (struct target_ops *self, int, int, int); -static void procfs_info_proc (struct target_ops *, char *, +static void procfs_info_proc (struct target_ops *, const char *, enum info_proc_what); #if defined (PR_MODEL_NATIVE) && (PR_MODEL_NATIVE == PR_MODEL_LP64) @@ -5141,7 +5141,7 @@ info_proc_mappings (procinfo *pi, int summary) /* Implement the "info proc" command. */ static void -procfs_info_proc (struct target_ops *ops, char *args, +procfs_info_proc (struct target_ops *ops, const char *args, enum info_proc_what what) { struct cleanup *old_chain; diff --git a/gdb/target.c b/gdb/target.c index f3226b9..075425d 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -2542,7 +2542,7 @@ find_run_target (void) /* Implement the "info proc" command. */ int -target_info_proc (char *args, enum info_proc_what what) +target_info_proc (const char *args, enum info_proc_what what) { struct target_ops *t; diff --git a/gdb/target.h b/gdb/target.h index 7f9714e..e563f2f 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -815,7 +815,8 @@ struct target_ops /* Implement the "info proc" command. */ - void (*to_info_proc) (struct target_ops *, char *, enum info_proc_what); + void (*to_info_proc) (struct target_ops *, const char *, + enum info_proc_what); /* Tracepoint-related operations. */ @@ -1232,7 +1233,7 @@ struct address_space *target_thread_address_space (ptid_t); an error was encountered while attempting to handle the request. */ -int target_info_proc (char *, enum info_proc_what); +int target_info_proc (const char *, enum info_proc_what); /* Returns true if this target can debug multiple processes simultaneously. */