This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Re: [Bug translator/1326] negative shifting
- From: Eugene Teo <eteo at redhat dot com>
- To: systemtap at sources dot redhat dot com
- Date: Sat, 22 Apr 2006 14:59:40 +0800
- Subject: Re: [Bug translator/1326] negative shifting
- Organization: Red Hat Asia Pacific
- References: <20050910162637.1326.fche@redhat.com> <20060421193708.721.qmail@sourceware.org>
Hi all,
Fix committed.
I checked in some changes in testsuite/systemtap.samples/arith.stp
to assert some of the shift values as well.
Eugene
eteo at redhat dot com wrote:
> ------- Additional Comments From eteo at redhat dot com 2006-04-21 19:37 -------
> I have added code to handle negative left and right shift count.
>
> [eteo@eteo systemtap]$ cat negshift.stp
> probe begin {
> printf("%d\n", 120 >> -2);
> printf("%d\n", 120 >> 0);
> printf("%d\n", 120 >> 1);
> printf("%d\n", 120 >> 2);
> printf("%d\n", 120 << 2);
> printf("%d\n", 120 << 1);
> printf("%d\n", 120 << 0);
> printf("%d\n", 120 << -2);
> exit();
> }
> [eteo@eteo systemtap]$ stap negshift.stp
> 120
> 120
> 60
> 30
> 480
> 240
> 120
> 120
>
> Here's the patch:
>
> diff -Naurp src.default/ChangeLog src/ChangeLog
> --- src.default/ChangeLog 2006-04-20 19:52:54.000000000 +0800
> +++ src/ChangeLog 2006-04-22 03:25:29.000000000 +0800
> @@ -1,3 +1,9 @@
> +2006-04-21 Eugene Teo <eteo@redhat.com>
> +
> + PR 1326
> + * translate.cxx (c_unparser::visit_binary_expression): Handle
> + negative left and right shift count.
> +
> 2006-04-19 Eugene Teo <eteo@redhat.com>
>
> PR 2014
> diff -Naurp src.default/translate.cxx src/translate.cxx
> --- src.default/translate.cxx 2006-04-19 03:19:35.000000000 +0800
> +++ src/translate.cxx 2006-04-22 03:24:15.000000000 +0800
> @@ -2466,9 +2466,7 @@ c_unparser::visit_binary_expression (bin
> e->op == "*" ||
> e->op == "&" ||
> e->op == "|" ||
> - e->op == "^" ||
> - e->op == "<<" ||
> - e->op == ">>")
> + e->op == "^")
> {
> o->line() << "((";
> e->left->visit (this);
> @@ -2476,6 +2474,15 @@ c_unparser::visit_binary_expression (bin
> e->right->visit (this);
> o->line() << "))";
> }
> + else if (e->op == ">>" ||
> + e->op == "<<")
> + {
> + o->line() << "((";
> + e->left->visit (this);
> + o->line() << ") " << e->op << "max(min(";
> + e->right->visit (this);
> + o->line() << ", (int64_t)64LL), (int64_t)0LL))"; // between 0 and 64
> + }
> else if (e->op == "/" ||
> e->op == "%")
> {
>
>
--
eteo redhat.com ph: +65 6490 4142 http://www.kernel.org/~eugeneteo
gpg fingerprint: 47B9 90F6 AE4A 9C51 37E0 D6E1 EA84 C6A2 58DF 8823