aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorSergio Durigan Junior <sergiodj@redhat.com>2014-11-20 12:28:18 -0500
committerSergio Durigan Junior <sergiodj@redhat.com>2014-11-20 12:28:18 -0500
commit458c8db89f7e9913da6fa67c3df73404375c436b (patch)
tree9eb13211e2927b1ae6a0b08d3ee88dd8eebecdda /gdb/testsuite
parentd840c081f8082e8b9e63fead5306643975a97bb3 (diff)
downloadgdb-458c8db89f7e9913da6fa67c3df73404375c436b.zip
gdb-458c8db89f7e9913da6fa67c3df73404375c436b.tar.gz
gdb-458c8db89f7e9913da6fa67c3df73404375c436b.tar.bz2
Partial fix for PR breakpoints/10737: Make syscall info be per-arch instead of global
This patch intends to partially fix PR breakpoints/10737, which is about making the syscall information (for the "catch syscall" command) be per-arch, instead of global. This is not a full fix because of the other issues pointed by Pedro here: <https://sourceware.org/bugzilla/show_bug.cgi?id=10737#c5> However, I consider it a good step towards the real fix. It will also help me fix <https://sourceware.org/bugzilla/show_bug.cgi?id=17402>. What this patch does, basically, is move the "syscalls_info" struct to gdbarch. Currently, the syscall information is stored in a global variable inside gdb/xml-syscall.c, which means that there is no easy way to correlate this info with the current target or architecture being used, for example. This causes strange behaviors, because the syscall info is not re-read when the arch changes. For example, if you put a syscall catchpoint in syscall 5 on i386 (syscall open), and then load a x86_64 program on GDB and put the same syscall 5 there (fstat on x86_64), you will still see that GDB tells you that it is catching "open", even though it is not. With this patch, GDB correctly says that it will be catching fstat syscalls. (gdb) set architecture i386 The target architecture is assumed to be i386 (gdb) catch syscall 5 Catchpoint 1 (syscall 'open' [5]) (gdb) set architecture i386:x86-64 The target architecture is assumed to be i386:x86-64 (gdb) catch syscall 5 Catchpoint 2 (syscall 'open' [5]) But with the patch: (gdb) set architecture i386 The target architecture is assumed to be i386 (gdb) catch syscall 5 Catchpoint 1 (syscall 'open' [5]) (gdb) set architecture i386:x86-64 The target architecture is assumed to be i386:x86-64 (gdb) catch syscall 5 Catchpoint 2 (syscall 'fstat' [5]) As I said, there are still some problems on the "catch syscall" mechanism, because (for example) the user should be able to "catch syscall open" on i386, and then expect "open" to be caught also on x86_64. Currently, it doesn't work. I intend to work on this later. gdb/ 2014-11-20 Sergio Durigan Junior <sergiodj@redhat.com> PR breakpoints/10737 * amd64-linux-tdep.c (amd64_linux_init_abi_common): Adjust call to set_xml_syscall_file_name to provide gdbarch. * arm-linux-tdep.c (arm_linux_init_abi): Likewise. * bfin-linux-tdep.c (bfin_linux_init_abi): Likewise. * breakpoint.c (print_it_catch_syscall): Adjust call to get_syscall_by_number to provide gdbarch. (print_one_catch_syscall): Likewise. (print_mention_catch_syscall): Likewise. (print_recreate_catch_syscall): Likewise. (catch_syscall_split_args): Adjust calls to get_syscall_by_number and get_syscall_by_name to provide gdbarch. (catch_syscall_completer): Adjust call to get_syscall_names to provide gdbarch. * gdbarch.c: Regenerate. * gdbarch.h: Likewise. * gdbarch.sh: Forward declare "struct syscalls_info". (xml_syscall_file): New variable. (syscalls_info): Likewise. * i386-linux-tdep.c (i386_linux_init_abi): Adjust call to set_xml_syscall_file_name to provide gdbarch. * mips-linux-tdep.c (mips_linux_init_abi): Likewise. * ppc-linux-tdep.c (ppc_linux_init_abi): Likewise. * s390-linux-tdep.c (s390_gdbarch_init): Likewise. * sparc-linux-tdep.c (sparc32_linux_init_abi): Likewise. * sparc64-linux-tdep.c (sparc64_linux_init_abi): Likewise. * xml-syscall.c: Include gdbarch.h. (set_xml_syscall_file_name): Accept gdbarch parameter. (get_syscall_by_number): Likewise. (get_syscall_by_name): Likewise. (get_syscall_names): Likewise. (my_gdb_datadir): Delete global variable. (struct syscalls_info) <my_gdb_datadir>: New variable. (struct syscalls_info) <sysinfo>: Rename variable to "syscalls_info". (sysinfo): Delete global variable. (have_initialized_sysinfo): Likewise. (xml_syscall_file): Likewise. (sysinfo_free_syscalls_desc): Rename to... (syscalls_info_free_syscalls_desc): ... this. (free_syscalls_info): Rename "sysinfo" to "syscalls_info". Adjust code to the new layout of "struct syscalls_info". (make_cleanup_free_syscalls_info): Rename parameter "sysinfo" to "syscalls_info". (syscall_create_syscall_desc): Likewise. (syscall_start_syscall): Likewise. (syscall_parse_xml): Likewise. (xml_init_syscalls_info): Likewise. Drop "const" from return value. (init_sysinfo): Rename to... (init_syscalls_info): ...this. Add gdbarch as a parameter. Adjust function to deal with gdbarch. (xml_get_syscall_number): Delete parameter sysinfo. Accept gdbarch as a parameter. Adjust code. (xml_get_syscall_name): Likewise. (xml_list_of_syscalls): Likewise. (set_xml_syscall_file_name): Accept gdbarch as parameter. (get_syscall_by_number): Likewise. (get_syscall_by_name): Likewise. (get_syscall_names): Likewise. * xml-syscall.h (set_xml_syscall_file_name): Likewise. (get_syscall_by_number): Likewise. (get_syscall_by_name): Likewise. (get_syscall_names): Likewise. gdb/testsuite/ 2014-11-20 Sergio Durigan Junior <sergiodj@redhat.com> PR breakpoints/10737 * gdb.base/catch-syscall.exp (do_syscall_tests): Call test_catch_syscall_multi_arch. (test_catch_syscall_multi_arch): New function.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/ChangeLog7
-rw-r--r--gdb/testsuite/gdb.base/catch-syscall.exp71
2 files changed, 78 insertions, 0 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index fd1abfc..908ea49 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2014-11-20 Sergio Durigan Junior <sergiodj@redhat.com>
+
+ PR breakpoints/10737
+ * gdb.base/catch-syscall.exp (do_syscall_tests): Call
+ test_catch_syscall_multi_arch.
+ (test_catch_syscall_multi_arch): New function.
+
2014-11-20 Doug Evans <xdje42@gmail.com>
* gdb.base/maint.exp: Update expected output.
diff --git a/gdb/testsuite/gdb.base/catch-syscall.exp b/gdb/testsuite/gdb.base/catch-syscall.exp
index a70534c..ed87d61 100644
--- a/gdb/testsuite/gdb.base/catch-syscall.exp
+++ b/gdb/testsuite/gdb.base/catch-syscall.exp
@@ -311,6 +311,10 @@ proc do_syscall_tests {} {
# Testing the 'catch' syscall command during a restart of
# the inferior.
if [runto_main] then { test_catch_syscall_restarting_inferior }
+
+ # Testing if the 'catch syscall' command works when switching to
+ # different architectures on-the-fly (PR gdb/10737).
+ if [runto_main] then { test_catch_syscall_multi_arch }
}
proc test_catch_syscall_without_args_noxml {} {
@@ -372,6 +376,73 @@ proc test_catch_syscall_with_wrong_args_noxml {} {
}
}
+proc test_catch_syscall_multi_arch {} {
+ global decimal binfile
+
+ if { [istarget "i*86-*-*"] || [istarget "x86_64-*-*"] } {
+ set arch1 "i386"
+ set arch2 "i386:x86-64"
+ set syscall1_name "exit"
+ set syscall2_name "write"
+ set syscall_number 1
+ } elseif { [istarget "powerpc-*-linux*"] \
+ || [istarget "powerpc64-*-linux*"] } {
+ set arch1 "powerpc:common"
+ set arch2 "powerpc:common64"
+ set syscall1_name "openat"
+ set syscall2_name "unlinkat"
+ set syscall_number 286
+ } elseif { [istarget "sparc-*-linux*"] \
+ || [istarget "sparc64-*-linux*"] } {
+ set arch1 "sparc"
+ set arch2 "sparc:v9"
+ set syscall1_name "setresuid32"
+ set syscall2_name "setresuid"
+ set syscall_number 108
+ } elseif { [istarget "mips*-linux*"] } {
+ # MIPS does not use the same numbers for syscalls on 32 and 64
+ # bits.
+ verbose "Not testing MIPS for multi-arch syscall support"
+ return
+ } elseif { [istarget "arm*-linux*"] } {
+ # catch syscall supports only 32-bit ARM for now.
+ verbose "Not testing ARM for multi-arch syscall support"
+ return
+ } elseif { [istarget "s390*-linux*"] } {
+ set arch1 ""
+ set arch2 "s390:64-bit"
+ set syscall1_name "_newselect"
+ set syscall2_name "select"
+ set syscall_number 142
+ }
+
+ with_test_prefix "multiple targets" {
+ # We are not interested in loading any binary here, and in
+ # some systems (PowerPC, for example), if we load a binary
+ # there is no way to set other architecture.
+ gdb_exit
+ gdb_start
+
+ gdb_test "set architecture $arch1" \
+ "The target architecture is assumed to be $arch1" \
+ "set arch to $arch1"
+
+ gdb_test "catch syscall $syscall_number" \
+ "Catchpoint $decimal \\(syscall .${syscall1_name}. \\\[${syscall_number}\\\]\\)" \
+ "insert catch syscall on syscall $syscall_number -- $syscall1_name on $arch1"
+
+ gdb_test "set architecture $arch2" \
+ "The target architecture is assumed to be $arch2" \
+ "set arch to $arch2"
+
+ gdb_test "catch syscall $syscall_number" \
+ "Catchpoint $decimal \\(syscall .${syscall2_name}. \\\[${syscall_number}\\\]\\)" \
+ "insert catch syscall on syscall $syscall_number -- $syscall2_name on $arch2"
+
+ clean_restart $binfile
+ }
+}
+
proc do_syscall_tests_without_xml {} {
# Make sure GDB doesn't load the syscalls xml from the system data
# directory.