From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 65BE83858D37 for ; Thu, 21 Apr 2022 19:04:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 65BE83858D37 Received: from [172.16.0.95] (192-222-180-24.qc.cable.ebox.net [192.222.180.24]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id C8C641E15D; Thu, 21 Apr 2022 15:04:08 -0400 (EDT) Message-ID: Date: Thu, 21 Apr 2022 15:04:08 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH] Fix for gdb.base/solib-search.exp test. Content-Language: tl To: Carl Love , dje@google.com, gdb-patches@sourceware.org Cc: Rogerio Alves , Will Schmidt References: <8fe6f3bee129c0a3159d3ef57c942b9473255d8d.camel@us.ibm.com> <8f0ddc69-6cbd-14f6-8bb9-a3d3fb963493@simark.ca> <8c9d6b7cae96fd49cb455e6b1913b20ee8347c67.camel@us.ibm.com> From: Simon Marchi In-Reply-To: <8c9d6b7cae96fd49cb455e6b1913b20ee8347c67.camel@us.ibm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-8.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Apr 2022 19:04:12 -0000 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