Bug 12932 - Incorrent code line number on breakpoint set by function name
Summary: Incorrent code line number on breakpoint set by function name
Status: RESOLVED INVALID
Alias: None
Product: gdb
Classification: Unclassified
Component: breakpoints (show other bugs)
Version: HEAD
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-24 23:54 UTC by Ricardo Catalinas Jiménez
Modified: 2011-07-29 21:09 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
Test case (152 bytes, text/x-csrc)
2011-06-24 23:54 UTC, Ricardo Catalinas Jiménez
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ricardo Catalinas Jiménez 2011-06-24 23:54:53 UTC
Created attachment 5820 [details]
Test case

*Tested on GDB 7.3.50.20110624 x86_64*

In the next code, add a breakpoint in the function `f' with
the command `break f'. The breakpoint is placed after the
last brace of `for (;;)' which is wrong. It makes bypass the
first iteration of the loop. When the breakpoint is hit then i=1:

=================================================
void f(char *s, int i)
{
        for (;;) {
                if (s[i++] == '\n')
                        break;
        } <--- breakpoint set here with `break f'
               with i=1
}

int main(int argc, char *argv[])
{
        char buf[] = "0123456789\n";

        f(buf, 0);

        return 0;
}
=================================================
Comment 1 Jan Kratochvil 2011-07-29 21:09:27 UTC
Filed as:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49906