From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by sourceware.org (Postfix) with ESMTPS id 0B7D7385DC34 for ; Tue, 31 Mar 2020 17:12:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 0B7D7385DC34 IronPort-SDR: o+HJWVx++mviXr67HfsQbyqZzzPrntdz+SJRPCDRCWSy2BG3aAKLlNCLxvvb3mKm6hEsGIurkZ /o0KEhJa6q7w== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Mar 2020 10:12:31 -0700 IronPort-SDR: G3MlcyjLRt9rgHQSBeA/yTpd6n6r3bp3O+hSbJOLbkIzYRR0kiIBu81tawWQkfYXsqGNSQPWDD Fm68kkVWm0vQ== X-IronPort-AV: E=Sophos;i="5.72,328,1580803200"; d="scan'208";a="241971379" Received: from labpc7920x-08.iul.intel.com (HELO localhost) ([172.28.49.151]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Mar 2020 10:12:29 -0700 From: Mihails Strasuns To: gdb-patches@sourceware.org Subject: [PATCH v3 7/9] [gdb/testsuite] define jit function name via macro Date: Tue, 31 Mar 2020 19:13:54 +0200 Message-Id: <20200331171356.26126-7-mihails.strasuns@intel.com> X-Mailer: git-send-email 2.25.2 In-Reply-To: <20200331171356.26126-1-mihails.strasuns@intel.com> References: <166773> <20200331171356.26126-1-mihails.strasuns@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-25.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_DMARC_STATUS, KAM_SHORT, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 31 Mar 2020 17:12:33 -0000 Replaces previous approach with patching resulting ELF binary after loading - now that each test iteration works on a separately compiled binary it is not necessary anymore. Tests are still being ran without debug info to preserve original test functionality but this change opens up the possibility to enable debug info if needed too. gdb/testsuite/ChangeLog: 2020-03-27 Mihails Strasuns * lib/jit-elf-helpers.exp: supply -DFUNCTION_NAME macro definition when compiling jit-elf-solib.co * gdb.base/jit-elf-main.c: stop patching jit function name * gdb.base/jit-elf-solib.c: use FUNCTION_NAME macro value as a function name Signed-off-by: Mihails Strasuns Change-Id: Ie9296dd374cd1ae11c7d1b8bbe4f0b6b1d5e21b5 --- gdb/testsuite/gdb.base/jit-elf-main.c | 31 -------------------------- gdb/testsuite/gdb.base/jit-elf-solib.c | 6 ++--- gdb/testsuite/lib/jit-elf-helpers.exp | 1 + 3 files changed, 4 insertions(+), 34 deletions(-) diff --git a/gdb/testsuite/gdb.base/jit-elf-main.c b/gdb/testsuite/gdb.base/jit-elf-main.c index edf2f692f8..e25ea3f524 100644 --- a/gdb/testsuite/gdb.base/jit-elf-main.c +++ b/gdb/testsuite/gdb.base/jit-elf-main.c @@ -51,35 +51,6 @@ usage (void) exit (1); } -/* Rename jit_function_XXXX to match idx */ - -static void -update_name (const void *const addr, int idx) -{ - const ElfW (Ehdr) *const ehdr = (ElfW (Ehdr) *)addr; - ElfW (Shdr) *const shdr = (ElfW (Shdr) *)((char *)addr + ehdr->e_shoff); - ElfW (Phdr) *const phdr = (ElfW (Phdr) *)((char *)addr + ehdr->e_phoff); - int i; - - for (i = 0; i < ehdr->e_shnum; ++i) - { - if (shdr[i].sh_type == SHT_STRTAB) - { - /* Note: we update both .strtab and .dynstr. The latter would - not be correct if this were a regular shared library (.hash - would be wrong), but this is a simulation -- the library is - never exposed to the dynamic loader, so it all ends up ok. */ - char *const strtab = (char *)((ElfW (Addr))addr + shdr[i].sh_offset); - char *const strtab_end = strtab + shdr[i].sh_size; - char *p; - - for (p = strtab; p < strtab_end; p += strlen (p) + 1) - if (strcmp (p, "jit_function_XXXX") == 0) - sprintf (p, "jit_function_%04d", idx); - } - } -} - /* Defined by the .exp file if testing attach. */ #ifndef ATTACH #define ATTACH 0 @@ -151,8 +122,6 @@ MAIN (int argc, char *argv[]) exit (1); } - update_name (addr, i); - /* Link entry at the end of the list. */ entry->symfile_addr = (const char *)addr; entry->symfile_size = st.st_size; diff --git a/gdb/testsuite/gdb.base/jit-elf-solib.c b/gdb/testsuite/gdb.base/jit-elf-solib.c index 3bdebe9ed0..7901c58ac9 100644 --- a/gdb/testsuite/gdb.base/jit-elf-solib.c +++ b/gdb/testsuite/gdb.base/jit-elf-solib.c @@ -15,7 +15,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -/* This simulates a JIT library. The function is "renamed" after being - loaded into memory. */ +/* This simulates a JIT library. The function name is supplied during + compilation as a macro. */ -int jit_function_XXXX() { return 42; } +int FUNCTION_NAME() { return 42; } diff --git a/gdb/testsuite/lib/jit-elf-helpers.exp b/gdb/testsuite/lib/jit-elf-helpers.exp index 4d88ea3900..8a7a1796cc 100644 --- a/gdb/testsuite/lib/jit-elf-helpers.exp +++ b/gdb/testsuite/lib/jit-elf-helpers.exp @@ -82,6 +82,7 @@ proc compile_n_jit_so {count} { # function" changes when debug info is present. set addr [format 0x%x [expr $load_address + $load_increment * [expr $i-1]]] set options [list \ + additional_flags=-DFUNCTION_NAME=[format "jit_function_%04d" $i] \ additional_flags=-Xlinker \ additional_flags=-Ttext-segment=$addr] if { [gdb_compile_shlib $solib_srcfile $solib_binfile $options] != "" } { -- 2.25.2 Intel Deutschland GmbH Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany Tel: +49 89 99 8853-0, www.intel.de Managing Directors: Christin Eisenschmid, Gary Kershaw Chairperson of the Supervisory Board: Nicole Lau Registered Office: Munich Commercial Register: Amtsgericht Muenchen HRB 186928