RE: [RFC-v2] amd64-windows: Fix funcall with by-pointer arguments

Pierre Muller
2013-09-24T22:02:15Z

Following your commit,
I was able to recheck my code,
as you rebased it in:

https://sourceware.org/ml/gdb-patches/2013-09/msg00784.html

It still applies cleanly.

I ran I small script (in order to avoid running the whole testsuite,
as it takes ages for mingw hosts due to losts of timeouts...)

Here is the script:

>>>>>>>>>>>>>>>>>>>>Start of script
#!/bin/bash

builddir=~/gdbcvs/build-cross-src-mingw64
srcdir=~/gdbcvs/src/gdb

# Obtained by grep -E '"(call|p|print) +[A-Za-z_][a-zA-Z0-9_]* *(' */*.exp
# in testsuite sub-directory

exp_list=`cd $srcdir/testsuite; grep -E '"(call|p|print)
+[a-zA-Z_][a-zA-Z0-9_]
* *\(' */*exp -l`

exp_list=`echo ${exp_list} | tr '\n' ' '`

echo "exp_list is $exp_list"

function runtests {
cd $builddir
echo compiling
make all-gdb 1> make-$1.log 2>&1

cd gdb/testsuite
echo Running testsuite
echo "make check RUNTESTFLAGS=\"$exp_list\""
make check RUNTESTFLAGS="$exp_list" > ../make-tests-$1.log
cp gdb.sum gdb-$1.sum
cp gdb.log gdb-$1.log
cd $srcdir
}

runtests 0

patch -p 2 -i
../../patches/0002-Pierre-s-modifications-for-amd64-windows-funcalls.patch

runtests 1

patch -p 2 -i
../../patches/0002-Pierre-s-modifications-for-amd64-windows-funcalls.patch
-R

runtests 0b
>>>>>>>>>>>>>>>>>>>>End of script
Diffgdb-0.sum and gdb-1.sum is given below,
most of the FAIL->PASS are related to the fact that your
patch mishandles "long double" types and passes them
in xmm register when the need to be handled as copy-on-stack and pass
stack-address.

I will try to separate the patch into smaller pieces
for easier review.

Pierre Muller

