[2/3] Adjust calls for setting "catch syscall" information

Message ID 1415837887-28888-3-git-send-email-sergiodj@redhat.com
State New, archived
Headers

Commit Message

Sergio Durigan Junior Nov. 13, 2014, 12:18 a.m. UTC
  This patch adjusts the calls to several functions exported by
gdb/xml-syscall.c.  Now, we should receive a "gdbarch" argument that
refers to the architecture being used.

It is the logical move after patch #1, so it's very trivial.

gdb/
2014-11-12  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.
	* 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.
---
 gdb/amd64-linux-tdep.c   |  2 +-
 gdb/arm-linux-tdep.c     |  2 +-
 gdb/bfin-linux-tdep.c    |  2 +-
 gdb/breakpoint.c         | 21 +++++++++++++--------
 gdb/i386-linux-tdep.c    |  2 +-
 gdb/mips-linux-tdep.c    |  6 +++---
 gdb/ppc-linux-tdep.c     |  4 ++--
 gdb/s390-linux-tdep.c    |  4 ++--
 gdb/sparc-linux-tdep.c   |  2 +-
 gdb/sparc64-linux-tdep.c |  2 +-
 10 files changed, 26 insertions(+), 21 deletions(-)
  

Comments

Pedro Alves Nov. 14, 2014, 3:53 p.m. UTC | #1
On 11/13/2014 12:18 AM, Sergio Durigan Junior wrote:
> --- 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 = target_gdbarch ();

I think this would better be bs->bp_location_at->gdbarch .

> @@ -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 = target_gdbarch ();

Here, we can use b->loc->gdbarch.

Later, to handle the case "catch syscall open" with multiple
inferiors of different archs, I think we'll end up with a
location for each inferior, or for each arch, and we'll iterate
over locations here.  For now, I think we can assume there's only
one location.

Similarly for other places.

> @@ -15343,7 +15348,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 (target_gdbarch ());
>    VEC (char_ptr) *retlist
>      = (list == NULL) ? NULL : complete_on_enum (list, word, word);

This one is handling user input, so should be "get_current_arch ()":

/* Return "current" architecture.  If the target is running, this is
   the architecture of the selected frame.  Otherwise, the "current"
   architecture defaults to the target architecture.

   This function should normally be called solely by the command
   interpreter routines to determine the architecture to execute a
   command in.  */
struct gdbarch *
get_current_arch (void)


Thanks,
Pedro Alves
  
Sergio Durigan Junior Nov. 14, 2014, 11:18 p.m. UTC | #2
On Friday, November 14 2014, Pedro Alves wrote:

> On 11/13/2014 12:18 AM, Sergio Durigan Junior wrote:
>> --- 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 = target_gdbarch ();
>
> I think this would better be bs->bp_location_at->gdbarch .
>
>> @@ -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 = target_gdbarch ();
>
> Here, we can use b->loc->gdbarch.
>
> Later, to handle the case "catch syscall open" with multiple
> inferiors of different archs, I think we'll end up with a
> location for each inferior, or for each arch, and we'll iterate
> over locations here.  For now, I think we can assume there's only
> one location.

Hm, thanks for this insight.  I was already wondering the best way to
deal with this problem.  I will give it a try later.

> Similarly for other places.
>
>> @@ -15343,7 +15348,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 (target_gdbarch ());
>>    VEC (char_ptr) *retlist
>>      = (list == NULL) ? NULL : complete_on_enum (list, word, word);
>
> This one is handling user input, so should be "get_current_arch ()":
>
> /* Return "current" architecture.  If the target is running, this is
>    the architecture of the selected frame.  Otherwise, the "current"
>    architecture defaults to the target architecture.
>
>    This function should normally be called solely by the command
>    interpreter routines to determine the architecture to execute a
>    command in.  */
> struct gdbarch *
> get_current_arch (void)

Thanks for the review.  I fixed all the issues.  I will concentrate on
the testcase now in order to get this patch in.
  

Patch

diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c
index edbb1b3..27a3560 100644
--- a/gdb/amd64-linux-tdep.c
+++ b/gdb/amd64-linux-tdep.c
@@ -1663,7 +1663,7 @@  amd64_linux_init_abi_common(struct gdbarch_info info, struct gdbarch *gdbarch)
   tdep->register_reggroup_p = amd64_linux_register_reggroup_p;
 
   /* Functions for 'catch syscall'.  */
