diff options
author | John Baldwin <jhb@FreeBSD.org> | 2018-12-13 11:36:42 -0800 |
---|---|---|
committer | John Baldwin <jhb@FreeBSD.org> | 2018-12-13 11:36:42 -0800 |
commit | e9076973c822e6df7f84bb8bc0b69aa42dd29eb3 (patch) | |
tree | baf95c12260c844b6cc692d4259af2e749695b60 /gdb/xml-syscall.c | |
parent | 4794efbfdc4b1497c1f47397b2a2c43382e3de78 (diff) | |
download | gdb-e9076973c822e6df7f84bb8bc0b69aa42dd29eb3.zip gdb-e9076973c822e6df7f84bb8bc0b69aa42dd29eb3.tar.gz gdb-e9076973c822e6df7f84bb8bc0b69aa42dd29eb3.tar.bz2 |
Add an optional "alias" attribute to syscall entries.
When setting a syscall catchpoint by name, catch syscalls whose name
or alias matches the requested string.
When the ABI of a system call is changed in the FreeBSD kernel, this
is implemented by leaving a compatibility system call using the old
ABI at the existing "slot" and allocating a new system call for the
version using the new ABI. For example, new fields were added to the
'struct kevent' used by the kevent() system call in FreeBSD 12. The
previous kevent() system call in FreeBSD 12 kernels is now called
freebsd11_kevent() and is still used by older binaries compiled
against the older ABI. The freebsd11_kevent() system call can be
tagged with an "alias" attribute of "kevent" permitting 'catch syscall
kevent' to catch both system calls and providing the expected user
behavior for both old and new binaries. It also provides the expected
behavior if GDB is compiled on an older host (such as a FreeBSD 11
host).
gdb/ChangeLog:
* NEWS: Add entry documenting system call aliases.
* break-catch-syscall.c (catch_syscall_split_args): Pass 'result'
to get_syscalls_by_name.
* gdbarch.sh (UNKNOWN_SYSCALL): Remove.
* gdbarch.h: Regenerate.
* syscalls/gdb-syscalls.dtd (syscall): Add alias attribute.
* xml-syscall.c [!HAVE_LIBEXPAT] (get_syscalls_by_name): Rename
from get_syscall_by_name. Now accepts a pointer to a vector of
integers and returns a bool.
[HAVE_LIBEXPAT] (struct syscall_desc): Add alias member.
(syscall_create_syscall_desc): Add alias parameter and pass it to
syscall_desc constructor.
(syscall_start_syscall): Handle alias attribute.
(syscall_attr): Add alias attribute.
(xml_get_syscalls_by_name): Rename from xml_get_syscall_number.
Now accepts a pointer to a vector of integers and returns a
bool. Add syscalls whose alias or name matches the requested
name.
(get_syscalls_by_name): Rename from get_syscall_by_name. Now
accepts a pointer to a vector of integers and returns a bool.
* xml-syscall.h (get_syscalls_by_name): Likewise.
gdb/doc/ChangeLog:
* gdb.texinfo (Set Catchpoints): Add an anchor for 'catch syscall'.
(Native): Add a FreeBSD subsection.
(FreeBSD): Document use of system call aliases for compatibility
system calls.
Diffstat (limited to 'gdb/xml-syscall.c')
-rw-r--r-- | gdb/xml-syscall.c | 61 |
1 files changed, 35 insertions, 26 deletions
diff --git a/gdb/xml-syscall.c b/gdb/xml-syscall.c index d1b5bf8..a09ccb9 100644 --- a/gdb/xml-syscall.c +++ b/gdb/xml-syscall.c @@ -61,13 +61,12 @@ get_syscall_by_number (struct gdbarch *gdbarch, s->name = NULL; } -void -get_syscall_by_name (struct gdbarch *gdbarch, const char *syscall_name, - struct syscall *s) +bool +get_syscalls_by_name (struct gdbarch *gdbarch, const char *syscall_name, + std::vector<int> *syscall_numbers) { syscall_warn_user (); - s->number = UNKNOWN_SYSCALL; - s->name = syscall_name; + return false; } const char ** @@ -97,8 +96,8 @@ get_syscall_group_names (struct gdbarch *gdbarch) /* Structure which describes a syscall. */ struct syscall_desc { - syscall_desc (int number_, std::string name_) - : number (number_), name (name_) + syscall_desc (int number_, std::string name_, std::string alias_) + : number (number_), name (name_), alias (alias_) {} /* The syscall number. */ @@ -108,6 +107,10 @@ struct syscall_desc /* The syscall name. */ std::string name; + + /* An optional alias. */ + + std::string alias; }; typedef std::unique_ptr<syscall_desc> syscall_desc_up; @@ -207,10 +210,11 @@ syscall_group_add_syscall (struct syscalls_info *syscalls_info, static void syscall_create_syscall_desc (struct syscalls_info *syscalls_info, - const char *name, int number, + const char *name, int number, const char *alias, char *groups) { - syscall_desc *sysdesc = new syscall_desc (number, name); + syscall_desc *sysdesc = new syscall_desc (number, name, + alias != NULL ? alias : ""); syscalls_info->syscalls.emplace_back (sysdesc); @@ -235,6 +239,7 @@ syscall_start_syscall (struct gdb_xml_parser *parser, /* syscall info. */ char *name = NULL; int number = 0; + char *alias = NULL; char *groups = NULL; for (const gdb_xml_value &attr : attributes) @@ -243,6 +248,8 @@ syscall_start_syscall (struct gdb_xml_parser *parser, name = (char *) attr.value.get (); else if (strcmp (attr.name, "number") == 0) number = * (ULONGEST *) attr.value.get (); + else if (strcmp (attr.name, "alias") == 0) + alias = (char *) attr.value.get (); else if (strcmp (attr.name, "groups") == 0) groups = (char *) attr.value.get (); else @@ -251,7 +258,8 @@ syscall_start_syscall (struct gdb_xml_parser *parser, } gdb_assert (name); - syscall_create_syscall_desc (data->syscalls_info, name, number, groups); + syscall_create_syscall_desc (data->syscalls_info, name, number, alias, + groups); } @@ -259,6 +267,7 @@ syscall_start_syscall (struct gdb_xml_parser *parser, static const struct gdb_xml_attribute syscall_attr[] = { { "number", GDB_XML_AF_NONE, gdb_xml_parse_attr_ulongest, NULL }, { "name", GDB_XML_AF_NONE, NULL, NULL }, + { "alias", GDB_XML_AF_OPTIONAL, NULL, NULL }, { "groups", GDB_XML_AF_OPTIONAL, NULL, NULL }, { NULL, GDB_XML_AF_NONE, NULL, NULL } }; @@ -390,21 +399,22 @@ syscall_group_get_group_by_name (const struct syscalls_info *syscalls_info, return NULL; } -static int -xml_get_syscall_number (struct gdbarch *gdbarch, - const char *syscall_name) +static bool +xml_get_syscalls_by_name (struct gdbarch *gdbarch, const char *syscall_name, + std::vector<int> *syscall_numbers) { struct syscalls_info *syscalls_info = gdbarch_syscalls_info (gdbarch); - if (syscalls_info == NULL - || syscall_name == NULL) - return UNKNOWN_SYSCALL; - - for (const syscall_desc_up &sysdesc : syscalls_info->syscalls) - if (sysdesc->name == syscall_name) - return sysdesc->number; + bool found = false; + if (syscalls_info != NULL && syscall_name != NULL && syscall_numbers != NULL) + for (const syscall_desc_up &sysdesc : syscalls_info->syscalls) + if (sysdesc->name == syscall_name || sysdesc->alias == syscall_name) + { + syscall_numbers->push_back (sysdesc->number); + found = true; + } - return UNKNOWN_SYSCALL; + return found; } static const char * @@ -510,14 +520,13 @@ get_syscall_by_number (struct gdbarch *gdbarch, s->name = xml_get_syscall_name (gdbarch, syscall_number); } -void -get_syscall_by_name (struct gdbarch *gdbarch, - const char *syscall_name, struct syscall *s) +bool +get_syscalls_by_name (struct gdbarch *gdbarch, const char *syscall_name, + std::vector<int> *syscall_numbers) { init_syscalls_info (gdbarch); - s->number = xml_get_syscall_number (gdbarch, syscall_name); - s->name = syscall_name; + return xml_get_syscalls_by_name (gdbarch, syscall_name, syscall_numbers); } const char ** |