Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH 0/3] constification of to_open
@ 2014-07-23 21:27 Tom Tromey
  2014-07-23 21:27 ` [PATCH 1/3] constify exec_file_attach Tom Tromey
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Tom Tromey @ 2014-07-23 21:27 UTC (permalink / raw)
  To: gdb-patches

This series, based on the target debug fix for to_open, constifies the
string argument to to_open.  I think this is the last major
constification for target_ops.

Built and regtested on x86-64 Fedora 20.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 3/3] constify to_open
  2014-07-23 21:27 [PATCH 0/3] constification of to_open Tom Tromey
  2014-07-23 21:27 ` [PATCH 1/3] constify exec_file_attach Tom Tromey
@ 2014-07-23 21:27 ` Tom Tromey
  2014-07-24  1:34   ` Pedro Alves
  2014-07-23 22:06 ` [PATCH 2/3] constify some cli-utils stuff Tom Tromey
  2014-07-30 14:04 ` [PATCH 0/3] constification of to_open Tom Tromey
  3 siblings, 1 reply; 10+ messages in thread
From: Tom Tromey @ 2014-07-23 21:27 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

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-22  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.
	* inf-child.c (inf_child_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.
---
 gdb/ChangeLog         | 25 +++++++++++++++++++++++++
 gdb/bsd-kvm.c         |  7 ++++---
 gdb/corelow.c         |  9 ++++-----
 gdb/ctf.c             |  4 ++--
 gdb/dbug-rom.c        |  4 +---
 gdb/dink32-rom.c      |  4 +---
 gdb/exec.c            |  2 +-
 gdb/inf-child.c       |  4 ++--
 gdb/inf-child.h       |  2 +-
 gdb/m32r-rom.c        |  7 ++-----
 gdb/microblaze-rom.c  |  2 +-
 gdb/monitor.c         |  2 +-
 gdb/monitor.h         |  3 ++-
 gdb/nto-procfs.c      |  6 +++---
 gdb/ppcbug-rom.c      |  4 ++--
 gdb/record-btrace.c   |  2 +-
 gdb/record-full.c     |  6 +++---
 gdb/remote-m32r-sdi.c |  2 +-
 gdb/remote-mips.c     | 20 ++++++--------------
 gdb/remote-sim.c      |  2 +-
 gdb/remote.c          | 15 ++++++---------
 gdb/target.h          |  2 +-
 gdb/tracefile-tfile.c |  7 ++++---
 23 files changed, 75 insertions(+), 66 deletions(-)

diff --git a/gdb/bsd-kvm.c b/gdb/bsd-kvm.c
index 35ecebb..6705035 100644
--- a/gdb/bsd-kvm.c
+++ b/gdb/bsd-kvm.c
@@ -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);
diff --git a/gdb/corelow.c b/gdb/corelow.c
index 1775a66..9290f18 100644
--- a/gdb/corelow.c
+++ b/gdb/corelow.c
@@ -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, "/",
diff --git a/gdb/ctf.c b/gdb/ctf.c
index 84d0a48..df645c0 100644
--- 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;
diff --git a/gdb/dbug-rom.c b/gdb/dbug-rom.c
index 4157f27..c775543 100644
--- a/gdb/dbug-rom.c
+++ b/gdb/dbug-rom.c
@@ -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);
 }
diff --git a/gdb/dink32-rom.c b/gdb/dink32-rom.c
index 52d428d..9ab81ae 100644
--- a/gdb/dink32-rom.c
+++ b/gdb/dink32-rom.c
@@ -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);
 }
diff --git a/gdb/exec.c b/gdb/exec.c
index e42ef20..98defbc 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -79,7 +79,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);
diff --git a/gdb/inf-child.c b/gdb/inf-child.c
index 897e635..82a2781 100644
--- a/gdb/inf-child.c
+++ b/gdb/inf-child.c
@@ -122,7 +122,7 @@ static int inf_child_explicitly_opened;
 /* See inf-child.h.  */
 
 void
-inf_child_open_target (struct target_ops *target, char *arg, int from_tty)
+inf_child_open_target (struct target_ops *target, const char *arg, int from_tty)
 {
   target_preopen (from_tty);
   push_target (target);
@@ -132,7 +132,7 @@ inf_child_open_target (struct target_ops *target, char *arg, int from_tty)
 }
 
 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);
 }
diff --git a/gdb/inf-child.h b/gdb/inf-child.h
index b2692ca..163cab6 100644
--- a/gdb/inf-child.h
+++ b/gdb/inf-child.h
@@ -34,7 +34,7 @@ extern void store_waitstatus (struct target_waitstatus *, int);
    the target, in case it need to override to_open.  */
 
 extern void inf_child_open_target (struct target_ops *target,
-				   char *arg, int from_tty);
+				   const char *arg, int from_tty);
 
 /* To be called by the native target's to_mourn_inferior routine.  */
 
diff --git a/gdb/m32r-rom.c b/gdb/m32r-rom.c
index 0ab252a..6b20cd1 100644
--- a/gdb/m32r-rom.c
+++ b/gdb/m32r-rom.c
@@ -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);
 }
