From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13836 invoked by alias); 18 Oct 2006 18:51:24 -0000 Received: (qmail 13827 invoked by uid 22791); 18 Oct 2006 18:51:24 -0000 X-Spam-Check-By: sourceware.org Received: from mx2.palmsource.com (HELO mx2.palmsource.com) (12.7.175.14) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 18 Oct 2006 18:51:16 +0000 Received: from localhost (localhost [127.0.0.1]) by localhost.domain.tld (Postfix) with ESMTP id 7AE0127345; Wed, 18 Oct 2006 11:51:15 -0700 (PDT) Received: from mx2.palmsource.com ([127.0.0.1]) by localhost (mx2.palmsource.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 03998-06-13; Wed, 18 Oct 2006 11:51:14 -0700 (PDT) Received: from ussunex01.palmsource.com (unknown [192.168.101.9]) by mx2.palmsource.com (Postfix) with ESMTP id 7FB9427302; Wed, 18 Oct 2006 11:51:14 -0700 (PDT) Received: from 192.168.92.75 ([192.168.92.75]) by ussunex01.palmsource.com ([192.168.101.9]) via Exchange Front-End Server owa.palmsource.com ([10.0.20.17]) with Microsoft Exchange Server HTTP-DAV ; Wed, 18 Oct 2006 18:51:14 +0000 Received: from svmsnyderlnx by owa.palmsource.com; 18 Oct 2006 11:51:14 -0700 Subject: Re: Breakpoints in delay slots From: Michael Snyder To: Andrew STUBBS Cc: GDB List In-Reply-To: <453608FC.2040201@st.com> References: <453608FC.2040201@st.com> Content-Type: text/plain Content-Transfer-Encoding: 7bit Date: Wed, 18 Oct 2006 18:51:00 -0000 Message-Id: <1161197474.9942.11.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.4.1 X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2006-10/txt/msg00136.txt.bz2 On Wed, 2006-10-18 at 11:59 +0100, Andrew STUBBS wrote: > Hi all, > > There is an occasional issue debugging programs on processors that use > delay slots - in my case the SH4. > > The problem occurs when a breakpoint is placed on the delay slot > instruction. This can happen when (1) > this instruction happens to be the first instruction of a source line, or (2) > when the user sets the breakpoint on a specific address. > > In the case of the SH4, the breakpoint instruction (at least the one we > use) is illegal in a delay slot. This means that, instead of triggering > the breakpoint, an illegal slot exception is raised which the user > program is expected to handle and usually results in a panic. > > In any case, even if the breakpoint were handled as normal, there is the > problem of where the program should be resumed. It is incorrect to set > the PC to the slot instruction because this will ignore the branch. The > correct thing is to set the PC to the address of the branch/slot pair - > i.e. 2 bytes back in the case of the SH4. > > There is no general way to identify a delay slot from instruction > analysis - any instruction may be preceded by data which looks like a > branch with a slot, and there is the danger of reading addresses outside > memory - so there is no way to avoid the situation in the first place. > Similarly, there is no way to identify that a breakpoint just hit was in > a slot unless you make a note of how it was hit. > > I need a way to solve this problem. Any suggestions? Sorry to be terse, but... (1) -O0 (2) "Don't do that". Michael