From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12654 invoked by alias); 20 May 2005 13:14:06 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 12536 invoked from network); 20 May 2005 13:13:53 -0000 Received: from unknown (HELO nevyn.them.org) (66.93.172.17) by sourceware.org with SMTP; 20 May 2005 13:13:53 -0000 Received: from drow by nevyn.them.org with local (Exim 4.50) id 1DZ7K0-0006o4-9K; Fri, 20 May 2005 09:13:48 -0400 Date: Fri, 20 May 2005 13:14:00 -0000 From: Daniel Jacobowitz To: Eli Zaretskii Cc: Johan Rydberg , dan@shearer.org, gdb@sources.redhat.com Subject: Re: [discuss] Support for reverse-execution Message-ID: <20050520131348.GB25206@nevyn.them.org> Mail-Followup-To: Eli Zaretskii , Johan Rydberg , dan@shearer.org, gdb@sources.redhat.com References: <20050519012254.GZ19642@erizo.shearer.org> <428C8E04.3000305@virtutech.com> <01c55d27$Blat.v2.4$69471120@zahav.net.il> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <01c55d27$Blat.v2.4$69471120@zahav.net.il> User-Agent: Mutt/1.5.8i X-SW-Source: 2005-05/txt/msg00210.txt.bz2 Disclaimer: I have not looked at the code at all; I want to get the copyright assignment rolling first. On Fri, May 20, 2005 at 01:32:47PM +0300, Eli Zaretskii wrote: > > To implement "rnext" I had to add a new target-specific function that > > tries to figure out the address of the call instruction based on the > > last executed instruction and the instruction to be executed, IF the > > current instruction can be identified as a return insn. Johan, when I sketched out some algorithms for implementing these commands, I got the feeling that this was not a good way to do it. There are just too many ways to jump, and they can be pretty tricky to recognize on some architectures. PowerPC is easy, but it's a little more complicated to disassemble starting from the end of an instruction on ia32. Here's another one that requires absolutely no target support: - Detect reverse-step into a function - Set breakpoints at all entry points of the function; GDB doesn't support multiple entry points yet, really, so a breakpoint at the first instruction and a big fat comment is all this takes. - When you hit an entry point breakpoint, reverse-step once more. - If you have entered a different function, for instance via a reversed tail call, and you can still see the desired frame on the stack, then repeat. i.e. build reverse-next on top of reverse-finish. reverse-finish should take you to the intermediate caller in a tail call situation, not to the previous frame on the stack. Of course neither algorithm is robust in the case of stray jumps. Bookmarks and single-steps for that are the best we're going to get. > > + add_com ("rnext", class_run, rnext_command, > > + "Step program until it reaches the previous source line.\n\ > > "Go backwards until the program reaches the source line before the > current one." Johan used previous, you used backwards; let's figure out what we're calling the commands first :-P > > + add_com_alias ("rn", "rnext", class_run, 1); > > Do we want another alias called "previous"? I have no objection. > I'd prefer that target_resume accepted the direction argument. Is > there something that I'm missing that makes this hard or impossible? It should either be an argument, or a separate target hook as Michael proposed. No existing target supports it, so it would save us updating all targets to reject it. Which is just mechanical, so I don't feel strongly either way. -- Daniel Jacobowitz CodeSourcery, LLC