From patchwork Thu Jun 19 20:29:45 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 1575 Received: (qmail 22430 invoked by alias); 19 Jun 2014 20:29: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 22408 invoked by uid 89); 19 Jun 2014 20:29:54 -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, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD 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; Thu, 19 Jun 2014 20:29:53 +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 s5JKTqn9021032 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 19 Jun 2014 16:29:52 -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 s5JKTonW004581; Thu, 19 Jun 2014 16:29:51 -0400 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 1/4] constify to_load Date: Thu, 19 Jun 2014 14:29:45 -0600 Message-Id: <1403209788-1015-2-git-send-email-tromey@redhat.com> In-Reply-To: <1403209788-1015-1-git-send-email-tromey@redhat.com> References: <1403209788-1015-1-git-send-email-tromey@redhat.com> This makes the argument to the target_ops to_load method "const", and fixes up the fallout. Tested by rebuilding all the affected files. 2014-06-19 Tom Tromey * defs.h (generic_load): Update. * m32r-rom.c (m32r_load_gen): Make "filename" const. * monitor.c (monitor_load): Make "args" const. * remote-m32r-sdi.c (m32r_load): Make "args" const. * remote-mips.c (mips_load_srec, pmon_load_fast): Make "args" const. (mips_load): Make "file" const. * remote-sim.c (gdbsim_load): Make "args" const. * remote.c (remote_load): Make "name" const. * symfile.c (generic_load): Make "args" const. * target-delegates.c: Rebuild. * target.c (target_load): Make "arg" const. (debug_to_load): Make "args" const. * target.h (struct target_ops) : Make parameter const. (target_load): Update. --- gdb/ChangeLog | 18 ++++++++++++++++++ gdb/defs.h | 2 +- gdb/m32r-rom.c | 2 +- gdb/monitor.c | 2 +- gdb/remote-m32r-sdi.c | 25 ++++++++----------------- gdb/remote-mips.c | 10 ++++------ gdb/remote-sim.c | 5 +++-- gdb/remote.c | 2 +- gdb/symfile.c | 2 +- gdb/target-delegates.c | 4 ++-- gdb/target.c | 6 +++--- gdb/target.h | 4 ++-- 12 files changed, 45 insertions(+), 37 deletions(-) diff --git a/gdb/defs.h b/gdb/defs.h index b7e9ff4..511279a 100644 --- a/gdb/defs.h +++ b/gdb/defs.h @@ -291,7 +291,7 @@ extern char *re_comp (const char *); extern void symbol_file_command (char *, int); /* * Remote targets may wish to use this as their load function. */ -extern void generic_load (char *name, int from_tty); +extern void generic_load (const char *name, int from_tty); /* * Report on STREAM the performance of memory transfer operation, such as 'load'. diff --git a/gdb/m32r-rom.c b/gdb/m32r-rom.c index 2ca23ae..0ab252a 100644 --- a/gdb/m32r-rom.c +++ b/gdb/m32r-rom.c @@ -196,7 +196,7 @@ m32r_load (char *filename, int from_tty) } static void -m32r_load_gen (struct target_ops *self, char *filename, int from_tty) +m32r_load_gen (struct target_ops *self, const char *filename, int from_tty) { generic_load (filename, from_tty); } diff --git a/gdb/monitor.c b/gdb/monitor.c index 4a57d5e..61f0dff 100644 --- a/gdb/monitor.c +++ b/gdb/monitor.c @@ -2200,7 +2200,7 @@ monitor_wait_srec_ack (void) /* monitor_load -- download a file. */ static void -monitor_load (struct target_ops *self, char *args, int from_tty) +monitor_load (struct target_ops *self, const char *args, int from_tty) { CORE_ADDR load_offset = 0; char **argv; diff --git a/gdb/remote-m32r-sdi.c b/gdb/remote-m32r-sdi.c index 9c57171..37efaec 100644 --- a/gdb/remote-m32r-sdi.c +++ b/gdb/remote-m32r-sdi.c @@ -1238,9 +1238,9 @@ m32r_remove_breakpoint (struct target_ops *ops, } static void -m32r_load (struct target_ops *self, char *args, int from_tty) +m32r_load (struct target_ops *self, const char *args, int from_tty) { - struct cleanup *old_chain; + struct cleanup *old_chain = make_cleanup (null_cleanup, NULL); asection *section; bfd *pbfd; bfd_vma entry; @@ -1258,17 +1258,11 @@ m32r_load (struct target_ops *self, char *args, int from_tty) while (*args != '\000') { - char *arg; + char *arg = extract_arg_const (&args); - args = skip_spaces (args); - - arg = args; - - while ((*args != '\000') && !isspace (*args)) - args++; - - if (*args != '\000') - *args++ = '\000'; + if (arg == NULL) + break; + make_cleanup (xfree, arg); if (*arg != '-') filename = arg; @@ -1285,11 +1279,8 @@ m32r_load (struct target_ops *self, char *args, int from_tty) pbfd = gdb_bfd_open (filename, gnutarget, -1); if (pbfd == NULL) - { - perror_with_name (filename); - return; - } - old_chain = make_cleanup_bfd_unref (pbfd); + perror_with_name (filename); + make_cleanup_bfd_unref (pbfd); if (!bfd_check_format (pbfd, bfd_object)) error (_("\"%s\" is not an object file: %s"), filename, diff --git a/gdb/remote-mips.c b/gdb/remote-mips.c index 7f0d957..277621d 100644 --- a/gdb/remote-mips.c +++ b/gdb/remote-mips.c @@ -128,9 +128,7 @@ static void pmon_end_download (int final, int bintotal); static void pmon_download (char *buffer, int length); -static void pmon_load_fast (char *file); - -static void mips_load (struct target_ops *self, char *file, int from_tty); +static void mips_load (struct target_ops *self, const char *file, int from_tty); static int mips_make_srec (char *buffer, int type, CORE_ADDR memaddr, unsigned char *myaddr, int len); @@ -2804,7 +2802,7 @@ send_srec (char *srec, int len, CORE_ADDR addr) /* Download a binary file by converting it to S records. */ static void -mips_load_srec (char *args) +mips_load_srec (const char *args) { bfd *abfd; asection *s; @@ -3389,7 +3387,7 @@ pmon_download (char *buffer, int length) using the FastLoad format. */ static void -pmon_load_fast (char *file) +pmon_load_fast (const char *file) { bfd *abfd; asection *s; @@ -3548,7 +3546,7 @@ pmon_load_fast (char *file) /* mips_load -- download a file. */ static void -mips_load (struct target_ops *self, char *file, int from_tty) +mips_load (struct target_ops *self, const char *file, int from_tty) { struct regcache *regcache; diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c index 2e7db4b..4097372 100644 --- a/gdb/remote-sim.c +++ b/gdb/remote-sim.c @@ -73,7 +73,8 @@ static void gdb_os_error (host_callback *, const char *, ...) static void gdbsim_kill (struct target_ops *); -static void gdbsim_load (struct target_ops *self, char *prog, int fromtty); +static void gdbsim_load (struct target_ops *self, const char *prog, + int fromtty); static void gdbsim_open (char *args, int from_tty); @@ -562,7 +563,7 @@ gdbsim_kill (struct target_ops *ops) GDB's symbol tables to match. */ static void -gdbsim_load (struct target_ops *self, char *args, int fromtty) +gdbsim_load (struct target_ops *self, const char *args, int fromtty) { char **argv; const char *prog; diff --git a/gdb/remote.c b/gdb/remote.c index b5318f1..b6f3ddb 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -11378,7 +11378,7 @@ remote_augmented_libraries_svr4_read (struct target_ops *self) /* Implementation of to_load. */ static void -remote_load (struct target_ops *self, char *name, int from_tty) +remote_load (struct target_ops *self, const char *name, int from_tty) { generic_load (name, from_tty); } diff --git a/gdb/symfile.c b/gdb/symfile.c index 84858dc..42707ac 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -2090,7 +2090,7 @@ clear_memory_write_data (void *arg) } void -generic_load (char *args, int from_tty) +generic_load (const char *args, int from_tty) { bfd *loadfile_bfd; struct timeval start_time, end_time; diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c index 4eefae8..ed0aea2 100644 --- a/gdb/target-delegates.c +++ b/gdb/target-delegates.c @@ -381,14 +381,14 @@ tdefault_kill (struct target_ops *self) } static void -delegate_load (struct target_ops *self, char *arg1, int arg2) +delegate_load (struct target_ops *self, const char *arg1, int arg2) { self = self->beneath; self->to_load (self, arg1, arg2); } static void -tdefault_load (struct target_ops *self, char *arg1, int arg2) +tdefault_load (struct target_ops *self, const char *arg1, int arg2) { tcomplain (); } diff --git a/gdb/target.c b/gdb/target.c index 075425d..c2b0ea1 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -169,7 +169,7 @@ static void debug_to_terminal_save_ours (struct target_ops *self); static void debug_to_terminal_ours (struct target_ops *self); -static void debug_to_load (struct target_ops *self, char *, int); +static void debug_to_load (struct target_ops *self, const char *, int); static int debug_to_can_run (struct target_ops *self); @@ -476,7 +476,7 @@ target_kill (void) } void -target_load (char *arg, int from_tty) +target_load (const char *arg, int from_tty) { target_dcache_invalidate (); (*current_target.to_load) (¤t_target, arg, from_tty); @@ -3860,7 +3860,7 @@ debug_to_terminal_info (struct target_ops *self, } static void -debug_to_load (struct target_ops *self, char *args, int from_tty) +debug_to_load (struct target_ops *self, const char *args, int from_tty) { debug_target.to_load (&debug_target, args, from_tty); diff --git a/gdb/target.h b/gdb/target.h index e563f2f..0effa30 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -499,7 +499,7 @@ struct target_ops TARGET_DEFAULT_FUNC (default_terminal_info); void (*to_kill) (struct target_ops *) TARGET_DEFAULT_NORETURN (noprocess ()); - void (*to_load) (struct target_ops *, char *, int) + void (*to_load) (struct target_ops *, const char *, int) TARGET_DEFAULT_NORETURN (tcomplain ()); /* Start an inferior process and set inferior_ptid to its pid. EXEC_FILE is the file to run. @@ -1415,7 +1415,7 @@ extern void target_kill (void); sections. The target may define switches, or other non-switch arguments, as it pleases. */ -extern void target_load (char *arg, int from_tty); +extern void target_load (const char *arg, int from_tty); /* Some targets (such as ttrace-based HPUX) don't allow us to request notification of inferior events such as fork and vork immediately