From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 118828 invoked by alias); 26 May 2016 18:17:37 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 118814 invoked by uid 89); 26 May 2016 18:17:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 26 May 2016 18:17:26 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B3551B8920; Thu, 26 May 2016 18:17:25 +0000 (UTC) Received: from localhost (unused-10-15-17-51.yyz.redhat.com [10.15.17.51]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u4QIHOgM031035 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 26 May 2016 14:17:25 -0400 From: Sergio Durigan Junior To: Gabriel Krisman Bertazi Cc: gdb-patches@sourceware.org, palves@redhat.com, dje@google.com Subject: Re: [PATCH v6 2/5] Add support to catch groups of syscalls. References: <87shxd1mx2.fsf@oberon.home> <1463712948-9068-1-git-send-email-gabriel@krisman.be> <1463712948-9068-2-git-send-email-gabriel@krisman.be> X-URL: http://blog.sergiodj.net Date: Thu, 26 May 2016 18:17:00 -0000 In-Reply-To: <1463712948-9068-2-git-send-email-gabriel@krisman.be> (Gabriel Krisman Bertazi's message of "Thu, 19 May 2016 23:55:45 -0300") Message-ID: <87mvnc8z0r.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2016-05/txt/msg00470.txt.bz2 On Thursday, May 19 2016, Gabriel Krisman Bertazi wrote: > 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. Thanks for the patch. > 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. > --- > gdb/break-catch-syscall.c | 93 ++++++++++++++++++++++++++++++++++++++++++----- > 1 file changed, 84 insertions(+), 9 deletions(-) > > diff --git a/gdb/break-catch-syscall.c b/gdb/break-catch-syscall.c > index dbebdda..c564b8f 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; > } > > -- > 2.4.11 LGTM. -- Sergio GPG key ID: 237A 54B1 0287 28BF 00EF 31F4 D0EB 7628 65FC 5E36 Please send encrypted e-mail if possible http://sergiodj.net/