public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simark@simark.ca>
To: Tom de Vries <tdevries@suse.de>,
	Ivan Tetyushkin <ivan.tetyushkin@syntacore.com>,
	gdb-patches@sourceware.org,
	Andrew Burgess <andrew.burgess@embecosm.com>
Subject: Re: [PATCH 2/7] [gdb/testsuite] fix test gdb.base/print-file-var.exp for remote execution
Date: Mon, 7 Nov 2022 08:55:17 -0500	[thread overview]
Message-ID: <7ab4978f-6a96-8140-7702-f2790d6281b5@simark.ca> (raw)
In-Reply-To: <a15ed31b-6199-8811-4396-58fd63bb0ba4@suse.de>



On 11/6/22 05:54, Tom de Vries via Gdb-patches wrote:
> On 10/25/22 18:29, Ivan Tetyushkin wrote:
>> ---
>>   gdb/testsuite/gdb.base/print-file-var.exp | 4 +++-
>>   1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/gdb/testsuite/gdb.base/print-file-var.exp b/gdb/testsuite/gdb.base/print-file-var.exp
>> index 9abe87d7758..73137630fed 100644
>> --- a/gdb/testsuite/gdb.base/print-file-var.exp
>> +++ b/gdb/testsuite/gdb.base/print-file-var.exp
>> @@ -42,6 +42,8 @@ proc test {hidden dlopen version_id_main lang} {
>>       set libobj1 [standard_output_file ${lib1}$suffix.so]
>>       set libobj2 [standard_output_file ${lib2}$suffix.so]
>>   +    set runtimelibobj2 [get_runtime_file $libobj2]
>> +
>>       set lib_opts { debug $lang }
>>       lappend lib_opts "additional_flags=-DHIDDEN=$hidden"
>>   @@ -60,7 +62,7 @@ proc test {hidden dlopen version_id_main lang} {
>>       set link_opts [list debug shlib=${libobj1}]
>>         if {$dlopen} {
>> -    lappend main_opts "additional_flags=-DSHLIB_NAME=\"$libobj2\""
>> +    lappend main_opts "additional_flags=-DSHLIB_NAME=\"$runtimelibobj2\""
>>       lappend link_opts "shlib_load"
>>       } else {
>>       lappend link_opts "shlib=${libobj2}"
> 
> I get this test-case passing by avoiding to use an absolute file name:
> ...
> diff --git a/gdb/testsuite/gdb.base/print-file-var.exp b/gdb/testsuite/gdb.base/print-file-
> var.exp
> index 9abe87d7758..338840cb05e 100644
> --- a/gdb/testsuite/gdb.base/print-file-var.exp
> +++ b/gdb/testsuite/gdb.base/print-file-var.exp
> @@ -60,7 +60,7 @@ proc test {hidden dlopen version_id_main lang} {
>      set link_opts [list debug shlib=${libobj1}]
> 
>      if {$dlopen} {
> -       lappend main_opts "additional_flags=-DSHLIB_NAME=\"$libobj2\""
> +       lappend main_opts "additional_flags=-DSHLIB_NAME=\"[file tail $libobj2]\""
>         lappend link_opts "shlib_load"
>      } else {
>         lappend link_opts "shlib=${libobj2}"
> ...
> which means that the file is found relative to $ORIGIN, as is the case for $dlopen == 0.
> 
> I'm not entirely happy with this fix, because what we'd rather want is to use the name as returned by remote_download, but that's done in gdb_load_shlib later on (which also handles shlib_target_file, so actually, the name as returned by this proc is the one we really want), so it's not available yet at the time we do the compilation.
> 
> I've thought about allowing gdb_load_shlib to be called without gdb instance, and for cases where there's no instance, registering the solib-search-path setting to be done at gdb start.  This will allow us to move the gdb_load_shlib calls to before the compilation, such that we can use the result to set -DSHLIB_NAME.  But I think it's a solution bound to cause confusion because things happen under the hood.
> 
> Alternatively, we can try to not pass in the name into compilation (working around only some of the problems related to remote host testing, see https://sourceware.org/bugzilla/show_bug.cgi?id=16947), but that also has its limitations: we need to be able to patch target memory or the ability to use argv.
> 
> Perhaps splitting up the functionality in gdb_load_shlib makes the most sense.  By default, it'll do the same as before, but by calling it twice, once with -only-download, and once with -no-download can we get the solib name before starting gdb.
> 
> I've given this a try in patch attached below.
> 
> Ivan, could you check if the patch fixes the gdb.base/print-file-var.exp test-case for you?

I just gave it a quick look and I'm not familiar with the entire
problem.  But it sounds to me like it would be clearer to just make two
procs for the two steps, instead of one proc with flags to control its
behavior.  And perhaps a third proc that does both steps, for
convenience (which would be called gdb_load_shlib for backwards
compatibility, I guess).

Simon

  parent reply	other threads:[~2022-11-07 13:55 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-25 16:29 [PATCH 0/7] introduce get_runtime_path Ivan Tetyushkin
2022-10-25 16:29 ` [PATCH 1/7] [gdb/testsuite] Adding function to find runtime path to support remote execution for testsuite Ivan Tetyushkin
2022-10-25 16:29 ` [PATCH 2/7] [gdb/testsuite] fix test gdb.base/print-file-var.exp for remote execution Ivan Tetyushkin
2022-11-06 10:54   ` Tom de Vries
2022-11-07 13:32     ` Andrew Burgess
2022-11-07 13:49       ` Ivan Tetyushkin
2022-11-07 16:44         ` Tom de Vries
2022-11-15 14:39           ` Tom de Vries
2022-11-07 16:18       ` Tom de Vries
2022-11-07 13:55     ` Simon Marchi [this message]
2022-11-07 16:15       ` Tom de Vries
2022-10-25 16:29 ` [PATCH 3/7] [gdb/testsuite] fix test gdb.base/jit-reader-exec.exp " Ivan Tetyushkin
2022-10-25 16:29 ` [PATCH 4/7] [gdb/testsuite] fix test gdb.base/solib-vanish.exp " Ivan Tetyushkin
2022-10-25 16:29 ` [PATCH 5/7] [gdb/testsuite] fix test gdb.base/infcall-exec.exp " Ivan Tetyushkin
2022-10-25 16:29 ` [PATCH 6/7] [gdb/testsuite] fix test gdb.base/info-shared.exp " Ivan Tetyushkin
2022-10-25 16:29 ` [PATCH 7/7] [gdb/testsuite] fix test gdb.base/jit-elf-so.exp " Ivan Tetyushkin
2022-10-29  9:20 ` [PATCH 0/7] introduce get_runtime_path Andrew Burgess
2022-11-01  9:19   ` Ivan Tetyushkin
2022-11-05 14:39   ` Tom de Vries

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=7ab4978f-6a96-8140-7702-f2790d6281b5@simark.ca \
    --to=simark@simark.ca \
    --cc=andrew.burgess@embecosm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=ivan.tetyushkin@syntacore.com \
    --cc=tdevries@suse.de \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).