public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simark@simark.ca>
To: Carl Love <cel@us.ibm.com>, dje@google.com, gdb-patches@sourceware.org
Cc: Rogerio Alves <rogealve@br.ibm.com>,
	Will Schmidt <will_schmidt@vnet.ibm.com>
Subject: Re: [PATCH] Fix for gdb.base/solib-search.exp test.
Date: Thu, 21 Apr 2022 15:04:08 -0400	[thread overview]
Message-ID: <bd16e7df-a650-9fbd-7188-3889ce0445fd@simark.ca> (raw)
In-Reply-To: <8c9d6b7cae96fd49cb455e6b1913b20ee8347c67.camel@us.ibm.com>

On 2022-04-21 14:21, Carl Love wrote:
> Simon:
>
> The test needs the lib2 addresses to be different in the right and
> wrong cases.  That is the point of introducing function lib2_spacer
> with the ifdef RIGHT compiler directive.
>
> On Intel, the ARRAY_SIZE of 1 versus 8192 is sufficient to get the
> dynamic linker to move the addresses of the library.  You can also get
> the same effect on PowerPC but you must use a value much larger than
> 8192.
>
> The key thing is that the test was not properly setting RIGHT to
> defined to get the lib2_spacer function on Intel and Powerpc.
>
> Without the patch, we have the Intel backtrace for the bad libraries:
>
> backtrace
> #0  break_here () at /home/carll/GDB/binutils-build/gdb/testsuite/../../../binutils-gdb/gdb/testsuite/gdb.base/solib-search.c:30
> #1  0x00007ffff7fae156 in ?? ()
> #2  0x00007fffffffc150 in ?? ()
> #3  0x00007ffff7fbb156 in ?? ()
> #4  0x00007fffffffc160 in ?? ()
> #5  0x00007ffff7fae146 in ?? ()
> #6  0x00007fffffffc170 in ?? ()
> #7  0x00007ffff7fbb146 in ?? ()
> #8  0x00007fffffffc180 in ?? ()
> #9  0x0000555555555156 in main () at /home/carll/GDB/binutils-build/gdb/testsuite/../../../binutils-gdb/gdb/testsuite/gdb.base/solib-search.c:23
> Backtrace stopped: previous frame inner to this frame (corrupt stack?)
> (gdb) PASS: gdb.base/solib-search.exp: backtrace (with wrong libs) (data collection)
>
> The backtrace on Intel with the good libraries is:
>
> backtrace
> #0  break_here () at /home/carll/GDB/binutils-build/gdb/testsuite/../../../binutils-gdb/gdb/testsuite/gdb.base/solib-search.c:30
> #1  0x00007ffff7fae156 in lib2_func4 () at /home/carll/GDB/binutils-build/gdb/testsuite/../../../binutils-gdb/gdb/testsuite/gdb.base/solib-search-lib2.c:49
> #2  0x00007ffff7fbb156 in lib1_func3 () at /home/carll/GDB/binutils-build/gdb/testsuite/../../../binutils-gdb/gdb/testsuite/gdb.base/solib-search-lib1.c:49
> #3  0x00007ffff7fae146 in lib2_func2 () at /home/carll/GDB/binutils-build/gdb/testsuite/../../../binutils-gdb/gdb/testsuite/gdb.base/solib-search-lib2.c:30
> #4  0x00007ffff7fbb146 in lib1_func1 () at /home/carll/GDB/binutils-build/gdb/testsuite/../../../binutils-gdb/gdb/testsuite/gdb.base/solib-search-lib1.c:30
> #5  0x0000555555555156 in main () at /home/carll/GDB/binutils-build/gdb/testsuite/../../../binutils-gdb/gdb/testsuite/gdb.base/solib-search.c:23
> (gdb) PASS: gdb.base/solib-search.exp: backtrace (with right libs) (data collection)
> PASS: gdb.base/solib-search.exp: backtrace (with right libs)
>
> You can see in the one case the backtrace is correct and the other it
> is wrong on Intel.  This is due to the fact that the ARRAY_SIZE caused
> the dynamic linker to move the library function addresses around.  I
> believe it has to do with the default size of the data and code
> sections used by the dynamic linker.
>
>
> So without the patch the backtrace on PowerPC looks like:
>
>  backtrace
> #0  break_here () at /home/carll/GDB/build-play/gdb/testsuite/../../../binutils-gdb-play/gdb/testsuite/gdb.base/solib-search.c:30
> #1  0x00007ffff7f007f4 in lib2_func4 () at /home/carll/GDB/build-play/gdb/testsuite/../../../binutils-gdb-play/gdb/testsuite/gdb.base/solib-search-lib2.c:49
> #2  0x00007ffff7f307f4 in lib1_func3 () at /home/carll/GDB/build-play/gdb/testsuite/../../../binutils-gdb-play/gdb/testsuite/gdb.base/solib-search-lib1.c:49
> #3  0x00007ffff7f007ac in lib2_func2 () at /home/carll/GDB/build-play/gdb/testsuite/../../../binutils-gdb-play/gdb/testsuite/gdb.base/solib-search-lib2.c:30
> #4  0x00007ffff7f307ac in lib1_func1 () at /home/carll/GDB/build-play/gdb/testsuite/../../../binutils-gdb-play/gdb/testsuite/gdb.base/solib-search-lib1.c:30
> #5  0x000000001000074c in main () at /home/carll/GDB/build-play/gdb/testsuite/../../../binutils-gdb-play/gdb/testsuite/gdb.base/solib-search.c:23
>
> for both the good and bad libraries.
>
> The patch fixes defining RIGHT in solib-search-lib1.c and solib-search-
> lib2.c.  Note, without the patch the lib1_spacer and lib2_spacer
> functions do not show up in the object dump of the Intel or Powerpc
> libraries as it should.  The patch fixes that by making sure RIGHT gets
> defined.
>
> Now with the patch the backtrace for the bad library on PowerPC looks
> like:
>
> backtrace
> #0  break_here () at /home/carll/GDB/build-play/gdb/testsuite/../../../binutils-gdb-play/gdb/testsuite/gdb.base/solib-search.c:30
> #1  0x00007ffff7f0083c in __glink_PLTresolve () from /home/carll/GDB/build-play/gdb/testsuite/outputs/gdb.base/solib-search/solib-search-lib2.so
> Backtrace stopped: frame did not save the PC
>
> And the backtrace for the good libraries on PowerPC looks like:
>
> backtrace
> #0  break_here () at /home/carll/GDB/build-play/gdb/testsuite/../../../binutils-gdb-play/gdb/testsuite/gdb.base/solib-search.c:30
> #1  0x00007ffff7f0083c in lib2_func4 () at /home/carll/GDB/build-play/gdb/testsuite/../../../binutils-gdb-play/gdb/testsuite/gdb.base/solib-search-lib2.c:49
> #2  0x00007ffff7f3083c in lib1_func3 () at /home/carll/GDB/build-play/gdb/testsuite/../../../binutils-gdb-play/gdb/testsuite/gdb.base/solib-search-lib1.c:49
> #3  0x00007ffff7f007cc in lib2_func2 () at /home/carll/GDB/build-play/gdb/testsuite/../../../binutils-gdb-play/gdb/testsuite/gdb.base/solib-search-lib2.c:30
> #4  0x00007ffff7f307cc in lib1_func1 () at /home/carll/GDB/build-play/gdb/testsuite/../../../binutils-gdb-play/gdb/testsuite/gdb.base/solib-search-lib1.c:30
> #5  0x000000001000074c in main () at /home/carll/GDB/build-play/gdb/testsuite/../../../binutils-gdb-play/gdb/testsuite/gdb.base/solib-search.c:23
> (gdb) PASS: gdb.base/solib-search.exp: backtrace (with right libs) (data collection)
> PASS: gdb.base/solib-search.exp: backtrace (with right libs)

Cool, can you integrate the info above in your commit message?  That
makes the problem clearer for somebody not in your seat.  The patch is
ok with that changed, thanks.

Simon

  reply	other threads:[~2022-04-21 19:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-22 21:49 Carl Love
2022-03-28 15:21 ` [PING] " Carl Love
2022-04-07 15:13   ` [PING 2] " Carl Love
2022-04-21  1:49     ` [PING 3] " Carl Love
2022-04-21 13:39 ` Simon Marchi
2022-04-21 18:21   ` Carl Love
2022-04-21 19:04     ` Simon Marchi [this message]
2022-04-21 19:16       ` Carl Love
2022-04-21 15:05 ` will schmidt
2022-05-02 14:16 ` Ulrich Weigand

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=bd16e7df-a650-9fbd-7188-3889ce0445fd@simark.ca \
    --to=simark@simark.ca \
    --cc=cel@us.ibm.com \
    --cc=dje@google.com \
    --cc=gdb-patches@sourceware.org \
    --cc=rogealve@br.ibm.com \
    --cc=will_schmidt@vnet.ibm.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).