diff --git a/gdb/microblaze-rom.c b/gdb/microblaze-rom.c
index 936865c..a64217d 100644
--- a/gdb/microblaze-rom.c
+++ b/gdb/microblaze-rom.c
@@ -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);
 }
diff --git a/gdb/monitor.c b/gdb/monitor.c
index 61f0dff..788bca0 100644
--- a/gdb/monitor.c
+++ b/gdb/monitor.c
@@ -713,7 +713,7 @@ compile_pattern (char *pattern, struct re_pattern_buffer *compiled_pattern,
    for communication.  */
 
 void
-monitor_open (char *args, struct monitor_ops *mon_ops, int from_tty)
+monitor_open (const char *args, struct monitor_ops *mon_ops, int from_tty)
 {
   char *name;
   char **p;
diff --git a/gdb/monitor.h b/gdb/monitor.h
index 07caf97..52521c8 100644
--- a/gdb/monitor.h
+++ b/gdb/monitor.h
@@ -239,7 +239,8 @@ struct monitor_ops
 
 #define SREC_SIZE 160
 
-extern void monitor_open (char *args, struct monitor_ops *ops, int from_tty);
+extern void monitor_open (const char *args, struct monitor_ops *ops,
+			  int from_tty);
 extern void monitor_close (struct target_ops *self);
 extern char *monitor_supply_register (struct regcache *regcache,
 				      int regno, char *valstr);
diff --git a/gdb/nto-procfs.c b/gdb/nto-procfs.c
index 728d6f3..ff8f2af 100644
--- a/gdb/nto-procfs.c
+++ b/gdb/nto-procfs.c
@@ -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);
 }
diff --git a/gdb/ppcbug-rom.c b/gdb/ppcbug-rom.c
index 3038713..f1740d1 100644
--- a/gdb/ppcbug-rom.c
+++ b/gdb/ppcbug-rom.c
@@ -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);
 }
diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index 5ba4e06..3601e13 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -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;
diff --git a/gdb/record-full.c b/gdb/record-full.c
index fcd7790..119361f 100644
--- a/gdb/record-full.c
+++ b/gdb/record-full.c
@@ -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;
 
diff --git a/gdb/remote-m32r-sdi.c b/gdb/remote-m32r-sdi.c
index 37efaec..f3d5879 100644
--- a/gdb/remote-m32r-sdi.c
+++ b/gdb/remote-m32r-sdi.c
@@ -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;
diff --git a/gdb/remote-mips.c b/gdb/remote-mips.c
index 277621d..236f3cd 100644
--- a/gdb/remote-mips.c
+++ b/gdb/remote-mips.c
@@ -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;
 
diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c
index 4097372..ff7bf3a 100644
--- a/gdb/remote-sim.c
+++ b/gdb/remote-sim.c
@@ -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;
diff --git a/gdb/remote.c b/gdb/remote.c
index 76efefa..e3e56f3 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -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 */);
 }
@@ -3727,7 +3724,7 @@ remote_check_symbols (void)
 }
 
 static struct serial *
-remote_serial_open (char *name)
+remote_serial_open (const char *name)
 {
   static int udp_warning = 0;
 
@@ -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 ();
diff --git a/gdb/target.h b/gdb/target.h
index 92572ff..8ff358e 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -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").  */
diff --git a/gdb/tracefile-tfile.c b/gdb/tracefile-tfile.c
index 37dc691..5ba1b15 100644
--- a/gdb/tracefile-tfile.c
+++ b/gdb/tracefile-tfile.c
@@ -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);
-- 
1.9.3


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/3] constify exec_file_attach
  2014-07-23 21:27 [PATCH 0/3] constification of to_open Tom Tromey
@ 2014-07-23 21:27 ` Tom Tromey
  2014-07-24  1:27   ` Pedro Alves
  2014-07-23 21:27 ` [PATCH 3/3] constify to_open Tom Tromey
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 10+ messages in thread
From: Tom Tromey @ 2014-07-23 21:27 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

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  <tromey@redhat.com>

	* 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,
 \f
 /* 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,
-- 
1.9.3


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 2/3] constify some cli-utils stuff
  2014-07-23 21:27 [PATCH 0/3] constification of to_open Tom Tromey
  2014-07-23 21:27 ` [PATCH 1/3] constify exec_file_attach Tom Tromey
  2014-07-23 21:27 ` [PATCH 3/3] constify to_open Tom Tromey
@ 2014-07-23 22:06 ` Tom Tromey
  2014-07-24  1:32   ` Pedro Alves
  2014-07-30 14:04 ` [PATCH 0/3] constification of to_open Tom Tromey
  3 siblings, 1 reply; 10+ messages in thread
