From e34879080d8935792ef3942efa5f25b4c3169b5a Mon Sep 17 00:00:00 2001 From: Gabriel Krisman Bertazi Date: Sat, 23 Jul 2016 18:38:24 -0300 Subject: [PATCH] Implement catch syscall group Implement support to add catchpoints for a group of related syscalls using the syntax: (gdb) catch syscall group: or (gdb) catch syscall g: Several groups are predefined in the xml files for all architectures supported by GDB over Linux. They are based on the groups defined by strace. gdb/ * xml-syscall.c (get_syscalls_by_group): New. (get_syscall_group_names): New. (struct syscall_group_desc): New structure to store group data. (struct syscalls_info): Include field to store the group list. (sysinfo_free_syscall_group_desc): New. (free_syscalls_info): Free group list. (syscall_group_create_syscall_group_desc): New. (syscall_group_add_syscall): New. (syscall_create_syscall_desc): Add syscall to its groups. (syscall_start_syscall): Load group attribute. (syscall_group_get_group_by_name): New. (xml_list_syscalls_by_group): New. (xml_list_of_groups): New. * xml-syscall.h (get_syscalls_by_group): Export function to retrieve a list of syscalls filtered by the group name. (get_syscall_group_names): Export function to retrieve the list of syscall groups. * break-catch-syscall.c (catch_syscall_split_args): Verify if argument is a syscall group and expand it to a list of syscalls when creating catchpoints. (catch_syscall_completer): Add word completion for system call groups. * configure.ac: Include dependency for xsltproc when building in maintainer-mode. * break-catch-syscall.c (_initialize_breakpoint): Update catch syscall command documentation. * NEWS: Include section about catching groups of syscalls. * configure: Regenerate. * data-directory/Makefile.in: Generate syscall xml when building in maintainer mode. * syscalls/gdb-syscalls.dtd: Include group attribute to the syscall element. * syscalls/apply-defaults.xsl: New. * syscalls/linux-defaults.xml.in: New. * syscalls/aarch64-linux.xml: Rename to aarch64-linux.xml.in. * syscalls/amd64-linux.xml: Rename to amd64-linux.xml.in. * syscalls/arm-linux.xml: Rename to arm-linux.xml.in. * syscalls/bfin-linux.xml: Rename to bfin-linux.xml.in. * syscalls/i386-linux.xml: Rename to i386-linux.xml.in. * syscalls/mips-n32-linux.xml: Rename to mips-n32-linux.xml.in. * syscalls/mips-n64-linux.xml: Rename to mips-n64-linux.xml.in. * syscalls/mips-o32-linux.xml: Rename to mips-o32-linux.xml.in. * syscalls/ppc-linux.xml: Rename to ppc-linux.xml.in. * syscalls/ppc64-linux.xml: Rename to ppc64-linux.xml.in. * syscalls/s390-linux.xml: Rename to s390-linux.xml.in. * syscalls/s390x-linux.xml: Rename to s390x-linux.xml.in. * syscalls/sparc-linux.xml: Rename to sparc-linux.xml.in. * syscalls/sparc64-linux.xml: Rename to sparc64-linux.xml.in. * syscalls/aarch64-linux.xml: Regenerate. * syscalls/amd64-linux.xml: Regenerate. * syscalls/arm-linux.xml: Regenerate. * syscalls/i386-linux.xml: Regenerate. * syscalls/mips-n32-linux.xml: Regenerate. * syscalls/mips-n64-linux.xml: Regenerate. * syscalls/mips-o32-linux.xml: Regenerate. * syscalls/ppc-linux.xml: Regenerate. * syscalls/ppc64-linux.xml: Regenerate. * syscalls/s390-linux.xml: Regenerate. * syscalls/s390x-linux.xml: Regenerate. * syscalls/sparc-linux.xml: Regenerate. * syscalls/sparc64-linux.xml: Regenerate. gdb/testsuite/ * gdb.base/catch-syscall.exp (do_syscall_tests): Add call to test_catch_syscall_group. (test_catch_syscall_group): New. gdb/doc/ * gdb.texinfo (Set Catchpoints): Add 'group' argument to catch syscall. --- gdb/ChangeLog | 64 +++ gdb/NEWS | 5 + gdb/break-catch-syscall.c | 103 +++- gdb/configure | 54 +++ gdb/configure.ac | 9 + gdb/data-directory/Makefile.in | 25 +- gdb/doc/ChangeLog | 5 + gdb/doc/gdb.texinfo | 28 +- gdb/syscalls/aarch64-linux.xml | 318 ++++++------- gdb/syscalls/aarch64-linux.xml.in | 271 +++++++++++ gdb/syscalls/amd64-linux.xml | 367 +++++++------- gdb/syscalls/amd64-linux.xml.in | 314 ++++++++++++ gdb/syscalls/apply-defaults.xsl | 43 ++ gdb/syscalls/arm-linux.xml | 449 +++++++++--------- gdb/syscalls/arm-linux.xml.in | 398 ++++++++++++++++ .../{bfin-linux.xml => bfin-linux.xml.in} | 0 gdb/syscalls/gdb-syscalls.dtd | 3 +- gdb/syscalls/i386-linux.xml | 357 +++++++------- gdb/syscalls/i386-linux.xml.in | 340 +++++++++++++ gdb/syscalls/linux-defaults.xml.in | 243 ++++++++++ gdb/syscalls/mips-n32-linux.xml | 381 ++++++++------- gdb/syscalls/mips-n32-linux.xml.in | 319 +++++++++++++ gdb/syscalls/mips-n64-linux.xml | 371 +++++++-------- gdb/syscalls/mips-n64-linux.xml.in | 312 ++++++++++++ gdb/syscalls/mips-o32-linux.xml | 405 ++++++++-------- gdb/syscalls/mips-o32-linux.xml.in | 347 ++++++++++++++ gdb/syscalls/ppc-linux.xml | 325 +++++++------ gdb/syscalls/ppc-linux.xml.in | 310 ++++++++++++ gdb/syscalls/ppc64-linux.xml | 295 ++++++------ gdb/syscalls/ppc64-linux.xml.in | 295 ++++++++++++ gdb/syscalls/s390-linux.xml | 409 ++++++++-------- gdb/syscalls/s390-linux.xml.in | 367 ++++++++++++++ gdb/syscalls/s390x-linux.xml | 383 ++++++++------- gdb/syscalls/s390x-linux.xml.in | 334 +++++++++++++ gdb/syscalls/sparc-linux.xml | 403 ++++++++-------- gdb/syscalls/sparc-linux.xml.in | 344 ++++++++++++++ gdb/syscalls/sparc64-linux.xml | 389 ++++++++------- gdb/syscalls/sparc64-linux.xml.in | 326 +++++++++++++ gdb/testsuite/ChangeLog | 6 + gdb/testsuite/gdb.base/catch-syscall.exp | 39 ++ gdb/xml-syscall.c | 234 ++++++++- gdb/xml-syscall.h | 16 + 42 files changed, 7538 insertions(+), 2468 deletions(-) create mode 100644 gdb/syscalls/aarch64-linux.xml.in create mode 100644 gdb/syscalls/amd64-linux.xml.in create mode 100644 gdb/syscalls/apply-defaults.xsl create mode 100644 gdb/syscalls/arm-linux.xml.in rename gdb/syscalls/{bfin-linux.xml => bfin-linux.xml.in} (100%) create mode 100644 gdb/syscalls/i386-linux.xml.in create mode 100644 gdb/syscalls/linux-defaults.xml.in create mode 100644 gdb/syscalls/mips-n32-linux.xml.in create mode 100644 gdb/syscalls/mips-n64-linux.xml.in create mode 100644 gdb/syscalls/mips-o32-linux.xml.in create mode 100644 gdb/syscalls/ppc-linux.xml.in create mode 100644 gdb/syscalls/ppc64-linux.xml.in create mode 100644 gdb/syscalls/s390-linux.xml.in create mode 100644 gdb/syscalls/s390x-linux.xml.in create mode 100644 gdb/syscalls/sparc-linux.xml.in create mode 100644 gdb/syscalls/sparc64-linux.xml.in diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 56cd5ba387b..005c3e976f3 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,67 @@ +2016-07-23 Gabriel Krisman Bertazi + + * xml-syscall.c (get_syscalls_by_group): New. + (get_syscall_group_names): New. + (struct syscall_group_desc): New structure to store group data. + (struct syscalls_info): Include field to store the group list. + (sysinfo_free_syscall_group_desc): New. + (free_syscalls_info): Free group list. + (syscall_group_create_syscall_group_desc): New. + (syscall_group_add_syscall): New. + (syscall_create_syscall_desc): Add syscall to its groups. + (syscall_start_syscall): Load group attribute. + (syscall_group_get_group_by_name): New. + (xml_list_syscalls_by_group): New. + (xml_list_of_groups): New. + * xml-syscall.h (get_syscalls_by_group): Export function + to retrieve a list of syscalls filtered by the group name. + (get_syscall_group_names): Export function to retrieve the list + of syscall groups. + * break-catch-syscall.c (catch_syscall_split_args): Verify if + argument is a syscall group and expand it to a list of syscalls + when creating catchpoints. + (catch_syscall_completer): Add word completion for system call + groups. + * configure.ac: Include dependency for xsltproc when building + in maintainer-mode. + * break-catch-syscall.c (_initialize_breakpoint): Update catch + syscall command documentation. + * NEWS: Include section about catching groups of syscalls. + * configure: Regenerate. + * data-directory/Makefile.in: Generate syscall xml when building + in maintainer mode. + * syscalls/gdb-syscalls.dtd: Include group attribute to the + syscall element. + * syscalls/apply-defaults.xsl: New. + * syscalls/linux-defaults.xml.in: New. + * syscalls/aarch64-linux.xml: Rename to aarch64-linux.xml.in. + * syscalls/amd64-linux.xml: Rename to amd64-linux.xml.in. + * syscalls/arm-linux.xml: Rename to arm-linux.xml.in. + * syscalls/bfin-linux.xml: Rename to bfin-linux.xml.in. + * syscalls/i386-linux.xml: Rename to i386-linux.xml.in. + * syscalls/mips-n32-linux.xml: Rename to mips-n32-linux.xml.in. + * syscalls/mips-n64-linux.xml: Rename to mips-n64-linux.xml.in. + * syscalls/mips-o32-linux.xml: Rename to mips-o32-linux.xml.in. + * syscalls/ppc-linux.xml: Rename to ppc-linux.xml.in. + * syscalls/ppc64-linux.xml: Rename to ppc64-linux.xml.in. + * syscalls/s390-linux.xml: Rename to s390-linux.xml.in. + * syscalls/s390x-linux.xml: Rename to s390x-linux.xml.in. + * syscalls/sparc-linux.xml: Rename to sparc-linux.xml.in. + * syscalls/sparc64-linux.xml: Rename to sparc64-linux.xml.in. + * syscalls/aarch64-linux.xml: Regenerate. + * syscalls/amd64-linux.xml: Regenerate. + * syscalls/arm-linux.xml: Regenerate. + * syscalls/i386-linux.xml: Regenerate. + * syscalls/mips-n32-linux.xml: Regenerate. + * syscalls/mips-n64-linux.xml: Regenerate. + * syscalls/mips-o32-linux.xml: Regenerate. + * syscalls/ppc-linux.xml: Regenerate. + * syscalls/ppc64-linux.xml: Regenerate. + * syscalls/s390-linux.xml: Regenerate. + * syscalls/s390x-linux.xml: Regenerate. + * syscalls/sparc-linux.xml: Regenerate. + * syscalls/sparc64-linux.xml: Regenerate. + 2016-07-23 Andrew Pinski * nat/aarch64-linux-hw-point.c diff --git a/gdb/NEWS b/gdb/NEWS index 0e339dd7fbb..17c762ccdcd 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -60,6 +60,11 @@ for its own control and synchronization, invisible to the command line. +* The "catch syscall" command catches groups of related syscalls. + + The "catch syscall" command now supports catching a group of related + syscalls using the 'group:' or 'g:' prefix. + * New commands skip -file file diff --git a/gdb/break-catch-syscall.c b/gdb/break-catch-syscall.c index dbebddaae43..602aba4e935 100644 --- a/gdb/break-catch-syscall.c +++ b/gdb/break-catch-syscall.c @@ -464,10 +464,38 @@ catch_syscall_split_args (char *arg) cur_name[i] = '\0'; arg += i; - /* Check if the user provided a syscall name or a number. */ + /* Check if the user provided a syscall name, group, or a number. */ syscall_number = (int) strtol (cur_name, &endptr, 0); if (*endptr == '\0') - get_syscall_by_number (gdbarch, syscall_number, &s); + { + get_syscall_by_number (gdbarch, syscall_number, &s); + VEC_safe_push (int, result, s.number); + } + else if (startswith (cur_name, "g:") + || startswith (cur_name, "group:")) + { + /* 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) + 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. */ + VEC_safe_push (int, result, syscall_list[i].number); + } + + xfree (syscall_list); + } else { /* We have a name. Let's check if it's valid and convert it @@ -479,10 +507,10 @@ catch_syscall_split_args (char *arg) because GDB cannot do anything useful if there's no syscall number to be caught. */ error (_("Unknown syscall name '%s'."), cur_name); - } - /* Ok, it's valid. */ - VEC_safe_push (int, result, s.number); + /* Ok, it's valid. */ + VEC_safe_push (int, result, s.number); + } } discard_cleanups (cleanup); @@ -597,11 +625,58 @@ static VEC (char_ptr) * catch_syscall_completer (struct cmd_list_element *cmd, const char *text, const char *word) { - const char **list = get_syscall_names (get_current_arch ()); - VEC (char_ptr) *retlist - = (list == NULL) ? NULL : complete_on_enum (list, word, word); + struct gdbarch *gdbarch = get_current_arch (); + struct cleanup *cleanups = make_cleanup (null_cleanup, NULL); + VEC (char_ptr) *group_retlist = NULL; + VEC (char_ptr) *syscall_retlist = NULL; + VEC (char_ptr) *retlist = NULL; + const char **group_list = NULL; + const char **syscall_list = NULL; + const char *prefix; + int i; + + /* Completion considers ':' to be a word separator, so we use this to + verify whether the previous word was a group prefix. If so, we + build the completion list using group names only. */ + for (prefix = word; prefix != text && prefix[-1] != ' '; prefix--) + ; + + if (startswith (prefix, "g:") || startswith (prefix, "group:")) + { + /* Perform completion inside 'group:' namespace only. */ + group_list = get_syscall_group_names (gdbarch); + retlist = (group_list == NULL + ? NULL : complete_on_enum (group_list, word, word)); + } + else + { + /* Complete with both, syscall names and groups. */ + syscall_list = get_syscall_names (gdbarch); + group_list = get_syscall_group_names (gdbarch); + + /* Append "group:" prefix to syscall groups. */ + for (i = 0; group_list[i] != NULL; i++) + { + char *prefixed_group = xstrprintf ("group:%s", group_list[i]); + + group_list[i] = prefixed_group; + make_cleanup (xfree, prefixed_group); + } + + syscall_retlist = ((syscall_list == NULL) + ? NULL : complete_on_enum (syscall_list, word, word)); + group_retlist = ((group_list == NULL) + ? NULL : complete_on_enum (group_list, word, word)); + + retlist = VEC_merge (char_ptr, syscall_retlist, group_retlist); + } + + VEC_free (char_ptr, syscall_retlist); + VEC_free (char_ptr, group_retlist); + xfree (syscall_list); + xfree (group_list); + do_cleanups (cleanups); - xfree (list); return retlist; } @@ -649,11 +724,11 @@ _initialize_break_catch_syscall (void) catch_syscall_inferior_data_cleanup); add_catch_command ("syscall", _("\ -Catch system calls by their names and/or numbers.\n\ -Arguments say which system calls to catch. If no arguments\n\ -are given, every system call will be caught.\n\ -Arguments, if given, should be one or more system call names\n\ -(if your system supports that), or system call numbers."), +Catch system calls by their names, groups and/or numbers.\n\ +Arguments say which system calls to catch. If no arguments are given,\n\ +every system call will be caught. Arguments, if given, should be one\n\ +or more system call names (if your system supports that), system call\n\ +groups or system call numbers."), catch_syscall_command_1, catch_syscall_completer, CATCH_PERMANENT, diff --git a/gdb/configure b/gdb/configure index 43d207c788f..067f86e5e27 100755 --- a/gdb/configure +++ b/gdb/configure @@ -593,6 +593,7 @@ ac_subst_vars='LTLIBOBJS LIBOBJS GCORE_TRANSFORM_NAME GDB_TRANSFORM_NAME +XSLTPROC GDB_NM_FILE LTLIBBABELTRACE LIBBABELTRACE @@ -16499,6 +16500,59 @@ _ACEOF fi +for ac_prog in xsltproc +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_path_XSLTPROC+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + case $XSLTPROC in + [\\/]* | ?:[\\/]*) + ac_cv_path_XSLTPROC="$XSLTPROC" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_path_XSLTPROC="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +XSLTPROC=$ac_cv_path_XSLTPROC +if test -n "$XSLTPROC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $XSLTPROC" >&5 +$as_echo "$XSLTPROC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$XSLTPROC" && break +done +test -n "$XSLTPROC" || XSLTPROC="missing" + +if test "x$USE_MAINTAINER_MODE" = xyes; then + if test "${XSLTPROC}" = missing; then + as_fn_error "unable to find xsltproc. maintainer-mode requires xsltproc." "$LINENO" 5 + fi +fi + + ac_sources="$files" ac_dests="$links" while test -n "$ac_sources"; do diff --git a/gdb/configure.ac b/gdb/configure.ac index 5e2e938f005..f774db7ea6e 100644 --- a/gdb/configure.ac +++ b/gdb/configure.ac @@ -2344,6 +2344,15 @@ if test "${nativefile}" != ""; then fi AC_SUBST(GDB_NM_FILE) +dnl Add dependency for xsltproc if building with maintainer-mode enabled. +AC_PATH_PROGS(XSLTPROC, xsltproc, missing) +if test "x$USE_MAINTAINER_MODE" = xyes; then + if test "${XSLTPROC}" = missing; then + AC_ERROR(unable to find xsltproc. maintainer-mode requires xsltproc.) + fi +fi +AC_SUBST(XSLTPROC) + AC_LINK_FILES($files, $links) dnl Check for exe extension set on certain hosts (e.g. Win32) diff --git a/gdb/data-directory/Makefile.in b/gdb/data-directory/Makefile.in index 0beca553eb3..3f235168762 100644 --- a/gdb/data-directory/Makefile.in +++ b/gdb/data-directory/Makefile.in @@ -22,6 +22,7 @@ PYTHON_SRCDIR = $(srcdir)/../python/lib GUILE_SRCDIR = $(srcdir)/../guile/lib SYSTEM_GDBINIT_SRCDIR = $(srcdir)/../system-gdbinit VPATH = $(srcdir):$(SYSCALLS_SRCDIR):$(PYTHON_SRCDIR):$(GUILE_SRCDIR):$(SYSTEM_GDBINIT_SRCDIR) +XSLTPROC = @XSLTPROC@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ @@ -44,15 +45,14 @@ GDB_DATADIR = @GDB_DATADIR@ SYSCALLS_DIR = syscalls SYSCALLS_INSTALL_DIR = $(DESTDIR)$(GDB_DATADIR)/$(SYSCALLS_DIR) -SYSCALLS_FILES = \ - gdb-syscalls.dtd \ - arm-linux.xml aarch64-linux.xml \ +GEN_SYSCALLS_FILES = arm-linux.xml aarch64-linux.xml \ ppc-linux.xml ppc64-linux.xml \ i386-linux.xml amd64-linux.xml \ sparc-linux.xml sparc64-linux.xml \ mips-o32-linux.xml mips-n32-linux.xml mips-n64-linux.xml \ - s390-linux.xml s390x-linux.xml \ - freebsd.xml + s390-linux.xml s390x-linux.xml + +SYSCALLS_FILES = gdb-syscalls.dtd freebsd.xml $(GEN_SYSCALLS_FILES) PYTHON_DIR = python PYTHON_INSTALL_DIR = $(DESTDIR)$(GDB_DATADIR)/$(PYTHON_DIR) @@ -163,6 +163,21 @@ FLAGS_TO_PASS = \ .PHONY: all all: stamp-syscalls stamp-python stamp-guile stamp-system-gdbinit +%.xml: @MAINTAINER_MODE_TRUE@ %.xml.in apply-defaults.xsl linux-defaults.xml.in + $(XSLTPROC) -o $(SYSCALLS_SRCDIR)/$@ $(SYSCALLS_SRCDIR)/apply-defaults.xsl\ + $(SYSCALLS_SRCDIR)/$@.in + +.PHONY: syscall-xml +syscall-xml: $(GEN_SYSCALLS_FILES) + +.PHONY: clean-syscall-xml +# Only clean files generated XML files. +clean-syscall-xml: + files='$(GEN_SYSCALLS_FILES)' ; \ + for file in $$files; do \ + rm -f "$(SYSCALLS_SRCDIR)/$$file"; \ + done + # For portability's sake, we need to handle systems that don't have # symbolic links. stamp-syscalls: Makefile $(SYSCALLS_FILES) diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index e45d92558b3..39eeab2bbfa 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,8 @@ +2016-07-23 Gabriel Krisman Bertazi + + * gdb.texinfo (Set Catchpoints): Add 'group' argument to catch + syscall. + 2016-06-30 Руслан Ижбулатов * gdb.texinfo (Cygwin Native): Document the new 'signal-event' diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 285a912bbb0..ae74ed44eaa 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -4375,7 +4375,7 @@ A failed Ada assertion. A call to @code{exec}. @item syscall -@itemx syscall @r{[}@var{name} @r{|} @var{number}@r{]} @dots{} +@itemx syscall @r{[}@var{name} @r{|} @var{number} @r{|} @r{group:}@var{groupname} @r{|} @r{g:}@var{groupname}@r{]} @dots{} @kindex catch syscall @cindex break on a system call. A call to or return from a system call, a.k.a.@: @dfn{syscall}. A @@ -4410,6 +4410,15 @@ may be useful if @value{GDBN}'s database does not have the complete list of syscalls on your system (e.g., because @value{GDBN} lags behind the OS upgrades). +You may specify a group of related syscalls to be caught at once using +the @code{group:} syntax (@code{g:} is a shorter equivalent). For +instance, on some platforms @value{GDBN} allows you to catch all +network related syscalls, by passing the argument @code{group:network} +to @code{catch syscall}. Note that not all syscall groups are +available in every system. You can use the command completion +facilities (@pxref{Completion,, command completion}) to list the +syscall groups available on your environment. + The example below illustrates how this command works if you don't provide arguments to it: @@ -4466,6 +4475,23 @@ Program exited normally. (@value{GDBP}) @end smallexample +Here is an example of catching a syscall group: + +@smallexample +(@value{GDBP}) catch syscall group:process +Catchpoint 1 (syscalls 'exit' [1] 'fork' [2] 'waitpid' [7] +'execve' [11] 'wait4' [114] 'clone' [120] 'vfork' [190] +'exit_group' [252] 'waitid' [284] 'unshare' [310]) +(@value{GDBP}) r +Starting program: /tmp/catch-syscall + +Catchpoint 1 (call to syscall fork), 0x00007ffff7df4e27 in open64 () + from /lib64/ld-linux-x86-64.so.2 + +(@value{GDBP}) c +Continuing. +@end smallexample + However, there can be situations when there is no corresponding name in XML file for that syscall number. In this case, @value{GDBN} prints a warning message saying that it was not able to find the syscall name, diff --git a/gdb/syscalls/aarch64-linux.xml b/gdb/syscalls/aarch64-linux.xml index e1fa0da80f5..aa83a0b3222 100644 --- a/gdb/syscalls/aarch64-linux.xml +++ b/gdb/syscalls/aarch64-linux.xml @@ -1,112 +1,110 @@ + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - + + + + + + + + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - + + + + + + + + - - - + + + - + @@ -138,17 +136,17 @@ - - - - - - - - - - - + + + + + + + + + + + @@ -195,75 +193,75 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - + + + + - - - + + + diff --git a/gdb/syscalls/aarch64-linux.xml.in b/gdb/syscalls/aarch64-linux.xml.in new file mode 100644 index 00000000000..e1fa0da80f5 --- /dev/null +++ b/gdb/syscalls/aarch64-linux.xml.in @@ -0,0 +1,271 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gdb/syscalls/amd64-linux.xml b/gdb/syscalls/amd64-linux.xml index 074b5870efc..9778258e032 100644 --- a/gdb/syscalls/amd64-linux.xml +++ b/gdb/syscalls/amd64-linux.xml @@ -1,114 +1,111 @@ + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -141,18 +138,18 @@ - - - - - - - - + + + + + + + + - - + + @@ -163,26 +160,26 @@ - - - - + + + + - + - + - + - + - - - - + + + + @@ -193,7 +190,7 @@ - + @@ -201,20 +198,20 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + @@ -227,15 +224,15 @@ - + - - + + - - + + @@ -245,15 +242,15 @@ - - - - - + + + + + - - - + + + @@ -261,54 +258,54 @@ - + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/gdb/syscalls/amd64-linux.xml.in b/gdb/syscalls/amd64-linux.xml.in new file mode 100644 index 00000000000..074b5870efc --- /dev/null +++ b/gdb/syscalls/amd64-linux.xml.in @@ -0,0 +1,314 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gdb/syscalls/apply-defaults.xsl b/gdb/syscalls/apply-defaults.xsl new file mode 100644 index 00000000000..5ab2b67484a --- /dev/null +++ b/gdb/syscalls/apply-defaults.xsl @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + , + + + + + + diff --git a/gdb/syscalls/arm-linux.xml b/gdb/syscalls/arm-linux.xml index c0a456b1982..0777c64222f 100644 --- a/gdb/syscalls/arm-linux.xml +++ b/gdb/syscalls/arm-linux.xml @@ -1,95 +1,92 @@ + - - - - - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - + + + + + + - - + + - - - + + + - + - - - - - - + + + + + + - + - + - - + + - - + + - + - + - - - + + + - - + + @@ -98,78 +95,78 @@ - - - - - - + + + + + + - - - - - - - + + + + + + + - - + + - + - - - + + + - - + + - - - - + + + + - - + + - + - + - - - - - - - + + + + + + + - + - - - - + + + + @@ -179,40 +176,40 @@ - + - + - - - - - - - - - - - + + + + + + + + + + + - - - + + + - - - - - - - + + + + + + + @@ -221,37 +218,37 @@ - + - + - - - - - + + + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + @@ -260,12 +257,12 @@ - + - - - - + + + + @@ -276,10 +273,10 @@ - - - - + + + + @@ -290,106 +287,106 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - + - - - + + + - + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - + + - - - + + + - + diff --git a/gdb/syscalls/arm-linux.xml.in b/gdb/syscalls/arm-linux.xml.in new file mode 100644 index 00000000000..c0a456b1982 --- /dev/null +++ b/gdb/syscalls/arm-linux.xml.in @@ -0,0 +1,398 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gdb/syscalls/bfin-linux.xml b/gdb/syscalls/bfin-linux.xml.in similarity index 100% rename from gdb/syscalls/bfin-linux.xml rename to gdb/syscalls/bfin-linux.xml.in diff --git a/gdb/syscalls/gdb-syscalls.dtd b/gdb/syscalls/gdb-syscalls.dtd index 3deda1285a6..de47d4dc831 100644 --- a/gdb/syscalls/gdb-syscalls.dtd +++ b/gdb/syscalls/gdb-syscalls.dtd @@ -11,4 +11,5 @@ + number CDATA #REQUIRED + groups CDATA #IMPLIED> diff --git a/gdb/syscalls/i386-linux.xml b/gdb/syscalls/i386-linux.xml index aab03ecdec6..51330c4cc42 100644 --- a/gdb/syscalls/i386-linux.xml +++ b/gdb/syscalls/i386-linux.xml @@ -1,93 +1,90 @@ + - - - - - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - + + + + + + - - + + - - - + + + - + - - - - - - + + + + + + - + - + - - + + - - + + - + - + - - - + + + - - + + @@ -96,78 +93,78 @@ - - - - - - + + + + + + - - - - - - - + + + + + + + - - + + - + - - - + + + - - + + - - - - + + + + - - + + - + - + - - - - - - - + + + + + + + - + - - - - + + + + @@ -177,42 +174,42 @@ - + - + - - - - - - - - - - - + + + + + + + + + + + - - + + - + - - - - - - - + + + + + + + @@ -221,38 +218,38 @@ - + - + - - - + + + - - + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + @@ -263,13 +260,13 @@ - - + + - - - - + + + + @@ -280,15 +277,15 @@ - - - - - + + + + + - - - + + + @@ -296,45 +293,45 @@ - + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - - + + + + + - - - - - - - + + + + + + + diff --git a/gdb/syscalls/i386-linux.xml.in b/gdb/syscalls/i386-linux.xml.in new file mode 100644 index 00000000000..aab03ecdec6 --- /dev/null +++ b/gdb/syscalls/i386-linux.xml.in @@ -0,0 +1,340 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gdb/syscalls/linux-defaults.xml.in b/gdb/syscalls/linux-defaults.xml.in new file mode 100644 index 00000000000..1c4e187818b --- /dev/null +++ b/gdb/syscalls/linux-defaults.xml.in @@ -0,0 +1,243 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gdb/syscalls/mips-n32-linux.xml b/gdb/syscalls/mips-n32-linux.xml index 7318ae18f26..d2864aac83d 100644 --- a/gdb/syscalls/mips-n32-linux.xml +++ b/gdb/syscalls/mips-n32-linux.xml @@ -1,112 +1,109 @@ + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -139,17 +136,17 @@ - - - - - - - + + + + + + + - - + + @@ -160,24 +157,24 @@ - - - - + + + + - + - + - + - - - - + + + + @@ -186,27 +183,27 @@ - + - - - - - - - - - - - - - - + + + + + + + + + + + + + + @@ -219,21 +216,21 @@ - + - - - - - - + + + + + + - - - - - + + + + + @@ -243,11 +240,11 @@ - - - - - + + + + + @@ -255,65 +252,65 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gdb/syscalls/mips-n32-linux.xml.in b/gdb/syscalls/mips-n32-linux.xml.in new file mode 100644 index 00000000000..7318ae18f26 --- /dev/null +++ b/gdb/syscalls/mips-n32-linux.xml.in @@ -0,0 +1,319 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gdb/syscalls/mips-n64-linux.xml b/gdb/syscalls/mips-n64-linux.xml index b45f4b9146a..315b7ad3bda 100644 --- a/gdb/syscalls/mips-n64-linux.xml +++ b/gdb/syscalls/mips-n64-linux.xml @@ -1,112 +1,109 @@ + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -139,17 +136,17 @@ - - - - - - - + + + + + + + - - + + @@ -160,24 +157,24 @@ - - - - + + + + - + - + - + - - - - + + + + @@ -186,26 +183,26 @@ - + - - - - - - - - - - - - - - + + + + + + + + + + + + + + @@ -217,17 +214,17 @@ - + - - - - - + + + + + - - + + @@ -237,11 +234,11 @@ - - - - - + + + + + @@ -249,64 +246,64 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/gdb/syscalls/mips-n64-linux.xml.in b/gdb/syscalls/mips-n64-linux.xml.in new file mode 100644 index 00000000000..b45f4b9146a --- /dev/null +++ b/gdb/syscalls/mips-n64-linux.xml.in @@ -0,0 +1,312 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gdb/syscalls/mips-o32-linux.xml b/gdb/syscalls/mips-o32-linux.xml index 94fa3f71ae1..90ba598befd 100644 --- a/gdb/syscalls/mips-o32-linux.xml +++ b/gdb/syscalls/mips-o32-linux.xml @@ -1,90 +1,87 @@ + - - - - - - - - - - - - - - - - + + + + + + + + + + + + - - - - - + + + + + - - + + - - + + - + - - - - - - + + + + + + - + - + - - + + - - + + - + - + - - - + + + - - + + @@ -93,78 +90,78 @@ - - - - + + + + - - - - - - - + + + + + + + - - + + - + - - - + + + - - + + - - - - + + + + - - + + - + - + - - - - - - - + + + + + + + - + - - - - + + + + @@ -174,76 +171,76 @@ - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - + + + + + + + + + + + - - + + - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + @@ -252,17 +249,17 @@ - + - - - - + + + + - - - + + + @@ -272,11 +269,11 @@ - - - - - + + + + + @@ -284,64 +281,64 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/gdb/syscalls/mips-o32-linux.xml.in b/gdb/syscalls/mips-o32-linux.xml.in new file mode 100644 index 00000000000..94fa3f71ae1 --- /dev/null +++ b/gdb/syscalls/mips-o32-linux.xml.in @@ -0,0 +1,347 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gdb/syscalls/ppc-linux.xml b/gdb/syscalls/ppc-linux.xml index 71e7cd6c17f..32f85233663 100644 --- a/gdb/syscalls/ppc-linux.xml +++ b/gdb/syscalls/ppc-linux.xml @@ -1,93 +1,90 @@ + - - - - - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - + + + + + + - - + + - - - + + + - + - - - - - - + + + + + + - + - + - - + + - - + + - + - + - - - + + + - - + + @@ -96,78 +93,78 @@ - - - - - - + + + + + + - - - - - - - + + + + + + + - - + + - + - - - + + + - - + + - - - - + + + + - - + + - + - + - - - - - - - + + + + + + + - + - - - - + + + + @@ -177,82 +174,82 @@ - + - + - - - - - - - - - - - + + + + + + + + + + + - - + + - + - - - - - - - + + + + + + + - - - - - + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + - + - - + + - - - - + + + + @@ -263,16 +260,16 @@ - - - - - + + + + + - - - + + + @@ -283,28 +280,28 @@ - + - - - + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/gdb/syscalls/ppc-linux.xml.in b/gdb/syscalls/ppc-linux.xml.in new file mode 100644 index 00000000000..71e7cd6c17f --- /dev/null +++ b/gdb/syscalls/ppc-linux.xml.in @@ -0,0 +1,310 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gdb/syscalls/ppc64-linux.xml b/gdb/syscalls/ppc64-linux.xml index 6906e7e986c..784a79b3a81 100644 --- a/gdb/syscalls/ppc64-linux.xml +++ b/gdb/syscalls/ppc64-linux.xml @@ -1,93 +1,90 @@ + - - - - - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - + + + + + + - - + + - - - + + + - + - - - - - - + + + + + + - + - + - - + + - - + + - + - + - - - + + + - - + + @@ -96,78 +93,78 @@ - - - - - - + + + + + + - - - - - - - + + + + + + + - - + + - + - - - + + + - - + + - - - - + + + + - - + + - + - + - - - - - - - + + + + + + + - + - - - - + + + + @@ -177,57 +174,57 @@ - + - + - - - - - - - - - - - + + + + + + + + + + + - - + + - + - + - - - - + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + @@ -238,13 +235,13 @@ - - + + - - - - + + + + @@ -255,15 +252,15 @@ - - - - + + + + - - - + + + @@ -274,22 +271,22 @@ - + - - - + + + - - - - - - - - - - + + + + + + + + + + diff --git a/gdb/syscalls/ppc64-linux.xml.in b/gdb/syscalls/ppc64-linux.xml.in new file mode 100644 index 00000000000..6906e7e986c --- /dev/null +++ b/gdb/syscalls/ppc64-linux.xml.in @@ -0,0 +1,295 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gdb/syscalls/s390-linux.xml b/gdb/syscalls/s390-linux.xml index 56e92870685..cbab4e11cd5 100644 --- a/gdb/syscalls/s390-linux.xml +++ b/gdb/syscalls/s390-linux.xml @@ -1,79 +1,76 @@ + - - - - - - - - - - + + + + + + - - - - - + + + + + - - - - + + + + - - + + - - - + + + - - - - - - + + + + + + - + - + - - - - + + + + - + - + - + - - + + @@ -82,72 +79,72 @@ - - - - + + + + - - - - - - - + + + + + + + - - + + - + - - - + + + - - + + - - - - + + + + - - + + - + - + - - - - - - - + + + + + + + - + - - - - + + + + @@ -157,41 +154,41 @@ - + - + - - - - - - - - - - - + + + + + + + + + + + - - + + - + - - - - - - - + + + + + + + @@ -200,52 +197,52 @@ - + - + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - + - + - - - - + + + + - + @@ -255,13 +252,13 @@ - - - - - - - + + + + + + + @@ -272,68 +269,68 @@ - + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - - + + + + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - + + - - + + - + @@ -346,22 +343,22 @@ - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/gdb/syscalls/s390-linux.xml.in b/gdb/syscalls/s390-linux.xml.in new file mode 100644 index 00000000000..56e92870685 --- /dev/null +++ b/gdb/syscalls/s390-linux.xml.in @@ -0,0 +1,367 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gdb/syscalls/s390x-linux.xml b/gdb/syscalls/s390x-linux.xml index 91a8927c085..57b837e209a 100644 --- a/gdb/syscalls/s390x-linux.xml +++ b/gdb/syscalls/s390x-linux.xml @@ -1,134 +1,131 @@ + - - - - - - - - - - + + + + + + - - - - - - - - + + + + + + + + - - + + - - - + + + - - - - - - + + + + + + - - - - - - + + + + + + - + - + - - - + + + - - - - + + + + - - - - - - + + + + + + - - - + + + - - - + + + - - + + - - - - + + + + - - + + - + - + - - - - - - + + + + + + - + - - - - + + + + @@ -138,30 +135,30 @@ - + - + - - - - - - - - - - + + + + + + + + + + - - + + - + - + @@ -170,50 +167,50 @@ - + - + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - + - + - - - - + + + + - + @@ -223,12 +220,12 @@ - - - - - - + + + + + + @@ -239,68 +236,68 @@ - + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - - + + + + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - + + - - + + - + @@ -313,22 +310,22 @@ - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/gdb/syscalls/s390x-linux.xml.in b/gdb/syscalls/s390x-linux.xml.in new file mode 100644 index 00000000000..91a8927c085 --- /dev/null +++ b/gdb/syscalls/s390x-linux.xml.in @@ -0,0 +1,334 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gdb/syscalls/sparc-linux.xml b/gdb/syscalls/sparc-linux.xml index 70115ab0a54..79ba7f016a0 100644 --- a/gdb/syscalls/sparc-linux.xml +++ b/gdb/syscalls/sparc-linux.xml @@ -1,238 +1,235 @@ + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - + - + - - - - - - + + + + + + - + - - - - - - + + + + + + - + - + - + - + - - - - + + + + - - - + + + - - - - + + + + - + - - - + + + - - + + - - + + - + - - + + - + - - - + + + - - - - - - - + + + + + + + - - + + - - - - + + + + - - - + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - + - - - - - - - - - - + + + + + + + + + + - + - + - - - - - - + + + + + + - - - - - - - - + + + + + + + + - - - + + + - - - - + + + + - - - - - - - - - + + + + + + + + + - - - - - + + + + + - - - + + + - + @@ -242,17 +239,17 @@ - + - + - - - - - - - + + + + + + + @@ -262,12 +259,12 @@ - + - + - + @@ -291,54 +288,54 @@ - - + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - + + + + - + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/gdb/syscalls/sparc-linux.xml.in b/gdb/syscalls/sparc-linux.xml.in new file mode 100644 index 00000000000..70115ab0a54 --- /dev/null +++ b/gdb/syscalls/sparc-linux.xml.in @@ -0,0 +1,344 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gdb/syscalls/sparc64-linux.xml b/gdb/syscalls/sparc64-linux.xml index 7dd62b4ccbd..7fd4d76ce39 100644 --- a/gdb/syscalls/sparc64-linux.xml +++ b/gdb/syscalls/sparc64-linux.xml @@ -1,221 +1,218 @@ + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - + - + - - - - + + + + - - - - - - + + + + + + - + - + - + - + - - - + + + - - - + + + - - - - - - - - + + + + + + + + - + - + - - - - + + + + - - - + + + - - - - - - - + + + + + + + - - + + - - - - + + + + - - - + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - + - - - - - - - - - + + + + + + + + + - + - + - - - - - - + + + + + + - - - - - - - - + + + + + + + + - - - + + + - - - - + + + + - - - - - - - - - + + + + + + + + + - - - - - + + + + + - - - + + + - + @@ -225,16 +222,16 @@ - - + + - - - - - - - + + + + + + + @@ -244,12 +241,12 @@ - + - + - + @@ -273,54 +270,54 @@ - - + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - + + + + - + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/gdb/syscalls/sparc64-linux.xml.in b/gdb/syscalls/sparc64-linux.xml.in new file mode 100644 index 00000000000..7dd62b4ccbd --- /dev/null +++ b/gdb/syscalls/sparc64-linux.xml.in @@ -0,0 +1,326 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 547776147c4..1406201b53e 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2016-07-23 Gabriel Krisman Bertazi + + * gdb.base/catch-syscall.exp (do_syscall_tests): Add call + to test_catch_syscall_group. + (test_catch_syscall_group): New. + 2016-07-21 Tom Tromey * gdb.rust/simple.rs (main): Use empty struct expression. diff --git a/gdb/testsuite/gdb.base/catch-syscall.exp b/gdb/testsuite/gdb.base/catch-syscall.exp index f3ab6cbfbb8..a739c46d02d 100644 --- a/gdb/testsuite/gdb.base/catch-syscall.exp +++ b/gdb/testsuite/gdb.base/catch-syscall.exp @@ -385,6 +385,42 @@ proc test_catch_syscall_fail_nodatadir {} { } } +proc test_catch_syscall_group {} { + global decimal + + set sysnum "\\\[${decimal}\\\]" + + gdb_test "catch syscall g:process" \ + "Catchpoint $decimal \\(syscalls (\'(clone|fork|execve|exit)\' $sysnum)+.*" \ + "set catchpoint on a group of syscalls" + + gdb_test "catch syscall group:process read" \ + "Catchpoint $decimal \\(syscalls (\'(clone|fork|execve|exit)\' $sysnum)+.*read.*\\)" \ + "set catchpoints on a group of syscalls and on a single syscall" + + gdb_test "catch syscall group:" \ + "Unknown syscall group ''\." \ + "set catchpoints on an invalid group" + + gdb_test "catch syscall g:junk" \ + "Unknown syscall group 'junk'\." \ + "set catchpoints on an unknown group." + + gdb_test "complete catch syscall g:proc" \ + "catch syscall g:process" \ + "complete catch syscall group with 'g:' prefix" + + gdb_test "complete catch syscall group:proc" \ + "catch syscall group:process" \ + "complete catch syscall group with 'group:' prefix" + + gdb_test_sequence "complete catch syscall g" \ + "complete catch syscall group suggests 'group:' prefix" { + "group:descriptor" "group:file" "group:ipc" "group:memory" + "group:network" "group:process" "group:signal" + } +} + proc do_syscall_tests {} { # NOTE: We don't have to point gdb at the correct data-directory. # For the build tree that is handled by INTERNAL_GDBFLAGS. @@ -435,6 +471,9 @@ proc do_syscall_tests {} { # Testing if the 'catch syscall' command works when switching to # different architectures on-the-fly (PR gdb/10737). if [runto_main] then { test_catch_syscall_multi_arch } + + # Testing the 'catch' syscall command for a group of syscalls. + if [runto_main] then { test_catch_syscall_group } } proc test_catch_syscall_without_args_noxml {} { diff --git a/gdb/xml-syscall.c b/gdb/xml-syscall.c index ceaf750104a..141ca3da922 100644 --- a/gdb/xml-syscall.c +++ b/gdb/xml-syscall.c @@ -77,6 +77,20 @@ get_syscall_names (struct gdbarch *gdbarch) return NULL; } +struct syscall * +get_syscalls_by_group (struct gdbarch *gdbarch, const char *group) +{ + syscall_warn_user (); + return NULL; +} + +const char ** +get_syscall_group_names (struct gdbarch *gdbarch) +{ + syscall_warn_user (); + return NULL; +} + #else /* ! HAVE_LIBEXPAT */ /* Structure which describes a syscall. */ @@ -92,6 +106,19 @@ typedef struct syscall_desc } *syscall_desc_p; DEF_VEC_P(syscall_desc_p); +/* Structure of a syscall group. */ +typedef struct syscall_group_desc +{ + /* The group name. */ + + char *name; + + /* The syscalls that are part of the group. */ + + VEC(syscall_desc_p) *syscalls; +} *syscall_group_desc_p; +DEF_VEC_P(syscall_group_desc_p); + /* Structure that represents syscalls information. */ struct syscalls_info { @@ -99,6 +126,10 @@ struct syscalls_info VEC(syscall_desc_p) *syscalls; + /* The syscall groups. */ + + VEC(syscall_group_desc_p) *groups; + /* Variable that will hold the last known data-directory. This is useful to know whether we should re-read the XML info for the target. */ @@ -126,11 +157,21 @@ syscalls_info_free_syscalls_desc (struct syscall_desc *sd) xfree (sd->name); } +/* Free syscall_group_desc members but not the structure itself. */ + +static void +syscalls_info_free_syscall_group_desc (struct syscall_group_desc *sd) +{ + VEC_free (syscall_desc_p, sd->syscalls); + xfree (sd->name); +} + static void free_syscalls_info (void *arg) { struct syscalls_info *syscalls_info = (struct syscalls_info *) arg; struct syscall_desc *sysdesc; + struct syscall_group_desc *groupdesc; int i; xfree (syscalls_info->my_gdb_datadir); @@ -144,6 +185,17 @@ free_syscalls_info (void *arg) VEC_free (syscall_desc_p, syscalls_info->syscalls); } + if (syscalls_info->groups != NULL) + { + for (i = 0; + VEC_iterate (syscall_group_desc_p, + syscalls_info->groups, i, groupdesc); + i++) + syscalls_info_free_syscall_group_desc (groupdesc); + + VEC_free (syscall_group_desc_p, syscalls_info->groups); + } + xfree (syscalls_info); } @@ -153,16 +205,73 @@ make_cleanup_free_syscalls_info (struct syscalls_info *syscalls_info) return make_cleanup (free_syscalls_info, syscalls_info); } +/* Create a new syscall group. Return pointer to the + syscall_group_desc structure that represents the new group. */ + +static struct syscall_group_desc * +syscall_group_create_syscall_group_desc (struct syscalls_info *syscalls_info, + const char *group) +{ + struct syscall_group_desc *groupdesc = XCNEW (struct syscall_group_desc); + + groupdesc->name = xstrdup (group); + + VEC_safe_push (syscall_group_desc_p, syscalls_info->groups, groupdesc); + + return groupdesc; +} + +/* Add a syscall to the group. If group doesn't exist, create it. */ + +static void +syscall_group_add_syscall (struct syscalls_info *syscalls_info, + struct syscall_desc *syscall, + const char *group) +{ + struct syscall_group_desc *groupdesc = NULL; + int i; + + /* Search for an existing group. */ + for (i = 0; + VEC_iterate (syscall_group_desc_p, syscalls_info->groups, i, groupdesc); + i++) + { + if (strcmp (groupdesc->name, group) == 0) + break; + } + + if (groupdesc == NULL) + { + /* No group was found with this name. We must create a new + one. */ + groupdesc = syscall_group_create_syscall_group_desc (syscalls_info, + group); + } + + VEC_safe_push (syscall_desc_p, groupdesc->syscalls, syscall); +} + static void syscall_create_syscall_desc (struct syscalls_info *syscalls_info, - const char *name, int number) + const char *name, int number, + char *groups) { struct syscall_desc *sysdesc = XCNEW (struct syscall_desc); + char *group; sysdesc->name = xstrdup (name); sysdesc->number = number; VEC_safe_push (syscall_desc_p, syscalls_info->syscalls, sysdesc); + + /* Add syscall to its groups. */ + if (groups != NULL) + { + for (group = strtok (groups, ","); + group != NULL; + group = strtok (NULL, ",")) + syscall_group_add_syscall (syscalls_info, sysdesc, group); + } } /* Handle the start of a element. */ @@ -177,6 +286,7 @@ syscall_start_syscall (struct gdb_xml_parser *parser, /* syscall info. */ char *name = NULL; int number = 0; + char *groups = NULL; len = VEC_length (gdb_xml_value_s, attributes); @@ -186,13 +296,15 @@ syscall_start_syscall (struct gdb_xml_parser *parser, name = (char *) attrs[i].value; else if (strcmp (attrs[i].name, "number") == 0) number = * (ULONGEST *) attrs[i].value; + else if (strcmp (attrs[i].name, "groups") == 0) + groups = (char *) attrs[i].value; else internal_error (__FILE__, __LINE__, _("Unknown attribute name '%s'."), attrs[i].name); } gdb_assert (name); - syscall_create_syscall_desc (data->syscalls_info, name, number); + syscall_create_syscall_desc (data->syscalls_info, name, number, groups); } @@ -200,6 +312,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 }, + { "groups", GDB_XML_AF_OPTIONAL, NULL, NULL }, { NULL, GDB_XML_AF_NONE, NULL, NULL } }; @@ -321,6 +434,34 @@ init_syscalls_info (struct gdbarch *gdbarch) set_gdbarch_syscalls_info (gdbarch, syscalls_info); } +/* Search for a syscall group by its name. Return syscall_group_desc + structure for the group if found or NULL otherwise. */ + +static struct syscall_group_desc * +syscall_group_get_group_by_name (const struct syscalls_info *syscalls_info, + const char *group) +{ + struct syscall_group_desc *groupdesc; + int i; + + if (syscalls_info == NULL) + return NULL; + + if (group == NULL) + return NULL; + + /* Search for existing group. */ + for (i = 0; + VEC_iterate (syscall_group_desc_p, syscalls_info->groups, i, groupdesc); + i++) + { + if (strcmp (groupdesc->name, group) == 0) + return groupdesc; + } + + return NULL; +} + static int xml_get_syscall_number (struct gdbarch *gdbarch, const char *syscall_name) @@ -388,6 +529,75 @@ xml_list_of_syscalls (struct gdbarch *gdbarch) return names; } +/* 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. */ + +static struct syscall * +xml_list_syscalls_by_group (struct gdbarch *gdbarch, const char *group) +{ + struct syscalls_info *syscalls_info = gdbarch_syscalls_info (gdbarch); + struct syscall_group_desc *groupdesc; + struct syscall_desc *sysdesc; + struct syscall *syscalls = NULL; + int nsyscalls; + int i; + + if (syscalls_info == NULL) + return NULL; + + groupdesc = syscall_group_get_group_by_name (syscalls_info, group); + if (groupdesc == NULL) + return NULL; + + nsyscalls = VEC_length (syscall_desc_p, groupdesc->syscalls); + syscalls = (struct syscall*) xmalloc ((nsyscalls + 1) + * sizeof (struct syscall)); + + for (i = 0; + VEC_iterate (syscall_desc_p, groupdesc->syscalls, i, sysdesc); + i++) + { + syscalls[i].name = sysdesc->name; + syscalls[i].number = sysdesc->number; + } + + /* Add final element marker. */ + syscalls[i].name = NULL; + syscalls[i].number = 0; + + return syscalls; +} + +/* Return a NULL terminated list of syscall groups or an empty list, if + no syscall group is available. Return NULL, if there is no syscall + information available. */ + +static const char ** +xml_list_of_groups (struct gdbarch *gdbarch) +{ + struct syscalls_info *syscalls_info = gdbarch_syscalls_info (gdbarch); + struct syscall_group_desc *groupdesc; + const char **names = NULL; + int i; + int ngroups; + + if (syscalls_info == NULL) + return NULL; + + ngroups = VEC_length (syscall_group_desc_p, syscalls_info->groups); + names = (const char**) xmalloc ((ngroups + 1) * sizeof (char *)); + + for (i = 0; + VEC_iterate (syscall_group_desc_p, syscalls_info->groups, i, groupdesc); + i++) + names[i] = groupdesc->name; + + names[i] = NULL; + + return names; +} + void set_xml_syscall_file_name (struct gdbarch *gdbarch, const char *name) { @@ -422,4 +632,24 @@ get_syscall_names (struct gdbarch *gdbarch) return xml_list_of_syscalls (gdbarch); } +/* See comment in xml-syscall.h. */ + +struct syscall * +get_syscalls_by_group (struct gdbarch *gdbarch, const char *group) +{ + init_syscalls_info (gdbarch); + + return xml_list_syscalls_by_group (gdbarch, group); +} + +/* See comment in xml-syscall.h. */ + +const char ** +get_syscall_group_names (struct gdbarch *gdbarch) +{ + init_syscalls_info (gdbarch); + + return xml_list_of_groups (gdbarch); +} + #endif /* ! HAVE_LIBEXPAT */ diff --git a/gdb/xml-syscall.h b/gdb/xml-syscall.h index b0dd401cc80..407613ec018 100644 --- a/gdb/xml-syscall.h +++ b/gdb/xml-syscall.h @@ -50,4 +50,20 @@ 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. */ + +struct syscall *get_syscalls_by_group (struct gdbarch *gdbarch, + const char *group); + +/* Function used to retrieve the list of syscall groups in the system. + Return an array of strings terminated by a NULL element. The list + must be freed by the caller. Return NULL if there is no syscall + information available. */ + +const char **get_syscall_group_names (struct gdbarch *gdbarch); + #endif /* XML_SYSCALL_H */ -- 2.30.2