From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14450 invoked by alias); 27 Aug 2013 11:37:29 -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 14424 invoked by uid 89); 27 Aug 2013 11:37:28 -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; Tue, 27 Aug 2013 11:37:28 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-6.3 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-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r7RBbOHI020727 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 27 Aug 2013 07:37:24 -0400 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r7RBbMrW012367; Tue, 27 Aug 2013 07:37:23 -0400 Message-ID: <521C8F72.1090607@redhat.com> Date: Tue, 27 Aug 2013 11:37: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: Yao Qi CC: gdb-patches@sourceware.org Subject: Re: [PATCH] windows-nat.c: Don't install a deprecated_xfer_memory method. References: <20130823181245.4023.25651.stgit@brno.lan> <521BF779.5050006@codesourcery.com> In-Reply-To: <521BF779.5050006@codesourcery.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2013-08/txt/msg00777.txt.bz2 On 08/27/2013 01:48 AM, Yao Qi wrote: > On 08/24/2013 02:12 AM, Pedro Alves wrote: >> main, so I can't imagine any regression from this. Does anyone want >> (and is willing) to run this through the testsuite? >> > > Pedro, > I tested this patch on mingw native GDB. There is no regression. Thanks! I've applied this then. >> -static int >> -windows_xfer_memory (CORE_ADDR memaddr, gdb_byte *our, int len, >> - int write, struct mem_attrib *mem, >> - struct target_ops *target) >> +static LONGEST >> +windows_xfer_memory (gdb_byte *readbuf, const gdb_byte *writebuf, >> + ULONGEST memaddr, LONGEST len) > > It is not installed to deprecated_xfer_memory any more, so we need > documentation on this function. Guess so. Below's what I applied. ------ windows-nat.c: Don't install a deprecated_xfer_memory method. This stops another target from installing a target_ops->deprecated_xfer_memory method. Tested on native MinGW. gdb/ 2013-08-27 Pedro Alves * windows-nat.c (windows_xfer_memory): Adjust prototype to follow xfer_partial's interface. Return TARGET_XFER_E_IO on error. (windows_xfer_partial): Defer TARGET_OBJECT_MEMORY handling to windows_xfer_memory directly. (init_windows_ops): Don't install a deprecated_xfer_memory method. --- gdb/windows-nat.c | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index 9a0241b..2ffaad4 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -2315,20 +2315,23 @@ windows_stop (ptid_t ptid) registers_changed (); /* refresh register state */ } -static int -windows_xfer_memory (CORE_ADDR memaddr, gdb_byte *our, int len, - int write, struct mem_attrib *mem, - struct target_ops *target) +/* Helper for windows_xfer_partial that handles memory transfers. + Arguments are like target_xfer_partial. */ + +static LONGEST +windows_xfer_memory (gdb_byte *readbuf, const gdb_byte *writebuf, + ULONGEST memaddr, LONGEST len) { SIZE_T done = 0; - if (write) + BOOL success; + + if (writebuf != NULL) { DEBUG_MEM (("gdb: write target memory, %d bytes at %s\n", len, core_addr_to_string (memaddr))); - if (!WriteProcessMemory (current_process_handle, - (LPVOID) (uintptr_t) memaddr, our, - len, &done)) - done = 0; + success = WriteProcessMemory (current_process_handle, + (LPVOID) (uintptr_t) memaddr, writebuf, + len, &done); FlushInstructionCache (current_process_handle, (LPCVOID) (uintptr_t) memaddr, len); } @@ -2336,12 +2339,11 @@ windows_xfer_memory (CORE_ADDR memaddr, gdb_byte *our, int len, { DEBUG_MEM (("gdb: read target memory, %d bytes at %s\n", len, core_addr_to_string (memaddr))); - if (!ReadProcessMemory (current_process_handle, - (LPCVOID) (uintptr_t) memaddr, our, - len, &done)) - done = 0; + success = ReadProcessMemory (current_process_handle, + (LPCVOID) (uintptr_t) memaddr, readbuf, + len, &done); } - return done; + return success ? done : TARGET_XFER_E_IO; } static void @@ -2442,13 +2444,7 @@ windows_xfer_partial (struct target_ops *ops, enum target_object object, switch (object) { case TARGET_OBJECT_MEMORY: - if (readbuf) - return (*ops->deprecated_xfer_memory) (offset, readbuf, - len, 0/*read*/, NULL, ops); - if (writebuf) - return (*ops->deprecated_xfer_memory) (offset, (gdb_byte *) writebuf, - len, 1/*write*/, NULL, ops); - return -1; + return windows_xfer_memory (readbuf, writebuf, offset, len); case TARGET_OBJECT_LIBRARIES: return windows_xfer_shared_libraries (ops, object, annex, readbuf, @@ -2502,7 +2498,6 @@ init_windows_ops (void) windows_ops.to_fetch_registers = windows_fetch_inferior_registers; windows_ops.to_store_registers = windows_store_inferior_registers; windows_ops.to_prepare_to_store = windows_prepare_to_store; - windows_ops.deprecated_xfer_memory = windows_xfer_memory; windows_ops.to_xfer_partial = windows_xfer_partial; windows_ops.to_files_info = windows_files_info; windows_ops.to_insert_breakpoint = memory_insert_breakpoint;