From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22309 invoked by alias); 29 Nov 2014 00:19:01 -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 22299 invoked by uid 89); 29 Nov 2014 00:19:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham version=3.3.2 X-HELO: layla.krisman.be Received: from layla.krisman.be (HELO layla.krisman.be) (176.31.208.35) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Sat, 29 Nov 2014 00:18:58 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (envelope-from ) id 1XuVeB-0000L8-Im for gdb-patches@sourceware.org; Sat, 29 Nov 2014 01:12:24 +0100 From: Gabriel Krisman Bertazi To: gdb-patches@sourceware.org Subject: Re: [ping PATCH v2 1/4] Implemement support for groups of syscalls in the xml-syscall interface. References: <1414956944-8856-1-git-send-email-gabriel@krisman.be> <1416596731-2170-1-git-send-email-gabriel@krisman.be> Date: Sat, 29 Nov 2014 00:19:00 -0000 In-Reply-To: <1416596731-2170-1-git-send-email-gabriel@krisman.be> (Gabriel Krisman Bertazi's message of "Fri, 21 Nov 2014 17:05:28 -0200") Message-ID: <87wq6ec10n.fsf_-_@anubis.Home> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" X-IsSubscribed: yes X-SW-Source: 2014-11/txt/msg00725.txt.bz2 --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Content-length: 12749 Gabriel Krisman Bertazi writes: > Hello, > > These are the updated patches after applying Sergio's suggestions. > > Is this good to go? > Ping. :) > gdb/ > > * syscalls/gdb-syscalls.dtd: Include group attribute to the > syscall element. > * 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. > (syscalls_info_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. > --- > gdb/syscalls/gdb-syscalls.dtd | 3 +- > gdb/xml-syscall.c | 230 ++++++++++++++++++++++++++++++++++++= +++++- > gdb/xml-syscall.h | 15 +++ > 3 files changed, 245 insertions(+), 3 deletions(-) > > diff --git a/gdb/syscalls/gdb-syscalls.dtd b/gdb/syscalls/gdb-syscalls.dtd > index 3ad3625..b60eb74 100644 > --- a/gdb/syscalls/gdb-syscalls.dtd > +++ b/gdb/syscalls/gdb-syscalls.dtd > @@ -11,4 +11,5 @@ > > name CDATA #REQUIRED > - number CDATA #REQUIRED> > + number CDATA #REQUIRED > + groups CDATA #OPTIONAL> > diff --git a/gdb/xml-syscall.c b/gdb/xml-syscall.c > index 987fe7a..0d11c3a 100644 > --- a/gdb/xml-syscall.c > +++ b/gdb/xml-syscall.c > @@ -77,6 +77,20 @@ get_syscall_names (struct gdbarch *gdbarch) > return NULL; > } >=20=20 > +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 */ >=20=20 > /* Structure which describes a syscall. */ > @@ -92,6 +106,19 @@ typedef struct syscall_desc > } *syscall_desc_p; > DEF_VEC_P(syscall_desc_p); >=20=20 > +/* 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 >=20=20 > VEC(syscall_desc_p) *syscalls; >=20=20 > + /* 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_de= sc *sd) > xfree (sd->name); > } >=20=20 > +/* 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 =3D arg; > struct syscall_desc *sysdesc; > + struct syscall_group_desc *groupdesc; > int i; >=20=20 > xfree (syscalls_info->my_gdb_datadir); > @@ -143,6 +184,15 @@ free_syscalls_info (void *arg) > syscalls_info_free_syscalls_desc (sysdesc); > VEC_free (syscall_desc_p, syscalls_info->syscalls); > } > + if (syscalls_info->groups !=3D NULL) > + { > + for (i =3D 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); > + } >=20=20 > xfree (syscalls_info); > } > @@ -153,16 +203,71 @@ make_cleanup_free_syscalls_info (struct syscalls_in= fo *syscalls_info) > return make_cleanup (free_syscalls_info, syscalls_info); > } >=20=20 > +/* 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 =3D XCNEW (struct syscall_group_d= esc); > + > + groupdesc->name =3D 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; > + int i; > + > + /* Search for an existing group. */ > + for (i =3D 0; > + VEC_iterate (syscall_group_desc_p, > + syscalls_info->groups, i, groupdesc); > + i++) > + if (strcmp (groupdesc->name, group) =3D=3D 0) > + break; > + > + if (groupdesc =3D=3D NULL) > + { > + /* No group was found with this name. We must create a new > + one. */ > + groupdesc =3D syscall_group_create_syscall_group_desc (syscalls_in= fo, > + 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 =3D XCNEW (struct syscall_desc); > + char *group; >=20=20 > sysdesc->name =3D xstrdup (name); > sysdesc->number =3D number; >=20=20 > VEC_safe_push (syscall_desc_p, syscalls_info->syscalls, sysdesc); > + > + /* Add syscall to its groups. */ > + if (groups !=3D NULL) > + for (group =3D strtok (groups, ","); > + group !=3D NULL; > + group =3D strtok (NULL, ",")) > + syscall_group_add_syscall (syscalls_info, sysdesc, group); > } >=20=20 > /* Handle the start of a element. */ > @@ -177,6 +282,7 @@ syscall_start_syscall (struct gdb_xml_parser *parser, > /* syscall info. */ > char *name =3D NULL; > int number =3D 0; > + char *groups =3D NULL; >=20=20 > len =3D VEC_length (gdb_xml_value_s, attributes); >=20=20 > @@ -186,13 +292,16 @@ syscall_start_syscall (struct gdb_xml_parser *parse= r, > name =3D attrs[i].value; > else if (strcmp (attrs[i].name, "number") =3D=3D 0) > number =3D * (ULONGEST *) attrs[i].value; > + else if (strcmp (attrs[i].name, "groups") =3D=3D 0) > + groups =3D attrs[i].value; > else > internal_error (__FILE__, __LINE__, > _("Unknown attribute name '%s'."), attrs[i].name= ); > } >=20=20 > gdb_assert (name); > - syscall_create_syscall_desc (data->syscalls_info, name, number); > + > + syscall_create_syscall_desc (data->syscalls_info, name, number, groups= ); > } >=20=20 >=20=20 > @@ -200,6 +309,7 @@ syscall_start_syscall (struct gdb_xml_parser *parser, > static const struct gdb_xml_attribute syscall_attr[] =3D { > { "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 } > }; >=20=20 > @@ -321,6 +431,33 @@ init_syscalls_info (struct gdbarch *gdbarch) > set_gdbarch_syscalls_info (gdbarch, syscalls_info); > } >=20=20 > +/* 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_in= fo, > + const char *group) > +{ > + struct syscall_group_desc *groupdesc; > + int i; > + > + if (syscalls_info =3D=3D NULL) > + return NULL; > + > + if (group =3D=3D NULL) > + return NULL; > + > + /* Search for existing group. */ > + for (i =3D 0; > + VEC_iterate (syscall_group_desc_p, > + syscalls_info->groups, i, groupdesc); > + i++) > + if (strcmp (groupdesc->name, group) =3D=3D 0) > + return groupdesc; > + > + return NULL; > +} > + > static int > xml_get_syscall_number (struct gdbarch *gdbarch, > const char *syscall_name) > @@ -388,6 +525,75 @@ xml_list_of_syscalls (struct gdbarch *gdbarch) > return names; > } >=20=20 > +/* 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 =3D gdbarch_syscalls_info (gdbarch= ); > + struct syscall_group_desc *groupdesc; > + struct syscall_desc *sysdesc; > + struct syscall *syscalls =3D NULL; > + int nsyscalls; > + int i; > + > + if (syscalls_info =3D=3D NULL) > + return NULL; > + > + groupdesc =3D syscall_group_get_group_by_name (syscalls_info, group); > + if (groupdesc =3D=3D NULL) > + return NULL; > + > + nsyscalls =3D VEC_length (syscall_desc_p, groupdesc->syscalls); > + syscalls =3D xmalloc ((nsyscalls + 1) * sizeof (struct syscall)); > + > + for (i =3D 0; > + VEC_iterate (syscall_desc_p, groupdesc->syscalls, i, sysdesc); > + i++) > + { > + syscalls[i].name =3D sysdesc->name; > + syscalls[i].number =3D sysdesc->number; > + } > + > + /* Add final element marker. */ > + syscalls[i].name =3D NULL; > + syscalls[i].number =3D 0; > + > + return syscalls; > +} > + > +/* Return the list of syscall groups. If no syscall group is > + available, return NULL. */ > + > +static const char ** > +xml_list_of_groups (struct gdbarch *gdbarch) > +{ > + struct syscalls_info *syscalls_info =3D gdbarch_syscalls_info (gdbarch= ); > + struct syscall_group_desc *groupdesc; > + const char **names =3D NULL; > + int i; > + int ngroups; > + > + if (syscalls_info =3D=3D NULL) > + return NULL; > + > + ngroups =3D VEC_length (syscall_group_desc_p, syscalls_info->groups); > + names =3D xmalloc ((ngroups + 1) * sizeof (char *)); > + > + for (i =3D 0; > + VEC_iterate (syscall_group_desc_p, > + syscalls_info->groups, i, groupdesc); > + i++) > + names[i] =3D groupdesc->name; > + > + names[i] =3D NULL; > + > + return names; > +} > + > void > set_xml_syscall_file_name (struct gdbarch *gdbarch, const char *name) > { > @@ -422,4 +628,24 @@ get_syscall_names (struct gdbarch *gdbarch) > return xml_list_of_syscalls (gdbarch); > } >=20=20 > +/* 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 42b9dea..9ba4e93 100644 > --- a/gdb/xml-syscall.h > +++ b/gdb/xml-syscall.h > @@ -50,4 +50,19 @@ void get_syscall_by_name (struct gdbarch *gdbarch, >=20=20 > const char **get_syscall_names (struct gdbarch *gdbarch); >=20=20 > +/* 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. */ > + > +const char **get_syscall_group_names (struct gdbarch *gdbarch); > + > #endif /* XML_SYSCALL_H */ --=20 Gabriel Krisman Bertazi --=-=-= Content-Type: application/pgp-signature Content-length: 818 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJUeRDZAAoJEO9pqxSS5VgPZxIP/2BobGxtBfUexvBWbzI/msLr 7b3xq7qsU3MFxmJZNpMW0tRUlOG6hAsiAooGo0ERzbo0mri3jToxiWriyfw3GKgb 1/n9Q0hhDBEGV4IokhfVYAWRZXBmimote9fM+RPN6hZ2QRAf0fTHoNZ0Hsi5DOZp /kxTN6DztnfECWBPHPvuEaW8UrE+ieByfzkmJQ2+XJfv1nWe4caVaMfLfYHwif4G 3C1vX//XKsGpLOhmF7b60rQQslqIKjc9p34itruqYOoNu9JQMb6gy/LUQgYu5khO RnzO+gOJ+yqne90KeIYaBb7tyc3JYNVzmPXy5WPOuIYY7cwxUyXna/UBuqM1U+Hx CSwGvbxvOXQ591xMujZUkOowHj/N2g/10ZnQZh/qIix3KD5BDwI4kpE5QBECd7D9 f11DCaZHC+uBpuUWrojB0yuE6foGFJuLQhvc7e1xEWUgTwlQZo1dhAvUy0P6rvvE eOa4A+prfdQRnGRblqe+ibTl7XF2tE5EHVtSuKKqn5t+fkotMaFIh4D3J9GSAZtt Yhu+Rs6Wm2jBTvu4O6zIj34pEMEnqcgqS0eszyRLnMOs/Ex63aGZrom6KI5JzfyH 8bIGBrPfF/ypWhlAhOIS4vNM6cfxm0R/PYuXtT9e/bn9MNwSQyy4nr831ybLxBnh ZjbbaMCCT+xGRWQ0UJ32 =CQAV -----END PGP SIGNATURE----- --=-=-=--