From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 41866 invoked by alias); 21 May 2015 17:45:28 -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 41854 invoked by uid 89); 21 May 2015 17:45:28 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,SPF_HELO_PASS,T_RP_MATCHES_RCVD autolearn=no 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 (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 21 May 2015 17:45:27 +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 t4LHjMlZ023208 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 21 May 2015 13:45:23 -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 t4LHjLng001953; Thu, 21 May 2015 13:45:22 -0400 Message-ID: <555E19B1.3010504@redhat.com> Date: Thu, 21 May 2015 17:45:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Simon Marchi , gdb-patches@sourceware.org Subject: Re: [PATCH v2 2/7] Cleanup some docs about memory write References: <1429127258-1033-1-git-send-email-simon.marchi@ericsson.com> <1429127258-1033-3-git-send-email-simon.marchi@ericsson.com> In-Reply-To: <1429127258-1033-3-git-send-email-simon.marchi@ericsson.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2015-05/txt/msg00547.txt.bz2 On 04/15/2015 08:47 PM, Simon Marchi wrote: > Some docs seemed outdated. In the case of target_write_memory, the docs > in target.c and target/target.h diverged a bit, so I tried to find a > reasonnable in-between version. "reasonable" > > gdb/ChangeLog: > > * corefile.c (write_memory): Update doc. > * gdbcore.h (write_memory): Same. > * target.c (target_write_memory): Same. > * target/target.h (target_write_memory): Same. > --- > gdb/corefile.c | 4 ++-- > gdb/gdbcore.h | 6 ++---- > gdb/target.c | 6 +----- > gdb/target/target.h | 10 +++++----- > 4 files changed, 10 insertions(+), 16 deletions(-) > > diff --git a/gdb/corefile.c b/gdb/corefile.c > index a042e6d..83b0e80 100644 > --- a/gdb/corefile.c > +++ b/gdb/corefile.c > @@ -383,8 +383,8 @@ read_memory_typed_address (CORE_ADDR addr, struct type *type) > return extract_typed_address (buf, type); > } > > -/* Same as target_write_memory, but report an error if can't > - write. */ > +/* See gdbcore.h. */ Double space after period. > diff --git a/gdb/target.c b/gdb/target.c > index fcf7090..bd9a0eb 100644 > int > target_write_memory (CORE_ADDR memaddr, const gdb_byte *myaddr, ssize_t len) > diff --git a/gdb/target/target.h b/gdb/target/target.h > index 05ac758..e0b7554 100644 > --- a/gdb/target/target.h > +++ b/gdb/target/target.h > @@ -49,12 +49,12 @@ extern int target_read_memory (CORE_ADDR memaddr, gdb_byte *myaddr, > extern int target_read_uint32 (CORE_ADDR memaddr, uint32_t *result); > > /* Write LEN bytes from MYADDR to target memory at address MEMADDR. > - Return zero for success, nonzero if any error occurs. This > + Return zero for success or TARGET_XFER_E_IO if any error occurs. This > function must be provided by the client. Implementations of this > - function may define and use their own error codes, but functions > - in the common, nat and target directories must treat the return > - code as opaque. No guarantee is made about the contents of the > - data at MEMADDR if any error occurs. */ > + function may define and use their own error codes, but functions in > + the common, nat and target directories must treat the return code as > + opaque. No guarantee is made about how much data got written if any > + error occurs. */ > > extern int target_write_memory (CORE_ADDR memaddr, const gdb_byte *myaddr, > ssize_t len); > This one's not right. TARGET_XFER_E_IO is a GDB-specific thing, while this declaration is meant for both gdb and gdbserver. It's what "This function must be provided by the client" refers to. It doesn't make sense to say "TARGET_XFER_E_IO" one error and then explain that the return code is opaque. So probably it'd be better to leave this comment: > --- a/gdb/target.c > +++ b/gdb/target.c > @@ -1464,11 +1464,7 @@ target_read_code (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len) > return TARGET_XFER_E_IO; > } > > -/* Write LEN bytes from MYADDR to target memory at address MEMADDR. > - Returns either 0 for success or TARGET_XFER_E_IO if any > - error occurs. If an error occurs, no guarantee is made about how > - much data got written. Callers that can deal with partial writes > - should call target_write. */ > +/* See target/target.h. */ ... but extend it by starting by saying that this is GDB's implementation of the function as declared in target/target.h. Thanks, Pedro Alves