From cd096ec85fb3aedf5cf9c3c116a7deab2ee0d388 Mon Sep 17 00:00:00 2001 From: Hannes Domani Date: Tue, 5 May 2020 14:31:26 +0200 Subject: Fix function argument and return value locations Fixes these testsuite fails on Windows: FAIL: gdb.base/callfuncs.exp: p t_float_complex_values(fc1, fc2) 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) FAIL: gdb.base/callfuncs.exp: noproto: p t_float_complex_values(fc1, fc2) FAIL: gdb.base/callfuncs.exp: noproto: p t_float_complex_many_args(fc1, fc2, fc3, fc4, fc1, fc2, fc3, fc4, fc1, fc2, fc3, fc4, fc1, fc2, fc3, fc4) FAIL: gdb.base/call-sc.exp: p/c fun(); 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() for 'call-sc-tld' FAIL: gdb.base/call-sc.exp: return foo; synchronize pc to main() for 'call-sc-tld' FAIL: gdb.base/call-sc.exp: advance to fun for finish; return call-sc-tld 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 For function arguments (callfuncs.exp), only TYPE_CODE_COMPLEX was missing in the types passed via integer registers. For return values, there were a lot more issues: - TYPE_CODE_DECFLOAT is NOT returned via XMM0. - long double is NOT returned via XMM0. - but __int128 IS returned via XMM0. - the comments for TYPE_CODE_FLT state that __m128, __m128i and __m128d are returned by XMM0, and this is correct, but it doesn't actually check for them, because they are TYPE_CODE_ARRAY with TYPE_VECTOR So I had to add TYPE_CODE_DECFLOAT to the arguments passed via XMM register, but I had to remove it from the values returned via XMM0 register. gdb/ChangeLog: 2020-10-05 Hannes Domani * amd64-windows-tdep.c (amd64_windows_passed_by_integer_register): Add TYPE_CODE_COMPLEX. (amd64_windows_return_value): Fix types returned via XMM0. gdb/testsuite/ChangeLog: 2020-10-05 Hannes Domani * gdb.base/call-sc.c: Fix return struct on stack test case. * gdb.base/call-sc.exp: Likewise. --- gdb/amd64-windows-tdep.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'gdb/amd64-windows-tdep.c') diff --git a/gdb/amd64-windows-tdep.c b/gdb/amd64-windows-tdep.c index e427c20..320388b 100644 --- a/gdb/amd64-windows-tdep.c +++ b/gdb/amd64-windows-tdep.c @@ -125,6 +125,7 @@ amd64_windows_passed_by_integer_register (struct type *type) case TYPE_CODE_RVALUE_REF: case TYPE_CODE_STRUCT: case TYPE_CODE_UNION: + case TYPE_CODE_COMPLEX: return (TYPE_LENGTH (type) == 1 || TYPE_LENGTH (type) == 2 || TYPE_LENGTH (type) == 4 @@ -364,17 +365,29 @@ amd64_windows_return_value (struct gdbarch *gdbarch, struct value *function, switch (type->code ()) { case TYPE_CODE_FLT: - case TYPE_CODE_DECFLOAT: - /* __m128, __m128i, __m128d, floats, and doubles are returned - via XMM0. */ - if (len == 4 || len == 8 || len == 16) + /* floats, and doubles are returned via XMM0. */ + if (len == 4 || len == 8) regnum = AMD64_XMM0_REGNUM; break; + case TYPE_CODE_ARRAY: + /* __m128, __m128i and __m128d are returned via XMM0. */ + if (TYPE_VECTOR (type) && len == 16) + { + enum type_code code = TYPE_TARGET_TYPE (type)->code (); + if (code == TYPE_CODE_INT || code == TYPE_CODE_FLT) + { + regnum = AMD64_XMM0_REGNUM; + break; + } + } + /* fall through */ default: /* All other values that are 1, 2, 4 or 8 bytes long are returned via RAX. */ if (len == 1 || len == 2 || len == 4 || len == 8) regnum = AMD64_RAX_REGNUM; + else if (len == 16 && type->code () == TYPE_CODE_INT) + regnum = AMD64_XMM0_REGNUM; break; } -- cgit v1.1