Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Gabriel Krisman Bertazi <gabriel@krisman.be>
To: gdb-patches@sourceware.org
Cc: Gabriel Krisman Bertazi <gabriel@krisman.be>
Subject: [RFC PATCH 2/3] Add support to catch groups of syscalls.
Date: Wed, 08 Oct 2014 02:51:00 -0000	[thread overview]
Message-ID: <1412736678-2760-3-git-send-email-gabriel@krisman.be> (raw)
In-Reply-To: <1412736678-2760-1-git-send-email-gabriel@krisman.be>

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/

	* breakpoint.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): Include syscall groups to the list of
	word completion.
---
 gdb/breakpoint.c | 73 +++++++++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 57 insertions(+), 16 deletions(-)

diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index e2170b4..5243916 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -12117,22 +12117,50 @@ catch_syscall_split_args (char *arg)
       /* Check if the user provided a syscall name or a number.  */
       syscall_number = (int) strtol (cur_name, &endptr, 0);
       if (*endptr == '\0')
-	get_syscall_by_number (syscall_number, &s);
+	{
+	  get_syscall_by_number (syscall_number, &s);
+
+	  /* Ok, it's valid.  */
+	  VEC_safe_push (int, result, s.number);
+	}
       else
 	{
-	  /* We have a name.  Let's check if it's valid and convert it
-	     to a number.  */
-	  get_syscall_by_name (cur_name, &s);
-
-	  if (s.number == UNKNOWN_SYSCALL)
-	    /* Here we have to issue an error instead of a warning,
-	       because GDB cannot do anything useful if there's no
-	       syscall number to be caught.  */
+	  const char **syscall_list;
+
+	  /*  If we have a syscall group, expand it to a list of
+	      syscalls.  */
+	  syscall_list = get_syscall_names_by_group (cur_name);
+
+	  if (syscall_list == NULL)
 	    error (_("Unknown syscall name '%s'."), cur_name);
-	}
 
-      /* Ok, it's valid.  */
-      VEC_safe_push (int, result, s.number);
+	  if (syscall_list[0] == NULL)
+	    {
+	      /* If syscall_list is empty, cur_name is a syscall name
+		 instead of a group.  We push it into the group
+		 list.  */
+	      syscall_list[0] = cur_name;
+	      syscall_list[1] = NULL;
+	    }
+
+	  for (i = 0; syscall_list[i]; i++)
+	    {
+	      get_syscall_by_name (syscall_list[i], &s);
+
+	      if (s.number == UNKNOWN_SYSCALL)
+		{
+		  /* Here we have to issue an error instead of a warning,
+		     because GDB cannot do anything useful if there's no
+		     syscall number to be caught.  */
+		  error (_("Unknown syscall name '%s'."), syscall_list[i]);
+		}
+
+	      /* Ok, it's valid.  */
+	      VEC_safe_push (int, result, s.number);
+	    }
+
+	  xfree (syscall_list);
+	}
     }
 
   discard_cleanups (cleanup);
@@ -15615,11 +15643,24 @@ static VEC (char_ptr) *
 catch_syscall_completer (struct cmd_list_element *cmd,
                          const char *text, const char *word)
 {
-  const char **list = get_syscall_names ();
-  VEC (char_ptr) *retlist
-    = (list == NULL) ? NULL : complete_on_enum (list, word, word);
+  VEC (char_ptr) *retlist;
+  const char **syscall_list = get_syscall_names ();
+  const char **group_list = get_syscall_group_names ();
+
+  VEC (char_ptr) *sys_retlist
+    = (syscall_list == NULL) ? NULL : complete_on_enum (syscall_list,
+							word, word);
+
+  VEC (char_ptr) *group_retlist
+    = (group_list == NULL) ? NULL : complete_on_enum (group_list, word, word);
+
+  retlist = VEC_merge (char_ptr, sys_retlist, group_retlist);
+
+  xfree (syscall_list);
+  xfree (group_list);
+  VEC_free (char_ptr, sys_retlist);
+  VEC_free (char_ptr, group_retlist);
 
-  xfree (list);
   return retlist;
 }
 
-- 
1.9.3


  reply	other threads:[~2014-10-08  2:51 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-08  2:51 [RFC PATCH 0/3] Catch syscall group Gabriel Krisman Bertazi
2014-10-08  2:51 ` Gabriel Krisman Bertazi [this message]
2014-10-08 19:07   ` [RFC PATCH 2/3] Add support to catch groups of syscalls Sergio Durigan Junior
2014-10-08 19:46     ` Doug Evans
2014-10-08 20:48       ` Sergio Durigan Junior
2014-10-12 21:37         ` Gabriel Krisman Bertazi
2014-10-12 22:52           ` Sergio Durigan Junior
2014-10-13 16:49           ` Doug Evans
2014-10-20  4:52             ` Gabriel Krisman Bertazi
2014-10-20 19:39               ` Sergio Durigan Junior
2014-10-27 19:20                 ` Doug Evans
2014-10-08  2:51 ` [RFC PATCH 1/3] Implemement support for groups of syscalls in the xml-syscall interface Gabriel Krisman Bertazi
2014-10-08 17:21   ` Sergio Durigan Junior
2014-10-08  2:52 ` [RFC PATCH 3/3] Create syscall groups for x86_64 Gabriel Krisman Bertazi
2014-10-08 19:00   ` Sergio Durigan Junior
2014-10-08 16:10 ` [RFC PATCH 0/3] Catch syscall group Sergio Durigan Junior
2014-10-12 21:12   ` Gabriel Krisman Bertazi
2014-10-12 22:55     ` Sergio Durigan Junior
2014-10-08 16:12 ` Doug Evans

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=1412736678-2760-3-git-send-email-gabriel@krisman.be \
    --to=gabriel@krisman.be \
    --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