Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 345010 - Null Pointer Exception is raised when I open a file in Kernel Source view in Systemtap IDE
Summary: Null Pointer Exception is raised when I open a file in Kernel Source view in ...
Status: RESOLVED FIXED
Alias: None
Product: Linux Tools
Classification: Tools
Component: Systemtap (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: anithra CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-06 14:37 EDT by Otavio Pontes CLA
Modified: 2011-10-13 12:41 EDT (History)
4 users (show)

See Also:


Attachments
Using only systemtap editors to open kernel files. (1.77 KB, patch)
2011-07-07 09:05 EDT, Otavio Pontes CLA
no flags Details | Diff
Another approach is to hardcode the supported editors like this. (2.54 KB, patch)
2011-09-16 11:20 EDT, Otavio Pontes CLA
no flags Details | Diff
Systemtap: Using only stp editors to open files in stap perspective (3.92 KB, patch)
2011-09-16 13:42 EDT, Otavio Pontes CLA
anithra: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Otavio Pontes CLA 2011-05-06 14:37:09 EDT
Build Identifier: M20110210-1200

When I try to open a kernel source file using the Kernel Source tab in Systemtap IDE perspective it raises a NullPointerException complaining that: "Could not open the editor: Editor could not be initialized.". And cdt is installed and works with c projects.
This was tested in fedora 14, RHEL6 and arch linux, using eclipse-3.6.2.

Details of the error message:
java.lang.NullPointerException
	at org.eclipse.cdt.internal.ui.editor.CEditor.updateScalabilityMode(CEditor.java:1412)
	at org.eclipse.cdt.internal.ui.editor.CEditor.doSetInput(CEditor.java:1359)
	at org.eclipse.ui.texteditor.AbstractTextEditor$19.run(AbstractTextEditor.java:3043)
	at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:464)
	at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:372)
	at org.eclipse.jface.window.ApplicationWindow$1.run(ApplicationWindow.java:759)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
	at org.eclipse.jface.window.ApplicationWindow.run(ApplicationWindow.java:756)
	at org.eclipse.ui.internal.WorkbenchWindow.run(WorkbenchWindow.java:2606)
	at org.eclipse.ui.texteditor.AbstractTextEditor.internalInit(AbstractTextEditor.java:3061)
	at org.eclipse.ui.texteditor.AbstractTextEditor.init(AbstractTextEditor.java:3088)
	at org.eclipse.ui.internal.EditorManager.createSite(EditorManager.java:798)
	at org.eclipse.ui.internal.EditorReference.createPartHelper(EditorReference.java:647)
	at org.eclipse.ui.internal.EditorReference.createPart(EditorReference.java:465)
	at org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:595)
	at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:313)
	at org.eclipse.ui.internal.presentations.PresentablePart.setVisible(PresentablePart.java:180)
	at org.eclipse.ui.internal.presentations.util.PresentablePartFolder.select(PresentablePartFolder.java:270)
	at org.eclipse.ui.internal.presentations.util.LeftToRightTabOrder.select(LeftToRightTabOrder.java:65)
	at org.eclipse.ui.internal.presentations.util.TabbedStackPresentation.selectPart(TabbedStackPresentation.java:473)
	at org.eclipse.ui.internal.PartStack.refreshPresentationSelection(PartStack.java:1254)
	at org.eclipse.ui.internal.PartStack.setSelection(PartStack.java:1207)
	at org.eclipse.ui.internal.PartStack.showPart(PartStack.java:1606)
	at org.eclipse.ui.internal.PartStack.add(PartStack.java:497)
	at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:103)
	at org.eclipse.ui.internal.PartStack.add(PartStack.java:483)
	at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:112)
	at org.eclipse.ui.internal.EditorSashContainer.addEditor(EditorSashContainer.java:63)
	at org.eclipse.ui.internal.EditorAreaHelper.addToLayout(EditorAreaHelper.java:225)
	at org.eclipse.ui.internal.EditorAreaHelper.addEditor(EditorAreaHelper.java:213)
	at org.eclipse.ui.internal.EditorManager.createEditorTab(EditorManager.java:778)
	at org.eclipse.ui.internal.EditorManager.openEditorFromDescriptor(EditorManager.java:677)
	at org.eclipse.ui.internal.EditorManager.openEditor(EditorManager.java:638)
	at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditorBatched(WorkbenchPage.java:2860)
	at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(WorkbenchPage.java:2768)
	at org.eclipse.ui.internal.WorkbenchPage.access$11(WorkbenchPage.java:2760)
	at org.eclipse.ui.internal.WorkbenchPage$10.run(WorkbenchPage.java:2711)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2707)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2691)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2674)
	at org.eclipse.linuxtools.systemtap.ui.ide.actions.hidden.KernelSourceAction.run(KernelSourceAction.java:162)
	at org.eclipse.linuxtools.systemtap.ui.ide.views.KernelBrowserView$2.doubleClick(KernelBrowserView.java:70)
	at org.eclipse.jface.viewers.StructuredViewer$1.run(StructuredViewer.java:824)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:49)
	at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:175)
	at org.eclipse.jface.viewers.StructuredViewer.fireDoubleClick(StructuredViewer.java:822)
	at org.eclipse.jface.viewers.AbstractTreeViewer.handleDoubleSelect(AbstractTreeViewer.java:1421)
	at org.eclipse.jface.viewers.StructuredViewer$4.widgetDefaultSelected(StructuredViewer.java:1225)
	at org.eclipse.jface.util.OpenStrategy.fireDefaultSelectionEvent(OpenStrategy.java:238)
	at org.eclipse.jface.util.OpenStrategy.access$0(OpenStrategy.java:235)
	at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java:296)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1258)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3540)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3161)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2640)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2604)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2438)
	at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:671)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:664)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:620)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:575)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1408)


