mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-01 11:59:27 +08:00
gdb/
* defs.h (parse_pid_to_attach): New. * utils.c (parse_pid_to_attach): New. * darwin-nat.c (darwin_attach): Replace ARGS parsing by parse_pid. * gnu-nat.c (gnu_attach): Likewise. * nto-procfs.c (procfs_attach): Likewise. * procfs.c (procfs_attach): Likewise. * windows-nat.c (windows_attach): Likewise. * inf-ptrace.c (inf_ptrace_attach): Likewise. Remove variable dummy. * inf-ttrace.c (inf_ttrace_attach): Likewise. * remote.c (extended_remote_attach_1): Likewise. New comment on getpid check. gdb/testsuite/ * gdb.base/attach.exp (attach to nonsense is prohibited): Make the "Illegal process-id" expect string more exact. (attach to digits-starting nonsense is prohibited): New.
This commit is contained in:
20
gdb/utils.c
20
gdb/utils.c
@ -3648,6 +3648,26 @@ gdb_bfd_errmsg (bfd_error_type error_tag, char **matching)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Return ARGS parsed as a valid pid, or throw an error. */
|
||||
|
||||
int
|
||||
parse_pid_to_attach (char *args)
|
||||
{
|
||||
unsigned long pid;
|
||||
char *dummy;
|
||||
|
||||
if (!args)
|
||||
error_no_arg (_("process-id to attach"));
|
||||
|
||||
dummy = args;
|
||||
pid = strtoul (args, &dummy, 0);
|
||||
/* Some targets don't set errno on errors, grrr! */
|
||||
if ((pid == 0 && dummy == args) || dummy != &args[strlen (args)])
|
||||
error (_("Illegal process-id: %s."), args);
|
||||
|
||||
return pid;
|
||||
}
|
||||
|
||||
/* Provide a prototype to silence -Wmissing-prototypes. */
|
||||
extern initialize_file_ftype _initialize_utils;
|
||||
|
||||
|
Reference in New Issue
Block a user