public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix for gdb.base/solib-search.exp test.
@ 2022-03-22 21:49 Carl Love
  2022-03-28 15:21 ` [PING] " Carl Love
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Carl Love @ 2022-03-22 21:49 UTC (permalink / raw)
  To: dje, gdb-patches; +Cc: cel, Will Schmidt, Rogerio Alves


GDB maintainers:

The following patch fixes the setting of the variable right_lib_flags
in the solib-search.exp test.  With the fix the test now run correctly
on Powerpc.

The patch has been tested on a Power 10 system.

Please let me know if the patch is acceptable for mainline gdb. 
Thanks.

                      Carl Love

---------------------------------------------------
Fix for gdb.base/solib-search.exp test.

The variable right_lib_flags is not being set correctly to define RIGHT.
The value RIGHT is needed to force the address of the library functions
lib1_func3 and lib2_func4 to occur at different address in the wrong and
right libraries.

With RIGHT defined correctly, functions lib1_func3 and lib2_func4 occur
at different addresses the test runs correctly on Powerpc.
---
 gdb/testsuite/gdb.base/solib-search.exp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.base/solib-search.exp b/gdb/testsuite/gdb.base/solib-search.exp
index eaabe508bf0..202e79d85de 100644
--- a/gdb/testsuite/gdb.base/solib-search.exp
+++ b/gdb/testsuite/gdb.base/solib-search.exp
@@ -54,7 +54,7 @@ set binfile2_lib [standard_output_file ${libname2}.so]
 
 set lib_flags [list debug ldflags=-Wl,-Bsymbolic]
 set wrong_lib_flags "$lib_flags additional_flags=-DARRAY_SIZE=1"
-set right_lib_flags "$lib_flags additional_flags=-DARRAY_SIZE=8192 -DRIGHT"
+set right_lib_flags "$lib_flags additional_flags=-DARRAY_SIZE=8192 additional_flags=-DRIGHT"
 
 # Binary file.
 standard_testfile .c
-- 
2.31.1



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PING] [PATCH] Fix for gdb.base/solib-search.exp test.
  2022-03-22 21:49 [PATCH] Fix for gdb.base/solib-search.exp test Carl Love
@ 2022-03-28 15:21 ` Carl Love
  2022-04-07 15:13   ` [PING 2] " Carl Love
  2022-04-21 13:39 ` Simon Marchi
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 10+ messages in thread
From: Carl Love @ 2022-03-28 15:21 UTC (permalink / raw)
  To: dje, gdb-patches; +Cc: Will Schmidt, Rogerio Alves

