aboutsummaryrefslogtreecommitdiff
path: root/gdb/windows-tdep.c
diff options
context:
space:
mode:
authorHannes Domani <ssbssa@yahoo.de>2019-12-21 17:08:14 +0100
committerHannes Domani <ssbssa@yahoo.de>2020-01-23 18:44:27 +0100
commitc162ed3e66aa985fa2e79d0e7ccd2da80a532c1e (patch)
treeeab65ab7be42099b34e1d584bdc5500af23f5579 /gdb/windows-tdep.c
parent24e648d4b80268c164ba1e1eecb581bf9c42745f (diff)
downloadfsf-binutils-gdb-c162ed3e66aa985fa2e79d0e7ccd2da80a532c1e.zip
fsf-binutils-gdb-c162ed3e66aa985fa2e79d0e7ccd2da80a532c1e.tar.gz
fsf-binutils-gdb-c162ed3e66aa985fa2e79d0e7ccd2da80a532c1e.tar.bz2
Cache the text section offset of shared libraries
Each time a dll is loaded, update_solib_list is called. This in turn calls deep down xfer_partial -> windows_xfer_shared_libraries, which calls windows_xfer_shared_library for each loaded dll, and pe_text_section_offset reads the dll for the text section offset. Also if the data provided by xfer_partial is bigger than 4K, then all of this is done for each 4K chunk (see target_read_alloc_1). Caching of the text section offset improves the startup time of an application with >300 dynamically loaded plugins from 2m10s to 10s. And the shutdown time improves from 2m to 2s. gdb/ChangeLog: 2020-01-23 Hannes Domani <ssbssa@yahoo.de> * i386-cygwin-tdep.c (core_process_module_section): Update. * windows-nat.c (struct lm_info_windows): Add text_offset. (windows_xfer_shared_libraries): Update. * windows-tdep.c (windows_xfer_shared_library): Add text_offset_cached argument. * windows-tdep.h (windows_xfer_shared_library): Update.
Diffstat (limited to 'gdb/windows-tdep.c')
-rw-r--r--gdb/windows-tdep.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/gdb/windows-tdep.c b/gdb/windows-tdep.c
index 1fc2748..6c9632d 100644
--- a/gdb/windows-tdep.c
+++ b/gdb/windows-tdep.c
@@ -483,19 +483,27 @@ display_tib (const char * args, int from_tty)
void
windows_xfer_shared_library (const char* so_name, CORE_ADDR load_addr,
+ CORE_ADDR *text_offset_cached,
struct gdbarch *gdbarch, struct obstack *obstack)
{
- CORE_ADDR text_offset;
+ CORE_ADDR text_offset = text_offset_cached ? *text_offset_cached : 0;
obstack_grow_str (obstack, "<library name=\"");
std::string p = xml_escape_text (so_name);
obstack_grow_str (obstack, p.c_str ());
obstack_grow_str (obstack, "\"><segment address=\"");
- gdb_bfd_ref_ptr dll (gdb_bfd_open (so_name, gnutarget, -1));
- /* The following calls are OK even if dll is NULL.
- The default value 0x1000 is returned by pe_text_section_offset
- in that case. */
- text_offset = pe_text_section_offset (dll.get ());
+
+ if (!text_offset)
+ {
+ gdb_bfd_ref_ptr dll (gdb_bfd_open (so_name, gnutarget, -1));
+ /* The following calls are OK even if dll is NULL.
+ The default value 0x1000 is returned by pe_text_section_offset
+ in that case. */
+ text_offset = pe_text_section_offset (dll.get ());
+ if (text_offset_cached)
+ *text_offset_cached = text_offset;
+ }
+
obstack_grow_str (obstack, paddress (gdbarch, load_addr + text_offset));
obstack_grow_str (obstack, "\"/></library>");
}