constify to_attach

This constifies the "args" argument to the target_ops to_attach
method.

I updated all instances of the method.  I could not compile all of
them but I hand-inspected them.  In all cases either the argument is
ignored, or it is passed to parse_pid_to_attach.  (linux-nat does some
extra stuff, but that one I built...)

If you want to try it on your host of choice, please do so.

The code in parse_pid_to_attach seems a little bogus to me.  If there
is a platform with a broken strtoul, we have better methods for fixing
the issue now.  However, I left the code as is since it is clearly ok
to do so.

Built and regtested on x86-64 Fedora 20.

2014-06-04  Tom Tromey  <tromey@redhat.com>

	* procfs.c (procfs_attach): Make "args" const.
	* windows-nat.c (windows_attach): Make "args" const.
	* nto-procfs.c (procfs_attach): Make "args" const.
	* inf-ttrace.c (inf_ttrace_attach): Make "args" const.
	* go32-nat.c (go32_attach): Make "args" const.
	* gnu-nat.c (gnu_attach): Make "args" const.
	* darwin-nat.c (darwin_attach): Make "args" const.
	* inf-ptrace.c (inf_ptrace_attach): Make "args" const.
	* linux-nat.c (linux_nat_attach): Make "args" const.
	* remote.c (extended_remote_attach_1, extended_remote_attach):
	Make "args" const.
	* target.h (struct target_ops) <to_attach>: Make "args" const.
	(find_default_attach): Likewise.
	* utils.c (parse_pid_to_attach): Make "args" const.
	* utils.h (parse_pid_to_attach): Update.
This commit is contained in:
Tom Tromey 2013-04-15 09:40:57 -06:00
parent 8eaff7cd13
commit c0939df1ce
14 changed files with 36 additions and 17 deletions

View file

@ -1,3 +1,21 @@
2014-06-04 Tom Tromey <tromey@redhat.com>
* procfs.c (procfs_attach): Make "args" const.
* windows-nat.c (windows_attach): Make "args" const.
* nto-procfs.c (procfs_attach): Make "args" const.
* inf-ttrace.c (inf_ttrace_attach): Make "args" const.
* go32-nat.c (go32_attach): Make "args" const.
* gnu-nat.c (gnu_attach): Make "args" const.
* darwin-nat.c (darwin_attach): Make "args" const.
* inf-ptrace.c (inf_ptrace_attach): Make "args" const.
* linux-nat.c (linux_nat_attach): Make "args" const.
* remote.c (extended_remote_attach_1, extended_remote_attach):
Make "args" const.
* target.h (struct target_ops) <to_attach>: Make "args" const.
(find_default_attach): Likewise.
* utils.c (parse_pid_to_attach): Make "args" const.
* utils.h (parse_pid_to_attach): Update.
2014-06-04 Tom Tromey <tromey@redhat.com>
* target-delegates.c: Rebuild.

View file

