From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9619 invoked by alias); 27 Jun 2009 20:59:11 -0000 Received: (qmail 9610 invoked by uid 22791); 27 Jun 2009 20:59:11 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from smtp-outbound-1.vmware.com (HELO smtp-outbound-1.vmware.com) (65.115.85.69) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 27 Jun 2009 20:59:04 +0000 Received: from mailhost4.vmware.com (mailhost4.vmware.com [10.16.67.124]) by smtp-outbound-1.vmware.com (Postfix) with ESMTP id 6BF583E011; Sat, 27 Jun 2009 13:59:01 -0700 (PDT) Received: from [10.20.94.141] (msnyder-server.eng.vmware.com [10.20.94.141]) by mailhost4.vmware.com (Postfix) with ESMTP id 60BCBC9CAF; Sat, 27 Jun 2009 13:59:01 -0700 (PDT) Message-ID: <4A4687B2.2060907@vmware.com> Date: Sat, 27 Jun 2009 20:59:00 -0000 From: Michael Snyder User-Agent: Thunderbird 1.5.0.12 (X11/20080411) MIME-Version: 1.0 To: Pedro Alves CC: "gdb-patches@sourceware.org" , Hui Zhu , drow@false.org Subject: Re: [RFA] Patch to fix reverse return from subroutine error References: <4A466BAE.2010305@vmware.com> <200906272049.36692.pedro@codesourcery.com> In-Reply-To: <200906272049.36692.pedro@codesourcery.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2009-06/txt/msg00774.txt.bz2 Pedro Alves wrote: >> - || execution_direction == EXEC_REVERSE)) >> + || (execution_direction == EXEC_REVERSE >> + && ecs->event_thread->step_frame_id.stack_addr_p >> + && get_frame_id (get_current_frame ()).stack_addr_p >> + && !gdbarch_inner_than (current_gdbarch, >> + ecs->event_thread->step_frame_id.stack_addr, >> + get_frame_id > > Sorry to pitch in so late, but this doesn't look right to me. > Common code shouldn't be accessing frame id members directly, frame ids > are supposed to be opaque. What is this trying to do? It's trying to answer the question "have we stepped into a subroutine call?", in reverse. This unfortunately involves corner cases that we don't see when we're going forward. Originally the code just looked (approximately) like this: /* Check for subroutine calls. The check for the current frame equalling the step ID is not necessary - the check of the previous frame's ID is sufficient - but it is a common case and cheaper than checking the previous frame's ID. */ if (!frame_id_eq (get_frame_id (frame), step_frame_id) && frame_id_eq (frame_unwind_id (frame), step_frame_id)) The problem is that the second "frame_id_eq" test fails in the case where we've just stepped backward to the RET instruction of a function which, in forward-time, had just returned. It's possible that what we're trying to do here is work around a bug in the i386 implementation of frame_unwind_id. When I look at the frame_id that it returns at this point, it does not match either the caller or the callee, and its code_addr is particularly wrong. We don't encounter this situation in forward execution, because it is caught earler by the stepping-within-line-range code, and we never reach this test on the RET instruction.