public inbox for gdb-testers@sourceware.org
help / color / mirror / Atom feed
From: gdb-buildbot@sergiodj.net
To: gdb-testers@sourceware.org
Subject: [binutils-gdb] Cache the text section offset of shared libraries
Date: Thu, 23 Jan 2020 18:35:00 -0000	[thread overview]
Message-ID: <c162ed3e66aa985fa2e79d0e7ccd2da80a532c1e@gdb-build> (raw)

*** TEST RESULTS FOR COMMIT c162ed3e66aa985fa2e79d0e7ccd2da80a532c1e ***

commit c162ed3e66aa985fa2e79d0e7ccd2da80a532c1e
Author:     Hannes Domani <ssbssa@yahoo.de>
AuthorDate: Sat Dec 21 17:08:14 2019 +0100
Commit:     Hannes Domani <ssbssa@yahoo.de>
CommitDate: Thu Jan 23 18:44:27 2020 +0100

    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.

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index a407c04bf5..026aaf1703 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,12 @@
+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.
+
 2020-01-21  Simon Marchi  <simon.marchi@efficios.com>
 
 	* gdbarch.sh: Add declaration for _initialize_gdbarch.
diff --git a/gdb/i386-cygwin-tdep.c b/gdb/i386-cygwin-tdep.c
index f703579efd..cb66632648 100644
--- a/gdb/i386-cygwin-tdep.c
+++ b/gdb/i386-cygwin-tdep.c
@@ -137,7 +137,7 @@ core_process_module_section (bfd *abfd, asection *sect, void *obj)
   /* The first module is the .exe itself.  */
   if (data->module_count != 0)
     windows_xfer_shared_library (module_name, base_addr,
-				 data->gdbarch, data->obstack);
+				 NULL, data->gdbarch, data->obstack);
   data->module_count++;
 
 out:
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index 901e64263c..366c98fbf3 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -682,6 +682,7 @@ windows_nat_target::store_registers (struct regcache *regcache, int r)
 struct lm_info_windows : public lm_info_base
 {
   LPVOID load_addr = 0;
+  CORE_ADDR text_offset = 0;
 };
 
 static struct so_list solib_start, *solib_end;
@@ -2974,6 +2975,7 @@ windows_xfer_shared_libraries (struct target_ops *ops,
 
       windows_xfer_shared_library (so->so_name, (CORE_ADDR)
 				   (uintptr_t) li->load_addr,
+				   &li->text_offset,
 				   target_gdbarch (), &obstack);
     }
   obstack_grow_str0 (&obstack, "</library-list>\n");
diff --git a/gdb/windows-tdep.c b/gdb/windows-tdep.c
index 1fc2748581..6c9632d035 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>");
 }
diff --git a/gdb/windows-tdep.h b/gdb/windows-tdep.h
index ab6c2d6e55..34474f259c 100644
--- a/gdb/windows-tdep.h
+++ b/gdb/windows-tdep.h
@@ -27,6 +27,7 @@ extern void init_w32_command_list (void);
 
 extern void windows_xfer_shared_library (const char* so_name,
 					 CORE_ADDR load_addr,
+					 CORE_ADDR *text_offset_cached,
 					 struct gdbarch *gdbarch,
 					 struct obstack *obstack);
 


             reply	other threads:[~2020-01-23 18:07 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-23 18:35 gdb-buildbot [this message]
2020-01-23 18:25 ` Failures on Ubuntu-Aarch64-native-extended-gdbserver-m64, branch master gdb-buildbot
2020-01-23 18:38 ` Failures on Fedora-x86_64-m64, " gdb-buildbot
2020-01-23 18:45 ` Failures on Fedora-x86_64-native-extended-gdbserver-m64, " gdb-buildbot
2020-01-23 18:51 ` Failures on Ubuntu-Aarch64-native-gdbserver-m64, " gdb-buildbot
2020-01-23 19:00 ` Failures on Fedora-i686, " gdb-buildbot
2020-01-23 19:08 ` Failures on Fedora-x86_64-native-extended-gdbserver-m32, " gdb-buildbot
2020-01-23 19:20 ` Failures on Fedora-x86_64-cc-with-index, " gdb-buildbot
2020-01-23 19:32 ` Failures on Fedora-x86_64-m32, " gdb-buildbot
2020-01-23 20:16 ` Failures on Fedora-x86_64-native-gdbserver-m64, " gdb-buildbot
2020-01-23 20:16 ` Failures on Fedora-x86_64-native-gdbserver-m32, " gdb-buildbot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c162ed3e66aa985fa2e79d0e7ccd2da80a532c1e@gdb-build \
    --to=gdb-buildbot@sergiodj.net \
    --cc=gdb-testers@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).