@ -1672,7 +1672,7 @@ darwin_setup_fake_stop_event (struct inferior *inf)
/* Attach to process PID, then initialize for debugging it
and wait for the trace-trap that results from attaching. */
static void
darwin_attach (struct target_ops *ops, char *args, int from_tty)
darwin_attach (struct target_ops *ops, const char *args, int from_tty)
{
pid_t pid;
pid_t pid2;

View file

@ -2165,7 +2165,7 @@ gnu_create_inferior (struct target_ops *ops,
/* Attach to process PID, then initialize for debugging it
and wait for the trace-trap that results from attaching. */
static void
gnu_attach (struct target_ops *ops, char *args, int from_tty)
gnu_attach (struct target_ops *ops, const char *args, int from_tty)
{
int pid;
char *exec_file;

View file

@ -340,7 +340,7 @@ static struct {
};
static void
go32_attach (struct target_ops *ops, char *args, int from_tty)
go32_attach (struct target_ops *ops, const char *args, int from_tty)
{
error (_("\
You cannot attach to a running program on this platform.\n\

View file

@ -181,7 +181,7 @@ inf_ptrace_mourn_inferior (struct target_ops *ops)
be chatty about it. */
static void
inf_ptrace_attach (struct target_ops *ops, char *args, int from_tty)
inf_ptrace_attach (struct target_ops *ops, const char *args, int from_tty)
{
char *exec_file;
pid_t pid;

View file

@ -747,7 +747,7 @@ inf_ttrace_create_threads_after_attach (int pid)
}
static void
inf_ttrace_attach (struct target_ops *ops, char *args, int from_tty)
inf_ttrace_attach (struct target_ops *ops, const char *args, int from_tty)
{
char *exec_file;
pid_t pid;

View file

@ -1301,7 +1301,7 @@ linux_nat_create_inferior (struct target_ops *ops,
}
static void
linux_nat_attach (struct target_ops *ops, char *args, int from_tty)
linux_nat_attach (struct target_ops *ops, const char *args, int from_tty)
{
struct lwp_info *lp;
int status;

View file

@ -602,7 +602,7 @@ procfs_files_info (struct target_ops *ignore)
/* Attach to process PID, then initialize for debugging it. */
static void
procfs_attach (struct target_ops *ops, char *args, int from_tty)
procfs_attach (struct target_ops *ops, const char *args, int from_tty)
{
char *exec_file;
int pid;

View file

@ -110,7 +110,7 @@
/* This module defines the GDB target vector and its methods. */
static void procfs_attach (struct target_ops *, char *, int);
static void procfs_attach (struct target_ops *, const char *, int);
static void procfs_detach (struct target_ops *, const char *, int);
static void procfs_resume (struct target_ops *,
ptid_t, int, enum gdb_signal);
@ -3039,7 +3039,7 @@ procfs_debug_inferior (procinfo *pi)
}
static void
procfs_attach (struct target_ops *ops, char *args, int from_tty)
procfs_attach (struct target_ops *ops, const char *args, int from_tty)
{
char *exec_file;
int pid;

View file

@ -4365,7 +4365,8 @@ remote_disconnect (struct target_ops *target, char *args, int from_tty)
be chatty about it. */
static void
extended_remote_attach_1 (struct target_ops *target, char *args, int from_tty)
extended_remote_attach_1 (struct target_ops *target, const char *args,
int from_tty)
{
struct remote_state *rs = get_remote_state ();
int pid;
@ -4478,7 +4479,7 @@ extended_remote_attach_1 (struct target_ops *target, char *args, int from_tty)
}
static void
extended_remote_attach (struct target_ops *ops, char *args, int from_tty)
extended_remote_attach (struct target_ops *ops, const char *args, int from_tty)
{
extended_remote_attach_1 (ops, args, from_tty);
}

View file

@ -409,7 +409,7 @@ struct target_ops
for normal operations, and should be ready to deliver the
status of the process immediately (without waiting) to an
upcoming target_wait call. */
void (*to_attach) (struct target_ops *ops, char *, int);
void (*to_attach) (struct target_ops *ops, const char *, int);
void (*to_post_attach) (struct target_ops *, int)
TARGET_DEFAULT_IGNORE ();
void (*to_detach) (struct target_ops *ops, const char *, int)
@ -2140,7 +2140,7 @@ extern void noprocess (void) ATTRIBUTE_NORETURN;
extern void target_require_runnable (void);
extern void find_default_attach (struct target_ops *, char *, int);
extern void find_default_attach (struct target_ops *, const char *, int);
extern void find_default_create_inferior (struct target_ops *,
char *, char *, char **, int);

View file

@ -3255,7 +3255,7 @@ gdb_bfd_errmsg (bfd_error_type error_tag, char **matching)
/* Return ARGS parsed as a valid pid, or throw an error. */
int
parse_pid_to_attach (char *args)
parse_pid_to_attach (const char *args)
{
unsigned long pid;
char *dummy;
@ -3263,7 +3263,7 @@ parse_pid_to_attach (char *args)
if (!args)
error_no_arg (_("process-id to attach"));
dummy = args;
dummy = (char *) args;
pid = strtoul (args, &dummy, 0);
/* Some targets don't set errno on errors, grrr! */
if ((pid == 0 && dummy == args) || dummy != &args[strlen (args)])

View file

@ -63,7 +63,7 @@ struct timeval get_prompt_for_continue_wait_time (void);
/* Parsing utilites. */
extern int parse_pid_to_attach (char *args);
extern int parse_pid_to_attach (const char *args);
extern int parse_escape (struct gdbarch *, const char **);

View file

@ -1834,7 +1834,7 @@ out:
/* Attach to process PID, then initialize for debugging it. */
static void
windows_attach (struct target_ops *ops, char *args, int from_tty)
windows_attach (struct target_ops *ops, const char *args, int from_tty)
{
BOOL ok;
DWORD pid;