lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20160805181013.053409b3261aa52909226b64@kernel.org>
Date:	Fri, 5 Aug 2016 18:10:13 +0900
From:	Masami Hiramatsu <mhiramat@...nel.org>
To:	Naohiro Aota <naohiro.aota@...t.com>
Cc:	Peter Zijlstra <peterz@...radead.org>,
	Ingo Molnar <mingo@...hat.com>,
	Arnaldo Carvalho de Melo <acme@...nel.org>,
	Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
	Wang Nan <wangnan0@...wei.com>,
	Hemant Kumar <hemant@...ux.vnet.ibm.com>,
	<linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] perf probe: support signedness casting

On Fri, 5 Aug 2016 14:33:53 +0900
Naohiro Aota <naohiro.aota@...t.com> wrote:

> Perf-probe detects a variable's type and use the detected type to add new
> probe. Then, kprobes prints its variable in hexadecimal format if the
> variable is unsigned and prints in decimal if it is signed.
> 
> We sometimes want to see unsigned variable in decimal format (e.g.
> sector_t or size_t). In that case, we need to investigate variable's
> size manually to specify just signedness.
> 
> This patch add signedness casting support. By specifying "s" or "u" as a
> type, perf-probe will investigate variable size as usual and use
> the specified signedness.

OK, I could understand what the patch does from code. Please add an
example, and update tools/perf/Documentation/perf-probe.txt too.

Thank you,

> 
> Signed-off-by: Naohiro Aota <naohiro.aota@...t.com>
> ---
>  tools/perf/util/probe-finder.c | 15 ++++++++++++---
>  1 file changed, 12 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
> index f2d9ff0..5c290c6 100644
> --- a/tools/perf/util/probe-finder.c
> +++ b/tools/perf/util/probe-finder.c
> @@ -297,10 +297,13 @@ static int convert_variable_type(Dwarf_Die *vr_die,
>  	char sbuf[STRERR_BUFSIZE];
>  	int bsize, boffs, total;
>  	int ret;
> +	char sign;
>  
>  	/* TODO: check all types */
> -	if (cast && strcmp(cast, "string") != 0) {
> +	if (cast && strcmp(cast, "string") != 0 &&
> +	    strcmp(cast, "s") != 0 && strcmp(cast, "u") != 0) {
>  		/* Non string type is OK */
> +		/* and respect signedness cast */
>  		tvar->type = strdup(cast);
>  		return (tvar->type == NULL) ? -ENOMEM : 0;
>  	}
> @@ -361,6 +364,13 @@ static int convert_variable_type(Dwarf_Die *vr_die,
>  		return (tvar->type == NULL) ? -ENOMEM : 0;
>  	}
>  
> +	if (cast && (strcmp(cast, "u") == 0))
> +		sign = 'u';
> +	else if (cast && (strcmp(cast, "s") == 0))
> +		sign = 's';
> +	else
> +		sign = die_is_signed_type(&type) ? 's' : 'u';
> +
>  	ret = dwarf_bytesize(&type);
>  	if (ret <= 0)
>  		/* No size ... try to use default type */
> @@ -373,8 +383,7 @@ static int convert_variable_type(Dwarf_Die *vr_die,
>  			dwarf_diename(&type), MAX_BASIC_TYPE_BITS);
>  		ret = MAX_BASIC_TYPE_BITS;
>  	}
> -	ret = snprintf(buf, 16, "%c%d",
> -		       die_is_signed_type(&type) ? 's' : 'u', ret);
> +	ret = snprintf(buf, 16, "%c%d", sign, ret);
>  
>  formatted:
>  	if (ret < 0 || ret >= 16) {
> -- 
> 2.7.3
> 


-- 
Masami Hiramatsu <mhiramat@...nel.org>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