Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 353986

Summary: OProfile can't be started with Eclipse Plug-in
Product: z_Archived Reporter: Eric <eas>
Component: LinuxToolsAssignee: OProfile Inbox <linux.oprofile-inbox>
Status: CLOSED FIXED QA Contact:
Severity: blocker    
Priority: P3 CC: akurtakov, jjohnstn, kksebasti, overholt, sgehwolf
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Eric CLA 2011-08-05 05:50:42 EDT
Used Software:
Running CentOS 5.4-i386-server VMWare Image from [1].
Eclipse Helios SR2
Linux Tools Nightly Build from 03.08.2011
OProfile 0.94 from repository
Reproduced with Java Versions 1.6_20, 1.6_26, 1.7 since I thought it might relate to bug #336977

Setup:
Executed Linux Tools 'install.sh'
Commented out 'requiretty' in sudoers file, because this might lead to another error "opcontrol process error output: sudo: sorry, you must have a tty to run 
sudo" (Eclipse Error Log)
OProfile _does_ work using commands from [2] .

Reproduce:
When starting OProfile from within Eclipse via "Profile As > Profile with OProfile" Eclipse shows an error - for clarity stack strace and other data from Eclipse Error Log are below.

It is further not possible to do any configurations in the menu to setup OProfile - this will just fill the Eclipse Error Log.

--

[1]...http://www.thoughtpolice.co.uk/vmware/
[2]...http://blogs.epfl.ch/article/24223

Data from Eclipse Error Log when starting OProfile

>>>

eclipse.buildId=M20110210-1200
java.version=1.7.0
java.vendor=Oracle Corporation
BootLoader constants: OS=linux, ARCH=x86, WS=gtk, NL=en_US
Framework arguments:  -product org.eclipse.epp.package.linuxtools.product
Command-line arguments:  -os linux -ws gtk -arch x86 -product org.eclipse.epp.package.linuxtools.product


Error
Thu Aug 04 16:23:44 EDT 2011
An internal error occurred during: "Launching op (1)".

java.lang.ExceptionInInitializerError
at org.eclipse.linuxtools.oprofile.core.linux.LinuxOpcontrolProvider.setupDaemon(LinuxOpcontrolProvider.java:182)
at org.eclipse.linuxtools.oprofile.launch.launching.AbstractOprofileLaunchConfigurationDelegate.oprofileSetupDaemon(AbstractOprofileLaunchConfigurationDelegate.java:130)
at org.eclipse.linuxtools.oprofile.launch.launching.OprofileLaunchConfigurationDelegate.preExec(OprofileLaunchConfigurationDelegate.java:42)
at org.eclipse.linuxtools.oprofile.launch.launching.AbstractOprofileLaunchConfigurationDelegate.launch(AbstractOprofileLaunchConfigurationDelegate.java:66)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:853)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:702)
at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:924)
at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1128)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Caused by: java.lang.NullPointerException
at org.eclipse.linuxtools.oprofile.core.opxml.info.InfoAdapter.createHeaders(InfoAdapter.java:131)
at org.eclipse.linuxtools.oprofile.core.opxml.info.InfoAdapter.process(InfoAdapter.java:124)
at org.eclipse.linuxtools.oprofile.core.linux.OpxmlRunner.run(OpxmlRunner.java:111)
at org.eclipse.linuxtools.oprofile.core.linux.LinuxOpxmlProvider$OpInfoRunner.run(LinuxOpxmlProvider.java:55)
at org.eclipse.linuxtools.oprofile.core.linux.LinuxOpxmlProvider$OpInfoRunner.run0(LinuxOpxmlProvider.java:46)
at org.eclipse.linuxtools.oprofile.core.daemon.OpInfo.getInfo(OpInfo.java:85)
at org.eclipse.linuxtools.oprofile.core.Oprofile._initializeOprofileCore(Oprofile.java:94)
at org.eclipse.linuxtools.oprofile.core.Oprofile.initializeOprofileModule(Oprofile.java:64)
at org.eclipse.linuxtools.oprofile.core.Oprofile.<clinit>(Oprofile.java:43)
... 9 more

