This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [patch] PID cmdline argument should be whole from digits [+testcase]
On Sunday 14 February 2010 14:37:16, Jan Kratochvil wrote:
> --- a/gdb/remote.c
> +++ b/gdb/remote.c
> @@ -3857,17 +3857,9 @@ extended_remote_attach_1 (struct target_ops *target, char *args, int from_tty)
> {
> struct remote_state *rs = get_remote_state ();
> int pid;
> - char *dummy;
> char *wait_status = NULL;
>
> - if (!args)
> - error_no_arg (_("process-id to attach"));
> -
> - dummy = args;
> - pid = strtol (args, &dummy, 0);
> - /* Some targets don't set errno on errors, grrr! */
> - if (pid == 0 && args == dummy)
> - error (_("Illegal process-id: %s."), args);
> + pid = parse_pid (args);
> +unsigned long
> +parse_pid (char *args)
> +{
(...)
> +#ifdef HAVE_GETPID
> + if (pid == getpid ()) /* Trying to masturbate? */
> + error (_("I refuse to debug myself!"));
> +#endif
(...)
Certainly a remote PID has nothing to do with a local PID. On
windows-nat.c, the PID can either be a Windows or Cygwin PID.
--
Pedro Alves