binutils-gdb/gdb/testsuite/gdb.base/catch-syscall.exp

426 lines
13 KiB
Plaintext
Raw Normal View History

# Copyright 1997-2014 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 program tests the 'catch syscall' functionality.
#
# It was written by Sergio Durigan Junior <sergiodj@linux.vnet.ibm.com>
# on September/2008.
if { [is_remote target] || ![isnative] } then {
continue
}
# Until "catch syscall" is implemented on other targets...
Improve and fix catch-syscall.exp While fixing another bug, I found that the current gdb.base/catch-syscall.exp is kind of messy, could use some improvements, and is not correctly testing some things. I've made the following patch to address all the issues I found. On the organization side, it does a cleanup and removes unecessary imports of gdb_prompt, uses prepare_for_testing and clean_restart where needed, and fixes some comments. The testcase was also not correctly testing catching syscalls using only numbers, or catching many syscalls at once. I fixed that. The patch also uses a new method for obtaining the syscalls numbers: it relies on the C source file to get them, via <sys/syscall.h> and SYS_* macros. This makes the .exp file simpler because there is no need to include target conditionals there. I tested this on x86_64 Fedora 18. gdb/testsuite/ChangeLog: 2013-12-18 Sergio Durigan Junior <sergiodj@redhat.com> * gdb.base/catch-syscall.c: Include <sys/syscall.h>. (close_syscall, chroot_syscall, exit_group_syscall): New variables. * gdb.base/catch-syscall.exp: Replace gdb_compile by prepare_for_testing. Call fill_all_syscalls_numbers before starting. Replace gdb_exit, gdb_start, gdb_reinitialize_dir and gdb_load by clean_restart. (check_info_bp_any_syscall, check_info_bp_specific_syscall) (check_info_bp_many_syscalls): Remove global gdb_prompt. (check_call_to_syscall): Likewise. Add global decimal. Improve testing regex. (check_return_from_syscall): Likewise. (check_continue, insert_catch_syscall_with_arg): Remove global gdb_prompt. (insert_catch_syscall_with_many_args): Likewise. Add global decimal. Fix $filter_str. Improve testing regex. (check_for_program_end): Remove global gdb_prompt. (test_catch_syscall_without_args): Likewise. Add global decimal. Improve testing regex. (test_catch_syscall_with_args, test_catch_syscall_with_many_args) (test_catch_syscall_with_wrong_args) (test_catch_syscall_restarting_inferior) (test_catch_syscall_fail_nodatadir): Remove global gdb_prompt. (do_syscall_tests): Likewise. Remove global srcdir. (test_catch_syscall_without_args_noxml): Remove global gdb_prompt. Add global last_syscall_number. Test for the exact syscall number to be caught. (test_catch_syscall_with_args_noxml): Remove global gdb_prompt. Add global all_syscalls_numbers. Test each syscall number to be caught, instead of only testing "close". (test_catch_syscall_with_wrong_args_noxml): Remove global gdb_prompt. (do_syscall_tests_without_xml): Likewise. Remove global srcdir. Remove stale comment. (fill_all_syscalls_numbers): Add global last_syscall_number. Fill the correct syscall numbers using information from the inferior.
2013-12-18 23:19:01 +01:00
if { ![istarget "hppa*-hp-hpux*"] && ![istarget "*-linux*"] } {
continue
}
# This shall be updated whenever 'catch syscall' is implemented
# on some architecture.
#if { ![istarget "i\[34567\]86-*-linux*"]
if { ![istarget "x86_64-*-linux*"] && ![istarget "i\[34567\]86-*-linux*"]
&& ![istarget "powerpc-*-linux*"] && ![istarget "powerpc64-*-linux*"]
&& ![istarget "sparc-*-linux*"] && ![istarget "sparc64-*-linux*"]
&& ![istarget "mips*-linux*"] && ![istarget "arm*-linux*"]
&& ![istarget "s390*-linux*"] } {
continue
}
standard_testfile
Improve and fix catch-syscall.exp While fixing another bug, I found that the current gdb.base/catch-syscall.exp is kind of messy, could use some improvements, and is not correctly testing some things. I've made the following patch to address all the issues I found. On the organization side, it does a cleanup and removes unecessary imports of gdb_prompt, uses prepare_for_testing and clean_restart where needed, and fixes some comments. The testcase was also not correctly testing catching syscalls using only numbers, or catching many syscalls at once. I fixed that. The patch also uses a new method for obtaining the syscalls numbers: it relies on the C source file to get them, via <sys/syscall.h> and SYS_* macros. This makes the .exp file simpler because there is no need to include target conditionals there. I tested this on x86_64 Fedora 18. gdb/testsuite/ChangeLog: 2013-12-18 Sergio Durigan Junior <sergiodj@redhat.com> * gdb.base/catch-syscall.c: Include <sys/syscall.h>. (close_syscall, chroot_syscall, exit_group_syscall): New variables. * gdb.base/catch-syscall.exp: Replace gdb_compile by prepare_for_testing. Call fill_all_syscalls_numbers before starting. Replace gdb_exit, gdb_start, gdb_reinitialize_dir and gdb_load by clean_restart. (check_info_bp_any_syscall, check_info_bp_specific_syscall) (check_info_bp_many_syscalls): Remove global gdb_prompt. (check_call_to_syscall): Likewise. Add global decimal. Improve testing regex. (check_return_from_syscall): Likewise. (check_continue, insert_catch_syscall_with_arg): Remove global gdb_prompt. (insert_catch_syscall_with_many_args): Likewise. Add global decimal. Fix $filter_str. Improve testing regex. (check_for_program_end): Remove global gdb_prompt. (test_catch_syscall_without_args): Likewise. Add global decimal. Improve testing regex. (test_catch_syscall_with_args, test_catch_syscall_with_many_args) (test_catch_syscall_with_wrong_args) (test_catch_syscall_restarting_inferior) (test_catch_syscall_fail_nodatadir): Remove global gdb_prompt. (do_syscall_tests): Likewise. Remove global srcdir. (test_catch_syscall_without_args_noxml): Remove global gdb_prompt. Add global last_syscall_number. Test for the exact syscall number to be caught. (test_catch_syscall_with_args_noxml): Remove global gdb_prompt. Add global all_syscalls_numbers. Test each syscall number to be caught, instead of only testing "close". (test_catch_syscall_with_wrong_args_noxml): Remove global gdb_prompt. (do_syscall_tests_without_xml): Likewise. Remove global srcdir. Remove stale comment. (fill_all_syscalls_numbers): Add global last_syscall_number. Fill the correct syscall numbers using information from the inferior.
2013-12-18 23:19:01 +01:00
if { [prepare_for_testing ${testfile}.exp $testfile ${testfile}.c] } {
untested catch-syscall.exp
return -1
}
# All (but the last) syscalls from the example code
# They are ordered according to the file, so do not change this.
Fix PR breakpoints/16297: catch syscall with syscall 0 Code rationale ============== by: Gabriel Krisman Bertazi This is a fix for bug 16297. The problem occurs when the user attempts to catch any syscall 0 (such as syscall read on Linux/x86_64). GDB was not able to catch the syscall and was missing the breakpoint. Now, breakpoint_hit_catch_syscall returns immediately when it finds the correct syscall number, avoiding a following check for the end of the search vector, that returns a no hit if the syscall number was zero. Testcase rationale ================== by: Sergio Durigan Junior This testcase is a little difficult to write. By doing a quick inspection at the Linux source, one can see that, in many targets, the syscall number 0 is restart_syscall, which is forbidden to be called from userspace. Therefore, on many targets, there's just no way to test this safely. My decision was to take the simpler route and just adds the "read" syscall on the default test. Its number on x86_64 is zero, which is "good enough" since many people here do their tests on x86_64 anyway and it is a popular architecture. However, there was another little gotcha. When using "read" passing 0 as the third parameter (i.e., asking it to read 0 bytes), current libc implementations could choose not to effectively call the syscall. Therefore, the best solution was to create a temporary pipe, write 1 byte into it, and then read this byte from it. gdb/ChangeLog 2013-12-19 Gabriel Krisman Bertazi <gabriel@krisman.be> PR breakpoints/16297 * breakpoint.c (breakpoint_hit_catch_syscall): Return immediately when expected syscall is hit. gdb/testsuite/ChangeLog 2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com> PR breakpoints/16297 * gdb.base/catch-syscall.c (read_syscall, pipe_syscall) (write_syscall): New variables. (main): Create a pipe, write 1 byte in it, and read 1 byte from it. * gdb.base/catch-syscall.exp (all_syscalls): Include "pipe, "write" and "read" syscalls. (fill_all_syscalls_numbers): Improve the way to obtain syscalls numbers.
2013-12-19 20:01:49 +01:00
set all_syscalls { "close" "chroot" "pipe" "write" "read" }
set all_syscalls_numbers { }
Improve and fix catch-syscall.exp While fixing another bug, I found that the current gdb.base/catch-syscall.exp is kind of messy, could use some improvements, and is not correctly testing some things. I've made the following patch to address all the issues I found. On the organization side, it does a cleanup and removes unecessary imports of gdb_prompt, uses prepare_for_testing and clean_restart where needed, and fixes some comments. The testcase was also not correctly testing catching syscalls using only numbers, or catching many syscalls at once. I fixed that. The patch also uses a new method for obtaining the syscalls numbers: it relies on the C source file to get them, via <sys/syscall.h> and SYS_* macros. This makes the .exp file simpler because there is no need to include target conditionals there. I tested this on x86_64 Fedora 18. gdb/testsuite/ChangeLog: 2013-12-18 Sergio Durigan Junior <sergiodj@redhat.com> * gdb.base/catch-syscall.c: Include <sys/syscall.h>. (close_syscall, chroot_syscall, exit_group_syscall): New variables. * gdb.base/catch-syscall.exp: Replace gdb_compile by prepare_for_testing. Call fill_all_syscalls_numbers before starting. Replace gdb_exit, gdb_start, gdb_reinitialize_dir and gdb_load by clean_restart. (check_info_bp_any_syscall, check_info_bp_specific_syscall) (check_info_bp_many_syscalls): Remove global gdb_prompt. (check_call_to_syscall): Likewise. Add global decimal. Improve testing regex. (check_return_from_syscall): Likewise. (check_continue, insert_catch_syscall_with_arg): Remove global gdb_prompt. (insert_catch_syscall_with_many_args): Likewise. Add global decimal. Fix $filter_str. Improve testing regex. (check_for_program_end): Remove global gdb_prompt. (test_catch_syscall_without_args): Likewise. Add global decimal. Improve testing regex. (test_catch_syscall_with_args, test_catch_syscall_with_many_args) (test_catch_syscall_with_wrong_args) (test_catch_syscall_restarting_inferior) (test_catch_syscall_fail_nodatadir): Remove global gdb_prompt. (do_syscall_tests): Likewise. Remove global srcdir. (test_catch_syscall_without_args_noxml): Remove global gdb_prompt. Add global last_syscall_number. Test for the exact syscall number to be caught. (test_catch_syscall_with_args_noxml): Remove global gdb_prompt. Add global all_syscalls_numbers. Test each syscall number to be caught, instead of only testing "close". (test_catch_syscall_with_wrong_args_noxml): Remove global gdb_prompt. (do_syscall_tests_without_xml): Likewise. Remove global srcdir. Remove stale comment. (fill_all_syscalls_numbers): Add global last_syscall_number. Fill the correct syscall numbers using information from the inferior.
2013-12-18 23:19:01 +01:00
# The last syscall (exit()) does not return, so
# we cannot expect the catchpoint to be triggered
# twice. It is a special case.
set last_syscall "exit_group"
Improve and fix catch-syscall.exp While fixing another bug, I found that the current gdb.base/catch-syscall.exp is kind of messy, could use some improvements, and is not correctly testing some things. I've made the following patch to address all the issues I found. On the organization side, it does a cleanup and removes unecessary imports of gdb_prompt, uses prepare_for_testing and clean_restart where needed, and fixes some comments. The testcase was also not correctly testing catching syscalls using only numbers, or catching many syscalls at once. I fixed that. The patch also uses a new method for obtaining the syscalls numbers: it relies on the C source file to get them, via <sys/syscall.h> and SYS_* macros. This makes the .exp file simpler because there is no need to include target conditionals there. I tested this on x86_64 Fedora 18. gdb/testsuite/ChangeLog: 2013-12-18 Sergio Durigan Junior <sergiodj@redhat.com> * gdb.base/catch-syscall.c: Include <sys/syscall.h>. (close_syscall, chroot_syscall, exit_group_syscall): New variables. * gdb.base/catch-syscall.exp: Replace gdb_compile by prepare_for_testing. Call fill_all_syscalls_numbers before starting. Replace gdb_exit, gdb_start, gdb_reinitialize_dir and gdb_load by clean_restart. (check_info_bp_any_syscall, check_info_bp_specific_syscall) (check_info_bp_many_syscalls): Remove global gdb_prompt. (check_call_to_syscall): Likewise. Add global decimal. Improve testing regex. (check_return_from_syscall): Likewise. (check_continue, insert_catch_syscall_with_arg): Remove global gdb_prompt. (insert_catch_syscall_with_many_args): Likewise. Add global decimal. Fix $filter_str. Improve testing regex. (check_for_program_end): Remove global gdb_prompt. (test_catch_syscall_without_args): Likewise. Add global decimal. Improve testing regex. (test_catch_syscall_with_args, test_catch_syscall_with_many_args) (test_catch_syscall_with_wrong_args) (test_catch_syscall_restarting_inferior) (test_catch_syscall_fail_nodatadir): Remove global gdb_prompt. (do_syscall_tests): Likewise. Remove global srcdir. (test_catch_syscall_without_args_noxml): Remove global gdb_prompt. Add global last_syscall_number. Test for the exact syscall number to be caught. (test_catch_syscall_with_args_noxml): Remove global gdb_prompt. Add global all_syscalls_numbers. Test each syscall number to be caught, instead of only testing "close". (test_catch_syscall_with_wrong_args_noxml): Remove global gdb_prompt. (do_syscall_tests_without_xml): Likewise. Remove global srcdir. Remove stale comment. (fill_all_syscalls_numbers): Add global last_syscall_number. Fill the correct syscall numbers using information from the inferior.
2013-12-18 23:19:01 +01:00
set last_syscall_number { }
# Internal procedure used to check if, after issuing a 'catch syscall'
# command (without arguments), the 'info breakpoints' command displays
# that '"any syscall"' is to be caught.
proc check_info_bp_any_syscall {} {
# Verifying that the catchpoint appears in the 'info breakpoints'
# command, but with "<any syscall>".
set thistest "catch syscall appears in 'info breakpoints'"
gdb_test "info breakpoints" ".*catchpoint.*keep y.*syscall \"<any syscall>\".*" $thistest
}
# Internal procedure used to check if, after issuing a 'catch syscall X'
# command (with arguments), the 'info breakpoints' command displays
# that the syscall 'X' is to be caught.
proc check_info_bp_specific_syscall { syscall } {
set thistest "syscall(s) $syscall appears in 'info breakpoints'"
gdb_test "info breakpoints" ".*catchpoint.*keep y.*syscall(\[(\]s\[)\])? (.)?${syscall}(.)?.*" $thistest
}
# Internal procedure used to check if, after issuing a 'catch syscall X'
# command (with many arguments), the 'info breakpoints' command displays
# that the syscalls 'X' are to be caught.
proc check_info_bp_many_syscalls { syscalls } {
set filter_str ""
foreach name $syscalls {
set filter_str "${filter_str}${name}, "
}
set filter_str [ string trimright $filter_str ", " ]
set thistest "syscalls $filter_str appears in 'info breakpoints'"
gdb_test "info breakpoints" ".*catchpoint.*keep y.*syscalls (.)?${filter_str}(.)?.*" $thistest
}
# This procedure checks if there was a call to a syscall.
proc check_call_to_syscall { syscall } {
Improve and fix catch-syscall.exp While fixing another bug, I found that the current gdb.base/catch-syscall.exp is kind of messy, could use some improvements, and is not correctly testing some things. I've made the following patch to address all the issues I found. On the organization side, it does a cleanup and removes unecessary imports of gdb_prompt, uses prepare_for_testing and clean_restart where needed, and fixes some comments. The testcase was also not correctly testing catching syscalls using only numbers, or catching many syscalls at once. I fixed that. The patch also uses a new method for obtaining the syscalls numbers: it relies on the C source file to get them, via <sys/syscall.h> and SYS_* macros. This makes the .exp file simpler because there is no need to include target conditionals there. I tested this on x86_64 Fedora 18. gdb/testsuite/ChangeLog: 2013-12-18 Sergio Durigan Junior <sergiodj@redhat.com> * gdb.base/catch-syscall.c: Include <sys/syscall.h>. (close_syscall, chroot_syscall, exit_group_syscall): New variables. * gdb.base/catch-syscall.exp: Replace gdb_compile by prepare_for_testing. Call fill_all_syscalls_numbers before starting. Replace gdb_exit, gdb_start, gdb_reinitialize_dir and gdb_load by clean_restart. (check_info_bp_any_syscall, check_info_bp_specific_syscall) (check_info_bp_many_syscalls): Remove global gdb_prompt. (check_call_to_syscall): Likewise. Add global decimal. Improve testing regex. (check_return_from_syscall): Likewise. (check_continue, insert_catch_syscall_with_arg): Remove global gdb_prompt. (insert_catch_syscall_with_many_args): Likewise. Add global decimal. Fix $filter_str. Improve testing regex. (check_for_program_end): Remove global gdb_prompt. (test_catch_syscall_without_args): Likewise. Add global decimal. Improve testing regex. (test_catch_syscall_with_args, test_catch_syscall_with_many_args) (test_catch_syscall_with_wrong_args) (test_catch_syscall_restarting_inferior) (test_catch_syscall_fail_nodatadir): Remove global gdb_prompt. (do_syscall_tests): Likewise. Remove global srcdir. (test_catch_syscall_without_args_noxml): Remove global gdb_prompt. Add global last_syscall_number. Test for the exact syscall number to be caught. (test_catch_syscall_with_args_noxml): Remove global gdb_prompt. Add global all_syscalls_numbers. Test each syscall number to be caught, instead of only testing "close". (test_catch_syscall_with_wrong_args_noxml): Remove global gdb_prompt. (do_syscall_tests_without_xml): Likewise. Remove global srcdir. Remove stale comment. (fill_all_syscalls_numbers): Add global last_syscall_number. Fill the correct syscall numbers using information from the inferior.
2013-12-18 23:19:01 +01:00
global decimal
set thistest "program has called $syscall"
Improve and fix catch-syscall.exp While fixing another bug, I found that the current gdb.base/catch-syscall.exp is kind of messy, could use some improvements, and is not correctly testing some things. I've made the following patch to address all the issues I found. On the organization side, it does a cleanup and removes unecessary imports of gdb_prompt, uses prepare_for_testing and clean_restart where needed, and fixes some comments. The testcase was also not correctly testing catching syscalls using only numbers, or catching many syscalls at once. I fixed that. The patch also uses a new method for obtaining the syscalls numbers: it relies on the C source file to get them, via <sys/syscall.h> and SYS_* macros. This makes the .exp file simpler because there is no need to include target conditionals there. I tested this on x86_64 Fedora 18. gdb/testsuite/ChangeLog: 2013-12-18 Sergio Durigan Junior <sergiodj@redhat.com> * gdb.base/catch-syscall.c: Include <sys/syscall.h>. (close_syscall, chroot_syscall, exit_group_syscall): New variables. * gdb.base/catch-syscall.exp: Replace gdb_compile by prepare_for_testing. Call fill_all_syscalls_numbers before starting. Replace gdb_exit, gdb_start, gdb_reinitialize_dir and gdb_load by clean_restart. (check_info_bp_any_syscall, check_info_bp_specific_syscall) (check_info_bp_many_syscalls): Remove global gdb_prompt. (check_call_to_syscall): Likewise. Add global decimal. Improve testing regex. (check_return_from_syscall): Likewise. (check_continue, insert_catch_syscall_with_arg): Remove global gdb_prompt. (insert_catch_syscall_with_many_args): Likewise. Add global decimal. Fix $filter_str. Improve testing regex. (check_for_program_end): Remove global gdb_prompt. (test_catch_syscall_without_args): Likewise. Add global decimal. Improve testing regex. (test_catch_syscall_with_args, test_catch_syscall_with_many_args) (test_catch_syscall_with_wrong_args) (test_catch_syscall_restarting_inferior) (test_catch_syscall_fail_nodatadir): Remove global gdb_prompt. (do_syscall_tests): Likewise. Remove global srcdir. (test_catch_syscall_without_args_noxml): Remove global gdb_prompt. Add global last_syscall_number. Test for the exact syscall number to be caught. (test_catch_syscall_with_args_noxml): Remove global gdb_prompt. Add global all_syscalls_numbers. Test each syscall number to be caught, instead of only testing "close". (test_catch_syscall_with_wrong_args_noxml): Remove global gdb_prompt. (do_syscall_tests_without_xml): Likewise. Remove global srcdir. Remove stale comment. (fill_all_syscalls_numbers): Add global last_syscall_number. Fill the correct syscall numbers using information from the inferior.
2013-12-18 23:19:01 +01:00
gdb_test "continue" "Catchpoint $decimal \\(call to syscall .?${syscall}.?\\).*" $thistest
}
# This procedure checks if the syscall returned.
proc check_return_from_syscall { syscall } {
Improve and fix catch-syscall.exp While fixing another bug, I found that the current gdb.base/catch-syscall.exp is kind of messy, could use some improvements, and is not correctly testing some things. I've made the following patch to address all the issues I found. On the organization side, it does a cleanup and removes unecessary imports of gdb_prompt, uses prepare_for_testing and clean_restart where needed, and fixes some comments. The testcase was also not correctly testing catching syscalls using only numbers, or catching many syscalls at once. I fixed that. The patch also uses a new method for obtaining the syscalls numbers: it relies on the C source file to get them, via <sys/syscall.h> and SYS_* macros. This makes the .exp file simpler because there is no need to include target conditionals there. I tested this on x86_64 Fedora 18. gdb/testsuite/ChangeLog: 2013-12-18 Sergio Durigan Junior <sergiodj@redhat.com> * gdb.base/catch-syscall.c: Include <sys/syscall.h>. (close_syscall, chroot_syscall, exit_group_syscall): New variables. * gdb.base/catch-syscall.exp: Replace gdb_compile by prepare_for_testing. Call fill_all_syscalls_numbers before starting. Replace gdb_exit, gdb_start, gdb_reinitialize_dir and gdb_load by clean_restart. (check_info_bp_any_syscall, check_info_bp_specific_syscall) (check_info_bp_many_syscalls): Remove global gdb_prompt. (check_call_to_syscall): Likewise. Add global decimal. Improve testing regex. (check_return_from_syscall): Likewise. (check_continue, insert_catch_syscall_with_arg): Remove global gdb_prompt. (insert_catch_syscall_with_many_args): Likewise. Add global decimal. Fix $filter_str. Improve testing regex. (check_for_program_end): Remove global gdb_prompt. (test_catch_syscall_without_args): Likewise. Add global decimal. Improve testing regex. (test_catch_syscall_with_args, test_catch_syscall_with_many_args) (test_catch_syscall_with_wrong_args) (test_catch_syscall_restarting_inferior) (test_catch_syscall_fail_nodatadir): Remove global gdb_prompt. (do_syscall_tests): Likewise. Remove global srcdir. (test_catch_syscall_without_args_noxml): Remove global gdb_prompt. Add global last_syscall_number. Test for the exact syscall number to be caught. (test_catch_syscall_with_args_noxml): Remove global gdb_prompt. Add global all_syscalls_numbers. Test each syscall number to be caught, instead of only testing "close". (test_catch_syscall_with_wrong_args_noxml): Remove global gdb_prompt. (do_syscall_tests_without_xml): Likewise. Remove global srcdir. Remove stale comment. (fill_all_syscalls_numbers): Add global last_syscall_number. Fill the correct syscall numbers using information from the inferior.
2013-12-18 23:19:01 +01:00
global decimal
set thistest "syscall $syscall has returned"
Improve and fix catch-syscall.exp While fixing another bug, I found that the current gdb.base/catch-syscall.exp is kind of messy, could use some improvements, and is not correctly testing some things. I've made the following patch to address all the issues I found. On the organization side, it does a cleanup and removes unecessary imports of gdb_prompt, uses prepare_for_testing and clean_restart where needed, and fixes some comments. The testcase was also not correctly testing catching syscalls using only numbers, or catching many syscalls at once. I fixed that. The patch also uses a new method for obtaining the syscalls numbers: it relies on the C source file to get them, via <sys/syscall.h> and SYS_* macros. This makes the .exp file simpler because there is no need to include target conditionals there. I tested this on x86_64 Fedora 18. gdb/testsuite/ChangeLog: 2013-12-18 Sergio Durigan Junior <sergiodj@redhat.com> * gdb.base/catch-syscall.c: Include <sys/syscall.h>. (close_syscall, chroot_syscall, exit_group_syscall): New variables. * gdb.base/catch-syscall.exp: Replace gdb_compile by prepare_for_testing. Call fill_all_syscalls_numbers before starting. Replace gdb_exit, gdb_start, gdb_reinitialize_dir and gdb_load by clean_restart. (check_info_bp_any_syscall, check_info_bp_specific_syscall) (check_info_bp_many_syscalls): Remove global gdb_prompt. (check_call_to_syscall): Likewise. Add global decimal. Improve testing regex. (check_return_from_syscall): Likewise. (check_continue, insert_catch_syscall_with_arg): Remove global gdb_prompt. (insert_catch_syscall_with_many_args): Likewise. Add global decimal. Fix $filter_str. Improve testing regex. (check_for_program_end): Remove global gdb_prompt. (test_catch_syscall_without_args): Likewise. Add global decimal. Improve testing regex. (test_catch_syscall_with_args, test_catch_syscall_with_many_args) (test_catch_syscall_with_wrong_args) (test_catch_syscall_restarting_inferior) (test_catch_syscall_fail_nodatadir): Remove global gdb_prompt. (do_syscall_tests): Likewise. Remove global srcdir. (test_catch_syscall_without_args_noxml): Remove global gdb_prompt. Add global last_syscall_number. Test for the exact syscall number to be caught. (test_catch_syscall_with_args_noxml): Remove global gdb_prompt. Add global all_syscalls_numbers. Test each syscall number to be caught, instead of only testing "close". (test_catch_syscall_with_wrong_args_noxml): Remove global gdb_prompt. (do_syscall_tests_without_xml): Likewise. Remove global srcdir. Remove stale comment. (fill_all_syscalls_numbers): Add global last_syscall_number. Fill the correct syscall numbers using information from the inferior.
2013-12-18 23:19:01 +01:00
gdb_test "continue" "Catchpoint $decimal \\(returned from syscall ${syscall}\\).*" $thistest
}
# Internal procedure that performs two 'continue' commands and checks if
# a syscall call AND return occur.
proc check_continue { syscall } {
# Testing if the 'continue' stops at the
# specified syscall_name. If it does, then it should
# first print that the infeior has called the syscall,
# and after print that the syscall has returned.
# Testing if the inferiorr has called the syscall.
check_call_to_syscall $syscall
# And now, that the syscall has returned.
check_return_from_syscall $syscall
}
# Inserts a syscall catchpoint with an argument.
proc insert_catch_syscall_with_arg { syscall } {
Improve and fix catch-syscall.exp While fixing another bug, I found that the current gdb.base/catch-syscall.exp is kind of messy, could use some improvements, and is not correctly testing some things. I've made the following patch to address all the issues I found. On the organization side, it does a cleanup and removes unecessary imports of gdb_prompt, uses prepare_for_testing and clean_restart where needed, and fixes some comments. The testcase was also not correctly testing catching syscalls using only numbers, or catching many syscalls at once. I fixed that. The patch also uses a new method for obtaining the syscalls numbers: it relies on the C source file to get them, via <sys/syscall.h> and SYS_* macros. This makes the .exp file simpler because there is no need to include target conditionals there. I tested this on x86_64 Fedora 18. gdb/testsuite/ChangeLog: 2013-12-18 Sergio Durigan Junior <sergiodj@redhat.com> * gdb.base/catch-syscall.c: Include <sys/syscall.h>. (close_syscall, chroot_syscall, exit_group_syscall): New variables. * gdb.base/catch-syscall.exp: Replace gdb_compile by prepare_for_testing. Call fill_all_syscalls_numbers before starting. Replace gdb_exit, gdb_start, gdb_reinitialize_dir and gdb_load by clean_restart. (check_info_bp_any_syscall, check_info_bp_specific_syscall) (check_info_bp_many_syscalls): Remove global gdb_prompt. (check_call_to_syscall): Likewise. Add global decimal. Improve testing regex. (check_return_from_syscall): Likewise. (check_continue, insert_catch_syscall_with_arg): Remove global gdb_prompt. (insert_catch_syscall_with_many_args): Likewise. Add global decimal. Fix $filter_str. Improve testing regex. (check_for_program_end): Remove global gdb_prompt. (test_catch_syscall_without_args): Likewise. Add global decimal. Improve testing regex. (test_catch_syscall_with_args, test_catch_syscall_with_many_args) (test_catch_syscall_with_wrong_args) (test_catch_syscall_restarting_inferior) (test_catch_syscall_fail_nodatadir): Remove global gdb_prompt. (do_syscall_tests): Likewise. Remove global srcdir. (test_catch_syscall_without_args_noxml): Remove global gdb_prompt. Add global last_syscall_number. Test for the exact syscall number to be caught. (test_catch_syscall_with_args_noxml): Remove global gdb_prompt. Add global all_syscalls_numbers. Test each syscall number to be caught, instead of only testing "close". (test_catch_syscall_with_wrong_args_noxml): Remove global gdb_prompt. (do_syscall_tests_without_xml): Likewise. Remove global srcdir. Remove stale comment. (fill_all_syscalls_numbers): Add global last_syscall_number. Fill the correct syscall numbers using information from the inferior.
2013-12-18 23:19:01 +01:00
global decimal
# Trying to set the catchpoint
set thistest "catch syscall with arguments ($syscall)"
Improve and fix catch-syscall.exp While fixing another bug, I found that the current gdb.base/catch-syscall.exp is kind of messy, could use some improvements, and is not correctly testing some things. I've made the following patch to address all the issues I found. On the organization side, it does a cleanup and removes unecessary imports of gdb_prompt, uses prepare_for_testing and clean_restart where needed, and fixes some comments. The testcase was also not correctly testing catching syscalls using only numbers, or catching many syscalls at once. I fixed that. The patch also uses a new method for obtaining the syscalls numbers: it relies on the C source file to get them, via <sys/syscall.h> and SYS_* macros. This makes the .exp file simpler because there is no need to include target conditionals there. I tested this on x86_64 Fedora 18. gdb/testsuite/ChangeLog: 2013-12-18 Sergio Durigan Junior <sergiodj@redhat.com> * gdb.base/catch-syscall.c: Include <sys/syscall.h>. (close_syscall, chroot_syscall, exit_group_syscall): New variables. * gdb.base/catch-syscall.exp: Replace gdb_compile by prepare_for_testing. Call fill_all_syscalls_numbers before starting. Replace gdb_exit, gdb_start, gdb_reinitialize_dir and gdb_load by clean_restart. (check_info_bp_any_syscall, check_info_bp_specific_syscall) (check_info_bp_many_syscalls): Remove global gdb_prompt. (check_call_to_syscall): Likewise. Add global decimal. Improve testing regex. (check_return_from_syscall): Likewise. (check_continue, insert_catch_syscall_with_arg): Remove global gdb_prompt. (insert_catch_syscall_with_many_args): Likewise. Add global decimal. Fix $filter_str. Improve testing regex. (check_for_program_end): Remove global gdb_prompt. (test_catch_syscall_without_args): Likewise. Add global decimal. Improve testing regex. (test_catch_syscall_with_args, test_catch_syscall_with_many_args) (test_catch_syscall_with_wrong_args) (test_catch_syscall_restarting_inferior) (test_catch_syscall_fail_nodatadir): Remove global gdb_prompt. (do_syscall_tests): Likewise. Remove global srcdir. (test_catch_syscall_without_args_noxml): Remove global gdb_prompt. Add global last_syscall_number. Test for the exact syscall number to be caught. (test_catch_syscall_with_args_noxml): Remove global gdb_prompt. Add global all_syscalls_numbers. Test each syscall number to be caught, instead of only testing "close". (test_catch_syscall_with_wrong_args_noxml): Remove global gdb_prompt. (do_syscall_tests_without_xml): Likewise. Remove global srcdir. Remove stale comment. (fill_all_syscalls_numbers): Add global last_syscall_number. Fill the correct syscall numbers using information from the inferior.
2013-12-18 23:19:01 +01:00
gdb_test "catch syscall $syscall" "Catchpoint $decimal \\(syscall \'?${syscall}\'?( \[${decimal}\])?\\)" $thistest
check_info_bp_specific_syscall $syscall
}
# Inserts a syscall catchpoint with many arguments.
proc insert_catch_syscall_with_many_args { syscalls numbers } {
Improve and fix catch-syscall.exp While fixing another bug, I found that the current gdb.base/catch-syscall.exp is kind of messy, could use some improvements, and is not correctly testing some things. I've made the following patch to address all the issues I found. On the organization side, it does a cleanup and removes unecessary imports of gdb_prompt, uses prepare_for_testing and clean_restart where needed, and fixes some comments. The testcase was also not correctly testing catching syscalls using only numbers, or catching many syscalls at once. I fixed that. The patch also uses a new method for obtaining the syscalls numbers: it relies on the C source file to get them, via <sys/syscall.h> and SYS_* macros. This makes the .exp file simpler because there is no need to include target conditionals there. I tested this on x86_64 Fedora 18. gdb/testsuite/ChangeLog: 2013-12-18 Sergio Durigan Junior <sergiodj@redhat.com> * gdb.base/catch-syscall.c: Include <sys/syscall.h>. (close_syscall, chroot_syscall, exit_group_syscall): New variables. * gdb.base/catch-syscall.exp: Replace gdb_compile by prepare_for_testing. Call fill_all_syscalls_numbers before starting. Replace gdb_exit, gdb_start, gdb_reinitialize_dir and gdb_load by clean_restart. (check_info_bp_any_syscall, check_info_bp_specific_syscall) (check_info_bp_many_syscalls): Remove global gdb_prompt. (check_call_to_syscall): Likewise. Add global decimal. Improve testing regex. (check_return_from_syscall): Likewise. (check_continue, insert_catch_syscall_with_arg): Remove global gdb_prompt. (insert_catch_syscall_with_many_args): Likewise. Add global decimal. Fix $filter_str. Improve testing regex. (check_for_program_end): Remove global gdb_prompt. (test_catch_syscall_without_args): Likewise. Add global decimal. Improve testing regex. (test_catch_syscall_with_args, test_catch_syscall_with_many_args) (test_catch_syscall_with_wrong_args) (test_catch_syscall_restarting_inferior) (test_catch_syscall_fail_nodatadir): Remove global gdb_prompt. (do_syscall_tests): Likewise. Remove global srcdir. (test_catch_syscall_without_args_noxml): Remove global gdb_prompt. Add global last_syscall_number. Test for the exact syscall number to be caught. (test_catch_syscall_with_args_noxml): Remove global gdb_prompt. Add global all_syscalls_numbers. Test each syscall number to be caught, instead of only testing "close". (test_catch_syscall_with_wrong_args_noxml): Remove global gdb_prompt. (do_syscall_tests_without_xml): Likewise. Remove global srcdir. Remove stale comment. (fill_all_syscalls_numbers): Add global last_syscall_number. Fill the correct syscall numbers using information from the inferior.
2013-12-18 23:19:01 +01:00
global decimal
set catch [ join $syscalls " " ]
set filter_str ""
foreach name $syscalls number $numbers {
Improve and fix catch-syscall.exp While fixing another bug, I found that the current gdb.base/catch-syscall.exp is kind of messy, could use some improvements, and is not correctly testing some things. I've made the following patch to address all the issues I found. On the organization side, it does a cleanup and removes unecessary imports of gdb_prompt, uses prepare_for_testing and clean_restart where needed, and fixes some comments. The testcase was also not correctly testing catching syscalls using only numbers, or catching many syscalls at once. I fixed that. The patch also uses a new method for obtaining the syscalls numbers: it relies on the C source file to get them, via <sys/syscall.h> and SYS_* macros. This makes the .exp file simpler because there is no need to include target conditionals there. I tested this on x86_64 Fedora 18. gdb/testsuite/ChangeLog: 2013-12-18 Sergio Durigan Junior <sergiodj@redhat.com> * gdb.base/catch-syscall.c: Include <sys/syscall.h>. (close_syscall, chroot_syscall, exit_group_syscall): New variables. * gdb.base/catch-syscall.exp: Replace gdb_compile by prepare_for_testing. Call fill_all_syscalls_numbers before starting. Replace gdb_exit, gdb_start, gdb_reinitialize_dir and gdb_load by clean_restart. (check_info_bp_any_syscall, check_info_bp_specific_syscall) (check_info_bp_many_syscalls): Remove global gdb_prompt. (check_call_to_syscall): Likewise. Add global decimal. Improve testing regex. (check_return_from_syscall): Likewise. (check_continue, insert_catch_syscall_with_arg): Remove global gdb_prompt. (insert_catch_syscall_with_many_args): Likewise. Add global decimal. Fix $filter_str. Improve testing regex. (check_for_program_end): Remove global gdb_prompt. (test_catch_syscall_without_args): Likewise. Add global decimal. Improve testing regex. (test_catch_syscall_with_args, test_catch_syscall_with_many_args) (test_catch_syscall_with_wrong_args) (test_catch_syscall_restarting_inferior) (test_catch_syscall_fail_nodatadir): Remove global gdb_prompt. (do_syscall_tests): Likewise. Remove global srcdir. (test_catch_syscall_without_args_noxml): Remove global gdb_prompt. Add global last_syscall_number. Test for the exact syscall number to be caught. (test_catch_syscall_with_args_noxml): Remove global gdb_prompt. Add global all_syscalls_numbers. Test each syscall number to be caught, instead of only testing "close". (test_catch_syscall_with_wrong_args_noxml): Remove global gdb_prompt. (do_syscall_tests_without_xml): Likewise. Remove global srcdir. Remove stale comment. (fill_all_syscalls_numbers): Add global last_syscall_number. Fill the correct syscall numbers using information from the inferior.
2013-12-18 23:19:01 +01:00
set filter_str "${filter_str}'${name}' \\\[${number}\\\] "
}
set filter_str [ string trimright $filter_str " " ]
# Trying to set the catchpoint
set thistest "catch syscall with arguments ($filter_str)"
Improve and fix catch-syscall.exp While fixing another bug, I found that the current gdb.base/catch-syscall.exp is kind of messy, could use some improvements, and is not correctly testing some things. I've made the following patch to address all the issues I found. On the organization side, it does a cleanup and removes unecessary imports of gdb_prompt, uses prepare_for_testing and clean_restart where needed, and fixes some comments. The testcase was also not correctly testing catching syscalls using only numbers, or catching many syscalls at once. I fixed that. The patch also uses a new method for obtaining the syscalls numbers: it relies on the C source file to get them, via <sys/syscall.h> and SYS_* macros. This makes the .exp file simpler because there is no need to include target conditionals there. I tested this on x86_64 Fedora 18. gdb/testsuite/ChangeLog: 2013-12-18 Sergio Durigan Junior <sergiodj@redhat.com> * gdb.base/catch-syscall.c: Include <sys/syscall.h>. (close_syscall, chroot_syscall, exit_group_syscall): New variables. * gdb.base/catch-syscall.exp: Replace gdb_compile by prepare_for_testing. Call fill_all_syscalls_numbers before starting. Replace gdb_exit, gdb_start, gdb_reinitialize_dir and gdb_load by clean_restart. (check_info_bp_any_syscall, check_info_bp_specific_syscall) (check_info_bp_many_syscalls): Remove global gdb_prompt. (check_call_to_syscall): Likewise. Add global decimal. Improve testing regex. (check_return_from_syscall): Likewise. (check_continue, insert_catch_syscall_with_arg): Remove global gdb_prompt. (insert_catch_syscall_with_many_args): Likewise. Add global decimal. Fix $filter_str. Improve testing regex. (check_for_program_end): Remove global gdb_prompt. (test_catch_syscall_without_args): Likewise. Add global decimal. Improve testing regex. (test_catch_syscall_with_args, test_catch_syscall_with_many_args) (test_catch_syscall_with_wrong_args) (test_catch_syscall_restarting_inferior) (test_catch_syscall_fail_nodatadir): Remove global gdb_prompt. (do_syscall_tests): Likewise. Remove global srcdir. (test_catch_syscall_without_args_noxml): Remove global gdb_prompt. Add global last_syscall_number. Test for the exact syscall number to be caught. (test_catch_syscall_with_args_noxml): Remove global gdb_prompt. Add global all_syscalls_numbers. Test each syscall number to be caught, instead of only testing "close". (test_catch_syscall_with_wrong_args_noxml): Remove global gdb_prompt. (do_syscall_tests_without_xml): Likewise. Remove global srcdir. Remove stale comment. (fill_all_syscalls_numbers): Add global last_syscall_number. Fill the correct syscall numbers using information from the inferior.
2013-12-18 23:19:01 +01:00
gdb_test "catch syscall $catch" "Catchpoint $decimal \\(syscalls ${filter_str}\\).*" $thistest
check_info_bp_many_syscalls $syscalls
}
proc check_for_program_end {} {
# Deleting the catchpoints
delete_breakpoints
gdb * infrun.c (print_exited_reason): Include inferior id and pid in message. gdb/testsuite * lib/opencl.exp (skip_opencl_tests): Update for exit message change. * lib/mi-support.exp (mi_gdb_test): Update for exit message change. * lib/gdb.exp (gdb_test_multiple): Update comment. Update for exit message change. (skip_altivec_tests): Update for exit message change. (skip_vsx_tests): Likewise. (gdb_continue_to_end): Likewise. Add 'command' argument. * lib/cell.exp (skip_cell_tests): Update for exit message change. * gdb.threads/tls.exp: Update for exit message change. * gdb.threads/thread-unwindonsignal.exp: Use gdb_continue_to_end. * gdb.threads/step.exp (step_it): Update for exit message change. (continue_all): Likewise. * gdb.threads/print-threads.exp (test_all_threads): Update for exit message change. * gdb.threads/interrupted-hand-call.exp: Use gdb_continue_to_end. * gdb.threads/execl.exp: Use gdb_continue_to_end. * gdb.python/py-prettyprint.exp (run_lang_tests): Use gdb_continue_to_end. * gdb.hp/gdb.objdbg/objdbg02.exp: Use gdb_continue_to_end. * gdb.hp/gdb.objdbg/objdbg01.exp: Use gdb_continue_to_end. * gdb.hp/gdb.defects/solib-d.exp: Update for exit message change. * gdb.cp/method.exp: Update for exit message change. * gdb.cp/mb-templates.exp: Update for exit message change. * gdb.cp/mb-inline.exp: Use gdb_continue_to_end. * gdb.cp/annota3.exp: Update for exit message change. * gdb.cp/annota2.exp: Update for exit message change. * gdb.cell/fork.exp: Use gdb_continue_to_end. * gdb.base/term.exp: Update for exit message change. * gdb.base/step-test.exp (test_i): Update for exit message change. * gdb.base/sigstep.exp (advance): Update for exit message change. (advancei): Likewise. * gdb.base/siginfo.exp: Update for exit message change. * gdb.base/shlib-call.exp: Use gdb_continue_to_end. * gdb.base/reread.exp: Use gdb_continue_to_end. * gdb.base/langs.exp: Use gdb_continue_to_end. * gdb.base/interrupt.exp: Update for exit message change. * gdb.base/gdb1555.exp: Update for exit message change. * gdb.base/exe-lock.exp: Use gdb_continue_to_end. * gdb.base/ending-run.exp: Update for exit message change. * gdb.base/chng-syms.exp: Update for exit message change. * gdb.base/checkpoint.exp: Update for exit message change. * gdb.base/catch-syscall.exp (check_for_program_end): Use gdb_continue_to_end. (test_catch_syscall_with_wrong_args): Likewise. * gdb.base/call-signal-resume.exp: Use gdb_continue_to_end. * gdb.base/break-interp.exp (test_ld): Update for exit message change. * gdb.base/bang.exp: Update for exit message change. * gdb.base/attach.exp (do_attach_tests): Use gdb_continue_to_end. (do_call_attach_tests): Likewise. * gdb.base/a2-run.exp: Update for exit message change. * gdb.arch/ppc-dfp.exp: Update for exit message change. * gdb.ada/tasks.exp: Use gdb_continue_to_end. * gdb.ada/catch_ex.exp: Use gdb_continue_to_end.
2011-03-07 17:03:04 +01:00
gdb_continue_to_end
}
proc test_catch_syscall_without_args {} {
Improve and fix catch-syscall.exp While fixing another bug, I found that the current gdb.base/catch-syscall.exp is kind of messy, could use some improvements, and is not correctly testing some things. I've made the following patch to address all the issues I found. On the organization side, it does a cleanup and removes unecessary imports of gdb_prompt, uses prepare_for_testing and clean_restart where needed, and fixes some comments. The testcase was also not correctly testing catching syscalls using only numbers, or catching many syscalls at once. I fixed that. The patch also uses a new method for obtaining the syscalls numbers: it relies on the C source file to get them, via <sys/syscall.h> and SYS_* macros. This makes the .exp file simpler because there is no need to include target conditionals there. I tested this on x86_64 Fedora 18. gdb/testsuite/ChangeLog: 2013-12-18 Sergio Durigan Junior <sergiodj@redhat.com> * gdb.base/catch-syscall.c: Include <sys/syscall.h>. (close_syscall, chroot_syscall, exit_group_syscall): New variables. * gdb.base/catch-syscall.exp: Replace gdb_compile by prepare_for_testing. Call fill_all_syscalls_numbers before starting. Replace gdb_exit, gdb_start, gdb_reinitialize_dir and gdb_load by clean_restart. (check_info_bp_any_syscall, check_info_bp_specific_syscall) (check_info_bp_many_syscalls): Remove global gdb_prompt. (check_call_to_syscall): Likewise. Add global decimal. Improve testing regex. (check_return_from_syscall): Likewise. (check_continue, insert_catch_syscall_with_arg): Remove global gdb_prompt. (insert_catch_syscall_with_many_args): Likewise. Add global decimal. Fix $filter_str. Improve testing regex. (check_for_program_end): Remove global gdb_prompt. (test_catch_syscall_without_args): Likewise. Add global decimal. Improve testing regex. (test_catch_syscall_with_args, test_catch_syscall_with_many_args) (test_catch_syscall_with_wrong_args) (test_catch_syscall_restarting_inferior) (test_catch_syscall_fail_nodatadir): Remove global gdb_prompt. (do_syscall_tests): Likewise. Remove global srcdir. (test_catch_syscall_without_args_noxml): Remove global gdb_prompt. Add global last_syscall_number. Test for the exact syscall number to be caught. (test_catch_syscall_with_args_noxml): Remove global gdb_prompt. Add global all_syscalls_numbers. Test each syscall number to be caught, instead of only testing "close". (test_catch_syscall_with_wrong_args_noxml): Remove global gdb_prompt. (do_syscall_tests_without_xml): Likewise. Remove global srcdir. Remove stale comment. (fill_all_syscalls_numbers): Add global last_syscall_number. Fill the correct syscall numbers using information from the inferior.
2013-12-18 23:19:01 +01:00
global all_syscalls last_syscall decimal
with_test_prefix "without arguments" {
# Trying to set the syscall.
Improve and fix catch-syscall.exp While fixing another bug, I found that the current gdb.base/catch-syscall.exp is kind of messy, could use some improvements, and is not correctly testing some things. I've made the following patch to address all the issues I found. On the organization side, it does a cleanup and removes unecessary imports of gdb_prompt, uses prepare_for_testing and clean_restart where needed, and fixes some comments. The testcase was also not correctly testing catching syscalls using only numbers, or catching many syscalls at once. I fixed that. The patch also uses a new method for obtaining the syscalls numbers: it relies on the C source file to get them, via <sys/syscall.h> and SYS_* macros. This makes the .exp file simpler because there is no need to include target conditionals there. I tested this on x86_64 Fedora 18. gdb/testsuite/ChangeLog: 2013-12-18 Sergio Durigan Junior <sergiodj@redhat.com> * gdb.base/catch-syscall.c: Include <sys/syscall.h>. (close_syscall, chroot_syscall, exit_group_syscall): New variables. * gdb.base/catch-syscall.exp: Replace gdb_compile by prepare_for_testing. Call fill_all_syscalls_numbers before starting. Replace gdb_exit, gdb_start, gdb_reinitialize_dir and gdb_load by clean_restart. (check_info_bp_any_syscall, check_info_bp_specific_syscall) (check_info_bp_many_syscalls): Remove global gdb_prompt. (check_call_to_syscall): Likewise. Add global decimal. Improve testing regex. (check_return_from_syscall): Likewise. (check_continue, insert_catch_syscall_with_arg): Remove global gdb_prompt. (insert_catch_syscall_with_many_args): Likewise. Add global decimal. Fix $filter_str. Improve testing regex. (check_for_program_end): Remove global gdb_prompt. (test_catch_syscall_without_args): Likewise. Add global decimal. Improve testing regex. (test_catch_syscall_with_args, test_catch_syscall_with_many_args) (test_catch_syscall_with_wrong_args) (test_catch_syscall_restarting_inferior) (test_catch_syscall_fail_nodatadir): Remove global gdb_prompt. (do_syscall_tests): Likewise. Remove global srcdir. (test_catch_syscall_without_args_noxml): Remove global gdb_prompt. Add global last_syscall_number. Test for the exact syscall number to be caught. (test_catch_syscall_with_args_noxml): Remove global gdb_prompt. Add global all_syscalls_numbers. Test each syscall number to be caught, instead of only testing "close". (test_catch_syscall_with_wrong_args_noxml): Remove global gdb_prompt. (do_syscall_tests_without_xml): Likewise. Remove global srcdir. Remove stale comment. (fill_all_syscalls_numbers): Add global last_syscall_number. Fill the correct syscall numbers using information from the inferior.
2013-12-18 23:19:01 +01:00
gdb_test "catch syscall" "Catchpoint $decimal \\(any syscall\\)"
check_info_bp_any_syscall
# We have to check every syscall.
foreach name $all_syscalls {
check_continue $name
}
# At last but not least, we check if the inferior has called
# the last (exit) syscall.
check_call_to_syscall $last_syscall
# Now let's see if the inferior correctly finishes.
check_for_program_end
}
}
proc test_catch_syscall_with_args {} {
with_test_prefix "with arguments" {
set syscall_name "close"
insert_catch_syscall_with_arg $syscall_name
# Can we continue until we catch the syscall?
check_continue $syscall_name
# Now let's see if the inferior correctly finishes.
check_for_program_end
}
}
proc test_catch_syscall_with_many_args {} {
with_test_prefix "with many arguments" {
Improve and fix catch-syscall.exp While fixing another bug, I found that the current gdb.base/catch-syscall.exp is kind of messy, could use some improvements, and is not correctly testing some things. I've made the following patch to address all the issues I found. On the organization side, it does a cleanup and removes unecessary imports of gdb_prompt, uses prepare_for_testing and clean_restart where needed, and fixes some comments. The testcase was also not correctly testing catching syscalls using only numbers, or catching many syscalls at once. I fixed that. The patch also uses a new method for obtaining the syscalls numbers: it relies on the C source file to get them, via <sys/syscall.h> and SYS_* macros. This makes the .exp file simpler because there is no need to include target conditionals there. I tested this on x86_64 Fedora 18. gdb/testsuite/ChangeLog: 2013-12-18 Sergio Durigan Junior <sergiodj@redhat.com> * gdb.base/catch-syscall.c: Include <sys/syscall.h>. (close_syscall, chroot_syscall, exit_group_syscall): New variables. * gdb.base/catch-syscall.exp: Replace gdb_compile by prepare_for_testing. Call fill_all_syscalls_numbers before starting. Replace gdb_exit, gdb_start, gdb_reinitialize_dir and gdb_load by clean_restart. (check_info_bp_any_syscall, check_info_bp_specific_syscall) (check_info_bp_many_syscalls): Remove global gdb_prompt. (check_call_to_syscall): Likewise. Add global decimal. Improve testing regex. (check_return_from_syscall): Likewise. (check_continue, insert_catch_syscall_with_arg): Remove global gdb_prompt. (insert_catch_syscall_with_many_args): Likewise. Add global decimal. Fix $filter_str. Improve testing regex. (check_for_program_end): Remove global gdb_prompt. (test_catch_syscall_without_args): Likewise. Add global decimal. Improve testing regex. (test_catch_syscall_with_args, test_catch_syscall_with_many_args) (test_catch_syscall_with_wrong_args) (test_catch_syscall_restarting_inferior) (test_catch_syscall_fail_nodatadir): Remove global gdb_prompt. (do_syscall_tests): Likewise. Remove global srcdir. (test_catch_syscall_without_args_noxml): Remove global gdb_prompt. Add global last_syscall_number. Test for the exact syscall number to be caught. (test_catch_syscall_with_args_noxml): Remove global gdb_prompt. Add global all_syscalls_numbers. Test each syscall number to be caught, instead of only testing "close". (test_catch_syscall_with_wrong_args_noxml): Remove global gdb_prompt. (do_syscall_tests_without_xml): Likewise. Remove global srcdir. Remove stale comment. (fill_all_syscalls_numbers): Add global last_syscall_number. Fill the correct syscall numbers using information from the inferior.
2013-12-18 23:19:01 +01:00
global all_syscalls all_syscalls_numbers
insert_catch_syscall_with_many_args $all_syscalls $all_syscalls_numbers
# Can we continue until we catch the syscalls?
foreach name $all_syscalls {
check_continue $name
}
# Now let's see if the inferior correctly finishes.
check_for_program_end
}
}
proc test_catch_syscall_with_wrong_args {} {
with_test_prefix "wrong args" {
# mlock is not called from the source
set syscall_name "mlock"
insert_catch_syscall_with_arg $syscall_name
# Now, we must verify if the program stops with a continue.
# If it doesn't, everything is right (since we don't have
# a syscall named "mlock" in it). Otherwise, this is a failure.
set thistest "catch syscall with unused syscall ($syscall_name)"
gdb_continue_to_end $thistest
}
}
proc test_catch_syscall_restarting_inferior {} {
with_test_prefix "restarting inferior" {
set syscall_name "chroot"
with_test_prefix "entry" {
insert_catch_syscall_with_arg $syscall_name
# Let's first reach the entry of the syscall.
check_call_to_syscall $syscall_name
}
with_test_prefix "entry/return" {
# Now, restart the program.
rerun_to_main
# And check for entry/return.
check_continue $syscall_name
# Can we finish?
check_for_program_end
}
}
}
proc test_catch_syscall_fail_nodatadir {} {
with_test_prefix "fail no datadir" {
# Sanitizing.
delete_breakpoints
# Make sure GDB doesn't load the syscalls xml from the system
# data directory.
gdb_test_no_output "set data-directory /the/path/to/nowhere"
# Testing to see if we receive a warning when calling "catch
# syscall" without XML support (without datadir).
set thistest "catch syscall displays a warning when there is no XML support"
gdb_test "catch syscall" \
"warning: Could not load the syscall XML file.*warning: GDB will not be able to display syscall names nor to verify if.*any provided syscall numbers are valid.*Catchpoint .*(syscall).*" \
$thistest
# Since the catchpoint was set, we must check if it's present
# in "info breakpoints" output.
check_info_bp_any_syscall
# Sanitizing.
delete_breakpoints
}
}
proc do_syscall_tests {} {
# NOTE: We don't have to point gdb at the correct data-directory.
# For the build tree that is handled by INTERNAL_GDBFLAGS.
# Verify that the 'catch syscall' help is available
set thistest "help catch syscall"
gdb_test "help catch syscall" "Catch system calls.*" $thistest
# Try to set a catchpoint to a nonsense syscall
set thistest "catch syscall to a nonsense syscall is prohibited"
gdb_test "catch syscall nonsense_syscall" "Unknown syscall name .*" $thistest
# Regression test for syscall completer bug.
gdb_test "complete catch syscall close chroo" \
"catch syscall close chroot" \
"complete catch syscall with multiple words"
# Testing the 'catch syscall' command without arguments.
# This test should catch any syscalls.
if [runto_main] then { test_catch_syscall_without_args }
# Testing the 'catch syscall' command with arguments.
# This test should only catch the specified syscall.
if [runto_main] then { test_catch_syscall_with_args }
# Testing the 'catch syscall' command with many arguments.
# This test should catch $all_syscalls.
if [runto_main] then { test_catch_syscall_with_many_args }
# Testing the 'catch syscall' command with WRONG arguments.
# This test should not trigger any catchpoints.
if [runto_main] then { test_catch_syscall_with_wrong_args }
# Testing the 'catch' syscall command during a restart of
# the inferior.
if [runto_main] then { test_catch_syscall_restarting_inferior }
}
proc test_catch_syscall_without_args_noxml {} {
with_test_prefix "without args noxml" {
# We will need the syscall names even not using it because we
# need to know know many syscalls are in the example file.
Improve and fix catch-syscall.exp While fixing another bug, I found that the current gdb.base/catch-syscall.exp is kind of messy, could use some improvements, and is not correctly testing some things. I've made the following patch to address all the issues I found. On the organization side, it does a cleanup and removes unecessary imports of gdb_prompt, uses prepare_for_testing and clean_restart where needed, and fixes some comments. The testcase was also not correctly testing catching syscalls using only numbers, or catching many syscalls at once. I fixed that. The patch also uses a new method for obtaining the syscalls numbers: it relies on the C source file to get them, via <sys/syscall.h> and SYS_* macros. This makes the .exp file simpler because there is no need to include target conditionals there. I tested this on x86_64 Fedora 18. gdb/testsuite/ChangeLog: 2013-12-18 Sergio Durigan Junior <sergiodj@redhat.com> * gdb.base/catch-syscall.c: Include <sys/syscall.h>. (close_syscall, chroot_syscall, exit_group_syscall): New variables. * gdb.base/catch-syscall.exp: Replace gdb_compile by prepare_for_testing. Call fill_all_syscalls_numbers before starting. Replace gdb_exit, gdb_start, gdb_reinitialize_dir and gdb_load by clean_restart. (check_info_bp_any_syscall, check_info_bp_specific_syscall) (check_info_bp_many_syscalls): Remove global gdb_prompt. (check_call_to_syscall): Likewise. Add global decimal. Improve testing regex. (check_return_from_syscall): Likewise. (check_continue, insert_catch_syscall_with_arg): Remove global gdb_prompt. (insert_catch_syscall_with_many_args): Likewise. Add global decimal. Fix $filter_str. Improve testing regex. (check_for_program_end): Remove global gdb_prompt. (test_catch_syscall_without_args): Likewise. Add global decimal. Improve testing regex. (test_catch_syscall_with_args, test_catch_syscall_with_many_args) (test_catch_syscall_with_wrong_args) (test_catch_syscall_restarting_inferior) (test_catch_syscall_fail_nodatadir): Remove global gdb_prompt. (do_syscall_tests): Likewise. Remove global srcdir. (test_catch_syscall_without_args_noxml): Remove global gdb_prompt. Add global last_syscall_number. Test for the exact syscall number to be caught. (test_catch_syscall_with_args_noxml): Remove global gdb_prompt. Add global all_syscalls_numbers. Test each syscall number to be caught, instead of only testing "close". (test_catch_syscall_with_wrong_args_noxml): Remove global gdb_prompt. (do_syscall_tests_without_xml): Likewise. Remove global srcdir. Remove stale comment. (fill_all_syscalls_numbers): Add global last_syscall_number. Fill the correct syscall numbers using information from the inferior.
2013-12-18 23:19:01 +01:00
global all_syscalls last_syscall_number all_syscalls_numbers
delete_breakpoints
gdb_test "catch syscall" "Catchpoint .*(syscall).*"
# Now, we should be able to set a catchpoint, and GDB shall
# not display the warning anymore.
Improve and fix catch-syscall.exp While fixing another bug, I found that the current gdb.base/catch-syscall.exp is kind of messy, could use some improvements, and is not correctly testing some things. I've made the following patch to address all the issues I found. On the organization side, it does a cleanup and removes unecessary imports of gdb_prompt, uses prepare_for_testing and clean_restart where needed, and fixes some comments. The testcase was also not correctly testing catching syscalls using only numbers, or catching many syscalls at once. I fixed that. The patch also uses a new method for obtaining the syscalls numbers: it relies on the C source file to get them, via <sys/syscall.h> and SYS_* macros. This makes the .exp file simpler because there is no need to include target conditionals there. I tested this on x86_64 Fedora 18. gdb/testsuite/ChangeLog: 2013-12-18 Sergio Durigan Junior <sergiodj@redhat.com> * gdb.base/catch-syscall.c: Include <sys/syscall.h>. (close_syscall, chroot_syscall, exit_group_syscall): New variables. * gdb.base/catch-syscall.exp: Replace gdb_compile by prepare_for_testing. Call fill_all_syscalls_numbers before starting. Replace gdb_exit, gdb_start, gdb_reinitialize_dir and gdb_load by clean_restart. (check_info_bp_any_syscall, check_info_bp_specific_syscall) (check_info_bp_many_syscalls): Remove global gdb_prompt. (check_call_to_syscall): Likewise. Add global decimal. Improve testing regex. (check_return_from_syscall): Likewise. (check_continue, insert_catch_syscall_with_arg): Remove global gdb_prompt. (insert_catch_syscall_with_many_args): Likewise. Add global decimal. Fix $filter_str. Improve testing regex. (check_for_program_end): Remove global gdb_prompt. (test_catch_syscall_without_args): Likewise. Add global decimal. Improve testing regex. (test_catch_syscall_with_args, test_catch_syscall_with_many_args) (test_catch_syscall_with_wrong_args) (test_catch_syscall_restarting_inferior) (test_catch_syscall_fail_nodatadir): Remove global gdb_prompt. (do_syscall_tests): Likewise. Remove global srcdir. (test_catch_syscall_without_args_noxml): Remove global gdb_prompt. Add global last_syscall_number. Test for the exact syscall number to be caught. (test_catch_syscall_with_args_noxml): Remove global gdb_prompt. Add global all_syscalls_numbers. Test each syscall number to be caught, instead of only testing "close". (test_catch_syscall_with_wrong_args_noxml): Remove global gdb_prompt. (do_syscall_tests_without_xml): Likewise. Remove global srcdir. Remove stale comment. (fill_all_syscalls_numbers): Add global last_syscall_number. Fill the correct syscall numbers using information from the inferior.
2013-12-18 23:19:01 +01:00
foreach name $all_syscalls number $all_syscalls_numbers {
with_test_prefix "$name" {
Improve and fix catch-syscall.exp While fixing another bug, I found that the current gdb.base/catch-syscall.exp is kind of messy, could use some improvements, and is not correctly testing some things. I've made the following patch to address all the issues I found. On the organization side, it does a cleanup and removes unecessary imports of gdb_prompt, uses prepare_for_testing and clean_restart where needed, and fixes some comments. The testcase was also not correctly testing catching syscalls using only numbers, or catching many syscalls at once. I fixed that. The patch also uses a new method for obtaining the syscalls numbers: it relies on the C source file to get them, via <sys/syscall.h> and SYS_* macros. This makes the .exp file simpler because there is no need to include target conditionals there. I tested this on x86_64 Fedora 18. gdb/testsuite/ChangeLog: 2013-12-18 Sergio Durigan Junior <sergiodj@redhat.com> * gdb.base/catch-syscall.c: Include <sys/syscall.h>. (close_syscall, chroot_syscall, exit_group_syscall): New variables. * gdb.base/catch-syscall.exp: Replace gdb_compile by prepare_for_testing. Call fill_all_syscalls_numbers before starting. Replace gdb_exit, gdb_start, gdb_reinitialize_dir and gdb_load by clean_restart. (check_info_bp_any_syscall, check_info_bp_specific_syscall) (check_info_bp_many_syscalls): Remove global gdb_prompt. (check_call_to_syscall): Likewise. Add global decimal. Improve testing regex. (check_return_from_syscall): Likewise. (check_continue, insert_catch_syscall_with_arg): Remove global gdb_prompt. (insert_catch_syscall_with_many_args): Likewise. Add global decimal. Fix $filter_str. Improve testing regex. (check_for_program_end): Remove global gdb_prompt. (test_catch_syscall_without_args): Likewise. Add global decimal. Improve testing regex. (test_catch_syscall_with_args, test_catch_syscall_with_many_args) (test_catch_syscall_with_wrong_args) (test_catch_syscall_restarting_inferior) (test_catch_syscall_fail_nodatadir): Remove global gdb_prompt. (do_syscall_tests): Likewise. Remove global srcdir. (test_catch_syscall_without_args_noxml): Remove global gdb_prompt. Add global last_syscall_number. Test for the exact syscall number to be caught. (test_catch_syscall_with_args_noxml): Remove global gdb_prompt. Add global all_syscalls_numbers. Test each syscall number to be caught, instead of only testing "close". (test_catch_syscall_with_wrong_args_noxml): Remove global gdb_prompt. (do_syscall_tests_without_xml): Likewise. Remove global srcdir. Remove stale comment. (fill_all_syscalls_numbers): Add global last_syscall_number. Fill the correct syscall numbers using information from the inferior.
2013-12-18 23:19:01 +01:00
check_continue $number
}
}
# At last but not least, we check if the inferior has called
# the last (exit) syscall.
Improve and fix catch-syscall.exp While fixing another bug, I found that the current gdb.base/catch-syscall.exp is kind of messy, could use some improvements, and is not correctly testing some things. I've made the following patch to address all the issues I found. On the organization side, it does a cleanup and removes unecessary imports of gdb_prompt, uses prepare_for_testing and clean_restart where needed, and fixes some comments. The testcase was also not correctly testing catching syscalls using only numbers, or catching many syscalls at once. I fixed that. The patch also uses a new method for obtaining the syscalls numbers: it relies on the C source file to get them, via <sys/syscall.h> and SYS_* macros. This makes the .exp file simpler because there is no need to include target conditionals there. I tested this on x86_64 Fedora 18. gdb/testsuite/ChangeLog: 2013-12-18 Sergio Durigan Junior <sergiodj@redhat.com> * gdb.base/catch-syscall.c: Include <sys/syscall.h>. (close_syscall, chroot_syscall, exit_group_syscall): New variables. * gdb.base/catch-syscall.exp: Replace gdb_compile by prepare_for_testing. Call fill_all_syscalls_numbers before starting. Replace gdb_exit, gdb_start, gdb_reinitialize_dir and gdb_load by clean_restart. (check_info_bp_any_syscall, check_info_bp_specific_syscall) (check_info_bp_many_syscalls): Remove global gdb_prompt. (check_call_to_syscall): Likewise. Add global decimal. Improve testing regex. (check_return_from_syscall): Likewise. (check_continue, insert_catch_syscall_with_arg): Remove global gdb_prompt. (insert_catch_syscall_with_many_args): Likewise. Add global decimal. Fix $filter_str. Improve testing regex. (check_for_program_end): Remove global gdb_prompt. (test_catch_syscall_without_args): Likewise. Add global decimal. Improve testing regex. (test_catch_syscall_with_args, test_catch_syscall_with_many_args) (test_catch_syscall_with_wrong_args) (test_catch_syscall_restarting_inferior) (test_catch_syscall_fail_nodatadir): Remove global gdb_prompt. (do_syscall_tests): Likewise. Remove global srcdir. (test_catch_syscall_without_args_noxml): Remove global gdb_prompt. Add global last_syscall_number. Test for the exact syscall number to be caught. (test_catch_syscall_with_args_noxml): Remove global gdb_prompt. Add global all_syscalls_numbers. Test each syscall number to be caught, instead of only testing "close". (test_catch_syscall_with_wrong_args_noxml): Remove global gdb_prompt. (do_syscall_tests_without_xml): Likewise. Remove global srcdir. Remove stale comment. (fill_all_syscalls_numbers): Add global last_syscall_number. Fill the correct syscall numbers using information from the inferior.
2013-12-18 23:19:01 +01:00
check_call_to_syscall $last_syscall_number
delete_breakpoints
}
}
proc test_catch_syscall_with_args_noxml {} {
with_test_prefix "with args noxml" {
Improve and fix catch-syscall.exp While fixing another bug, I found that the current gdb.base/catch-syscall.exp is kind of messy, could use some improvements, and is not correctly testing some things. I've made the following patch to address all the issues I found. On the organization side, it does a cleanup and removes unecessary imports of gdb_prompt, uses prepare_for_testing and clean_restart where needed, and fixes some comments. The testcase was also not correctly testing catching syscalls using only numbers, or catching many syscalls at once. I fixed that. The patch also uses a new method for obtaining the syscalls numbers: it relies on the C source file to get them, via <sys/syscall.h> and SYS_* macros. This makes the .exp file simpler because there is no need to include target conditionals there. I tested this on x86_64 Fedora 18. gdb/testsuite/ChangeLog: 2013-12-18 Sergio Durigan Junior <sergiodj@redhat.com> * gdb.base/catch-syscall.c: Include <sys/syscall.h>. (close_syscall, chroot_syscall, exit_group_syscall): New variables. * gdb.base/catch-syscall.exp: Replace gdb_compile by prepare_for_testing. Call fill_all_syscalls_numbers before starting. Replace gdb_exit, gdb_start, gdb_reinitialize_dir and gdb_load by clean_restart. (check_info_bp_any_syscall, check_info_bp_specific_syscall) (check_info_bp_many_syscalls): Remove global gdb_prompt. (check_call_to_syscall): Likewise. Add global decimal. Improve testing regex. (check_return_from_syscall): Likewise. (check_continue, insert_catch_syscall_with_arg): Remove global gdb_prompt. (insert_catch_syscall_with_many_args): Likewise. Add global decimal. Fix $filter_str. Improve testing regex. (check_for_program_end): Remove global gdb_prompt. (test_catch_syscall_without_args): Likewise. Add global decimal. Improve testing regex. (test_catch_syscall_with_args, test_catch_syscall_with_many_args) (test_catch_syscall_with_wrong_args) (test_catch_syscall_restarting_inferior) (test_catch_syscall_fail_nodatadir): Remove global gdb_prompt. (do_syscall_tests): Likewise. Remove global srcdir. (test_catch_syscall_without_args_noxml): Remove global gdb_prompt. Add global last_syscall_number. Test for the exact syscall number to be caught. (test_catch_syscall_with_args_noxml): Remove global gdb_prompt. Add global all_syscalls_numbers. Test each syscall number to be caught, instead of only testing "close". (test_catch_syscall_with_wrong_args_noxml): Remove global gdb_prompt. (do_syscall_tests_without_xml): Likewise. Remove global srcdir. Remove stale comment. (fill_all_syscalls_numbers): Add global last_syscall_number. Fill the correct syscall numbers using information from the inferior.
2013-12-18 23:19:01 +01:00
global all_syscalls_numbers
delete_breakpoints
Improve and fix catch-syscall.exp While fixing another bug, I found that the current gdb.base/catch-syscall.exp is kind of messy, could use some improvements, and is not correctly testing some things. I've made the following patch to address all the issues I found. On the organization side, it does a cleanup and removes unecessary imports of gdb_prompt, uses prepare_for_testing and clean_restart where needed, and fixes some comments. The testcase was also not correctly testing catching syscalls using only numbers, or catching many syscalls at once. I fixed that. The patch also uses a new method for obtaining the syscalls numbers: it relies on the C source file to get them, via <sys/syscall.h> and SYS_* macros. This makes the .exp file simpler because there is no need to include target conditionals there. I tested this on x86_64 Fedora 18. gdb/testsuite/ChangeLog: 2013-12-18 Sergio Durigan Junior <sergiodj@redhat.com> * gdb.base/catch-syscall.c: Include <sys/syscall.h>. (close_syscall, chroot_syscall, exit_group_syscall): New variables. * gdb.base/catch-syscall.exp: Replace gdb_compile by prepare_for_testing. Call fill_all_syscalls_numbers before starting. Replace gdb_exit, gdb_start, gdb_reinitialize_dir and gdb_load by clean_restart. (check_info_bp_any_syscall, check_info_bp_specific_syscall) (check_info_bp_many_syscalls): Remove global gdb_prompt. (check_call_to_syscall): Likewise. Add global decimal. Improve testing regex. (check_return_from_syscall): Likewise. (check_continue, insert_catch_syscall_with_arg): Remove global gdb_prompt. (insert_catch_syscall_with_many_args): Likewise. Add global decimal. Fix $filter_str. Improve testing regex. (check_for_program_end): Remove global gdb_prompt. (test_catch_syscall_without_args): Likewise. Add global decimal. Improve testing regex. (test_catch_syscall_with_args, test_catch_syscall_with_many_args) (test_catch_syscall_with_wrong_args) (test_catch_syscall_restarting_inferior) (test_catch_syscall_fail_nodatadir): Remove global gdb_prompt. (do_syscall_tests): Likewise. Remove global srcdir. (test_catch_syscall_without_args_noxml): Remove global gdb_prompt. Add global last_syscall_number. Test for the exact syscall number to be caught. (test_catch_syscall_with_args_noxml): Remove global gdb_prompt. Add global all_syscalls_numbers. Test each syscall number to be caught, instead of only testing "close". (test_catch_syscall_with_wrong_args_noxml): Remove global gdb_prompt. (do_syscall_tests_without_xml): Likewise. Remove global srcdir. Remove stale comment. (fill_all_syscalls_numbers): Add global last_syscall_number. Fill the correct syscall numbers using information from the inferior.
2013-12-18 23:19:01 +01:00
# Inserting all syscalls numbers to be caught
foreach syscall_number $all_syscalls_numbers {
insert_catch_syscall_with_arg $syscall_number
}
Improve and fix catch-syscall.exp While fixing another bug, I found that the current gdb.base/catch-syscall.exp is kind of messy, could use some improvements, and is not correctly testing some things. I've made the following patch to address all the issues I found. On the organization side, it does a cleanup and removes unecessary imports of gdb_prompt, uses prepare_for_testing and clean_restart where needed, and fixes some comments. The testcase was also not correctly testing catching syscalls using only numbers, or catching many syscalls at once. I fixed that. The patch also uses a new method for obtaining the syscalls numbers: it relies on the C source file to get them, via <sys/syscall.h> and SYS_* macros. This makes the .exp file simpler because there is no need to include target conditionals there. I tested this on x86_64 Fedora 18. gdb/testsuite/ChangeLog: 2013-12-18 Sergio Durigan Junior <sergiodj@redhat.com> * gdb.base/catch-syscall.c: Include <sys/syscall.h>. (close_syscall, chroot_syscall, exit_group_syscall): New variables. * gdb.base/catch-syscall.exp: Replace gdb_compile by prepare_for_testing. Call fill_all_syscalls_numbers before starting. Replace gdb_exit, gdb_start, gdb_reinitialize_dir and gdb_load by clean_restart. (check_info_bp_any_syscall, check_info_bp_specific_syscall) (check_info_bp_many_syscalls): Remove global gdb_prompt. (check_call_to_syscall): Likewise. Add global decimal. Improve testing regex. (check_return_from_syscall): Likewise. (check_continue, insert_catch_syscall_with_arg): Remove global gdb_prompt. (insert_catch_syscall_with_many_args): Likewise. Add global decimal. Fix $filter_str. Improve testing regex. (check_for_program_end): Remove global gdb_prompt. (test_catch_syscall_without_args): Likewise. Add global decimal. Improve testing regex. (test_catch_syscall_with_args, test_catch_syscall_with_many_args) (test_catch_syscall_with_wrong_args) (test_catch_syscall_restarting_inferior) (test_catch_syscall_fail_nodatadir): Remove global gdb_prompt. (do_syscall_tests): Likewise. Remove global srcdir. (test_catch_syscall_without_args_noxml): Remove global gdb_prompt. Add global last_syscall_number. Test for the exact syscall number to be caught. (test_catch_syscall_with_args_noxml): Remove global gdb_prompt. Add global all_syscalls_numbers. Test each syscall number to be caught, instead of only testing "close". (test_catch_syscall_with_wrong_args_noxml): Remove global gdb_prompt. (do_syscall_tests_without_xml): Likewise. Remove global srcdir. Remove stale comment. (fill_all_syscalls_numbers): Add global last_syscall_number. Fill the correct syscall numbers using information from the inferior.
2013-12-18 23:19:01 +01:00
# Checking that all syscalls are caught.
foreach syscall_number $all_syscalls_numbers {
check_continue $syscall_number
}
delete_breakpoints
}
}
proc test_catch_syscall_with_wrong_args_noxml {} {
with_test_prefix "with wrong args noxml" {
delete_breakpoints
# Even without XML support, GDB should not accept unknown
# syscall names for the catchpoint.
gdb_test "catch syscall nonsense_syscall" \
"Unknown syscall name .nonsense_syscall.*"
delete_breakpoints
}
}
proc do_syscall_tests_without_xml {} {
# Make sure GDB doesn't load the syscalls xml from the system data
# directory.
2010-06-01 Michael Snyder <msnyder@vmware.com> * gdb.base/arithmet.exp: Use gdb_test_no_output. * gdb.base/arrayidx.exp: Ditto. * gdb.base/attach.exp: Ditto. * gdb.base/auxv.exp: Ditto. * gdb.base/bigcre.exp: Ditto. * gdb.base/break-always.exp: Ditto. * gdb.base/break-interp.exp: Ditto. * gdb.base/break.exp: Ditto. * gdb.base/breakpoint-shadow.exp: Ditto. * gdb.base/call-ar-st.exp: Ditto. * gdb.base/call-sc.exp: Ditto. * gdb.base/call-signal-resume.exp: Ditto. * gdb.base/callfuncs.exp: Ditto. * gdb.base/catch-syscall.exp: Ditto. * gdb.base/charset.exp: Ditto. * gdb.base/code-expr.exp: Ditto. * gdb.base/commands.exp: Ditto. * gdb.base/cond-expr.exp: Ditto. * gdb.base/condbreak.exp: Ditto. * gdb.base/cursal.exp: Ditto. * gdb.base/cvexpr.exp: Ditto. * gdb.base/default.exp: Ditto. * gdb.base/del.exp: Ditto. * gdb.base/detach.exp: Ditto. * gdb.base/display.exp: Ditto. * gdb.base/ena-dis-br.exp: Ditto. * gdb.base/eval-skip.exp: Ditto. * gdb.base/foll-fork.exp: Ditto. * gdb.base/foll-vfork.exp: Ditto. * gdb.base/frame-args.exp: Ditto. * gdb.base/funcargs.exp: Ditto. * gdb.base/gcore-buffer-overflow.exp: Ditto. * gdb.base/gdbvars.exp: Ditto. * gdb.base/help.exp: Ditto. * gdb.base/ifelse.exp: Ditto. * gdb.base/included.exp: Ditto. * gdb.base/list.exp: Ditto. * gdb.base/macscp.exp: Ditto. * gdb.base/maint.exp: Ditto. * gdb.base/multi-fork.exp: Ditto. * gdb.base/overlays.exp: Ditto. * gdb.base/page.exp: Ditto. * gdb.base/pending.exp: Ditto. * gdb.base/pointers.exp: Ditto. * gdb.base/pr11022.exp: Ditto. * gdb.base/prelink.exp: Ditto. * gdb.base/printcmds.exp: Ditto. * gdb.base/psymtab.exp: Ditto. * gdb.base/randomize.exp: Ditto. * gdb.base/relational.exp: Ditto. * gdb.base/relocate.exp: Ditto. * gdb.base/remote.exp: Ditto. * gdb.base/sepdebug.exp: Ditto. * gdb.base/set-lang-auto.exp: Ditto. * gdb.base/setshow.exp: Ditto. * gdb.base/setvar.exp: Ditto. * gdb.base/signals.exp: Ditto. * gdb.base/signull.exp: Ditto. * gdb.base/sigstep.exp: Ditto. * gdb.base/sizeof.exp: Ditto. * gdb.base/solib-disc.exp: Ditto. * gdb.base/store.exp: Ditto. * gdb.base/structs.exp: Ditto. * gdb.base/structs2.exp: Ditto. * gdb.base/subst.exp: Ditto. * gdb.base/term.exp: Ditto. * gdb.base/trace-commands.exp: Ditto. * gdb.base/unwindonsignal.exp: Ditto. * gdb.base/valgrind-db-attach.exp: Ditto. * gdb.base/varargs.exp: Ditto. * gdb.base/watch-cond.exp: Ditto. * gdb.base/watch_thread_num.exp: Ditto. * gdb.base/watchpoint-cond-gone.exp: Ditto. * gdb.base/watchpoint.exp: Ditto. * gdb.base/whatis-exp.exp: Ditto.
2010-06-01 23:29:21 +02:00
gdb_test_no_output "set data-directory /the/path/to/nowhere"
# Let's test if we can catch syscalls without XML support.
# We should succeed, but GDB is not supposed to print syscall names.
if [runto_main] then { test_catch_syscall_without_args_noxml }
# The only valid argument "catch syscall" should accept is the
# syscall number, and not the name (since it can't translate a
# name to a number).
if [runto_main] then { test_catch_syscall_with_args_noxml }
# Now, we'll try to provide a syscall name (valid or not) to the command,
# and expect it to fail.
if [runto_main] then { test_catch_syscall_with_wrong_args_noxml }
}
# This procedure fills the vector "all_syscalls_numbers" with the proper
# numbers for the used syscalls according to the architecture.
proc fill_all_syscalls_numbers {} {
Fix PR breakpoints/16297: catch syscall with syscall 0 Code rationale ============== by: Gabriel Krisman Bertazi This is a fix for bug 16297. The problem occurs when the user attempts to catch any syscall 0 (such as syscall read on Linux/x86_64). GDB was not able to catch the syscall and was missing the breakpoint. Now, breakpoint_hit_catch_syscall returns immediately when it finds the correct syscall number, avoiding a following check for the end of the search vector, that returns a no hit if the syscall number was zero. Testcase rationale ================== by: Sergio Durigan Junior This testcase is a little difficult to write. By doing a quick inspection at the Linux source, one can see that, in many targets, the syscall number 0 is restart_syscall, which is forbidden to be called from userspace. Therefore, on many targets, there's just no way to test this safely. My decision was to take the simpler route and just adds the "read" syscall on the default test. Its number on x86_64 is zero, which is "good enough" since many people here do their tests on x86_64 anyway and it is a popular architecture. However, there was another little gotcha. When using "read" passing 0 as the third parameter (i.e., asking it to read 0 bytes), current libc implementations could choose not to effectively call the syscall. Therefore, the best solution was to create a temporary pipe, write 1 byte into it, and then read this byte from it. gdb/ChangeLog 2013-12-19 Gabriel Krisman Bertazi <gabriel@krisman.be> PR breakpoints/16297 * breakpoint.c (breakpoint_hit_catch_syscall): Return immediately when expected syscall is hit. gdb/testsuite/ChangeLog 2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com> PR breakpoints/16297 * gdb.base/catch-syscall.c (read_syscall, pipe_syscall) (write_syscall): New variables. (main): Create a pipe, write 1 byte in it, and read 1 byte from it. * gdb.base/catch-syscall.exp (all_syscalls): Include "pipe, "write" and "read" syscalls. (fill_all_syscalls_numbers): Improve the way to obtain syscalls numbers.
2013-12-19 20:01:49 +01:00
global all_syscalls_numbers last_syscall_number all_syscalls
foreach syscall $all_syscalls {
lappend all_syscalls_numbers [get_integer_valueof "${syscall}_syscall" -1]
}
Improve and fix catch-syscall.exp While fixing another bug, I found that the current gdb.base/catch-syscall.exp is kind of messy, could use some improvements, and is not correctly testing some things. I've made the following patch to address all the issues I found. On the organization side, it does a cleanup and removes unecessary imports of gdb_prompt, uses prepare_for_testing and clean_restart where needed, and fixes some comments. The testcase was also not correctly testing catching syscalls using only numbers, or catching many syscalls at once. I fixed that. The patch also uses a new method for obtaining the syscalls numbers: it relies on the C source file to get them, via <sys/syscall.h> and SYS_* macros. This makes the .exp file simpler because there is no need to include target conditionals there. I tested this on x86_64 Fedora 18. gdb/testsuite/ChangeLog: 2013-12-18 Sergio Durigan Junior <sergiodj@redhat.com> * gdb.base/catch-syscall.c: Include <sys/syscall.h>. (close_syscall, chroot_syscall, exit_group_syscall): New variables. * gdb.base/catch-syscall.exp: Replace gdb_compile by prepare_for_testing. Call fill_all_syscalls_numbers before starting. Replace gdb_exit, gdb_start, gdb_reinitialize_dir and gdb_load by clean_restart. (check_info_bp_any_syscall, check_info_bp_specific_syscall) (check_info_bp_many_syscalls): Remove global gdb_prompt. (check_call_to_syscall): Likewise. Add global decimal. Improve testing regex. (check_return_from_syscall): Likewise. (check_continue, insert_catch_syscall_with_arg): Remove global gdb_prompt. (insert_catch_syscall_with_many_args): Likewise. Add global decimal. Fix $filter_str. Improve testing regex. (check_for_program_end): Remove global gdb_prompt. (test_catch_syscall_without_args): Likewise. Add global decimal. Improve testing regex. (test_catch_syscall_with_args, test_catch_syscall_with_many_args) (test_catch_syscall_with_wrong_args) (test_catch_syscall_restarting_inferior) (test_catch_syscall_fail_nodatadir): Remove global gdb_prompt. (do_syscall_tests): Likewise. Remove global srcdir. (test_catch_syscall_without_args_noxml): Remove global gdb_prompt. Add global last_syscall_number. Test for the exact syscall number to be caught. (test_catch_syscall_with_args_noxml): Remove global gdb_prompt. Add global all_syscalls_numbers. Test each syscall number to be caught, instead of only testing "close". (test_catch_syscall_with_wrong_args_noxml): Remove global gdb_prompt. (do_syscall_tests_without_xml): Likewise. Remove global srcdir. Remove stale comment. (fill_all_syscalls_numbers): Add global last_syscall_number. Fill the correct syscall numbers using information from the inferior.
2013-12-18 23:19:01 +01:00
set last_syscall_number [get_integer_valueof "exit_group_syscall" -1]
}
Improve and fix catch-syscall.exp While fixing another bug, I found that the current gdb.base/catch-syscall.exp is kind of messy, could use some improvements, and is not correctly testing some things. I've made the following patch to address all the issues I found. On the organization side, it does a cleanup and removes unecessary imports of gdb_prompt, uses prepare_for_testing and clean_restart where needed, and fixes some comments. The testcase was also not correctly testing catching syscalls using only numbers, or catching many syscalls at once. I fixed that. The patch also uses a new method for obtaining the syscalls numbers: it relies on the C source file to get them, via <sys/syscall.h> and SYS_* macros. This makes the .exp file simpler because there is no need to include target conditionals there. I tested this on x86_64 Fedora 18. gdb/testsuite/ChangeLog: 2013-12-18 Sergio Durigan Junior <sergiodj@redhat.com> * gdb.base/catch-syscall.c: Include <sys/syscall.h>. (close_syscall, chroot_syscall, exit_group_syscall): New variables. * gdb.base/catch-syscall.exp: Replace gdb_compile by prepare_for_testing. Call fill_all_syscalls_numbers before starting. Replace gdb_exit, gdb_start, gdb_reinitialize_dir and gdb_load by clean_restart. (check_info_bp_any_syscall, check_info_bp_specific_syscall) (check_info_bp_many_syscalls): Remove global gdb_prompt. (check_call_to_syscall): Likewise. Add global decimal. Improve testing regex. (check_return_from_syscall): Likewise. (check_continue, insert_catch_syscall_with_arg): Remove global gdb_prompt. (insert_catch_syscall_with_many_args): Likewise. Add global decimal. Fix $filter_str. Improve testing regex. (check_for_program_end): Remove global gdb_prompt. (test_catch_syscall_without_args): Likewise. Add global decimal. Improve testing regex. (test_catch_syscall_with_args, test_catch_syscall_with_many_args) (test_catch_syscall_with_wrong_args) (test_catch_syscall_restarting_inferior) (test_catch_syscall_fail_nodatadir): Remove global gdb_prompt. (do_syscall_tests): Likewise. Remove global srcdir. (test_catch_syscall_without_args_noxml): Remove global gdb_prompt. Add global last_syscall_number. Test for the exact syscall number to be caught. (test_catch_syscall_with_args_noxml): Remove global gdb_prompt. Add global all_syscalls_numbers. Test each syscall number to be caught, instead of only testing "close". (test_catch_syscall_with_wrong_args_noxml): Remove global gdb_prompt. (do_syscall_tests_without_xml): Likewise. Remove global srcdir. Remove stale comment. (fill_all_syscalls_numbers): Add global last_syscall_number. Fill the correct syscall numbers using information from the inferior.
2013-12-18 23:19:01 +01:00
# Fill all the syscalls numbers before starting anything.
fill_all_syscalls_numbers
# Execute the tests, using XML support
Improve and fix catch-syscall.exp While fixing another bug, I found that the current gdb.base/catch-syscall.exp is kind of messy, could use some improvements, and is not correctly testing some things. I've made the following patch to address all the issues I found. On the organization side, it does a cleanup and removes unecessary imports of gdb_prompt, uses prepare_for_testing and clean_restart where needed, and fixes some comments. The testcase was also not correctly testing catching syscalls using only numbers, or catching many syscalls at once. I fixed that. The patch also uses a new method for obtaining the syscalls numbers: it relies on the C source file to get them, via <sys/syscall.h> and SYS_* macros. This makes the .exp file simpler because there is no need to include target conditionals there. I tested this on x86_64 Fedora 18. gdb/testsuite/ChangeLog: 2013-12-18 Sergio Durigan Junior <sergiodj@redhat.com> * gdb.base/catch-syscall.c: Include <sys/syscall.h>. (close_syscall, chroot_syscall, exit_group_syscall): New variables. * gdb.base/catch-syscall.exp: Replace gdb_compile by prepare_for_testing. Call fill_all_syscalls_numbers before starting. Replace gdb_exit, gdb_start, gdb_reinitialize_dir and gdb_load by clean_restart. (check_info_bp_any_syscall, check_info_bp_specific_syscall) (check_info_bp_many_syscalls): Remove global gdb_prompt. (check_call_to_syscall): Likewise. Add global decimal. Improve testing regex. (check_return_from_syscall): Likewise. (check_continue, insert_catch_syscall_with_arg): Remove global gdb_prompt. (insert_catch_syscall_with_many_args): Likewise. Add global decimal. Fix $filter_str. Improve testing regex. (check_for_program_end): Remove global gdb_prompt. (test_catch_syscall_without_args): Likewise. Add global decimal. Improve testing regex. (test_catch_syscall_with_args, test_catch_syscall_with_many_args) (test_catch_syscall_with_wrong_args) (test_catch_syscall_restarting_inferior) (test_catch_syscall_fail_nodatadir): Remove global gdb_prompt. (do_syscall_tests): Likewise. Remove global srcdir. (test_catch_syscall_without_args_noxml): Remove global gdb_prompt. Add global last_syscall_number. Test for the exact syscall number to be caught. (test_catch_syscall_with_args_noxml): Remove global gdb_prompt. Add global all_syscalls_numbers. Test each syscall number to be caught, instead of only testing "close". (test_catch_syscall_with_wrong_args_noxml): Remove global gdb_prompt. (do_syscall_tests_without_xml): Likewise. Remove global srcdir. Remove stale comment. (fill_all_syscalls_numbers): Add global last_syscall_number. Fill the correct syscall numbers using information from the inferior.
2013-12-18 23:19:01 +01:00
if { ![gdb_skip_xml_test] } {
clean_restart $binfile
do_syscall_tests
# Now, we have to see if GDB displays a warning when we
# don't set the data-directory but try to use catch syscall
# anyway. For that, we must restart GDB first.
Improve and fix catch-syscall.exp While fixing another bug, I found that the current gdb.base/catch-syscall.exp is kind of messy, could use some improvements, and is not correctly testing some things. I've made the following patch to address all the issues I found. On the organization side, it does a cleanup and removes unecessary imports of gdb_prompt, uses prepare_for_testing and clean_restart where needed, and fixes some comments. The testcase was also not correctly testing catching syscalls using only numbers, or catching many syscalls at once. I fixed that. The patch also uses a new method for obtaining the syscalls numbers: it relies on the C source file to get them, via <sys/syscall.h> and SYS_* macros. This makes the .exp file simpler because there is no need to include target conditionals there. I tested this on x86_64 Fedora 18. gdb/testsuite/ChangeLog: 2013-12-18 Sergio Durigan Junior <sergiodj@redhat.com> * gdb.base/catch-syscall.c: Include <sys/syscall.h>. (close_syscall, chroot_syscall, exit_group_syscall): New variables. * gdb.base/catch-syscall.exp: Replace gdb_compile by prepare_for_testing. Call fill_all_syscalls_numbers before starting. Replace gdb_exit, gdb_start, gdb_reinitialize_dir and gdb_load by clean_restart. (check_info_bp_any_syscall, check_info_bp_specific_syscall) (check_info_bp_many_syscalls): Remove global gdb_prompt. (check_call_to_syscall): Likewise. Add global decimal. Improve testing regex. (check_return_from_syscall): Likewise. (check_continue, insert_catch_syscall_with_arg): Remove global gdb_prompt. (insert_catch_syscall_with_many_args): Likewise. Add global decimal. Fix $filter_str. Improve testing regex. (check_for_program_end): Remove global gdb_prompt. (test_catch_syscall_without_args): Likewise. Add global decimal. Improve testing regex. (test_catch_syscall_with_args, test_catch_syscall_with_many_args) (test_catch_syscall_with_wrong_args) (test_catch_syscall_restarting_inferior) (test_catch_syscall_fail_nodatadir): Remove global gdb_prompt. (do_syscall_tests): Likewise. Remove global srcdir. (test_catch_syscall_without_args_noxml): Remove global gdb_prompt. Add global last_syscall_number. Test for the exact syscall number to be caught. (test_catch_syscall_with_args_noxml): Remove global gdb_prompt. Add global all_syscalls_numbers. Test each syscall number to be caught, instead of only testing "close". (test_catch_syscall_with_wrong_args_noxml): Remove global gdb_prompt. (do_syscall_tests_without_xml): Likewise. Remove global srcdir. Remove stale comment. (fill_all_syscalls_numbers): Add global last_syscall_number. Fill the correct syscall numbers using information from the inferior.
2013-12-18 23:19:01 +01:00
clean_restart $binfile
test_catch_syscall_fail_nodatadir
}
# Restart gdb
Improve and fix catch-syscall.exp While fixing another bug, I found that the current gdb.base/catch-syscall.exp is kind of messy, could use some improvements, and is not correctly testing some things. I've made the following patch to address all the issues I found. On the organization side, it does a cleanup and removes unecessary imports of gdb_prompt, uses prepare_for_testing and clean_restart where needed, and fixes some comments. The testcase was also not correctly testing catching syscalls using only numbers, or catching many syscalls at once. I fixed that. The patch also uses a new method for obtaining the syscalls numbers: it relies on the C source file to get them, via <sys/syscall.h> and SYS_* macros. This makes the .exp file simpler because there is no need to include target conditionals there. I tested this on x86_64 Fedora 18. gdb/testsuite/ChangeLog: 2013-12-18 Sergio Durigan Junior <sergiodj@redhat.com> * gdb.base/catch-syscall.c: Include <sys/syscall.h>. (close_syscall, chroot_syscall, exit_group_syscall): New variables. * gdb.base/catch-syscall.exp: Replace gdb_compile by prepare_for_testing. Call fill_all_syscalls_numbers before starting. Replace gdb_exit, gdb_start, gdb_reinitialize_dir and gdb_load by clean_restart. (check_info_bp_any_syscall, check_info_bp_specific_syscall) (check_info_bp_many_syscalls): Remove global gdb_prompt. (check_call_to_syscall): Likewise. Add global decimal. Improve testing regex. (check_return_from_syscall): Likewise. (check_continue, insert_catch_syscall_with_arg): Remove global gdb_prompt. (insert_catch_syscall_with_many_args): Likewise. Add global decimal. Fix $filter_str. Improve testing regex. (check_for_program_end): Remove global gdb_prompt. (test_catch_syscall_without_args): Likewise. Add global decimal. Improve testing regex. (test_catch_syscall_with_args, test_catch_syscall_with_many_args) (test_catch_syscall_with_wrong_args) (test_catch_syscall_restarting_inferior) (test_catch_syscall_fail_nodatadir): Remove global gdb_prompt. (do_syscall_tests): Likewise. Remove global srcdir. (test_catch_syscall_without_args_noxml): Remove global gdb_prompt. Add global last_syscall_number. Test for the exact syscall number to be caught. (test_catch_syscall_with_args_noxml): Remove global gdb_prompt. Add global all_syscalls_numbers. Test each syscall number to be caught, instead of only testing "close". (test_catch_syscall_with_wrong_args_noxml): Remove global gdb_prompt. (do_syscall_tests_without_xml): Likewise. Remove global srcdir. Remove stale comment. (fill_all_syscalls_numbers): Add global last_syscall_number. Fill the correct syscall numbers using information from the inferior.
2013-12-18 23:19:01 +01:00
clean_restart $binfile
# Execute the tests, without XML support. In this case, GDB will
# only display syscall numbers, and not syscall names.
do_syscall_tests_without_xml