From patchwork Wed May 21 18:20:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 1059 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx23.g.dreamhost.com (mx2.sub5.homie.mail.dreamhost.com [208.113.200.128]) by wilcox.dreamhost.com (Postfix) with ESMTP id 368DD360073 for ; Wed, 21 May 2014 11:21:04 -0700 (PDT) Received: by homiemail-mx23.g.dreamhost.com (Postfix, from userid 14314964) id EC51D63FE904E; Wed, 21 May 2014 11:21:03 -0700 (PDT) X-Original-To: gdb@patchwork.siddhesh.in Delivered-To: x14314964@homiemail-mx23.g.dreamhost.com Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by homiemail-mx23.g.dreamhost.com (Postfix) with ESMTPS id CD14C63FE9053 for ; Wed, 21 May 2014 11:21:03 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id; q=dns; s= default; b=Z9YXa78ZNmuoRxokzxHcuqhcPxAKpE6QAPfpxH04uxChjcngqvyzX rykMYDfkOl9leCkCHdjF+M2MsarjJJQQW2+nL3icNuwimBSLlnvakVW1Rld00EI3 Wn+7DWoIjyGKY/tK+6zfh6QyBACBlVL3L8cxeM9JDtxQx7bQet/nLI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id; s=default; bh=L3xiC40Ns8tDFkupfvkEVATkGuc=; b=hzG8RmekW0AFZLsSn3NmIBkTHC1X EuzgMkC/uZR3y1Z1LO6oT203uug+KtfJdfzeRQxJMvkuNnjUGzX7idm9yDCb63XE 6TY/GTBbdVcPKaLaPcei80mfKQlcWAfXLNa2dyxdr8GE0rehOZwhY9Rkcb3l4wzH /FcsFNL8ZAjIE1s= Received: (qmail 6500 invoked by alias); 21 May 2014 18:21:02 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 6489 invoked by uid 89); 21 May 2014 18:21:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 21 May 2014 18:21:00 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s4LIKxpu027501 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 21 May 2014 14:20:59 -0400 Received: from barimba.redhat.com (ovpn-113-182.phx2.redhat.com [10.3.113.182]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s4LIKwk5024885; Wed, 21 May 2014 14:20:58 -0400 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] constify to_attach Date: Wed, 21 May 2014 12:20:55 -0600 Message-Id: <1400696455-29563-1-git-send-email-tromey@redhat.com> X-DH-Original-To: gdb@patchwork.siddhesh.in 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-05-21 Tom Tromey * 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) : Make "args" const. (find_default_attach): Likewise. * utils.c (parse_pid_to_attach): Make "args" const. * utils.h (parse_pid_to_attach): Update. --- gdb/ChangeLog | 17 +++++++++++++++++ gdb/darwin-nat.c | 2 +- gdb/gnu-nat.c | 2 +- gdb/go32-nat.c | 2 +- gdb/inf-ptrace.c | 2 +- gdb/inf-ttrace.c | 2 +- gdb/linux-nat.c | 2 +- gdb/nto-procfs.c | 2 +- gdb/remote.c | 5 +++-- gdb/target.h | 4 ++-- gdb/utils.c | 4 ++-- gdb/utils.h | 2 +- gdb/windows-nat.c | 2 +- 13 files changed, 33 insertions(+), 15 deletions(-) diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c index f3d510d..51087ea 100644 --- a/gdb/darwin-nat.c +++ b/gdb/darwin-nat.c @@ -1673,7 +1673,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; diff --git a/gdb/gnu-nat.c b/gdb/gnu-nat.c index 3317215..5177ac0 100644 --- a/gdb/gnu-nat.c +++ b/gdb/gnu-nat.c @@ -2166,7 +2166,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; diff --git a/gdb/go32-nat.c b/gdb/go32-nat.c index 77843ea..c7a5e5a 100644 --- a/gdb/go32-nat.c +++ b/gdb/go32-nat.c @@ -339,7 +339,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\ diff --git a/gdb/inf-ptrace.c b/gdb/inf-ptrace.c index cc4921b..4c1a18c 100644 --- a/gdb/inf-ptrace.c +++ b/gdb/inf-ptrace.c @@ -183,7 +183,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; diff --git a/gdb/inf-ttrace.c b/gdb/inf-ttrace.c index 96105dc..406ec26 100644 --- a/gdb/inf-ttrace.c +++ b/gdb/inf-ttrace.c @@ -748,7 +748,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; diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c index f60d54c..ff4dff6 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -1300,7 +1300,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; diff --git a/gdb/nto-procfs.c b/gdb/nto-procfs.c index 8a241a8..0d0197d 100644 --- a/gdb/nto-procfs.c +++ b/gdb/nto-procfs.c @@ -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; diff --git a/gdb/remote.c b/gdb/remote.c index 964bd41..394b58e 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -4364,7 +4364,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; @@ -4477,7 +4478,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); } diff --git a/gdb/target.h b/gdb/target.h index 9371529..e841ffb 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -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); diff --git a/gdb/utils.c b/gdb/utils.c index a8a7cb3..7506c37 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -3249,7 +3249,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; @@ -3257,7 +3257,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)]) diff --git a/gdb/utils.h b/gdb/utils.h index 33371ac..0eba8ae 100644 --- a/gdb/utils.h +++ b/gdb/utils.h @@ -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 **); diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index fe43c24..a2a95e5 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -1833,7 +1833,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;