Improve and fix catch-syscall.exp
authorSergio Durigan Junior <sergiodj@redhat.com>
Wed, 18 Dec 2013 22:19:01 +0000 (20:19 -0200)
committerSergio Durigan Junior <sergiodj@redhat.com>
Wed, 18 Dec 2013 22:19:01 +0000 (20:19 -0200)
commit2e0d821f2db9d3ffe06c3532993584d484b04699
treebddc1cf896782125f40c7facef816e9008d0f749
parent3f06bfce701d5060c7a11c827742b86dc385b4b4
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.
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/catch-syscall.c
gdb/testsuite/gdb.base/catch-syscall.exp