-  set_xml_syscall_file_name (XML_SYSCALL_FILENAME_AMD64);
+  set_xml_syscall_file_name (gdbarch, XML_SYSCALL_FILENAME_AMD64);
   set_gdbarch_get_syscall_number (gdbarch,
                                   amd64_linux_get_syscall_number);
 
diff --git a/gdb/arm-linux-tdep.c b/gdb/arm-linux-tdep.c
index 2e79658..fa28695 100644
--- a/gdb/arm-linux-tdep.c
+++ b/gdb/arm-linux-tdep.c
@@ -1468,7 +1468,7 @@  arm_linux_init_abi (struct gdbarch_info info,
   tdep->syscall_next_pc = arm_linux_syscall_next_pc;
 
   /* `catch syscall' */
-  set_xml_syscall_file_name ("syscalls/arm-linux.xml");
+  set_xml_syscall_file_name (gdbarch, "syscalls/arm-linux.xml");
   set_gdbarch_get_syscall_number (gdbarch, arm_linux_get_syscall_number);
 
   /* Syscall record.  */
diff --git a/gdb/bfin-linux-tdep.c b/gdb/bfin-linux-tdep.c
index 8471ec7..c3e37c0 100644
--- a/gdb/bfin-linux-tdep.c
+++ b/gdb/bfin-linux-tdep.c
@@ -157,7 +157,7 @@  bfin_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
   tramp_frame_prepend_unwinder (gdbarch, &bfin_linux_sigframe);
 
   /* Functions for 'catch syscall'.  */
-  set_xml_syscall_file_name ("syscalls/bfin-linux.xml");
+  set_xml_syscall_file_name (gdbarch, "syscalls/bfin-linux.xml");
   set_gdbarch_get_syscall_number (gdbarch,
                                   bfin_linux_get_syscall_number);
 }
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 3ebe9c9..2e19602 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 = target_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 = target_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 = target_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 = target_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
@@ -12035,6 +12039,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')
     {
@@ -12054,12 +12059,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,
@@ -12100,7 +12105,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
@@ -15343,7 +15348,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 (target_gdbarch ());
   VEC (char_ptr) *retlist
     = (list == NULL) ? NULL : complete_on_enum (list, word, word);
 
diff --git a/gdb/i386-linux-tdep.c b/gdb/i386-linux-tdep.c
index 7feb21d..b45c230 100644
--- a/gdb/i386-linux-tdep.c
+++ b/gdb/i386-linux-tdep.c
@@ -994,7 +994,7 @@  i386_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
                                        displaced_step_at_entry_point);
 
   /* Functions for 'catch syscall'.  */
-  set_xml_syscall_file_name (XML_SYSCALL_FILENAME_I386);
+  set_xml_syscall_file_name (gdbarch, XML_SYSCALL_FILENAME_I386);
   set_gdbarch_get_syscall_number (gdbarch,
                                   i386_linux_get_syscall_number);
 
