aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorAnton Blanchard <anton@samba.org>2013-11-04 21:39:20 +1100
committerAnton Blanchard <anton@samba.org>2013-11-04 22:18:23 +1100
commit67c059c29e1fb0cdeacdd2005f955514d8d1fb34 (patch)
treea8a6ca67ff1b3f4e311447e82c2d650086aac93c /gdb
parent88b8e63904fda25c029deaf25d7b4e489b351470 (diff)
downloadgdb-67c059c29e1fb0cdeacdd2005f955514d8d1fb34.zip
gdb-67c059c29e1fb0cdeacdd2005f955514d8d1fb34.tar.gz
gdb-67c059c29e1fb0cdeacdd2005f955514d8d1fb34.tar.bz2
Improve performance of large restore commands
I noticed a large (100MB) restore took hours to complete. The problem is memory_xfer_partial repeatedly mallocs and memcpys the entire 100MB buffer for breakpoint shadow handling only to find a small portion of it is actually written. The testcase that originally took hours now takes 50 seconds. gdb/ 2013-07-29 Anton Blanchard <anton@samba.org> * target.c (memory_xfer_partial): Cap write to 4KB.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog4
-rw-r--r--gdb/target.c7
2 files changed, 11 insertions, 0 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 2d6a751..7d7a6fc 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,7 @@
+2013-11-04 Anton Blanchard <anton@samba.org>
+
+ * target.c (memory_xfer_partial): Cap write to 4KB.
+
2013-11-01 Tiago Stürmer Daitx <tdaitx@linux.vnet.ibm.com>
* breakpoint.c (create_longjmp_master_breakpoint): Allow libc
diff --git a/gdb/target.c b/gdb/target.c
index 22d7fb6..7aeab79 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -1678,6 +1678,13 @@ memory_xfer_partial (struct target_ops *ops, enum target_object object,
void *buf;
struct cleanup *old_chain;
+ /* A large write request is likely to be partially satisfied
+ by memory_xfer_partial_1. We will continually malloc
+ and free a copy of the entire write request for breakpoint
+ shadow handling even though we only end up writing a small
+ subset of it. Cap writes to 4KB to mitigate this. */
+ len = min (4096, len);
+
buf = xmalloc (len);
old_chain = make_cleanup (xfree, buf);
memcpy (buf, writebuf, len);