public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Masami Hiramatsu <mhiramat@redhat.com>
To: Jonathan Nieder <jrnieder@gmail.com>
Cc: linux-kernel@vger.kernel.org, Jim Keniston <jkenisto@us.ibm.com>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	x86@kernel.org
Subject: Re: [PATCH] x86: Fix kprobes build with non-gawk awk
Date: Mon, 14 Dec 2009 09:17:10 -0500	[thread overview]
Message-ID: <4B2648E6.4050603@redhat.com> (raw)
In-Reply-To: <20091213220437.GA27718@progeny.tock>

Hi Jonathan,

Jonathan Nieder wrote:
> The instruction attribute table generator fails when run by mawk
> or original-awk:
> 
>  $ mawk -f arch/x86/tools/gen-insn-attr-x86.awk \
> 	arch/x86/lib/x86-opcode-map.txt > /dev/null
>  Semantic error at 240: Second IMM error
>  $ echo $?
>  1
> 
> Line 240 contains "c8: ENTER Iw,Ib", which indicates that this
> instruction has two immediate operands, the second of which is
> one byte.  The script loops through the immediate operands using
> a for loop.
> 
> Unfortunately, there is no guarantee in awk that a for (variable
> in array) loop will return the indices in increasing order.
> Internally, both original-awk and mawk iterate over a hash table
> for this purpose, and both implementations happen to produce the
> index 2 before 1.  The supposed second immediate operand is more
> than one byte wide, producing the error.

Oh, I see.

> 
> So loop over the indices in increasing order instead.  As a
> side-effect, with mawk this means the silly two-entry hash table
> never has to be built.

Thank you for fixing it!

Acked-by: Masami Hiramatsu <mhiramat@redhat.com>

> 
> Cc: Masami Hiramatsu <mhiramat@redhat.com>
> Cc: Jim Keniston <jkenisto@us.ibm.com>
> Cc: Frederic Weisbecker <fweisbec@gmail.com>
> Cc: x86@kernel.org
> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
> ---
>  arch/x86/tools/gen-insn-attr-x86.awk |   10 +++++-----
>  1 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/arch/x86/tools/gen-insn-attr-x86.awk b/arch/x86/tools/gen-insn-attr-x86.awk
> index e34e92a..7a68506 100644
> --- a/arch/x86/tools/gen-insn-attr-x86.awk
> +++ b/arch/x86/tools/gen-insn-attr-x86.awk
> @@ -226,12 +226,12 @@ function add_flags(old,new) {
>  }
>  
>  # convert operands to flags.
> -function convert_operands(opnd,       i,imm,mod)
> +function convert_operands(count,opnd,       i,j,imm,mod)
>  {
>  	imm = null
>  	mod = null
> -	for (i in opnd) {
> -		i  = opnd[i]
> +	for (j = 1; j <= count; j++) {
> +		i = opnd[j]
>  		if (match(i, imm_expr) == 1) {
>  			if (!imm_flag[i])
>  				semantic_error("Unknown imm opnd: " i)
> @@ -282,8 +282,8 @@ function convert_operands(opnd,       i,imm,mod)
>  		# parse one opcode
>  		if (match($i, opnd_expr)) {
>  			opnd = $i
> -			split($(i++), opnds, ",")
> -			flags = convert_operands(opnds)
> +			count = split($(i++), opnds, ",")
> +			flags = convert_operands(count, opnds)
>  		}
>  		if (match($i, ext_expr))
>  			ext = $(i++)

-- 
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America), Inc.
Software Solutions Division

e-mail: mhiramat@redhat.com


  reply	other threads:[~2009-12-14 14:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-13 22:04 [PATCH] x86: Fix kprobes build with non-gawk awk Jonathan Nieder
2009-12-14 14:17 ` Masami Hiramatsu [this message]
2009-12-15 23:51   ` Jonathan Nieder
2009-12-15 20:30 ` [tip:x86/urgent] " tip-bot for Jonathan Nieder

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=4B2648E6.4050603@redhat.com \
    --to=mhiramat@redhat.com \
    --cc=fweisbec@gmail.com \
    --cc=jkenisto@us.ibm.com \
    --cc=jrnieder@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=x86@kernel.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