From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32505 invoked by alias); 11 Jul 2005 14:44:33 -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 32459 invoked by uid 22791); 11 Jul 2005 14:44:28 -0000 Received: from fra-del-04.spheriq.net (HELO fra-del-04.spheriq.net) (195.46.51.100) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Mon, 11 Jul 2005 14:44:28 +0000 Received: from fra-out-01.spheriq.net (fra-out-01.spheriq.net [195.46.51.129]) by fra-del-04.spheriq.net with ESMTP id j6BEiQHJ000653 for ; Mon, 11 Jul 2005 14:44:26 GMT Received: from fra-cus-02.spheriq.net (fra-cus-02.spheriq.net [195.46.51.38]) by fra-out-01.spheriq.net with ESMTP id j6BEi7GB008866 for ; Mon, 11 Jul 2005 14:44:11 GMT Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by fra-cus-02.spheriq.net with ESMTP id j6BEi5ku022958 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=OK) for ; Mon, 11 Jul 2005 14:44:06 GMT Received: from zeta.dmz-eu.st.com (ns2.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 3AE79DA4C for ; Mon, 11 Jul 2005 14:43:58 +0000 (GMT) Received: by zeta.dmz-eu.st.com (STMicroelectronics, from userid 60012) id A4E824750B; Mon, 11 Jul 2005 14:45:57 +0000 (GMT) Received: from zeta.dmz-eu.st.com (localhost [127.0.0.1]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 5508C75969 for ; Mon, 11 Jul 2005 14:45:57 +0000 (UTC) Received: from mail2.gnb.st.com (mail2.gnb.st.com [164.129.119.59]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id C50A447510 for ; Mon, 11 Jul 2005 14:45:56 +0000 (GMT) Received: from st.com (pcx0003.gnb.st.com [164.129.118.67]) by mail2.gnb.st.com (MOS 3.4.4-GR) with ESMTP id BNP00887 (AUTH lyon); Mon, 11 Jul 2005 16:43:55 +0200 (CEST) Message-ID: <42D285AB.9E36C062@st.com> Date: Mon, 11 Jul 2005 14:44:00 -0000 From: Christophe LYON MIME-Version: 1.0 To: gdb@sources.redhat.com Subject: dwarf2 frame unwinder assumptions on SP Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-O-General-Status: No X-O-Spam1-Status: Not Scanned X-O-Spam2-Status: Not Scanned X-O-URL-Status: Not Scanned X-O-Virus1-Status: No X-O-Virus2-Status: Not Scanned X-O-Virus3-Status: No X-O-Virus4-Status: No X-O-Virus5-Status: Not Scanned X-O-Image-Status: Not Scanned X-O-Attach-Status: Not Scanned X-SpheriQ-Ver: 2.2.2 X-SW-Source: 2005-07/txt/msg00113.txt.bz2 Hi all, I am working on the connection of the dwarf2 frame unwinder to our GDB port, and I have trouble with some assumptions made by GDB about SP. Currently, in my x-tdep.c I have: set_gdbarch_unwind_pc(gdbarch, x_unwind_pc); frame_unwind_append_sniffer (gdbarch, dwarf2_frame_sniffer); This improves the backtracing capability (especially in presence of alloca()), but exhibits many regressions when displaying the parameters of functions called. (eg gdb.base/funcargs) I have isolated the reason of failure, but don't know how to solve it cleanly. In the debug_info section, the call6b() function has: DW_AT_frame_base DW_OP_bregx12+48 (register 12 is our SP) and the 1st parameter of call6b() has: DW_AT_location DW_OP_fbreg -16 The frame_base described here is the value of SP upon entry in call6b(). In the debug_frame section, in CIE, we have: DW_CFA_def_cfa: r12 ofs 16 which means that our CFA is SP + 16 upon function entry. Now, when 'backtrace' looks for the value of the 1st parameter, it needs to recompute the value of SP. The default for this is provided by frame2-frame.c:dwarf2_frame_default_init_reg() to: ... else if (regnum == SP_REGNUM) reg->how = DWARF2_FRAME_REG_CFA; which leads to my trouble. The comes from an assumption about the GCC behaviour and the Dwarf spec saying that "Typically, the CFA is defined to be the value of the stack pointer at the call site in the previous frame" which does not hold for our target/ABI (the compiler is Open64). I would like to express that SP is CFA-16, but I don't see how to achieve that. Indeed, in dwarf2-frame.c:dwarf2_frame_prev_register(), no code would enable the beheviour I want. I thought of using DWARF2_FRAME_REG_SAVED_EXP but it involves an extra indirection. The possibilities I can think of are as follows: 1 - add a case like DWARF2_FRAME_REG_CFA_OFFSET in dwarf2-frame.[ch] to do what I need 2 - copy a large part of the generic support from dwarf2-frame.c into x-tdep.c to have a customized x_frame_prev_register() 3 - have a specific dwarf2_sniffer / frame_prev_register that calls the generic code, except for SP (still not clear how to do that cleanly, as most of the functions I need to call are 'static') 4 - modify the compiler so that DW_AT_frame_base takes into account the missing 16 bytes and thus have frame_base == CFA but frame_base != SP. I fear this will lead to trouble further.... 5 - modify the compiler / libdwarf so that it makes use of the Dwarf3 operators such as DW_CFA_offset_extended_sf which allow for signed offsets (which, basically is the reason for having CFA != SP: in our ABI, the caller reserves 16 bytes on the stack for callee usage) I hope my description is clear enough so that someone can help me. Thanks, Christophe.