diff mbox series

[4/4] as-name: specify the names via -faddress-space-names

Message ID 20181208220401.10409-5-luc.vanoostenryck@gmail.com (mailing list archive)
State Superseded, archived
Headers show
Series display address spaces by name | expand

Commit Message

Luc Van Oostenryck Dec. 8, 2018, 10:04 p.m. UTC
Currently, the syntax of attribute(address-space()) accept
an identifier as well as the usual 'address space number'.

However, developers with a recent version can't benefit
of the display of address spaces by name before the kernel
definition of __user is changed.

To let early adopters to already benefit, allow to specify
the address names via the command line (which ignore unknown
options and is thus forward compatible): -faddress-space-names.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 lib.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

Comments

Ramsay Jones Dec. 9, 2018, 3:04 a.m. UTC | #1
On 08/12/2018 22:04, Luc Van Oostenryck wrote:
> Currently, the syntax of attribute(address-space()) accept
> an identifier as well as the usual 'address space number'.
> 
> However, developers with a recent version can't benefit
> of the display of address spaces by name before the kernel
> definition of __user is changed.
> 
> To let early adopters to already benefit, allow to specify
> the address names via the command line (which ignore unknown
> options and is thus forward compatible): -faddress-space-names.
> 
> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
> ---
>  lib.c | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/lib.c b/lib.c
> index d8f652421..3d0fbf27b 100644
> --- a/lib.c
> +++ b/lib.c
> @@ -924,6 +924,19 @@ static int handle_fpasses(const char *arg, const char *opt, const struct flag *f
>  	return 0;
>  }
>  
> +static int handle_faddress_space_names(const char *arg, const char *opt, const struct flag *flag, int options)
> +{
> +	int max = ARRAY_SIZE(address_space_names);
use MAX_AS_NAMES below instead?

> +	char *buf = (char *) opt;
> +	char *name;
> +	int i;
> +
> +	for (i = 0;  i < max && (name = strsep(&buf, ",")); i++)

Hmm, i = 0, so the first address-space name is given the
'invalid' address-space number?

> +		address_space_names[i] = built_in_ident(name);
> +
> +	return 1;
> +}
> +
>  static int handle_fdiagnostic_prefix(const char *arg, const char *opt, const struct flag *flag, int options)
>  {
>  	switch (*opt) {
> @@ -964,6 +977,7 @@ static int handle_fmax_warnings(const char *arg, const char *opt, const struct f
>  }
>  
>  static struct flag fflags[] = {
> +	{ "address-space-names=",NULL,	handle_faddress_space_names },
>  	{ "diagnostic-prefix",	NULL,	handle_fdiagnostic_prefix },
>  	{ "dump-ir",		NULL,	handle_fdump_ir },
>  	{ "linearize",		NULL,	handle_fpasses,	PASS_LINEARIZE },> 

Document -faddress-space-names and filter it out in cgcc.

[that's me done for tonight!]

ATB,
Ramsay Jones
Luc Van Oostenryck Dec. 9, 2018, 1:36 p.m. UTC | #2
On Sun, Dec 09, 2018 at 03:04:02AM +0000, Ramsay Jones wrote:
> On 08/12/2018 22:04, Luc Van Oostenryck wrote:
> > @@ -924,6 +924,19 @@ static int handle_fpasses(const char *arg, const char *opt, const struct flag *f
> > +	char *buf = (char *) opt;
> > +	char *name;
> > +	int i;
> > +
> > +	for (i = 0;  i < max && (name = strsep(&buf, ",")); i++)
> 
> Hmm, i = 0, so the first address-space name is given the
> 'invalid' address-space number?

It was more for consistency reasons. In the kernel the address space
1 & 2 are called '__user' & '__iomem' and, in the few place where it is
needed, the default AS (0) is called '__kernel'.
The idea here was to be able to specify them all:
	-faddress-space-names=__kernel,__user,__iomem, ...
but '__kernel' would never be used (unless some debug code ask for it).

Anyway, this patch will be dropped with the next version.
 
-- Luc
diff mbox series

Patch

diff --git a/lib.c b/lib.c
index d8f652421..3d0fbf27b 100644
--- a/lib.c
+++ b/lib.c
@@ -924,6 +924,19 @@  static int handle_fpasses(const char *arg, const char *opt, const struct flag *f
 	return 0;
 }
 
+static int handle_faddress_space_names(const char *arg, const char *opt, const struct flag *flag, int options)
+{
+	int max = ARRAY_SIZE(address_space_names);
+	char *buf = (char *) opt;
+	char *name;
+	int i;
+
+	for (i = 0;  i < max && (name = strsep(&buf, ",")); i++)
+		address_space_names[i] = built_in_ident(name);
+
+	return 1;
+}
+
 static int handle_fdiagnostic_prefix(const char *arg, const char *opt, const struct flag *flag, int options)
 {
 	switch (*opt) {
@@ -964,6 +977,7 @@  static int handle_fmax_warnings(const char *arg, const char *opt, const struct f
 }
 
 static struct flag fflags[] = {
+	{ "address-space-names=",NULL,	handle_faddress_space_names },
 	{ "diagnostic-prefix",	NULL,	handle_fdiagnostic_prefix },
 	{ "dump-ir",		NULL,	handle_fdump_ir },
 	{ "linearize",		NULL,	handle_fpasses,	PASS_LINEARIZE },