aboutsummaryrefslogtreecommitdiff
path: root/gdb/xml-syscall.c
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2018-12-13 11:36:42 -0800
committerJohn Baldwin <jhb@FreeBSD.org>2018-12-13 11:36:42 -0800
commit4794efbfdc4b1497c1f47397b2a2c43382e3de78 (patch)
tree1747426f8724a8f0d3bf3c000f6906c9242df1c3 /gdb/xml-syscall.c
parentb7c8601a7f2874de1bbe0dc38ef86ea053593ad8 (diff)
downloadgdb-4794efbfdc4b1497c1f47397b2a2c43382e3de78.zip
gdb-4794efbfdc4b1497c1f47397b2a2c43382e3de78.tar.gz
gdb-4794efbfdc4b1497c1f47397b2a2c43382e3de78.tar.bz2
Change get_syscalls_by_group to append to an existing vector of integers.
This removes the need for the caller to explicitly manage the memory for the returned system call list. The sole caller only needed the system call numbers rather than the full syscall structures. get_syscalls_by_group now uses a boolean return value to indicate if the requested group exists. gdb/ChangeLog: * break-catch-syscall.c (catch_syscall_split_args): Pass 'result' to get_syscalls_by_group. * xml-syscall.c [!HAVE_LIBEXPAT] (get_syscalls_by_group): Return false. [HAVE_LIBEXPAT] (xml_list_syscalls_by_group): Append syscall numbers to an existing vector of integers and return a bool. (get_syscalls_by_group): Accept pointer to vector of integers and change return type to bool. * xml-syscall.h (get_syscalls_by_group): Likewise.
Diffstat (limited to 'gdb/xml-syscall.c')
-rw-r--r--gdb/xml-syscall.c49
1 files changed, 19 insertions, 30 deletions
diff --git a/gdb/xml-syscall.c b/gdb/xml-syscall.c
index bf17642..d1b5bf8 100644
--- a/gdb/xml-syscall.c
+++ b/gdb/xml-syscall.c
@@ -77,11 +77,12 @@ get_syscall_names (struct gdbarch *gdbarch)
return NULL;
}
-struct syscall *
-get_syscalls_by_group (struct gdbarch *gdbarch, const char *group)
+bool
+get_syscalls_by_group (struct gdbarch *gdbarch, const char *group,
+ std::vector<int> *syscall_numbers)
{
syscall_warn_user ();
- return NULL;
+ return false;
}
const char **
@@ -444,40 +445,27 @@ xml_list_of_syscalls (struct gdbarch *gdbarch)
}
/* Iterate over the syscall_group_desc element to return a list of
- syscalls that are part of the given group, terminated by an empty
- element. If the syscall group doesn't exist, return NULL. */
+ syscalls that are part of the given group. If the syscall group
+ doesn't exist, return false. */
-static struct syscall *
-xml_list_syscalls_by_group (struct gdbarch *gdbarch, const char *group)
+static bool
+xml_list_syscalls_by_group (struct gdbarch *gdbarch, const char *group,
+ std::vector<int> *syscalls)
{
struct syscalls_info *syscalls_info = gdbarch_syscalls_info (gdbarch);
struct syscall_group_desc *groupdesc;
- struct syscall *syscalls = NULL;
- int nsyscalls;
- int i;
- if (syscalls_info == NULL)
- return NULL;
+ if (syscalls_info == NULL || syscalls == NULL)
+ return false;
groupdesc = syscall_group_get_group_by_name (syscalls_info, group);
if (groupdesc == NULL)
- return NULL;
-
- nsyscalls = groupdesc->syscalls.size ();
- syscalls = (struct syscall*) xmalloc ((nsyscalls + 1)
- * sizeof (struct syscall));
-
- for (i = 0; i < groupdesc->syscalls.size (); i++)
- {
- syscalls[i].name = groupdesc->syscalls[i]->name.c_str ();
- syscalls[i].number = groupdesc->syscalls[i]->number;
- }
+ return false;
- /* Add final element marker. */
- syscalls[i].name = NULL;
- syscalls[i].number = 0;
+ for (const struct syscall_desc *sysdesc : groupdesc->syscalls)
+ syscalls->push_back (sysdesc->number);
- return syscalls;
+ return true;
}
/* Return a NULL terminated list of syscall groups or an empty list, if
@@ -542,12 +530,13 @@ get_syscall_names (struct gdbarch *gdbarch)
/* See comment in xml-syscall.h. */
-struct syscall *
-get_syscalls_by_group (struct gdbarch *gdbarch, const char *group)
+bool
+get_syscalls_by_group (struct gdbarch *gdbarch, const char *group,
+ std::vector<int> *syscall_numbers)
{
init_syscalls_info (gdbarch);
- return xml_list_syscalls_by_group (gdbarch, group);
+ return xml_list_syscalls_by_group (gdbarch, group, syscall_numbers);
}
/* See comment in xml-syscall.h. */