From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22466 invoked by alias); 2 Nov 2009 23:16:39 -0000 Received: (qmail 22456 invoked by uid 22791); 2 Nov 2009 23:16:38 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from mail3.caviumnetworks.com (HELO mail3.caviumnetworks.com) (12.108.191.235) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 02 Nov 2009 23:16:34 +0000 Received: from caexch01.caveonetworks.com (Not Verified[192.168.16.9]) by mail3.caviumnetworks.com with MailMarshal (v6,5,4,7535) id ; Mon, 02 Nov 2009 15:16:27 -0800 Received: from caexch01.caveonetworks.com ([192.168.16.9]) by caexch01.caveonetworks.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 2 Nov 2009 15:16:06 -0800 Received: from dd1.caveonetworks.com ([12.108.191.236]) by caexch01.caveonetworks.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Mon, 2 Nov 2009 15:16:06 -0800 Message-ID: <4AEF6834.1080208@caviumnetworks.com> Date: Mon, 02 Nov 2009 23:16:00 -0000 From: David Daney User-Agent: Thunderbird 2.0.0.21 (X11/20090320) MIME-Version: 1.0 To: Jean Christophe Beyler CC: gdb@sourceware.org Subject: Re: GDB interactions with GCC References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2009-11/txt/msg00012.txt.bz2 Jean Christophe Beyler wrote: [...] > > For example, on my architecture, the return address is passed in one > register that the function can push on the stack if it's necessary (if > a call happens) but not if it's a leaf function. The local variables > are also sent via registers and therefore, potentially are never > stored on the stack. This is similar to MIPS which is supported by gdb. [...] > And if someone can answer these questions: > > - It seems to me that GCC outputs debug information that helps GDB > follow the course of the program: > - With this information, is GDB able to follow where the local > variables are kept (register or stack) depending on what the program > is doing ? Usually. > - Does GCC need to output anything in particular to allow GDB to > give the information of the backtrace for example? > Yes. > In other words: > > - Does the ABI need to store the stack pointer for each frame in order > for GDB to give all the backtrace, variable information? Or does GDB > keep track of this independantly of the ABI. For some (many) archectures, the compiler emits debug information describing the information needed to generate a backtrace. Look at .debug_frame sections in DWARF for example. Given a lack of frame meta-data, you can have target specific code that does ad hoc stack and code examination to try to generate a backtrace. > > - Does GDB require that the ABI store arguments at some point on the > stack in order to provide information about a function calls > arguments? I would assume not because otherwise register-based ABIs > would have to redundantly copy things on the stack for GDB use... > The debug data emitted by the compiler should allow gdb to track variable locations. For most Linux systems this is specified by DWARF. That is an simplified answer based on my limited knowledge of the subject. David Daney