On Tue, 2022-03-22 at 14:49 -0700, Carl Love wrote:
> GDB maintainers:
> 
> The following patch fixes the setting of the variable right_lib_flags
> in the solib-search.exp test.  With the fix the test now run
> correctly
> on Powerpc.
> 
> The patch has been tested on a Power 10 system.
> 
> Please let me know if the patch is acceptable for mainline gdb. 
> Thanks.
> 
>                       Carl Love
> 
> ---------------------------------------------------
> Fix for gdb.base/solib-search.exp test.
> 
> The variable right_lib_flags is not being set correctly to define
> RIGHT.
> The value RIGHT is needed to force the address of the library
> functions
> lib1_func3 and lib2_func4 to occur at different address in the wrong
> and
> right libraries.
> 
> With RIGHT defined correctly, functions lib1_func3 and lib2_func4
> occur
> at different addresses the test runs correctly on Powerpc.
> ---
>  gdb/testsuite/gdb.base/solib-search.exp | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/gdb/testsuite/gdb.base/solib-search.exp
> b/gdb/testsuite/gdb.base/solib-search.exp
> index eaabe508bf0..202e79d85de 100644
> --- a/gdb/testsuite/gdb.base/solib-search.exp
> +++ b/gdb/testsuite/gdb.base/solib-search.exp
> @@ -54,7 +54,7 @@ set binfile2_lib [standard_output_file
> ${libname2}.so]
> 
>  set lib_flags [list debug ldflags=-Wl,-Bsymbolic]
>  set wrong_lib_flags "$lib_flags additional_flags=-DARRAY_SIZE=1"
> -set right_lib_flags "$lib_flags additional_flags=-DARRAY_SIZE=8192
> -DRIGHT"
> +set right_lib_flags "$lib_flags additional_flags=-DARRAY_SIZE=8192
> additional_flags=-DRIGHT"
> 
>  # Binary file.
>  standard_testfile .c


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PING 2] [PATCH] Fix for gdb.base/solib-search.exp test.
  2022-03-28 15:21 ` [PING] " Carl Love
@ 2022-04-07 15:13   ` Carl Love
  2022-04-21  1:49     ` [PING 3] " Carl Love
  0 siblings, 1 reply; 10+ messages in thread
From: Carl Love @ 2022-04-07 15:13 UTC (permalink / raw)
  To: dje, gdb-patches, cel; +Cc: Will Schmidt, Rogerio Alves

GDB maintainers:

Still hoping someone can take a look at this patch for me.  Thanks.

                    Carl Love

On Mon, 2022-03-28 at 08:21 -0700, Carl Love wrote:
> On Tue, 2022-03-22 at 14:49 -0700, Carl Love wrote:
> > GDB maintainers:
> > 
> > The following patch fixes the setting of the variable
> > right_lib_flags
> > in the solib-search.exp test.  With the fix the test now run
> > correctly
> > on Powerpc.
> > 
> > The patch has been tested on a Power 10 system.
> > 
> > Please let me know if the patch is acceptable for mainline gdb. 
> > Thanks.
> > 
> >                       Carl Love
> > 
> > ---------------------------------------------------
> > Fix for gdb.base/solib-search.exp test.
> > 
> > The variable right_lib_flags is not being set correctly to define
> > RIGHT.
> > The value RIGHT is needed to force the address of the library
> > functions
> > lib1_func3 and lib2_func4 to occur at different address in the
> > wrong
> > and
> > right libraries.
> > 
> > With RIGHT defined correctly, functions lib1_func3 and lib2_func4
> > occur
> > at different addresses the test runs correctly on Powerpc.
> > ---
> >  gdb/testsuite/gdb.base/solib-search.exp | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/gdb/testsuite/gdb.base/solib-search.exp
> > b/gdb/testsuite/gdb.base/solib-search.exp
> > index eaabe508bf0..202e79d85de 100644
> > --- a/gdb/testsuite/gdb.base/solib-search.exp
> > +++ b/gdb/testsuite/gdb.base/solib-search.exp
> > @@ -54,7 +54,7 @@ set binfile2_lib [standard_output_file
> > ${libname2}.so]
> > 
> >  set lib_flags [list debug ldflags=-Wl,-Bsymbolic]
> >  set wrong_lib_flags "$lib_flags additional_flags=-DARRAY_SIZE=1"
> > -set right_lib_flags "$lib_flags additional_flags=-DARRAY_SIZE=8192
> > -DRIGHT"
> > +set right_lib_flags "$lib_flags additional_flags=-DARRAY_SIZE=8192
> > additional_flags=-DRIGHT"
> > 
> >  # Binary file.
> >  standard_testfile .c


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PING 3] [PATCH] Fix for gdb.base/solib-search.exp test.
  2022-04-07 15:13   ` [PING 2] " Carl Love
@ 2022-04-21  1:49     ` Carl Love
  0 siblings, 0 replies; 10+ messages in thread
From: Carl Love @ 2022-04-21  1:49 UTC (permalink / raw)
  To: dje, gdb-patches, Ulrich Weigand, cel; +Cc: Will Schmidt, Rogerio Alves

GDB maintainers:

This patch has yet to be reviewed by a GDB maintainer.

                     Carl 

On Thu, 2022-04-07 at 08:13 -0700, Carl Love wrote:
> GDB maintainers:
> 
> Still hoping someone can take a look at this patch for me.  Thanks.
> 
>                     Carl Love
> 
> On Mon, 2022-03-28 at 08:21 -0700, Carl Love wrote:
> > On Tue, 2022-03-22 at 14:49 -0700, Carl Love wrote:
> > > GDB maintainers:
> > > 
> > > The following patch fixes the setting of the variable
> > > right_lib_flags
> > > in the solib-search.exp test.  With the fix the test now run
> > > correctly
> > > on Powerpc.
> > > 
> > > The patch has been tested on a Power 10 system.
> > > 
> > > Please let me know if the patch is acceptable for mainline gdb. 
> > > Thanks.
> > > 
> > >                       Carl Love
> > > 
> > > ---------------------------------------------------
> > > Fix for gdb.base/solib-search.exp test.
> > > 
> > > The variable right_lib_flags is not being set correctly to define
> > > RIGHT.
> > > The value RIGHT is needed to force the address of the library
> > > functions
> > > lib1_func3 and lib2_func4 to occur at different address in the
> > > wrong
> > > and
> > > right libraries.
> > > 
> > > With RIGHT defined correctly, functions lib1_func3 and lib2_func4
> > > occur
> > > at different addresses the test runs correctly on Powerpc.
> > > ---
> > >  gdb/testsuite/gdb.base/solib-search.exp | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/gdb/testsuite/gdb.base/solib-search.exp
> > > b/gdb/testsuite/gdb.base/solib-search.exp
> > > index eaabe508bf0..202e79d85de 100644
> > > --- a/gdb/testsuite/gdb.base/solib-search.exp
> > > +++ b/gdb/testsuite/gdb.base/solib-search.exp
> > > @@ -54,7 +54,7 @@ set binfile2_lib [standard_output_file
> > > ${libname2}.so]
> > > 
> > >  set lib_flags [list debug ldflags=-Wl,-Bsymbolic]
> > >  set wrong_lib_flags "$lib_flags additional_flags=-DARRAY_SIZE=1"
> > > -set right_lib_flags "$lib_flags additional_flags=-
> > > DARRAY_SIZE=8192
> > > -DRIGHT"
> > > +set right_lib_flags "$lib_flags additional_flags=-
> > > DARRAY_SIZE=8192
> > > additional_flags=-DRIGHT"
> > > 
> > >  # Binary file.
> > >  standard_testfile .c


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Fix for gdb.base/solib-search.exp test.
  2022-03-22 21:49 [PATCH] Fix for gdb.base/solib-search.exp test Carl Love
  2022-03-28 15:21 ` [PING] " Carl Love
