From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 49905 invoked by alias); 22 Mar 2017 06:21:03 -0000 Mailing-List: contact gdb-testers-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-testers-owner@sourceware.org Received: (qmail 49857 invoked by uid 89); 22 Mar 2017 06:21:02 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 spammy=mounted, yields, transfer X-HELO: kwanyin.sergiodj.net Received: from kwanyin.sergiodj.net (HELO kwanyin.sergiodj.net) (158.69.185.54) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 22 Mar 2017 06:21:00 +0000 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [binutils-gdb] inf-ptrace: Do not stop memory transfers after a single word From: sergiodj+buildbot@sergiodj.net To: gdb-testers@sourceware.org Message-Id: <87c336f60eccc6506ff19369c29575f43fea02ea@gdb-build> Date: Wed, 22 Mar 2017 06:21:00 -0000 X-SW-Source: 2017-q1/txt/msg05127.txt.bz2 *** TEST RESULTS FOR COMMIT 87c336f60eccc6506ff19369c29575f43fea02ea *** Author: Andreas Arnez Branch: master Commit: 87c336f60eccc6506ff19369c29575f43fea02ea inf-ptrace: Do not stop memory transfers after a single word When inf_ptrace_xfer_partial performs a memory transfer via ptrace with PT_READ_I, PT_WRITE_I (aka PTRACE_PEEKTEXT, PTRACE_POKETEXT), etc., then it currently transfers at most one word. This behavior yields degraded performance, particularly if the caller has significant preparation work for each invocation. And indeed it has for writing, in memory_xfer_partial in target.c, where all of the remaining data to be transferred is copied to a temporary buffer each time, for breakpoint shadow handling. Thus large writes have quadratic runtime and can take hours. Note: On GNU/Linux targets GDB usually does not use inf_ptrace_xfer_partial for large memory transfers, but attempts a single read/write from/to /proc//mem instead. However, the kernel may reject writes to /proc//mem (such as kernels prior to 2.6.39), or /proc may not be mounted. In both cases GDB falls back to the ptrace mechanism. This patch fixes the performance issue by attempting to fulfill the whole transfer request in inf_ptrace_xfer_partial, using a loop around the ptrace call. gdb/ChangeLog: PR gdb/21220 * inf-ptrace.c (inf_ptrace_xfer_partial): In "case TARGET_OBJECT_MEMORY", extract the logic for ptrace peek/poke... (inf_ptrace_peek_poke): ...here. New function. Now also loop over ptrace peek/poke until end of buffer or error.