*** gdb-0.sum 2013-09-24 23:25:04.777087500 +0200
--- gdb-1.sum 2013-09-24 23:30:50.094838600 +0200
***************
*** 1,4 ****
! Test Run By Pierre on Tue Sep 24 23:19:29 2013
Target is x86_64-w64-mingw32
Host is x86_64-w64-mingw32
Build is i686-pc-cygwin
--- 1,4 ----
! Test Run By Pierre on Tue Sep 24 23:25:38 2013
Target is x86_64-w64-mingw32
Host is x86_64-w64-mingw32
Build is i686-pc-cygwin
***************
*** 1274,1280 ****
PASS: gdb.base/varargs.exp: print find_max1(10,1,2,3,4,5,6,7,8,29,0)
PASS: gdb.base/varargs.exp: print find_max2(3,1,2,3)
PASS: gdb.base/varargs.exp: print find_max_double(5,1.0,17.0,2.0,3.0,4.0)
! FAIL: gdb.base/varargs.exp: print find_max_float_real(4, fc1, fc2, fc3,
fc4)
PASS: gdb.base/varargs.exp: print find_max_double_real(4, dc1, dc2, dc3,
dc4)
PASS: gdb.base/varargs.exp: print find_max_long_double_real(4, ldc1, ldc2,
ldc3, ldc4)
Running ../../../src/gdb/testsuite/gdb.arch/e500-abi.exp ...
--- 1274,1280 ----
PASS: gdb.base/varargs.exp: print find_max1(10,1,2,3,4,5,6,7,8,29,0)
PASS: gdb.base/varargs.exp: print find_max2(3,1,2,3)
PASS: gdb.base/varargs.exp: print find_max_double(5,1.0,17.0,2.0,3.0,4.0)
! PASS: gdb.base/varargs.exp: print find_max_float_real(4, fc1, fc2, fc3,
fc4)
PASS: gdb.base/varargs.exp: print find_max_double_real(4, dc1, dc2, dc3,
dc4)
PASS: gdb.base/varargs.exp: print find_max_long_double_real(4, ldc1, ldc2,
ldc3, ldc4)
Running ../../../src/gdb/testsuite/gdb.arch/e500-abi.exp ...
***************
*** 1425,1433 ****
PASS: gdb.base/callfuncs.exp: p t_double_int(99.0, 99)
PASS: gdb.base/callfuncs.exp: p t_int_double(99, 1.0)
PASS: gdb.base/callfuncs.exp: p t_int_double(99, 99.0)
! FAIL: gdb.base/callfuncs.exp: p t_float_complex_values(fc1, fc2)
PASS: gdb.base/callfuncs.exp: p t_float_complex_values(fc3, fc4)
! FAIL: gdb.base/callfuncs.exp: p t_float_complex_many_args(fc1, fc2, fc3,
fc4, fc1, fc2, fc3, fc4, fc1, fc2, fc3, fc4, fc1, fc2, fc3, fc4)
PASS: gdb.base/callfuncs.exp: p t_float_complex_many_args(fc1, fc1, fc1,
fc1, fc1, fc1, fc1, fc1, fc1, fc1, fc1, fc1, fc1, fc1, fc1, fc1)
PASS: gdb.base/callfuncs.exp: p t_double_complex_values(dc1, dc2)
PASS: gdb.base/callfuncs.exp: p t_double_complex_values(dc3, dc4)
--- 1425,1433 ----
PASS: gdb.base/callfuncs.exp: p t_double_int(99.0, 99)
PASS: gdb.base/callfuncs.exp: p t_int_double(99, 1.0)
PASS: gdb.base/callfuncs.exp: p t_int_double(99, 99.0)
! PASS: gdb.base/callfuncs.exp: p t_float_complex_values(fc1, fc2)
PASS: gdb.base/callfuncs.exp: p t_float_complex_values(fc3, fc4)
! PASS: gdb.base/callfuncs.exp: p t_float_complex_many_args(fc1, fc2, fc3,
fc4, fc1, fc2, fc3, fc4, fc1, fc2, fc3, fc4, fc1, fc2, fc3, fc4)
PASS: gdb.base/callfuncs.exp: p t_float_complex_many_args(fc1, fc1, fc1,
fc1, fc1, fc1, fc1, fc1, fc1, fc1, fc1, fc1, fc1, fc1, fc1, fc1)
PASS: gdb.base/callfuncs.exp: p t_double_complex_values(dc1, dc2)
PASS: gdb.base/callfuncs.exp: p t_double_complex_values(dc3, dc4)
***************
*** 1601,1607 ****
PASS: gdb.cp/koenig.exp: p rfoo()
PASS: gdb.cp/koenig.exp: p this->rfoo()
Running ../../../src/gdb/testsuite/gdb.base/call-signal-resume.exp ...
! gdb compile failed, /tmp/ccGWbOM2.o: In function `gen_signal':

/home/Pierre/gdbcvs/build-cross-src-mingw64/gdb/testsuite/../../../src/gdb/t
estsuite/gdb.base/call-signals.c:35: undefined reference to `kill'
collect2: error: ld returned 1 exit status
UNTESTED: gdb.base/call-signal-resume.exp: call-signal-resume.exp
--- 1601,1607 ----
PASS: gdb.cp/koenig.exp: p rfoo()
PASS: gdb.cp/koenig.exp: p this->rfoo()
Running ../../../src/gdb/testsuite/gdb.base/call-signal-resume.exp ...
! gdb compile failed, /tmp/cc2cnwEe.o: In function `gen_signal':

/home/Pierre/gdbcvs/build-cross-src-mingw64/gdb/testsuite/../../../src/gdb/t
estsuite/gdb.base/call-signals.c:35: undefined reference to `kill'
collect2: error: ld returned 1 exit status
UNTESTED: gdb.base/call-signal-resume.exp: call-signal-resume.exp
***************
*** 1778,1797 ****
PASS: gdb.base/call-sc.exp: set width 0
PASS: gdb.base/call-sc.exp: ptype; call-sc-tld (long double)
PASS: gdb.base/call-sc.exp: ptype foo; call-sc-tld long double
! FAIL: gdb.base/call-sc.exp: p/c fun(); call call-sc-tld
PASS: gdb.base/call-sc.exp: call Fun(foo); call call-sc-tld
PASS: gdb.base/call-sc.exp: p/c L; call call-sc-tld
! FAIL: gdb.base/call-sc.exp: advance to fun for return; return call-sc-tld
! FAIL: gdb.base/call-sc.exp: zed L for return; return call-sc-tld
! FAIL: gdb.base/call-sc.exp: return foo; return call-sc-tld
! FAIL: gdb.base/call-sc.exp: return foo; synchronize pc to main()
! FAIL: gdb.base/call-sc.exp: return foo; synchronize pc to main()
! PASS: gdb.base/call-sc.exp: value foo returned; return call-sc-tld
! FAIL: gdb.base/call-sc.exp: advance to fun for finish; return call-sc-tld
(the program exited)
! FAIL: gdb.base/call-sc.exp: zed L for finish; return call-sc-tld
! FAIL: gdb.base/call-sc.exp: finish foo; return call-sc-tld (the program is
no longer running)
! FAIL: gdb.base/call-sc.exp: value foo finished; return call-sc-tld
! PASS: gdb.base/call-sc.exp: return and finish use same convention; return
call-sc-tld
PASS: gdb.base/call-sc.exp: set print sevenbit-strings
PASS: gdb.base/call-sc.exp: set print address off
PASS: gdb.base/call-sc.exp: set width 0
--- 1778,1796 ----
PASS: gdb.base/call-sc.exp: set width 0
PASS: gdb.base/call-sc.exp: ptype; call-sc-tld (long double)
PASS: gdb.base/call-sc.exp: ptype foo; call-sc-tld long double
! PASS: gdb.base/call-sc.exp: p/c fun(); call call-sc-tld
PASS: gdb.base/call-sc.exp: call Fun(foo); call call-sc-tld
PASS: gdb.base/call-sc.exp: p/c L; call call-sc-tld
! PASS: gdb.base/call-sc.exp: advance to fun for return; return call-sc-tld
! PASS: gdb.base/call-sc.exp: zed L for return; return call-sc-tld
! PASS: gdb.base/call-sc.exp: return foo; return call-sc-tld
! PASS: gdb.base/call-sc.exp: return foo; synchronize pc to main()
! FAIL: gdb.base/call-sc.exp: value foo returned; return call-sc-tld
! PASS: gdb.base/call-sc.exp: advance to fun for finish; return call-sc-tld
! PASS: gdb.base/call-sc.exp: zed L for finish; return call-sc-tld
! PASS: gdb.base/call-sc.exp: finish foo; return call-sc-tld
! PASS: gdb.base/call-sc.exp: value foo finished; return call-sc-tld
! KFAIL: gdb.base/call-sc.exp: return and finish use same convention; return
call-sc-tld (PRMS: gdb/1444)
PASS: gdb.base/call-sc.exp: set print sevenbit-strings
PASS: gdb.base/call-sc.exp: set print address off
PASS: gdb.base/call-sc.exp: set width 0
***************
*** 2365,2373 ****
PASS: gdb.cp/bool.exp: print return_true()
PASS: gdb.cp/bool.exp: print return_false()
Running ../../../src/gdb/testsuite/gdb.base/gnu-ifunc.exp ...
! gdb compile failed, /tmp/ccIypBHh.s: Assembler messages:
! /tmp/ccIypBHh.s:3: Warning: .type pseudo-op used outside of .def/.endef
ignored.
! /tmp/ccIypBHh.s:3: Error: junk at end of line, first unrecognized
character is `g'
UNTESTED: gdb.base/gnu-ifunc.exp: Could not compile dynamic executable
././gdb.base/gnu-ifunc.
Running ../../../src/gdb/testsuite/gdb.base/wchar.exp ...
PASS: gdb.base/wchar.exp: print narrow
--- 2364,2372 ----
PASS: gdb.cp/bool.exp: print return_true()
PASS: gdb.cp/bool.exp: print return_false()
Running ../../../src/gdb/testsuite/gdb.base/gnu-ifunc.exp ...
! gdb compile failed, /tmp/ccrPsyHD.s: Assembler messages:
! /tmp/ccrPsyHD.s:3: Warning: .type pseudo-op used outside of .def/.endef
ignored.
! /tmp/ccrPsyHD.s:3: Error: junk at end of line, first unrecognized
character is `g'
UNTESTED: gdb.base/gnu-ifunc.exp: Could not compile dynamic executable
././gdb.base/gnu-ifunc.
Running ../../../src/gdb/testsuite/gdb.base/wchar.exp ...
PASS: gdb.base/wchar.exp: print narrow
***************
*** 2737,2744 ****
PASS: gdb.base/dfp-test.exp: Backtrace function with correct _Decimal64
arguments.
PASS: gdb.base/dfp-test.exp: Correct _Decimal64 return value from called
function.
PASS: gdb.base/dfp-test.exp: Call function with correct _Decimal128
arguments.
! FAIL: gdb.base/dfp-test.exp: Backtrace function with correct _Decimal128
arguments.
! FAIL: gdb.base/dfp-test.exp: Correct _Decimal128 return value from called
function.
PASS: gdb.base/dfp-test.exp: Call function with mixed decimal float
arguments TEST.
PASS: gdb.base/dfp-test.exp: Call function with mixed decimal float
arguments.
PASS: gdb.base/dfp-test.exp: Call function with many _Decimal32 arguments.
--- 2736,2743 ----
PASS: gdb.base/dfp-test.exp: Backtrace function with correct _Decimal64
arguments.
PASS: gdb.base/dfp-test.exp: Correct _Decimal64 return value from called
function.
PASS: gdb.base/dfp-test.exp: Call function with correct _Decimal128
arguments.
! PASS: gdb.base/dfp-test.exp: Backtrace function with correct _Decimal128
arguments.
! PASS: gdb.base/dfp-test.exp: Correct _Decimal128 return value from called
function.
PASS: gdb.base/dfp-test.exp: Call function with mixed decimal float
arguments TEST.
PASS: gdb.base/dfp-test.exp: Call function with mixed decimal float
arguments.
PASS: gdb.base/dfp-test.exp: Call function with many _Decimal32 arguments.
***************
*** 3166,3172 ****
PASS: gdb.base/call-rt-st.exp: finish out from loop_count (line 777)
PASS: gdb.base/call-rt-st.exp: print print_struct_rep(*struct1)
PASS: gdb.base/call-rt-st.exp: print print_one_large_struct(*list1)
! FAIL: gdb.base/call-rt-st.exp: print print_one_double(*d1)
PASS: gdb.base/call-rt-st.exp: print print_two_floats(*f3)
PASS: gdb.base/call-rt-st.exp: print print_bit_flags_char(*cflags)
PASS: gdb.base/call-rt-st.exp: print print_bit_flags_short(*sflags)
--- 3165,3171 ----
PASS: gdb.base/call-rt-st.exp: finish out from loop_count (line 777)
PASS: gdb.base/call-rt-st.exp: print print_struct_rep(*struct1)
PASS: gdb.base/call-rt-st.exp: print print_one_large_struct(*list1)
! PASS: gdb.base/call-rt-st.exp: print print_one_double(*d1)
PASS: gdb.base/call-rt-st.exp: print print_two_floats(*f3)
PASS: gdb.base/call-rt-st.exp: print print_bit_flags_char(*cflags)
PASS: gdb.base/call-rt-st.exp: print print_bit_flags_short(*sflags)
***************
*** 3821,3830 ****