@ 2022-04-21 13:39 ` Simon Marchi
  2022-04-21 18:21   ` Carl Love
  2022-04-21 15:05 ` will schmidt
  2022-05-02 14:16 ` Ulrich Weigand
  3 siblings, 1 reply; 10+ messages in thread
From: Simon Marchi @ 2022-04-21 13:39 UTC (permalink / raw)
  To: Carl Love, dje, gdb-patches; +Cc: Rogerio Alves

On 2022-03-22 17:49, Carl Love via Gdb-patches wrote:
>
> GDB maintainers:
>
> The following patch fixes the setting of the variable right_lib_flags
> in the solib-search.exp test.  With the fix the test now run correctly
> on Powerpc.
>
> The patch has been tested on a Power 10 system.
>
> Please let me know if the patch is acceptable for mainline gdb.
> Thanks.
>
>                       Carl Love
>
> ---------------------------------------------------
> Fix for gdb.base/solib-search.exp test.
>
> The variable right_lib_flags is not being set correctly to define RIGHT.
> The value RIGHT is needed to force the address of the library functions
> lib1_func3 and lib2_func4 to occur at different address in the wrong and
> right libraries.
>
> With RIGHT defined correctly, functions lib1_func3 and lib2_func4 occur
> at different addresses the test runs correctly on Powerpc.
> ---
>  gdb/testsuite/gdb.base/solib-search.exp | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/gdb/testsuite/gdb.base/solib-search.exp b/gdb/testsuite/gdb.base/solib-search.exp
> index eaabe508bf0..202e79d85de 100644
> --- a/gdb/testsuite/gdb.base/solib-search.exp
> +++ b/gdb/testsuite/gdb.base/solib-search.exp
> @@ -54,7 +54,7 @@ set binfile2_lib [standard_output_file ${libname2}.so]
>
>  set lib_flags [list debug ldflags=-Wl,-Bsymbolic]
>  set wrong_lib_flags "$lib_flags additional_flags=-DARRAY_SIZE=1"
> -set right_lib_flags "$lib_flags additional_flags=-DARRAY_SIZE=8192 -DRIGHT"
> +set right_lib_flags "$lib_flags additional_flags=-DARRAY_SIZE=8192 additional_flags=-DRIGHT"

Hi Carl,

Intuitively, this looks good.  But I'd like to understand why this fails
on PPC but not x86-64.  Can you show the failure that you see?  It's
also a good idea to put it in the commit log for future reference.  You
can paste the FAIL line that you get before the patch, and the PASS line
that you get after the patch.  Include the relevant lines from gdb.log
just before those, so we can see what changed between before and after.

Simon

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Fix for gdb.base/solib-search.exp test.
  2022-03-22 21:49 [PATCH] Fix for gdb.base/solib-search.exp test Carl Love
  2022-03-28 15:21 ` [PING] " Carl Love
  2022-04-21 13:39 ` Simon Marchi
@ 2022-04-21 15:05 ` will schmidt
  2022-05-02 14:16 ` Ulrich Weigand
  3 siblings, 0 replies; 10+ messages in thread
From: will schmidt @ 2022-04-21 15:05 UTC (permalink / raw)
  To: Carl Love, dje, gdb-patches; +Cc: Rogerio Alves

