* [patch] Do not use notcurrent line for caller-'break' [Re: Why does gdb stop at a different line than “i b” shows while returning from function?]
[not found] ` <20120804200150.GA2730@a.lan>
@ 2012-08-04 20:06 ` Jan Kratochvil
2012-08-05 19:42 ` wempwer
2012-08-27 16:56 ` [commit] " Jan Kratochvil
0 siblings, 2 replies; 3+ messages in thread
From: Jan Kratochvil @ 2012-08-04 20:06 UTC (permalink / raw)
To: wempwer; +Cc: Joachim Protze, gdb-patches
On Sat, 04 Aug 2012 22:01:50 +0200, wempwer@gmail.com wrote:
> That's right, I didn't notice that before. Maybe it's a bug? I include the full log:
Yes, I think it is a bug.
(gdb) up
#1 0x00000000004005aa in main () at ./gdb.base/break-caller-line.c:29
29 callee ();
(gdb) PASS: gdb.base/break-caller-line.exp: up
info line *$pc
Line 30 of "./gdb.base/break-caller-line.c" starts at address 0x4005aa <main+9> and ends at 0x4005af <main+14>.
(gdb) PASS: gdb.base/break-caller-line.exp: info line *$pc
break
-Breakpoint 2 at 0x4005aa: file ./gdb.base/break-caller-line.c, line 29.
-(gdb) FAIL: gdb.base/break-caller-line.exp: break (caller line)
+Breakpoint 2 at 0x4005aa: file ./gdb.base/break-caller-line.c, line 30.
+(gdb) PASS: gdb.base/break-caller-line.exp: break
No regressions on {x86_64,x86_64-m32,i686}-fedorarawhide-linux-gnu.
For example on ia64 it is UNTESTED.
Thanks,
Jan
gdb/
2012-08-04 Jan Kratochvil <jan.kratochvil@redhat.com>
* breakpoint.c (parse_breakpoint_sals) <(*address) == NULL>: New
variable pc. Call find_pc_line instead of find_pc_overlay, restore
original PC for it.
gdb/testsuite/
2012-08-04 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.base/break-caller-line.c: New file.
* gdb.base/break-caller-line.exp: New file.
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 03719d4..3e44a5b 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -9128,21 +9128,27 @@ parse_breakpoint_sals (char **address,
{
struct linespec_sals lsal;
struct symtab_and_line sal;
+ CORE_ADDR pc;
init_sal (&sal); /* Initialize to zeroes. */
lsal.sals.sals = (struct symtab_and_line *)
xmalloc (sizeof (struct symtab_and_line));
/* Set sal's pspace, pc, symtab, and line to the values
- corresponding to the last call to print_frame_info. */
+ corresponding to the last call to print_frame_info.
+ Be sure to reinitialize LINE with NOTCURRENT == 0
+ as the breakpoint line number is inappropriate otherwise.
+ find_pc_line would adjust PC, re-set it back. */
get_last_displayed_sal (&sal);
- sal.section = find_pc_overlay (sal.pc);
+ pc = sal.pc;
+ sal = find_pc_line (pc, 0);
/* "break" without arguments is equivalent to "break *PC"
where PC is the last displayed codepoint's address. So
make sure to set sal.explicit_pc to prevent GDB from
trying to expand the list of sals to include all other
instances with the same symtab and line. */
+ sal.pc = pc;
sal.explicit_pc = 1;
lsal.sals.sals[0] = sal;
diff --git a/gdb/testsuite/gdb.base/break-caller-line.c b/gdb/testsuite/gdb.base/break-caller-line.c
new file mode 100644
index 0000000..59d15ee
--- /dev/null
+++ b/gdb/testsuite/gdb.base/break-caller-line.c
@@ -0,0 +1,31 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2012 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/>. */
+
+static int v;
+
+static void
+callee (void)
+{
+ v++;
+}
+
+int
+main (void)
+{
+ callee ();
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.base/break-caller-line.exp b/gdb/testsuite/gdb.base/break-caller-line.exp
new file mode 100644
index 0000000..45abe476
--- /dev/null
+++ b/gdb/testsuite/gdb.base/break-caller-line.exp
@@ -0,0 +1,55 @@
+# Copyright (C) 2012 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/>.
+
+standard_testfile
+
+if { [prepare_for_testing ${testfile}.exp ${testfile}] } {
+ return -1
+}
+
+if ![runto callee] {
+ return 0
+}
+
+set test "up"
+gdb_test_multiple $test $test {
+ -re "\r\n(\[0-9\]+)\[ \t\]+callee \\(\\);\r\n$gdb_prompt $" {
+ set notcurrent $expect_out(1,string)
+ pass $test
+ }
+}
+
+set test {info line *$pc}
+gdb_test_multiple $test $test {
+ -re "\r\nLine (\[0-9\]+) of .*\r\n$gdb_prompt $" {
+ set current $expect_out(1,string)
+ pass $test
+ }
+}
+
+if {$notcurrent == $current} {
+ untested "target arch has an instruction after call as part of the caller line"
+ return 0
+}
+
+set test "break"
+gdb_test_multiple $test $test {
+ -re "\r\nBreakpoint \[0-9\]+ at .*, line $current\\.\r\n$gdb_prompt $" {
+ pass $test
+ }
+ -re "\r\nBreakpoint \[0-9\]+ at .*, line $notcurrent\\.\r\n$gdb_prompt $" {
+ fail "$test (caller line)"
+ }
+}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch] Do not use notcurrent line for caller-'break' [Re: Why does gdb stop at a different line than “i b” shows while returning from function?]
2012-08-04 20:06 ` [patch] Do not use notcurrent line for caller-'break' [Re: Why does gdb stop at a different line than “i b” shows while returning from function?] Jan Kratochvil
@ 2012-08-05 19:42 ` wempwer
2012-08-27 16:56 ` [commit] " Jan Kratochvil
1 sibling, 0 replies; 3+ messages in thread
From: wempwer @ 2012-08-05 19:42 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: Joachim Protze, gdb-patches
On Sat, Aug 04, 2012 at 10:05:16PM +0200, Jan Kratochvil wrote:
> On Sat, 04 Aug 2012 22:01:50 +0200, wempwer@gmail.com wrote:
> > That's right, I didn't notice that before. Maybe it's a bug? I include the full log:
>
> Yes, I think it is a bug.
>
> (gdb) up
> #1 0x00000000004005aa in main () at ./gdb.base/break-caller-line.c:29
> 29 callee ();
> (gdb) PASS: gdb.base/break-caller-line.exp: up
> info line *$pc
> Line 30 of "./gdb.base/break-caller-line.c" starts at address 0x4005aa <main+9> and ends at 0x4005af <main+14>.
> (gdb) PASS: gdb.base/break-caller-line.exp: info line *$pc
> break
> -Breakpoint 2 at 0x4005aa: file ./gdb.base/break-caller-line.c, line 29.
> -(gdb) FAIL: gdb.base/break-caller-line.exp: break (caller line)
> +Breakpoint 2 at 0x4005aa: file ./gdb.base/break-caller-line.c, line 30.
> +(gdb) PASS: gdb.base/break-caller-line.exp: break
>
> No regressions on {x86_64,x86_64-m32,i686}-fedorarawhide-linux-gnu.
> For example on ia64 it is UNTESTED.
>
>
> Thanks,
> Jan
>
>
> gdb/
> 2012-08-04 Jan Kratochvil <jan.kratochvil@redhat.com>
>
> * breakpoint.c (parse_breakpoint_sals) <(*address) == NULL>: New
> variable pc. Call find_pc_line instead of find_pc_overlay, restore
> original PC for it.
>
> gdb/testsuite/
> 2012-08-04 Jan Kratochvil <jan.kratochvil@redhat.com>
>
> * gdb.base/break-caller-line.c: New file.
> * gdb.base/break-caller-line.exp: New file.
>
> diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
> index 03719d4..3e44a5b 100644
> --- a/gdb/breakpoint.c
> +++ b/gdb/breakpoint.c
> @@ -9128,21 +9128,27 @@ parse_breakpoint_sals (char **address,
> {
> struct linespec_sals lsal;
> struct symtab_and_line sal;
> + CORE_ADDR pc;
>
> init_sal (&sal); /* Initialize to zeroes. */
> lsal.sals.sals = (struct symtab_and_line *)
> xmalloc (sizeof (struct symtab_and_line));
>
> /* Set sal's pspace, pc, symtab, and line to the values
> - corresponding to the last call to print_frame_info. */
> + corresponding to the last call to print_frame_info.
> + Be sure to reinitialize LINE with NOTCURRENT == 0
> + as the breakpoint line number is inappropriate otherwise.
> + find_pc_line would adjust PC, re-set it back. */
> get_last_displayed_sal (&sal);
> - sal.section = find_pc_overlay (sal.pc);
> + pc = sal.pc;
> + sal = find_pc_line (pc, 0);
>
> /* "break" without arguments is equivalent to "break *PC"
> where PC is the last displayed codepoint's address. So
> make sure to set sal.explicit_pc to prevent GDB from
> trying to expand the list of sals to include all other
> instances with the same symtab and line. */
> + sal.pc = pc;
> sal.explicit_pc = 1;
>
> lsal.sals.sals[0] = sal;
> diff --git a/gdb/testsuite/gdb.base/break-caller-line.c b/gdb/testsuite/gdb.base/break-caller-line.c
> new file mode 100644
> index 0000000..59d15ee
> --- /dev/null
> +++ b/gdb/testsuite/gdb.base/break-caller-line.c
> @@ -0,0 +1,31 @@
> +/* This testcase is part of GDB, the GNU debugger.
> +
> + Copyright 2012 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/>. */
> +
> +static int v;
> +
> +static void
> +callee (void)
> +{
> + v++;
> +}
> +
> +int
> +main (void)
> +{
> + callee ();
> + return 0;
> +}
> diff --git a/gdb/testsuite/gdb.base/break-caller-line.exp b/gdb/testsuite/gdb.base/break-caller-line.exp
> new file mode 100644
> index 0000000..45abe476
> --- /dev/null
> +++ b/gdb/testsuite/gdb.base/break-caller-line.exp
> @@ -0,0 +1,55 @@
> +# Copyright (C) 2012 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/>.
> +
> +standard_testfile
> +
> +if { [prepare_for_testing ${testfile}.exp ${testfile}] } {
> + return -1
> +}
> +
> +if ![runto callee] {
> + return 0
> +}
> +
> +set test "up"
> +gdb_test_multiple $test $test {
> + -re "\r\n(\[0-9\]+)\[ \t\]+callee \\(\\);\r\n$gdb_prompt $" {
> + set notcurrent $expect_out(1,string)
> + pass $test
> + }
> +}
> +
> +set test {info line *$pc}
> +gdb_test_multiple $test $test {
> + -re "\r\nLine (\[0-9\]+) of .*\r\n$gdb_prompt $" {
> + set current $expect_out(1,string)
> + pass $test
> + }
> +}
> +
> +if {$notcurrent == $current} {
> + untested "target arch has an instruction after call as part of the caller line"
> + return 0
> +}
> +
> +set test "break"
> +gdb_test_multiple $test $test {
> + -re "\r\nBreakpoint \[0-9\]+ at .*, line $current\\.\r\n$gdb_prompt $" {
> + pass $test
> + }
> + -re "\r\nBreakpoint \[0-9\]+ at .*, line $notcurrent\\.\r\n$gdb_prompt $" {
> + fail "$test (caller line)"
> + }
> +}
Thank you, I applied your patch to the code from cvs and now 'i b' reports that breakpoint is set at line 9 correctly.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [commit] [patch] Do not use notcurrent line for caller-'break' [Re: Why does gdb stop at a different line than “i b” shows while returning from function?]
2012-08-04 20:06 ` [patch] Do not use notcurrent line for caller-'break' [Re: Why does gdb stop at a different line than “i b” shows while returning from function?] Jan Kratochvil
2012-08-05 19:42 ` wempwer
@ 2012-08-27 16:56 ` Jan Kratochvil
1 sibling, 0 replies; 3+ messages in thread
From: Jan Kratochvil @ 2012-08-27 16:56 UTC (permalink / raw)
To: wempwer; +Cc: Joachim Protze, gdb-patches
On Sat, 04 Aug 2012 22:05:16 +0200, Jan Kratochvil wrote:
> gdb/
> 2012-08-04 Jan Kratochvil <jan.kratochvil@redhat.com>
>
> * breakpoint.c (parse_breakpoint_sals) <(*address) == NULL>: New
> variable pc. Call find_pc_line instead of find_pc_overlay, restore
> original PC for it.
>
> gdb/testsuite/
> 2012-08-04 Jan Kratochvil <jan.kratochvil@redhat.com>
>
> * gdb.base/break-caller-line.c: New file.
> * gdb.base/break-caller-line.exp: New file.
Checked in:
http://sourceware.org/ml/gdb-cvs/2012-08/msg00205.html
Thanks,
Jan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-08-27 16:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20120729185452.GB2732@a.lan>
[not found] ` <501B96BE.8050604@tu-dresden.de>
[not found] ` <20120804200150.GA2730@a.lan>
2012-08-04 20:06 ` [patch] Do not use notcurrent line for caller-'break' [Re: Why does gdb stop at a different line than “i b” shows while returning from function?] Jan Kratochvil
2012-08-05 19:42 ` wempwer
2012-08-27 16:56 ` [commit] " Jan Kratochvil
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).