diff --git a/gdb/mips-linux-tdep.c b/gdb/mips-linux-tdep.c
index c2cec3d..bc42921 100644
--- a/gdb/mips-linux-tdep.c
+++ b/gdb/mips-linux-tdep.c
@@ -1558,7 +1558,7 @@  mips_linux_init_abi (struct gdbarch_info info,
 	  (gdbarch, svr4_ilp32_fetch_link_map_offsets);
 	tramp_frame_prepend_unwinder (gdbarch, &mips_linux_o32_sigframe);
 	tramp_frame_prepend_unwinder (gdbarch, &mips_linux_o32_rt_sigframe);
-	set_xml_syscall_file_name ("syscalls/mips-o32-linux.xml");
+	set_xml_syscall_file_name (gdbarch, "syscalls/mips-o32-linux.xml");
 	break;
       case MIPS_ABI_N32:
 	set_gdbarch_get_longjmp_target (gdbarch,
@@ -1572,7 +1572,7 @@  mips_linux_init_abi (struct gdbarch_info info,
 	   does not distinguish between quiet and signalling NaNs).  */
 	set_gdbarch_long_double_format (gdbarch, floatformats_ia64_quad);
 	tramp_frame_prepend_unwinder (gdbarch, &mips_linux_n32_rt_sigframe);
-	set_xml_syscall_file_name ("syscalls/mips-n32-linux.xml");
+	set_xml_syscall_file_name (gdbarch, "syscalls/mips-n32-linux.xml");
 	break;
       case MIPS_ABI_N64:
 	set_gdbarch_get_longjmp_target (gdbarch,
@@ -1586,7 +1586,7 @@  mips_linux_init_abi (struct gdbarch_info info,
 	   does not distinguish between quiet and signalling NaNs).  */
 	set_gdbarch_long_double_format (gdbarch, floatformats_ia64_quad);
 	tramp_frame_prepend_unwinder (gdbarch, &mips_linux_n64_rt_sigframe);
-	set_xml_syscall_file_name ("syscalls/mips-n64-linux.xml");
+	set_xml_syscall_file_name (gdbarch, "syscalls/mips-n64-linux.xml");
 	break;
       default:
 	break;
diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c
index a997869..fa51ed0 100644
--- a/gdb/ppc-linux-tdep.c
+++ b/gdb/ppc-linux-tdep.c
@@ -1294,7 +1294,7 @@  ppc_linux_init_abi (struct gdbarch_info info,
         (gdbarch, svr4_ilp32_fetch_link_map_offsets);
 
       /* Setting the correct XML syscall filename.  */
-      set_xml_syscall_file_name (XML_SYSCALL_FILENAME_PPC);
+      set_xml_syscall_file_name (gdbarch, XML_SYSCALL_FILENAME_PPC);
 
       /* Trampolines.  */
       tramp_frame_prepend_unwinder (gdbarch,
@@ -1346,7 +1346,7 @@  ppc_linux_init_abi (struct gdbarch_info info,
         (gdbarch, svr4_lp64_fetch_link_map_offsets);
 
       /* Setting the correct XML syscall filename.  */
-      set_xml_syscall_file_name (XML_SYSCALL_FILENAME_PPC64);
+      set_xml_syscall_file_name (gdbarch, XML_SYSCALL_FILENAME_PPC64);
 
       /* Trampolines.  */
       tramp_frame_prepend_unwinder (gdbarch,
diff --git a/gdb/s390-linux-tdep.c b/gdb/s390-linux-tdep.c
index abd2e40..b5d94ce 100644
--- a/gdb/s390-linux-tdep.c
+++ b/gdb/s390-linux-tdep.c
@@ -3107,7 +3107,7 @@  s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
       set_solib_svr4_fetch_link_map_offsets
 	(gdbarch, svr4_ilp32_fetch_link_map_offsets);
 
-      set_xml_syscall_file_name (XML_SYSCALL_FILENAME_S390);
+      set_xml_syscall_file_name (gdbarch, XML_SYSCALL_FILENAME_S390);
       break;
 
     case ABI_LINUX_ZSERIES:
@@ -3122,7 +3122,7 @@  s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 						    s390_address_class_type_flags_to_name);
       set_gdbarch_address_class_name_to_type_flags (gdbarch,
 						    s390_address_class_name_to_type_flags);
-      set_xml_syscall_file_name (XML_SYSCALL_FILENAME_S390);
+      set_xml_syscall_file_name (gdbarch, XML_SYSCALL_FILENAME_S390);
       break;
     }
 
diff --git a/gdb/sparc-linux-tdep.c b/gdb/sparc-linux-tdep.c
index fd1fc3d..ec7d84d 100644
--- a/gdb/sparc-linux-tdep.c
+++ b/gdb/sparc-linux-tdep.c
@@ -455,7 +455,7 @@  sparc32_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
   set_gdbarch_write_pc (gdbarch, sparc_linux_write_pc);
 
   /* Functions for 'catch syscall'.  */
-  set_xml_syscall_file_name (XML_SYSCALL_FILENAME_SPARC32);
+  set_xml_syscall_file_name (gdbarch, XML_SYSCALL_FILENAME_SPARC32);
   set_gdbarch_get_syscall_number (gdbarch,
                                   sparc32_linux_get_syscall_number);
 
diff --git a/gdb/sparc64-linux-tdep.c b/gdb/sparc64-linux-tdep.c
index e843eb3..0dd47d0 100644
--- a/gdb/sparc64-linux-tdep.c
+++ b/gdb/sparc64-linux-tdep.c
@@ -336,7 +336,7 @@  sparc64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
   set_gdbarch_write_pc (gdbarch, sparc64_linux_write_pc);
 
   /* Functions for 'catch syscall'.  */
-  set_xml_syscall_file_name (XML_SYSCALL_FILENAME_SPARC64);
+  set_xml_syscall_file_name (gdbarch, XML_SYSCALL_FILENAME_SPARC64);
   set_gdbarch_get_syscall_number (gdbarch,
                                   sparc64_linux_get_syscall_number);
 }