DISCLAIMER: I am new to oprofile.
--------------------------
The Problem
opcontrol fails when I run it on both of my linux boxes. Both are Ubuntu 6.10 (Edgy Eft).
--------------------------
What I Did
I ran the command line:
sudo opcontrol --no-vmlinux --start
and the following output was printed:
Using default event: CPU_CLK_UNHALTED:100000:0:1:1
/usr/bin/opcontrol: 1: arith: syntax error: "NR_CHOSEN - 1"
No events given.
--------------------------
The Stopgap Fix
After a bunch of troubleshooting, I tracked the problem down to /bin/sh (the interpreter for opcontrol) being symlinked to /bin/dash in my distro instead of /bin/bash.
This command line works:
sudo bash opcontrol --no-vmlinux --start
-------------------------
Permanent Solution Options
1. The interpreter for opcontrol could be changed from one that sometimes does not work (i.e. /bin/sh) to one that works (i.e. /bin/bash).
2. opcontrol, and possibly other programs related to oprofile, could be rewritten to work with dash.
3. A warning could be printed if opcontrol detects that it is being interpreted by dash. However, for some reason, the SHELL variable is set to /bin/bash inside dash. I have no idea why this is done, but it means the SHELL variable is not a reliable method of detecting which shell is being used.
Logged In: YES
user_id=53034
Originator: NO
The script is supposed to be shell agnostic. I'm not sure whether $((FOO - 1)) is POSIX or not.
Logged In: YES
user_id=1678773
Originator: NO
This is a bug in dash: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=329025
Logged In: YES
user_id=53034
Originator: NO
Then I'm much inclined to either get Ubuntu to ship their own hacked oprofile, and/or tell Ubuntu users to
switch to bash (as essentially everybody has to do anyway). We're not regressing beyond standard shell
behaviour to suit a poorly thought out decision by one vendor.
Obuntu used to have a problem with dash failing on $((NR_CHOSEN - 1)) in opcontrol. This form is, in fact, posix-compliant, which is why no action was taken on the part of the oprofile project. On May 12, 2009, Brian Bloniarz reported to the oprofile list that Obuntu has fixed this problem, and that opcontrol's use of the "let" built-in was the lone bashism that needed to be replaced with something posix-compliant. Brian posted a patch and it was committed to CVS on May 13. So this bug has now been resolved.