From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16172 invoked by alias); 22 Aug 2010 13:39:32 -0000 Received: (qmail 16153 invoked by uid 22791); 22 Aug 2010 13:39:30 -0000 X-SWARE-Spam-Status: No, hits=-0.5 required=5.0 tests=BAYES_05,RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from mtaout01-winn.ispmail.ntl.com (HELO mtaout01-winn.ispmail.ntl.com) (81.103.221.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 22 Aug 2010 13:39:23 +0000 Received: from aamtaout02-winn.ispmail.ntl.com ([81.103.221.35]) by mtaout01-winn.ispmail.ntl.com (InterMail vM.7.08.04.00 201-2186-134-20080326) with ESMTP id <20100822133916.TKVM3266.mtaout01-winn.ispmail.ntl.com@aamtaout02-winn.ispmail.ntl.com> for ; Sun, 22 Aug 2010 14:39:16 +0100 Received: from [192.168.0.2] (really [86.9.212.44]) by aamtaout02-winn.ispmail.ntl.com (InterMail vG.2.02.00.01 201-2161-120-102-20060912) with ESMTP id <20100822133916.OANX12520.aamtaout02-winn.ispmail.ntl.com@[192.168.0.2]> for ; Sun, 22 Aug 2010 14:39:16 +0100 Message-ID: <4C712882.9040700@fano.co.uk> Date: Sun, 22 Aug 2010 13:39:00 -0000 From: David McQuillan User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2.8) Gecko/20100802 Lightning/1.0b2 Thunderbird/3.1.2 MIME-Version: 1.0 To: gdb@sourceware.org Subject: reverse debugging implementation Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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: 2010-08/txt/msg00132.txt.bz2 Hi, I see gdb now supports reverse debugging. This is something I implemented for myself a number of years ago with my own simulators when I was working on testing some compilers and other stuff. That all died a long time ago but some of the ideas from it might be useful if you haven't done them already. Firstly as far as I can see gdb saves all the state change for every instruction. This is unnecessary, all you have to do is save the state of the cpu every few thousand instructions and for each instruction only save the state of memory locations before they are changed. Going back one instruction then involves rolling back the memory changes, the registers are set up then go forward n-1 instruction to go back one. I also had debug instructions to mark the current spot, then one could go between a few different different states easily to check on the difference. I think practically everything else I had about what to do about library calls is there - I intercepted system calls so they weren't redone just the old results returned so I had to save both before and after looks. Special work had to be done about allocating and freeing space and I only had serial files and no special device access so you can see I had a fairly straightforward environment. If you used virtual memory tricks it might be possible to save the state of the memory that way instead of even taking before looks. It would slow going backwards a bit but I never noticed any particular delay going back an instruction and machines have sped up and there's lots more memory nowadays. Cheers, David McQuillan