From: Joel Brobecker <brobecker@adacore.com>
To: gdb-patches@sourceware.org
Cc: Joel Brobecker <brobecker@adacore.com>
Subject: [RFA] wrong language used when re-setting breakpoint
Date: Tue, 18 Sep 2012 00:40:00 -0000 [thread overview]
Message-ID: <1347928803-15526-1-git-send-email-brobecker@adacore.com> (raw)
The debugger sometimes fails to re-set a breakpoint as follow,
causing it to become disabled:
(gdb) b nested_sub
Breakpoint 1 at 0x401cec: file foo.adb, line 7.
(gdb) b do_nothing
Breakpoint 2 at 0x401cdc: file pck.adb, line 4.
(gdb) run
Starting program: /[...]/foo
Error in re-setting breakpoint 1: Function "nested_sub" not defined.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Breakpoint 2, pck.do_nothing () at pck.adb:4
4 null;
This only happens on machines where the debug-file-directory is
a valid directory name.
The reason behind the error is that the linespec code that re-sets
the breakpoints uses the current_language global when iterating
over a symtab's symbols. However, the that global gets switched from
Ada to C during the startup phase, probably as a side-effect of stopping
in some system code for which debugging info is available. The fix
is to make sure that we use the correct language.
gdb/ChangeLog:
* linespec.c (iterate_over_all_matching_symtabs): Use the correct
language when iterating over symbols.
gdb/testsuite/ChangeLog:
* gdb.ada/bp_reset: New testcase.
Tested on x86_64-linux, no regression.
OK to commit?
Thank you,
--
Joel
---
gdb/linespec.c | 7 +++---
gdb/testsuite/gdb.ada/bp_reset.exp | 37 ++++++++++++++++++++++++++++++++
gdb/testsuite/gdb.ada/bp_reset/foo.adb | 27 +++++++++++++++++++++++
gdb/testsuite/gdb.ada/bp_reset/io.adb | 21 ++++++++++++++++++
gdb/testsuite/gdb.ada/bp_reset/io.ads | 18 ++++++++++++++++
gdb/testsuite/gdb.ada/bp_reset/pck.adb | 21 ++++++++++++++++++
gdb/testsuite/gdb.ada/bp_reset/pck.ads | 18 ++++++++++++++++
7 files changed, 146 insertions(+), 3 deletions(-)
create mode 100644 gdb/testsuite/gdb.ada/bp_reset.exp
create mode 100644 gdb/testsuite/gdb.ada/bp_reset/foo.adb
create mode 100644 gdb/testsuite/gdb.ada/bp_reset/io.adb
create mode 100644 gdb/testsuite/gdb.ada/bp_reset/io.ads
create mode 100644 gdb/testsuite/gdb.ada/bp_reset/pck.adb
create mode 100644 gdb/testsuite/gdb.ada/bp_reset/pck.ads
diff --git a/gdb/linespec.c b/gdb/linespec.c
index 86239c9..f7ff54e 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -1010,7 +1010,8 @@ iterate_over_all_matching_symtabs (struct linespec_state *state,
struct block *block;
block = BLOCKVECTOR_BLOCK (BLOCKVECTOR (symtab), STATIC_BLOCK);
- LA_ITERATE_OVER_SYMBOLS (block, name, domain, callback, data);
+ state->language->la_iterate_over_symbols (block, name, domain,
+ callback, data);
if (include_inline)
{
@@ -1021,8 +1022,8 @@ iterate_over_all_matching_symtabs (struct linespec_state *state,
i < BLOCKVECTOR_NBLOCKS (BLOCKVECTOR (symtab)); i++)
{
block = BLOCKVECTOR_BLOCK (BLOCKVECTOR (symtab), i);
- LA_ITERATE_OVER_SYMBOLS (block, name, domain,
- iterate_inline_only, &cad);
+ state->language->la_iterate_over_symbols
+ (block, name, domain, iterate_inline_only, &cad);
}
}
}
diff --git a/gdb/testsuite/gdb.ada/bp_reset.exp b/gdb/testsuite/gdb.ada/bp_reset.exp
new file mode 100644
index 0000000..aff3341
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/bp_reset.exp
@@ -0,0 +1,37 @@
+# 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/>.
+
+load_lib "ada.exp"
+
+standard_ada_testfile foo
+
+if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug ]] != "" } {
+ return -1
+}
+
+clean_restart ${testfile}
+
+gdb_test "break nested_sub" \
+ "Breakpoint $decimal at $hex: file .*foo.adb, line $decimal\\."
+
+gdb_test "break do_nothing" \
+ "Breakpoint $decimal at $hex: file .*pck.adb, line $decimal\\."
+
+# Run the program. Make sure the program runs until it hits
+# the first breakpoint inside nested_sub.
+
+gdb_run_cmd
+gdb_test "" "Breakpoint $decimal, foo\\.nested_sub \\(\\).*"
+
diff --git a/gdb/testsuite/gdb.ada/bp_reset/foo.adb b/gdb/testsuite/gdb.ada/bp_reset/foo.adb
new file mode 100644
index 0000000..27298f4
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/bp_reset/foo.adb
@@ -0,0 +1,27 @@
+-- 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/>.
+
+with Pck; use Pck;
+with IO; use IO;
+
+procedure Foo is
+ procedure Nested_Sub is
+ begin
+ Put_Line ("Some string");
+ end Nested_Sub;
+begin
+ Nested_Sub;
+ Do_Nothing;
+end Foo;
diff --git a/gdb/testsuite/gdb.ada/bp_reset/io.adb b/gdb/testsuite/gdb.ada/bp_reset/io.adb
new file mode 100644
index 0000000..ea7306e
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/bp_reset/io.adb
@@ -0,0 +1,21 @@
+-- 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/>.
+
+package body IO is
+ procedure Put_Line (S : String) is
+ begin
+ null;
+ end Put_Line;
+end IO;
diff --git a/gdb/testsuite/gdb.ada/bp_reset/io.ads b/gdb/testsuite/gdb.ada/bp_reset/io.ads
new file mode 100644
index 0000000..65772db
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/bp_reset/io.ads
@@ -0,0 +1,18 @@
+-- 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/>.
+
+package IO is
+ procedure Put_Line (S : String);
+end IO;
diff --git a/gdb/testsuite/gdb.ada/bp_reset/pck.adb b/gdb/testsuite/gdb.ada/bp_reset/pck.adb
new file mode 100644
index 0000000..ea1d233
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/bp_reset/pck.adb
@@ -0,0 +1,21 @@
+-- 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/>.
+
+package body Pck is
+ procedure Do_Nothing is
+ begin
+ null;
+ end Do_Nothing;
+end Pck;
diff --git a/gdb/testsuite/gdb.ada/bp_reset/pck.ads b/gdb/testsuite/gdb.ada/bp_reset/pck.ads
new file mode 100644
index 0000000..c8f9ec9
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/bp_reset/pck.ads
@@ -0,0 +1,18 @@
+-- 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/>.
+
+package Pck is
+ procedure Do_Nothing;
+end Pck;
--
1.7.9.5
next reply other threads:[~2012-09-18 0:40 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-18 0:40 Joel Brobecker [this message]
2012-09-18 14:52 ` Tom Tromey
2012-09-18 15:06 ` Joel Brobecker
2012-09-18 17:36 ` Tom Tromey
2012-09-18 17:47 ` Tom Tromey
2012-09-18 18:18 ` Joel Brobecker
2012-09-18 18:26 ` Tom Tromey
2012-09-18 18:55 ` Joel Brobecker
2012-09-18 19:16 ` Tom Tromey
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=1347928803-15526-1-git-send-email-brobecker@adacore.com \
--to=brobecker@adacore.com \
--cc=gdb-patches@sourceware.org \
/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