Reproducible: Always

Steps to Reproduce:
1. Install systemtap plugin from linuxtools
2. Click in window->Open Perspective->Other and selecting 'Systemtap IDE'
3. Click in Kernel Source tab.
4. A dialog will be displayed asking for kernel sources location. Type the correct path.
5. Double click a .c or .h file in Kernel Source browser
6. Error happens.
Comment 1 Otavio Pontes CLA 2011-07-06 15:25:08 EDT
I did some extra tests and the problem doesn't happen when I use an eclipse without cdt installed or when I set the systemtap c editor as the default editor for .c and .h files. Using the eclipse Text Editor also fails.
Hardcoding the systemtap c editor for opening c/c++/h files in kernel source browser worked fine for me too.
Comment 2 Otavio Pontes CLA 2011-07-07 09:05:41 EDT
Created attachment 199259 [details]
Using only systemtap editors to open kernel files.
Comment 3 Otavio Pontes CLA 2011-07-07 09:06:20 EDT
(In reply to comment #2)
> Created attachment 199259 [details]
> Using only systemtap editors to open kernel files.
This is a patch to use only systemtap editors do visualize files from kernel in kernel Source View. This is not the perfect solution, but it works. I couldn't realize how to open files using any other editor.
Comment 4 Roland Grunberg CLA 2011-09-16 09:32:56 EDT
Just as a possiblity : http://wiki.eclipse.org/FAQ_How_do_I_dynamically_register_an_editor_to_handle_a_given_extension%3F . It is possible to register file extentions with an editor, but I think this would override defaults for the CDT. Maybe there's a way to unregister the editor when not in the Systemtap perspective.
Comment 5 Otavio Pontes CLA 2011-09-16 10:48:53 EDT
(In reply to comment #4)
> Just as a possiblity :
> http://wiki.eclipse.org/FAQ_How_do_I_dynamically_register_an_editor_to_handle_a_given_extension%3F
> . It is possible to register file extentions with an editor, but I think this
> would override defaults for the CDT. Maybe there's a way to unregister the
> editor when not in the Systemtap perspective.

Doing this is really messing with the default editors for other perspectives. And that is not good. Not sure if unregistering the Systemtap editors would be a good solution too. What I can do is to get the correct Systemtap editor using IEditorRegistry#findEditor. But to do that I would need to check the file extension in systemtap, and I was avoiding this.
Comment 6 Otavio Pontes CLA 2011-09-16 11:20:58 EDT
Created attachment 203494 [details]
Another approach is to hardcode the supported editors like this.
Comment 7 Roland Grunberg CLA 2011-09-16 12:43:59 EDT
I think the previous patch ( https://bugs.eclipse.org/bugs/attachment.cgi?id=199259 ) is probably best.
Comment 8 Roland Grunberg CLA 2011-09-16 12:52:27 EDT
Also, it could probably be applid (similarly) in systemtap/org.eclipse.linuxtools.systemtap.ui.editor/src/org/eclipse/linuxtools/systemtap/ui/editor/actions/file/OpenFileAction.java:getEditor .
Comment 9 Otavio Pontes CLA 2011-09-16 13:31:01 EDT
(In reply to comment #7)
> I think the previous patch (
> https://bugs.eclipse.org/bugs/attachment.cgi?id=199259 ) is probably best.

I agree
Comment 10 Otavio Pontes CLA 2011-09-16 13:42:58 EDT
Created attachment 203509 [details]
Systemtap: Using only stp editors to open files in stap perspective

This patch fixes this problem for kernel files and for files opened by the File->Open menu.
Comment 11 Roland Grunberg CLA 2011-10-12 16:56:46 EDT
Anithra, if the patch is fine with you then I think it should be commited (with iplog set on the patch itself).
Comment 12 anithra CLA 2011-10-13 12:41:08 EDT
Thanks Otavio/Roland,