aboutsummaryrefslogtreecommitdiff
path: root/gdb/xml-syscall.h
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/xml-syscall.h
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/xml-syscall.h')
-rw-r--r--gdb/xml-syscall.h11
1 files changed, 7 insertions, 4 deletions
diff --git a/gdb/xml-syscall.h b/gdb/xml-syscall.h
index dff389d..42b9dea 100644
--- a/gdb/xml-syscall.h
+++ b/gdb/xml-syscall.h
@@ -29,22 +29,25 @@
GDB won't be able to find the correct XML file to open and get
the syscalls definitions. */
-void set_xml_syscall_file_name (const char *name);
+void set_xml_syscall_file_name (struct gdbarch *gdbarch,
+ const char *name);
/* Function that retrieves the syscall name corresponding to the given
number. It puts the requested information inside 'struct syscall'. */
-void get_syscall_by_number (int syscall_number, struct syscall *s);
+void get_syscall_by_number (struct gdbarch *gdbarch,
+ int syscall_number, struct syscall *s);
/* Function that retrieves the syscall number corresponding to the given
name. It puts the requested information inside 'struct syscall'. */
-void get_syscall_by_name (const char *syscall_name, struct syscall *s);
+void get_syscall_by_name (struct gdbarch *gdbarch,
+ const char *syscall_name, struct syscall *s);
/* Function used to retrieve the list of syscalls in the system. This list
is returned as an array of strings. Returns the list of syscalls in the
system, or NULL otherwise. */
-const char **get_syscall_names (void);
+const char **get_syscall_names (struct gdbarch *gdbarch);
#endif /* XML_SYSCALL_H */