From: Pedro Alves <palves@redhat.com>
To: Walfred Tedeschi <walfred.tedeschi@intel.com>, qiyaoltc@gmail.com
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] symlookup: improves symbol lookup when a file is specified.
Date: Mon, 09 Oct 2017 12:42:00 -0000 [thread overview]
Message-ID: <c84bf663-383f-8189-81fb-af86c59bdbdc@redhat.com> (raw)
In-Reply-To: <1504687613-14649-3-git-send-email-walfred.tedeschi@intel.com>
On 09/06/2017 09:46 AM, Walfred Tedeschi wrote:
> The provided patch adds a global lookup with higher priority for the
> provided file.
>
> Usual symbol lookup from GDB follows linker logic. This is what is
> desired most of the time. In the usage case a file is provided as
> scope, so the lookup has to follow this priority. Failing in finding
> the symbol at this scope usual path is followed.
>
> As test case it is presented two shared objects having a global variable
> with the same name but comming from different source files. Without the
> patch accessing them via the file scope returns the value seen in the
> first loaded shared object. Using the patch the value defined in the file
> scope is the one returned.
>
> One of the already existing test cases in print-file-var.exp starts to
> fail after using this patch. In fact the value that the linker sees is
> different then the one debugger can read from the shared object. In
> this sense it looks like to me that the test has to be changed.
> The fail is in the call:
> print 'print-file-var-lib2.c'::this_version_id == v2
> In this case there also in both libraries the symbol this_version_id.
> During load of the libraries linker resolves the symbol as the first one
> loaded and independent of the scope symbol will have the same value, as
> defined in the first library loaded.
> However, when defining the scope the value should represent the value
> in that context. Diferent evaluations of the same symbols might also better
> spot the issue in users code.
>
> - I haven't changed the test because I wanted to hear the community
> thought on the subject.
I'm not sure I understand the description above, so I'd like to try this
locally to try to understand it better, but the test fails for me:
(gdb) break print-file-var-dlopen-main.c:51
Breakpoint 2 at 0x400751: file /home/pedro/gdb/mygit/src/gdb/testsuite/gdb.base/print-file-var-dlopen-main.c, line 51.
(gdb) PASS: gdb.base/print-file-var-dlopen.exp: breapoint past v1 & v2 initialization
continue
Continuing.
[Inferior 1 (process 11534) exited with code 01]
(gdb) FAIL: gdb.base/print-file-var-dlopen.exp: continue to STOP marker (the program exited)
The program exits because dlopen failed. Is there a reason the test
is trying to use LD_LIBRARY_PATH instead of compiling the program
with the shared library file name defined as an absolute path via
additional_flags=-DXXXX like seemingly every other dlopen test does?
> +
> + dummy (); /* STOP */
> + dlclose (lib1);
> + dlclose (lib2);
> + if (v1 != 104)
> + return 1;
> + /* The value returned by get_version_2 depends on the target system. */
> + if (v2 != 104 || v2 != 203)
> + return 2;
> +
> + return 0;
> +}
> +
I tried to fix the above to get it running for me, but then noticed other
things clearly bad with the test. This certainly can't have passed as
is for you.
For example, the test reuses these source files from the
print-file-var.exp test:
+set lib1 "print-file-var-lib1"
+set lib2 "print-file-var-lib2"
But then looks for "get_version" symbols in them, but there's
no such symbols...:
+ *(int **) (&get_version1) = dlsym (lib1, "get_version");
+ *(int **) (&get_version2) = dlsym (lib2, "get_version");
While here:
> +
> +gdb_test "print 'print-file-var-dlopen-lib1.c'::this_version_id == v1" \
> + " = 1"
it looks like the test actually wanted to use some different
source files, but there's no print-file-var-dlopen-lib1.c included
in the patch.
Walfred, please double check what you intend to submit.
Pedro Alves
next prev parent reply other threads:[~2017-10-09 12:42 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-06 8:47 [PATCH] icc: allow code path for newer versions of icc Walfred Tedeschi
2017-09-06 8:47 ` [PATCH] gdb - avx512: tests were failing due to missing memory aligment Walfred Tedeschi
2017-09-16 13:57 ` Simon Marchi
2017-09-17 20:22 ` Yao Qi
2017-09-18 14:18 ` Tedeschi, Walfred
2017-09-20 13:39 ` [pushed] " Tedeschi, Walfred
2017-09-06 8:47 ` [PATCH] symlookup: improves symbol lookup when a file is specified Walfred Tedeschi
2017-09-20 15:22 ` [ping][PATCH] " Tedeschi, Walfred
2017-10-09 7:35 ` Tedeschi, Walfred
2017-10-09 12:42 ` Pedro Alves [this message]
2017-10-09 14:06 ` [PATCH] " Tedeschi, Walfred
2017-09-16 13:49 ` [PATCH] icc: allow code path for newer versions of icc Simon Marchi
2017-09-18 14:17 ` Tedeschi, Walfred
2017-09-18 15:34 ` Pedro Alves
2017-09-18 16:24 ` Simon Marchi
2017-09-18 16:34 ` Tedeschi, Walfred
2017-09-18 19:13 ` Simon Marchi
2017-09-20 15:19 ` Tedeschi, Walfred
2017-09-20 15:45 ` Pedro Alves
2017-09-20 15:55 ` Tedeschi, Walfred
2017-09-21 11:27 ` Tedeschi, Walfred
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=c84bf663-383f-8189-81fb-af86c59bdbdc@redhat.com \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=qiyaoltc@gmail.com \
--cc=walfred.tedeschi@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