From patchwork Mon Jan 13 17:24:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Terekhov, Mikhail via Gdb-patches" X-Patchwork-Id: 37349 Received: (qmail 39099 invoked by alias); 13 Jan 2020 17:25:17 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 39087 invoked by uid 89); 13 Jan 2020 17:25:17 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.6 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: sonic314-19.consmr.mail.ir2.yahoo.com Received: from sonic314-19.consmr.mail.ir2.yahoo.com (HELO sonic314-19.consmr.mail.ir2.yahoo.com) (77.238.177.145) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 13 Jan 2020 17:25:15 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.de; s=s2048; t=1578936313; bh=ssy8Fz7erdaRbAqsTmpwo0F/+taPKGjK+RRxFHeorjU=; h=From:To:Subject:Date:References:From:Subject; b=GSUDHOsjJ9CXE8TYmjVc2b9lLVpJ8fCf8vRT6xWQ2EqH8JYeEXB5II7wBxoWsS2Lwa2ySHMQepuu9qYwBna2kHO9PV2YEGALRU1oDE8UoOqOnAml88FzRF4cxhrrT5cDWxiocn9vXDUc9WEuzse/cvoT+S+/iFlftaBagF5+4M8GjU2uFTSiCwGXJT08AH2Nf4DT2fvTcrlD/YhgCkt95YDq6jjkxa3RL3HAVQ8fUo72ypLBpCHbGZ5LbsRaAinDLfTRVNOYjsPqDCv3nnjLyreWf8KimIS2NV9AhnWXDZDh+WsWTQrgLuodqXV8T+fG++89aCSCg50++MnUK+/zsw== Received: from sonic.gate.mail.ne1.yahoo.com by sonic314.consmr.mail.ir2.yahoo.com with HTTP; Mon, 13 Jan 2020 17:25:13 +0000 Received: by smtp408.mail.ir2.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID 7f1034d12470e4a30e4128e189c8bd62; Mon, 13 Jan 2020 17:25:10 +0000 (UTC) X-Patchwork-Original-From: "Hannes Domani via gdb-patches" From: "Terekhov, Mikhail via Gdb-patches" Reply-To: Hannes Domani To: gdb-patches@sourceware.org Subject: [PATCH v2] Cache the text section offset of shared libraries Date: Mon, 13 Jan 2020 18:24:55 +0100 Message-Id: <20200113172455.1688-1-ssbssa@yahoo.de> MIME-Version: 1.0 References: <20200113172455.1688-1-ssbssa.ref@yahoo.de> Content-Length: 4187 X-IsSubscribed: yes 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: 2019-12-21 Hannes Domani * 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/i386-cygwin-tdep.c | 2 +- gdb/windows-nat.c | 2 ++ gdb/windows-tdep.c | 20 ++++++++++++++------ gdb/windows-tdep.h | 1 + 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/gdb/i386-cygwin-tdep.c b/gdb/i386-cygwin-tdep.c index ee04752b54..9f891f4d98 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 be5955d379..cd5922a685 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, "\n"); diff --git a/gdb/windows-tdep.c b/gdb/windows-tdep.c index b6e5b9ff7c..621146bf43 100644 --- a/gdb/windows-tdep.c +++ b/gdb/windows-tdep.c @@ -424,19 +424,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, ""); } 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);