From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8075 invoked by alias); 6 Sep 2013 18:53:20 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 8065 invoked by uid 89); 6 Sep 2013 18:53:20 -0000 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; Fri, 06 Sep 2013 18:53:20 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-5.7 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com 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 r86IrEIr015728 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 6 Sep 2013 14:53:14 -0400 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r86IrCep029756; Fri, 6 Sep 2013 14:53:12 -0400 Message-ID: <522A2497.7090405@redhat.com> Date: Fri, 06 Sep 2013 18:53:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7 MIME-Version: 1.0 To: gdb-patches CC: Yue Lu , Thomas Schwinge , Luis Machado , bug-hurd@gnu.org Subject: Re: [PATCH 1/2] Port gdbserver to GNU/Hurd References: <87txi2i6t6.fsf@kepler.schwinge.homeip.net> <5225C3C6.8090101@redhat.com> <5228DBA7.9050408@redhat.com> In-Reply-To: <5228DBA7.9050408@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2013-09/txt/msg00254.txt.bz2 Hi! On 09/05/2013 08:29 PM, Pedro Alves wrote: >> > +static int >> > +gnu_read_memory (CORE_ADDR addr, unsigned char *myaddr, int length) >> > +{ >> > + int ret = 0; >> > + task_t task = (gnu_current_inf >> > + ? (gnu_current_inf->task >> > + ? gnu_current_inf->task->port : 0) : 0); >> > + if (task == MACH_PORT_NULL) >> > + return 0; >> > + ret = gnu_read_inferior (task, addr, myaddr, length); >> > + if (length != ret) >> > + { >> > + gnu_debug ("gnu_read_inferior,length=%d, but return %d\n", length, ret); >> > + return -1; >> > + } >> > + return 0; >> > +} >> > + >> > +static int >> > +gnu_write_memory (CORE_ADDR addr, const unsigned char *myaddr, int length) >> > +{ >> > + int ret = 0; >> > + task_t task = (gnu_current_inf >> > + ? (gnu_current_inf->task >> > + ? gnu_current_inf->task->port : 0) : 0); >> > + if (task == MACH_PORT_NULL) >> > + return 0; >> > + ret = gnu_write_inferior (task, addr, myaddr, length); >> > + if (length != ret) >> > + { >> > + gnu_debug ("gnu_write_inferior,length=%d, but return %d\n", length, >> > + ret); >> > + return -1; >> > + } >> > + return 0; >> > +} >> > + > These should reall be wrappers around a common shared function. I have > a patch that I think helps here. I'll post it in soon. > This is what I meant: https://sourceware.org/ml/gdb-patches/2013-09/msg00253.html I was thinking you'd wrap gnu_xfer_memory. But I have to say I don't really understand the real need for all those: task_t task = (gnu_current_inf ? (gnu_current_inf->task ? gnu_current_inf->task->port : 0) : 0); int res; if (task == MACH_PORT_NULL) return 0; checks in the existing code. I mean, why would we reach here with an invalid inferior/task/port selected? It just reads as workaround for some bug to me. Thanks, -- Pedro Alves