From: Simon Marchi <simark@simark.ca>
To: Mihails Strasuns <mihails.strasuns@intel.com>,
gdb-patches@sourceware.org
Subject: Re: [PATCH 5/7] [gdb/testsuite] add lib/jit-elf-helpers.exp
Date: Sun, 22 Mar 2020 20:52:44 -0400 [thread overview]
Message-ID: <03d76c7f-88ee-19ae-811f-a66a60af6a69@simark.ca> (raw)
In-Reply-To: <20200218124339.11270-6-mihails.strasuns@intel.com>
On 2020-02-18 7:43 a.m., Mihails Strasuns wrote:
> New utility library to be used by jit-elf tests responsible for
> compiling binary artifacts. In the next commit the compilation process
> will become more complicated because of extra mandatory flag - keeping
> it in one place will make tests less fragile.
>
> gdb/testsuite/ChangeLog:
>
> 2020-02-18 Mihails Strasuns <mihails.strasuns@intel.com>
>
> * lib/jit-elf-helpers.exp: new file
> * gdb.base/jit-elf.exp: updated to use jit-elf-helpers.exp
> * gdb.base/jit-elf-so.exp: updated to use jit-elf-helpers.exp
>
> Change-Id: I2fda518406aeca55e82df45edd67cef149497bbe
> Signed-off-by: Mihails Strasuns <mihails.strasuns@intel.com>
> ---
> gdb/testsuite/gdb.base/jit-elf-so.exp | 69 +++++++------------------
> gdb/testsuite/gdb.base/jit-elf.exp | 39 +-------------
> gdb/testsuite/lib/jit-elf-helpers.exp | 73 +++++++++++++++++++++++++++
> 3 files changed, 92 insertions(+), 89 deletions(-)
> create mode 100644 gdb/testsuite/lib/jit-elf-helpers.exp
>
> diff --git a/gdb/testsuite/gdb.base/jit-elf-so.exp b/gdb/testsuite/gdb.base/jit-elf-so.exp
> index eee20e16c2..31a422a5d2 100644
> --- a/gdb/testsuite/gdb.base/jit-elf-so.exp
> +++ b/gdb/testsuite/gdb.base/jit-elf-so.exp
> @@ -26,67 +26,32 @@ if {[get_compiler_info]} {
> return 1
> }
>
> -proc compile_jit_main {options} {
> - global srcdir subdir testfile2 srcfile2 binfile2
> - set testfile2 jit-elf-main
> - set srcfile2 ${testfile2}.c
> - set binfile2 [standard_output_file $testfile2.so]
> - set options [concat \
> - $options \
> - debug]
> - if { [gdb_compile_shlib "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" \
> - $options] != "" } {
> - untested "Failure to compile jit-elf-main"
> - }
> -}
> +load_lib jit-elf-helpers.exp
>
> proc compile_jit_dlmain {options} {
> - global srcdir subdir testfile srcfile binfile
> - set testfile jit-elf-dlmain
> - set srcfile ${testfile}.c
> - set binfile [standard_output_file $testfile]
> + global srcdir subdir testfile_dlmain srcfile_dlmain
> + set testfile_dlmain jit-elf-dlmain
> + set srcfile_dlmain ${testfile_dlmain}.c
> + set binfile [standard_output_file $testfile_dlmain]
> set options [concat \
> $options \
> debug]
> - if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
> + if { [gdb_compile "${srcdir}/${subdir}/${srcfile_dlmain}" "${binfile}" \
> executable $options] != "" } {
> untested "Failure to compile jit-elf-main"
> }
> }
It looks like we're returning values through global variables, which are then used
in the top-level code. Let's use return values if possible. The local variable
names can remain unchanged, to minimize the diff.
One convenient way to return multiple values is using a list and lassign:
proc foo { } {
return [list a b c]
}
lassign [foo] x y z
puts "$x $y $z"
> diff --git a/gdb/testsuite/lib/jit-elf-helpers.exp b/gdb/testsuite/lib/jit-elf-helpers.exp
> new file mode 100644
> index 0000000000..f63694b8f5
> --- /dev/null
> +++ b/gdb/testsuite/lib/jit-elf-helpers.exp
> @@ -0,0 +1,73 @@
> +# Copyright 2020 Free Software Foundation, Inc.
> +
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; either version 3 of the License, or
> +# (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program. If not, see <http://www.gnu.org/licenses/>.
> +
> +# Compiles jit-elf-main.c as a regular executable
> +
> +proc compile_jit_main {binsuffix options} {
> + global srcdir subdir testfile srcfile binfile
> + set testfile jit-elf-main
> + set srcfile ${testfile}.c
> + set binfile [standard_output_file $testfile$binsuffix]
> + set options [concat \
> + $options \
> + debug]
> + if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
> + executable $options] != "" } {
> + untested "Failure to compile jit-elf-main"
> + }
> +}
> +
> +# Compiles jit-elf-main.c as a shared library
> +
> +proc compile_jit_main_as_so {binsuffix options} {
> + global srcdir subdir testfile srcfile binfile
> + set testfile jit-elf-main
> + set srcfile ${testfile}.c
> + set binfile [standard_output_file $testfile$binsuffix]
> + set options [concat \
> + $options \
> + additional_flags="-DMAIN=jit_dl_main" \
> + debug]
> + if { [gdb_compile_shlib "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
> + $options] != "" } {
> + untested "Failure to compile jit-elf-main"
> + }
> +}
> +
> +# Compiles jit-elf-solib.c as multiple shared libraries
> +# distinguished by a numerical suffix
> +
> +proc compile_n_jit_so {count binsuffix options} {
> + global srcdir subdir solib_binfile_targets
I almost mentioned it in the previous patch, but especially now since this is
split in a separate library, I would suggest make this function return
solib_binfile_targets, instead of setting a global variable, that will make it
much easier to follow.
Simon
next prev parent reply other threads:[~2020-03-23 0:52 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 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 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 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 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 [this message]
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-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=03d76c7f-88ee-19ae-811f-a66a60af6a69@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