diff options
Diffstat (limited to 'gdb/utils.c')
-rw-r--r-- | gdb/utils.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/gdb/utils.c b/gdb/utils.c index 33c195a..52596ca 100644 --- a/gdb/utils.c +++ b/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; |