aboutsummaryrefslogtreecommitdiff
path: root/gdb/breakpoint.c
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/breakpoint.c
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/breakpoint.c')
-rw-r--r--gdb/breakpoint.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index b19d198..7b56260 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -8607,10 +8607,11 @@ print_it_catch_syscall (bpstat bs)
ptid_t ptid;
struct target_waitstatus last;
struct syscall s;
+ struct gdbarch *gdbarch = bs->bp_location_at->gdbarch;
get_last_target_status (&ptid, &last);
- get_syscall_by_number (last.value.syscall_number, &s);
+ get_syscall_by_number (gdbarch, last.value.syscall_number, &s);
annotate_catchpoint (b->number);
@@ -8653,6 +8654,7 @@ print_one_catch_syscall (struct breakpoint *b,
struct syscall_catchpoint *c = (struct syscall_catchpoint *) b;
struct value_print_options opts;
struct ui_out *uiout = current_uiout;
+ struct gdbarch *gdbarch = b->loc->gdbarch;
get_user_print_options (&opts);
/* Field 4, the address, is omitted (which makes the columns not
@@ -8679,7 +8681,7 @@ print_one_catch_syscall (struct breakpoint *b,
{
char *x = text;
struct syscall s;
- get_syscall_by_number (iter, &s);
+ get_syscall_by_number (gdbarch, iter, &s);
if (s.name != NULL)
text = xstrprintf ("%s%s, ", text, s.name);
@@ -8710,6 +8712,7 @@ static void
print_mention_catch_syscall (struct breakpoint *b)
{
struct syscall_catchpoint *c = (struct syscall_catchpoint *) b;
+ struct gdbarch *gdbarch = b->loc->gdbarch;
if (c->syscalls_to_be_caught)
{
@@ -8725,7 +8728,7 @@ print_mention_catch_syscall (struct breakpoint *b)
i++)
{
struct syscall s;
- get_syscall_by_number (iter, &s);
+ get_syscall_by_number (gdbarch, iter, &s);
if (s.name)
printf_filtered (" '%s' [%d]", s.name, s.number);
@@ -8746,6 +8749,7 @@ static void
print_recreate_catch_syscall (struct breakpoint *b, struct ui_file *fp)
{
struct syscall_catchpoint *c = (struct syscall_catchpoint *) b;
+ struct gdbarch *gdbarch = b->loc->gdbarch;
fprintf_unfiltered (fp, "catch syscall");
@@ -8759,7 +8763,7 @@ print_recreate_catch_syscall (struct breakpoint *b, struct ui_file *fp)
{
struct syscall s;
- get_syscall_by_number (iter, &s);
+ get_syscall_by_number (gdbarch, iter, &s);
if (s.name)
fprintf_unfiltered (fp, " %s", s.name);
else
@@ -12037,6 +12041,7 @@ catch_syscall_split_args (char *arg)
{
VEC(int) *result = NULL;
struct cleanup *cleanup = make_cleanup (VEC_cleanup (int), &result);
+ struct gdbarch *gdbarch = target_gdbarch ();
while (*arg != '\0')
{
@@ -12056,12 +12061,12 @@ catch_syscall_split_args (char *arg)
/* Check if the user provided a syscall name or a number. */
syscall_number = (int) strtol (cur_name, &endptr, 0);
if (*endptr == '\0')
- get_syscall_by_number (syscall_number, &s);
+ get_syscall_by_number (gdbarch, syscall_number, &s);
else
{
/* We have a name. Let's check if it's valid and convert it
to a number. */
- get_syscall_by_name (cur_name, &s);
+ get_syscall_by_name (gdbarch, cur_name, &s);
if (s.number == UNKNOWN_SYSCALL)
/* Here we have to issue an error instead of a warning,
@@ -12102,7 +12107,7 @@ this architecture yet."));
to get the syscall XML file loaded or, most important,
to display a warning to the user if there's no XML file
for his/her architecture. */
- get_syscall_by_number (0, &s);
+ get_syscall_by_number (gdbarch, 0, &s);
/* The allowed syntax is:
catch syscall
@@ -15345,7 +15350,7 @@ static VEC (char_ptr) *
catch_syscall_completer (struct cmd_list_element *cmd,
const char *text, const char *word)
{
- const char **list = get_syscall_names ();
+ const char **list = get_syscall_names (get_current_arch ());
VEC (char_ptr) *retlist
= (list == NULL) ? NULL : complete_on_enum (list, word, word);