This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 0/3] PR gdb/21220: Fix quadratic runtime of memory writes into inferior on GNU/Linux


On GNU/Linux native targets, when writing into inferior memory, only a
single word is currently transferred at a time.  This causes trouble with
large transfers, because memory_xfer_partial wastes a lot of effort in
this case: allocate a buffer and copy all remaining bytes of the transfer
request into it, then fill the breakpoints in, but just transfer the first
word of this buffer, and drop the rest.  This quadratic behavior affects
large "restore" operations, as reported by PR 21220, as well as
reverse-stepping a large memory-copy instruction, such as in the
s390-specific test case s390-mvcle.exp.  The quadratic run-time of a large
restore operation was already addressed and circumvented by this patch:

  https://sourceware.org/ml/gdb-patches/2013-07/msg00611.html -- "Improve
  performance of large restore commands"

But then another patch broke the circumvention:

  https://sourceware.org/ml/gdb-patches/2016-06/msg00565.html -- "Optimize
  memory_xfer_partial for remote"

This series fixes the problem in two different ways:

* When using ptrace with PTRACE_POKEDATA, do not return to the caller
  after transferring a single word, but attempt to fulfill the whole
  transfer request in one invocation.

* If possible, do not even use PTRACE_POKEDATA, but write to
  /proc/<pid>/mem instead.

To avoid another regression, a new dump/restore test case is added as
well.

Andreas Arnez (3):
  inf-ptrace: Do not stop memory transfers after a single word
  Test case for dump/restore of large array
  linux-nat: Exploit /proc/<pid>/mem for writing

 gdb/inf-ptrace.c                | 115 ++++++++++++++++++----------------------
 gdb/linux-nat.c                 |  32 +++++------
 gdb/testsuite/gdb.base/dump.c   |  37 +++++++++++++
 gdb/testsuite/gdb.base/dump.exp |   8 +++
 4 files changed, 112 insertions(+), 80 deletions(-)

-- 
2.3.0


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]