<<<
Comment 1 Eric CLA 2011-08-05 05:57:14 EDT
I am also not able to get it working on a real machine...details might follow.  Hope the stackstrace is enought for the moment.
Comment 2 Severin Gehwolf CLA 2011-08-05 09:22:33 EDT
(In reply to comment #1)
> I am also not able to get it working on a real machine...details might follow. 
> Hope the stackstrace is enought for the moment.

Since you are getting the sudo error, it looks like you ran install.sh and install-noconsolehelper.sh afterwards. You want to only run one of them. Since you are on CentOS, you'd want to use install.sh only. Make sure you have the usermode package installed.

On a physical machine, Eclipse oprofile should work after that.
Comment 3 Severin Gehwolf CLA 2011-08-05 09:34:19 EDT
(In reply to comment #0)
> Used Software:
> Running CentOS 5.4-i386-server VMWare Image from [1].

Since you are running Eclipse oprofile from within a VM, you have to run oprofile in timer interrupt mode. If the module gets loaded like this (as root):

$ modprobe oprofile timer=1

And you attempt to profile from within Eclipse you'll likely get the following error:

"You cannot specify any performance eventsbecause Oprofile is in timer mode"

This is due to the fact that the Eclipse integration of oprofile explicitly sets the event via opcontrol. I've changed the summary of this bug to reflect that this isn't supported at the moment. Yet, I think we should.

We'd need to do a couple of things to support this:

1. Have a way to determine if the module should get loaded in timer interrupt mode
2. Make sure to be able to do this in a secure way. I.e. There is no option to opcontrol which directs it to load the module in timer interrupt mode. Hence, we can't use the opcontrol wrapper we use at this time.
3. Don't set events explicitly if in timer interrupt mode.
Comment 4 Severin Gehwolf CLA 2011-08-05 09:59:14 EDT
Here is the sequence of commands Eclipse oprofile emits to opcontrol:

# opcontrol --reset 
# opcontrol --setup --separate=none --no-vmlinux --image=/path/to/binary --callgraph=0 --event=default 
# opcontrol --start 
# oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/scripts/opcontrol --dump 
# opcontrol --shutdown

This only works on a physical machine. Trying to execute

# opcontrol --deinit
# modprobe oprofile timer=1
# opcontrol --setup --separate=none --no-vmlinux --image=/path/to/binary --callgraph=0 --event=default

in a VM gives this error:

You cannot specify any performance events because Oprofile is in timer mode

Using this instead:

# opcontrol --setup --separate=none --no-vmlinux --image=/path/to/binary

does not yield an error. This pretty much describes what needs to be done to support this.
Comment 5 Eric CLA 2011-08-05 15:41:24 EDT
Maybe everything got a bit confusing.

#1
As I have stated it does _not_ work for me in 

- VM

AND

- on a physical machine (CentOS 5.6 + Eclipse Indigo)

#2
Before posting the stacktrace I executed both uninstall scripts and just executed the 'install.sh'

#3
I would like to direct your attention to
'Caused by: java.lang.NullPointerException'
in the stacktrace.

I am not able to do anything within Eclipse concerning OProfile.

There is no possibility for me to configure OProfile in any way in the 'Profile Configuration'.

#4
After exectuing 
$ modprobe oprofile timer=1

Following stacktrace can be obtained:

java.lang.NoClassDefFoundError: Could not initialize class org.eclipse.linuxtools.oprofile.core.Oprofile
	at org.eclipse.linuxtools.oprofile.core.linux.LinuxOpcontrolProvider.setupDaemon(LinuxOpcontrolProvider.java:182)
	at org.eclipse.linuxtools.oprofile.launch.launching.AbstractOprofileLaunchConfigurationDelegate.oprofileSetupDaemon(AbstractOprofileLaunchConfigurationDelegate.java:130)
	at org.eclipse.linuxtools.oprofile.launch.launching.OprofileLaunchConfigurationDelegate.preExec(OprofileLaunchConfigurationDelegate.java:42)
	at org.eclipse.linuxtools.oprofile.launch.launching.AbstractOprofileLaunchConfigurationDelegate.launch(AbstractOprofileLaunchConfigurationDelegate.java:66)
	at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:853)
	at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:702)
	at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:924)
	at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1128)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)