From: Tom Tromey @ 2014-07-23 22:06 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This constifies a few functions in cli-utils -- get_number_trailer and
friends -- and then fixes the fallout.

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

	* breakpoint.c (map_breakpoint_numbers): Update.
	* cli/cli-utils.c (get_number_trailer): Make "pp" const.  Update.
	(get_number_const): New function.
	(get_number): Rewrite using get_number_const.
	(init_number_or_range): Make "string" const.
	(number_is_in_list): Make "list" const.
	* cli/cli-utils.h (get_number_const): Declare.
	(struct get_number_or_range_state) <string, end_ptr>: Now const.
	(init_number_or_range, number_is_in_list): Update.
	* printcmd.c (map_display_numbers): Update.
	* value.c (value_from_history_ref): Constify.
	* value.h (value_from_history_ref): Update.
---
 gdb/ChangeLog       | 15 +++++++++++++++
 gdb/breakpoint.c    |  2 +-
 gdb/cli/cli-utils.c | 33 +++++++++++++++++++++++----------
 gdb/cli/cli-utils.h | 12 ++++++++----
 gdb/printcmd.c      |  2 +-
 gdb/value.c         | 16 +++++++++++++---
 gdb/value.h         |  2 +-
 7 files changed, 62 insertions(+), 20 deletions(-)

diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 908a1ea..775d555 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -14790,7 +14790,7 @@ map_breakpoint_numbers (char *args, void (*function) (struct breakpoint *,
 
   while (!state.finished)
     {
-      char *p = state.string;
+      const char *p = state.string;
 
       match = 0;
 
diff --git a/gdb/cli/cli-utils.c b/gdb/cli/cli-utils.c
index a0ebc11..819c94c 100644
--- a/gdb/cli/cli-utils.c
+++ b/gdb/cli/cli-utils.c
@@ -35,10 +35,10 @@
    commonly this is `-'.  If you don't want a trailer, use \0.  */
 
 static int
-get_number_trailer (char **pp, int trailer)
+get_number_trailer (const char **pp, int trailer)
 {
   int retval = 0;	/* default */
-  char *p = *pp;
+  const char *p = *pp;
 
   if (*p == '$')
     {
@@ -59,7 +59,7 @@ get_number_trailer (char **pp, int trailer)
 	  /* Internal variable.  Make a copy of the name, so we can
 	     null-terminate it to pass to lookup_internalvar().  */
 	  char *varname;
-	  char *start = ++p;
+	  const char *start = ++p;
 	  LONGEST val;
 
 	  while (isalnum (*p) || *p == '_')
@@ -102,7 +102,7 @@ get_number_trailer (char **pp, int trailer)
 	++p;
       retval = 0;
     }
-  p = skip_spaces (p);
+  p = skip_spaces_const (p);
   *pp = p;
   return retval;
 }
@@ -110,16 +110,29 @@ get_number_trailer (char **pp, int trailer)
 /* See documentation in cli-utils.h.  */
 
 int
-get_number (char **pp)
+get_number_const (const char **pp)
 {
   return get_number_trailer (pp, '\0');
 }
 
 /* See documentation in cli-utils.h.  */
 
+int
+get_number (char **pp)
+{
+  int result;
+  const char *p = *pp;
+
+  result = get_number_trailer (&p, '\0');
+  *pp = (char *) p;
+  return result;
+}
+
+/* See documentation in cli-utils.h.  */
+
 void
 init_number_or_range (struct get_number_or_range_state *state,
-		      char *string)
+		      const char *string)
 {
   memset (state, 0, sizeof (*state));
   state->string = string;
@@ -137,15 +150,15 @@ get_number_or_range (struct get_number_or_range_state *state)
       state->last_retval = get_number_trailer (&state->string, '-');
       if (*state->string == '-')
 	{
-	  char **temp;
+	  const char **temp;
 
 	  /* This is the start of a range (<number1> - <number2>).
 	     Skip the '-', parse and remember the second number,
 	     and also remember the end of the final token.  */
 
 	  temp = &state->end_ptr; 
-	  state->end_ptr = skip_spaces (state->string + 1);
-	  state->end_value = get_number (temp);
+	  state->end_ptr = skip_spaces_const (state->string + 1);
+	  state->end_value = get_number_const (temp);
 	  if (state->end_value < state->last_retval) 
 	    {
 	      error (_("inverted range"));
@@ -191,7 +204,7 @@ get_number_or_range (struct get_number_or_range_state *state)
    no arguments.  */
 
 int
-number_is_in_list (char *list, int number)
+number_is_in_list (const char *list, int number)
 {
   struct get_number_or_range_state state;
 
diff --git a/gdb/cli/cli-utils.h b/gdb/cli/cli-utils.h
index fed876b..1f0f3df 100644
--- a/gdb/cli/cli-utils.h
+++ b/gdb/cli/cli-utils.h
@@ -26,6 +26,10 @@
    Currently the string can either be a number,  or "$" followed by the
    name of a convenience variable, or ("$" or "$$") followed by digits.  */
 
+extern int get_number_const (const char **);
+
+/* Like get_number_const, but takes a non-const "char **".  */
+
 extern int get_number (char **);
 
 /* An object of this type is passed to get_number_or_range.  It must
@@ -40,7 +44,7 @@ struct get_number_or_range_state
 
   /* The string being parsed.  When parsing has finished, this points
      past the last parsed token.  */
-  char *string;
+  const char *string;
 
   /* Last value returned.  */
   int last_retval;
@@ -50,7 +54,7 @@ struct get_number_or_range_state
 
   /* When parsing a range, a pointer past the final token in the
      range.  */
-  char *end_ptr;
+  const char *end_ptr;
 
   /* Non-zero when parsing a range.  */
   int in_range;
@@ -60,7 +64,7 @@ struct get_number_or_range_state
    get_number_or_range_state.  STRING is the string to be parsed.  */
 
 extern void init_number_or_range (struct get_number_or_range_state *state,
-				  char *string);
+				  const char *string);
 
 /* Parse a number or a range.
    A number will be of the form handled by get_number.
@@ -87,7 +91,7 @@ extern int get_number_or_range (struct get_number_or_range_state *state);
    be interpreted as typing a command such as "delete break" with 
    no arguments.  */
 
-extern int number_is_in_list (char *list, int number);
+extern int number_is_in_list (const char *list, int number);
 
 /* Skip leading whitespace characters in INP, returning an updated
    pointer.  If INP is NULL, return NULL.  */
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index 228d4ad..b4fd894 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -1618,7 +1618,7 @@ map_display_numbers (char *args,
 
   while (!state.finished)
     {
-      char *p = state.string;
+      const char *p = state.string;
 
       num = get_number_or_range (&state);
       if (num == 0)
diff --git a/gdb/value.c b/gdb/value.c
index 29abe5f..5666aa3 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -3446,7 +3446,7 @@ value_from_decfloat (struct type *type, const gdb_byte *dec)
    for details.  */
 
 struct value *
-value_from_history_ref (char *h, char **endp)
+value_from_history_ref (const char *h, const char **endp)
 {
   int index, len;
 
@@ -3477,7 +3477,12 @@ value_from_history_ref (char *h, char **endp)
 	  *endp += len;
 	}
       else
-	index = -strtol (&h[2], endp, 10);
+	{
+	  char *local_end;
+
+	  index = -strtol (&h[2], &local_end, 10);
+	  *endp = local_end;
+	}
     }
   else
     {
@@ -3488,7 +3493,12 @@ value_from_history_ref (char *h, char **endp)
 	  *endp += len;
 	}
       else
-	index = strtol (&h[1], endp, 10);
+	{
+	  char *local_end;
+
+	  index = strtol (&h[1], &local_end, 10);
+	  *endp = local_end;
+	}
     }
 
   return access_value_history (index);
diff --git a/gdb/value.h b/gdb/value.h
index 86ebd70..4654042 100644
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -569,7 +569,7 @@ extern struct value *value_from_pointer (struct type *type, CORE_ADDR addr);
 extern struct value *value_from_double (struct type *type, DOUBLEST num);
 extern struct value *value_from_decfloat (struct type *type,
 					  const gdb_byte *decbytes);
-extern struct value *value_from_history_ref (char *, char **);
+extern struct value *value_from_history_ref (const char *, const char **);
 
 extern struct value *value_at (struct type *type, CORE_ADDR addr);
 extern struct value *value_at_lazy (struct type *type, CORE_ADDR addr);
-- 
1.9.3


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/3] constify exec_file_attach
  2014-07-23 21:27 ` [PATCH 1/3] constify exec_file_attach Tom Tromey
@ 2014-07-24  1:27   ` Pedro Alves
  2014-07-24 15:23     ` Tom Tromey
  0 siblings, 1 reply; 10+ messages in thread
From: Pedro Alves @ 2014-07-24  1:27 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 07/23/2014 10:27 PM, Tom Tromey wrote:
> @@ -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))

Why not use catch_command_errors_const instead?  Seems like
you wouldn't need call_exec_file_attach then.

>  	catch_command_errors_const (symbol_file_add_main, symarg,
>  				    !batch_flag, RETURN_MASK_ALL);

-- 
Pedro Alves


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/3] constify some cli-utils stuff
  2014-07-23 22:06 ` [PATCH 2/3] constify some cli-utils stuff Tom Tromey
@ 2014-07-24  1:32   ` Pedro Alves
  0 siblings, 0 replies; 10+ messages in thread
From: Pedro Alves @ 2014-07-24  1:32 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

Looks good.

Thanks,
Pedro Alves

