From: John Baldwin <jhb@FreeBSD.org>
To: gdb-patches@sourceware.org
Subject: [PATCH v3 1/3] Change get_syscalls_by_group to append to an existing vector of integers.
Date: Fri, 09 Nov 2018 20:04:00 -0000 [thread overview]
Message-ID: <20181109200432.84491-2-jhb@FreeBSD.org> (raw)
In-Reply-To: <20181109200432.84491-1-jhb@FreeBSD.org>
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 reference to vector of integers
and change return type to bool.
* xml-syscall.h (get_syscalls_by_group): Likewise.
---
gdb/ChangeLog | 12 ++++++++++
gdb/break-catch-syscall.c | 14 +-----------
gdb/xml-syscall.c | 47 +++++++++++++++------------------------
gdb/xml-syscall.h | 10 ++++-----
4 files changed, 35 insertions(+), 48 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index b6c612bd0b..81faa2994d 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,15 @@
+2018-11-09 John Baldwin <jhb@FreeBSD.org>
+
+ * 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 reference to vector of integers
+ and change return type to bool.
+ * xml-syscall.h (get_syscalls_by_group): Likewise.
+
2018-11-09 Hafiz Abid Qadeer <abidh@codesourcery.com>
* configure: Regenerate.
diff --git a/gdb/break-catch-syscall.c b/gdb/break-catch-syscall.c
index 93ef74c249..f3740a1673 100644
--- a/gdb/break-catch-syscall.c
+++ b/gdb/break-catch-syscall.c
@@ -409,25 +409,13 @@ catch_syscall_split_args (const char *arg)
{
/* We have a syscall group. Let's expand it into a syscall
list before inserting. */
- struct syscall *syscall_list;
const char *group_name;
/* Skip over "g:" and "group:" prefix strings. */
group_name = strchr (cur_name, ':') + 1;
- syscall_list = get_syscalls_by_group (gdbarch, group_name);
-
- if (syscall_list == NULL)
+ if (!get_syscalls_by_group (gdbarch, group_name, result))
error (_("Unknown syscall group '%s'."), group_name);
-
- for (i = 0; syscall_list[i].name != NULL; i++)
- {
- /* Insert each syscall that are part of the group. No
- need to check if it is valid. */
- result.push_back (syscall_list[i].number);
- }
-
- xfree (syscall_list);
}
else
{
diff --git a/gdb/xml-syscall.c b/gdb/xml-syscall.c
index bf17642911..664cee77dd 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;
+ return false;
groupdesc = syscall_group_get_group_by_name (syscalls_info, group);
if (groupdesc == NULL)
- return NULL;
+ return false;
- nsyscalls = groupdesc->syscalls.size ();
- syscalls = (struct syscall*) xmalloc ((nsyscalls + 1)
- * sizeof (struct syscall));
+ for (const struct syscall_desc *sysdesc : groupdesc->syscalls)
+ syscalls.push_back (sysdesc->number);
- for (i = 0; i < groupdesc->syscalls.size (); i++)
- {
- syscalls[i].name = groupdesc->syscalls[i]->name.c_str ();
- syscalls[i].number = groupdesc->syscalls[i]->number;
- }
-
- /* Add final element marker. */
- syscalls[i].name = NULL;
- syscalls[i].number = 0;
-
- 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. */
diff --git a/gdb/xml-syscall.h b/gdb/xml-syscall.h
index 4429d66400..2e76a9a97f 100644
--- a/gdb/xml-syscall.h
+++ b/gdb/xml-syscall.h
@@ -51,13 +51,11 @@ void get_syscall_by_name (struct gdbarch *gdbarch,
const char **get_syscall_names (struct gdbarch *gdbarch);
/* Function used to retrieve the list of syscalls of a given group in
- the system. Return a list of syscalls that are element of the
- group, terminated by an empty element. The list is malloc'ed
- and must be freed by the caller. If group doesn't exist, return
- NULL. */
+ the system. The syscall numbers are appended to SYSCALL_NUMBERS.
+ If the group doesn't exist, return false. */
-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);
/* Function used to retrieve the list of syscall groups in the system.
Return an array of strings terminated by a NULL element. The list
--
2.18.0
next prev parent reply other threads:[~2018-11-09 20:04 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-09 20:04 [PATCH v3 0/3] Update FreeBSD's syscall table John Baldwin
2018-11-09 20:04 ` John Baldwin [this message]
2018-11-09 20:04 ` [PATCH v3 3/3] Update the FreeBSD system call table to match FreeBSD 12.0 John Baldwin
2018-11-09 20:04 ` [PATCH v3 2/3] Add an optional "alias" attribute to syscall entries John Baldwin
2018-11-09 20:18 ` Eli Zaretskii
2018-11-16 17:44 ` John Baldwin
2018-11-16 19:37 ` Eli Zaretskii
2018-11-27 17:13 ` Pedro Alves
2018-11-27 21:54 ` John Baldwin
2018-11-28 6:31 ` Eli Zaretskii
[not found] ` <34fcc769-4533-31bf-d258-36c6110037e0@redhat.com>
2018-11-28 17:22 ` John Baldwin
2018-11-28 17:44 ` Eli Zaretskii
2018-11-28 18:00 ` John Baldwin
2018-11-28 18:31 ` Eli Zaretskii
2018-11-28 18:34 ` Pedro Alves
2018-11-28 19:15 ` John Baldwin
2018-11-28 19:21 ` Eli Zaretskii
[not found] ` <7ffda341-7706-d541-939e-f45a7a3f9bd7@FreeBSD.org>
2018-11-27 17:20 ` [PATCH v3 0/3] Update FreeBSD's syscall table Pedro Alves
2018-11-27 20:00 ` John Baldwin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181109200432.84491-2-jhb@FreeBSD.org \
--to=jhb@freebsd.org \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox