From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4140 invoked by alias); 27 Jun 2003 05:41:56 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 4133 invoked from network); 27 Jun 2003 05:41:55 -0000 Received: from unknown (HELO Cantor.suse.de) (213.95.15.193) by sources.redhat.com with SMTP; 27 Jun 2003 05:41:55 -0000 Received: from Hermes.suse.de (Hermes.suse.de [213.95.15.136]) by Cantor.suse.de (Postfix) with ESMTP id E87391445E for ; Fri, 27 Jun 2003 07:41:54 +0200 (MEST) Received: from aj by arthur.inka.de with local (Exim 4.12) id 19Vlzc-0005Fm-00 for gdb-patches@sources.redhat.com; Fri, 27 Jun 2003 07:41:52 +0200 To: gdb-patches@sources.redhat.com Subject: Fix passing of arguments on x86-64 From: Andreas Jaeger Date: Fri, 27 Jun 2003 05:41:00 -0000 Message-ID: User-Agent: Gnus/5.1003 (Gnus v5.10.3) XEmacs/21.4 (Portable Code, linux) MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" X-SW-Source: 2003-06/txt/msg00807.txt.bz2 --=-=-= Content-Transfer-Encoding: quoted-printable Content-length: 8061 call-ar-st was failing to "print print_small_structs" since the stack was not properly aligned and therefore the called function died in glibc with a segv. The problem is that entries have to be aligned by 8 byte but the bottom of the stack by 16 byte. I fixed also another failure where my last patch set %rax to all floating points args where it should have been only the floating points args passed in SSE registers. The appended patch fixes all failures in call-ar-st and brings down the testsuite failures: =3D=3D=3D gdb Summary =3D=3D=3D # of expected passes 8984 # of unexpected failures 72 # of unexpected successes 4 # of expected failures 46 # of known failures 23 # of unresolved testcases 3 # of untested testcases 6 # of unsupported tests 1 The remaining failures are: FAIL: gdb.base/callfuncs.exp: backtrace at nested call level 2 FAIL: gdb.base/callfuncs.exp: backtrace at nested call level 3 FAIL: gdb.base/callfuncs.exp: backtrace at nested call level 4 FAIL: gdb.base/callfuncs.exp: backtrace after finish from nested call level= 4 FAIL: gdb.base/callfuncs.exp: Finish from nested call level 3 FAIL: gdb.base/callfuncs.exp: backtrace after finish from nested call level= 3 FAIL: gdb.base/callfuncs.exp: Finish from nested call level 2 FAIL: gdb.base/callfuncs.exp: backtrace after finish from nested call level= 2 FAIL: gdb.base/callfuncs.exp: Finish from nested call level 1 FAIL: gdb.base/restore.exp: caller1 called callee1; variable l1 restored to= 32492 FAIL: gdb.base/restore.exp: caller2 called callee1; variable l2 restored to= 32493 FAIL: gdb.base/restore.exp: caller3 called callee1; variable l3 restored to= 32494 FAIL: gdb.base/restore.exp: caller4 called callee1; variable l4 restored to= 32495 FAIL: gdb.base/restore.exp: caller5 called callee1; variable l5 restored to= 32496 FAIL: gdb.base/selftest.exp: step into xmalloc call FAIL: gdb.base/shlib-call.exp: step into mainshr1 FAIL: gdb.base/signals.exp: continue to func1 (probably kernel bug) FAIL: gdb.base/signals.exp: continue to handler (the program exited) FAIL: gdb.base/store.exp: up print old r - char FAIL: gdb.base/store.exp: up print old r - short FAIL: gdb.base/store.exp: up print old r - int FAIL: gdb.base/store.exp: up print old r - long FAIL: gdb.base/store.exp: up print old r - longest FAIL: gdb.base/store.exp: up print old r - float FAIL: gdb.base/store.exp: up print old r - double FAIL: gdb.base/store.exp: up print old r - doublest FAIL: gdb.base/structs2.exp: structs2 continue1 (PRMS 13536) FAIL: gdb.base/structs2.exp: structs2 continue2 (PRMS 13536) FAIL: gdb.c++/templates.exp: ptype T5 FAIL: gdb.c++/templates.exp: ptype t5i FAIL: gdb.c++/templates.exp: constructor breakpoint (timeout) FAIL: gdb.c++/templates.exp: (timeout) print fint FAIL: gdb.c++/templates.exp: (timeout) print fvpchar FAIL: gdb.c++/templates.exp: (timeout) ptype Foo FAIL: gdb.c++/templates.exp: (timeout) ptype fint FAIL: gdb.c++/templates.exp: (timeout) ptype fchar FAIL: gdb.c++/templates.exp: (timeout) ptype fvpchar FAIL: gdb.c++/templates.exp: (timeout) print Foo::foo FAIL: gdb.c++/templates.exp: (timeout) print Foo::foo FAIL: gdb.c++/templates.exp: (timeout) ptype Bar FAIL: gdb.c++/templates.exp: (timeout) ptype bint FAIL: gdb.c++/templates.exp: (timeout) ptype bint2 FAIL: gdb.c++/templates.exp: (timeout) ptype Baz FAIL: gdb.c++/templates.exp: (timeout) ptype bazint FAIL: gdb.c++/templates.exp: (timeout) ptype bazint2 FAIL: gdb.c++/templates.exp: (timeout) ptype Qux FAIL: gdb.c++/templates.exp: (timeout) ptype quxint FAIL: gdb.c++/templates.exp: (timeout) ptype Spec FAIL: gdb.c++/templates.exp: (timeout) ptype siip FAIL: gdb.c++/templates.exp: (timeout) ptype Garply FAIL: gdb.c++/templates.exp: (timeout) ptype Garply > FAIL: gdb.c++/templates.exp: print Garply >::garply (timeout) FAIL: gdb.c++/templates.exp: break Garply >::garply (timeout) FAIL: gdb.java/jmisc.exp: setting breakpoint at jmisc.main FAIL: gdb.java/jmisc.exp: ptype jmisc FAIL: gdb.java/jmisc.exp: p args FAIL: gdb.java/jmisc.exp: p *args FAIL: gdb.java/jmisc1.exp: ptype jmisc FAIL: gdb.java/jmisc2.exp: ptype jmisc FAIL: gdb.mi/mi-var-display.exp: get children local variable weird FAIL: gdb.mi/mi1-var-display.exp: get children local variable weird FAIL: gdb.objc/basicclass.exp: Call an Objective-C method with no arguments FAIL: gdb.objc/basicclass.exp: Call an Objective-C method with one argument FAIL: gdb.objc/basicclass.exp: Use of the print-object command FAIL: gdb.objc/basicclass.exp: Use of the po (print-object) command FAIL: gdb.threads/linux-dp.exp: philosopher is distinct: 1 FAIL: gdb.threads/linux-dp.exp: philosopher is distinct: 3 FAIL: gdb.threads/linux-dp.exp: philosopher is distinct: 4 FAIL: gdb.threads/linux-dp.exp: philosopher is distinct: 7 FAIL: gdb.threads/print-threads.exp: Running threads (slow with kill breakp= oint) (unknown output) FAIL: gdb.threads/pthreads.exp: check backtrace from main thread FAIL: gdb.threads/pthreads.exp: apply backtrace command to all three threads So, this looks like push_arguments is working now correctly. Thanks Elena et. al for writing such good testcases! Ok to commit for 6.0 and mainline? Andreas 2003-06-27 Andreas Jaeger * x86-64-tdep.c (x86_64_push_arguments): Align stack to 16-byte before the call. Set %rax only to number of SSE registers used. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Index: gdb/x86-64-tdep.c --- gdb/x86-64-tdep.c 26 Jun 2003 17:08:10 -0000 1.80 +++ gdb/x86-64-tdep.c 27 Jun 2003 05:34:12 -0000 @@ -597,13 +597,14 @@ x86_64_push_arguments (struct regcache * { int intreg =3D 0; int ssereg =3D 0; - /* For varargs functions we have to pass the total number of SSE argumen= ts - in %rax. So, let's count this number. */ + /* For varargs functions we have to pass the total number of SSE + registers used in %rax. So, let's count this number. */ int total_sse_args =3D 0; /* Once an SSE/int argument is passed on the stack, all subsequent arguments are passed there. */ int sse_stack =3D 0; int int_stack =3D 0; + unsigned total_sp; int i; char buf[8]; static int int_parameter_registers[INT_REGS] =3D @@ -644,7 +645,8 @@ x86_64_push_arguments (struct regcache * int_stack =3D 1; if (ssereg / 2 + needed_sseregs > SSE_REGS) sse_stack =3D 1; - total_sse_args +=3D needed_sseregs; + if (!sse_stack) + total_sse_args +=3D needed_sseregs; =20 for (j =3D 0; j < n; j++) { @@ -720,13 +722,29 @@ x86_64_push_arguments (struct regcache * } } =20 + /* We have to make sure that the stack is 16-byte aligned after the + setup. Let's calculate size of arguments first, align stack and + then fill in the arguments. */ + total_sp =3D 0; + for (i =3D 0; i < stack_values_count; i++) + { + struct value *arg =3D args[stack_values[i]]; + int len =3D TYPE_LENGTH (VALUE_ENCLOSING_TYPE (arg)); + total_sp +=3D (len + 7) & ~7; + } + /* total_sp is now a multiple of 8, if it is not a multiple of 16, + change the stack pointer so that it will be afterwards correctly + aligned. */ + if (total_sp & 15) + sp -=3D 8; +=20=20=20=20 /* Push any remaining arguments onto the stack. */ while (--stack_values_count >=3D 0) { struct value *arg =3D args[stack_values[stack_values_count]]; int len =3D TYPE_LENGTH (VALUE_ENCLOSING_TYPE (arg)); =20 - /* Make sure the stack stays eightbyte-aligned. */ + /* Make sure the stack is 8-byte-aligned. */ sp -=3D (len + 7) & ~7; write_memory (sp, VALUE_CONTENTS_ALL (arg), len); } --=20 Andreas Jaeger, SuSE Linux AG, aj@suse.de, http://www.suse.de/~aj GPG fingerprint =3D 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126 --=-=-= Content-Type: application/pgp-signature Content-length: 197 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2-rc1-SuSE (GNU/Linux) iD8DBQA++9kfOJpWPMJyoSYRArB4AJ0do8lo+tUQanEl5/NTqsvGszImWQCfQg1S LBuPoptjsagOEQSbXLPdB3Q= =/2pS -----END PGP SIGNATURE----- --=-=-=--