From patchwork Wed May 21 18:58:21 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 1061 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx20.g.dreamhost.com (mx2.sub5.homie.mail.dreamhost.com [208.113.200.128]) by wilcox.dreamhost.com (Postfix) with ESMTP id B007A360079 for ; Wed, 21 May 2014 11:58:28 -0700 (PDT) Received: by homiemail-mx20.g.dreamhost.com (Postfix, from userid 14314964) id 70D5341E97B2A; Wed, 21 May 2014 11:58:28 -0700 (PDT) X-Original-To: gdb@patchwork.siddhesh.in Delivered-To: x14314964@homiemail-mx20.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-mx20.g.dreamhost.com (Postfix) with ESMTPS id 4FDC641E53FE9 for ; Wed, 21 May 2014 11:58:28 -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:subject:references:date:in-reply-to :message-id:mime-version:content-type; q=dns; s=default; b=XN9OS S5eDtD51Rv/sLrWHjzRkwhYp0nISMfQhpkS5gaIisI9nu7OTb+KeRPJetZUiJYxa rggbe2AV+EbdHAfTLV8JMH0t8yYTjjSr62Nx7b490Yin7DQZ9rXGLovFKRSysZan NtA2sQe4IOs5hC+OmqmUk7IPMcLqBcGg4HyTP0= 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:subject:references:date:in-reply-to :message-id:mime-version:content-type; s=default; bh=iCwlfMqGnIV Je+9dGMUAII0Yijs=; b=NleZD5FGxbrzIY5G4pGtdq7HfrfivpygvkAVj88DT8R QsQoQ4JpbVptGFMNC22fVd23N3aT2CQSgirt3p4KPuinZrUrRSzxjeAu9av6HGg6 tRVraGk0u/9cZ7db8Dd9vZg7Eo6ufNWpM4l+ArXAnZnF4x2jAFM+Hun/3rKVczAM = Received: (qmail 12248 invoked by alias); 21 May 2014 18:58:27 -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 12236 invoked by uid 89); 21 May 2014 18:58:26 -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:58:24 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s4LIwN8L020567 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 21 May 2014 14:58:23 -0400 Received: from barimba (ovpn-113-182.phx2.redhat.com [10.3.113.182]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s4LIwMbI003943 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=NO); Wed, 21 May 2014 14:58:22 -0400 From: Tom Tromey To: gdb-patches@sourceware.org Subject: Re: [PATCH] constify to_attach References: <1400696455-29563-1-git-send-email-tromey@redhat.com> Date: Wed, 21 May 2014 12:58:21 -0600 In-Reply-To: <1400696455-29563-1-git-send-email-tromey@redhat.com> (Tom Tromey's message of "Wed, 21 May 2014 12:20:55 -0600") Message-ID: <87mwebhsc2.fsf@fleche.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 X-DH-Original-To: gdb@patchwork.siddhesh.in >>>>> "Tom" == Tom Tromey writes: Tom> This constifies the "args" argument to the target_ops to_attach Tom> method. Tom> I updated all instances of the method. .. except procfs.c, which I somehow missed. Here's the updated patch. I also wanted to note that I checked all the functions for forward declarations as well. Tom 2014-05-21 Tom Tromey * 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) : Make "args" const. (find_default_attach): Likewise. * utils.c (parse_pid_to_attach): Make "args" const. * utils.h (parse_pid_to_attach): Update. commit 2f15772fddec94e04478a52d63e333e53e4d4bf5 Author: Tom Tromey Date: Mon Apr 15 09:40:57 2013 -0600 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-05-21 Tom Tromey * 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) : Make "args" const. (find_default_attach): Likewise. * utils.c (parse_pid_to_attach): Make "args" const. * utils.h (parse_pid_to_attach): Update. 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/procfs.c b/gdb/procfs.c index 80b0a6a..90c53e3 100644 --- a/gdb/procfs.c +++ b/gdb/procfs.c @@ -109,7 +109,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); @@ -3038,7 +3038,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; 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;