On Tue, 2022-03-22 at 14:49 -0700, Carl Love wrote:
> GDB maintainers:
> 
> The following patch fixes the setting of the variable right_lib_flags
> in the solib-search.exp test.  With the fix the test now run
> correctly
> on Powerpc.
> 
> The patch has been tested on a Power 10 system.
> 
> Please let me know if the patch is acceptable for mainline gdb. 
> Thanks.
> 
>                       Carl Love
> 
> ---------------------------------------------------
> Fix for gdb.base/solib-search.exp test.
> 
> The variable right_lib_flags is not being set correctly to define
> RIGHT.
> The value RIGHT is needed to force the address of the library
> functions
> lib1_func3 and lib2_func4 to occur at different address in the wrong
> and
> right libraries.
> 
> With RIGHT defined correctly, functions lib1_func3 and lib2_func4
> occur
> at different addresses the test runs correctly on Powerpc.
> ---
>  gdb/testsuite/gdb.base/solib-search.exp | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/gdb/testsuite/gdb.base/solib-search.exp
> b/gdb/testsuite/gdb.base/solib-search.exp
> index eaabe508bf0..202e79d85de 100644
> --- a/gdb/testsuite/gdb.base/solib-search.exp
> +++ b/gdb/testsuite/gdb.base/solib-search.exp
> @@ -54,7 +54,7 @@ set binfile2_lib [standard_output_file
> ${libname2}.so]
> 
>  set lib_flags [list debug ldflags=-Wl,-Bsymbolic]
>  set wrong_lib_flags "$lib_flags additional_flags=-DARRAY_SIZE=1"
> -set right_lib_flags "$lib_flags additional_flags=-DARRAY_SIZE=8192
> -DRIGHT"
> +set right_lib_flags "$lib_flags additional_flags=-DARRAY_SIZE=8192
> additional_flags=-DRIGHT"
> 

This change seems reasonable.  Presumably the DARRAY_SIZE change
introduced enough delta such that the test passed on other archs, and
PowerPC was simply unlucky to catch the error.

This change may fall under "obvious" , since it's a fix to the
arguments used for the test, and post-fix now matches the style used in
other tests with more than one argument.  Particularly in comparison
with the existing vsx-vsr-float28.exp test.
Maybe an informal chat in the GDB IRC chat to confirm the guidelines
for obvious.  :-)

