Split gdbarch.h into two files
[binutils-gdb.git] / gdb / xml-syscall.c
index 3830faa43652fdce9e09efeaa2c0629ab7c8d46e..4c285b331ba7534f8c5840a4d4d14196e8209cc3 100644 (file)
@@ -1,7 +1,7 @@
 /* Functions that provide the mechanism to parse a syscall XML file
    and get its values.
 
-   Copyright (C) 2009-2019 Free Software Foundation, Inc.
+   Copyright (C) 2009-2021 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -232,8 +232,8 @@ syscall_create_syscall_desc (struct syscalls_info *syscalls_info,
 /* Handle the start of a <syscall> element.  */
 static void
 syscall_start_syscall (struct gdb_xml_parser *parser,
-                       const struct gdb_xml_element *element,
-                       void *user_data,
+                      const struct gdb_xml_element *element,
+                      void *user_data,
                       std::vector<gdb_xml_value> &attributes)
 {
   struct syscall_parsing_data *data = (struct syscall_parsing_data *) user_data;
@@ -246,16 +246,16 @@ syscall_start_syscall (struct gdb_xml_parser *parser,
   for (const gdb_xml_value &attr : attributes)
     {
       if (strcmp (attr.name, "name") == 0)
-        name = (char *) attr.value.get ();
+       name = (char *) attr.value.get ();
       else if (strcmp (attr.name, "number") == 0)
-        number = * (ULONGEST *) attr.value.get ();
+       number = * (ULONGEST *) attr.value.get ();
       else if (strcmp (attr.name, "alias") == 0)
-        alias = (char *) attr.value.get ();
+       alias = (char *) attr.value.get ();
       else if (strcmp (attr.name, "groups") == 0)
-        groups = (char *) attr.value.get ();
+       groups = (char *) attr.value.get ();
       else
-        internal_error (__FILE__, __LINE__,
-                        _("Unknown attribute name '%s'."), attr.name);
+       internal_error (__FILE__, __LINE__,
+                       _("Unknown attribute name '%s'."), attr.name);
     }
 
   gdb_assert (name);
@@ -287,8 +287,7 @@ static const struct gdb_xml_element syselements[] = {
 };
 
 static struct syscalls_info *
-syscall_parse_xml (const char *document, xml_fetch_another fetcher,
-                   void *fetcher_baton)
+syscall_parse_xml (const char *document, xml_fetch_another fetcher)
 {
   struct syscall_parsing_data data;
   syscalls_info_up sysinfo (new syscalls_info ());
@@ -322,9 +321,13 @@ xml_init_syscalls_info (const char *filename)
   if (!full_file)
     return NULL;
 
-  return syscall_parse_xml (full_file->data (),
-                           xml_fetch_content_from_file,
-                           (void *) ldirname (filename).c_str ());
+  const std::string dirname = ldirname (filename);
+  auto fetch_another = [&dirname] (const char *name)
+    {
+      return xml_fetch_content_from_file (name, dirname.c_str ());
+    };
+
+  return syscall_parse_xml (full_file->data (), fetch_another);
 }
 
 /* Initializes the syscalls_info structure according to the
@@ -421,7 +424,7 @@ xml_get_syscalls_by_name (struct gdbarch *gdbarch, const char *syscall_name,
 
 static const char *
 xml_get_syscall_name (struct gdbarch *gdbarch,
-                      int syscall_number)
+                     int syscall_number)
 {
   struct syscalls_info *syscalls_info = gdbarch_syscalls_info (gdbarch);