#5
What I am gonna do:
Tomorrow I will verify the error message on the real machine.
I will put a configured VM image onto a FTP server showing the bug.

Before working around the problem, maybe someone could have a try on the VM image since it reflects the errors which also occur on the real machine.
Comment 6 Eric CLA 2011-08-06 12:14:07 EDT
Well, I tried on my Pentium III running CentOS 5.6

---

First, timer mode was enabled by default as described by [1].

To enable performance counters the kernel needs to be started with 'lapic' command

This can be done in '/boot/grub/menu.lst'

The command line will look like

kernel /vmlinuz-2.6.18-238.12.1.el5 ro root=/dev/VolGroup00/LogVol00 rhgb quiet lapic

[1]...http://oprofile.sourceforge.net/faq/ (Why is OProfile in timer mode on x86? I have performance counters...)

---

It was then possible to do profiling using performance counters with OProfile.

However, in Eclipse profiling with OProfile did not work.

Any ideas?

Stack trace below

>>>

eclipse.buildId=I20110613-1736
java.version=1.6.0_20
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=linux, ARCH=x86, WS=gtk, NL=en_US
Framework arguments:  -product org.eclipse.epp.package.cpp.product
Command-line arguments:  -os linux -ws gtk -arch x86 -product org.eclipse.epp.package.cpp.product

Error
Sat Aug 06 18:55:00 CEST 2011
An internal error occurred during: "Launching test".

java.lang.ExceptionInInitializerError
    at org.eclipse.linuxtools.oprofile.core.linux.LinuxOpcontrolProvider.setupDaemon(LinuxOpcontrolProvider.java:182)
    at org.eclipse.linuxtools.oprofile.launch.launching.AbstractOprofileLaunchConfigurationDelegate.oprofileSetupDaemon(AbstractOprofileLaunchConfigurationDelegate.java:130)
    at org.eclipse.linuxtools.oprofile.launch.launching.OprofileLaunchConfigurationDelegate.preExec(OprofileLaunchConfigurationDelegate.java:42)
    at org.eclipse.linuxtools.oprofile.launch.launching.AbstractOprofileLaunchConfigurationDelegate.launch(AbstractOprofileLaunchConfigurationDelegate.java:66)
    at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:854)
    at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:703)
    at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:928)
    at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1132)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Caused by: java.lang.NullPointerException
    at org.eclipse.linuxtools.oprofile.core.opxml.info.InfoAdapter.createHeaders(InfoAdapter.java:131)
    at org.eclipse.linuxtools.oprofile.core.opxml.info.InfoAdapter.process(InfoAdapter.java:124)
    at org.eclipse.linuxtools.oprofile.core.linux.OpxmlRunner.run(OpxmlRunner.java:111)
    at org.eclipse.linuxtools.oprofile.core.linux.LinuxOpxmlProvider$OpInfoRunner.run(LinuxOpxmlProvider.java:55)
    at org.eclipse.linuxtools.oprofile.core.linux.LinuxOpxmlProvider$OpInfoRunner.run0(LinuxOpxmlProvider.java:46)
    at org.eclipse.linuxtools.oprofile.core.daemon.OpInfo.getInfo(OpInfo.java:85)
    at org.eclipse.linuxtools.oprofile.core.Oprofile._initializeOprofileCore(Oprofile.java:94)
    at org.eclipse.linuxtools.oprofile.core.Oprofile.initializeOprofileModule(Oprofile.java:64)
    at org.eclipse.linuxtools.oprofile.core.Oprofile.<clinit>(Oprofile.java:43)
    ... 9 more

<<<
Comment 7 Alexander Kurtakov CLA 2013-01-19 04:43:54 EST
Is this problem still reproducible with Linux tools 1.2 release?
Comment 8 Alexander Kurtakov CLA 2014-01-16 05:51:51 EST
No reply for a year. Closing. Please reopen if you still see the problem with Linux Tools 2.2 release.