From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14998 invoked by alias); 6 Sep 2003 22:06:21 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 14986 invoked from network); 6 Sep 2003 22:06:19 -0000 Received: from unknown (HELO walton.kettenis.dyndns.org) (213.93.115.144) by sources.redhat.com with SMTP; 6 Sep 2003 22:06:19 -0000 Received: from elgar.kettenis.dyndns.org (elgar.kettenis.dyndns.org [192.168.0.2]) by walton.kettenis.dyndns.org (8.12.6p2/8.12.5) with ESMTP id h86M635c000466; Sun, 7 Sep 2003 00:06:03 +0200 (CEST) (envelope-from kettenis@elgar.kettenis.dyndns.org) Received: from elgar.kettenis.dyndns.org (localhost [127.0.0.1]) by elgar.kettenis.dyndns.org (8.12.6p2/8.12.6) with ESMTP id h86M63Uf012599; Sun, 7 Sep 2003 00:06:03 +0200 (CEST) (envelope-from kettenis@elgar.kettenis.dyndns.org) Received: (from kettenis@localhost) by elgar.kettenis.dyndns.org (8.12.6p2/8.12.6/Submit) id h86M62no012596; Sun, 7 Sep 2003 00:06:02 +0200 (CEST) Date: Sat, 06 Sep 2003 22:06:00 -0000 Message-Id: <200309062206.h86M62no012596@elgar.kettenis.dyndns.org> From: Mark Kettenis To: gdb@sources.redhat.com CC: ac131313@redhat.com, dan@debian.org Subject: REG_STRUCT_HAS_ADDR X-SW-Source: 2003-09/txt/msg00090.txt.bz2 By defining REG_STRUCT_HAS_ADDR, a target can indicate that structure and union arguments are passed by reference instead of by value. While working on the SPARC target, I read the following comment in infcall.c:call_function_by_hand: if (REG_STRUCT_HAS_ADDR_P ()) { ... if (STACK_ALIGN_P ()) /* MVS 11/22/96: I think at least some of this stack_align code is really broken. Better to let PUSH_ARGUMENTS adjust the stack in a target-defined manner. */ aligned_len = STACK_ALIGN (len); else aligned_len = len; I totally agree with Michael here, so I decided that the new SPARC stuff shouldn't define REG_STRUCT_HAS_ADDR, and implement the whole thing in its PUSH_DUMMY_CALL function. Unfortunately this breaks debugging with stabs, since stabsread.c uses the same REG_STRUCT_HAS_ADDR to see if a function argument is passed by value or by reference. I think we really want to get rid of the broken code in infcall.c in the long run. Therefore I looked for a way to disable it for "modern" targets, i.e. targets that define PUSH_DUMMY_CALL as opposed to the old PUSH_DUMMY_FRAME & friends. Looking at the code I found that the following targets (besides SPARC) are using REG_STRUCT_HAS_ADDR: * MIPS EABI (32-bit and 64-bit) * CRIS * HP PA * MN10300 (MCore defines REG_STRUCT_HAS_ADDR, but always returns 0, soo it doesn't actually use the feature.) Of these targets, only MIPS EABI uses the new PUSH_DUMMY_CALL. Looking at mips_eabi_push_dummy_call, it seems as if it already handles tries to pass the larger structures by reference. That would mean that it is indeed possible to change the if (REG_STRUCT_HAS_ADDR_P ()) into if (REG_STRUCT_HAS_ADDR_P () && !gdbarch_push_dummy_call_p (current_gdbarch)) and be done with it. I'm a little afraid however, that the MIPS code in mips_eabi_push_dummy_call has never been tested, since in the current situation it's dead code. I don't have access to a MIPS machine myself, is there anyone who could test the attached patch for me on MIPS EABI? Look for any regressions in gdb.base/call-ar-st.exp, in particular: FAIL: gdb.base/call-ar-st.exp: step into print_long_arg_list Thanks, Mark Index: infcall.c =================================================================== RCS file: /cvs/src/src/gdb/infcall.c,v retrieving revision 1.24 diff -u -p -r1.24 infcall.c --- infcall.c 28 Aug 2003 02:53:08 -0000 1.24 +++ infcall.c 6 Sep 2003 22:02:21 -0000 @@ -661,7 +661,8 @@ You must use a pointer to function type } } - if (REG_STRUCT_HAS_ADDR_P ()) + if (REG_STRUCT_HAS_ADDR_P () + && !gdbarch_push_dummy_call_p (current_gdbcarch)) { int i; /* This is a machine like the sparc, where we may need to pass a