constify to_open
authorTom Tromey <tromey@redhat.com>
Tue, 22 Jul 2014 16:56:01 +0000 (10:56 -0600)
committerTom Tromey <tromey@redhat.com>
Wed, 30 Jul 2014 14:02:53 +0000 (08:02 -0600)
This makes target_ops::to_open take a const string and then fixes the
fallout.

There were a few of these I could not build.  However I eyeballed it
and in any case the fixes should generally be trivial.

This is based on the patch to fix up the target debugging for to_open,
because that changes gdb to not directly install to_open as the target
command

2014-07-30  Tom Tromey  <tromey@redhat.com>

* bsd-kvm.c (bsd_kvm_open): Constify.
* corelow.c (core_open): Constify.
* ctf.c (ctf_open): Constify.
* dbug-rom.c (dbug_open): Constify.
* exec.c (exec_open): Constify.
* m32r-rom.c (m32r_open, mon2000_open): Constify.
* microblaze-rom.c (picobug_open): Constify.
* nto-procfs.c (procfs_open_1, procfs_open, procfs_native_open):
Constify.
* ppcbug-rom.c (ppcbug_open0, ppcbug_open1): Constify.
* record-btrace.c (record_btrace_open): Constify.
* record-full.c (record_full_core_open_1, record_full_open_1)
(record_full_open): Constify.
* remote-m32r-sdi.c (m32r_open): Constify.
* remote-mips.c (common_open, mips_open, pmon_open, ddb_open)
(rockhopper_open, lsi_open): Constify.
* remote-sim.c (gdbsim_open): Constify.
* remote.c (remote_open, extended_remote_open, remote_open_1):
Constify.
* target.h (struct target_ops) <to_open>: Make "arg" const.
* tracefile-tfile.c (tfile_open): Constify.

20 files changed:
gdb/ChangeLog
gdb/bsd-kvm.c
gdb/corelow.c
gdb/ctf.c
gdb/dbug-rom.c
gdb/dink32-rom.c
gdb/exec.c
gdb/inf-child.c
gdb/m32r-rom.c
gdb/microblaze-rom.c
gdb/nto-procfs.c
gdb/ppcbug-rom.c
gdb/record-btrace.c
gdb/record-full.c
gdb/remote-m32r-sdi.c
gdb/remote-mips.c
gdb/remote-sim.c
gdb/remote.c
gdb/target.h
gdb/tracefile-tfile.c

index 24d867381ad402b57c35d073320e6f8866aeb2c9..1322e94ce0cba41489dd5b91af1506efd94868a1 100644 (file)
@@ -1,3 +1,27 @@
+2014-07-30  Tom Tromey  <tromey@redhat.com>
+
+       * bsd-kvm.c (bsd_kvm_open): Constify.
+       * corelow.c (core_open): Constify.
+       * ctf.c (ctf_open): Constify.
+       * dbug-rom.c (dbug_open): Constify.
+       * exec.c (exec_open): Constify.
+       * m32r-rom.c (m32r_open, mon2000_open): Constify.
+       * microblaze-rom.c (picobug_open): Constify.
+       * nto-procfs.c (procfs_open_1, procfs_open, procfs_native_open):
+       Constify.
+       * ppcbug-rom.c (ppcbug_open0, ppcbug_open1): Constify.
+       * record-btrace.c (record_btrace_open): Constify.
+       * record-full.c (record_full_core_open_1, record_full_open_1)
+       (record_full_open): Constify.
+       * remote-m32r-sdi.c (m32r_open): Constify.
+       * remote-mips.c (common_open, mips_open, pmon_open, ddb_open)
+       (rockhopper_open, lsi_open): Constify.
+       * remote-sim.c (gdbsim_open): Constify.
+       * remote.c (remote_open, extended_remote_open, remote_open_1):
+       Constify.
+       * target.h (struct target_ops) <to_open>: Make "arg" const.
+       * tracefile-tfile.c (tfile_open): Constify.
+
 2014-07-30  Tom Tromey  <tromey@redhat.com>
 
        * breakpoint.c (map_breakpoint_numbers): Update.
index 35ecebb1c007dd6b15f4760c6d1f6e14efb26902..67050358ecd0847795b3f1240d6413e42f318cee 100644 (file)
@@ -63,19 +63,20 @@ static struct target_ops bsd_kvm_ops;
 static ptid_t bsd_kvm_ptid;
 
 static void
