From: "Strasuns, Mihails" <mihails.strasuns@intel.com>
To: Simon Marchi <simark@simark.ca>,
"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: RE: [PATCH 7/7] [gdb/testsuite] add jit-elf-util.h and run jit function
Date: Mon, 23 Mar 2020 09:23:21 +0000 [thread overview]
Message-ID: <MWHPR11MB004823B58A7FE4DA6C29B6DF95F00@MWHPR11MB0048.namprd11.prod.outlook.com> (raw)
In-Reply-To: <32519038-95ed-d46e-28cd-0670e0798a02@simark.ca>
> -----Original Message-----
> From: Simon Marchi <simark@simark.ca>
> Sent: Monday, March 23, 2020 4:13 AM
> To: Strasuns, Mihails <mihails.strasuns@intel.com>; gdb-
> patches@sourceware.org
> Subject: Re: [PATCH 7/7] [gdb/testsuite] add jit-elf-util.h and run jit function
>
> On 2020-02-18 7:43 a.m., Mihails Strasuns wrote:
> > +/* Looks into string tables for entry
> > + "jit_function_XXXX" and updates it to use `rename_num`. */ static
> > +void update_name (ElfW (Addr) addr, int rename_num) {
> > + 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);
> > +
> > + for (int 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 *) (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", rename_num);
> > + }
> > + }
> > +}
>
> I was wondering about this function. It updates the function name in the ELF
> string table, but not in the DWARF debug info, so what is GDB going to display
> if the debug info says that the function is called `jit_function_XXXX`?
>
> In fact, since we generate multiple shared objects, could we just generate
> them with the right function names directly? The .exp would compile the
> first one with
>
> -DJIT_FUNCTION_NAME=jit_function_0001
>
> the second one with
>
> -DJIT_FUNCTION_NAME=jit_function_0002
>
> and so forth. We wouldn't need any of this name munging.
Hello,
Here I was trying to preserve the old test flow as much as possible - I did seem a bit strange to me though.
Original version relies on _not_ having DWARF debug info present (there is a comment about it in .exp file), the
same applies for the refactored one. If you think simply emitting different function names in the first place is
an equivalent change, I am more than happy to get rid of this :)
Will address rest of comments and submit a new patchset soon, thanks for review!
BR,
Mihails
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
next prev parent reply other threads:[~2020-03-23 9:23 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-18 12:42 [PATCH 0/7] refactor and enhance jit testing Mihails Strasuns
2020-02-18 12:42 ` [PATCH 2/7] [gdb/testsuite] structured rename of jit test files Mihails Strasuns
2020-02-19 21:23 ` Tom Tromey
2020-03-22 2:47 ` Simon Marchi
2020-02-18 12:42 ` [PATCH 7/7] [gdb/testsuite] add jit-elf-util.h and run jit function Mihails Strasuns
2020-03-23 3:13 ` Simon Marchi
2020-03-23 9:23 ` Strasuns, Mihails [this message]
2020-03-23 11:14 ` Simon Marchi
2020-02-18 12:42 ` [PATCH 6/7] [gdb/testsuite] use -Ttext-segment for jit-elf tests Mihails Strasuns
2020-03-23 3:03 ` Simon Marchi
2020-02-18 12:42 ` [PATCH 4/7] [gdb/testsuite] use args as lib list " Mihails Strasuns
2020-03-23 0:04 ` Simon Marchi
2020-03-23 0:35 ` Simon Marchi
2020-02-18 12:42 ` [PATCH 1/7] [gdb/testsuite] allow more registers in reader test Mihails Strasuns
2020-02-19 21:22 ` Tom Tromey
2020-03-21 16:03 ` Simon Marchi
2020-03-22 2:09 ` Simon Marchi
2020-02-18 12:42 ` [PATCH 3/7] [gdb/testsuite] share jit-protocol.h by all jit tests Mihails Strasuns
2020-02-19 21:23 ` Tom Tromey
2020-03-22 16:00 ` Simon Marchi
2020-02-18 12:42 ` [PATCH 5/7] [gdb/testsuite] add lib/jit-elf-helpers.exp Mihails Strasuns
2020-03-23 0:52 ` Simon Marchi
2020-02-26 13:56 ` [PATCH 0/7] refactor and enhance jit testing Strasuns, Mihails
2020-03-18 12:48 ` Simon Marchi
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=MWHPR11MB004823B58A7FE4DA6C29B6DF95F00@MWHPR11MB0048.namprd11.prod.outlook.com \
--to=mihails.strasuns@intel.com \
--cc=gdb-patches@sourceware.org \
--cc=simark@simark.ca \
/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