aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/ChangeLog9
-rw-r--r--gdb/testsuite/gdb.mi/mi-solib.exp62
-rw-r--r--gdb/testsuite/gdb.mi/solib-lib.c19
-rw-r--r--gdb/testsuite/gdb.mi/solib-main.c23
-rw-r--r--gdb/testsuite/lib/mi-support.exp32
5 files changed, 140 insertions, 5 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 16838e1..d84b323 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,12 @@
+2011-11-22 Tom Tromey <tromey@redhat.com>
+
+ * lib/mi-support.exp (mi_run_cmd_full): Rename from mi_run_cmd.
+ Add "use_mi_command" argument.
+ (mi_run_cmd, mi_run_with_cli): New procs.
+ * gdb.mi/solib-lib.c: New file.
+ * gdb.mi/solib-main.c: New file.
+ * gdb.mi/mi-solib.exp: New file.
+
2011-11-21 Doug Evans <dje@google.com>
* gdb.cp/nextoverthrow.exp: Skip test if debug info for
diff --git a/gdb/testsuite/gdb.mi/mi-solib.exp b/gdb/testsuite/gdb.mi/mi-solib.exp
new file mode 100644
index 0000000..4344f96
--- /dev/null
+++ b/gdb/testsuite/gdb.mi/mi-solib.exp
@@ -0,0 +1,62 @@
+# Copyright 2011 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 mi-support.exp
+set MIFLAGS "-i=mi2"
+
+if {[skip_shlib_tests]} {
+ untested mi-solib.exp
+ return -1
+}
+
+gdb_exit
+if [mi_gdb_start] {
+ continue
+}
+
+set libname "solib-lib"
+set srcfile_lib ${srcdir}/${subdir}/${libname}.c
+set binfile_lib ${objdir}/${subdir}/${libname}.so
+set lib_flags [list debug]
+
+set testfile "solib-main"
+set srcfile ${srcdir}/${subdir}/${testfile}.c
+set binfile ${objdir}/${subdir}/${testfile}
+set bin_flags [list debug shlib=${binfile_lib}]
+
+if [get_compiler_info ${binfile}] {
+ return -1
+}
+
+if { [gdb_compile_shlib ${srcfile_lib} ${binfile_lib} $lib_flags] != ""
+ || [gdb_compile ${srcfile} ${binfile} executable $bin_flags] != "" } {
+ untested "Could not compile $binfile_lib or $binfile."
+ return -1
+}
+
+mi_delete_breakpoints
+mi_gdb_reinitialize_dir $srcdir/$subdir
+mi_gdb_reinitialize_dir $srcdir/$subdir
+mi_gdb_load ${binfile}
+
+gdb_load_shlibs $binfile_lib
+
+mi_gdb_test "777-gdb-set stop-on-solib-events 1" "777\\^done" \
+ "set stop-on-solib-events"
+
+# We use "run" rather than "-exec-run" here in order to test that CLI
+# commands still cause the correct MI output to be generated.
+mi_run_with_cli
+mi_expect_stop solib-event .* .* .* .* .* "check for solib event"
diff --git a/gdb/testsuite/gdb.mi/solib-lib.c b/gdb/testsuite/gdb.mi/solib-lib.c
new file mode 100644
index 0000000..e30ce83
--- /dev/null
+++ b/gdb/testsuite/gdb.mi/solib-lib.c
@@ -0,0 +1,19 @@
+/* Copyright 2011 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/>.
+*/
+
+void solibfunction(void)
+{
+}
diff --git a/gdb/testsuite/gdb.mi/solib-main.c b/gdb/testsuite/gdb.mi/solib-main.c
new file mode 100644
index 0000000..eff210f
--- /dev/null
+++ b/gdb/testsuite/gdb.mi/solib-main.c
@@ -0,0 +1,23 @@
+/* Copyright 2011 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/>.
+*/
+
+extern void solibfunction(void);
+
+int main ()
+{
+ solibfunction ();
+ return 0;
+}
diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp
index 63097cb..dc1717b 100644
--- a/gdb/testsuite/lib/mi-support.exp
+++ b/gdb/testsuite/lib/mi-support.exp
@@ -788,7 +788,7 @@ proc mi_gdb_test { args } {
# In patterns, the newline sequence ``\r\n'' is matched explicitly as
# ``.*$'' could swallow up output that we attempt to match elsewhere.
-proc mi_run_cmd {args} {
+proc mi_run_cmd_full {use_mi_command args} {
global suppress_flag
if { $suppress_flag } {
return -1
@@ -797,6 +797,14 @@ proc mi_run_cmd {args} {
global thread_selected_re
global library_loaded_re
+ if {$use_mi_command} {
+ set run_prefix "220-exec-"
+ set run_match "220"
+ } else {
+ set run_prefix ""
+ set run_match ""
+ }
+
if [target_info exists gdb_init_command] {
send_gdb "[target_info gdb_init_command]\n";
gdb_expect 30 {
@@ -814,9 +822,9 @@ proc mi_run_cmd {args} {
if [target_info exists use_gdb_stub] {
if [target_info exists gdb,do_reload_on_run] {
- send_gdb "220-exec-continue\n";
+ send_gdb "${run_prefix}continue\n";
gdb_expect 60 {
- -re "220\\^running\[\r\n\]+\\*running,thread-id=\"\[^\"\]+\"\r\n$mi_gdb_prompt" {}
+ -re "${run_match}\\^running\[\r\n\]+\\*running,thread-id=\"\[^\"\]+\"\r\n$mi_gdb_prompt" {}
default {}
}
return 0;
@@ -835,9 +843,9 @@ proc mi_run_cmd {args} {
return 0
}
- send_gdb "220-exec-run $args\n"
+ send_gdb "${run_prefix}run $args\n"
gdb_expect {
- -re "220\\^running\r\n(\\*running,thread-id=\"\[^\"\]+\"\r\n|=thread-created,id=\"1\",group-id=\"\[0-9\]+\"\r\n)*(${library_loaded_re})*(${thread_selected_re})?${mi_gdb_prompt}" {
+ -re "${run_match}\\^running\r\n(\\*running,thread-id=\"\[^\"\]+\"\r\n|=thread-created,id=\"1\",group-id=\"\[0-9\]+\"\r\n)*(${library_loaded_re})*(${thread_selected_re})?${mi_gdb_prompt}" {
}
-re "\\^error,msg=\"The target does not support running in non-stop mode.\"" {
unsupported "Non-stop mode not supported"
@@ -853,6 +861,20 @@ proc mi_run_cmd {args} {
return 0
}
+# A wrapper for mi_run_cmd_full which uses -exec-run and
+# -exec-continue, as appropriate. ARGS are passed verbatim to
+# mi_run_cmd_full.
+proc mi_run_cmd {args} {
+ return [eval mi_run_cmd_full 1 $args]
+}
+
+# A wrapper for mi_run_cmd_full which uses the CLI commands 'run' and
+# 'continue', as appropriate. ARGS are passed verbatim to
+# mi_run_cmd_full.
+proc mi_run_with_cli {args} {
+ return [eval mi_run_cmd_full 0 $args]
+}
+
#
# Just like run-to-main but works with the MI interface
#