-bsd_kvm_open (char *filename, int from_tty)
+bsd_kvm_open (const char *arg, int from_tty)
 {
   char errbuf[_POSIX2_LINE_MAX];
   char *execfile = NULL;
   kvm_t *temp_kd;
+  char *filename = NULL;
 
   target_preopen (from_tty);
 
-  if (filename)
+  if (arg)
     {
       char *temp;
 
-      filename = tilde_expand (filename);
+      filename = tilde_expand (arg);
       if (filename[0] != '/')
        {
          temp = concat (current_directory, "/", filename, (char *)NULL);
index 0a066f427f527825966102ed4edec5f846e67e16..ad780edf99e4a30b037bdf15051527dda9e61a6e 100644 (file)
@@ -84,8 +84,6 @@ static struct core_fns *sniff_core_bfd (bfd *);
 
 static int gdb_check_format (bfd *);
 
-static void core_open (char *, int);
-
 static void core_close (struct target_ops *self);
 
 static void core_close_cleanup (void *ignore);
@@ -275,7 +273,7 @@ add_to_thread_list (bfd *abfd, asection *asect, void *reg_sect_arg)
 /* This routine opens and sets up the core file bfd.  */
 
 static void
-core_open (char *filename, int from_tty)
+core_open (const char *arg, int from_tty)
 {
   const char *p;
   int siggy;
@@ -285,9 +283,10 @@ core_open (char *filename, int from_tty)
   int scratch_chan;
   int flags;
   volatile struct gdb_exception except;
+  char *filename;
 
   target_preopen (from_tty);
-  if (!filename)
+  if (!arg)
     {
       if (core_bfd)
        error (_("No core file specified.  (Use `detach' "
@@ -296,7 +295,7 @@ core_open (char *filename, int from_tty)
        error (_("No core file specified."));
     }
 
-  filename = tilde_expand (filename);
+  filename = tilde_expand (arg);
   if (!IS_ABSOLUTE_PATH (filename))
     {
       temp = concat (current_directory, "/",
index 84d0a4817cee6b126e2542c9202ea2a2390250d6..df645c04b48cfb7b24b590305e5e3870a39c6df4 100644 (file)
--- a/gdb/ctf.c
+++ b/gdb/ctf.c
@@ -904,7 +904,7 @@ ctf_destroy (void)
 /* Open CTF trace data in DIRNAME.  */
 
 static void
-ctf_open_dir (char *dirname)
+ctf_open_dir (const char *dirname)
 {
   struct bt_iter_pos begin_pos;
   struct bt_iter_pos *pos;
@@ -1127,7 +1127,7 @@ ctf_read_tp (struct uploaded_tp **uploaded_tps)
    second packet which contains events on trace blocks.  */
 
 static void
-ctf_open (char *dirname, int from_tty)
+ctf_open (const char *dirname, int from_tty)
 {
   struct bt_ctf_event *event;
   uint32_t event_id;
index 4157f273a310edc4dfb68cbb4e42b674eef38633..c7755437dc888c863efd7c2071035cc3cc5e55b2 100644 (file)
@@ -32,8 +32,6 @@
 
 #include "m68k-tdep.h"
 
-static void dbug_open (char *args, int from_tty);
-
 static void
 dbug_supply_register (struct regcache *regcache, char *regname,
                      int regnamelen, char *val, int vallen)
@@ -155,7 +153,7 @@ init_dbug_cmds (void)
 }                              /* init_debug_ops */
 
 static void
-dbug_open (char *args, int from_tty)
+dbug_open (const char *args, int from_tty)
 {
   monitor_open (args, &dbug_cmds, from_tty);
 }
index 52d428de0675ccf510f8a39d44169f005263edcd..9ab81ae553194d8bad761903d8df7274d1ba9a93 100644 (file)
@@ -26,8 +26,6 @@
 #include "inferior.h"
 #include "regcache.h"
 
-static void dink32_open (char *args, int from_tty);
-
 static void
 dink32_supply_register (struct regcache *regcache, char *regname,
                        int regnamelen, char *val, int vallen)
@@ -123,7 +121,7 @@ static char *dink32_inits[] =
 static struct monitor_ops dink32_cmds;
 
 static void
-dink32_open (char *args, int from_tty)
+dink32_open (const char *args, int from_tty)
 {
   monitor_open (args, &dink32_cmds, from_tty);
 }
index 371fccbd231e9e7045f93649ac11d785f037f2c4..e53a1497a0c4ea2f2ee376681d8676d9391038d0 100644 (file)
@@ -76,7 +76,7 @@ show_write_files (struct ui_file *file, int from_tty,
 
 
 static void
-exec_open (char *args, int from_tty)
+exec_open (const char *args, int from_tty)
 {
   target_preopen (from_tty);
   exec_file_attach (args, from_tty);
index 883ed775eadc8e2afaeb5d707d655f4572e12385..1b929729f117de1a6f13b570011bb5ea58162488 100644 (file)
@@ -133,7 +133,7 @@ inf_child_open_target (struct target_ops *target, const char *arg,
 }
 
 static void
-inf_child_open (char *arg, int from_tty)
+inf_child_open (const char *arg, int from_tty)
 {
   inf_child_open_target (inf_child_ops, arg, from_tty);
 }
index 0ab252a1fd191d1794cb0ac878b89cc42996903e..6b20cd10ce7fc0b0b2364354eba939281f5f3864 100644 (file)
@@ -201,9 +201,6 @@ m32r_load_gen (struct target_ops *self, const char *filename, int from_tty)
   generic_load (filename, from_tty);
 }
 
-static void m32r_open (char *args, int from_tty);
-static void mon2000_open (char *args, int from_tty);
-
 /* This array of registers needs to match the indexes used by GDB.  The
    whole reason this exists is because the various ROM monitors use
    different names than GDB does, and don't support all the registers
@@ -362,7 +359,7 @@ init_m32r_cmds (void)
 }                              /* init_m32r_cmds */
 
 static void
-m32r_open (char *args, int from_tty)
+m32r_open (const char *args, int from_tty)
 {
   monitor_open (args, &m32r_cmds, from_tty);
 }
@@ -422,7 +419,7 @@ init_mon2000_cmds (void)
 }                              /* init_mon2000_cmds */
 
 static void
-mon2000_open (char *args, int from_tty)
+mon2000_open (const char *args, int from_tty)
 {
   monitor_open (args, &mon2000_cmds, from_tty);
 }
index 936865c181f684b87c36670698feb5bf91eed00b..a64217d1120edb8b1132a7bbc3a0d941db208610 100644 (file)
@@ -49,7 +49,7 @@ static char *picobug_regnames[] = {
 
 
 static void
-picobug_open (char *args, int from_tty)
+picobug_open (const char *args, int from_tty)
 {
   monitor_open (args, &picobug_cmds, from_tty);
 }
index 728d6f3a76d9f0b8e81b58ad63749a9a383f8839..ff8f2af85ddea1c309be181f201b1aed473b27c0 100644 (file)
@@ -106,7 +106,7 @@ procfs_is_nto_target (bfd *abfd)
    will be a QNX node string, eg: "/net/some_node".  If arg is not a
    valid QNX node, we will default to local.  */
 static void
-procfs_open_1 (struct target_ops *ops, char *arg, int from_tty)
+procfs_open_1 (struct target_ops *ops, const char *arg, int from_tty)
 {
   char *nodestr;
   char *endstr;
@@ -1395,7 +1395,7 @@ static struct target_ops *nto_native_ops;
 /* to_open implementation for "target procfs".  */
 
 static void
-procfs_open (char *arg, int from_tty)
+procfs_open (const char *arg, int from_tty)
 {
   procfs_open_1 (&nto_procfs_ops, arg, from_tty);
 }
@@ -1403,7 +1403,7 @@ procfs_open (char *arg, int from_tty)
 /* to_open implementation for "target native".  */
 
 static void
-procfs_native_open (char *arg, int from_tty)
+procfs_native_open (const char *arg, int from_tty)
 {
   procfs_open_1 (nto_native_ops, arg, from_tty);
 }
index 3038713703fdfe37efa28d82a1d38fffe2ab33a4..f1740d189f98fbe434e5e79b7032ea2b6a93f00c 100644 (file)
@@ -184,13 +184,13 @@ static struct monitor_ops ppcbug_cmds0;
 static struct monitor_ops ppcbug_cmds1;
 
 static void
-ppcbug_open0 (char *args, int from_tty)
+ppcbug_open0 (const char *args, int from_tty)
 {
   monitor_open (args, &ppcbug_cmds0, from_tty);
 }
 
 static void
-ppcbug_open1 (char *args, int from_tty)
+ppcbug_open1 (const char *args, int from_tty)
 {
   monitor_open (args, &ppcbug_cmds1, from_tty);
 }
index e48ad615ffbb81dd3a55b281cc27d8c56566e9f2..430c7957d7b45bdfb0f1985b542ed7f68e2e0b15 100644 (file)
@@ -188,7 +188,7 @@ record_btrace_handle_async_inferior_event (gdb_client_data data)
 /* The to_open method of target record-btrace.  */
 
 static void
-record_btrace_open (char *args, int from_tty)
+record_btrace_open (const char *args, int from_tty)
 {
   struct cleanup *disable_chain;
   struct thread_info *tp;
index fcd77908632a7fb83f40910cab0799c9521d50b1..119361f9eb8c3655cd87b84b11dcd7a31a3f66c8 100644 (file)
@@ -792,7 +792,7 @@ record_full_async_inferior_event_handler (gdb_client_data data)
 /* Open the process record target.  */
 
 static void
-record_full_core_open_1 (char *name, int from_tty)
+record_full_core_open_1 (const char *name, int from_tty)
 {
   struct regcache *regcache = get_current_regcache ();
   int regnum = gdbarch_num_regs (get_regcache_arch (regcache));
@@ -822,7 +822,7 @@ record_full_core_open_1 (char *name, int from_tty)
 /* "to_open" target method for 'live' processes.  */
 
 static void
-record_full_open_1 (char *name, int from_tty)
+record_full_open_1 (const char *name, int from_tty)
 {
   if (record_debug)
     fprintf_unfiltered (gdb_stdlog, "Process record: record_full_open\n");
@@ -846,7 +846,7 @@ static void record_full_init_record_breakpoints (void);
 /* "to_open" target method.  Open the process record target.  */
 
 static void
-record_full_open (char *name, int from_tty)
+record_full_open (const char *name, int from_tty)
 {
   struct target_ops *t;
 
index 38cfba7635d3fc8984180af294191ff80cafe7a1..e5b66a0556416e012dc1967924e6de15b65e1323 100644 (file)
@@ -359,7 +359,7 @@ m32r_create_inferior (struct target_ops *ops, char *execfile,
    NAME is the filename used for communication.  */
 
 static void
-m32r_open (char *args, int from_tty)
+m32r_open (const char *args, int from_tty)
 {
   struct hostent *host_ent;
   struct sockaddr_in server_addr;
index 277621ddc45ba9ebd5b72040cd1210acdf5a42bc..236f3cdab45b10be90816b42c8a418fcdd4d4b21 100644 (file)
@@ -77,14 +77,6 @@ static ULONGEST mips_request (int cmd, ULONGEST addr, ULONGEST data,
 
 static void mips_initialize (void);
 
-static void mips_open (char *name, int from_tty);
-
-static void pmon_open (char *name, int from_tty);
-
-static void ddb_open (char *name, int from_tty);
-
-static void lsi_open (char *name, int from_tty);
-
 static void mips_close (struct target_ops *self);
 
 static int mips_map_regno (struct gdbarch *, int);
@@ -1541,7 +1533,7 @@ mips_initialize (void)
 /* Open a connection to the remote board.  */
 
 static void
-common_open (struct target_ops *ops, char *name, int from_tty,
+common_open (struct target_ops *ops, const char *name, int from_tty,
             enum mips_monitor_type new_monitor,
             const char *new_monitor_prompt)
 {
@@ -1669,7 +1661,7 @@ seen from the board via TFTP, specify that name as the third parameter.\n"));
 /* Open a connection to an IDT board.  */
 
 static void
-mips_open (char *name, int from_tty)
+mips_open (const char *name, int from_tty)
 {
   const char *monitor_prompt = NULL;
   if (gdbarch_bfd_arch_info (target_gdbarch ()) != NULL
@@ -1694,7 +1686,7 @@ mips_open (char *name, int from_tty)
 /* Open a connection to a PMON board.  */
 
 static void
-pmon_open (char *name, int from_tty)
+pmon_open (const char *name, int from_tty)
 {
   common_open (&pmon_ops, name, from_tty, MON_PMON, "PMON> ");
 }
@@ -1702,7 +1694,7 @@ pmon_open (char *name, int from_tty)
 /* Open a connection to a DDB board.  */
 
 static void
-ddb_open (char *name, int from_tty)
+ddb_open (const char *name, int from_tty)
 {
   common_open (&ddb_ops, name, from_tty, MON_DDB, "NEC010>");
 }
@@ -1710,7 +1702,7 @@ ddb_open (char *name, int from_tty)
 /* Open a connection to a rockhopper board.  */
 
 static void
-rockhopper_open (char *name, int from_tty)
+rockhopper_open (const char *name, int from_tty)
 {
   common_open (&rockhopper_ops, name, from_tty, MON_ROCKHOPPER, "NEC01>");
 }
@@ -1718,7 +1710,7 @@ rockhopper_open (char *name, int from_tty)
 /* Open a connection to an LSI board.  */
 
 static void
-lsi_open (char *name, int from_tty)
+lsi_open (const char *name, int from_tty)
 {
   int i;
 
index 3acc9da52aca348233643e98a99941acee961107..753de74ac1097700bf04630a22c89aa59c9f0533 100644 (file)
@@ -667,7 +667,7 @@ gdbsim_create_inferior (struct target_ops *target, char *exec_file, char *args,
 /* Called when selecting the simulator.  E.g. (gdb) target sim name.  */
 
 static void
-gdbsim_open (char *args, int from_tty)
+gdbsim_open (const char *args, int from_tty)
 {
   int len;
   char *arg_buf;
index 3a05bfd1a6bf83f3bf09e84b37245dbe6a21d438..fcddd1cc8646018f1033c9a99d878eefa6697fe9 100644 (file)
@@ -102,11 +102,8 @@ static void remote_files_info (struct target_ops *ignore);
 static void remote_prepare_to_store (struct target_ops *self,
                                     struct regcache *regcache);
 
-static void remote_open (char *name, int from_tty);
-
-static void extended_remote_open (char *name, int from_tty);
-
-static void remote_open_1 (char *, int, struct target_ops *, int extended_p);
+static void remote_open_1 (const char *, int, struct target_ops *,
+                          int extended_p);
 
 static void remote_close (struct target_ops *self);
 
@@ -3619,7 +3616,7 @@ remote_start_remote (int from_tty, struct target_ops *target, int extended_p)
    NAME is the filename used for communication.  */
 
 static void
-remote_open (char *name, int from_tty)
+remote_open (const char *name, int from_tty)
 {
   remote_open_1 (name, from_tty, &remote_ops, 0);
 }
@@ -3628,7 +3625,7 @@ remote_open (char *name, int from_tty)
    remote gdb protocol.  NAME is the filename used for communication.  */
 
 static void
-extended_remote_open (char *name, int from_tty)
+extended_remote_open (const char *name, int from_tty)
 {
   remote_open_1 (name, from_tty, &extended_remote_ops, 1 /*extended_p */);
 }
@@ -4128,7 +4125,7 @@ remote_unpush_target (void)
 }
 
 static void
-remote_open_1 (char *name, int from_tty,
+remote_open_1 (const char *name, int from_tty,
               struct target_ops *target, int extended_p)
 {
   struct remote_state *rs = get_remote_state ();
index 29a1f01ccb852a3846c54a9959079cd85474e7e5..4d91b6b8032e688dd22a1cf4d0fce80a4d14ca07 100644 (file)
@@ -405,7 +405,7 @@ struct target_ops
        command, and (if successful) pushes a new target onto the
        stack.  Targets should supply this routine, if only to provide
        an error message.  */
-    void (*to_open) (char *, int);
+    void (*to_open) (const char *, int);
     /* Old targets with a static target vector provide "to_close".
        New re-entrant targets provide "to_xclose" and that is expected
        to xfree everything (including the "struct target_ops").  */
index 37dc69191c2056253e8ff21dd832bc4c4929ca5a..5ba1b1509ae3872be3b8ffbb35924c4330e9c019 100644 (file)
@@ -376,7 +376,7 @@ tfile_read (gdb_byte *readbuf, int size)
 }
 
 static void
-tfile_open (char *filename, int from_tty)
+tfile_open (const char *arg, int from_tty)
 {
   volatile struct gdb_exception ex;
   char *temp;
@@ -390,12 +390,13 @@ tfile_open (char *filename, int from_tty)
   struct trace_status *ts;
   struct uploaded_tp *uploaded_tps = NULL;
   struct uploaded_tsv *uploaded_tsvs = NULL;
+  char *filename;
 
   target_preopen (from_tty);
-  if (!filename)
+  if (!arg)
     error (_("No trace file specified."));
 
-  filename = tilde_expand (filename);
+  filename = tilde_expand (arg);
   if (!IS_ABSOLUTE_PATH(filename))
     {
       temp = concat (current_directory, "/", filename, (char *) NULL);
This page took 0.04943 seconds and 4 git commands to generate.