=== gdb Summary ===

! # of expected passes 3437
! # of unexpected failures 160
# of expected failures 11
! # of known failures 28
# of unresolved testcases 3
# of untested testcases 13
# of unsupported tests 6
--- 3820,3829 ----

=== gdb Summary ===

! # of expected passes 3450
! # of unexpected failures 145
# of expected failures 11
! # of known failures 29
# of unresolved testcases 3
# of untested testcases 13
# of unsupported tests 6
> -----Message d'origine-----
> De : gdb-patches-owner@sourceware.org [mailto:gdb-patches-
> owner@sourceware.org] De la part de Joel Brobecker
> Envoyé : mardi 24 septembre 2013 18:33
> À : gdb-patches@sourceware.org
> Cc : Pierre Muller; Mark Kettenis
> Objet : Re: [RFC-v2] amd64-windows: Fix funcall with by-pointer arguments
>
> Hello,
>
> > Once again, I'm short of time to finish what I had hoped to be able
> > to complete. But I thought I'd send an update anyway. The first patch
> > is an update to the patch I wrote in January, rebased for today's HEAD.
> > This is what I have tested and intend to check in soon.
> >
> > Left to do on my end, is clean things up in amd64-tdep, because many
> > hooks in the tdep structure can now be removed, and replaced by
> > direct calls. But this is independent of your changes, so we can
> > both work at the same time.
>
> I have now checked in the patch re-implementing function call on
> amd64-windows. After this was done, I was able to revert all changes
> that added hooks in the gdbarch_tdep and in the amd64 sysV code
> to tweak it for amd64-windows, since the two implementations are
> now completely distinct.
>
> All patches were tested on x86_64-linux and x86_64-windows.
> And just in case, I tested them on x86-windows as well.
>
> Thanks,
> --
> Joel