inf-ptrace: Do not stop memory transfers after a single word
authorAndreas Arnez <arnez@linux.vnet.ibm.com>
Tue, 14 Mar 2017 18:20:46 +0000 (19:20 +0100)
committerAndreas Arnez <arnez@linux.vnet.ibm.com>
Tue, 14 Mar 2017 18:20:46 +0000 (19:20 +0100)
commit87c336f60eccc6506ff19369c29575f43fea02ea
treef6484e93cfe87fa5b4bfe1e8283d18f2ad7bb498
parentd47c3ff7d55122befac848fe64b7445789c78787
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/<pid>/mem instead.  However, the kernel may
reject writes to /proc/<pid>/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.
gdb/ChangeLog
gdb/inf-ptrace.c
This page took 0.030555 seconds and 4 git commands to generate.