Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH v5 0/5] Catch syscall groups
@ 2016-05-15 20:32 Gabriel Krisman Bertazi
  2016-05-15 20:32 ` [PATCH v5 3/5] Add tests for catching groups of syscalls on supported architectures Gabriel Krisman Bertazi
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Gabriel Krisman Bertazi @ 2016-05-15 20:32 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves, sergiodj, dje, Gabriel Krisman Bertazi

Hi,

Last year, I submitted a proposal to include support to catch groups of
related syscalls in GDB.  My goal was to allow users to just write
"catch syscall group:network" to catch all network related syscalls,
instead of listing every single one of them in the command line.  This
idea came after what is done by the "strace -e trace=" kind of
expressions, and a suggestion made by Tom Tromey in the Sourceware
bugzilla.

Anyway, the patch iterated a little in this list and got positive
feedback and great suggestions from Sergio, Pedro and Doug.  Eventually,
I got very busy with college/work stuff, and had to put this on
hold.. until now.  I'm looking to put more effort on this to get it
upstream anytime soon.

There are just a few differences from the last iteration I submitted.
In summary, I followed Doug's suggestion and made the XML generation
happen only when building in maintainer's mode.  On that mode, we invoke
xsltproc to transform the xml.in files to .xml files that get read by
GDB.  I also plan to keep the generated xmls in the repository, such
that when building outside of maintainers mode, we don't depend on
xltproc.

As usual, the patches don't iclude the generated files.  Therefore, to
test it, you need to use maintainer mode at least once to get the xml
files generated.  When I push the patch set upstream, I'll ammend the
commit to include generated files, such that it doesn't break bisectable
builds.

If anyone is feeling lazy and just want to see things working, I have a
version that includes the generated files at my git:

git clone git://git.krisman.be/binutils-gdb.git -b syscall-group

Thanks,


Gabriel Krisman Bertazi (5):
  Implemement support for groups of syscalls in the xml-syscall    
    interface.
  Add support to catch groups of syscalls.
  Add tests for catching groups of syscalls on supported    
    architectures.
  Include group information to xml syscall files.
  Update documentation on catching a group of related syscalls.

 gdb/NEWS                                           |   5 +
 gdb/break-catch-syscall.c                          | 104 +++++++--
 gdb/configure.ac                                   |  10 +
 gdb/data-directory/Makefile.in                     |   4 +
 gdb/doc/gdb.texinfo                                |  28 ++-
 .../{aarch64-linux.xml => aarch64-linux.xml.in}    |   0
 .../{amd64-linux.xml => amd64-linux.xml.in}        |   0
 gdb/syscalls/apply-defaults.xsl                    |  27 +++
 gdb/syscalls/{arm-linux.xml => arm-linux.xml.in}   |   0
 gdb/syscalls/{bfin-linux.xml => bfin-linux.xml.in} |   0
 gdb/syscalls/gdb-syscalls.dtd                      |   3 +-
 gdb/syscalls/{i386-linux.xml => i386-linux.xml.in} |   0
 gdb/syscalls/linux-defaults.xml.in                 | 243 +++++++++++++++++++++
 .../{mips-n32-linux.xml => mips-n32-linux.xml.in}  |   0
 .../{mips-n64-linux.xml => mips-n64-linux.xml.in}  |   0
 .../{mips-o32-linux.xml => mips-o32-linux.xml.in}  |   0
 gdb/syscalls/{ppc-linux.xml => ppc-linux.xml.in}   |   0
 .../{ppc64-linux.xml => ppc64-linux.xml.in}        |   0
 gdb/syscalls/{s390-linux.xml => s390-linux.xml.in} |   0
 .../{s390x-linux.xml => s390x-linux.xml.in}        |   0
 .../{sparc-linux.xml => sparc-linux.xml.in}        |   0
 .../{sparc64-linux.xml => sparc64-linux.xml.in}    |   0
 gdb/testsuite/gdb.base/catch-syscall.exp           |  39 ++++
 gdb/xml-syscall.c                                  | 232 +++++++++++++++++++-
 gdb/xml-syscall.h                                  |  16 ++
 25 files changed, 693 insertions(+), 18 deletions(-)
 rename gdb/syscalls/{aarch64-linux.xml => aarch64-linux.xml.in} (100%)
 rename gdb/syscalls/{amd64-linux.xml => amd64-linux.xml.in} (100%)
 create mode 100644 gdb/syscalls/apply-defaults.xsl
 rename gdb/syscalls/{arm-linux.xml => arm-linux.xml.in} (100%)
 rename gdb/syscalls/{bfin-linux.xml => bfin-linux.xml.in} (100%)
 rename gdb/syscalls/{i386-linux.xml => i386-linux.xml.in} (100%)
 create mode 100644 gdb/syscalls/linux-defaults.xml.in
 rename gdb/syscalls/{mips-n32-linux.xml => mips-n32-linux.xml.in} (100%)
 rename gdb/syscalls/{mips-n64-linux.xml => mips-n64-linux.xml.in} (100%)
 rename gdb/syscalls/{mips-o32-linux.xml => mips-o32-linux.xml.in} (100%)
 rename gdb/syscalls/{ppc-linux.xml => ppc-linux.xml.in} (100%)
 rename gdb/syscalls/{ppc64-linux.xml => ppc64-linux.xml.in} (100%)
 rename gdb/syscalls/{s390-linux.xml => s390-linux.xml.in} (100%)
 rename gdb/syscalls/{s390x-linux.xml => s390x-linux.xml.in} (100%)
 rename gdb/syscalls/{sparc-linux.xml => sparc-linux.xml.in} (100%)
 rename gdb/syscalls/{sparc64-linux.xml => sparc64-linux.xml.in} (100%)

-- 
2.4.3


^ permalink raw reply	[flat|nested] 8+ messages in thread
* Re: [PATCH v5 2/5] Add support to catch groups of syscalls.
@ 2016-05-17 16:55 Doug Evans
  0 siblings, 0 replies; 8+ messages in thread
From: Doug Evans @ 2016-05-17 16:55 UTC (permalink / raw)
  To: Gabriel Krisman Bertazi; +Cc: gdb-patches, palves, sergiodj

Gabriel Krisman Bertazi writes:
  > This implements the catchpoint side.  While parsing 'catch syscall'
  > arguments, we verify if the argument is a syscall group and expand it to
  > a list of syscalls that are part of that group.
  >
  > gdb/
  >
  > 	* 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.

Hi.
Just more nits.

  > diff --git a/gdb/break-catch-syscall.c b/gdb/break-catch-syscall.c
  > index dbebdda..be034ac 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 (strncmp (cur_name, "g:", sizeof ("g:") - 1) == 0
  > +	       || strncmp (cur_name, "group:", sizeof ("group:") - 1) == 0)

Use startswith here.
[See common/common-utils.h.]

  > +	{
  > +	  /* 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,59 @@ 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 (strncmp (prefix, "g:", sizeof ("g:") - 1) == 0
  > +      || strncmp (prefix, "group:", sizeof ("group:") - 1) == 0)

startswith

  > +    {
  > +      /* 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;
  >  }
  >
  > --
  > 2.4.3
  >


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-05-17 16:55 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-15 20:32 [PATCH v5 0/5] Catch syscall groups Gabriel Krisman Bertazi
2016-05-15 20:32 ` [PATCH v5 3/5] Add tests for catching groups of syscalls on supported architectures Gabriel Krisman Bertazi
2016-05-15 20:32 ` [PATCH v5 1/5] Implemement support for groups of syscalls in the xml-syscall interface Gabriel Krisman Bertazi
2016-05-15 20:32 ` [PATCH v5 4/5] Include group information to xml syscall files Gabriel Krisman Bertazi
2016-05-15 20:32 ` [PATCH v5 5/5] Update documentation on catching a group of related syscalls Gabriel Krisman Bertazi
2016-05-16  2:30   ` Eli Zaretskii
2016-05-15 20:32 ` [PATCH v5 2/5] Add support to catch groups of syscalls Gabriel Krisman Bertazi
2016-05-17 16:55 Doug Evans

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox