From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22765 invoked by alias); 2 Nov 2009 22:44:19 -0000 Received: (qmail 22724 invoked by uid 22791); 2 Nov 2009 22:44:19 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00,SARE_MSGID_LONG40,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail-vw0-f182.google.com (HELO mail-vw0-f182.google.com) (209.85.212.182) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 02 Nov 2009 22:44:13 +0000 Received: by vws12 with SMTP id 12so1559505vws.12 for ; Mon, 02 Nov 2009 14:44:11 -0800 (PST) MIME-Version: 1.0 Received: by 10.220.123.2 with SMTP id n2mr5725214vcr.71.1257201851254; Mon, 02 Nov 2009 14:44:11 -0800 (PST) Date: Mon, 02 Nov 2009 22:44:00 -0000 Message-ID: Subject: GDB interactions with GCC From: Jean Christophe Beyler To: gdb@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 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/msg00011.txt.bz2 Dear all, I apologize if this is in the wrong mailing-list, I tried to determine if this was more a GCC question than a GDB and decided to start out with the GDB mailing list. I'm currently helping a port of GDB to a new architecture and I am having trouble understanding the interaction between GCC and GDB regarding how GDB keeps track of what's on the stack, how to backtrace, what variable is stored where. 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. I admit I've never worked in the GDB-GCC interaction so I'm really only starting to read documentation and understanding what does what. I'm normally only in the GCC port so I've never ventured this far out. Can anyone give me a simple break-down of what does what in this interaction? 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 ? - Does GCC need to output anything in particular to allow GDB to give the information of the backtrace for example? 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. - 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... - Are there other documents than the GDB-internals and Bennet's HowTo ? Thanks a lot, Jc