This is the mail archive of the
gdb-prs@sourceware.org
mailing list for the GDB project.
[Bug c++/17315] New: 'until' behavion in watchpoint.c (for loops) incompatible with loop condition instructions at the top of the loop
- From: "dblaikie at gmail dot com" <sourceware-bugzilla at sourceware dot org>
- To: gdb-prs at sourceware dot org
- Date: Tue, 26 Aug 2014 22:20:28 +0000
- Subject: [Bug c++/17315] New: 'until' behavion in watchpoint.c (for loops) incompatible with loop condition instructions at the top of the loop
- Auto-submitted: auto-generated
https://sourceware.org/bugzilla/show_bug.cgi?id=17315
Bug ID: 17315
Summary: 'until' behavion in watchpoint.c (for loops)
incompatible with loop condition instructions at the
top of the loop
Product: gdb
Version: 7.7
Status: NEW
Severity: normal
Priority: P2
Component: c++
Assignee: unassigned at sourceware dot org
Reporter: dblaikie at gmail dot com
Simplifying the watchpoint.c code down to:
void func() {}
int main() {
int a;
for (a = 0; a != 2; ++a) {
func();
}
return 0;
}
And running this through clang (assembly attached) and gdb, the following
behavior is observed:
=> 0x00000000004005af <main+15>: c7 45 f8 00 00 00 00 movl
$0x0,-0x8(%rbp)
(gdb) until
=> 0x00000000004005c3 <main+35>: e8 c8 ff ff ff callq 0x400590 <func>
(gdb)
=> 0x00000000004005c8 <main+40>: 8b 45 f8 mov -0x8(%rbp),%eax
0x00000000004005cb <main+43>: 05 01 00 00 00 add $0x1,%eax
0x00000000004005d0 <main+48>: 89 45 f8 mov %eax,-0x8(%rbp)
(gdb)
=> 0x00000000004005c3 <main+35>: e8 c8 ff ff ff callq 0x400590 <func>
so 'until' doesn't cause the loop to be skipped at all - continuing to run
'until' will just behave as though the user is stepping through the entire
loop.
I believe the issue here is that Clang keeps the loop condition at the top of
the loop, whereas GCC puts it at the end, the theory being 'until' really looks
for an instruction with a higher PC than the /last/ instruction on the line you
started at, not the specific instruction you started at.
(eg: while I ran "until" from <main+40>, I went through 40, 43, 48, then
<main+51> jumped up to the top of the loop (+22) but on the same line according
to the line table, continued on to 29, and then to 35 - since 35 is on a
distinct line from 29 and 29 > 35, GDB stopped here, even though 40 !> 35)
And GCC puts the condition at the end of the loop, so you go from increment, to
condition, then jump up from the condition to the body - changing lines and
decreasing the PC, so that causes until to skip that and keep going... until
eventually it gets out of the loop.
--
You are receiving this mail because:
You are on the CC list for the bug.