From: Michael Snyder <msnyder@vmware.com>
To: Michael Snyder <msnyder@vmware.com>,
"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>,
teawater <teawater@gmail.com>
Subject: Re: [reverse RFA] no singlestep-over-BP in reverse
Date: Tue, 16 Sep 2008 00:09:00 -0000 [thread overview]
Message-ID: <48CEF8AB.8080706@vmware.com> (raw)
In-Reply-To: <20080915184245.GA21388@caradoc.them.org>
[-- Attachment #1: Type: text/plain, Size: 969 bytes --]
Daniel Jacobowitz wrote:
> On Mon, Sep 15, 2008 at 11:31:33AM -0700, Michael Snyder wrote:
>> When we're stopped at a breakpoint and we want to
>> continue in reverse, we're not actually going to
>> execute the instruction at the breakpoint -- we're
>> going to de-execute the previous instruction.
>>
>> Therefore there's no need to singlestep before
>> inserting breakpoints. In fact it would be a bad
>> idea to do so, because if there is a breakpoint at
>> the previous instruction, we WANT to hit it.
>>
>> Note that this patch is to be applied to the reverse branch.
>
> If there is a breakpoint on the previous instruction, will you hit it
> before or after de-executing that instruction? It seems like this
> logic should be somehow still necessary... but I can't put my finger
> on when.
The attached test does just that -- and it passes on three
targets that can go in reverse (teawater's, gdb-freeplay,
and the as yet unreleased VMware implementation).
[-- Attachment #2: consecutive-reverse.exp --]
[-- Type: text/plain, Size: 3284 bytes --]
# Copyright 2001, 2007, 2008 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Please email any bugs, comments, and/or additions to this file to:
# bug-gdb@prep.ai.mit.edu
# Based on a file written by Michael Snyder. (msnyder@redhat.com)
#
# Test breakpoints at consecutive instruction addresses.
#
set testfile "consecutive-reverse"
set srcfile ${testfile}.c
set binfile ${objdir}/${subdir}/${testfile}
if { [prepare_for_testing ${testfile}.exp $testfile $srcfile] } {
untested "${testfile}.exp"
return -1
}
runto main
# FIXME 'record' command should say something so we know it's working.
gdb_test "record" "" "start recording"
gdb_breakpoint foo
gdb_test "continue" "Breakpoint $decimal, foo .*" \
"continue to breakpoint in foo"
set foo1_addr 0
set foo2_addr 0
set stop_addr 0
send_gdb "x /2i \$pc\n"
gdb_expect {
global hex
global foo1_addr
global foo2_addr
global gdb_prompt
-re "($hex).*\[\r\n\]+($hex).*$gdb_prompt $" {
set foo1_addr $expect_out(1,string)
set foo2_addr $expect_out(2,string)
pass "get breakpoint address for foo"
}
-re ".*$gdb_prompt $" {
fail "get breakpoint address for foo"
return 0;
}
timeout {
fail "get breakpoint address for foo (timeout)"
return 0;
}
}
gdb_test "break \*$foo2_addr" "Breakpoint $decimal at $foo2_addr: file .*" \
"set bp, 2nd instr"
send_gdb "step\n"
gdb_expect {
-re "Breakpoint $decimal, ($hex) in foo.*$gdb_prompt $" {
set stop_addr $expect_out(1,string)
if [eval expr "$foo2_addr == $stop_addr"] then {
pass "stopped at bp, 2nd instr"
} else {
fail "stopped at bp, 2nd instr (wrong address)"
}
}
-re ".*$gdb_prompt $" {
fail "stopped at bp, 2nd instr"
}
timeout {
fail "stopped at bp, 2nd instr (timeout)"
}
}
###
###
###
# Set reverse execution direction
# FIXME: command needs to acknowledge, so we can test if it succeeded.
gdb_test "set exec-dir reverse" "" "set reverse execution"
# Now step backward and hope to hit the first breakpoint.
set test_msg "stopped at bp in reverse, 1st instr"
gdb_test_multiple "step" "$test_msg" {
-re "Breakpoint $decimal, ($hex) in foo.*$gdb_prompt $" {
set stop_addr $expect_out(1,string)
if [eval expr "$foo1_addr == $stop_addr"] then {
pass "$test_msg"
} else {
fail "$test_msg (wrong address)"
}
}
-re "Breakpoint $decimal, foo.*$gdb_prompt $" {
send_gdb "print \$pc == $foo1_addr\n"
gdb_expect {
-re "$decimal = 1\[\r\n\]+$gdb_prompt $" {
pass "$test_msg"
}
-re "$decimal = 0\[\r\n\]+$gdb_prompt $" {
fail "$test_msg (wrong address)"
}
}
}
-re ".*$gdb_prompt $" {
fail "$test_msg"
}
}
next prev parent reply other threads:[~2008-09-16 0:09 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-15 18:33 Michael Snyder
2008-09-15 18:43 ` Daniel Jacobowitz
2008-09-15 19:07 ` Michael Snyder
2008-09-15 21:15 ` Daniel Jacobowitz
2008-09-15 23:09 ` Michael Snyder
2008-09-16 0:09 ` Michael Snyder [this message]
2008-09-16 4:13 ` teawater
[not found] ` <daef60380809152110u663350abx76b283d519c5a09d@mail.gmail.com>
2008-09-16 18:40 ` Michael Snyder
2008-09-16 4:22 ` teawater
2008-09-16 15:04 ` teawater
2008-09-16 15:14 ` teawater
2008-09-16 15:22 ` Daniel Jacobowitz
2008-09-16 15:34 ` teawater
2008-09-16 15:35 ` teawater
2008-09-16 18:50 ` Michael Snyder
2008-09-16 18:45 ` Michael Snyder
2008-09-16 20:11 ` Joel Brobecker
2008-09-17 0:56 ` Michael Snyder
2008-09-17 15:44 ` teawater
2008-09-17 18:18 ` Michael Snyder
2008-09-17 15:32 ` teawater
2008-09-17 18:16 ` Michael Snyder
2008-09-18 6:39 ` teawater
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=48CEF8AB.8080706@vmware.com \
--to=msnyder@vmware.com \
--cc=gdb-patches@sourceware.org \
--cc=teawater@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox