Hide Forgot
Created attachment 475585 [details] reproducer Description of problem: When modifying return value of syscall, the retstr doesn't reflect the change. Version-Release number of selected component (if applicable): systemtap-1.4-3.fc15.x86_64 How reproducible: Always Steps to Reproduce: 1. Paste the following script to write.stp probe begin { printf("%6s -> %6s | %7s\n", "name", "retstr", "$return"); } probe syscall.write.return { if (pid() == target()) { printf("%6s -> %6s | %7d\n", name, retstr, $return); $return = -1; printf("%6s -> %6s | %7d\n", name, retstr, $return); } } 2. Run `stap -g ./write.stp -c /bin/echo' 3. Output is something like: /bin/echo: write error name -> retstr | $return write -> 1 | 1 write -> 1 | -1 write -> 11 | 11 write -> 11 | -1 write -> 11 | 11 write -> 11 | -1 write -> 1 | 1 write -> 1 | -1 Actual results: Value of retstr is not changed. Expected results: Value of retstr reflects value of $return Additional info: The same thing is at least on FC14, RHEL5 and RHEL6.
This is expected behaviour. Script-level variables such as "retstr" that are set by script aliases such as "syscall.write.return" are only *initialized* by those aliases based upon any underlying $variables. They do not constitute some sort of macro that reevaluates the $variables every time. Can you find some documentation that is ambiguous on this point? We can extend that.
Ok, sorry, my bad. I should have looked at the source code. But it wouldn't hurt to explicitly state the info above as warning in stapprobes(3stap) manpage, end of SYSCALL section. Feel free to close this.
We'll add some documentation about this in a future version of systemtap.