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 88C1D385E03A for ; Fri, 27 Mar 2020 10:38:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 88C1D385E03A IronPort-SDR: keXkKJQnOVguoByKTmzWhhtHqbSE3Ll5IvTPhdpBuS5mT+Ivq37VdA1hRpIqz2TsFSjbHvtIyp icEKH0fzcscA== 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; 27 Mar 2020 03:38:00 -0700 IronPort-SDR: bmqylkFvfjA6Ugy44VyiAzwuSLmDmIYirzp6wjW7JGYjuF6rSQGr7Nyd9f5IbLxpGcDqetzCfO 2i4goV4i5L5g== X-IronPort-AV: E=Sophos;i="5.72,312,1580803200"; d="scan'208";a="240930354" 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; 27 Mar 2020 03:37:59 -0700 From: Mihails Strasuns To: gdb-patches@sourceware.org Subject: [PATCH v2 7/8] [gdb/testsuite] define jit function name via macro Date: Fri, 27 Mar 2020 11:39:31 +0100 Message-Id: <20200327103932.17765-7-mihails.strasuns@intel.com> X-Mailer: git-send-email 2.25.2 In-Reply-To: <20200327103932.17765-1-mihails.strasuns@intel.com> References: <165972> <20200327103932.17765-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.8 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: Fri, 27 Mar 2020 10:38:03 -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 5bd8a05926..ce94fe3875 100644 --- a/gdb/testsuite/gdb.base/jit-elf-main.c +++ b/gdb/testsuite/gdb.base/jit-elf-main.c @@ -51,35 +51,6 @@ usage () 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 @@ -150,8 +121,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 8f17c2f972..2273333b60 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 binsuffix options} { set addr [format 0x%x [expr $load_address + $load_increment * [expr $i-1]]] set comp_options [concat \ $options \ + 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 $comp_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