On 07/23/2014 10:27 PM, Tom Tromey wrote:
> This constifies a few functions in cli-utils -- get_number_trailer and
> friends -- and then fixes the fallout.
> 
> 2014-07-22  Tom Tromey  <tromey@redhat.com>
> 
> 	* breakpoint.c (map_breakpoint_numbers): Update.
> 	* cli/cli-utils.c (get_number_trailer): Make "pp" const.  Update.
> 	(get_number_const): New function.
> 	(get_number): Rewrite using get_number_const.
> 	(init_number_or_range): Make "string" const.
> 	(number_is_in_list): Make "list" const.
> 	* cli/cli-utils.h (get_number_const): Declare.
> 	(struct get_number_or_range_state) <string, end_ptr>: Now const.
> 	(init_number_or_range, number_is_in_list): Update.
> 	* printcmd.c (map_display_numbers): Update.
> 	* value.c (value_from_history_ref): Constify.
> 	* value.h (value_from_history_ref): Update.
> ---
>  gdb/ChangeLog       | 15 +++++++++++++++
>  gdb/breakpoint.c    |  2 +-
>  gdb/cli/cli-utils.c | 33 +++++++++++++++++++++++----------
>  gdb/cli/cli-utils.h | 12 ++++++++----
>  gdb/printcmd.c      |  2 +-
>  gdb/value.c         | 16 +++++++++++++---
>  gdb/value.h         |  2 +-
>  7 files changed, 62 insertions(+), 20 deletions(-)
> 
> diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
> index 908a1ea..775d555 100644
> --- a/gdb/breakpoint.c
> +++ b/gdb/breakpoint.c
> @@ -14790,7 +14790,7 @@ map_breakpoint_numbers (char *args, void (*function) (struct breakpoint *,
>  
>    while (!state.finished)
>      {
> -      char *p = state.string;
> +      const char *p = state.string;
>  
>        match = 0;
>  
> diff --git a/gdb/cli/cli-utils.c b/gdb/cli/cli-utils.c
> index a0ebc11..819c94c 100644
> --- a/gdb/cli/cli-utils.c
> +++ b/gdb/cli/cli-utils.c
> @@ -35,10 +35,10 @@
>     commonly this is `-'.  If you don't want a trailer, use \0.  */
>  
>  static int
> -get_number_trailer (char **pp, int trailer)
> +get_number_trailer (const char **pp, int trailer)
>  {
>    int retval = 0;	/* default */
> -  char *p = *pp;
> +  const char *p = *pp;
>  
>    if (*p == '$')
>      {
> @@ -59,7 +59,7 @@ get_number_trailer (char **pp, int trailer)
>  	  /* Internal variable.  Make a copy of the name, so we can
>  	     null-terminate it to pass to lookup_internalvar().  */
>  	  char *varname;
> -	  char *start = ++p;
> +	  const char *start = ++p;
>  	  LONGEST val;
>  
>  	  while (isalnum (*p) || *p == '_')
> @@ -102,7 +102,7 @@ get_number_trailer (char **pp, int trailer)
>  	++p;
>        retval = 0;
>      }
> -  p = skip_spaces (p);
> +  p = skip_spaces_const (p);
>    *pp = p;
>    return retval;
>  }
> @@ -110,16 +110,29 @@ get_number_trailer (char **pp, int trailer)
>  /* See documentation in cli-utils.h.  */
>  
>  int
> -get_number (char **pp)
> +get_number_const (const char **pp)
>  {
>    return get_number_trailer (pp, '\0');
>  }
>  
>  /* See documentation in cli-utils.h.  */
>  
> +int
> +get_number (char **pp)
> +{
> +  int result;
> +  const char *p = *pp;
> +
> +  result = get_number_trailer (&p, '\0');
> +  *pp = (char *) p;
> +  return result;
> +}
> +
> +/* See documentation in cli-utils.h.  */
> +
>  void
>  init_number_or_range (struct get_number_or_range_state *state,
> -		      char *string)
> +		      const char *string)
>  {
>    memset (state, 0, sizeof (*state));
>    state->string = string;
> @@ -137,15 +150,15 @@ get_number_or_range (struct get_number_or_range_state *state)
>        state->last_retval = get_number_trailer (&state->string, '-');
>        if (*state->string == '-')
>  	{
> -	  char **temp;
> +	  const char **temp;
>  
>  	  /* This is the start of a range (<number1> - <number2>).
>  	     Skip the '-', parse and remember the second number,
>  	     and also remember the end of the final token.  */
>  
>  	  temp = &state->end_ptr; 
> -	  state->end_ptr = skip_spaces (state->string + 1);
> -	  state->end_value = get_number (temp);
> +	  state->end_ptr = skip_spaces_const (state->string + 1);
> +	  state->end_value = get_number_const (temp);
>  	  if (state->end_value < state->last_retval) 
>  	    {
>  	      error (_("inverted range"));
> @@ -191,7 +204,7 @@ get_number_or_range (struct get_number_or_range_state *state)
>     no arguments.  */
>  
>  int
> -number_is_in_list (char *list, int number)
> +number_is_in_list (const char *list, int number)
>  {
>    struct get_number_or_range_state state;
>  
> diff --git a/gdb/cli/cli-utils.h b/gdb/cli/cli-utils.h
> index fed876b..1f0f3df 100644
> --- a/gdb/cli/cli-utils.h
> +++ b/gdb/cli/cli-utils.h
> @@ -26,6 +26,10 @@
>     Currently the string can either be a number,  or "$" followed by the
>     name of a convenience variable, or ("$" or "$$") followed by digits.  */
>  
> +extern int get_number_const (const char **);
> +
> +/* Like get_number_const, but takes a non-const "char **".  */
> +
>  extern int get_number (char **);
>  
>  /* An object of this type is passed to get_number_or_range.  It must
> @@ -40,7 +44,7 @@ struct get_number_or_range_state
>  
>    /* The string being parsed.  When parsing has finished, this points
>       past the last parsed token.  */
> -  char *string;
> +  const char *string;
>  
>    /* Last value returned.  */
>    int last_retval;
> @@ -50,7 +54,7 @@ struct get_number_or_range_state
>  
>    /* When parsing a range, a pointer past the final token in the
>       range.  */
> -  char *end_ptr;
> +  const char *end_ptr;
>  
>    /* Non-zero when parsing a range.  */
>    int in_range;
> @@ -60,7 +64,7 @@ struct get_number_or_range_state
>     get_number_or_range_state.  STRING is the string to be parsed.  */
>  
>  extern void init_number_or_range (struct get_number_or_range_state *state,
> -				  char *string);
> +				  const char *string);
>  
>  /* Parse a number or a range.
>     A number will be of the form handled by get_number.
> @@ -87,7 +91,7 @@ extern int get_number_or_range (struct get_number_or_range_state *state);
>     be interpreted as typing a command such as "delete break" with 
>     no arguments.  */
>  
> -extern int number_is_in_list (char *list, int number);
> +extern int number_is_in_list (const char *list, int number);
>  
>  /* Skip leading whitespace characters in INP, returning an updated
>     pointer.  If INP is NULL, return NULL.  */
> diff --git a/gdb/printcmd.c b/gdb/printcmd.c
> index 228d4ad..b4fd894 100644
> --- a/gdb/printcmd.c
> +++ b/gdb/printcmd.c
> @@ -1618,7 +1618,7 @@ map_display_numbers (char *args,
>  
>    while (!state.finished)
>      {
> -      char *p = state.string;
> +      const char *p = state.string;
>  
>        num = get_number_or_range (&state);
>        if (num == 0)
> diff --git a/gdb/value.c b/gdb/value.c
> index 29abe5f..5666aa3 100644
> --- a/gdb/value.c
> +++ b/gdb/value.c
> @@ -3446,7 +3446,7 @@ value_from_decfloat (struct type *type, const gdb_byte *dec)
>     for details.  */
>  
>  struct value *
> -value_from_history_ref (char *h, char **endp)
> +value_from_history_ref (const char *h, const char **endp)
>  {
>    int index, len;
>  
> @@ -3477,7 +3477,12 @@ value_from_history_ref (char *h, char **endp)
>  	  *endp += len;
>  	}
>        else
> -	index = -strtol (&h[2], endp, 10);
> +	{
> +	  char *local_end;
> +
> +	  index = -strtol (&h[2], &local_end, 10);
> +	  *endp = local_end;
> +	}
>      }
>    else
>      {
> @@ -3488,7 +3493,12 @@ value_from_history_ref (char *h, char **endp)
>  	  *endp += len;
>  	}
>        else
> -	index = strtol (&h[1], endp, 10);
> +	{
> +	  char *local_end;
> +
> +	  index = strtol (&h[1], &local_end, 10);
> +	  *endp = local_end;
> +	}
>      }
>  
>    return access_value_history (index);
> diff --git a/gdb/value.h b/gdb/value.h
> index 86ebd70..4654042 100644
> --- a/gdb/value.h
> +++ b/gdb/value.h
> @@ -569,7 +569,7 @@ extern struct value *value_from_pointer (struct type *type, CORE_ADDR addr);
>  extern struct value *value_from_double (struct type *type, DOUBLEST num);
>  extern struct value *value_from_decfloat (struct type *type,
>  					  const gdb_byte *decbytes);
> -extern struct value *value_from_history_ref (char *, char **);
> +extern struct value *value_from_history_ref (const char *, const char **);
>  
>  extern struct value *value_at (struct type *type, CORE_ADDR addr);
>  extern struct value *value_at_lazy (struct type *type, CORE_ADDR addr);
> 



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 3/3] constify to_open
  2014-07-23 21:27 ` [PATCH 3/3] constify to_open Tom Tromey
@ 2014-07-24  1:34   ` Pedro Alves
  0 siblings, 0 replies; 10+ messages in thread
From: Pedro Alves @ 2014-07-24  1:34 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

Looks good.

Thanks,
Pedro Alves

On 07/23/2014 10:27 PM, Tom Tromey wrote:
> 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-22  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.
> 	* inf-child.c (inf_child_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.
> ---
>  gdb/ChangeLog         | 25 +++++++++++++++++++++++++
>  gdb/bsd-kvm.c         |  7 ++++---
>  gdb/corelow.c         |  9 ++++-----
>  gdb/ctf.c             |  4 ++--
>  gdb/dbug-rom.c        |  4 +---
>  gdb/dink32-rom.c      |  4 +---
>  gdb/exec.c            |  2 +-
>  gdb/inf-child.c       |  4 ++--
>  gdb/inf-child.h       |  2 +-
>  gdb/m32r-rom.c        |  7 ++-----
>  gdb/microblaze-rom.c  |  2 +-
>  gdb/monitor.c         |  2 +-
>  gdb/monitor.h         |  3 ++-
>  gdb/nto-procfs.c      |  6 +++---
>  gdb/ppcbug-rom.c      |  4 ++--
>  gdb/record-btrace.c   |  2 +-
>  gdb/record-full.c     |  6 +++---
>  gdb/remote-m32r-sdi.c |  2 +-
>  gdb/remote-mips.c     | 20 ++++++--------------
>  gdb/remote-sim.c      |  2 +-
>  gdb/remote.c          | 15 ++++++---------
>  gdb/target.h          |  2 +-
>  gdb/tracefile-tfile.c |  7 ++++---
>  23 files changed, 75 insertions(+), 66 deletions(-)
> 
> diff --git a/gdb/bsd-kvm.c b/gdb/bsd-kvm.c
> index 35ecebb..6705035 100644
> --- a/gdb/bsd-kvm.c
> +++ b/gdb/bsd-kvm.c
> @@ -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);
> diff --git a/gdb/corelow.c b/gdb/corelow.c
> index 1775a66..9290f18 100644
> --- a/gdb/corelow.c
> +++ b/gdb/corelow.c
> @@ -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, "/",
> diff --git a/gdb/ctf.c b/gdb/ctf.c
> index 84d0a48..df645c0 100644
> --- 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;
> diff --git a/gdb/dbug-rom.c b/gdb/dbug-rom.c
> index 4157f27..c775543 100644
> --- a/gdb/dbug-rom.c
> +++ b/gdb/dbug-rom.c
> @@ -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);
>  }
> diff --git a/gdb/dink32-rom.c b/gdb/dink32-rom.c
> index 52d428d..9ab81ae 100644
> --- a/gdb/dink32-rom.c
> +++ b/gdb/dink32-rom.c
> @@ -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);
>  }
> diff --git a/gdb/exec.c b/gdb/exec.c
> index e42ef20..98defbc 100644
> --- a/gdb/exec.c
> +++ b/gdb/exec.c
> @@ -79,7 +79,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);
> diff --git a/gdb/inf-child.c b/gdb/inf-child.c
> index 897e635..82a2781 100644
> --- a/gdb/inf-child.c
> +++ b/gdb/inf-child.c
> @@ -122,7 +122,7 @@ static int inf_child_explicitly_opened;
>  /* See inf-child.h.  */
>  
>  void
> -inf_child_open_target (struct target_ops *target, char *arg, int from_tty)
> +inf_child_open_target (struct target_ops *target, const char *arg, int from_tty)
>  {
>    target_preopen (from_tty);
>    push_target (target);
> @@ -132,7 +132,7 @@ inf_child_open_target (struct target_ops *target, char *arg, int from_tty)
>  }
>  
>  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);
>  }
> diff --git a/gdb/inf-child.h b/gdb/inf-child.h
> index b2692ca..163cab6 100644
> --- a/gdb/inf-child.h
> +++ b/gdb/inf-child.h
> @@ -34,7 +34,7 @@ extern void store_waitstatus (struct target_waitstatus *, int);
>     the target, in case it need to override to_open.  */
>  
>  extern void inf_child_open_target (struct target_ops *target,
> -				   char *arg, int from_tty);
> +				   const char *arg, int from_tty);
>  
>  /* To be called by the native target's to_mourn_inferior routine.  */
>  
> diff --git a/gdb/m32r-rom.c b/gdb/m32r-rom.c
> index 0ab252a..6b20cd1 100644
> --- a/gdb/m32r-rom.c
> +++ b/gdb/m32r-rom.c
> @@ -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);
>  }
> diff --git a/gdb/microblaze-rom.c b/gdb/microblaze-rom.c
> index 936865c..a64217d 100644
> --- a/gdb/microblaze-rom.c
> +++ b/gdb/microblaze-rom.c
> @@ -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);
>  }
> diff --git a/gdb/monitor.c b/gdb/monitor.c
> index 61f0dff..788bca0 100644
> --- a/gdb/monitor.c
> +++ b/gdb/monitor.c
> @@ -713,7 +713,7 @@ compile_pattern (char *pattern, struct re_pattern_buffer *compiled_pattern,
>     for communication.  */
>  
>  void
> -monitor_open (char *args, struct monitor_ops *mon_ops, int from_tty)
> +monitor_open (const char *args, struct monitor_ops *mon_ops, int from_tty)
>  {
>    char *name;
>    char **p;
> diff --git a/gdb/monitor.h b/gdb/monitor.h
> index 07caf97..52521c8 100644
> --- a/gdb/monitor.h
> +++ b/gdb/monitor.h
> @@ -239,7 +239,8 @@ struct monitor_ops
>  
>  #define SREC_SIZE 160
>  
> -extern void monitor_open (char *args, struct monitor_ops *ops, int from_tty);
> +extern void monitor_open (const char *args, struct monitor_ops *ops,
> +			  int from_tty);
>  extern void monitor_close (struct target_ops *self);
>  extern char *monitor_supply_register (struct regcache *regcache,
>  				      int regno, char *valstr);
> diff --git a/gdb/nto-procfs.c b/gdb/nto-procfs.c
> index 728d6f3..ff8f2af 100644
> --- a/gdb/nto-procfs.c
> +++ b/gdb/nto-procfs.c
> @@ -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);
>  }
> diff --git a/gdb/ppcbug-rom.c b/gdb/ppcbug-rom.c
> index 3038713..f1740d1 100644
> --- a/gdb/ppcbug-rom.c
> +++ b/gdb/ppcbug-rom.c
> @@ -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);
>  }
> diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
> index 5ba4e06..3601e13 100644
> --- a/gdb/record-btrace.c
> +++ b/gdb/record-btrace.c
> @@ -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;
> diff --git a/gdb/record-full.c b/gdb/record-full.c
> index fcd7790..119361f 100644
> --- a/gdb/record-full.c
> +++ b/gdb/record-full.c
> @@ -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;
>  
> diff --git a/gdb/remote-m32r-sdi.c b/gdb/remote-m32r-sdi.c
> index 37efaec..f3d5879 100644
> --- a/gdb/remote-m32r-sdi.c
> +++ b/gdb/remote-m32r-sdi.c
> @@ -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;
> diff --git a/gdb/remote-mips.c b/gdb/remote-mips.c
> index 277621d..236f3cd 100644
> --- a/gdb/remote-mips.c
> +++ b/gdb/remote-mips.c
> @@ -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;
>  
> diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c
> index 4097372..ff7bf3a 100644
> --- a/gdb/remote-sim.c
> +++ b/gdb/remote-sim.c
> @@ -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;
> diff --git a/gdb/remote.c b/gdb/remote.c
> index 76efefa..e3e56f3 100644
> --- a/gdb/remote.c
> +++ b/gdb/remote.c
> @@ -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 */);
>  }
> @@ -3727,7 +3724,7 @@ remote_check_symbols (void)
>  }
>  
>  static struct serial *
> -remote_serial_open (char *name)
> +remote_serial_open (const char *name)
>  {
>    static int udp_warning = 0;
>  
> @@ -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 ();
> diff --git a/gdb/target.h b/gdb/target.h
> index 92572ff..8ff358e 100644
> --- a/gdb/target.h
> +++ b/gdb/target.h
> @@ -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").  */
> diff --git a/gdb/tracefile-tfile.c b/gdb/tracefile-tfile.c
> index 37dc691..5ba1b15 100644
> --- a/gdb/tracefile-tfile.c
> +++ b/gdb/tracefile-tfile.c
> @@ -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);
> 


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/3] constify exec_file_attach
  2014-07-24  1:27   ` Pedro Alves
@ 2014-07-24 15:23     ` Tom Tromey
  2014-07-24 15:27       ` Pedro Alves
  0 siblings, 1 reply; 10+ messages in thread
From: Tom Tromey @ 2014-07-24 15:23 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:

Pedro> Why not use catch_command_errors_const instead?

I had just forgotten about its existence.
I've made the obvious fix here.

Tom


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/3] constify exec_file_attach
  2014-07-24 15:23     ` Tom Tromey
@ 2014-07-24 15:27       ` Pedro Alves
  0 siblings, 0 replies; 10+ messages in thread
From: Pedro Alves @ 2014-07-24 15:27 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 07/24/2014 04:21 PM, Tom Tromey wrote:
>>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:
> 
> Pedro> Why not use catch_command_errors_const instead?
> 
> I had just forgotten about its existence.
> I've made the obvious fix here.

Great, thanks.

Thanks,
Pedro Alves


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 0/3] constification of to_open
  2014-07-23 21:27 [PATCH 0/3] constification of to_open Tom Tromey
                   ` (2 preceding siblings ...)
  2014-07-23 22:06 ` [PATCH 2/3] constify some cli-utils stuff Tom Tromey
@ 2014-07-30 14:04 ` Tom Tromey
  3 siblings, 0 replies; 10+ messages in thread
From: Tom Tromey @ 2014-07-30 14:04 UTC (permalink / raw)
  To: gdb-patches

>>>>> "Tom" == Tom Tromey <tromey@redhat.com> writes:

Tom> This series, based on the target debug fix for to_open, constifies the
Tom> string argument to to_open.  I think this is the last major
Tom> constification for target_ops.

I'm pushing this now.

Please report any build issues to me.  I don't anticipate any but as I
mentioned in the patch, I was unable to test all the changes.

Tom


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2014-07-30 14:02 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-23 21:27 [PATCH 0/3] constification of to_open Tom Tromey
2014-07-23 21:27 ` [PATCH 1/3] constify exec_file_attach Tom Tromey
2014-07-24  1:27   ` Pedro Alves
2014-07-24 15:23     ` Tom Tromey
2014-07-24 15:27       ` Pedro Alves
2014-07-23 21:27 ` [PATCH 3/3] constify to_open Tom Tromey
2014-07-24  1:34   ` Pedro Alves
2014-07-23 22:06 ` [PATCH 2/3] constify some cli-utils stuff Tom Tromey
2014-07-24  1:32   ` Pedro Alves
2014-07-30 14:04 ` [PATCH 0/3] constification of to_open Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox