]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Cache the text section offset of shared libraries
authorHannes Domani <ssbssa@yahoo.de>
Sat, 21 Dec 2019 16:08:14 +0000 (17:08 +0100)
committerHannes Domani <ssbssa@yahoo.de>
Thu, 23 Jan 2020 17:44:27 +0000 (18:44 +0100)
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.

gdb/ChangeLog
gdb/i386-cygwin-tdep.c
gdb/windows-nat.c
gdb/windows-tdep.c
gdb/windows-tdep.h

index a407c04bf5e66ee4bfa5f0676e062f19b2c4880c..026aaf1703b330a87e94c91f66e46013f1c1a366 100644 (file)
@@ -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.
index f703579efda9117496d09cd719e3180266a71fe1..cb66632648f7e644f21617a079820d08b321aa3d 100644 (file)
@@ -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:
index 901e64263c63c2e12c19d06ba059495d0213dc22..366c98fbf3ba131e33950e79d10de308cef5f130 100644 (file)
@@ -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");
index 1fc2748581886bbf15f34496d8309615bd9de66b..6c9632d035fb92a6c25fe0bd596e145b1f662eee 100644 (file)
@@ -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>");
 }
index ab6c2d6e552226d64c5f6e7d54820237da1f1198..34474f259c2a27a4d15b5c911ea723dc22696d57 100644 (file)
@@ -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);