The following testcase shows that the original assignment of the variable is ignored: probe begin { a = 5 // printf("%d ", a) printf("%d ", (a++)) printf("%d ", (++a)) printf("%d ", (a--)) printf("%d\n", (--a)) exit() } $ stap test.stp 0 2 2 0 If we uncomment the actually first use the original assigned value of a things look correct: $ stap test.stp 5 5 7 7 5 This is an translation optimization issue, the original script also prints out the correct value when unoptimized: $ stap -u test.stp 5 7 7 5
This seems to have been caused by commit 982b88bd which solved bug #6954. commit 982b88bd950381434a8325e550eff9df59f59dcd Author: Wenji Huang <wenji.huang@oracle.com> Date: Thu Jan 28 14:16:43 2010 +0800 PR6954: make ++/-- operation trigger automatic global printing * staptree.cxx (varuse_collecting_visitor::visit_arrayindex): Regard operations as pure writes. * testsuite/systemtap.base/global_end.exp: Add test case. * testsuite/systemtap.base/global_end.stp: Ditto. Note comment #3 of that bug: "FWIW, I wonder why we didn't just go this route earlier. I worry that pretending that ++ only writes to its argument may mess up some optimization, I can't think of one right now. We'll keep this special case in mind." Reverting this commit fixes this bug (but obviously introduces bug #6954 again).
commit d1cf0b627cfc9002b54c2ad40507de9ee6a2ce90 Author: Mark Wielaard <mjw@redhat.com> Date: Wed May 12 14:39:55 2010 +0200 Add testcase for PR11590 optimized pre/postfix operators * testsuite/systemtap.base/prepost_optim.stp: New test. * testsuite/systemtap.base/prepost_optim.exp: Harness. commit ad8c38ffc62200d6ba6ebc0b0339967cdd84669a Author: Mark Wielaard <mjw@redhat.com> Date: Wed May 12 14:31:59 2010 +0200 Add testcase for PR6954 ++ operations not triggering automatic global printing * testsuite/systemtap.base/global_end_var.stp: New test. * testsuite/systemtap.base/global_end.exp: Add xfail. commit 980759f3da625c5697440efc1bfda046c247866e Author: Mark Wielaard <mjw@redhat.com> Date: Wed May 12 14:16:26 2010 +0200 PR11590 Revert "PR6954: make ++/-- operation trigger automatic global printing" This reverts commit 982b88bd950381434a8325e550eff9df59f59dcd. Pretending that pre/postfix ++/-- operations only writes to its argument messes up the optimization of a variable that is assigned and then only used through post/prefix ++/--operators.
Get college assignment help from top professionals at a very affordable price for students. Every assignment content is plagiarism-free and 100% unique. To know more click on https://www.globalassignmenthelp.com/college-assignment-help