Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simark@simark.ca>
To: Mihails Strasuns <mihails.strasuns@intel.com>,
	gdb-patches@sourceware.org
Subject: Re: [PATCH 6/7] [gdb/testsuite] use -Ttext-segment for jit-elf tests
Date: Sun, 22 Mar 2020 23:03:47 -0400	[thread overview]
Message-ID: <80652212-6dcf-79b6-c2f0-e4cc26810c87@simark.ca> (raw)
In-Reply-To: <20200218124339.11270-7-mihails.strasuns@intel.com>

Just some formatting nits:

> @@ -96,6 +89,15 @@ update_locations (const void *const addr, int idx)
>  #define MAIN main
>  #endif
>  
> +/* Must be defined by .exp file when compiling to know
> +   what address to map the ELF binary to.  */
> +#ifndef LOAD_ADDRESS
> +#error "Must define LOAD_ADDRESS"
> +#endif
> +#ifndef LOAD_INCREMENT
> +#error "Must define LOAD_INCREMENT"
> +#endif
> +
>  /* Used to spin waiting for GDB.  */
>  volatile int wait_for_gdb = ATTACH;
>  #define WAIT_FOR_GDB while (wait_for_gdb)
> @@ -137,7 +139,8 @@ MAIN (int argc, char *argv[])
>  	  exit (1);
>  	}
>  
> -      const void *const addr = mmap (0, st.st_size, PROT_READ|PROT_WRITE,
> +      void* load_addr = (void*) (size_t) (LOAD_ADDRESS + (i-1) * LOAD_INCREMENT);
> +      const void *const addr = mmap (load_addr, st.st_size, PROT_READ|PROT_WRITE,
>  				     MAP_PRIVATE, fd, 0);

We try to use the same style in code for tests as code for GDB itself.  So

      void* load_addr = (void*) (size_t) (LOAD_ADDRESS + (i-1) * LOAD_INCREMENT);

should be

      void *load_addr = (void *) (size_t) (LOAD_ADDRESS + (i - 1) * LOAD_INCREMENT);

I think we should be using MAP_FIXED in this mmap call, to make sure the mapping ends
up exactly at `load_addr`, and check the result to make sure it's not MAP_FAILED.

>        struct jit_code_entry *const entry = calloc (1, sizeof (*entry));
>  
> @@ -147,7 +150,7 @@ MAIN (int argc, char *argv[])
>  	  exit (1);
>  	}
>  
> -      update_locations (addr, i);
> +      update_name (addr, i);
>  
>        /* Link entry at the end of the list.  */
>        entry->symfile_addr = (const char *)addr;
> diff --git a/gdb/testsuite/lib/jit-elf-helpers.exp b/gdb/testsuite/lib/jit-elf-helpers.exp
> index f63694b8f5..cff47ec73c 100644
> --- a/gdb/testsuite/lib/jit-elf-helpers.exp
> +++ b/gdb/testsuite/lib/jit-elf-helpers.exp
> @@ -13,15 +13,25 @@
>  # You should have received a copy of the GNU General Public License
>  # along with this program.  If not, see <http://www.gnu.org/licenses/>.
>  
> +# Magic constants used to calculate a starting address when linking
> +# "jit" shared libraries. When loaded, will be mapped by jit-elf-main

Our standard is to use two spaces after periods in comments and other "prose".

Simon


  reply	other threads:[~2020-03-23  3:03 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 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-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 6/7] [gdb/testsuite] use -Ttext-segment for jit-elf tests Mihails Strasuns
2020-03-23  3:03   ` Simon Marchi [this message]
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
2020-03-23 11:14       ` Simon Marchi
2020-02-18 12:42 ` [PATCH 4/7] [gdb/testsuite] use args as lib list for jit-elf tests Mihails Strasuns
2020-03-23  0:04   ` Simon Marchi
2020-03-23  0:35     ` Simon Marchi
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-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=80652212-6dcf-79b6-c2f0-e4cc26810c87@simark.ca \
    --to=simark@simark.ca \
    --cc=gdb-patches@sourceware.org \
    --cc=mihails.strasuns@intel.com \
    /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