From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17389 invoked by alias); 22 May 2007 23:56:20 -0000 Received: (qmail 17381 invoked by uid 22791); 22 May 2007 23:56:20 -0000 X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 22 May 2007 23:56:18 +0000 Received: (qmail 13567 invoked from network); 22 May 2007 23:56:16 -0000 Received: from unknown (HELO localhost) (jimb@127.0.0.2) by mail.codesourcery.com with ESMTPA; 22 May 2007 23:56:16 -0000 To: Maxim Grigoriev Cc: gdb@sourceware.org, Marc Gauthier , Pete MacLiesh , Ross Morley Subject: Re: Understanding GDB frames References: <46521C04.7040405@hq.tensilica.com> <465341B8.9060208@hq.tensilica.com> From: Jim Blandy Date: Tue, 22 May 2007 23:56:00 -0000 In-Reply-To: <465341B8.9060208@hq.tensilica.com> (Maxim Grigoriev's message of "Tue, 22 May 2007 12:17:12 -0700") Message-ID: User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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: 2007-05/txt/msg00125.txt.bz2 Maxim Grigoriev writes: >> It's worth pointing out that the 'PC' in a frame ID isn't the current >> PC within the function. It's always the PC of the function's entry >> point, so that stepping within a function doesn't cause the frame ID >> to change. Usually it's a PC value returned by 'frame_func_unwind', >> which takes care of calling get_pc_function_start for you. > > We've been using a function return address instead of the PC of the > function's entry, and it works just fine. Hmm. Consider: void foo (void) { } void bar (void) { } main () { int i; for (i = 0; i < 2; i++) { void (*f) (void) = i ? foo : bar; f (); } } So, main will call bar first, then foo. Both calls will have identical incoming sp's, and identical return addresses. Using the callee's entry point is more direct; there's less opportunity for things to go wrong. And the rest of GDB is already working to cover up the shortcomings of that approach. :) > I think distinguishing frames can be improved by using the third > argument of frame_id, which is a "special address". Most of the > implementations don't use it. What would you put there?