Thanks
-Will
>  # Binary file.
>  standard_testfile .c


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Fix for gdb.base/solib-search.exp test.
  2022-04-21 13:39 ` Simon Marchi
@ 2022-04-21 18:21   ` Carl Love
  2022-04-21 19:04     ` Simon Marchi
  0 siblings, 1 reply; 10+ messages in thread
From: Carl Love @ 2022-04-21 18:21 UTC (permalink / raw)
  To: Simon Marchi, dje, gdb-patches; +Cc: Rogerio Alves, Will Schmidt, cel

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)

The issue then is on Power where the ARRAY_SIZE of 1 versus 8192 is not
sufficient to cause the dymanic linker to allocate the libraries at
different addresses.  I don't claim to understand the specifics of how
the dynamic linker works and what the default size is for the data and
code sections are.  My guess is by default PowerPC allocates a larger
data size by default, which is large enough to hold array[8192].  The
default size of the data section allocated by the dynamic linker on
Intel is not large enough to hold array[8192] thus causing the code
section on Intel to have to move when the large array is defined.

Note on PowerPC, if you make ARRAY_SIZE big enough, then you will cause
the library addresses to occur at different addresses as the larger
data section forces the code section to a different address.  That was
actually my original fix for the program until I spoke with Doug Evans
who originally wrote the test.  Doug noticed that RIGHT was not getting
defined as he originally intended in the test.  

With the patch to fix the definition of RIGHT, PowerPC has a bad and a
good backtrace because the address of lib1_func3 and lib2_func4 both
move because lib1_spacer and lib2_spacer are now defined
before lib1_func3 and lib2_func4.  

I don't claim to understand the details of how the dynamic linker works
to layout the data and code sections on Intel versus PowerPC. But,
clearly you can change the address of lib1_func3 and lib2_func4 by
defining or not defining RIGHT and thus mess up the backtrace.  

The bottom line is without the patch, the lib1_spacer and lib2_spacer
function doesn't show up in the binary for the correct or incorrect
library on Intel or PowerPC.  With the patch, RIGHT gets defined as
originally intended for the test on both architectures and lib1_spacer
and lib2_spacer function show up in the binaries on both architectures
changing the other function addresses as intended thus causing the test
work as intended on PowerPC.

                      Carl Love

On Thu, 2022-04-21 at 09:39 -0400, Simon Marchi wrote:
> On 2022-03-22 17:49, Carl Love via Gdb-patches wrote:
> > GDB maintainers:
> > 
> > The following patch fixes the setting of the variable
> > right_lib_flags
> > in the solib-search.exp test.  With the fix the test now run
> > correctly
> > on Powerpc.
> > 
> > The patch has been tested on a Power 10 system.
> > 
> > Please let me know if the patch is acceptable for mainline gdb.
> > Thanks.
> > 
> >                       Carl Love
> > 
> > ---------------------------------------------------
> > Fix for gdb.base/solib-search.exp test.
> > 
> > The variable right_lib_flags is not being set correctly to define
> > RIGHT.
> > The value RIGHT is needed to force the address of the library
> > functions
> > lib1_func3 and lib2_func4 to occur at different address in the
> > wrong and
> > right libraries.
> > 
> > With RIGHT defined correctly, functions lib1_func3 and lib2_func4
> > occur
> > at different addresses the test runs correctly on Powerpc.
> > ---
> >  gdb/testsuite/gdb.base/solib-search.exp | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/gdb/testsuite/gdb.base/solib-search.exp
> > b/gdb/testsuite/gdb.base/solib-search.exp
> > index eaabe508bf0..202e79d85de 100644
> > --- a/gdb/testsuite/gdb.base/solib-search.exp
> > +++ b/gdb/testsuite/gdb.base/solib-search.exp
> > @@ -54,7 +54,7 @@ set binfile2_lib [standard_output_file
> > ${libname2}.so]
> > 
> >  set lib_flags [list debug ldflags=-Wl,-Bsymbolic]
> >  set wrong_lib_flags "$lib_flags additional_flags=-DARRAY_SIZE=1"
> > -set right_lib_flags "$lib_flags additional_flags=-DARRAY_SIZE=8192 
> > -DRIGHT"
> > +set right_lib_flags "$lib_flags additional_flags=-DARRAY_SIZE=8192 
> > additional_flags=-DRIGHT"
> 
> Hi Carl,
> 
> Intuitively, this looks good.  But I'd like to understand why this
> fails
> on PPC but not x86-64.  Can you show the failure that you see?  It's
> also a good idea to put it in the commit log for future
> reference.  You
> can paste the FAIL line that you get before the patch, and the PASS
> line
> that you get after the patch.  Include the relevant lines from
> gdb.log
> just before those, so we can see what changed between before and
> after.
> 
> Simon


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Fix for gdb.base/solib-search.exp test.
  2022-04-21 18:21   ` Carl Love
@ 2022-04-21 19:04     ` Simon Marchi
  2022-04-21 19:16       ` Carl Love
  0 siblings, 1 reply; 10+ messages in thread
From: Simon Marchi @ 2022-04-21 19:04 UTC (permalink / raw)
  To: Carl Love, dje, gdb-patches; +Cc: Rogerio Alves, Will Schmidt

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Fix for gdb.base/solib-search.exp test.
  2022-04-21 19:04     ` Simon Marchi
@ 2022-04-21 19:16       ` Carl Love
  0 siblings, 0 replies; 10+ messages in thread
From: Carl Love @ 2022-04-21 19:16 UTC (permalink / raw)
  To: Simon Marchi; +Cc: Carl Love, dje, gdb-patches, Rogerio Alves, Will Schmidt

On Thu, 2022-04-21 at 15:04 -0400, Simon Marchi wrote:
> 

<snip>
> 
> 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.

Yup, will do.  Thanks.

                    Carl 


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Fix for gdb.base/solib-search.exp test.
  2022-03-22 21:49 [PATCH] Fix for gdb.base/solib-search.exp test Carl Love
                   ` (2 preceding siblings ...)
  2022-04-21 15:05 ` will schmidt
@ 2022-05-02 14:16 ` Ulrich Weigand
  3 siblings, 0 replies; 10+ messages in thread
From: Ulrich Weigand @ 2022-05-02 14:16 UTC (permalink / raw)
  To: gdb-patches, cel

Carl Love <cel@us.ibm.com> wrote:

>The following patch fixes the setting of the variable right_lib_flags
>in the solib-search.exp test.  With the fix the test now run correctly
>on Powerpc.
>
>The patch has been tested on a Power 10 system.
>
>Please let me know if the patch is acceptable for mainline gdb. 
>Thanks.

This is OK.

Thanks,
Ulrich


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-05-02 14:16 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-22 21:49 [PATCH] Fix for gdb.base/solib-search.exp test 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
2022-04-21 19:16       ` Carl Love
2022-04-21 15:05 ` will schmidt
2022-05-02 14:16 ` Ulrich Weigand

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).