From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from sonic311-31.consmr.mail.ir2.yahoo.com (sonic311-31.consmr.mail.ir2.yahoo.com [77.238.176.163]) by sourceware.org (Postfix) with ESMTPS id 7C6E23840C25 for ; Fri, 29 May 2020 15:08:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 7C6E23840C25 X-YMail-OSG: YjcWtNkVM1kggrXvRJvCatnirO7LeEXaxmHHaDi92ThOk_hptoCg9ZLZJG9TBDi Ivu8xoWbQTzWrQJnXKC8kp22MksVqnYd3nxV2h4DPqhlRbwj7qFWMihDmTwDbkpYHOrX62aMd9AU c11SjDmyzEiyoOk_sre_cQI4wVgwOQa88lZ_KE2A97K0rF_24ZikNbhndzohlJvEdO34pm6S1SB1 JBEYNDgAYggJdLXK470NrNso644XpU_3q.YqdV9GGbvg.8M50dz2OnymHpasiGU6LuAv6tdfcO2. mvNFmGhHqcDeUSaD8SUgnwRXLdR3ljRrKMLwgZzyt2JCuiXp1JnT86OdrsYMf6KtQQVFWoLWB5nC 5XXklyMbgAotG0sRl1FZ0dkHmSTNY7KSUQYnKTYQ28_ktmkx9yAM.d5SK_zPGKCHPcVnrUrsHlY2 keQObh0U94mWUBle5Wgm.VUDoG80xxeHiIIV_JVEIx_xcphMm8VfN1sxDDKr.60k0nW3w3SU0OzJ 0NKLLVckymtBmK87oZYjV6XWTBjx8XDPwTNWSv_WmQhBf7ka4yYrbD5RxZcyK63qJiyvfRM6bHEN RMTQof2XR_Tmw6ayLL8nUoigCSQ1YwUi2qlPILLIQR1lM4vz6CV9J_M.YBQ3Db4OuMrSv1XP2cvB nDBx7ZCBv9GhG4C4NHoxnbE5xMk4mVzsEkn2leURzwAQWCifrSsm7yo6v4pQ7vPA0WaWX46NLlSq 8poYVN0HrIlVA.koAHo31J_P_1d4n8guDPkE1WtfO_bw3oM9.65zRlxi.ejfbQn4CFGAqMnW_oqW 7N2VZYwmZ17YCj4kDfkzEzGfao8ebCjN1H1Aw8VB8.i87aX2SNL7_8ajibGFhFleZ1fAxGYnGTZb uwNSUnQ19Ysda7UvbQyC9vBJ0SQ4IMOZ4134RASE_zXToKq__mRMuIRkKLx9c9kwVGh2bH_rf15W XzQPJE6ay1kkGRJg7oD7b9bLvD4z6Rl7gGA5ztzXwFDDUerjehWMzh.QWe1X9R4hP_3bQPd.cXCZ jJXUjGrl6KiDxanQnRoU73hgRfiyRVPXnlRalNZANpdcSX9iC1dhObnHcZ7wyh9OuNwUprNsbmct itAoH9FNMX1RHhYLxeO4_LYc1z_r9LDmVd7gbcHrIjxfZsmDeGUwT2Q2l8UQlNe1lSXMb5D2FpyD M8yKbmMqLMalHSGixXnJEUphp4YBiUtFtye29rPH1Ndkv2F3miR89i9Z1bq14GFNvlvJLEkAjZ7l CZ.9b0fC2wrhXNEckCAk7lhRj8gGkCMQwNXRsW4tueK8co20k4D_GL7F413zfa43wKiQbf2hqXuC UDTFUQi8QMXYT14plq6wSeRnEuO.nY0XsPOBlqwNA1wDmaBhhmTmWajaGdnaLFOeOBsWAPnMl.uF CSgmoljoo3UHDYZx1osLaTGA- Received: from sonic.gate.mail.ne1.yahoo.com by sonic311.consmr.mail.ir2.yahoo.com with HTTP; Fri, 29 May 2020 15:08:34 +0000 Received: by smtp422.mail.ir2.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID 1046120115d170935a2d82f1b1c0585f; Fri, 29 May 2020 15:08:33 +0000 (UTC) From: Hannes Domani To: gdb-patches@sourceware.org Subject: [PATCH v2 1/2] Fix function argument and return value locations Date: Fri, 29 May 2020 17:07:59 +0200 Message-Id: <20200529150800.2013-1-ssbssa@yahoo.de> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Antivirus: Avast (VPS 200528-0, 05/28/2020), Outbound message X-Antivirus-Status: Clean References: <20200529150800.2013-1-ssbssa.ref@yahoo.de> X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SCC_5_SHORT_WORD_LINES, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Fri, 29 May 2020 15:08:37 -0000 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-05-29 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-05-29 Hannes Domani * gdb.base/call-sc.c: Fix return struct on stack test case. * gdb.base/call-sc.exp: Likewise. --- v2: - TYPE_CODE_COMPLEX is actually passed via integer register, not XMM register. --- gdb/amd64-windows-tdep.c | 21 +++++++++++++++++---- gdb/testsuite/gdb.base/call-sc.c | 6 +++++- gdb/testsuite/gdb.base/call-sc.exp | 13 +++++++++++++ 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/gdb/amd64-windows-tdep.c b/gdb/amd64-windows-tdep.c index 487dfd45fc..e83d76257f 100644 --- a/gdb/amd64-windows-tdep.c +++ b/gdb/amd64-windows-tdep.c @@ -60,6 +60,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 @@ -299,17 +300,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; } diff --git a/gdb/testsuite/gdb.base/call-sc.c b/gdb/testsuite/gdb.base/call-sc.c index ba80576ac3..eb140cd9cf 100644 --- a/gdb/testsuite/gdb.base/call-sc.c +++ b/gdb/testsuite/gdb.base/call-sc.c @@ -35,6 +35,7 @@ typedef t T; #endif T foo = '1', L; +T init = '9'; T fun() { @@ -55,7 +56,10 @@ int main() { int i; - Fun(foo); + /* Use a different initial value then is later used in the + "value foo returned" test, so in case the struct is then returned + on the stack, it doesn't have the correct value by accident. */ + Fun(init); /* An infinite loop that first clears all the variables and then calls the function. This "hack" is to make re-testing easier - diff --git a/gdb/testsuite/gdb.base/call-sc.exp b/gdb/testsuite/gdb.base/call-sc.exp index 719000435a..9697c5ac24 100644 --- a/gdb/testsuite/gdb.base/call-sc.exp +++ b/gdb/testsuite/gdb.base/call-sc.exp @@ -291,6 +291,19 @@ proc test_scalar_returns { } { fail "${test}" } } + -re " = 57 .*${gdb_prompt} $" { + if $return_value_unknown { + # The struct return case. + # The return value is stored on the stack, and since GDB + # didn't override it, it still has value that was stored + # there in the earlier Foo(init) call. + pass "${test}" + } else { + # This contradicts the above claim that GDB knew + # the location of the return-value. + fail "${test}" + } + } -re ".*${gdb_prompt} $" { if $return_value_unimplemented { # What a suprize. The architecture hasn't implemented -- 2.26.2