aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.base/catch-load.exp
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2012-01-24 21:39:18 +0000
committerTom Tromey <tromey@redhat.com>2012-01-24 21:39:18 +0000
commitedcc5120824df89e290bfe8bded1c7cf89a5b40f (patch)
treead610ce2f545a5076d5fcfe5b4e0631dc54622ed /gdb/testsuite/gdb.base/catch-load.exp
parentfa864999823be896ef9d00d06c67a853f588aa22 (diff)
downloadgdb-edcc5120824df89e290bfe8bded1c7cf89a5b40f.zip
gdb-edcc5120824df89e290bfe8bded1c7cf89a5b40f.tar.gz
gdb-edcc5120824df89e290bfe8bded1c7cf89a5b40f.tar.bz2
PR symtab/12406:
* solib.c (update_solib_list): Update the program space's added_solibs and deleted_solibs fields. * progspace.h (struct program_space) <added_solibs, deleted_solibs>: New fields. (clear_program_space_solib_cache): Declare. * progspace.c (release_program_space): Call clear_program_space_solib_cache. (clear_program_space_solib_cache): New function. * infrun.c (handle_inferior_event) <TARGET_WAITKIND_LOADED>: Call bpstat_stop_status. Use handle_solib_event. * breakpoint.c: Include gdb_regex.h. (print_solib_event): New function. (bpstat_print): Use print_solib_event. (bpstat_stop_status): Add special case for bp_shlib_event. (handle_solib_event): New function. (bpstat_what): Use handle_solib_event. (struct solib_catchpoint): New. (dtor_catch_solib, insert_catch_solib, remove_catch_solib) (breakpoint_hit_catch_solib, check_status_catch_solib) (print_it_catch_solib, print_one_catch_solib) (print_mention_catch_solib, print_recreate_catch_solib): New functions. (catch_solib_breakpoint_ops): New global. (catch_load_or_unload, catch_load_command_1) (catch_unload_command_1): New functions. (internal_bkpt_check_status): Add special case for bp_shlib_event. (internal_bkpt_print_it): Use print_solib_event. (initialize_breakpoint_ops): Initialize catch_solib_breakpoint_ops. (_initialize_breakpoint): Register "catch load" and "catch unload". * breakpoint.h (handle_solib_event): Declare. * NEWS: Add entry for "catch load" and "catch unload". gdb/doc * gdb.texinfo (Set Catchpoints): Document "catch load" and "catch unload". (Files): Mention new catch commands. (GDB/MI Async Records): Likewise. gdb/testsuite * lib/mi-support.exp (mi_expect_stop): Add special case for solib-event. * gdb.base/catch-load-so.c: New file. * gdb.base/catch-load.exp: New file. * gdb.base/catch-load.c: New file. * gdb.base/break-interp.exp (reach_1): Update regexp.
Diffstat (limited to 'gdb/testsuite/gdb.base/catch-load.exp')
-rw-r--r--gdb/testsuite/gdb.base/catch-load.exp120
1 files changed, 120 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.base/catch-load.exp b/gdb/testsuite/gdb.base/catch-load.exp
new file mode 100644
index 0000000..af7114a
--- /dev/null
+++ b/gdb/testsuite/gdb.base/catch-load.exp
@@ -0,0 +1,120 @@
+# 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/>.
+#
+
+if {[skip_shlib_tests]} {
+ untested catch-load.exp
+ return -1
+}
+
+if {[get_compiler_info not-used]} {
+ warning "Could not get compiler info"
+ untested catch-load.exp
+ return -1
+}
+
+set testfile catch-load
+set srcfile ${testfile}.c
+set binfile ${objdir}/${subdir}/${testfile}
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug shlib_load}] != "" } {
+ untested catch-load.exp
+ return -1
+}
+
+set testfile2 catch-load-so
+set srcfile2 ${testfile2}.c
+set binfile2 ${objdir}/${subdir}/${testfile2}.so
+set binfile2_dlopen [shlib_target_file ${testfile2}.so]
+if { [gdb_compile_shlib "${srcdir}/${subdir}/${srcfile2}" ${binfile2} {debug}] != "" } {
+ untested catch-load.exp
+ return -1
+}
+
+# Run one set of tests.
+# SCENARIO is the name of the test scenario, it is just used in test
+# names.
+# KIND is passed to the "catch" command.
+# MATCH is a boolean saying whether we expect the catchpoint to be hit.
+proc one_catch_load_test {scenario kind match sostop} {
+ global verbose testfile testfile2 binfile2_dlopen
+ global pf_prefix srcfile
+ global decimal gdb_prompt
+
+ set saved_prefix $pf_prefix
+ append pf_prefix "${scenario}:"
+
+ clean_restart $testfile
+ gdb_load_shlibs $binfile2_dlopen
+
+ if {![runto_main]} {
+ fail "can't run to main"
+ set pf_prefix $saved_prefix
+ return
+ }
+
+ gdb_breakpoint [gdb_get_line_number "final breakpoint here"]
+ gdb_test_no_output "set var libname = \"$binfile2_dlopen\""
+ gdb_test_no_output "set stop-on-solib-events $sostop"
+ gdb_test "catch $kind" "Catchpoint $decimal \\(.*\\)"
+
+ send_gdb "continue\n"
+ gdb_test_multiple "continue" "continue" {
+ -re "Catchpoint $decimal\r\n.*loaded .*/$testfile2.*\r\n.*$gdb_prompt $" {
+ if {$match} {
+ pass "continue"
+ } else {
+ fail "continue"
+ }
+ }
+
+ -re "Stopped due to shared library event.*\r\n$gdb_prompt $" {
+ if {$sostop} {
+ pass "continue"
+ } else {
+ fail "continue"
+ }
+ }
+
+ -re "Breakpoint $decimal, .*\r\n$gdb_prompt $" {
+ if {!$match} {
+ pass "continue"
+ } else {
+ fail "continue"
+ }
+ }
+
+ -re ".*$gdb_prompt $" {
+ fail "continue"
+ }
+ }
+
+ set pf_prefix $saved_prefix
+}
+
+one_catch_load_test "plain load" "load" 1 0
+one_catch_load_test "plain load with stop-on-solib-events" "load" 1 1
+one_catch_load_test "rx load" "load $testfile2" 1 0
+one_catch_load_test "rx load with stop-on-solib-events" "load $testfile2" 1 1
+one_catch_load_test "non-matching load" "load zardoz" 0 0
+one_catch_load_test "non-matching load with stop-on-solib-events" \
+ "load zardoz" 0 1
+
+one_catch_load_test "plain unload" "unload" 1 0
+one_catch_load_test "plain unload with stop-on-solib-events" "unload" 1 1
+one_catch_load_test "rx unload" "unload $testfile2" 1 0
+one_catch_load_test "rx unload with stop-on-solib-events" \
+ "unload $testfile2" 1 1
+one_catch_load_test "non-matching unload" "unload zardoz" 0 0
+one_catch_load_test "non-matching unload with stop-on-solib-events" \
+ "unload zardoz" 0 1