aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.cp
diff options
context:
space:
mode:
authorDoug Evans <dje@google.com>2008-02-08 00:42:07 +0000
committerDoug Evans <dje@google.com>2008-02-08 00:42:07 +0000
commit776592bf173a191aa5d142808ca9164fd243c0ce (patch)
treede93b4f22843af0ac994cdb88997e54683932eca /gdb/testsuite/gdb.cp
parentb29242315eb0d6694d66d75895116361e20c8003 (diff)
downloadgdb-776592bf173a191aa5d142808ca9164fd243c0ce.zip
gdb-776592bf173a191aa5d142808ca9164fd243c0ce.tar.gz
gdb-776592bf173a191aa5d142808ca9164fd243c0ce.tar.bz2
* breakpoint.c: #include "hashtab.h".
(ambiguous_names_p): New fn. (update_breakpoint_locations): When restoring bp enable status, don't compare function names if any functions have same name. * Makefile.in (breakpoint.o): Add hashtab.h dependency. * gdb.cp/mb-inline.exp: New. * gdb.cp/mb-inline.h: New. * gdb.cp/mb-inline1.cc: New. * gdb.cp/mb-inline2.cc: New.
Diffstat (limited to 'gdb/testsuite/gdb.cp')
-rw-r--r--gdb/testsuite/gdb.cp/mb-inline.exp108
-rw-r--r--gdb/testsuite/gdb.cp/mb-inline.h30
-rw-r--r--gdb/testsuite/gdb.cp/mb-inline1.cc35
-rw-r--r--gdb/testsuite/gdb.cp/mb-inline2.cc25
4 files changed, 198 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.cp/mb-inline.exp b/gdb/testsuite/gdb.cp/mb-inline.exp
new file mode 100644
index 0000000..1331a75
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/mb-inline.exp
@@ -0,0 +1,108 @@
+# Copyright 2008 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/>.
+
+# This file is part of the gdb testsuite.
+
+# This test verifies that setting breakpoint on line in inline
+# function will fire in all instantiations of that function.
+
+if $tracelevel then {
+ strace $tracelevel
+}
+
+if { [skip_cplus_tests] } { continue }
+
+set prms_id 0
+set bug_id 0
+
+set testfile "mb-inline"
+set hdrfile "${testfile}.h"
+set srcfile1 "${testfile}1.cc"
+set objfile1 "${testfile}1.o"
+set srcfile2 "${testfile}2.cc"
+set objfile2 "${testfile}2.o"
+set binfile "${objdir}/${subdir}/${testfile}"
+
+if { [gdb_compile "$srcdir/$subdir/$srcfile1" "$objdir/$subdir/$objfile1" object {debug c++}] != "" } {
+ untested mb-inline.exp
+ return -1
+}
+
+if { [gdb_compile "$srcdir/$subdir/$srcfile2" "$objdir/$subdir/$objfile2" object {debug c++}] != "" } {
+ untested mb-inline.exp
+ return -1
+}
+
+if { [gdb_compile "$objdir/$subdir/$objfile1 $objdir/$subdir/$objfile2" "${binfile}" executable {debug c++}] != "" } {
+ untested mb-inline.exp
+ return -1
+}
+
+if [get_compiler_info ${binfile} "c++"] {
+ return -1
+}
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load ${binfile}
+
+set bp_location [gdb_get_line_number "set breakpoint here" $hdrfile]
+
+# Set a breakpoint with multiple locations.
+
+gdb_test "break $hdrfile:$bp_location" \
+ "Breakpoint.*at.* file .*$hdrfile, line.*\\(2 locations\\).*" \
+ "set breakpoint"
+
+gdb_run_cmd
+gdb_expect {
+ -re "Breakpoint \[0-9\]+,.*foo \\(i=0\\).*$gdb_prompt $" {
+ pass "run to breakpoint"
+ }
+ -re "$gdb_prompt $" {
+ fail "run to breakpoint"
+ }
+ timeout {
+ fail "run to breakpoint (timeout)"
+ }
+}
+
+gdb_test "continue" \
+ ".*Breakpoint.*foo \\(i=1\\).*" \
+ "run to breakpoint 2"
+
+# Try disabling a single location. We also test
+# that at least in simple cases, the enable/disable
+# state of locations survive "run".
+# Early bug would disable 1.1 and enable 1.2 when program is run.
+gdb_test "disable 1.2" "" "disabling location: disable"
+
+gdb_run_cmd
+gdb_expect {
+ -re "Breakpoint \[0-9\]+,.*foo \\(i=0\\).*$gdb_prompt $" {
+ pass "disabling location: run to breakpoint"
+ }
+ -re "$gdb_prompt $" {
+ fail "disabling location: run to breakpoint"
+ }
+ timeout {
+ fail "disabling location: run to breakpoint (timeout)"
+ }
+}
+
+gdb_test "continue" \
+ ".*Program exited normally.*" \
+ "continue with disabled breakpoint 1.2"
diff --git a/gdb/testsuite/gdb.cp/mb-inline.h b/gdb/testsuite/gdb.cp/mb-inline.h
new file mode 100644
index 0000000..bc910a6
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/mb-inline.h
@@ -0,0 +1,30 @@
+/* Test gdb support for setting multiple file:line breakpoints on static
+ functions. In practice the functions may be inline fns compiled with -O0.
+ We avoid using inline here for simplicity's sake.
+
+ This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2008 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
+foo (int i)
+{
+ return i; // set breakpoint here
+}
+
+extern int afn ();
+extern int bfn ();
diff --git a/gdb/testsuite/gdb.cp/mb-inline1.cc b/gdb/testsuite/gdb.cp/mb-inline1.cc
new file mode 100644
index 0000000..0945269
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/mb-inline1.cc
@@ -0,0 +1,35 @@
+/* Test gdb support for setting file:line breakpoints on inline fns.
+
+ This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2008 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/>.
+ */
+
+#include "mb-inline.h"
+
+int
+afn ()
+{
+ return foo (0);
+}
+
+int
+main ()
+{
+ int a = afn ();
+ int b = bfn ();
+ return a * b;
+}
diff --git a/gdb/testsuite/gdb.cp/mb-inline2.cc b/gdb/testsuite/gdb.cp/mb-inline2.cc
new file mode 100644
index 0000000..bad0b88
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/mb-inline2.cc
@@ -0,0 +1,25 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2008 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/>.
+ */
+
+#include "mb-inline.h"
+
+int
+bfn ()
+{
+ return foo (1);
+}