public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug gdb/31896] New: -exec-next skips statements
@ 2024-06-14 10:05 dmitry.neverov at jetbrains dot com
2024-06-14 12:54 ` [Bug gdb/31896] " tromey at sourceware dot org
2024-06-14 13:36 ` dmitry.neverov at jetbrains dot com
0 siblings, 2 replies; 3+ messages in thread
From: dmitry.neverov at jetbrains dot com @ 2024-06-14 10:05 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=31896
Bug ID: 31896
Summary: -exec-next skips statements
Product: gdb
Version: 14.1
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: gdb
Assignee: unassigned at sourceware dot org
Reporter: dmitry.neverov at jetbrains dot com
Target Milestone: ---
I'm debugging the following code, the at line1 (v == 0):
if (v) { // line1
// branch1
} else if (predicate()) { // line2
// branch2
}
else
{
// branch3, line3
}
When I issue the `next` command, execution stops at line3 instead of
line2. If I change the code and add a newline before the 'else if',
`next` stops at line2 as expected:
if (condition1) { // line1
// branch1
}
else if (predicate()) { // line2
// branch2
}
else
{
// branch3, line3
}
It looks like it happens because the last jump instruction in first
branch has the line2.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug gdb/31896] -exec-next skips statements
2024-06-14 10:05 [Bug gdb/31896] New: -exec-next skips statements dmitry.neverov at jetbrains dot com
@ 2024-06-14 12:54 ` tromey at sourceware dot org
2024-06-14 13:36 ` dmitry.neverov at jetbrains dot com
1 sibling, 0 replies; 3+ messages in thread
From: tromey at sourceware dot org @ 2024-06-14 12:54 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=31896
Tom Tromey <tromey at sourceware dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |tromey at sourceware dot org
--- Comment #1 from Tom Tromey <tromey at sourceware dot org> ---
Normally this kind of thing turns out to be caused
by the compiler. You can try examining the line
table to see.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug gdb/31896] -exec-next skips statements
2024-06-14 10:05 [Bug gdb/31896] New: -exec-next skips statements dmitry.neverov at jetbrains dot com
2024-06-14 12:54 ` [Bug gdb/31896] " tromey at sourceware dot org
@ 2024-06-14 13:36 ` dmitry.neverov at jetbrains dot com
1 sibling, 0 replies; 3+ messages in thread
From: dmitry.neverov at jetbrains dot com @ 2024-06-14 13:36 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=31896
--- Comment #2 from Dmitry Neverov <dmitry.neverov at jetbrains dot com> ---
Proper steps to reproduce on linux/aarch64 with main.cpp:
#include <iostream>
bool predicate(int v) {
return v == 7;
}
void f(int v) {
if (v) { // break here
std::cout << "branch1\n";
} else if(predicate(v)) {
std::cout << "branch2\n";
}
else {
std::cout << "branch3\n";
}
}
int main() {
f(0);
return 0;
}
$ clang++-15 -g -O0 main.cpp
$ gdb a.out
(gdb) b main.cpp:8
Breakpoint 1 at 0xa10: file main.cpp, line 8.
(gdb) run
Starting program: a.out
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/aarch64-linux-gnu/libthread_db.so.1".
Breakpoint 1, f (v=0) at main.cpp:8
8 if (v) {
(gdb) next
14 std::cout << "branch3\n";
(gdb) quit
I can reach the predicate() call if I use nexti (gdb stops at
0x0000aaaaaaaa0a38).
(gdb) info line *0x0000aaaaaaaa0a38
Line 10 of "main.cpp" starts at address 0xaaaaaaaa0a38 <_Z1fi+68> and ends at
0xaaaaaaaa0a3c <_Z1fi+72>.
Line 10 starts earlier than this address and this confuses gdb:
(gdb) info line 10
Line 10 of "main.cpp" starts at address 0xaaaaaaaa0a34 <_Z1fi+64> and ends at
0xaaaaaaaa0a38 <_Z1fi+68>.
Is it considered a compiler bug?
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-06-14 13:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-14 10:05 [Bug gdb/31896] New: -exec-next skips statements dmitry.neverov at jetbrains dot com
2024-06-14 12:54 ` [Bug gdb/31896] " tromey at sourceware dot org
2024-06-14 13:36 ` dmitry.neverov at jetbrains dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).