Tizen 2.0 Release tizen_2.0 submit/tizen_2.0/20130215.192345
authorHyungKyu Song <hk76.song@samsung.com>
Fri, 15 Feb 2013 15:59:18 +0000 (00:59 +0900)
committerHyungKyu Song <hk76.song@samsung.com>
Fri, 15 Feb 2013 15:59:18 +0000 (00:59 +0900)
371 files changed:
AUTHORS [new file with mode: 0644]
LICENSE.EPL [new file with mode: 0644]
NOTICE [new file with mode: 0644]
build.sh [new file with mode: 0644]
builder/build.properties.clean [new file with mode: 0644]
builder/customTargets.xml [new file with mode: 0644]
builder/metadata/data/platforms/tizen2.0/on-demand/eglibc-debuginfo_0.0.1_armel.tar [new file with mode: 0644]
builder/metadata/data/platforms/tizen2.0/on-demand/eglibc-debuginfo_0.0.1_i386.tar [new file with mode: 0644]
builder/metadata/pkginfo.manifest [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/.classpath [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/.project [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/.settings/org.eclipse.core.resources.prefs [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/.settings/org.eclipse.core.runtime.prefs [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/META-INF/MANIFEST.MF [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/NOTICE [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/README [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/about.html [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/build.properties [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/schema/OpxmlProvider.exsd [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/IOpcontrolProvider.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/IOpxmlProvider.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/OpcontrolException.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/Oprofile.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/OprofileCorePlugin.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/OprofileProperties.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/OpxmlException.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/daemon/OpEvent.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/daemon/OpInfo.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/daemon/OpUnitMask.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/daemon/OprofileDaemonEvent.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/daemon/OprofileDaemonOptions.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/linux/LinuxOpcontrolProvider.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/linux/LinuxOpxmlProvider.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/linux/OpxmlRunner.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/model/OpModelEvent.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/model/OpModelImage.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/model/OpModelRoot.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/model/OpModelSample.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/model/OpModelSession.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/model/OpModelSymbol.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/oprofile.properties [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/opxml/OprofileSAXHandler.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/opxml/OpxmlConstants.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/opxml/XMLProcessor.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/opxml/checkevent/CheckEventsProcessor.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/opxml/info/DefaultsProcessor.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/opxml/info/EventListProcessor.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/opxml/info/OpInfoProcessor.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/opxml/modeldata/DependentProcessor.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/opxml/modeldata/ModelDataProcessor.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/opxml/modeldata/SamplesProcessor.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/opxml/modeldata/SymbolsProcessor.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/opxml/sessions/SessionsProcessor.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/CommandManager.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/OprofileComm.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/OprofileCommonConstants.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/processor/checkevent/CheckEventsProcessor.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/processor/checkkernel/CheckKernelProcessor.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/processor/eventinfo/EventListProcessor.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/processor/eventinfo/OpInfoProcessor.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/processor/modeldata/ModelDataProcessor.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/processor/modeldata/handler/OprofileSAXHandler.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/processor/modeldata/handler/XMLParser.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/processor/modeldata/parser/BinaryParser.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/processor/modeldata/parser/ClassesParser.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/processor/modeldata/parser/DetailDataParser.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/processor/modeldata/parser/DetailTableParser.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/processor/modeldata/parser/ModuleParser.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/processor/modeldata/parser/ModuleSymbolParser.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/processor/modeldata/parser/SetupParser.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/processor/modeldata/parser/SymbolDetailsParser.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/processor/modeldata/parser/SymbolParser.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/processor/modeldata/parser/SymbolTableParser.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/processor/modeldata/util/ParserUtil.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/processor/sessions/SessionsProcessor.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/provider/OpcontrolDataProvider.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.launch.exe/.classpath [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.launch.exe/.project [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.launch.exe/.settings/org.eclipse.core.resources.prefs [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.launch.exe/.settings/org.eclipse.core.runtime.prefs [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.launch.exe/META-INF/MANIFEST.MF [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.launch.exe/NOTICE [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.launch.exe/build.properties [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.launch.exe/icons/event_tab.gif [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.launch.exe/icons/global_tab.gif [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.launch.exe/icons/profile_run.png [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.launch.exe/plugin.xml [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.launch.exe/src/org/tizen/oprofile/launch/Activator.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.launch.exe/src/org/tizen/oprofile/launch/NormalOprofileLaunchShortcut.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.launch.exe/src/org/tizen/oprofile/launch/TizenOprofileLaunchDelegate.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.launch.exe/src/org/tizen/oprofile/launch/configuration/NormalOprofileLaunchConfigurationTabGroup.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.launch/.classpath [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.launch/.project [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.launch/.settings/org.eclipse.core.resources.prefs [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.launch/.settings/org.eclipse.core.runtime.prefs [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.launch/META-INF/MANIFEST.MF [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.launch/META-INF/eclipse.inf [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.launch/NOTICE [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.launch/about.html [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.launch/build.properties [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.launch/icons/event_tab.gif [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.launch/icons/global_tab.gif [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.launch/icons/profile_run.png [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.launch/plugin.properties [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.launch/plugin.xml [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/oprofile/launch/OprofileLaunchMessages.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/oprofile/launch/OprofileLaunchPlugin.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/oprofile/launch/configuration/EventConfigCache.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/oprofile/launch/configuration/LaunchOptions.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/oprofile/launch/configuration/OprofileCounter.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/oprofile/launch/configuration/OprofileEventConfigTab.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/oprofile/launch/configuration/OprofileLaunchConfigurationTabGroup.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/oprofile/launch/configuration/OprofileSetupTab.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/oprofile/launch/launching/OprofileLaunchConfigurationDelegate.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/oprofile/launch/launching/OprofileLaunchShortcut.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/oprofile/launch/oprofilelaunch.properties [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.launch/src/org/tizen/oprofile/launch/DefaultSettingConstants.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.launch/src/org/tizen/oprofile/launch/listen/OProfileTargetConnectionListener.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.launch/src/org/tizen/oprofile/launch/listen/OprofileStartup.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.ui/.classpath [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.ui/.project [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.ui/.settings/org.eclipse.core.resources.prefs [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.ui/.settings/org.eclipse.core.runtime.prefs [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.ui/META-INF/MANIFEST.MF [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.ui/META-INF/eclipse.inf [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.ui/NOTICE [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.ui/about.html [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.ui/build.properties [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.ui/icons/chart.png [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.ui/icons/dependent.gif [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.ui/icons/dump.gif [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.ui/icons/event.gif [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.ui/icons/image.gif [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.ui/icons/open_log.png [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.ui/icons/oprofile_view.png [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.ui/icons/refresh.gif [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.ui/icons/reset_log.gif [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.ui/icons/sample.gif [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.ui/icons/save_log.png [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.ui/icons/session.gif [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.ui/icons/symbol.gif [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.ui/plugin.properties [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.ui/plugin.xml [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/OprofileUiMessages.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/OprofileUiPlugin.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/IUiModelElement.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelDependent.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelEvent.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelImage.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelRoot.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelSample.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelSession.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelSymbol.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/oprofileui.properties [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/view/OprofileView.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/view/OprofileViewContentProvider.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/view/OprofileViewDoubleClickListener.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/view/OprofileViewLabelProvider.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/view/OprofileViewLogReaderAction.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/view/OprofileViewRefreshAction.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/view/OprofileViewSaveDefaultSessionAction.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.ui/src/org/tizen/oprofile/ui/chart/ChartControl.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.ui/src/org/tizen/oprofile/ui/chart/ChartEditorInput.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.ui/src/org/tizen/oprofile/ui/chart/ChartModelRoot.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.ui/src/org/tizen/oprofile/ui/chart/PieChart.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.ui/src/org/tizen/oprofile/ui/editor/ChartEditor.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.ui/src/org/tizen/oprofile/ui/editor/OprofileEditor.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.ui/src/org/tizen/oprofile/ui/handler/OprofileDrawChartHandler.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.ui/src/org/tizen/oprofile/ui/handler/OprofileOpenDaemonLogHandler.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.ui/src/org/tizen/oprofile/ui/handler/OprofileRefreshViewHandler.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.ui/src/org/tizen/oprofile/ui/handler/OprofileResetHandler.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.ui/src/org/tizen/oprofile/ui/handler/OprofileSaveFileHandler.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.ui/src/org/tizen/oprofile/ui/view/OprofileViewDoubleClickListener.java [new file with mode: 0644]
org.eclipse.linuxtools.oprofile.ui/src/org/tizen/oprofile/ui/view/OprofileViewLabelProvider.java [new file with mode: 0644]
org.eclipse.linuxtools.profiling.launch/.classpath [new file with mode: 0644]
org.eclipse.linuxtools.profiling.launch/.project [new file with mode: 0644]
org.eclipse.linuxtools.profiling.launch/.settings/org.eclipse.core.resources.prefs [new file with mode: 0644]
org.eclipse.linuxtools.profiling.launch/.settings/org.eclipse.core.runtime.prefs [new file with mode: 0644]
org.eclipse.linuxtools.profiling.launch/META-INF/MANIFEST.MF [new file with mode: 0644]
org.eclipse.linuxtools.profiling.launch/META-INF/eclipse.inf [new file with mode: 0644]
org.eclipse.linuxtools.profiling.launch/NOTICE [new file with mode: 0644]
org.eclipse.linuxtools.profiling.launch/about.html [new file with mode: 0644]
org.eclipse.linuxtools.profiling.launch/build.properties [new file with mode: 0644]
org.eclipse.linuxtools.profiling.launch/plugin.properties [new file with mode: 0644]
org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/Messages.java [new file with mode: 0644]
org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/ProfileLaunchConfigurationTabGroup.java [new file with mode: 0644]
org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/ProfileLaunchPlugin.java [new file with mode: 0644]
org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/ProfileLaunchShortcut.java [new file with mode: 0644]
org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/messages.properties [new file with mode: 0644]
org.eclipse.linuxtools.profiling.ui/.classpath [new file with mode: 0644]
org.eclipse.linuxtools.profiling.ui/.project [new file with mode: 0644]
org.eclipse.linuxtools.profiling.ui/.settings/org.eclipse.core.resources.prefs [new file with mode: 0644]
org.eclipse.linuxtools.profiling.ui/.settings/org.eclipse.core.runtime.prefs [new file with mode: 0644]
org.eclipse.linuxtools.profiling.ui/META-INF/MANIFEST.MF [new file with mode: 0644]
org.eclipse.linuxtools.profiling.ui/META-INF/eclipse.inf [new file with mode: 0644]
org.eclipse.linuxtools.profiling.ui/NOTICE [new file with mode: 0644]
org.eclipse.linuxtools.profiling.ui/about.html [new file with mode: 0644]
org.eclipse.linuxtools.profiling.ui/build.properties [new file with mode: 0644]
org.eclipse.linuxtools.profiling.ui/plugin.properties [new file with mode: 0644]
org.eclipse.linuxtools.profiling.ui/plugin.xml [new file with mode: 0644]
org.eclipse.linuxtools.profiling.ui/src/org/eclipse/linuxtools/profiling/ui/ProfileUIPlugin.java [new file with mode: 0644]
org.eclipse.linuxtools.profiling.ui/src/org/eclipse/linuxtools/profiling/ui/ProfileUIUtils.java [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.core/.classpath [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.core/.project [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.core/.settings/org.eclipse.core.resources.prefs [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.core/.settings/org.eclipse.core.runtime.prefs [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.core/ChangeLog [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.core/META-INF/MANIFEST.MF [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.core/NOTICE [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.core/about.html [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.core/build.properties [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.core/plugin.properties [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.core/src/org/eclipse/linuxtools/valgrind/core/AbstractValgrindTextParser.java [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.core/src/org/eclipse/linuxtools/valgrind/core/ConsoleWriterThread.java [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.core/src/org/eclipse/linuxtools/valgrind/core/Messages.java [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.core/src/org/eclipse/linuxtools/valgrind/core/StreamReaderThread.java [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.core/src/org/eclipse/linuxtools/valgrind/core/ValgrindCommand.java [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.core/src/org/eclipse/linuxtools/valgrind/core/ValgrindPlugin.java [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.core/src/org/eclipse/linuxtools/valgrind/core/messages.properties [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.core/src/org/eclipse/linuxtools/valgrind/core/utils/LaunchConfigurationConstants.java [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.launch.exe/.classpath [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.launch.exe/.project [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.launch.exe/.settings/org.eclipse.core.resources.prefs [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.launch.exe/.settings/org.eclipse.core.runtime.prefs [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.launch.exe/META-INF/MANIFEST.MF [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.launch.exe/NOTICE [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.launch.exe/build.properties [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.launch.exe/icons/valgrind-icon.png [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.launch.exe/plugin.properties [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.launch.exe/plugin.xml [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.launch.exe/src/org/eclipse/linuxtools/valgrind/launch/CommandManager.java [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.launch.exe/src/org/eclipse/linuxtools/valgrind/launch/TizenValgrindLaunchDelegate.java [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.launch.exe/src/org/eclipse/linuxtools/valgrind/launch/ValgrindDebugPlugin.java [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.launch.exe/src/org/eclipse/linuxtools/valgrind/launch/ValgrindLaunchConfigurationTabGroup.java [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.launch.exe/src/org/eclipse/linuxtools/valgrind/launch/ValgrindLaunchShortcut.java [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.launch.exe/src/org/eclipse/linuxtools/valgrind/launch/ValgrindRuntimeProcess.java [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.launch/.classpath [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.launch/.project [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.launch/.settings/org.eclipse.core.resources.prefs [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.launch/.settings/org.eclipse.core.runtime.prefs [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.launch/ChangeLog [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.launch/META-INF/MANIFEST.MF [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.launch/NOTICE [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.launch/about.html [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.launch/build.properties [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.launch/icons/valgrind-icon.png [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.launch/icons/valgrind-icon.png.1 [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.launch/plugin.properties [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.launch/schema/org.eclipse.linuxtools.valgrind.launch.valgrindTools.exsd [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/valgrind/launch/IValgrindLaunchDelegate.java [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/valgrind/launch/IValgrindToolPage.java [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/valgrind/launch/Messages.java [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/valgrind/launch/ValgrindLaunchPlugin.java [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/valgrind/launch/ValgrindOptionsTab.java [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/valgrind/launch/messages.properties [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.massif/.classpath [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.massif/.project [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.massif/.settings/org.eclipse.core.resources.prefs [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.massif/.settings/org.eclipse.core.runtime.prefs [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.massif/ChangeLog [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.massif/META-INF/MANIFEST.MF [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.massif/NOTICE [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.massif/about.html [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.massif/build.properties [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.massif/icons/barcharticon.gif [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.massif/icons/call_hierarchy.gif [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.massif/icons/class_hi.gif [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.massif/icons/linecharticon.gif [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.massif/icons/memory_view.gif [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.massif/plugin.properties [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.massif/plugin.xml [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/valgrind/massif/MassifHeapTreeNode.java [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/valgrind/massif/MassifLaunchDelegate.java [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/valgrind/massif/MassifOutput.java [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/valgrind/massif/MassifParser.java [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/valgrind/massif/MassifPidMenuAction.java [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/valgrind/massif/MassifPlugin.java [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/valgrind/massif/MassifSnapshot.java [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/valgrind/massif/MassifToolPage.java [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/valgrind/massif/MassifTreeViewer.java [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/valgrind/massif/MassifViewPart.java [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/valgrind/massif/Messages.java [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/valgrind/massif/PowerOfTwoSpinner.java [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/valgrind/massif/birt/ChartControl.java [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/valgrind/massif/birt/ChartEditor.java [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/valgrind/massif/birt/ChartEditorInput.java [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/valgrind/massif/birt/HeapChart.java [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/valgrind/massif/birt/Messages.java [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/valgrind/massif/birt/messages.properties [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/valgrind/massif/messages.properties [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.massif/src/org/tizen/valgrind/massif/editor/MassifEditor.java [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.memcheck/.classpath [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.memcheck/.project [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.memcheck/.settings/org.eclipse.core.resources.prefs [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.memcheck/.settings/org.eclipse.core.runtime.prefs [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.memcheck/ChangeLog [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.memcheck/META-INF/MANIFEST.MF [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.memcheck/NOTICE [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.memcheck/about.html [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.memcheck/build.properties [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.memcheck/icons/valgrind-icon.png [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.memcheck/icons/warning.gif [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.memcheck/plugin.properties [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.memcheck/plugin.xml [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.memcheck/src/org/eclipse/linuxtools/valgrind/memcheck/MemcheckLaunchDelegate.java [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.memcheck/src/org/eclipse/linuxtools/valgrind/memcheck/MemcheckPlugin.java [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.memcheck/src/org/eclipse/linuxtools/valgrind/memcheck/MemcheckToolPage.java [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.memcheck/src/org/eclipse/linuxtools/valgrind/memcheck/MemcheckViewPart.java [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.memcheck/src/org/eclipse/linuxtools/valgrind/memcheck/Messages.java [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.memcheck/src/org/eclipse/linuxtools/valgrind/memcheck/ValgrindError.java [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.memcheck/src/org/eclipse/linuxtools/valgrind/memcheck/ValgrindErrorDesc.java [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.memcheck/src/org/eclipse/linuxtools/valgrind/memcheck/ValgrindStackFrame.java [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.memcheck/src/org/eclipse/linuxtools/valgrind/memcheck/ValgrindXMLParser.java [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.memcheck/src/org/eclipse/linuxtools/valgrind/memcheck/messages.properties [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.memcheck/src/org/eclipse/linuxtools/valgrind/memcheck/model/AuxErrorTreeElement.java [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.memcheck/src/org/eclipse/linuxtools/valgrind/memcheck/model/ErrorTreeElement.java [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.memcheck/src/org/eclipse/linuxtools/valgrind/memcheck/model/Messages.java [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.memcheck/src/org/eclipse/linuxtools/valgrind/memcheck/model/RootTreeElement.java [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.memcheck/src/org/eclipse/linuxtools/valgrind/memcheck/model/StackFrameTreeElement.java [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.memcheck/src/org/eclipse/linuxtools/valgrind/memcheck/model/TextTreeElement.java [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.memcheck/src/org/eclipse/linuxtools/valgrind/memcheck/model/ValgrindTreeElement.java [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.memcheck/src/org/eclipse/linuxtools/valgrind/memcheck/model/messages.properties [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.memcheck/src/org/tizen/valgrind/memcheck/editor/MemcheckEditor.java [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.ui/.classpath [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.ui/.project [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.ui/.settings/org.eclipse.core.resources.prefs [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.ui/.settings/org.eclipse.core.runtime.prefs [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.ui/ChangeLog [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.ui/META-INF/MANIFEST.MF [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.ui/NOTICE [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.ui/about.html [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.ui/build.properties [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.ui/icons/chart.png [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.ui/icons/dependent.gif [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.ui/icons/dump.gif [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.ui/icons/event.gif [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.ui/icons/image.gif [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.ui/icons/open_log.png [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.ui/icons/oprofile_view.png [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.ui/icons/refresh.gif [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.ui/icons/sample.gif [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.ui/icons/save_log.png [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.ui/icons/session.gif [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.ui/icons/symbol.gif [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.ui/icons/valgrind-icon.png [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.ui/icons/valgrind-icon.png.1 [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.ui/plugin.properties [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.ui/plugin.xml [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.ui/schema/org.eclipse.linuxtools.valgrind.ui.valgrindToolViews.exsd [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.ui/src/org/eclipse/linuxtools/valgrind/ui/IValgrindToolView.java [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.ui/src/org/eclipse/linuxtools/valgrind/ui/Messages.java [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.ui/src/org/eclipse/linuxtools/valgrind/ui/ValgrindUIPlugin.java [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.ui/src/org/eclipse/linuxtools/valgrind/ui/ValgrindViewPart.java [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.ui/src/org/eclipse/linuxtools/valgrind/ui/messages.properties [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.ui/src/org/tizen/valgrind/ui/handler/ValgrindRefreshViewHandler.java [new file with mode: 0644]
org.eclipse.linuxtools.valgrind.ui/src/org/tizen/valgrind/ui/handler/ValgrindSaveFileHandler.java [new file with mode: 0644]
org.tizen.profiler.branding/.project [new file with mode: 0644]
org.tizen.profiler.branding/32_TIZEN_SDK_icon.png [new file with mode: 0644]
org.tizen.profiler.branding/META-INF/MANIFEST.MF [new file with mode: 0644]
org.tizen.profiler.branding/about.ini [new file with mode: 0644]
org.tizen.profiler.branding/about.mappings [new file with mode: 0644]
org.tizen.profiler.branding/about.properties [new file with mode: 0644]
org.tizen.profiler.branding/build.properties [new file with mode: 0644]
org.tizen.profiler.feature/.project [new file with mode: 0644]
org.tizen.profiler.feature/build.properties [new file with mode: 0644]
org.tizen.profiler.feature/feature.properties [new file with mode: 0644]
org.tizen.profiler.feature/feature.xml [new file with mode: 0644]
org.tizen.profiler.feature/license.html [new file with mode: 0644]
package/build.linux [new file with mode: 0644]
package/changelog [new file with mode: 0644]
package/pkginfo.manifest [new file with mode: 0644]

diff --git a/AUTHORS b/AUTHORS
new file mode 100644 (file)
index 0000000..21370e0
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,3 @@
+Jaewon Lim <jaewon81.lim@samsung.com>
+Juyoung Kim <j0.kim@samsung.com>
+HyunGoo Kang <hyungoo1.kang@samsung.com>
diff --git a/LICENSE.EPL b/LICENSE.EPL
new file mode 100644 (file)
index 0000000..3998fce
--- /dev/null
@@ -0,0 +1,261 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
+<title>Eclipse Public License - Version 1.0</title>
+<style type="text/css">
+  body {
+    size: 8.5in 11.0in;
+    margin: 0.25in 0.5in 0.25in 0.5in;
+    tab-interval: 0.5in;
+    }
+  p {          
+    margin-left: auto;
+    margin-top:  0.5em;
+    margin-bottom: 0.5em;
+    }
+  p.list {
+       margin-left: 0.5in;
+    margin-top:  0.05em;
+    margin-bottom: 0.05em;
+    }
+  </style>
+
+</head>
+
+<body lang="EN-US">
+
+<h2>Eclipse Public License - v 1.0</h2>
+
+<p>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE
+PUBLIC LICENSE (&quot;AGREEMENT&quot;). ANY USE, REPRODUCTION OR
+DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS
+AGREEMENT.</p>
+
+<p><b>1. DEFINITIONS</b></p>
+
+<p>&quot;Contribution&quot; means:</p>
+
+<p class="list">a) in the case of the initial Contributor, the initial
+code and documentation distributed under this Agreement, and</p>
+<p class="list">b) in the case of each subsequent Contributor:</p>
+<p class="list">i) changes to the Program, and</p>
+<p class="list">ii) additions to the Program;</p>
+<p class="list">where such changes and/or additions to the Program
+originate from and are distributed by that particular Contributor. A
+Contribution 'originates' from a Contributor if it was added to the
+Program by such Contributor itself or anyone acting on such
+Contributor's behalf. Contributions do not include additions to the
+Program which: (i) are separate modules of software distributed in
+conjunction with the Program under their own license agreement, and (ii)
+are not derivative works of the Program.</p>
+
+<p>&quot;Contributor&quot; means any person or entity that distributes
+the Program.</p>
+
+<p>&quot;Licensed Patents&quot; mean patent claims licensable by a
+Contributor which are necessarily infringed by the use or sale of its
+Contribution alone or when combined with the Program.</p>
+
+<p>&quot;Program&quot; means the Contributions distributed in accordance
+with this Agreement.</p>
+
+<p>&quot;Recipient&quot; means anyone who receives the Program under
+this Agreement, including all Contributors.</p>
+
+<p><b>2. GRANT OF RIGHTS</b></p>
+
+<p class="list">a) Subject to the terms of this Agreement, each
+Contributor hereby grants Recipient a non-exclusive, worldwide,
+royalty-free copyright license to reproduce, prepare derivative works
+of, publicly display, publicly perform, distribute and sublicense the
+Contribution of such Contributor, if any, and such derivative works, in
+source code and object code form.</p>
+
+<p class="list">b) Subject to the terms of this Agreement, each
+Contributor hereby grants Recipient a non-exclusive, worldwide,
+royalty-free patent license under Licensed Patents to make, use, sell,
+offer to sell, import and otherwise transfer the Contribution of such
+Contributor, if any, in source code and object code form. This patent
+license shall apply to the combination of the Contribution and the
+Program if, at the time the Contribution is added by the Contributor,
+such addition of the Contribution causes such combination to be covered
+by the Licensed Patents. The patent license shall not apply to any other
+combinations which include the Contribution. No hardware per se is
+licensed hereunder.</p>
+
+<p class="list">c) Recipient understands that although each Contributor
+grants the licenses to its Contributions set forth herein, no assurances
+are provided by any Contributor that the Program does not infringe the
+patent or other intellectual property rights of any other entity. Each
+Contributor disclaims any liability to Recipient for claims brought by
+any other entity based on infringement of intellectual property rights
+or otherwise. As a condition to exercising the rights and licenses
+granted hereunder, each Recipient hereby assumes sole responsibility to
+secure any other intellectual property rights needed, if any. For
+example, if a third party patent license is required to allow Recipient
+to distribute the Program, it is Recipient's responsibility to acquire
+that license before distributing the Program.</p>
+
+<p class="list">d) Each Contributor represents that to its knowledge it
+has sufficient copyright rights in its Contribution, if any, to grant
+the copyright license set forth in this Agreement.</p>
+
+<p><b>3. REQUIREMENTS</b></p>
+
+<p>A Contributor may choose to distribute the Program in object code
+form under its own license agreement, provided that:</p>
+
+<p class="list">a) it complies with the terms and conditions of this
+Agreement; and</p>
+
+<p class="list">b) its license agreement:</p>
+
+<p class="list">i) effectively disclaims on behalf of all Contributors
+all warranties and conditions, express and implied, including warranties
+or conditions of title and non-infringement, and implied warranties or
+conditions of merchantability and fitness for a particular purpose;</p>
+
+<p class="list">ii) effectively excludes on behalf of all Contributors
+all liability for damages, including direct, indirect, special,
+incidental and consequential damages, such as lost profits;</p>
+
+<p class="list">iii) states that any provisions which differ from this
+Agreement are offered by that Contributor alone and not by any other
+party; and</p>
+
+<p class="list">iv) states that source code for the Program is available
+from such Contributor, and informs licensees how to obtain it in a
+reasonable manner on or through a medium customarily used for software
+exchange.</p>
+
+<p>When the Program is made available in source code form:</p>
+
+<p class="list">a) it must be made available under this Agreement; and</p>
+
+<p class="list">b) a copy of this Agreement must be included with each
+copy of the Program.</p>
+
+<p>Contributors may not remove or alter any copyright notices contained
+within the Program.</p>
+
+<p>Each Contributor must identify itself as the originator of its
+Contribution, if any, in a manner that reasonably allows subsequent
+Recipients to identify the originator of the Contribution.</p>
+
+<p><b>4. COMMERCIAL DISTRIBUTION</b></p>
+
+<p>Commercial distributors of software may accept certain
+responsibilities with respect to end users, business partners and the
+like. While this license is intended to facilitate the commercial use of
+the Program, the Contributor who includes the Program in a commercial
+product offering should do so in a manner which does not create
+potential liability for other Contributors. Therefore, if a Contributor
+includes the Program in a commercial product offering, such Contributor
+(&quot;Commercial Contributor&quot;) hereby agrees to defend and
+indemnify every other Contributor (&quot;Indemnified Contributor&quot;)
+against any losses, damages and costs (collectively &quot;Losses&quot;)
+arising from claims, lawsuits and other legal actions brought by a third
+party against the Indemnified Contributor to the extent caused by the
+acts or omissions of such Commercial Contributor in connection with its
+distribution of the Program in a commercial product offering. The
+obligations in this section do not apply to any claims or Losses
+relating to any actual or alleged intellectual property infringement. In
+order to qualify, an Indemnified Contributor must: a) promptly notify
+the Commercial Contributor in writing of such claim, and b) allow the
+Commercial Contributor to control, and cooperate with the Commercial
+Contributor in, the defense and any related settlement negotiations. The
+Indemnified Contributor may participate in any such claim at its own
+expense.</p>
+
+<p>For example, a Contributor might include the Program in a commercial
+product offering, Product X. That Contributor is then a Commercial
+Contributor. If that Commercial Contributor then makes performance
+claims, or offers warranties related to Product X, those performance
+claims and warranties are such Commercial Contributor's responsibility
+alone. Under this section, the Commercial Contributor would have to
+defend claims against the other Contributors related to those
+performance claims and warranties, and if a court requires any other
+Contributor to pay any damages as a result, the Commercial Contributor
+must pay those damages.</p>
+
+<p><b>5. NO WARRANTY</b></p>
+
+<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS
+PROVIDED ON AN &quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS
+OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION,
+ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY
+OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
+responsible for determining the appropriateness of using and
+distributing the Program and assumes all risks associated with its
+exercise of rights under this Agreement , including but not limited to
+the risks and costs of program errors, compliance with applicable laws,
+damage to or loss of data, programs or equipment, and unavailability or
+interruption of operations.</p>
+
+<p><b>6. DISCLAIMER OF LIABILITY</b></p>
+
+<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT
+NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING
+WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR
+DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
+HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.</p>
+
+<p><b>7. GENERAL</b></p>
+
+<p>If any provision of this Agreement is invalid or unenforceable under
+applicable law, it shall not affect the validity or enforceability of
+the remainder of the terms of this Agreement, and without further action
+by the parties hereto, such provision shall be reformed to the minimum
+extent necessary to make such provision valid and enforceable.</p>
+
+<p>If Recipient institutes patent litigation against any entity
+(including a cross-claim or counterclaim in a lawsuit) alleging that the
+Program itself (excluding combinations of the Program with other
+software or hardware) infringes such Recipient's patent(s), then such
+Recipient's rights granted under Section 2(b) shall terminate as of the
+date such litigation is filed.</p>
+
+<p>All Recipient's rights under this Agreement shall terminate if it
+fails to comply with any of the material terms or conditions of this
+Agreement and does not cure such failure in a reasonable period of time
+after becoming aware of such noncompliance. If all Recipient's rights
+under this Agreement terminate, Recipient agrees to cease use and
+distribution of the Program as soon as reasonably practicable. However,
+Recipient's obligations under this Agreement and any licenses granted by
+Recipient relating to the Program shall continue and survive.</p>
+
+<p>Everyone is permitted to copy and distribute copies of this
+Agreement, but in order to avoid inconsistency the Agreement is
+copyrighted and may only be modified in the following manner. The
+Agreement Steward reserves the right to publish new versions (including
+revisions) of this Agreement from time to time. No one other than the
+Agreement Steward has the right to modify this Agreement. The Eclipse
+Foundation is the initial Agreement Steward. The Eclipse Foundation may
+assign the responsibility to serve as the Agreement Steward to a
+suitable separate entity. Each new version of the Agreement will be
+given a distinguishing version number. The Program (including
+Contributions) may always be distributed subject to the version of the
+Agreement under which it was received. In addition, after a new version
+of the Agreement is published, Contributor may elect to distribute the
+Program (including its Contributions) under the new version. Except as
+expressly stated in Sections 2(a) and 2(b) above, Recipient receives no
+rights or licenses to the intellectual property of any Contributor under
+this Agreement, whether expressly, by implication, estoppel or
+otherwise. All rights in the Program not expressly granted under this
+Agreement are reserved.</p>
+
+<p>This Agreement is governed by the laws of the State of New York and
+the intellectual property laws of the United States of America. No party
+to this Agreement will bring a legal action under this Agreement more
+than one year after the cause of action arose. Each party waives its
+rights to a jury trial in any resulting litigation.</p>
+
+</body>
+
+</html>
\ No newline at end of file
diff --git a/NOTICE b/NOTICE
new file mode 100644 (file)
index 0000000..a8d404b
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,4 @@
+copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
+Except as noted, this software is licensed under Eclipse Public License, Version 1.0.
+Please, see the LICENSE.EPL file for Eclipse Public License, Version 1.0 terms and conditions.
+
diff --git a/build.sh b/build.sh
new file mode 100644 (file)
index 0000000..fea82ab
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,164 @@
+#!/bin/bash
+start_path=`pwd`
+
+###############################################################
+##
+## Please modify parameter value.
+##
+###############################################################
+build_type=N
+build_id=profiler_build
+build_path="`pwd`/../build_result"
+
+###############################################################
+##
+## Do not touch here.
+##
+###############################################################
+build_result_directory=${build_type}.${build_id}
+build_result_path="$build_path/$build_result_directory"
+builder_path="$start_path/builder"
+equinox_launcher=`echo org.eclipse.equinox.launcher_*.jar`
+pde_build=`echo org.eclipse.pde.build_*`
+metadata_path=$start_path/builder
+fresh_ide_path=$3
+
+if [ "x$1" = "x" ]
+then
+       echo "
+Usage : build.sh PLATFORM_NAME TARGET_ECLIPSE_PATH
+
+   PLATFORM_NAME               You can set \"linux\" or \"windows\"
+   TARGET_ECLIPSE_PATH         Set target eclipse path.
+                               For example, $HOME/git/fresh-ide-pde
+"
+       exit 1
+fi
+
+if [ "x$2" = "x" ]
+then
+       echo "
+Usage : build.sh $1 TARGET_ECLIPSE_PATH
+   TARGET_ECLIPSE_PATH Set target eclipse path.
+                       For example, $HOME/git/fresh-ide-pde
+"
+       exit 1
+fi
+
+#if [ "x$3" != "x" ]
+#then
+#      build_path=$3
+#fi
+
+platform=$1
+based_eclipse_path=$2
+parent_path_of_based_eclipse=${based_eclipse_path}/..
+architecture=x86
+
+case ${platform} in
+       linux)
+               archive_platform_name=linux
+               windowing=gtk
+               ;;
+       windows)
+               archive_platform_name=win32
+               windowing=win32
+               ;;
+       *)
+               echo "${platform} is not support yet."
+               exit 1
+               ;;
+esac
+
+result_archive_file=${build_id}-${archive_platform_name}.${windowing}.${architecture}.zip
+
+if [ -d $build_path ]
+then
+       echo "Build result directory : [$build_path]"
+else
+       echo "Make build result directory [$build_path]"
+       mkdir -p $build_path
+fi
+
+echo "Remove legacy build files..."
+if [ -d ${build_result_path}/${archive_platform_name}.${windowing}.${architecture} ]
+then
+       rm -rf ${build_result_path}/${archive_platform_name}.${windowing}.${architecture}
+fi
+if [ -e ${build_result_path}/${result_archive_file} ]
+then
+       rm -rf ${build_result_path}/${result_archive_file}
+fi
+
+if [ -d $build_path/plugins ]
+then
+       echo "plugins directory recreate..."
+        rm -rf $build_path/plugins
+       mkdir $build_path/plugins
+else
+       echo "Make plugins directory..."
+       mkdir $build_path/plugins
+fi
+if [ -d $build_path/features/ ]
+then
+       echo "features directory recreate..."
+        rm -rf $build_path/features
+       mkdir $build_path/features
+else
+       echo "Make features directory..."
+       mkdir $build_path/features
+fi
+
+echo "Copy features from $start_path to $build_path/features"
+cp -r $start_path/*.feature $build_path/features
+
+echo "Copy plugins from $start_path to $build_path/plugins"
+cp -r $start_path/* $build_path/plugins
+rm -rf $build_path/plugins/*.feature
+
+echo "Copy fresh ide plugins..."
+if [ -d ${fresh_ide_path} ]
+then
+       cp -rf ${fresh_ide_path}/${archive_platform_name}.${windowing}.${architecture}/IDE/plugins/* ${build_path}/plugins
+       cp -rf ${fresh_ide_path}/${archive_platform_name}.${windowing}.${architecture}/IDE/features/* ${build_path}/features
+else
+       echo "ERROR : Fresh IDE does not exist..."
+       exit 1
+fi
+
+echo "Make build.properties file..."
+if [ ! -e $builder_path/build.properties.clean ] ; then
+       echo "ERROR : \"build.properties.clean\" file does not exist..."
+       exit 1
+fi
+cp $builder_path/build.properties.clean $build_path
+cp $builder_path/customTargets.xml $build_path
+
+if [ -d $based_eclipse_path ] 
+then
+       sed -e "s;\(^buildDirectory=\).*;\1${build_path};g" -e "s;\(^base=\).*;\1${parent_path_of_based_eclipse};g" -e "s;\(^baseLocation=\).*;\1${based_eclipse_path};g" -e "s;\(^configs=\).*;\1${archive_platform_name},${windowing},${architecture};g" -e "s;\(^buildType=\).*;\1${build_type};g" -e "s;\(^buildId=\).*;\1${build_id};g" < $build_path/build.properties.clean > $build_path/build.properties
+else
+       echo "ERROR : target eclipse is not exist."
+       exit 1
+fi
+
+echo "Execute Product Ant Builder..."
+java -server -XX:+UseParNewGC -jar ${based_eclipse_path}/plugins/$equinox_launcher -application org.eclipse.ant.core.antRunner -buildfile ${based_eclipse_path}/plugins/$pde_build/scripts/productBuild/productBuild.xml -Dbuilder=$build_path 2>&1
+
+if [ $? != 0 ];
+then
+       echo "Build failed..."
+       exit 1
+fi
+
+echo "unzip to $build_result_path"
+unzip -a $build_result_path/${result_archive_file} -d $build_result_path/${archive_platform_name}.${windowing}.${architecture}
+
+#echo "Delete temp files..."
+#rm -rf $build_path/features
+#rm -rf $build_path/plugins
+#rm $build_path/*.xml
+#rm $build_path/*.properties
+#rm $build_path/*.properties.clean
+
+echo "Build SUCCESS. You will find SDK IDE in \"${build_result_path}\"."
diff --git a/builder/build.properties.clean b/builder/build.properties.clean
new file mode 100644 (file)
index 0000000..2b8a31f
--- /dev/null
@@ -0,0 +1,260 @@
+###############################################################################
+# Copyright (c) 2003, 2006 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+# 
+# Contributors:
+#     IBM Corporation - initial API and implementation
+###############################################################################
+#####################
+# Parameters describing how and where to execute the build.
+# Typical users need only update the following properties:
+#    baseLocation - where things you are building against are installed
+#    bootclasspath - The base jars to compile against (typicaly rt.jar)
+#    configs - the list of {os, ws, arch} configurations to build.  
+#
+# Of course any of the settings here can be overridden by spec'ing 
+# them on the command line (e.g., -DbaseLocation=d:/eclipse
+
+#The type of the top level element we are building,  generally "feature"
+topLevelElementType=feature
+#The id of the top level element we are building
+topLevelElementId=org.tizen.profiler.feature
+
+############# PRODUCT/PACKAGING CONTROL #############
+#product=/org.tizen.base.platform/TizenIDE_base_linux.product
+#runPackager=true
+
+#Set the name of the archive that will result from the product build.
+#archiveNamePrefix=
+
+# The prefix that will be used in the generated archive.
+archivePrefix=profiler
+
+# The location underwhich all of the build output will be collected.
+collectingFolder=${archivePrefix}
+
+# The list of {os, ws, arch} configurations to build.  This 
+# value is a '&' separated list of ',' separate triples.  For example, 
+#     configs=win32,win32,x86 & linux,motif,x86
+# By default the value is *,*,*
+configs="Do not touch here."
+#configs=win32, win32, x86 & \
+#      win32,win32,x86_64 & \
+#      win32,win32,wpf & \
+#      linux, gtk, ppc & \
+#      linux, gtk, x86 & \
+#      linux, gtk, x86_64 & \
+#      linux, motif, x86 & \
+#      solaris, motif, sparc & \
+#      solaris, gtk, sparc & \
+#      aix, motif, ppc & \
+#      hpux, motif, ia64_32 & \
+#      macosx, carbon, ppc & \
+#      macosx, carbon, x86 & \
+#      macosx, cocoa, ppc & \
+#      macosx, cocoa, x86 & \
+#      macosx, cocoa, x86_64
+
+# By default PDE creates one archive (result) per entry listed in the configs property.
+# Setting this value to true will cause PDE to only create one output containing all 
+# artifacts for all the platforms listed in the configs property.
+# To control the output format for the group, add a "group, group, group - <format>" entry to the
+# archivesFormat. 
+#groupConfigurations=true
+
+#The format of the archive. By default a zip is created using antZip.
+#The list can only contain the configuration for which the desired format is different than zip.
+#archivesFormat=win32, win32, x86 - antZip& \
+#      linux, gtk, ppc - antZip &\
+#    linux, gtk, x86 - antZip& \
+#      linux, gtk, x86_64 - antZip& \
+# linux, motif, x86 - antZip& \
+#      solaris, motif, sparc - antZip& \
+#      solaris, gtk, sparc - antZip& \
+#      aix, motif, ppc - antZip& \
+#      hpux, motif, PA_RISC - antZip& \
+#      macosx, carbon, ppc - antZip
+
+#Allow cycles involving at most one bundle that needs to be compiled with the rest being binary bundles.
+allowBinaryCycles=true
+
+#Sort bundles depenedencies across all features instead of just within a given feature.
+#flattenDependencies = true
+
+#Parallel compilation, requires flattenedDependencies=true
+#parallelCompilation=true
+#parallelThreadCount=
+#parallelThreadsPerProcessor=
+       
+#Set to true if you want the output to be ready for an update jar (no site.xml generated)
+#outputUpdateJars = false
+
+#Set to true for Jnlp generation
+#codebase should be a URL that will be used as the root of all relative URLs in the output.
+#generateJnlp=false
+#jnlp.codebase=<codebase url>
+#jnlp.j2se=<j2se version>
+#jnlp.locale=<a locale>
+#jnlp.generateOfflineAllowed=true or false generate <offlineAllowed/> attribute in the generated features
+#jnlp.configs=${configs}                       #uncomment to filter the content of the generated jnlp files based on the configuration being built
+
+#Set to true if you want to sign jars
+#signJars=false
+#sign.alias=<alias>
+#sign.keystore=<keystore location>
+#sign.storepass=<keystore password>
+#sign.keypass=<key password>
+
+#Arguments to send to the zip executable
+#zipargs=
+
+#Arguments to send to the tar executable
+#tarargs=
+
+#Control the creation of a file containing the version included in each configuration - on by default 
+#generateVersionsLists=false
+
+############## BUILD NAMING CONTROL ################
+# The directory into which the build elements are fetched and where
+# the build takes place.
+buildDirectory="Do not touch here"
+
+# Type of build.  Used in naming the build output.  Typically this value is
+# one of I, N, M, S, ...
+buildType="Do not touch here"
+
+# ID of the build.  Used in naming the build output.
+buildId="Do not touch here"
+
+# Label for the build.  Used in naming the build output
+buildLabel=${buildType}.${buildId}
+
+# Timestamp for the build.  Used in naming the build output
+timestamp=007
+
+#The value to be used for the qualifier of a plugin or feature when you want to override the value computed by pde.
+#The value will only be applied to plugin or features indicating build.properties, qualifier = context 
+#forceContextQualifier=<the value for the qualifier>
+
+#Enable / disable the generation of a suffix for the features that use .qualifier. 
+#The generated suffix is computed according to the content of the feature   
+#generateFeatureVersionSuffix=true
+
+############# BASE CONTROL #############
+# Settings for the base Eclipse components and Java class libraries 
+# against which you are building.
+# Base location for anything the build needs to compile against.  For example,
+# in most RCP app or a plug-in,  the baseLocation should be the location of a previously
+# installed Eclipse against which the application or plug-in code will be compiled and the RCP delta pack.
+
+base="Do not touch here"
+baseLocation="Do not touch here"
+
+
+#Folder containing repositories whose content is needed to compile against
+#repoBaseLocation=${base}/repos
+#Folder where the content of the repositories from ${repoBaseLocation} will be made available as a form suitable to be compiled against
+#transformedRepoLocation=${base}/transformedRepos
+
+#Os/Ws/Arch/nl of the eclipse specified by baseLocation
+baseos=linux
+basews=gtk
+basearch=x86
+
+#this property indicates whether you want the set of plug-ins and features to be considered during the build to be limited to the ones reachable from the features / plugins being built
+filteredDependencyCheck=false
+
+#this property indicates whether the resolution should be done in development mode (i.e. ignore multiple bundles with singletons)
+resolution.devMode=false
+
+#pluginPath is a list of locations in which to find plugins and features.  This list is separated by the platform file separator (; or :)
+#a location is one of:  
+#- the location of the jar or folder that is the plugin or feature : /path/to/foo.jar or /path/to/foo
+#- a directory that contains a /plugins or /features subdirectory
+#- the location of a feature.xml, or for 2.1 style plugins, the plugin.xml or fragment.xml
+#pluginPath=
+
+skipBase=true
+eclipseURL=<url for eclipse download site>
+eclipseBuildId=<Id of Eclipse build to get>
+eclipseBaseURL=${eclipseURL}/eclipse-platform-${eclipseBuildId}-win32.zip
+
+
+############# MAP FILE CONTROL ################
+# This section defines CVS tags to use when fetching the map files from the repository.
+# If you want to fetch the map file from repository / location, change the getMapFiles target in the customTargets.xml
+
+skipMaps=true
+mapsRepo=:pserver:anonymous@example.com/path/to/repo
+mapsRoot=path/to/maps
+mapsCheckoutTag=HEAD
+
+#tagMaps=true
+mapsTagTag=v${buildId}
+
+
+############ REPOSITORY CONTROL ###############
+# This section defines properties parameterizing the repositories where plugins, fragments
+# bundles and features are being obtained from. 
+
+# The tags to use when fetching elements to build.
+# By default thebuilder will use whatever is in the maps.  
+# This value takes the form of a comma separated list of repository identifier (like used in the map files) and the 
+# overriding value
+# For example fetchTag=CVS=HEAD, SVN=v20050101
+# fetchTag=HEAD
+skipFetch=true
+
+
+############# P2 OPTIONS ##############
+#p2.gathering = true
+#p2.compress=true
+
+############# JAVA COMPILER OPTIONS ##############
+# The location of the Java jars to compile against.  Typically the rt.jar for your JDK/JRE
+#bootclasspath=${java.home}/lib/rt.jar
+
+# specific JRE locations to compile against. These values are used to compile bundles specifying a 
+# Bundle-RequiredExecutionEnvironment. Uncomment and set values for environments that you support
+#CDC-1.0/Foundation-1.0= /path/to/rt.jar
+#CDC-1.1/Foundation-1.1=
+#OSGi/Minimum-1.0=
+#OSGi/Minimum-1.1=
+#JRE-1.1=
+#J2SE-1.2=
+#J2SE-1.3=
+#J2SE-1.4=
+#J2SE-1.5=
+#JavaSE-1.6=
+#PersonalJava-1.1=
+#PersonalJava-1.2=
+#CDC-1.0/PersonalBasis-1.0=
+#CDC-1.0/PersonalJava-1.0=
+#CDC-1.1/PersonalBasis-1.1=
+#CDC-1.1/PersonalJava-1.1=
+
+# Specify the output format of the compiler log when eclipse jdt is used
+logExtension=.log
+
+# Whether or not to include debug info in the output jars
+javacDebugInfo=false 
+
+# Whether or not to fail the build if there are compiler errors
+javacFailOnError=true
+
+# Enable or disable verbose mode of the compiler
+javacVerbose=true
+
+# Extra arguments for the compiler. These are specific to the java compiler being used.
+#compilerArg=
+
+# Default value for the version of the source code. This value is used when compiling plug-ins that do not set the Bundle-RequiredExecutionEnvironment or set javacSource in build.properties
+javacSource=1.6
+
+# Default value for the version of the byte code targeted. This value is used when compiling plug-ins that do not set the Bundle-RequiredExecutionEnvironment or set javacTarget in build.properties.
+javacTarget=1.6
+
+
diff --git a/builder/customTargets.xml b/builder/customTargets.xml
new file mode 100644 (file)
index 0000000..cc059b7
--- /dev/null
@@ -0,0 +1,187 @@
+<project name="Build specific targets and properties" default="noDefault">
+
+       <!-- ===================================================================== -->
+       <!-- Run a given ${target} on all elements being built -->
+       <!-- Add on <ant> task for each top level element being built. -->
+       <!-- ===================================================================== -->
+       <available property="allElementsFile" file="${builder}/allElements.xml" value="${builder}/allElements.xml"/>
+       <property name="allElementsFile" location="${eclipse.pdebuild.templates}/headless-build/allElements.xml"/>
+
+       <import file="${allElementsFile}" />
+       <target name="allElements">
+               <ant antfile="${genericTargets}" target="${target}">
+                       <property name="type" value="feature"/>
+                       <property name="id" value="org.tizen.profiler.feature"/>
+               </ant>
+       </target>
+
+       <target
+               name="assemble.org.tizen.profiler.feature.linux.gtk.x86">
+               <ant antfile="{$assembleScriptName}" dir="${buildDirectory}"/>
+       </target>
+       <target
+               name="assemble.org.tizen.profiler.feature.win32.win32.x86">
+               <ant antfile="{$assembleScriptName}" dir="${buildDirectory}"/>
+       </target>
+       
+       <!-- ===================================================================== -->
+       <!-- ===================================================================== -->
+       <target name="getBaseComponents" depends="checkLocalBase" unless="skipBase">
+               <get src="${eclipseBaseURL}" dest="${buildDirectory}/../temp-base.zip" />
+               <unzip dest="${base}" overwrite="true" src="${buildDirectory}/../temp-base.zip" />
+       </target>
+
+       <target name="checkLocalBase">
+               <available file="${base}" property="skipBase" />
+       </target>
+
+       <!-- ===================================================================== -->
+       <!-- Check out map files from correct repository -->
+       <!-- Replace values for mapsCheckoutTag as desired. -->
+       <!-- ===================================================================== -->
+       <target name="getMapFiles" depends="checkLocalMaps" unless="skipMaps">
+               <property name="mapsCheckoutTag" value="HEAD" />
+               <cvs cvsRoot="${mapsRepo}" package="${mapsRoot}" dest="${buildDirectory}/maps" tag="${mapsCheckoutTag}" />
+       </target>
+
+       <target name="checkLocalMaps">
+               <available property="skipMaps" file="${buildDirectory}/maps" />
+       </target>
+
+       <target name="tagMapFiles" if="tagMaps">
+               <cvs dest="${buildDirectory}/maps/${mapsRoot}" command="tag ${mapsTagTag}" />
+       </target>
+
+       <!-- ===================================================================== -->
+
+       <target name="clean" unless="noclean">
+               <antcall target="allElements">
+                       <param name="target" value="cleanElement" />
+               </antcall>
+       </target>
+
+       <target name="gatherLogs">
+               <mkdir dir="${buildDirectory}/${buildLabel}/compilelogs" />
+               <antcall target="allElements">
+                       <param name="target" value="gatherLogs" />
+               </antcall>
+               <unzip dest="${buildDirectory}/${buildLabel}/compilelogs" overwrite="true">
+                       <fileset dir="${buildDirectory}/features">
+                               <include name="**/*.log.zip" />
+                       </fileset>
+               </unzip>
+       </target>
+
+       <!-- ===================================================================== -->
+       <!-- Steps to do before setup -->
+       <!-- ===================================================================== -->
+       <target name="preSetup">
+       </target>
+
+       <!-- ===================================================================== -->
+       <!-- Steps to do after setup but before starting the build proper -->
+       <!-- ===================================================================== -->
+       <target name="postSetup">
+               <antcall target="getBaseComponents" />
+       </target>
+
+       <!-- ===================================================================== -->
+       <!-- Steps to do before fetching the build elements -->
+       <!-- ===================================================================== -->
+       <target name="preFetch">
+       </target>
+
+       <!-- ===================================================================== -->
+       <!-- Steps to do after fetching the build elements -->
+       <!-- ===================================================================== -->
+       <target name="postFetch">
+       </target>
+
+       <!-- ===================================================================== -->
+       <!-- Steps to do before the repositories are being processed -->
+       <!-- ===================================================================== -->
+       <target name="preProcessRepos">
+       </target>
+
+       <!-- ===================================================================== -->
+       <!-- Steps to do after the repositories have been processed -->
+       <!-- ===================================================================== -->
+       <target name="postProcessRepos">
+       </target>
+       
+       <!-- ===================================================================== -->
+       <!-- Steps to do before generating the build scripts. -->
+       <!-- ===================================================================== -->
+       <target name="preGenerate">
+       </target>
+
+       <!-- ===================================================================== -->
+       <!-- Steps to do after generating the build scripts. -->
+       <!-- ===================================================================== -->
+       <target name="postGenerate">
+               <antcall target="clean" />
+       </target>
+
+       <!-- ===================================================================== -->
+       <!-- Steps to do before running the build.xmls for the elements being built. -->
+       <!-- ===================================================================== -->
+       <target name="preProcess">
+       </target>
+
+       <!-- ===================================================================== -->
+       <!-- Steps to do after running the build.xmls for the elements being built. -->
+       <!-- ===================================================================== -->
+       <target name="postProcess">
+       </target>
+
+       <!-- ===================================================================== -->
+       <!-- Steps to do before running assemble. -->
+       <!-- ===================================================================== -->
+       <target name="preAssemble">
+       </target>
+
+       <!-- ===================================================================== -->
+       <!-- Steps to do after  running assemble. -->
+       <!-- ===================================================================== -->
+       <target name="postAssemble">
+       </target>
+
+       <!-- ===================================================================== -->
+       <!-- Steps to do before running package. -->
+       <!-- ===================================================================== -->
+       <target name="prePackage">
+       </target>
+
+       <!-- ===================================================================== -->
+       <!-- Steps to do after  running package. -->
+       <!-- ===================================================================== -->
+       <target name="postPackage">
+       </target>
+
+       <!-- ===================================================================== -->
+       <!-- Steps to do after the build is done. -->
+       <!-- ===================================================================== -->
+       <target name="postBuild">
+               <antcall target="gatherLogs" />
+       </target>
+
+       <!-- ===================================================================== -->
+       <!-- Steps to do to test the build results -->
+       <!-- ===================================================================== -->
+       <target name="test">
+       </target>
+
+       <!-- ===================================================================== -->
+       <!-- Steps to do to publish the build results -->
+       <!-- ===================================================================== -->
+       <target name="publish">
+       </target>
+
+       <!-- ===================================================================== -->
+       <!-- Default target                                                        -->
+       <!-- ===================================================================== -->
+       <target name="noDefault">
+               <echo message="You must specify a target when invoking this file" />
+       </target>
+
+</project>
diff --git a/builder/metadata/data/platforms/tizen2.0/on-demand/eglibc-debuginfo_0.0.1_armel.tar b/builder/metadata/data/platforms/tizen2.0/on-demand/eglibc-debuginfo_0.0.1_armel.tar
new file mode 100644 (file)
index 0000000..31a3bbf
Binary files /dev/null and b/builder/metadata/data/platforms/tizen2.0/on-demand/eglibc-debuginfo_0.0.1_armel.tar differ
diff --git a/builder/metadata/data/platforms/tizen2.0/on-demand/eglibc-debuginfo_0.0.1_i386.tar b/builder/metadata/data/platforms/tizen2.0/on-demand/eglibc-debuginfo_0.0.1_i386.tar
new file mode 100644 (file)
index 0000000..a8a39b2
Binary files /dev/null and b/builder/metadata/data/platforms/tizen2.0/on-demand/eglibc-debuginfo_0.0.1_i386.tar differ
diff --git a/builder/metadata/pkginfo.manifest b/builder/metadata/pkginfo.manifest
new file mode 100644 (file)
index 0000000..5cf0990
--- /dev/null
@@ -0,0 +1,6 @@
+Package: Profiler
+Version: 1.0
+Architecture: i386
+Maintainer: Jaewon Lim <jaewon81.lim@samsung.com>, Juyoung Kim
+Description: Tizen SDK profiler
+Category: IDE/Tizen IDE/Plugins/Dynamic analysis
diff --git a/org.eclipse.linuxtools.oprofile.core/.classpath b/org.eclipse.linuxtools.oprofile.core/.classpath
new file mode 100644 (file)
index 0000000..ad32c83
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+       <classpathentry kind="src" path="src"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.eclipse.linuxtools.oprofile.core/.project b/org.eclipse.linuxtools.oprofile.core/.project
new file mode 100644 (file)
index 0000000..f6a0d69
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.eclipse.linuxtools.oprofile.core</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.ManifestBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.SchemaBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.pde.PluginNature</nature>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>
diff --git a/org.eclipse.linuxtools.oprofile.core/.settings/org.eclipse.core.resources.prefs b/org.eclipse.linuxtools.oprofile.core/.settings/org.eclipse.core.resources.prefs
new file mode 100644 (file)
index 0000000..04d1538
--- /dev/null
@@ -0,0 +1,3 @@
+#Wed Dec 01 09:13:12 CET 2010
+eclipse.preferences.version=1
+encoding/<project>=UTF-8
diff --git a/org.eclipse.linuxtools.oprofile.core/.settings/org.eclipse.core.runtime.prefs b/org.eclipse.linuxtools.oprofile.core/.settings/org.eclipse.core.runtime.prefs
new file mode 100644 (file)
index 0000000..98f42b9
--- /dev/null
@@ -0,0 +1,3 @@
+#Tue Dec 14 16:36:19 CET 2010
+eclipse.preferences.version=1
+line.separator=\n
diff --git a/org.eclipse.linuxtools.oprofile.core/META-INF/MANIFEST.MF b/org.eclipse.linuxtools.oprofile.core/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..18715ed
--- /dev/null
@@ -0,0 +1,26 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Tizen SDK Oprofile Core
+Bundle-SymbolicName: org.eclipse.linuxtools.oprofile.core;singleton:=true
+Bundle-Version: 1.3.18.qualifier
+Bundle-Activator: org.eclipse.linuxtools.oprofile.core.OprofileCorePlugin
+Bundle-Vendor: Eclipse Linux Tools
+Require-Bundle: org.eclipse.core.runtime;bundle-version="3.4.0",
+ org.eclipse.ui;bundle-version="3.4.0",
+ org.eclipse.linuxtools.profiling.launch,
+ org.tizen.common,
+ org.tizen.common.connection
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-ActivationPolicy: lazy
+Export-Package: org.tizen.oprofile.core,
+ org.tizen.oprofile.core.processor.modeldata.handler,
+ org.eclipse.linuxtools.oprofile.core,
+ org.eclipse.linuxtools.oprofile.core.daemon,
+ org.eclipse.linuxtools.oprofile.core.linux,
+ org.eclipse.linuxtools.oprofile.core.model,
+ org.eclipse.linuxtools.oprofile.core.opxml,
+ org.eclipse.linuxtools.oprofile.core.opxml.checkevent,
+ org.eclipse.linuxtools.oprofile.core.opxml.info,
+ org.eclipse.linuxtools.oprofile.core.opxml.modeldata,
+ org.eclipse.linuxtools.oprofile.core.opxml.sessions
+Import-Package: org.tizen.sdblib
diff --git a/org.eclipse.linuxtools.oprofile.core/NOTICE b/org.eclipse.linuxtools.oprofile.core/NOTICE
new file mode 100644 (file)
index 0000000..a6b69ae
--- /dev/null
@@ -0,0 +1,79 @@
+2010-02-10 SPRC SDK Team <d.kozinski@samsung.com>
+       * MANIFEST.MF : delete Bundle-Localization
+       * build.properties : fix bin.includes
+       * Oprofile.java : commented _OPROFILE_CPU_TYPE_FILES member
+       * OprofileCorePlugin.java : commented some member varaible (OPXMLPROVIDER_XPT_NAME, _opcontrolDataProvider)
+       * LinuxOpcontrolProvider.java : commented some variables and functions
+       
+2010-10-21 HyungJong, Shin <hj_shin@samsung.com>
+       * opxml, scripts directory : remove unnecessary files
+       
+2010-10-21 HyungJong, Shin <hj_shin@samsung.com>
+       * build.properties : modify bin.includes
+       * remove unused code (38 files in ./native/linux/*.*)
+       
+2010-11-03 HyungJong, Shin <hj_shin@samsung.com>
+       * LinuxOpcontrolProvider.java : modify 'session.run' code
+       * OpxmlRunner.java : modify 'session.run' code
+       
+2010-11-05 sdk <sdk@sdk-laptop.(none)>
+       * MANIFEST.MF : changed some package name
+       * Oprofile.java : changed some package name
+       * LinuxOpcontrolProvider.java : changed some package name
+       * LinuxOpxmlProvider.java : changed some package name
+       * OpxmlRunner.java : changed some package name
+       * OpModelRoot.java : changed some package name
+       
+2011-06-09 jaewon81.lim <jaewon81.lim@samsung.com>
+       * MANIFEST.MF : rearrange plugins dependency
+
+2011-06-13 jaewon81.lim <jaewon81.lim@samsung.com>
+       * LinuxOpcontrolProvider.java : some bug fix
+       
+2011-07-13 jaewon81.lim <jaewon81.lim@samsung.com>
+       * MANIFEST.MF : modified import package name
+       * LinuxOpcontrolProvider.java : modified import package name
+       * OpxmlRunner.java : modified import package name
+       
+2011-08-22 joogwan.kim <joogwan.kim@samsung.com>
+       * MANIFEST.MF : Change plug-in name
+       * LinuxOpcontrolProvider.java : Change plug-in name
+       * OpxmlRunner.java : Change plug-in name
+
+2011-10-14 wonhyoung2.park <wonhyoung2.park@samsung.com>
+       * PathParser.java : profile bug fix for window
+       * OpxmlRunner.java : profile bug fix for window
+
+2011-11-16 wonhyoung2.park <wonhyoung2.park@samsung.com>
+       * MANIFEST.MF : Profiler sdb apply
+       * CommandManager.java : added new file
+       * PathParser.java : deleted file
+       * LinuxOpcontrolProvider.java : Profiler sdb apply
+       * OpxmlRunner.java : Profiler sdb apply
+
+2011-11-29 wonhyoung2.park <wonhyoung2.park@samsung.com>
+       * MANIFEST.MF : chagne slp to tizen
+       * CommandManager.java : chagne slp to tizen
+       * Oprofile.java : chagne slp to tizen
+       * LinuxOpcontrolProvider.java : chagne slp to tizen
+       * LinuxOpxmlProvider.java : chagne slp to tizen
+       * OpxmlRunner.java : chagne slp to tizen
+       * OpModelRoot.java : chagne slp to tizen
+       
+2011-11-30 wonhyoung2.park <wonhyoung2.park@samsung.com>
+       * MANIFEST.MF : provider and plugin name modify
+
+2011-12-02 taeyoung2.son <taeyoung2.son@samsung.com>
+       * MANIFEST.MF : Delete dependency feature's version value.
+
+2011-12-03 wonhyoung2.park <wonhyoung2.park@samsung.com>
+       * MANIFEST.MF : package instll routine chage
+       * plugin.xml : package instll routine chage
+       * CommandManager.java : package instll routine chage
+
+2011-12-04 wonhyoung2.park <wonhyoung2.park@samsung.com>
+       * plugin.xml : deleted file
+
+2011-12-05 wonhyoung2.park <wonhyoung2.park@samsung.com>
+       * LinuxOpcontrolProvider.java : add console (profile stop available)
+       * OpxmlRunner.java : add console (profile stop available)
diff --git a/org.eclipse.linuxtools.oprofile.core/README b/org.eclipse.linuxtools.oprofile.core/README
new file mode 100644 (file)
index 0000000..f872c8a
--- /dev/null
@@ -0,0 +1,23 @@
+An extra step is required to install the plugin (due to OProfile's lack of a user-space mode):
+
+* Run the install script in the natives/linux/scripts directory (must be as root):
+
+               # ./install
+               
+  * This will ensure all the necessary programs are installed, and create a wrapper for opcontrol
+    which prompts for the root password (since OProfile must be run as root). It will also load the
+    OProfile kernel module, however it is not loaded persistently. Hence, after the computer is 
+    restarted and any functions of the plugin are used, there will be an extra prompt to run 
+    opcontrol that would not normally appear.
+  
+  * If there are any programs missing or an error occurs, the script will fail and display the error.
+    If there are no errors, you will see the message:
+       
+       Eclipse-OProfile plugin install successful.
+    
+    
+* To uninstall the plugin, run the uninstall script in the natives/linux/scripts (must be root):
+
+               # ./uninstall
+               
+  * This will simply remove the same files the install script created.
diff --git a/org.eclipse.linuxtools.oprofile.core/about.html b/org.eclipse.linuxtools.oprofile.core/about.html
new file mode 100644 (file)
index 0000000..0c6525d
--- /dev/null
@@ -0,0 +1,33 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
+<html>
+<head>
+<title>About</title>
+<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+<p>24th October, 2008</p>      
+<h3>License</h3>
+<p>The Eclipse Software Foundation makes available all content in this plug-in (&quot;Content&quot;).  Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;).  A copy of the EPL is available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<h3>Contributions</h3>
+
+<p>If this Content is licensed to you under the terms and conditions of the EPL, any Contributions, as defined in the EPL, uploaded, submitted, or otherwise
+made available to the Eclipse Foundation, its members and/or the host of the Eclipse Foundation web site, by you that relate to such
+Content are provided under the terms and conditions of the <a href="http://www.eclipse.org/legal/termsofuse.html">Terms of Use</a>
+for the Eclipse Foundation web site and can be made available to others under the terms of the licenses as set out in the
+<a href="http://www.eclipse.org/legal/termsofuse.html">Terms of Use</a>.</p>
+
+<p>If this Content is licensed to you under license terms and conditions other than the EPL (&quot;Other License&quot;), any modifications, enhancements and/or
+other code and/or documentation (&quot;Modifications&quot;) uploaded, submitted, or otherwise made available to the Eclipse Foundation, its members and/or the
+host of the Eclipse Foundation web site, by you that relate to such Content are provided under terms and conditions of the Other License and can be made available
+to others under the terms of the Other License.  In addition, with regard to Modifications for which you are the copyright holder, you are also
+providing the Modifications under the terms and conditions of the <a href="http://www.eclipse.org/legal/termsofuse.html">Terms of Use</a>
+for the Eclipse Foundation web site and such Modifications can be made available to others under the terms of the licenses as set out in the
+<a href="http://www.eclipse.org/legal/termsofuse.html">Terms of Use</a>.</p>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/org.eclipse.linuxtools.oprofile.core/build.properties b/org.eclipse.linuxtools.oprofile.core/build.properties
new file mode 100644 (file)
index 0000000..fb21e3e
--- /dev/null
@@ -0,0 +1,7 @@
+source.. = src/
+bin.includes = META-INF/,\
+               README,\
+               about.html,\
+               .
+javacSource = 1.6
+javacTarget = 1.6
diff --git a/org.eclipse.linuxtools.oprofile.core/schema/OpxmlProvider.exsd b/org.eclipse.linuxtools.oprofile.core/schema/OpxmlProvider.exsd
new file mode 100644 (file)
index 0000000..8b02e63
--- /dev/null
@@ -0,0 +1,70 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.linuxtools.oprofile.core" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+      <appinfo>
+         <meta.schema plugin="org.eclipse.linuxtools.oprofile.core" id="OpxmlProvider" name="OpxmlProvider"/>
+      </appinfo>
+      <documentation>
+         An extension point to allow architecture fragments to provide the opxml binary.
+      </documentation>
+   </annotation>
+
+   <element name="extension">
+      <annotation>
+         <appinfo>
+            <meta.element />
+         </appinfo>
+      </annotation>
+      <complexType>
+         <sequence>
+            <element ref="opxmlProvider"/>
+         </sequence>
+         <attribute name="point" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="id" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appinfo>
+                  <meta.attribute translatable="true"/>
+               </appinfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <element name="opxmlProvider">
+      <complexType>
+         <attribute name="class" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appinfo>
+                  <meta.attribute kind="java" basedOn=":org.eclipse.linuxtools.oprofile.core.IOpxmlProvider"/>
+               </appinfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+
+
+
+
+
+</schema>
diff --git a/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/IOpcontrolProvider.java b/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/IOpcontrolProvider.java
new file mode 100644 (file)
index 0000000..3d55bb6
--- /dev/null
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Keith Seitz <keiths@redhat.com> - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.oprofile.core;
+
+import org.eclipse.linuxtools.oprofile.core.daemon.OprofileDaemonEvent;
+import org.eclipse.linuxtools.oprofile.core.daemon.OprofileDaemonOptions;
+
+/**
+ * Interface for oprofile core to utilize opcontrol program. Platform plugins should define/register
+ * an OpcontrolProvider for the core to use.
+ */
+public interface IOpcontrolProvider {
+       
+       /**
+        * Initialize the Oprofile kernel module
+        * @throws OpcontrolException
+        */
+       public void initModule() throws OpcontrolException;
+       
+       /**
+        * De-initialize (unload) the kernel module
+        * @throws OpcontrolException
+        */
+       public void deinitModule() throws OpcontrolException;
+       
+       /**
+        * Clears out data from the current session
+        * @throws OpcontrolException
+        */
+       public void reset() throws OpcontrolException;
+       
+       /**
+        * Flush the current oprofiled sample buffers to disk
+        * @throws OpcontrolException
+        */
+       public void dumpSamples() throws OpcontrolException;
+       
+       /**
+        * Setup oprofiled collection parameters
+        * @param options a list of command-line arguments for opcontrol
+        * @param events list of events to collect
+        * @throws OpcontrolException
+        */
+       public void setupDaemon(OprofileDaemonOptions options, OprofileDaemonEvent[] events) throws OpcontrolException;
+       
+       //jinu added at 20090602
+       public void setupDaemon(OprofileDaemonOptions options, OprofileDaemonEvent[] events, String defaultEvent) throws OpcontrolException;
+       
+       /**
+        * Start data collection by oprofiled (will start oprofiled if necessary)
+        * @throws OpcontrolException
+        */
+       public void startCollection() throws OpcontrolException;
+       
+       /**
+        * Stop data collection (does NOT stop daemon)
+        * @throws OpcontrolException
+        */
+       public void stopCollection() throws OpcontrolException;
+       
+       /**
+        * Stop data collection and shutdown oprofiled
+        * @throws OpcontrolException
+        */
+       public void shutdownDaemon() throws OpcontrolException;
+       
+       /**
+        * Start oprofiled (does NOT start data collection)
+        * @throws OpcontrolException
+        */
+       public void startDaemon() throws OpcontrolException;
+       
+       /**
+        * Save the current session
+        * @throws OpcontrolException
+        */
+       public void saveSession(String name) throws OpcontrolException;
+       
+       //jinu added at 20090526
+       public void removeDaemonSetting() throws OpcontrolException;
+}
diff --git a/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/IOpxmlProvider.java b/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/IOpxmlProvider.java
new file mode 100644 (file)
index 0000000..97e05bc
--- /dev/null
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2004,2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Keith Seitz <keiths@redhat.com> - initial API and implementation
+ *    Kent Sebastian <ksebasti@redhat.com> - 
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.oprofile.core;
+
+import java.util.ArrayList;
+
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.linuxtools.oprofile.core.daemon.OpInfo;
+import org.eclipse.linuxtools.oprofile.core.model.OpModelEvent;
+import org.eclipse.linuxtools.oprofile.core.model.OpModelImage;
+
+/**
+ * Interface for the core to utilize opxml. Platform plugins should define/register an
+ * OpxmlProvider for the core to use.
+ */
+public interface IOpxmlProvider {
+       
+       /**
+        * Returns an <code>IRunnableWithProgress</code> that fetches generic information from opxml
+        * @param info <code>OpInfo</code> object for results
+        * @return <code>IRunnableWithProgress</code> that may be run by the caller
+        */
+       public IRunnableWithProgress info(OpInfo info);
+       
+       /**
+        * Returns an <code>IRunnableWithProgress</code> that fetches samples for the
+        * given <code>OpModelSession</code>
+        * @param eventName the event for which to fetch samples
+        * @param sessionName the session for which to fetch samples
+        * @param image the image being profiled to be returned to the caller
+        * @return <code>IRunnableWithProgress</code> that may be run by the caller
+        */
+       public IRunnableWithProgress modelData(String eventName, String sessionName, OpModelImage image);
+       
+       /**
+        * Returns an <code>IRunnableWithProgress</code> that checks the validity of the given
+        * event, unit mask, and counter combination 
+        * @param ctr the counter
+        * @param event the integer event number
+        * @param um the integer unit mask
+        * @param eventValid a size one array to hold the return result (see <code>CheckKernelProcessor</code>)
+        * @return <code>IRunnableWithProgress</code> that may be run by the caller
+        */
+       public IRunnableWithProgress checkEvents(int ctr, int event, int um, int[] eventValid);
+       
+       /**
+        * Returns an /code>IRunnableWithProgress</code> that fetches the list of sessions
+        * @param info the <code>OpInfo</code> for oprofile
+        * @param sessionList an <code>ArrayList</code> in which to return the list of sessions
+        * @return <code>IRunnableWithProgress</code> that may be run by the caller
+        */
+       public IRunnableWithProgress sessions(ArrayList<OpModelEvent> sessionList);
+}
diff --git a/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/OpcontrolException.java b/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/OpcontrolException.java
new file mode 100644 (file)
index 0000000..f6de34b
--- /dev/null
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2004,2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Keith Seitz <keiths@redhat.com> - initial API and implementation
+ *    Kent Sebastian <ksebasti@redhat.com> - 
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.oprofile.core;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+
+public class OpcontrolException extends CoreException {
+       //without this there's a warning..
+       private static final long serialVersionUID = 8508930482724912901L;
+
+       public OpcontrolException(IStatus status) {
+               super(status);
+       }
+}
diff --git a/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/Oprofile.java b/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/Oprofile.java
new file mode 100644 (file)
index 0000000..60fe4a3
--- /dev/null
@@ -0,0 +1,324 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008, 2009 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Keith Seitz <keiths@redhat.com> - initial API and implementation
+ *    Kent Sebastian <ksebasti@redhat.com> - 
+ *******************************************************************************/ 
+
+package org.eclipse.linuxtools.oprofile.core;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.linuxtools.oprofile.core.daemon.OpEvent;
+import org.eclipse.linuxtools.oprofile.core.daemon.OpInfo;
+import org.eclipse.linuxtools.oprofile.core.model.OpModelEvent;
+import org.eclipse.linuxtools.oprofile.core.model.OpModelImage;
+import org.eclipse.linuxtools.oprofile.core.opxml.checkevent.CheckEventsProcessor;
+
+import org.tizen.oprofile.core.OprofileComm;
+import org.tizen.oprofile.core.provider.OpcontrolDataProvider;
+
+
+/**
+ * Common class wrapper for all things Oprofile.
+ */
+public abstract class Oprofile
+{
+       // Ugh. Need to know whether the module is loaded without running oprofile commands...
+//     private static final String[] _OPROFILE_CPU_TYPE_FILES = {
+//             "/dev/oprofile/cpu_type", //$NON-NLS-1$
+//             "/proc/sys/dev/oprofile/cpu_type"  //$NON-NLS-1$
+//     };
+       
+       // Oprofile information
+       private static OpInfo _info;
+       
+       
+       // Make sure that oprofile is ready to go
+       //jinu removed at 20090603
+       /*
+       static {
+               initializeOprofileModule();
+       }
+       */
+       
+       /**
+        * Initialize the oprofile module
+        * 
+        * This function will check if the kernel module is
+        * loaded. If it is not, it will attempt to load it
+        * (which will cause the system to prompt the user for
+        * root access).
+        */
+       static private void initializeOprofileModule() throws OpcontrolException{
+               // Check if kernel module is loaded, if not, try to load it
+
+               //jinu removed at 20090628
+               //if (!isKernelModuleLoaded())
+                       _initializeOprofile();
+               
+               //it still may not have loaded, if not, critical error
+               if (!isKernelModuleLoaded()) {
+                       //jinu modified at 20090628
+                       /*
+                       OprofileCorePlugin.showErrorDialog("oprofileInit", null); //$NON-NLS-1$
+                       throw new ExceptionInInitializerError(OprofileProperties.getString("fatal.kernelModuleNotLoaded")); //$NON-NLS-1$
+                       */
+                       String error = "The OProfile kernel module could not be loaded";
+                       String reason = "An error occurred initializing OProfile for use with the plugin. Please check Oprofile to be installed successfully";
+                       OprofileComm.showErrorDialog(error, reason , null); //$NON-NLS-1$
+               } else {
+                       _initializeOprofileCore();
+               }
+       }
+       
+       // This requires more inside knowledge about Oprofile than one would like,
+       // but it is the only way of knowing whether the module is loaded (and we can
+       // succesfully call into the oprofile wrapper library without causing it to print out
+       // a lot of warnings).
+       //jinu modified at 20090619
+       /*
+       private static boolean isKernelModuleLoaded() {
+               for (int i = 0; i < _OPROFILE_CPU_TYPE_FILES.length; ++i) {
+                       File f = new File(_OPROFILE_CPU_TYPE_FILES[i]);
+                       if (f.exists())
+                               return true;
+               }
+               
+               return false;
+       }
+       */
+       private static boolean isKernelModuleLoaded() {
+               String[] result = new String[1];
+               try {
+                       IRunnableWithProgress opxml = OpcontrolDataProvider.checkKernelModule(result);
+                       opxml.run(null);
+               } catch (InvocationTargetException e) {
+                       String error = "The OProfile kernel module could not be loaded";
+                       String reason = "An error occurred initializing OProfile for use with the plugin. Please check OProfile to be installed successfully";
+                       OprofileComm.showErrorDialog(error, reason , e); //$NON-NLS-1$
+               } catch (InterruptedException e) {
+                       String error = "The OProfile kernel module could not be loaded";
+                       String reason = "An error occurred initializing OProfile for use with the plugin. Please check OProfile to be installed successfully";
+                       OprofileComm.showErrorDialog(error, reason , e); //$NON-NLS-1$
+               }
+               
+               setCpuType(result[0]);
+               return !(result[0] == null);
+       }
+       
+       //jinu modified at 20090619
+       // initialize oprofile module by calling `opcontrol --init`
+       /*
+       private static void _initializeOprofile() {
+               try {
+                       OprofileCorePlugin.getDefault().getOpcontrolProvider().initModule();
+               } catch (OpcontrolException e) {
+                       OprofileCorePlugin.showErrorDialog("opcontrolProvider", e); //$NON-NLS-1$
+               } 
+       }
+       */
+       private static void _initializeOprofile() throws OpcontrolException{
+               OprofileCorePlugin.getDefault().getOpcontrolProvider().initModule();
+       }
+       
+       // Initializes static data for oprofile.        
+       private static void _initializeOprofileCore () {
+               //jinu modified at 20090622
+               //_info = OpInfo.getInfo();
+               _info = OprofileComm.getEventInfo();
+       }
+       
+
+       /**
+        * Queries oprofile for the number of counters on the current CPU.
+        * Used only in launch config tabs.
+        * @return the number of counters
+        */
+       public static int getNumberOfCounters() {
+               //jinu modified at 20090622
+               //return _info.getNrCounters();
+               return getOpInfo().getNrCounters();
+       }
+       
+       /**
+        * Returns the CPU speed of the current configuration.
+        * @return the cpu speed in MHz
+        */
+       public static double getCpuFrequency() {
+               //jinu modified at 20090622
+               //return _info.getCPUSpeed();
+               return getOpInfo().getCPUSpeed();
+       }
+
+       /**
+        * Finds the event with the given name
+        * @param name the event's name (i.e., CPU_CLK_UNHALTED)
+        * @return the event or <code>null</code> if not found
+        */
+       public static OpEvent findEvent(String name) {
+               //jinu modified at 20090622
+               //return _info.findEvent(name);
+               return getOpInfo().findEvent(name);
+       }
+
+       /**
+        * Get all the events that may be collected on the given counter.
+        * @param num the counter number
+        * @return an array of all valid events -- NEVER RETURNS NULL!
+        */
+       public static OpEvent[] getEvents(int num) {
+               //jinu modified at 20090622
+               //return _info.getEvents(num);
+               return getOpInfo().getEvents(num);
+       }
+       
+       /**
+        * Returns the default location of the oprofile samples directory.
+        * @return the default samples directory
+        */
+       public static String getDefaultSamplesDirectory() {
+               //jinu modified at 20090622
+               //return _info.getDefault(OpInfo.DEFAULT_SAMPLE_DIR);
+               return getOpInfo().getDefault(OpInfo.DEFAULT_SAMPLE_DIR);
+       }
+       
+       /**
+        * Returns the oprofile daemon log file.
+        * @return the log file (absolute pathname)
+        */
+       public static String getLogFile() {
+               //jinu modified at 20090622
+               //return _info.getDefault(OpInfo.DEFAULT_LOG_FILE);
+               return getOpInfo().getDefault(OpInfo.DEFAULT_LOG_FILE);
+       }
+       
+       /**
+        * Returns whether or not oprofile is in timer mode.
+        * @return true if oprofile is in timer mode, false otherwise
+        */
+       public static boolean getTimerMode() {
+               //jinu modified at 20090622
+               //return _info.getTimerMode();
+               return getOpInfo().getTimerMode();
+       }
+       
+       /**
+        * Checks the requested counter, event, and unit mask for vailidity.
+        * @param ctr   the counter
+        * @param event the event number
+        * @param um    the unit mask
+        * @return whether the requested event is valid
+        */
+       public static Boolean checkEvent(int ctr, int event, int um) {
+               int[] validResult = new int[1];
+               try {
+                       IRunnableWithProgress opxml = OprofileCorePlugin.getDefault().getOpxmlProvider().checkEvents(ctr, event, um, validResult);
+                       opxml.run(null);
+               } catch (InvocationTargetException e) {
+                       e.printStackTrace();
+               } catch (InterruptedException e) {
+                       e.printStackTrace();
+               } catch (OpxmlException e) {
+                       OprofileCorePlugin.showErrorDialog("opxmlProvider", e); //$NON-NLS-1$
+                       return null;
+               }
+               
+               return (validResult[0] == CheckEventsProcessor.EVENT_OK);
+       }
+       
+       
+       
+       /**
+        * Returns a list of all the events collected on the system, as well as
+        * the sessions under each of them.
+        * @returns a list of all collected events
+        */
+       public static OpModelEvent[] getEvents() {
+               OpModelEvent[] events = null;
+               
+               ArrayList<OpModelEvent> sessionList = new ArrayList<OpModelEvent>();
+               try {
+                       IRunnableWithProgress opxml = OprofileCorePlugin.getDefault().getOpxmlProvider().sessions(sessionList);
+                       opxml.run(null);
+                       events = new OpModelEvent[sessionList.size()];
+                       sessionList.toArray(events);
+               } catch (InvocationTargetException e) {
+                       e.printStackTrace();
+               } catch (InterruptedException e) {
+                       e.printStackTrace();
+               } catch (OpxmlException e) {
+                       OprofileCorePlugin.showErrorDialog("opxmlProvider", e); //$NON-NLS-1$
+               }
+               return events;
+       }
+       
+       
+       /**
+        * Return a list of all the Samples in the given session.
+        * @param session the session for which to get samples
+        * @param shell the composite shell to use for the progress dialog
+        */
+       public static OpModelImage getModelData(String eventName, String sessionName) {         
+               OpModelImage image = new OpModelImage();
+               
+               final IRunnableWithProgress opxml;
+               try {
+                       opxml = OprofileCorePlugin.getDefault().getOpxmlProvider().modelData(eventName, sessionName, image);
+                       opxml.run(null);
+               } catch (InvocationTargetException e) { 
+                       e.printStackTrace();
+               } catch (InterruptedException e) { 
+                       e.printStackTrace();
+               } catch (OpxmlException e) {
+                       OprofileCorePlugin.showErrorDialog("opxmlProvider", e); //$NON-NLS-1$
+                       return null;
+               }
+
+               return image;
+       }
+       
+       
+       
+       
+
+       
+       //jinu added at 20090604 -----------------------------
+       public static void initialize(){
+               if(_info != null)
+                       _info = null;
+       }
+       
+       public static OpInfo getOpInfo(){
+               try {
+                       if(_info==null||isValid(_info))
+                               initializeOprofileModule();
+               } catch (OpcontrolException e) {
+                       e.printStackTrace();
+               }
+               
+               return _info;
+       }
+       
+       private static boolean isValid(OpInfo info){
+               return info.getNrCounters()==0 ^ info.getTimerMode();
+       }
+       
+       private static String _cpuType;
+       public static String getCpuType() {
+               return _cpuType;
+       }
+       public static void setCpuType(String cpuType) {
+               _cpuType = cpuType;
+       }
+       //------------------------------------
+       
+       
+}
diff --git a/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/OprofileCorePlugin.java b/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/OprofileCorePlugin.java
new file mode 100644 (file)
index 0000000..bea8799
--- /dev/null
@@ -0,0 +1,196 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008, 2009 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Keith Seitz <keiths@redhat.com> - initial API and implementation
+ *    Kent Sebastian <ksebasti@redhat.com> - 
+ *******************************************************************************/ 
+
+package org.eclipse.linuxtools.oprofile.core;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Plugin;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.linuxtools.oprofile.core.linux.LinuxOpcontrolProvider;
+import org.eclipse.linuxtools.oprofile.core.linux.LinuxOpxmlProvider;
+import org.eclipse.swt.widgets.Display;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The main plugin class to be used in the desktop.
+ */
+public class OprofileCorePlugin extends Plugin {
+       private static final String PLUGIN_ID = "org.eclipse.linuxtools.oprofile.core"; //$NON-NLS-1$
+//     private static final String OPXMLPROVIDER_XPT_NAME = "OpxmlProvider"; //$NON-NLS-1$
+
+       //The shared instance.
+       private static OprofileCorePlugin plugin;
+       private IOpxmlProvider _opxmlProvider;
+//     private OpcontrolDataProvider _opcontrolDataProvider;
+       
+       /**
+        * The constructor.
+        */
+       public OprofileCorePlugin() {
+               plugin = this;
+       }
+       
+       /**
+        * This method is called upon plug-in activation
+        */
+       public void start(BundleContext context) throws Exception {
+               super.start(context);
+       }
+
+       /**
+        * This method is called when the plug-in is stopped
+        */
+       public void stop(BundleContext context) throws Exception {
+               super.stop(context);
+               plugin = null;
+       }
+       
+       /**
+        * Returns the shared instance.
+        */
+       public static OprofileCorePlugin getDefault() {
+               return plugin;
+       }
+
+       /**
+        * Returns the unique id of this plugin. Should match plugin.xml!
+        */
+       public static String getId() {
+               return PLUGIN_ID;
+       }
+       
+       /**
+        * Returns the OpxmlProvider registered with the plugin or throws an exception
+        * @return the OpxmlProvider
+        * @throws OpxmlException
+        */
+       public IOpxmlProvider getOpxmlProvider() throws OpxmlException {
+               //jinu modified at 20090526
+               /*
+               Exception except = null;
+               
+               if (_opxmlProvider == null) {
+                       IExtensionRegistry registry = Platform.getExtensionRegistry();
+                       IExtensionPoint extension = registry.getExtensionPoint(PLUGIN_ID, OPXMLPROVIDER_XPT_NAME);
+                       if (extension != null) {
+                               IExtension[] extensions = extension.getExtensions();
+                               for (IExtension e : extensions) {
+                                       IConfigurationElement[] configElements = e.getConfigurationElements();
+                                       if (configElements.length != 0) {
+                                               try {
+                                                       _opxmlProvider = (IOpxmlProvider) configElements[0].createExecutableExtension("class"); //$NON-NLS-1$
+                                                       if (_opxmlProvider != null)
+                                                               break;
+                                               } catch (CoreException ce) {
+                                                       except = ce;
+                                               }
+                                       }
+                               }
+                       }
+               }
+               
+               // If there was a problem finding opxml, throw an exception
+               if (_opxmlProvider == null) {
+                       throw new OpxmlException(createErrorStatus("opxmlProvider", except)); //$NON-NLS-1$
+               } else {
+                       return _opxmlProvider;
+               }
+               */
+               if(_opxmlProvider==null)
+                       _opxmlProvider = new LinuxOpxmlProvider();
+               
+               return _opxmlProvider;
+       }
+       
+       
+       /*public OpcontrolDataProvider getOpcontrolDataProvider() throws OpcontrolException {
+               if(_opcontrolDataProvider==null)
+                       _opcontrolDataProvider = new OpcontrolDataProvider();
+               
+               return _opcontrolDataProvider;
+       }*/
+       
+       /**
+        * Returns the registered opcontrol provider or throws an exception
+        * @return the OpcontrolProvider registered with the plugin
+        * @throws OpcontrolException
+        */
+       public IOpcontrolProvider getOpcontrolProvider() throws OpcontrolException {
+               //jinu modified at 20090526
+               /*
+               Exception except = null;
+               
+               if (_opcontrol == null) {
+                       IExtensionRegistry registry = Platform.getExtensionRegistry();
+                       IExtensionPoint extension = registry.getExtensionPoint(PLUGIN_ID, "OpcontrolProvider"); //$NON-NLS-1$
+                       if (extension != null) {
+                               IExtension[] extensions = extension.getExtensions();
+                               IConfigurationElement[] configElements = extensions[0].getConfigurationElements();
+                               if (configElements.length != 0) {
+                                       try {
+                                               _opcontrol = (IOpcontrolProvider) configElements[0].createExecutableExtension("class"); //$NON-NLS-1$
+                                       } catch (CoreException ce) {
+                                               except = ce;
+                                       }
+                               }
+                       }
+               }
+               
+               // If there was a problem finding opcontrol, throw an exception
+               if (_opcontrol == null) {
+                       String msg = getResourceString("opcontrolProvider.error.missing"); //$NON-NLS-1$
+                       Status status = new Status(IStatus.ERROR, getId(), IStatus.OK, msg, except);
+                       throw new OpcontrolException(status);
+               }
+
+               return _opcontrol;
+               */
+               
+               return new LinuxOpcontrolProvider();
+       }
+       
+       public static IStatus createErrorStatus(String errorClassString, Exception e) {
+               String statusMessage = OprofileProperties.getString(errorClassString + ".error.statusMessage"); //$NON-NLS-1$
+
+               if (e == null) {
+                       return new Status(IStatus.ERROR, getId(), IStatus.OK, statusMessage, null);
+               } else {
+                       return new Status(IStatus.ERROR, getId(), IStatus.OK, statusMessage, e);
+               }
+       }
+       
+       public static void showErrorDialog(String errorClassString, CoreException ex) {
+               final IStatus status;
+               final String dialogTitle = OprofileProperties.getString(errorClassString + ".error.dialog.title"); //$NON-NLS-1$
+               final String errorMessage = OprofileProperties.getString(errorClassString + ".error.dialog.message"); //$NON-NLS-1$
+               
+               if (ex == null) {
+                       status = createErrorStatus(errorClassString, null);
+               } else {
+                       status = ex.getStatus();
+               }
+
+               //needs to be run in the ui thread otherwise swt throws invalid thread access 
+               Display.getDefault().syncExec(new Runnable() {
+                       public void run() {
+                               ErrorDialog.openError(null, dialogTitle, errorMessage, status);
+                       }
+               });
+
+       }
+       
+
+       
+       
+}
diff --git a/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/OprofileProperties.java b/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/OprofileProperties.java
new file mode 100644 (file)
index 0000000..f1bf26e
--- /dev/null
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Keith Seitz <keiths@redhat.com> - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.oprofile.core;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class OprofileProperties {
+       private static final String BUNDLE_NAME = "org.eclipse.linuxtools.oprofile.core.oprofile"; //$NON-NLS-1$
+       private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
+
+       private OprofileProperties() {
+       }
+
+       public static String getString(String key) {
+               try {
+                       return RESOURCE_BUNDLE.getString(key);
+               } catch (MissingResourceException e) {
+                       return '!' + key + '!';
+               }
+       }
+}
diff --git a/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/OpxmlException.java b/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/OpxmlException.java
new file mode 100644 (file)
index 0000000..21b40e0
--- /dev/null
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Keith Seitz <keiths@redhat.com> - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.oprofile.core;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+
+/**
+ * An exception thrown by any of the IOpxmlProvider functions
+ */
+public class OpxmlException extends CoreException {
+
+       /**
+        * 
+        */
+       private static final long serialVersionUID = 2788304536155025911L;
+
+       /**
+        * Constructor
+        * @param status <code>IStatus</code> for the exception
+        */
+       public OpxmlException(IStatus status) {
+               super(status);
+       }
+}
diff --git a/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/daemon/OpEvent.java b/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/daemon/OpEvent.java
new file mode 100644 (file)
index 0000000..9204f02
--- /dev/null
@@ -0,0 +1,118 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2009 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Keith Seitz <keiths@redhat.com> - initial API and implementation
+ *    Kent Sebastian <ksebasti@redhat.com>
+ *******************************************************************************/ 
+
+package org.eclipse.linuxtools.oprofile.core.daemon;
+
+/**
+ * A class which represents an Oprofile event
+ */
+public class OpEvent {
+       // The Oprofile event name, i.e., "CPU_CLK_UNHALTED"
+       private String _name;
+       
+       // The Oprofile event number
+       private int _number;
+       
+        //  A description of the event
+       private String _description;
+
+       // Unit masks for this event type
+       private OpUnitMask _unitMask;
+       
+       // Minimum count
+       private int _minCount;
+       
+       /**
+        * Sets the unit mask for this event.
+        * Only called from XML parsers.
+        * @param mask the new unit mask
+        */
+       public void _setUnitMask(OpUnitMask mask) {
+               _unitMask = mask;
+       }
+
+       /**
+        * Sets the name of this event.
+        * Only called from XML parsers.
+        * @param text the name
+        */
+       public void _setText(String text) {
+               _name = text;
+       }
+
+       /**
+        * Sets the description of this oprofile event.
+        * Only called from XML parsers.
+        * @param text the description
+        */
+       public void _setTextDescription(String text) {
+               _description = text;
+       }
+
+       /**
+        * Sets the minimum count for this event.
+        * Only called from XML parsers.
+        * @param min the minimum count
+        */
+       public void _setMinCount(int min) {
+               _minCount = min;
+       }
+
+       /**
+        * Sets oprofile's event number for this event.
+        * Only called from XML parsers.
+        * @param num the number
+        */
+       public void _setNumber(int num) {
+               _number = num;
+       }
+
+       /**
+        * Returns the unit mask corresponding to this event.
+        * @return the unit mask
+        */
+       public OpUnitMask getUnitMask() {               
+               return _unitMask;
+       }
+       
+       /**
+        * Returns the name of this oprofile event.
+        * @return the name
+        */
+       public String getText() {
+               return _name;
+       }
+       
+       /**
+        * Returns the description of this oprofile event.
+        * @return the description
+        */
+       public String getTextDescription() {
+               return _description;
+       }
+       
+       /**
+        * Returns the minimum count allowed for this event.
+        * @return the minimum count
+        */
+       public int getMinCount() {
+               return _minCount;
+       }
+       
+       /**
+        * Returns oprofile's event number for this event.
+        * @return the event number
+        */
+       public int getNumber() {
+               return _number;
+       }
+}
diff --git a/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/daemon/OpInfo.java b/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/daemon/OpInfo.java
new file mode 100644 (file)
index 0000000..4d926eb
--- /dev/null
@@ -0,0 +1,214 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008, 2009 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Keith Seitz <keiths@redhat.com> - initial API and implementation
+ *    Kent Sebastian <ksebasti@redhat.com>
+ *******************************************************************************/ 
+
+package org.eclipse.linuxtools.oprofile.core.daemon;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.HashMap;
+
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.linuxtools.oprofile.core.OprofileCorePlugin;
+import org.eclipse.linuxtools.oprofile.core.OpxmlException;
+import org.eclipse.linuxtools.oprofile.core.opxml.info.DefaultsProcessor;
+
+
+/**
+ * A class to hold generic information about Oprofile.
+ */
+public class OpInfo {
+       // Oprofile defaults
+       public static final String DEFAULT_SAMPLE_DIR = DefaultsProcessor.SAMPLE_DIR;
+       public static final String DEFAULT_LOCK_FILE = DefaultsProcessor.LOCK_FILE;
+       public static final String DEFAULT_LOG_FILE = DefaultsProcessor.LOG_FILE; //use
+       public static final String DEFAULT_DUMP_STATUS = DefaultsProcessor.DUMP_STATUS;
+       
+       // A comparator class used when sorting events
+       // (sorting by event name)
+       private static class SortEventComparator implements Comparator<OpEvent> {
+               public int compare(OpEvent o1, OpEvent o2) {
+                       return o1.getText().compareTo(o2.getText());
+               }
+       }
+
+       // A comparator class used when searching events
+       // (searching by event name)
+       private static class SearchEventComparator implements Comparator<Object> {
+               public int compare(Object a, Object b) {
+                       String astr, bstr;
+                       if (a instanceof String) {
+                               astr = (String) a;
+                               bstr = ((OpEvent) b).getText();
+                       } else {
+                               astr = ((OpEvent) a).getText();
+                               bstr = (String) b;
+                       }
+                       return astr.compareTo(bstr);
+               }
+       }
+       
+       // The number of counters supported by this configuration
+       private int _nrCounters;
+       
+       // A HashMap of Oprofile defaults
+       private HashMap<String,String> _defaults;
+       
+       // The permanent list of events indexed by counter
+       private OpEvent[][] _eventList;
+       
+       // The CPU frequency of this CPU in MHz
+       private double _cpuSpeed;
+       
+       // Whether or not oprofile is running in timer mode
+       private boolean _timerMode;
+       
+       /**
+        * Return all of Oprofile's generic information.
+        * @return a class containing the information
+        */
+       public static OpInfo getInfo() {                
+               // Run opmxl and get the static information
+               OpInfo info = new OpInfo();
+
+               try {
+                       IRunnableWithProgress opxml = OprofileCorePlugin.getDefault().getOpxmlProvider().info(info);
+                       opxml.run(null);
+               } catch (InvocationTargetException e) {
+                       e.printStackTrace();
+               } catch (InterruptedException e) {
+                       e.printStackTrace();
+               } catch (OpxmlException e) {
+                       OprofileCorePlugin.showErrorDialog("opxmlProvider", e); //$NON-NLS-1$
+               }
+               
+               return info;
+       }
+
+       /**
+        * Sets the number of counters allowed by Oprofile. This method is called
+        * after this object is contstructed, while opxml is run (the first tag output
+        * is num-counters).
+        * Only called from XML parsers.
+        * @param ctrs the number of counters
+        */
+       public void _setNrCounters(int ctrs) {
+               _nrCounters = ctrs;
+               
+               // Allocate room for event lists for the counters
+               _eventList = new OpEvent[_nrCounters][];
+       }
+
+       /**
+        * Set the CPU frequency (in MHz).
+        * Only called from the XML parsers.
+        * @param freq the frequency
+        */
+       public void _setCPUSpeed(double freq) {
+               _cpuSpeed = freq;
+       }
+
+       /**
+        * Sets the defaults associated with this configuration of Oprofile.
+        * Only called from XML parsers.
+        * @param map the <code>HashMap</code> containing the defaults
+        */
+       public void _setDefaults(HashMap<String,String> map) {
+               _defaults = map;
+       }
+
+       /**
+        * Adds the events of the counter counterNum into the list of all events.
+        * Note they are sorted here.
+        * Only called from XML parsers.
+        * @param counterNum the counter with the events
+        * @param events an array of OpEvent events belonging to this counter
+        */
+       public void _setEvents(int counterNum, OpEvent[] events) {
+               if (counterNum < _eventList.length) {
+                       _eventList[counterNum] = events;
+                       Arrays.sort(_eventList[counterNum], new SortEventComparator());
+               }
+       }
+       
+       /**
+        * Sets whether or not oprofile is operating in timer mode.
+        * Only called from XML parsers.
+        * @param timerMode true if oprofile is in timer mode, false if not
+        */
+       public void _setTimerMode(boolean timerMode) {
+               _timerMode = timerMode;
+       }
+
+       /**
+        * Returns the number of counters allowed by Oprofile
+        * @return the number of counters
+        */
+       public int getNrCounters() {
+               return _nrCounters;
+       }
+               
+       /**
+        * Returns the CPU's speed in MHz
+        * @return the speed
+        */
+       public double getCPUSpeed() {
+               return _cpuSpeed;
+       }
+       
+       /**
+        * Returns the requested default. Valid defaults are <code>DEFAULT_DUMP_STATUS</code>,
+        * <code>DEFAULT_LOCK_FILE</code>, <code>DEFAULT_LOG_FILE</code>, and
+        * <code>DEFAULT_SAMPLE_DIR</code>.
+        * @param what which default to return
+        * @return the requested default or <code>null</code> if not known
+        */
+       public String getDefault(String what) {
+               return (String) _defaults.get(what);
+       }
+
+       /**
+        * Returns an array of events valid for the given counter number.
+        * @param num the counter number
+        * @return an array of valid events
+        */ 
+       public OpEvent[] getEvents(int num) {
+               if (num >= 0 && num < _eventList.length)
+                       return _eventList[num];
+               
+               return new OpEvent[0];
+       }
+       
+       /**
+        * Returns whether or not oprofile is operating in timer mode.
+        * @return a boolean, true if in timer mode, false if not
+        */
+       public boolean getTimerMode() {
+               return _timerMode;
+       }
+       
+       /**
+        * Searches the for the event with the given name
+        * @param name the name of the event (e.g., CPU_CLK_UNHALTED)
+        * @return the event or <code>null</code> if not found
+        */
+       public OpEvent findEvent(String name) {
+               // Search through all counters
+               for (int counter = 0; counter < getNrCounters(); ++counter) {
+                       int idx = Arrays.binarySearch(getEvents(counter), name, new SearchEventComparator());
+                       if (idx >= 0)
+                               return _eventList[counter][idx];
+               }
+               
+               return null;
+       }
+}
diff --git a/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/daemon/OpUnitMask.java b/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/daemon/OpUnitMask.java
new file mode 100644 (file)
index 0000000..050cf0f
--- /dev/null
@@ -0,0 +1,244 @@
+/*******************************************************************************
+ * Copyright (c) 2004,2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Keith Seitz <keiths@redhat.com> - initial API and implementation
+ *    Kent Sebastian <ksebasti@redhat.com> 
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.oprofile.core.daemon;
+
+/**
+ * A class representing the unit mask that may be associated with oprofile
+ * events. Note that since this class was originally written, oprofile unit
+ * masks have changed -- a single unit mask may affect several bits at once.
+ * Hence, instead of a certain bit being flipped, the specific bits to be changed 
+ * are determined by the particular mask's index 
+ */
+public class OpUnitMask {
+       /**
+        * A class which describes an individual unit mask value. Used in XML parsing.
+        */
+       public static class MaskInfo {
+               /**
+                * The integer value of the mask.
+                */
+               public int value;
+
+               /**
+                * A description of the mask.
+                */
+               public String description;
+       };
+       
+       public static final int SET_DEFAULT_MASK = -1;
+
+       /**
+        * Invalid mask type.
+        */
+       public static final int INVALID = -1;
+
+       /**
+        * The mask is mandatory. It must be used.
+        */
+       public static final int MANDATORY = 1;
+
+       /**
+        * The mask is exclusive. Only one of its mask values may be used.
+        */
+       public static final int EXCLUSIVE = 2;
+
+       /**
+        * The mask is a bitmask. Any combination of its values may be used.
+        */
+       public static final int BITMASK = 3;
+
+
+       // The current value of this unitmask
+       private int _mask;
+
+       // The default mask provided by the oprofile library
+       private int _defaultMask;
+
+       // The type of this unitmask
+       private int _maskType;
+
+       // Descriptions of the bits of this mask
+       private String[] _maskOptionDescriptions = new String[0];
+
+       // mask values -- now bit masks have distinct values (eg: an all of the
+       // above)
+       private int[] _maskOptionValues;
+
+       /**
+        * Set the descriptions and values for this unitmask's mask options.
+        * Only used from the XML parsers.
+        * @param masks a list of all the mask options
+        */
+       public void _setMaskDescriptions(MaskInfo[] masks) {
+               _maskOptionDescriptions = new String[masks.length];
+               _maskOptionValues = new int[masks.length];
+
+               for (int i = 0; i < masks.length; ++i) {
+                       _maskOptionDescriptions[i] = masks[i].description;
+                       _maskOptionValues[i] = masks[i].value;
+               }
+       }
+
+       /**
+        * Sets the default value for this unitmask, and initializes
+        *   the current unitmask value to this default.
+        * Only used from the XML parsers.
+        * @param theDefault the default value
+        */
+       public void _setDefault(int theDefault) {
+               _defaultMask = theDefault;
+               setDefaultMaskValue();  
+       }
+       
+       /**
+        * Sets the unitmask type.
+        * Only used from the XML parsers.
+        * @param type the type
+        */
+       public void _setType(int type) {
+               _maskType = type;
+       }
+       
+       /**
+        * Returns the integer value of this unitmask, suitable for passing to oprofile.
+        * @return the integer value
+        */
+       public int getMaskValue() {
+               return _mask;
+       }
+
+       /**
+        * Tests whether a particular mask is set in the unitmask value, based on the
+        * value of the mask option at the given index.
+        * 
+        * @param index the index of the mask option to check
+        * @return whether the given mask option's value is set
+        */
+       public boolean isMaskSetFromIndex(int index) {
+               boolean result = false;
+
+               if (index >= 0 && index < _maskOptionValues.length) {
+                       switch (_maskType) {
+                       case EXCLUSIVE:
+                               result = (_mask == _maskOptionValues[index]);
+                               break;
+
+                       case BITMASK:
+                               result = ((_mask & _maskOptionValues[index]) != 0);
+                               break;
+
+                       default:
+                               result = false;
+                       }
+               }
+
+               return result;
+       }
+
+       /**
+        * Sets the absolute unitmask value. 
+        * 
+        * @param newValue the new value of this unitmask
+        */
+       public void setMaskValue(int newValue) {
+               if (newValue == SET_DEFAULT_MASK) {
+                       _mask = _defaultMask;
+               } else {
+                       _mask = newValue;
+               }
+       }
+       
+       /**
+        * Sets the bits of the given mask option's value in the unitmask value.
+        * @param index the index of the mask option to set
+        */
+       public void setMaskFromIndex(int index) {
+               //mandatory masks only use the default value
+               if (index >= 0 && index < _maskOptionValues.length) {
+                       if (_maskType == BITMASK)
+                               _mask |= _maskOptionValues[index];
+                       else if (_maskType == EXCLUSIVE) {
+                               _mask = _maskOptionValues[index];
+                       }
+               }
+       }
+
+       /**
+        * Returns the value of the mask based on the unitmask index.
+        * @param index the index of the mask option
+        * @return the mask option's value
+        */
+       public int getMaskFromIndex(int index) {
+               //mandatory masks only use the default value
+               if (_maskType == BITMASK) {
+                       if (index >= 0 && index < _maskOptionValues.length) {
+                               return _maskOptionValues[index];
+                       }
+               } else if (_maskType == EXCLUSIVE) {
+                       if (index >= 0 && index < _maskOptionValues.length) {
+                               return _maskOptionValues[index];
+                       }
+               } else if (_maskType == MANDATORY) {
+                       return _defaultMask;
+               }
+
+               //type invalid or unknown, or out of bounds
+               return -1;
+       }
+       
+       /**
+        * Unset the bits of the given mask option's value in the unitmask value.
+        * @param index the index of the mask option to set
+        */
+       public void unSetMaskFromIndex(int index) {
+               if (index >= 0 && index < _maskOptionValues.length && _maskType == BITMASK) {
+                       _mask = _mask & ~_maskOptionValues[index];
+               }
+       }
+
+       /**
+        * Sets the current unitmask value to the default mask value.
+        */
+       public void setDefaultMaskValue() {
+               _mask = _defaultMask;
+       }
+
+       /**
+        * Returns a description of the requested mask option.
+        * @param num the mask option index
+        * @return the description
+        */
+       public String getText(int num) {
+               if (num >= 0 && num < _maskOptionDescriptions.length)
+                       return _maskOptionDescriptions[num];
+
+               return null;
+       }
+       
+       /**
+        * Returns the number of mask options in this unitmask.
+        * @return the number of mask options
+        */
+       public int getNumMasks() {
+               return _maskOptionDescriptions.length;
+       }
+
+       /**
+        * Returns the mask type for this unit mask.
+        * @return <code>BITMASK</code>, <code>EXCLUSIVE</code>, or
+        *         <code>MANDATORY</code>
+        */
+       public int getType() {
+               return _maskType;
+       }
+}
diff --git a/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/daemon/OprofileDaemonEvent.java b/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/daemon/OprofileDaemonEvent.java
new file mode 100644 (file)
index 0000000..34ae43e
--- /dev/null
@@ -0,0 +1,118 @@
+/*******************************************************************************
+ * Copyright (c) 2004,2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Keith Seitz <keiths@redhat.com> - initial API and implementation
+ *    Kent Sebastian <ksebasti@redhat.com>
+ *******************************************************************************/ 
+
+package org.eclipse.linuxtools.oprofile.core.daemon;
+
+import org.eclipse.linuxtools.oprofile.core.Oprofile;
+
+/**
+ * This class represents an event used to configure the OProfile
+ * daemon.
+ */
+public class OprofileDaemonEvent {
+       public static final int COUNT_UNINITIALIZED = 0;
+       public static final int COUNT_INVALID = -1;
+       
+       // The event to collect on this counter
+       private OpEvent _event;
+       
+       // Profile kernel?
+       private boolean _profileKernel;
+       
+       // Profile userspace?
+       private boolean _profileUser;
+       
+       // Reset counter value
+       private int _count;
+
+       public OprofileDaemonEvent() {
+               _profileKernel = true;
+               _profileUser = true;
+               _count = COUNT_UNINITIALIZED;
+               _event = null;
+       }
+
+       /**
+        * Set the event to collect
+        * @param event the OProfile event
+        */
+       public void setEvent(OpEvent event) {
+               _event = event;
+       }
+       
+       /**
+        * Get the event to collect
+        * @returns the OProfile event
+        */
+       public OpEvent getEvent() {
+               return _event;
+       }
+
+       /**
+        * Set whether to profile the kernel
+        * @param profileKernel whether to enable kernel profiling
+        */
+       public void setProfileKernel(boolean profileKernel) {
+               _profileKernel = profileKernel;
+       }
+       
+       /**
+        * Get whether to profile the kernel
+        * @return whether to profile the kernel
+        */
+       public boolean getProfileKernel() {
+               return _profileKernel;
+       }
+
+       /**
+        * Set whether to profile userspace
+        * @param profileUser whether to profile userspace
+        */
+       public void setProfileUser(boolean profileUser) {
+               _profileUser = profileUser;
+       }
+       
+       /**
+        * Get whether to profile userspace
+        * @return whether to profile userspace
+        */
+       public boolean getProfileUser() {
+               return _profileUser;
+       }
+
+       /**
+        * Set the reset count
+        * @param count the new count
+        */
+       public void setResetCount(int count) {
+               _count = count;
+       }
+       
+       /**
+        * Get the reset count
+        * @return the reset count
+        */
+       public int getResetCount() {
+               // FIXME: This isn't quite in the right place...
+               if (_count == COUNT_UNINITIALIZED) {
+                       // This is what Oprofile does in oprof_start.cpp:
+                       double speed = Oprofile.getCpuFrequency();
+                       if (speed == 0.0) {
+                               _count = _event.getMinCount() * 30;
+                       } else {
+                               _count = (int) speed * 20;
+                       }
+               }
+               
+               return _count;
+       }
+}
diff --git a/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/daemon/OprofileDaemonOptions.java b/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/daemon/OprofileDaemonOptions.java
new file mode 100644 (file)
index 0000000..358ea27
--- /dev/null
@@ -0,0 +1,144 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008, 2009 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Keith Seitz <keiths@redhat.com> - initial API and implementation
+ *    Kent Sebastian <ksebasti@redhat.com>
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.oprofile.core.daemon;
+
+
+/**
+ * This class represents the global launch options for the
+ * OProfile daemon.
+ */
+public class OprofileDaemonOptions {
+       // Kernel image file
+       private String _kernelImageFile;
+       
+       // Enable verbose logging?
+       private boolean _verboseLogging;
+       
+       // How to separate profiles (mask)
+       private int _separateProfiles;
+       
+       // the image to profile
+       private String _binaryImage;
+       
+       //how many calls down to profile
+       private int _callgraphDepth;
+       
+       /**
+        * Sample separation options. Determines how oprofiled will group
+        *   samples for binaries which isn't the main binary being profiled.
+        *   
+        * Currently only properly support:
+        *   -none: ignore all other binaries
+        *   -library: include shared library samples
+        *   -kernel: include kernel module samples (which implicitly includes library)
+        *   
+        *   the others probably wouldn't show nicely in the view
+        */
+       public static final int SEPARATE_NONE = 0;
+       public static final int SEPARATE_LIBRARY = 1;
+       public static final int SEPARATE_KERNEL = 2;
+       public static final int SEPARATE_THREAD = 4;
+       public static final int SEPARATE_CPU = 8;
+       
+       public OprofileDaemonOptions() {
+               //defaults
+//             _kernelImageFile = Oprofile.getKernelImageFile();
+               _kernelImageFile = ""; //$NON-NLS-1$
+               _verboseLogging = false;
+               
+               //jinu modified at 20090526
+//             _separateProfiles = SEPARATE_NONE;
+               _separateProfiles = SEPARATE_LIBRARY;   
+               _binaryImage = ""; //$NON-NLS-1$
+               _callgraphDepth = 0;
+       }
+       
+       /**
+        * Get the kernel image file
+        * @return the kernel image file
+        */
+       public String getKernelImageFile() {
+               return _kernelImageFile;
+       }
+       
+       /**
+        * Set the kernel image file
+        * @param image the kernel image
+        */
+       public void setKernelImageFile(String image) {
+               _kernelImageFile = image;
+       }
+
+       /**
+        * Get daemon verbose logging
+        * @return whether verbose logging is enabled
+        */
+       public boolean getVerboseLogging() {
+               return _verboseLogging;
+       }
+       
+       /**
+        * Set daemon verbose logging
+        * @param logging whether to enable verbose logging
+        */
+       public void setVerboseLogging(boolean logging) {
+               _verboseLogging = logging;
+       }
+
+       /**
+        * Get daemon profile separation mask
+        * @return mask of options
+        */
+       public int getSeparateProfilesMask() {
+               return _separateProfiles;
+       }
+       
+       /**
+        * Set daemon profile separation mask
+        * @param mask the new separation mask
+        */
+       public void setSeparateProfilesMask(int mask) {
+               _separateProfiles = mask;
+       }
+
+       /**
+        * Get the path to the binary image being profiled.
+        * @return full path to the binary
+        */
+       public String getBinaryImage() {
+               return _binaryImage;
+       }
+
+       /**
+        * Sets the path of the binary image to profile.
+        * @param _image full path to the binary
+        */
+       public void setBinaryImage(String _image) {
+               this._binaryImage = _image;
+       }
+
+       /**
+        * Get the call depth value.
+        * @return integer amount of calls down to profile
+        */
+       public int getCallgraphDepth() {
+               return _callgraphDepth;
+       }
+
+       /**
+        * Sets the call depth value.
+        * @param depth integer amount of calls down to profile
+        */
+       public void setCallgraphDepth(int depth) {
+               this._callgraphDepth = depth;
+       }
+}
diff --git a/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/linux/LinuxOpcontrolProvider.java b/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/linux/LinuxOpcontrolProvider.java
new file mode 100644 (file)
index 0000000..a59516b
--- /dev/null
@@ -0,0 +1,425 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008, 2009 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Keith Seitz <keiths@redhat.com> - initial API and implementation
+ *    Kent Sebastian <ksebasti@redhat.com>
+ *******************************************************************************/
+package org.eclipse.linuxtools.oprofile.core.linux;
+
+import java.util.ArrayList;
+
+import org.eclipse.linuxtools.oprofile.core.IOpcontrolProvider;
+import org.eclipse.linuxtools.oprofile.core.OpcontrolException;
+import org.eclipse.linuxtools.oprofile.core.Oprofile;
+import org.eclipse.linuxtools.oprofile.core.OprofileCorePlugin;
+import org.eclipse.linuxtools.oprofile.core.daemon.OprofileDaemonEvent;
+import org.eclipse.linuxtools.oprofile.core.daemon.OprofileDaemonOptions;
+
+import org.tizen.common.connection.ConnectionPlugin;
+import org.tizen.oprofile.core.CommandManager;
+import org.tizen.oprofile.core.OprofileComm;
+import org.tizen.oprofile.core.OprofileCommonConstants;
+
+/**
+ * A class which encapsulates running opcontrol.
+ */
+public class LinuxOpcontrolProvider implements IOpcontrolProvider {
+       // Location of opcontrol security wrapper
+       //      private static final String _OPCONTROL_REL_PATH = "natives/linux/scripts/opcontrol"; //$NON-NLS-1$
+       private final String OPCONTROL_PROGRAM;
+
+       // Initialize the Oprofile kernel module and oprofilefs
+       private static final String _OPD_INIT_MODULE = "--init"; //$NON-NLS-1$
+
+       // Setup daemon collection arguments
+       private static final String _OPD_SETUP = "--setup"; //$NON-NLS-1$
+       private static final String _OPD_SETUP_SEPARATE = "--separate="; //$NON-NLS-1$
+       private static final String _OPD_SETUP_SEPARATE_SEPARATOR = ","; //$NON-NLS-1$
+       //      private static final String _OPD_SETUP_SEPARATE_NONE = "none"; //$NON-NLS-1$
+       private static final String _OPD_SETUP_SEPARATE_LIBRARY = "library"; //$NON-NLS-1$
+       private static final String _OPD_SETUP_SEPARATE_KERNEL = "kernel"; //$NON-NLS-1$
+       private static final String _OPD_SETUP_SEPARATE_THREAD = "thread"; //$NON-NLS-1$
+       private static final String _OPD_SETUP_SEPARATE_CPU = "cpu"; //$NON-NLS-1$
+
+       private static final String _OPD_SETUP_EVENT = "--event="; //$NON-NLS-1$
+       private static final String _OPD_SETUP_EVENT_SEPARATOR = ":"; //$NON-NLS-1$
+       private static final String _OPD_SETUP_EVENT_TRUE = "1"; //$NON-NLS-1$
+       private static final String _OPD_SETUP_EVENT_FALSE = "0"; //$NON-NLS-1$
+       private static final String _OPD_SETUP_EVENT_DEFAULT = "default"; //$NON-NLS-1$
+
+       private static final String _OPD_SETUP_IMAGE = "--image="; //$NON-NLS-1$
+
+       private static final String _OPD_CALLGRAPH_DEPTH = "--callgraph="; //$NON-NLS-1$
+
+       // Kernel image file options
+       private static final String _OPD_KERNEL_NONE = "--no-vmlinux"; //$NON-NLS-1$
+       private static final String _OPD_KERNEL_FILE = "--vmlinux="; //$NON-NLS-1$
+
+       // Logging verbosity
+       // private static final String _OPD_VERBOSE_LOGGING = "--verbose=";
+       // //$NON-NSL-1$
+       //      private static final String _OPD_VERBOSE_ALL = "all"; //$NON-NLS-1$
+       //      private static final String _OPD_VERBOSE_SFILE = "sfile"; //$NON-NLS-1$
+       //      private static final String _OPD_VERBOSE_ARCS = "arcs"; //$NON-NLS-1$
+       //      private static final String _OPD_VERBOSE_SAMPLES = "samples"; //$NON-NLS-1$
+       //      private static final String _OPD_VERBOSE_MODULE = "module"; //$NON-NLS-1$
+       //      private static final String _OPD_VERBOSE_MISC = "misc"; //$NON-NLS-1$
+
+       // Start the daemon process without starting data collection
+       private static final String _OPD_START_DAEMON = "--start-daemon"; //$NON-NLS-1$
+
+       // Start collecting profiling data
+       private static final String _OPD_START_COLLECTION = "--start"; //$NON-NLS-1$
+
+       // Flush the collected profiling data to disk
+       private static final String _OPD_DUMP = "--dump"; //$NON-NLS-1$
+
+       // Stop data collection
+       private static final String _OPD_STOP_COLLECTION = "--stop"; //$NON-NLS-1$
+
+       // Stop data collection and stop daemon
+       private static final String _OPD_SHUTDOWN = "--shutdown"; //$NON-NLS-1$
+
+       // Clear out data from current session
+       private static final String _OPD_RESET = "--reset"; //$NON-NLS-1$
+
+       // Save data from the current session
+       private static final String _OPD_SAVE_SESSION = "--save="; //$NON-NLS-1$
+
+       // Unload the oprofile kernel module and oprofilefs
+       private static final String _OPD_DEINIT_MODULE = "--deinit"; //$NON-NLS-1$
+
+       // Logging verbosity. Specified with setupDaemon.
+       // --verbosity=all generates WAY too much stuff in the log
+       private String _verbosity = ""; //$NON-NLS-1$
+
+       public LinuxOpcontrolProvider() throws OpcontrolException {
+               // jinu modified at 20090526
+               // OPCONTROL_PROGRAM = _findOpcontrol();
+               OPCONTROL_PROGRAM = OprofileCommonConstants.COMMAND_OPCONTROL;
+       }
+
+       /**
+        * Unload the kernel module and oprofilefs
+        * 
+        * @throws OpcontrolException
+        */
+       public void deinitModule() throws OpcontrolException {
+               _runOpcontrol(_OPD_DEINIT_MODULE);
+       }
+
+       /**
+        * Dump collected profiling data
+        * 
+        * @throws OpcontrolException
+        */
+       public void dumpSamples() throws OpcontrolException {
+               _runOpcontrol(_OPD_DUMP);
+       }
+
+       /**
+        * Loads the kernel module and oprofilefs
+        * 
+        * @throws OpcontrolException
+        */
+       public void initModule() throws OpcontrolException {
+               _runOpcontrol(_OPD_INIT_MODULE);
+       }
+
+       /**
+        * Clears out data from current session
+        * 
+        * @throws OpcontrolException
+        */
+       public void reset() throws OpcontrolException {
+               _runOpcontrol(_OPD_RESET);
+       }
+
+       /**
+        * Saves the current ("default") session
+        * 
+        * @param name
+        *            the name to which to save the session
+        * @throws OpcontrolException
+        */
+       public void saveSession(String name) throws OpcontrolException {
+               ArrayList<String> cmd = new ArrayList<String>();
+               cmd.add(_OPD_SAVE_SESSION + name);
+               _runOpcontrol(cmd);
+       }
+
+       /**
+        * Give setup aruments
+        * 
+        * @param args
+        *            list of parameters for daemon
+        * @throws OpcontrolException
+        */
+       public void setupDaemon(OprofileDaemonOptions options,
+                       OprofileDaemonEvent[] events) throws OpcontrolException {
+               // Convert options & events to arguments for opcontrol
+               ArrayList<String> args = new ArrayList<String>();
+               args.add(_OPD_SETUP);
+               _optionsToArguments(args, options);
+               if (!Oprofile.getTimerMode()) {
+                       if (events == null || events.length == 0) {
+                               args.add(_OPD_SETUP_EVENT + _OPD_SETUP_EVENT_DEFAULT);
+                       } else {
+                               for (int i = 0; i < events.length; ++i) {
+                                       _eventToArguments(args, events[i]);
+                               }
+                       }
+               }
+               _runOpcontrol(args);
+       }
+
+       // jinu added at 20090602
+       public void setupDaemon(OprofileDaemonOptions options,
+                       OprofileDaemonEvent[] events, String defaultEvent)
+                       throws OpcontrolException {
+               // Convert options & events to arguments for opcontrol
+               ArrayList<String> args = new ArrayList<String>();
+               args.add(_OPD_SETUP);
+               _optionsToArguments(args, options);
+               if (!Oprofile.getTimerMode()) {
+                       if (events == null || events.length == 0) {
+                               // jinu modified at 20090602
+                               // args.add(_OPD_SETUP_EVENT + _OPD_SETUP_EVENT_DEFAULT);
+                               if(null != defaultEvent)
+                                       args.add(defaultEvent);
+                       } else {
+                               for (int i = 0; i < events.length; ++i) {
+                                       _eventToArguments(args, events[i]);
+                               }
+                       }
+               }
+               _runOpcontrol(args);
+       }
+
+       /**
+        * Stop data collection and remove daemon
+        * 
+        * @throws OpcontrolException
+        */
+       public void shutdownDaemon() throws OpcontrolException {
+               _runOpcontrol(_OPD_SHUTDOWN);
+       }
+
+       /**
+        * Start data collection (will start daemon if necessary)
+        * 
+        * @throws OpcontrolException
+        */
+       public void startCollection() throws OpcontrolException {
+               _runOpcontrol(_OPD_START_COLLECTION);
+       }
+
+       /**
+        * Start daemon without starting profiling
+        * 
+        * @throws OpcontrolException
+        */
+       public void startDaemon() throws OpcontrolException {
+               _runOpcontrol(_OPD_START_DAEMON);
+       }
+
+       /**
+        * Stop data collection
+        * 
+        * @throws OpcontrolException
+        */
+       public void stopCollection() throws OpcontrolException {
+               _runOpcontrol(_OPD_STOP_COLLECTION);
+       }
+
+       // Convenience function
+       private void _runOpcontrol(String cmd) throws OpcontrolException {
+               ArrayList<String> list = new ArrayList<String>();
+               list.add(cmd);
+               _runOpcontrol(list);
+       }
+
+       // Will add opcontrol program to beginning of args
+       // args: list of opcontrol arguments (not including opcontrol program
+       // itself)
+       private void _runOpcontrol(ArrayList<String> args)
+                       throws OpcontrolException {
+               args.add(0, OPCONTROL_PROGRAM);
+               // Verbosity hack. If --start or --start-daemon, add verbosity, if set
+               String cmd = (String) args.get(1);
+               if (_verbosity.length() > 0
+                               && (cmd.equals(_OPD_START_COLLECTION) || cmd
+                                               .equals(_OPD_START_DAEMON))) {
+                       args.add(_verbosity);
+               }
+
+               String[] cmdArray = new String[args.size()];
+               args.toArray(cmdArray);
+
+               // jinu modified at 20090526
+               runCommand(cmdArray);
+               /*
+                * Process p = null; try { p = Runtime.getRuntime().exec(cmdArray); }
+                * catch (IOException ioe) { if (p != null) { p.destroy(); p = null; }
+                * 
+                * throw new
+                * OpcontrolException(OprofileCorePlugin.createErrorStatus("opcontrolRun"
+                * , ioe)); //$NON-NLS-1$ }
+                * 
+                * if (p != null) { BufferedReader stdout = new BufferedReader(new
+                * InputStreamReader(p.getErrorStream())); String output = "", s;
+                * //$NON-NLS-1$ try { while ((s = stdout.readLine()) != null) { output
+                * += s; }
+                * 
+                * int ret = p.waitFor(); if (ret != 0) { System.out.println(output);
+                * throw new OpcontrolException(OprofileCorePlugin.createErrorStatus(
+                * "opcontrolNonZeroExitCode", null)); //$NON-NLS-1$ } } catch
+                * (IOException ioe) { ioe.printStackTrace(); } catch
+                * (InterruptedException e) { e.printStackTrace(); } }
+                */
+       }
+
+       // private static String _findOpcontrol() throws OpcontrolException {
+       // URL url =
+       // FileLocator.find(Platform.getBundle(OprofileCorePlugin.getId()), new
+       // Path(_OPCONTROL_REL_PATH), null);
+       //
+       // if (url != null) {
+       // try {
+       // return FileLocator.toFileURL(url).getPath();
+       // } catch (IOException ignore) { }
+       // } else {
+       //                      throw new OpcontrolException(OprofileCorePlugin.createErrorStatus("opcontrolProvider", null)); //$NON-NLS-1$
+       // }
+       //
+       // return null;
+       // }
+
+       // Convert the event into arguments for opcontrol
+       private void _eventToArguments(ArrayList<String> args,
+                       OprofileDaemonEvent event) {
+               // Event spec: "EVENT:count:mask:profileKernel:profileUser"
+               String spec = new String(_OPD_SETUP_EVENT);
+               spec += event.getEvent().getText();
+               spec += _OPD_SETUP_EVENT_SEPARATOR;
+               spec += event.getResetCount();
+               spec += _OPD_SETUP_EVENT_SEPARATOR;
+               spec += event.getEvent().getUnitMask().getMaskValue();
+               spec += _OPD_SETUP_EVENT_SEPARATOR;
+               spec += (event.getProfileKernel() ? _OPD_SETUP_EVENT_TRUE
+                               : _OPD_SETUP_EVENT_FALSE);
+               spec += _OPD_SETUP_EVENT_SEPARATOR;
+               spec += (event.getProfileUser() ? _OPD_SETUP_EVENT_TRUE
+                               : _OPD_SETUP_EVENT_FALSE);
+               args.add(spec);
+       }
+
+       // Convert the options into arguments for opcontrol
+       private void _optionsToArguments(ArrayList<String> args,
+                       OprofileDaemonOptions options) {
+               // Add separate flags
+               int mask = options.getSeparateProfilesMask();
+
+               String separate = new String(_OPD_SETUP_SEPARATE);
+
+               if (mask == OprofileDaemonOptions.SEPARATE_NONE) {
+                       separate += _OPD_SETUP_SEPARATE_LIBRARY
+                                       + _OPD_SETUP_SEPARATE_SEPARATOR
+                                       + _OPD_SETUP_SEPARATE_KERNEL;
+                       // separate += _OPD_SETUP_SEPARATE_NONE;
+               } else {
+                       // note that opcontrol will nicely ignore the trailing comma
+                       if ((mask & OprofileDaemonOptions.SEPARATE_LIBRARY) != 0)
+                               separate += _OPD_SETUP_SEPARATE_LIBRARY
+                                               + _OPD_SETUP_SEPARATE_SEPARATOR;
+                       if ((mask & OprofileDaemonOptions.SEPARATE_KERNEL) != 0)
+                               separate += _OPD_SETUP_SEPARATE_KERNEL
+                                               + _OPD_SETUP_SEPARATE_SEPARATOR;
+                       if ((mask & OprofileDaemonOptions.SEPARATE_THREAD) != 0)
+                               separate += _OPD_SETUP_SEPARATE_THREAD
+                                               + _OPD_SETUP_SEPARATE_SEPARATOR;
+                       if ((mask & OprofileDaemonOptions.SEPARATE_CPU) != 0)
+                               separate += _OPD_SETUP_SEPARATE_CPU
+                                               + _OPD_SETUP_SEPARATE_SEPARATOR;
+               }
+               args.add(separate);
+
+               // Add kernel image
+               if (options.getKernelImageFile() == null
+                               || options.getKernelImageFile().length() == 0) {
+                       args.add(_OPD_KERNEL_NONE);
+               } else {
+                       args.add(_OPD_KERNEL_FILE + options.getKernelImageFile());
+               }
+
+               // image filter -- always non-null
+               args.add(_OPD_SETUP_IMAGE + options.getBinaryImage());
+
+               // callgraph depth
+               args.add(_OPD_CALLGRAPH_DEPTH + options.getCallgraphDepth());
+       }
+
+       // jinu added at 20090528
+       public void removeDaemonSetting() throws OpcontrolException {
+               final String[] _OPD_REMOVE_SETTING = { "rm", "-rf",
+                               "/root/.oprofile/daemonrc" };
+               runCommand(_OPD_REMOVE_SETTING);
+       }
+
+       // jinu added at 20090528
+       private void runCommand(String[] comm) throws OpcontrolException {
+
+               String str = OprofileComm.getCommandString(comm);
+//             String result=null;
+//             try {
+//                     result = session.run(str);
+//                     session.run(str, null);
+                       if(str.contains(_OPD_START_COLLECTION)){
+                               str = str + " && echo start_ok";
+                       }
+                       CommandManager.runShell(str);
+/*                     
+               } catch (Exception e) {
+                       String devType = null;
+                       if(null == ConnectionPlugin.getDefault().getCurrentDevice()){
+                               devType = "";
+                       }
+                       else if (CommandManager.isEmulator()) {
+                               devType = "Emulator";
+                       } else {
+                               devType = "RealDevice";
+                       }
+                       throw new OpcontrolException(OprofileCorePlugin.createErrorStatus(
+                                       "opcontrolRun (" + devType + ")", e)); //$NON-NLS-1$
+               }
+*/
+               // -----------------------------------
+
+               // jinu removed at 20090616
+               /*
+                * Process p = null; try { p = Runtime.getRuntime().exec(comm); } catch
+                * (IOException ioe) { if (p != null) { p.destroy(); p = null; }
+                * 
+                * throw new
+                * OpcontrolException(OprofileCorePlugin.createErrorStatus("opcontrolRun"
+                * , ioe)); //$NON-NLS-1$ }
+                * 
+                * if (p != null) { BufferedReader stdout = new BufferedReader(new
+                * InputStreamReader(p.getErrorStream())); String output = "", s;
+                * //$NON-NLS-1$ try { while ((s = stdout.readLine()) != null) { output
+                * += s; }
+                * 
+                * int ret = p.waitFor(); if (ret != 0) { System.out.println(output);
+                * throw new OpcontrolException(OprofileCorePlugin.createErrorStatus(
+                * "opcontrolNonZeroExitCode", null)); //$NON-NLS-1$ } } catch
+                * (IOException ioe) { ioe.printStackTrace(); } catch
+                * (InterruptedException e) { e.printStackTrace(); } }
+                */
+       }
+
+}
diff --git a/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/linux/LinuxOpxmlProvider.java b/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/linux/LinuxOpxmlProvider.java
new file mode 100644 (file)
index 0000000..2478c80
--- /dev/null
@@ -0,0 +1,118 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008, 2009 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Keith Seitz <keiths@redhat.com> - initial API and implementation
+ *    Kent Sebastian <ksebasti@redhat.com> 
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.oprofile.core.linux;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.linuxtools.oprofile.core.IOpxmlProvider;
+import org.eclipse.linuxtools.oprofile.core.OprofileCorePlugin;
+import org.eclipse.linuxtools.oprofile.core.OpxmlException;
+import org.eclipse.linuxtools.oprofile.core.daemon.OpInfo;
+import org.eclipse.linuxtools.oprofile.core.model.OpModelEvent;
+import org.eclipse.linuxtools.oprofile.core.model.OpModelImage;
+import org.eclipse.linuxtools.oprofile.core.opxml.OpxmlConstants;
+import org.eclipse.linuxtools.oprofile.core.opxml.modeldata.ModelDataProcessor;
+import org.eclipse.linuxtools.oprofile.core.opxml.sessions.SessionsProcessor;
+
+import org.tizen.oprofile.core.OprofileCommonConstants;
+
+/**
+ * A class which implements the IOpxmlProvider interface for running opxml.
+ */
+public class LinuxOpxmlProvider implements IOpxmlProvider {
+       private String _pathToOpxml;
+       
+       public LinuxOpxmlProvider() throws OpxmlException {
+               _pathToOpxml = _getOpxmlPath();
+               
+               if (_pathToOpxml == null) {
+                       throw new OpxmlException(OprofileCorePlugin.createErrorStatus("opxmlProvider", null)); //$NON-NLS-1$
+               }
+       }
+       
+       //jinu modified at 20090526
+       //public abstract String _getOpxmlPath();
+       public String _getOpxmlPath(){
+               String opxmlPath = OprofileCommonConstants.COMMAND_OPXML;
+               return opxmlPath;
+       }
+       
+       public IRunnableWithProgress info(final OpInfo info) {
+               IRunnableWithProgress runnable = new IRunnableWithProgress() {
+                       public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+                               OpxmlRunner runner = new OpxmlRunner(_pathToOpxml);
+                               String[] args = new String[] {
+                                       OpxmlConstants.OPXML_INFO
+                               };
+                               runner.run(args, info);
+                       }
+               };
+               
+               return runnable;
+       }
+       
+       public IRunnableWithProgress modelData(final String eventName, final String sessionName, final OpModelImage image) {
+               IRunnableWithProgress runnable = new IRunnableWithProgress() {  
+                       public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+                               OpxmlRunner runner = new OpxmlRunner(_pathToOpxml);
+
+                               String[] args = new String[] {
+                                               OpxmlConstants.OPXML_MODELDATA,
+                                               eventName,
+                                               sessionName
+                               };
+                               
+                               ModelDataProcessor.CallData data = new ModelDataProcessor.CallData(image);
+                               runner.run(args, data);
+                       }
+               };
+               
+               return runnable;
+       }
+               
+       public IRunnableWithProgress checkEvents(final int ctr, final int event, final int um, final int[] eventValid) {
+               IRunnableWithProgress runnable = new IRunnableWithProgress() {
+                       public void run(IProgressMonitor monitor) {
+                               OpxmlRunner runner = new OpxmlRunner(_pathToOpxml);
+                               String[] args = new String[] {
+                                       OpxmlConstants.CHECKEVENTS_TAG,
+                                       Integer.toString(ctr),
+                                       Integer.toString(event),
+                                       Integer.toString(um)
+                               };
+                               
+                               runner.run(args, eventValid);
+                       }
+               };
+               return runnable;
+       }
+       
+       public IRunnableWithProgress sessions(final ArrayList<OpModelEvent> sessionList) {
+               
+               IRunnableWithProgress runnable = new IRunnableWithProgress() {
+                       public void run(IProgressMonitor monitor) {
+                               OpxmlRunner runner = new OpxmlRunner(_pathToOpxml);
+                               String[] args = new String[] {
+                                       OpxmlConstants.OPXML_SESSIONS,
+                               };
+               
+                               SessionsProcessor.SessionInfo sinfo  = new SessionsProcessor.SessionInfo(sessionList);
+                               runner.run(args, sinfo);
+                       }
+               };
+
+               return runnable;
+       }
+}
diff --git a/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/linux/OpxmlRunner.java b/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/linux/OpxmlRunner.java
new file mode 100644 (file)
index 0000000..1331f08
--- /dev/null
@@ -0,0 +1,129 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008, 2009 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Keith Seitz <keiths@redhat.com> - initial API and implementation
+ *    Kent Sebastian <ksebasti@redhat.com> - 
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.oprofile.core.linux;
+
+import java.io.IOException;
+import java.io.StringReader;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.eclipse.linuxtools.oprofile.core.OprofileCorePlugin;
+import org.eclipse.linuxtools.oprofile.core.OpxmlException;
+import org.eclipse.linuxtools.oprofile.core.opxml.OprofileSAXHandler;
+import org.eclipse.linuxtools.oprofile.core.opxml.XMLProcessor;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+
+import org.tizen.oprofile.core.CommandManager;
+import org.tizen.oprofile.core.OprofileComm;
+import org.eclipse.linuxtools.profiling.launch.ProfileLaunchPlugin;
+
+/**
+ * This class will run opxml.
+ * 
+ * opxml is a small program which acts as a textual interface between Oprofile and
+ * BFD and the oprofile plugins. 
+ */
+public class OpxmlRunner {
+       private OprofileSAXHandler _handler;
+       private String _pathToOpxml;
+
+       public OpxmlRunner(String pathToOpxml) {
+               //assume that the path given is valid
+               _pathToOpxml = pathToOpxml;
+       }
+       
+       /**
+        * Returns the current XMLProcessor handling parsing of opxml output.
+        * @return the processor
+        */
+       public XMLProcessor getProcessor() {
+               return _handler.getProcessor();
+       }
+       
+       /**
+        * Runs opxml with the given arguments.
+        * @param args the arguments to pass to opxml
+        * @param callData any callData to pass to the processor
+        * @return boolean indicating the success/failure of opxml
+        * @throws OpxmlException 
+        */
+       public boolean run(String[] args, Object callData) {
+               XMLReader reader = null;
+               _handler = OprofileSAXHandler.getInstance(callData);
+               
+               // Create XMLReader
+        SAXParserFactory factory = SAXParserFactory.newInstance();
+        try {
+                       reader = factory.newSAXParser().getXMLReader();
+               } catch (ParserConfigurationException e) {
+                       e.printStackTrace();
+                       return false;
+               } catch (SAXException e) {
+                       e.printStackTrace();
+                       return false;
+               }
+               
+               // Set content/error handlers
+               reader.setContentHandler(_handler);
+               reader.setErrorHandler(_handler);
+               
+               // Setup args
+               String[] cmdArray = new String[args.length + 1];
+               cmdArray[0] = _pathToOpxml;
+               System.arraycopy(args, 0, cmdArray, 1, args.length);
+               
+               
+               // Run opxml
+               try {
+                       //jinu added at 20090604 --------------------------
+                       if(ProfileLaunchPlugin.checkTarget() == 0) return false;
+                       //ISession session =OprofileComm.getSession();
+                       
+                       String command = OprofileComm.getCommandString(cmdArray)+" | sed 's/^[^<]*//' | sed 's/&//'";
+                       //String str = session.run(command, null);
+                       String str = CommandManager.runCommandReturningResult(command);
+                       
+                       reader.parse(new InputSource(new StringReader(str)));   
+                       
+                       //jinu removed at 20090616
+                       /*
+                       // before procedure
+                       Process p = Runtime.getRuntime().exec(cmdArray);
+                               
+                       BufferedReader bi = new BufferedReader(new InputStreamReader(p.getInputStream()));
+                       reader.parse(new InputSource(bi));      
+                       
+                       if (p.waitFor() != 0) {
+                               //System.out.println("error running opxml");
+                               return false;
+                       }
+                       */
+                       
+                       return true;
+               } catch (SAXException e) {
+                       e.printStackTrace();
+               } catch (IOException e) {
+//                     System.out.println("IOException: " + e.getMessage());
+                       e.printStackTrace();
+                       OprofileCorePlugin.showErrorDialog("opxmlIOException", null); //$NON-NLS-1$
+               //jinu added at 20090604
+               } catch (Exception e) {
+                       e.printStackTrace();
+                       OprofileCorePlugin.showErrorDialog("opxmlIOException", null); //$NON-NLS-1$
+               }
+               
+               return false;
+       }
+}
diff --git a/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/model/OpModelEvent.java b/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/model/OpModelEvent.java
new file mode 100644 (file)
index 0000000..bd4fab7
--- /dev/null
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008, 2009 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Keith Seitz <keiths@redhat.com> - initial API and implementation
+ *    Kent Sebastian <ksebasti@redhat.com> - 
+ *******************************************************************************/ 
+
+package org.eclipse.linuxtools.oprofile.core.model;
+
+/**
+ * A class which represents the event collected in a given session.
+ */
+public class OpModelEvent {
+       private String _eventName;
+       private OpModelSession[] _sessions;
+       private String _printTabs = "";         //for nice output  //$NON-NLS-1$
+       
+       public OpModelEvent(String name) {
+               _eventName = name;
+       }
+
+       public OpModelSession[] getSessions() {
+               return _sessions;
+       }
+
+       public void _setSessions(OpModelSession[] sessions) {
+               _sessions = sessions;
+       }
+
+       public String getName() {
+               return _eventName;
+       }
+
+       //populate all sessions
+       public void refreshModel() {
+               if (_sessions != null) {
+                       for (int i = 0; i < _sessions.length; i++) {
+                               _sessions[i].refreshModel();
+                       }
+               }
+       }
+       
+       public String toString(String tabs) {
+               _printTabs = tabs;
+               String s = toString();
+               _printTabs = ""; //$NON-NLS-1$
+               return s;
+       }
+
+       @Override
+       public String toString() {
+               String s = _eventName + "\n"; //$NON-NLS-1$
+               if (_sessions != null) {
+                       for (int i = 0; i < _sessions.length; i++) {
+                               s += _printTabs + "Session: "; //$NON-NLS-1$
+                               s += _sessions[i].toString(_printTabs + "\t"); //$NON-NLS-1$
+                       }
+               }
+               return s;
+       }
+}
diff --git a/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/model/OpModelImage.java b/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/model/OpModelImage.java
new file mode 100644 (file)
index 0000000..42ee8e0
--- /dev/null
@@ -0,0 +1,181 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008, 2009 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Keith Seitz <keiths@redhat.com> - initial API and implementation
+ *    Kent Sebastian <ksebasti@redhat.com> - 
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.oprofile.core.model;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+
+
+/**
+ * A class which represents an image (executables,
+ * libraries, modules) profile by OProfile.
+ */
+public class OpModelImage {
+       public static final int IMAGE_PARSE_ERROR = -1;
+       
+       //The count of all samples from this image
+       private int _count;
+       
+       //the count for all dependent images -- needed?
+       private int _depcount;
+       
+       //The name of this image (the full path, where applicable)
+       private String _name;
+       
+       //The symbols profiled in this image
+       private OpModelSymbol[] _symbols;
+       
+       //Any dependent images on this image (usually shared libs, kernel modules)
+       private OpModelImage[] _dependents;
+       
+       private String _printTabs = "";         //for nice output //$NON-NLS-1$
+       
+       public OpModelImage() {
+               _name = ""; //$NON-NLS-1$
+               _count = 0;
+               _depcount = 0;
+               _symbols = null;
+               _dependents = null;
+       }
+       
+       public int getCount() {
+               return _count;
+       }
+       
+       public int getDepCount() {
+               return _depcount;
+       }
+
+       public String getName() {
+               return _name;
+       }
+
+       //jinu added at 20090622--------------------
+       private ArrayList<OpModelSymbol> _symbolList = new ArrayList<OpModelSymbol>();
+       private ArrayList<OpModelImage> _dependentList = new ArrayList<OpModelImage>();
+       public void _addSymbol(OpModelSymbol symbol){
+               _symbolList.add(symbol);
+       }
+       public void _addDependent(OpModelImage image){
+               _dependentList.add(image);
+       }
+       
+       private static class SortSymbolComparator implements Comparator<OpModelSymbol> {
+               public int compare(OpModelSymbol o1, OpModelSymbol o2) {
+                       int cnt1 = o1.getCount();
+                       int cnt2 = o2.getCount();
+                       
+                       return cnt1<cnt2?1:(cnt1==cnt2?0:-1);
+               }
+       }
+       
+       private static class SortImageComparator implements Comparator<OpModelImage> {
+               public int compare(OpModelImage o1, OpModelImage o2) {
+                       int cnt1 = o1.getCount();
+                       int cnt2 = o2.getCount();
+                       
+                       return cnt1<cnt2?1:(cnt1==cnt2?0:-1);
+               }
+       }
+       //-------------------------------
+       
+       public OpModelSymbol[] getSymbols() {
+               //jinu modified at 20090622
+               //return _symbols;
+               Collections.sort(_symbolList,new SortSymbolComparator());
+               return _symbolList.toArray(new OpModelSymbol[_symbolList.size()]);
+       }
+
+       public OpModelImage[] getDependents() {
+               //jinu modified at 20090622
+               //return _dependents;
+               Collections.sort(_dependentList,new SortImageComparator());
+               return  _dependentList.toArray(new OpModelImage[_dependentList.size()]);
+       }
+
+       public boolean hasDependents() {
+               //jinu modified at 20090622
+               //return (_dependents == null || _dependents.length == 0 ? false : true);
+               return _dependentList.size() == 0 ? false : true;
+       }
+       
+       /**
+        * This method is not meant to be called publicly, used only 
+        * from the XML processors      
+        * @param _count
+        */
+       public void _setCount(int _count) {
+               this._count = _count;
+       }
+       
+       /**
+        * This method is not meant to be called publicly, used only 
+        * from the XML processors      
+        * @param _depcount
+        */
+       public void _setDepCount(int _depcount) {
+               this._depcount = _depcount;
+       }
+
+       /**
+        * This method is not meant to be called publicly, used only 
+        * from the XML processors      
+        * @param _name
+        */
+       public void _setName(String _name) {
+               this._name = _name;
+       }
+
+       /**
+        * This method is not meant to be called publicly, used only 
+        * from the XML processors      
+        * @param _symbols
+        */
+       public void _setSymbols(OpModelSymbol[] _symbols) {
+               this._symbols = _symbols;
+       }
+
+       /**
+        * This method is not meant to be called publicly, used only 
+        * from the XML processors      
+        * @param _dependents
+        */
+       public void _setDependents(OpModelImage[] _dependents) {
+               this._dependents = _dependents;
+       }
+
+       public String toString(String tabs) {
+               _printTabs = tabs;
+               String s = toString();
+               _printTabs = ""; //$NON-NLS-1$
+               return s;
+       }
+
+       @Override
+       public String toString() {
+               String s = _name + ", Count: " + _count + (_depcount !=0 ? ", Dependent Count: " + _depcount + "\n" : "\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+               if (_symbols != null) {
+                       for (int i = 0; i < _symbols.length; i++) {
+                               s += _printTabs + "Symbols: "; //$NON-NLS-1$
+                               s += _symbols[i].toString(_printTabs + "\t"); //$NON-NLS-1$
+                       }
+               }
+               if (_dependents != null) {
+                       for (int i = 0; i < _dependents.length; i++) {
+                               s += _printTabs + "Dependent Image: "; //$NON-NLS-1$
+                               s += _dependents[i].toString(_printTabs + "\t"); //$NON-NLS-1$
+                       }                       
+               }
+               return s;
+       }
+}
diff --git a/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/model/OpModelRoot.java b/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/model/OpModelRoot.java
new file mode 100644 (file)
index 0000000..38a0bc1
--- /dev/null
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Kent Sebastian <ksebasti@redhat.com> - initial API and implementation 
+ *******************************************************************************/ 
+
+package org.eclipse.linuxtools.oprofile.core.model;
+
+import org.tizen.oprofile.core.OprofileComm;
+
+/**
+ * A root node for the data model. Only one instance exists at any time,
+ * although the contents will change. On instantiation the events and
+ * sessions are gathered. 
+ * 
+ * Note that this data model does not map 1:1 to the oprofile data model.
+ * This model is for use in profiling one application compiled with debug
+ * info, from within eclipse. 
+ */
+
+public class OpModelRoot {
+       //jinu removed at 20090704
+       //single instance
+       //private static OpModelRoot _modelRoot = new OpModelRoot();
+
+       private OpModelEvent[] _events;
+//     private String _printTabs = "\t";               //for nice output
+
+       //jinu removed at 20090704
+       /*
+       protected OpModelRoot() {
+//             refreshModel();
+               _events = null;
+//             _modelRoot = this;
+       }
+       */
+       public OpModelRoot() {
+               _events = null;
+       }
+
+       //jinu removed at 20090618
+       /*
+       public static OpModelRoot getDefault() {
+               return _modelRoot;
+       }
+       */
+       
+       //jinu added at 20090628 --------------------------
+       public void reset() {
+               _events = new OpModelEvent[0];
+       }
+
+       //jinu modified at 20090620
+       /*public void refreshModel() {
+               //TODO-performance/interactivity: some persistence for events/sessions
+               // that dont change from run to run (non default sessions) 
+               
+               _events = getNewEvents();
+               if (_events != null) {
+                       for (int i = 0; i < _events.length; i++) {
+                               if (_events[i] != null)
+                                       _events[i].refreshModel();
+                       }
+               }
+       }*/
+       
+       protected OpModelEvent[] getNewEvents() {
+               //launch `opxml sessions`, gather up events & the sessions under them
+               //jinu modified at 20090618
+               //return Oprofile.getEvents(); 
+               return OprofileComm.getEventList();
+       }
+       
+       public OpModelEvent[] getEvents() {
+               return _events;
+       }
+       
+
+       
+       @Override
+       public String toString() {
+               String s = ""; //$NON-NLS-1$
+               if (_events != null) {
+                       for (int i = 0; i < _events.length; i++) {
+                               if (_events[i] != null) {
+                                       s += "Event: "; //$NON-NLS-1$
+                                       s += _events[i].toString("\t"); //$NON-NLS-1$
+                               }
+                       }
+               }
+               return s;
+       }
+       
+       //jinu added at 20090620
+       public void _setEvents(OpModelEvent[] _events) {
+               this._events = _events;
+       }
+       
+       //jinu added at 20090704----------------------
+       private String xmlStr;
+       public void setXML(String xmlStr) {
+               this.xmlStr = xmlStr;
+       }
+
+       public String getXML() {
+               return xmlStr;
+       }
+       //--------------------------------
+
+       
+}
diff --git a/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/model/OpModelSample.java b/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/model/OpModelSample.java
new file mode 100644 (file)
index 0000000..a705c09
--- /dev/null
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2004,2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Keith Seitz <keiths@redhat.com> - initial API and implementation
+ *    Kent Sebastian <ksebasti@redhat.com> - 
+ *******************************************************************************/ 
+
+package org.eclipse.linuxtools.oprofile.core.model;
+
+/**
+ * Represents an OProfile sample.
+ */
+public class OpModelSample {
+       private int _count;
+       private int _line;
+
+       public OpModelSample() {
+               _count = 0;
+               _line = 0;
+       }
+       
+       public void _setCount(int _count) {
+               this._count = _count;
+       }
+
+       public void _setLine(int _line) {
+               this._line = _line;
+       }
+
+       public int getCount() {
+               return _count;
+       }
+
+       public int getLine() {
+               return _line;
+       }
+
+       @Override
+       public String toString() {
+               String s = "Line #: " + _line + ", Count: " + _count + "\n"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+               return s;
+       }
+}
diff --git a/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/model/OpModelSession.java b/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/model/OpModelSession.java
new file mode 100644 (file)
index 0000000..1d2e66a
--- /dev/null
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Kent Sebastian <ksebasti@redhat.com> - initial API and implementation 
+ *******************************************************************************/ 
+
+package org.eclipse.linuxtools.oprofile.core.model;
+
+import org.eclipse.linuxtools.oprofile.core.Oprofile;
+
+
+/**
+ * This class represents oprofile sessions. Sessions contain an image
+ * of the profiled binary.
+ */
+public class OpModelSession {
+       private static final String DEFAULT_SESSION_STRING = "current"; //$NON-NLS-1$
+
+       private OpModelEvent _parentEvent;
+       private OpModelImage _image;
+       private String _name;
+       private String _printTabs = "";         //for nice output //$NON-NLS-1$
+
+       public OpModelSession(OpModelEvent event, String name) {
+               _parentEvent = event;
+               _name = name;
+               _image = null;
+       }
+       
+       public OpModelImage getImage() {
+               return _image;
+       }
+
+       public OpModelEvent getEvent() {
+               return _parentEvent;
+       }
+       
+       public String getName() {
+               return _name;
+       }
+       
+       public int getCount() {
+               if (_image == null) {
+                       return 0;
+               } else {
+                       return _image.getCount();
+               }
+       }
+       
+       public boolean isDefaultSession() {
+               return _name.equals(DEFAULT_SESSION_STRING); 
+       }
+       
+       public void refreshModel() {
+               //populate this session with samples
+               _image = getNewImage();
+       }
+       
+       protected OpModelImage getNewImage() {
+               return Oprofile.getModelData(_parentEvent.getName(), _name);
+       }
+
+       public String toString(String tabs) {
+               _printTabs = tabs;
+               String s = toString();
+               _printTabs = ""; //$NON-NLS-1$
+               return s;
+       }
+
+       @Override
+       public String toString() {
+               String s = _name + "\n"; //$NON-NLS-1$
+               if (_image != null) {
+                       s += _printTabs + "Image: "; //$NON-NLS-1$
+                       s += _image.toString(_printTabs + "\t"); //$NON-NLS-1$
+               }
+               return s;
+               
+       }
+       
+       public void _setImage(OpModelImage image){
+               this._image = image;
+       }
+}
diff --git a/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/model/OpModelSymbol.java b/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/model/OpModelSymbol.java
new file mode 100644 (file)
index 0000000..db3c32d
--- /dev/null
@@ -0,0 +1,108 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Kent Sebastian <ksebasti@redhat.com> - initial API and implementation 
+ *******************************************************************************/ 
+
+package org.eclipse.linuxtools.oprofile.core.model;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+
+
+/**
+ * This class represents a debugging symbol, the symbol output
+ *  from opxml. If a symbol exists, it must have samples (which are
+ *  OpModelSamples), although those samples may or may not have 
+ *  complete debug info.
+ */
+public class OpModelSymbol {
+       private String _name;
+       private String _file;
+       private int _count;
+       private OpModelSample[] _samples;
+       private String _printTabs = "";         //for nice output //$NON-NLS-1$
+       
+       public OpModelSymbol() {
+               _name = ""; //$NON-NLS-1$
+               _file = ""; //$NON-NLS-1$
+               _count = 0;
+               _samples = null;
+       }
+       
+       public void _setName(String _name) {
+               this._name = _name;
+       }
+
+       public void _setFile(String _file) {
+               this._file = _file;
+       }
+
+       public void _setCount(int _count) {
+               this._count = _count;
+       }
+
+       public void _setSamples(OpModelSample[] _samples) {
+               this._samples = _samples;
+       }
+
+       public String getName() {
+               return _name;
+       }
+
+       public String getFile() {
+               return _file;
+       }
+
+       public int getCount() {
+               return _count;
+       }
+       
+       //jinu added at 20090623------------------
+       private ArrayList<OpModelSample> _sampleList = new ArrayList<OpModelSample>();
+       public void _addSample(OpModelSample sample){
+               _sampleList.add(sample);
+       }
+       
+       private static class SortSampleComparator implements Comparator<OpModelSample> {
+               public int compare(OpModelSample o1, OpModelSample o2) {
+                       int cnt1 = o1.getCount();
+                       int cnt2 = o2.getCount();
+                       
+                       return cnt1<cnt2?1:(cnt1==cnt2?0:-1);
+               }
+       }
+       //-----------------------------
+
+       public OpModelSample[] getSamples() {
+               //jinu modified at 20090623
+               //return _samples;
+               Collections.sort(_sampleList,new SortSampleComparator());
+               return _sampleList.toArray(new OpModelSample[_sampleList.size()]);
+       }
+
+       public String toString(String tabs) {
+               _printTabs = tabs;
+               String s = toString();
+               _printTabs = ""; //$NON-NLS-1$
+               return s;
+       }
+
+       @Override
+       public String toString() {
+               String s = _name + ", File: " + _file + ", Count: " + _count + "\n"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+               if (_samples != null) {
+                       for (int i = 0; i < _samples.length; i++) {
+                               s += _printTabs + "Sample: "; //$NON-NLS-1$
+                               s += _samples[i].toString();
+                       }
+               }
+               return s;
+       }
+}
diff --git a/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/oprofile.properties b/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/oprofile.properties
new file mode 100644 (file)
index 0000000..4c6e221
--- /dev/null
@@ -0,0 +1,44 @@
+######################################################################
+# Copyright (c) 2004, 2008, 2009 Red Hat, Inc.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#    Keith Seitz <keiths@redhat.com> - Initial implementation
+#    Kent Sebastian <ksebasti@redhat.com>
+######################################################################
+unknown-kernel=unknown
+getSamples.caption=Reading samples for session \"{0}\"...
+getSamples.caption.default-session=Reading samples for session \"Default\"...
+
+oprofileInit.error.statusMessage=An error occurred initializing OProfile for use with the plugin. Try loading the kernel module via OProfile itself with the command `opcontrol --init` (must be run as root).
+oprofileInit.error.dialog.title=Error initializing OProfile
+oprofileInit.error.dialog.message=FATAL: The OProfile kernel module could not be loaded.
+
+opcontrolRun.error.statusMessage=Error during run of opcontrol
+opcontrolNonZeroExitCode.error.statusMessage=Exit code of opcontrol indicates failure
+
+opcontrolProvider.error.statusMessage=Could not find an OpcontrolProvider, or no opcontrol binary exists.\n\nPlease ensure you have run the install script as the root user. The install script will be in the org.eclipse.linuxtools.oprofile.core plugin, which may be located in one of a few places. You can locate it with the following command (type in a terminal):\n\nfind ~/.eclipse -name 'org.eclipse.linuxtools.oprofile.core*'\n\nIf that doesn't return results, try looking for it in your Eclipse installation:\n\nfind <location from which you're running eclipse> -name 'org.eclipse.linuxtools.oprofile.core*'\n\nWhen you have found the location of the plugin, change to the following directory and run, as root, the install script contained therein:\n\ncd <path to org.eclipse.linuxtools.oprofile.core>/natives/linux/scripts\nsh -x install.sh\n\nYou may need to set the script as executable before running this command; do this with:\n\nchmod u+x install.sh
+
+opcontrolProvider.error.dialog.title=Error running opcontrol
+opcontrolProvider.error.dialog.message=FATAL: An error occurred running opcontrol.
+
+opxmlParse.error.statusMessage=An unexpected error occurred with parsing opxml's output. Please file a bug at http://bugs.eclipse.org/bugs.
+opxmlParse.error.dialog.title=Error with opxml
+opxmlParse.error.dialog.message=An error occurred with opxml.
+
+opxmlIOException.error.statusMessage=The opxml binary can not be read or executed. Either your user does not have sufficient permissions, or the install script was not run.\n\nPlease ensure you have run the install script as the root user. The install script will be in the org.eclipse.linuxtools.oprofile.core plugin, which may be located in one of a few places. You can locate it with the following command (type in a terminal):\n\nfind ~/.eclipse -name 'org.eclipse.linuxtools.oprofile.core*'\n\nIf that doesn't return results, try looking for it in your Eclipse installation:\n\nfind <location from which you're running eclipse> -name 'org.eclipse.linuxtools.oprofile.core*'\n\nWhen you have found the location of the plugin, change to the following directory and run, as root, the install script contained therein:\n\ncd <path to org.eclipse.linuxtools.oprofile.core>/natives/linux/scripts\nsh -x install.sh\n\nYou may need to set the script as executable before running this command; do this with:\n\nchmod u+x install.sh   
+opxmlIOException.error.dialog.title=Error with opxml
+opxmlIOException.error.dialog.message=FATAL: An error occurred with opxml.
+
+opxmlProvider.error.statusMessage=Could not find an OpxmlProvider, or no opxml binary exists. Please fix the issue before continuing.
+opxmlProvider.error.dialog.title=Error with opxml
+opxmlProvider.error.dialog.message=FATAL: An error occurred with opxml.
+
+fatal.kernelModuleNotLoaded=OProfile kernel module not loaded or no opcontrol. Please fix the issue and restart Eclipse.
+
+ui.annotate.no.sessions.error.statusMessage=There are no sessions to annotate. Please profile a binary.
+ui.annotate.no.sessions.error.dialog.title=Annotation Error
+ui.annotate.no.sessions.error.dialog.message=Error annotating
diff --git a/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/opxml/OprofileSAXHandler.java b/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/opxml/OprofileSAXHandler.java
new file mode 100644 (file)
index 0000000..954d061
--- /dev/null
@@ -0,0 +1,186 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Keith Seitz <keiths@redhat.com> - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.oprofile.core.opxml;
+
+import java.util.HashMap;
+import java.util.Stack;
+
+import org.eclipse.linuxtools.oprofile.core.opxml.checkevent.CheckEventsProcessor;
+import org.eclipse.linuxtools.oprofile.core.opxml.info.OpInfoProcessor;
+import org.eclipse.linuxtools.oprofile.core.opxml.modeldata.ModelDataProcessor;
+import org.eclipse.linuxtools.oprofile.core.opxml.sessions.SessionsProcessor;
+import org.xml.sax.Attributes;
+import org.xml.sax.helpers.DefaultHandler;
+
+/**
+ * The SAX handler class that is used to parse the output of opxml.
+ * @see org.eclipse.linuxtools.oprofile.core.opxml.OpxmlRunner
+ */
+public class OprofileSAXHandler extends DefaultHandler {
+       // The only allowed instance of this class
+       private static OprofileSAXHandler _instance = null;
+       
+       // A Map of all the XML processors for opxml
+       private static HashMap<String,Class<?>> _processors = new HashMap<String,Class<?>>();
+       
+       // The current processor being used to parse the document
+       private XMLProcessor _processor = null;
+       private Object _callData;
+       
+       /* A stack of XML processors. This allows processors to invoke sub-processors
+          for handling nested tags more efficiently. */
+       private Stack<XMLProcessor> _processorStack = new Stack<XMLProcessor>();
+       
+       // A convenience class for specifying XMLProcessors
+       private static class ProcessorItem {
+               public String tagName;
+               public Class<?> handlerClass;
+               public ProcessorItem(String name, Class<?> cls) {
+                       tagName = name;
+                       handlerClass = cls;
+               }
+       }
+       
+       // The list of all "root" XML tags and their handler classes 
+       private static final ProcessorItem[] _handlerList = {
+               new ProcessorItem(OpxmlConstants.INFO_TAG, OpInfoProcessor.class),
+               new ProcessorItem(OpxmlConstants.CHECKEVENTS_TAG, CheckEventsProcessor.class),
+               new ProcessorItem(OpxmlConstants.MODELDATA_TAG, ModelDataProcessor.class),
+               new ProcessorItem(OpxmlConstants.SESSIONS_TAG, SessionsProcessor.class)
+       };
+       
+       /**
+        * Returns an instance of the handler. This must be used to access the parser!
+        * @return a handler instance
+        */
+       public static OprofileSAXHandler getInstance(Object callData) {
+               if (_instance == null) {
+                       _instance = new OprofileSAXHandler();
+                       
+                       // Initialize processor map
+                       for (int i = 0; i < _handlerList.length; ++i) {
+                               _processors.put(_handlerList[i].tagName, _handlerList[i].handlerClass);
+                       }
+               }
+               
+               // Set calldata into handler
+               _instance.setCallData (callData);
+               return _instance;
+       }
+       
+       /**
+        * Sets the calldata for the processor.
+        * @param callData the calldata to pass to the processor
+        */
+       public void setCallData(Object callData)
+       {
+               _callData = callData;
+       }
+       
+       /**
+        * Returns the processor for a given request type.
+        * @param type the name of the processor
+        * @return the requested processor or null
+        */
+       public static XMLProcessor getProcessor(String type) {
+               XMLProcessor processor = null;
+               
+               Class<?> handlerClass = (Class<?>) _processors.get(type);
+               if (handlerClass != null) {
+                       try {
+                               processor = (XMLProcessor) handlerClass.newInstance();
+                       } catch (InstantiationException e) {
+                               e.printStackTrace();
+                       } catch (IllegalAccessException e) {
+                               e.printStackTrace();
+                       }
+               }
+               
+               return processor;
+       }
+       
+       /**
+        * @see org.xml.sax.ContentHandler#startDocument()
+        */
+       public void startDocument() {
+               // Reset processor
+               _processor = null;
+       }
+       
+       /**
+        * @see org.xml.sax.ContentHandler#endDocument()
+        */
+       public void endDocument() {
+       }
+       
+       /**
+        * @see org.xml.sax.ContentHandler#startElement(String, String, String, Attributes)
+        */
+       public void startElement(String uri, String lName, String qName, Attributes attrs) {
+               if (_processor == null) {
+                       // Get processor for this event type
+                       _processor = getProcessor(qName);
+                       _processor.reset(_callData);
+               }
+               
+               // If we already have a processor, so let it deal with this new element.
+               // Allow the processor to deal with it's own tag as well: this way it can
+               // grab attributes from it.
+               _processor.startElement(qName, attrs, _callData);
+       }
+       
+       /**
+        * @see org.xml.sax.ContentHandler#endElement(String, String, String)
+        */
+       public void endElement(String uri, String name, String qName) {
+               _processor.endElement(qName, _callData);
+       }
+       
+       /**
+        * @see org.xml.sax.ContentHandler#characters(char[], int, int)
+        */
+       public void characters(char ch[], int start, int length) {
+               // Ignore characters which are only whitespace
+               String str = new String(ch, start, length).trim();
+               if (str.length() > 0 && _processor != null)
+                       _processor.characters(new String(ch, start, length), _callData);
+       }
+       
+       /**
+        * Returns the processor used to parse the document.
+        * @return the XMLProcessor
+        */
+       public XMLProcessor getProcessor() {
+               return _processor;
+       }
+       
+       /**
+        * Pushes the current XMLProcessor onto the stack and installs the given
+        * processor as the document's parser/handler.
+        * @param proc the processor to continue parsing the document
+        */
+       public void push(XMLProcessor proc) {
+               _processorStack.add(_processor);
+               _processor = proc;
+               _processor.reset(_callData);
+       }
+       
+       /**
+        * Removes the current XMLProcessor and installs the previous processor.
+        * NOTE: This assumes that endElement caused the pop, so it calls endElement in
+        * the parent processor.
+        * @param tag the XML tag to pass to the parent processor
+        */
+       public void pop(String tag) {
+               _processor = (XMLProcessor) _processorStack.pop();
+               _processor.endElement(tag, _callData);
+       }
+}
diff --git a/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/opxml/OpxmlConstants.java b/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/opxml/OpxmlConstants.java
new file mode 100644 (file)
index 0000000..3a0f62a
--- /dev/null
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2004,2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Keith Seitz <keiths@redhat.com> - initial API and implementation
+ *    Kent Sebastian <ksebasti@redhat.com> - change samples to model-data
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.oprofile.core.opxml;
+
+/**
+ * A class of constants for communications with the opxml wrapper
+ * program.
+ * @see org.eclipse.linuxtools.oprofile.core.opxml.OprofileSAXHandler
+ */
+public class OpxmlConstants {
+       /**
+        * Request static oprofile information (num counters, defaults, event lists) 
+        */
+       public static final String OPXML_INFO = "info"; //$NON-NLS-1$
+       public static final String INFO_TAG = OPXML_INFO;
+
+       /**
+        * Request model data for a session
+        */
+       public static final String OPXML_MODELDATA = "model-data"; //$NON-NLS-1$
+       public static final String MODELDATA_TAG = OPXML_MODELDATA;
+       
+       /**
+        * Request event validity check
+        */
+       public static final String OPXML_CHECKEVENTS = "check-events"; //$NON-NLS-1$
+       public static final String CHECKEVENTS_TAG = OPXML_CHECKEVENTS;
+       
+       /**
+        * Request session list
+        */
+       public static final String OPXML_SESSIONS  = "sessions"; //$NON-NLS-1$
+       public static final String SESSIONS_TAG = OPXML_SESSIONS;
+}
diff --git a/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/opxml/XMLProcessor.java b/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/opxml/XMLProcessor.java
new file mode 100644 (file)
index 0000000..11a4a5d
--- /dev/null
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Keith Seitz <keiths@redhat.com> - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.oprofile.core.opxml;
+
+import org.xml.sax.Attributes;
+
+/**
+ * A class which (minimally) parses XML documents. This class provides only basic
+ * support for collecting information from XML documents. It is intended to be subclassed,
+ * providing only common functionality for all parser classes.
+ * @see org.eclipse.linuxtools.oprofile.core.opxml.OpxmlRunner
+ */
+public class XMLProcessor {
+       // The characters in the current tag
+       protected String _characters;
+       
+       /**
+        * This method is called whenever the SAXHandler is about to invoke the
+        * processor for the first time on a given document.
+        * @param callData call data for the processor (usually the result is stored here)
+        */
+       public void reset(Object callData) {
+       };
+       
+       //jinu added at 20090620
+       public void release(Object callData) {
+       };
+       
+       /**
+        * This method is called whenever a new tag is seen in the document. By default,
+        * this process will clear the characters collected for the tag. Processors will typically
+        * call this baseclass method to setup for collecting new character information for a
+        * tag.
+        * @param name the name of the tag
+        * @param attrs the tag's attributes
+        * @param callData call data for the processor (usually the result is stored here)
+        */
+       public void startElement(String name, Attributes attrs, Object callData) {
+               _characters = new String();
+       }
+       
+       /**
+        * This method is called whenever the closing tag for an element is seen in the
+        * document.
+        * @param name the element which is ending
+        * @param callData call data for the processor (usually the result is stored here)
+        */
+       public void endElement(String name, Object callData) {
+       }
+       
+       /**
+        * This method is called whenever characters are seen in the document that are not in
+        *  a markup tag.
+        * @param chars the characters read
+        * @param callData call data for the processor (usually the result is stored here)
+        */
+       public void characters(String chars, Object callData) {
+               _characters = chars;
+       }
+}
diff --git a/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/opxml/checkevent/CheckEventsProcessor.java b/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/opxml/checkevent/CheckEventsProcessor.java
new file mode 100644 (file)
index 0000000..79c8a58
--- /dev/null
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2009 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Keith Seitz <keiths@redhat.com> - initial API and implementation
+ *    Kent Sebastian <ksebasti@redhat.com> 
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.oprofile.core.opxml.checkevent;
+
+import org.eclipse.linuxtools.oprofile.core.opxml.XMLProcessor;
+
+/**
+ * XML handler class for opxml's "check-events".
+ * @see org.eclipse.linuxtools.oprofile.core.opxml.OpxmlRunner
+ */
+public class CheckEventsProcessor extends XMLProcessor {
+       public static final int INVALID_UNKNOWN = 0;    //unexpected error
+       public static final int EVENT_OK = 1;                   //valid
+       public static final int INVALID_EVENT = 2;              //invalid event number
+       public static final int INVALID_UMASK = 3;              //invalid unit mask value
+       public static final int INVALID_COUNTER = 4;    //invalid event for given counter number
+
+       private static final String _RESULT_TAG = "result"; //$NON-NLS-1$
+       private static final String _CHECK_EVENTS_TAG ="check-events"; //$NON-NLS-1$
+
+       private static final String _EVENT_OK = "ok"; //$NON-NLS-1$
+       private static final String _INVALID_EVENT = "invalid-event"; //$NON-NLS-1$
+       private static final String _INVALID_UMASK = "invalid-um"; //$NON-NLS-1$
+       private static final String _INVALID_COUNTER = "invalid-counter"; //$NON-NLS-1$
+
+       private int _result;
+
+       /**
+        * @see org.eclipse.linuxtools.oprofile.core.XMLProcessor#reset()
+        */
+       public void reset(Object callData) {
+               _result = INVALID_UNKNOWN;
+       }
+       
+       /**
+        * @see org.eclipse.linuxtools.oprofile.core.XMLProcessor#endElement(String)
+        */
+       public void endElement(String name, Object callData) {
+               if (name.equals(_RESULT_TAG)) {
+                       if (_characters.equals(_EVENT_OK)) {
+                               _result = EVENT_OK;
+                       } else if (_characters.equals(_INVALID_EVENT)) {
+                                       _result = INVALID_EVENT;
+                       } else if (_characters.equals(_INVALID_UMASK)) {
+                               _result = INVALID_UMASK;
+                       } else if (_characters.equals(_INVALID_COUNTER)) {
+                               _result = INVALID_COUNTER;
+                       }
+               } else if (name.equals(_CHECK_EVENTS_TAG)) {
+                       int[] result = (int[]) callData;
+                       result[0] = _result;
+               }
+       }
+}
diff --git a/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/opxml/info/DefaultsProcessor.java b/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/opxml/info/DefaultsProcessor.java
new file mode 100644 (file)
index 0000000..817d842
--- /dev/null
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Keith Seitz <keiths@redhat.com> - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.oprofile.core.opxml.info;
+
+import java.util.HashMap;
+
+import org.eclipse.linuxtools.oprofile.core.daemon.OpInfo;
+import org.eclipse.linuxtools.oprofile.core.opxml.OprofileSAXHandler;
+import org.eclipse.linuxtools.oprofile.core.opxml.XMLProcessor;
+
+/**
+ * XML handler class for opxml's "defaults".
+ * @see org.eclipse.linuxtools.oprofile.core.opxml.OpxmlRunner
+ */
+public class DefaultsProcessor extends XMLProcessor {
+       // XML tags reconize by this processor (public)
+       public static final String SAMPLE_DIR = "sample-dir"; //$NON-NLS-1$
+       public static final String LOCK_FILE = "lock-file"; //$NON-NLS-1$
+       public static final String LOG_FILE = "log-file"; //$NON-NLS-1$
+       public static final String DUMP_STATUS = "dump-status"; //$NON-NLS-1$
+       protected HashMap<String,String> _map = new HashMap<String,String>();
+
+       /**
+        * @see org.eclipse.linuxtools.oprofile.core.XMLProcessor#reset()
+        */
+       public void reset(Object callData) {
+               _map.clear();
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.linuxtools.oprofile.core.opxml.XMLProcessor#endElement(java.lang.String, java.lang.Object)
+        */
+       public void endElement(String name, Object callData) {
+               if (name.equals(OpInfoProcessor.DEFAULTS_TAG)) {
+                       OpInfo info = (OpInfo) callData;
+                       info._setDefaults(_map);
+                       OprofileSAXHandler.getInstance(callData).pop(name);
+               } else {
+                       _map.put(name, _characters);
+               }
+       }
+}
diff --git a/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/opxml/info/EventListProcessor.java b/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/opxml/info/EventListProcessor.java
new file mode 100644 (file)
index 0000000..72f5e77
--- /dev/null
@@ -0,0 +1,241 @@
+/*******************************************************************************
+ * Copyright (c) 2004,2009 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Keith Seitz <keiths@redhat.com> - initial API and implementation
+ *    Kent Sebastian <ksebasti@redhat.com>
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.oprofile.core.opxml.info;
+
+import java.util.ArrayList;
+
+import org.eclipse.linuxtools.oprofile.core.daemon.OpEvent;
+import org.eclipse.linuxtools.oprofile.core.daemon.OpUnitMask;
+import org.eclipse.linuxtools.oprofile.core.opxml.OprofileSAXHandler;
+import org.eclipse.linuxtools.oprofile.core.opxml.XMLProcessor;
+import org.xml.sax.Attributes;
+
+
+/**
+ * XML handler class for opxml's "event-list".
+ * @see org.eclipse.linuxtools.oprofile.core.opxml.OpxmlRunner
+ */
+public class EventListProcessor extends XMLProcessor {
+       // The current event being constructed
+       private OpEvent _currentEvent;
+       private int _counter;
+       private ArrayList<OpEvent> _currentEventList;
+       
+       // An XML processor for reading the unit mask information for an event
+       private UnitMaskProcessor _umProcessor;
+       
+       // XML elements recognized by this processor
+       private static final String _EVENT_TAG = "event"; //$NON-NLS-1$
+       private static final String _UNIT_MASK_TAG = "unit-mask"; //$NON-NLS-1$
+       private static final String _NAME_TAG = "name"; //$NON-NLS-1$
+       private static final String _VALUE_TAG = "value"; //$NON-NLS-1$
+       private static final String _DESCRIPTION_TAG = "description"; //$NON-NLS-1$
+       private static final String _MASK_TAG = "mask"; //$NON-NLS-1$
+       private static final String _MINIMUM_COUNT_TAG = "minimum"; //$NON-NLS-1$
+       private static final String _ATTR_EVENT_LIST_COUNTER = "counter"; //$NON-NLS-1$
+       
+       // This is a special processor which is used to deal with a single mask value
+       private class MaskProcessor extends XMLProcessor {
+               private OpUnitMask.MaskInfo _info;
+               
+               /**
+                * @see org.eclipse.linuxtools.oprofile.core.XMLProcessor#reset()
+                */
+               public void reset(Object callData) {
+                       _info = new OpUnitMask.MaskInfo();
+               }
+               
+               /**
+                * @see org.eclipse.linuxtools.oprofile.core.XMLProcessor#endElement(String)
+                */
+               public void endElement(String name, Object callData) {
+                       if (name.equals(_VALUE_TAG)) {
+                               // Set mask's value
+                               _info.value = Integer.parseInt(_characters);
+                       } else if (name.equals(_DESCRIPTION_TAG)) {
+                               _info.description = _characters;
+                       } else if (name.equals(_MASK_TAG)) {
+                               // Pop and pass mask tag to previous processor (UnitMaskProcessor)
+                               OprofileSAXHandler.getInstance(callData).pop(_MASK_TAG);
+                       }
+               }
+
+               /**
+                * Returns the information that has been collected about a mask.
+                * @return the mask information
+                */
+               public OpUnitMask.MaskInfo getResult() {
+                       return _info;
+               }
+       }
+       
+       // This is a special processor to handle unit mask information
+       private class UnitMaskProcessor extends XMLProcessor {
+               // An ArrayList to hold all the valid masks for a unit mask.
+               private ArrayList<OpUnitMask.MaskInfo> _masks;
+               
+               // The unit mask being constructed
+               private OpUnitMask _unitMask;
+               
+               // An XML processor for each individual mask value.
+               private MaskProcessor _maskProcessor;
+               
+               // XML elements recognized by this processor
+               private static final String _MASK_TYPE_TAG = "type"; //$NON-NLS-1$
+               private static final String _MASK_DEFAULT_TAG = "default"; //$NON-NLS-1$
+               private static final String _MASK_TYPE_BITMASK = "bitmask"; //$NON-NLS-1$
+               private static final String _MASK_TYPE_MANDATORY = "mandatory"; //$NON-NLS-1$
+               private static final String _MASK_TYPE_EXCLUSIVE = "exclusive"; //$NON-NLS-1$
+               
+               /**
+                * Constructor for UnitMaskProcessor. Initializes internal state.
+                */
+               public UnitMaskProcessor() {
+                       super();
+                       _maskProcessor = new MaskProcessor();
+                       _masks = new ArrayList<OpUnitMask.MaskInfo>();
+               }
+               
+               /**
+                * @see org.eclipse.linuxtools.oprofile.core.XMLProcessor#reset()
+                */
+               public void reset(Object callData) {
+                       _unitMask = new OpUnitMask();
+                       _masks.clear();
+               }
+               
+               /**
+                * @see org.eclipse.linuxtools.oprofile.core.XMLProcessor#startElement(String, Attributes)
+                */
+               public void startElement(String name, Attributes attrs, Object callData) {
+                       if (name.equals(_MASK_TAG)) {
+                               // Tell SAX handler to use the mask processor
+                               OprofileSAXHandler.getInstance(callData).push(_maskProcessor);
+                       } else {
+                               super.startElement(name, attrs, callData);
+                       }
+               }
+               
+               /**
+                * @see org.eclipse.linuxtools.oprofile.core.XMLProcessor#endElement(String)
+                */
+               public void endElement(String name, Object callData) {
+                       if (name.equals(_MASK_TYPE_TAG)) {
+                               // Set the mask type
+                               _unitMask._setType(_getTypeFromString(_characters));
+                       } else if (name.equals(_MASK_DEFAULT_TAG)) {
+                               // Set the default mask
+                               _unitMask._setDefault(Integer.parseInt(_characters));
+                       } else if (name.equals(_MASK_TAG)) {
+                               // Add this mask description to the list of all masks
+                               _masks.add(_maskProcessor.getResult());
+                       } else if (name.equals(_UNIT_MASK_TAG)) {
+                               // All done. Add the known masks to the unit mask
+                               OpUnitMask.MaskInfo[] descs = new OpUnitMask.MaskInfo[_masks.size()];
+                               _masks.toArray(descs);
+                               _unitMask._setMaskDescriptions(descs);
+                               
+                               // Pop this processor and pass _UNIT_MASK_TAG to previoius processor
+                               OprofileSAXHandler.getInstance(callData).pop(_UNIT_MASK_TAG);
+                       }
+               }
+                               
+               /**
+                * Returns the constructed unit mask.
+                * @return the unit mask
+                */
+               public OpUnitMask getResult() {
+                       return _unitMask;
+               }
+               
+               // Converts a string representing a mask type into an integer
+               private int _getTypeFromString(String string) {
+                       if (string.equals(_MASK_TYPE_MANDATORY)) {
+                               return OpUnitMask.MANDATORY;
+                       } else if (string.equals(_MASK_TYPE_BITMASK)) {
+                               return OpUnitMask.BITMASK;
+                       } else if (string.equals(_MASK_TYPE_EXCLUSIVE)) {
+                               return OpUnitMask.EXCLUSIVE;
+                       }
+
+                       return -1;
+               }
+       };
+       
+       /**
+        * Constructor for EventListProcessor. Initializes internal state.
+        */
+       public EventListProcessor() {
+               super();
+               _umProcessor = new UnitMaskProcessor();
+       }
+       
+       @Override
+       public void reset(Object callData) {
+               _currentEventList = new ArrayList<OpEvent>();
+       }
+       
+       /**
+        * @see org.eclipse.linuxtools.oprofile.core.XMLProcessor#startElement(String, Attributes)
+        */
+       public void startElement(String name, Attributes attrs, Object callData) {
+               if (name.equals(_EVENT_TAG)) {
+                       // new event
+                       _currentEvent = new OpEvent();
+               } else if (name.equals(_UNIT_MASK_TAG)) {
+                       // Tell the SAX handler to use the unit mask processor
+                       OprofileSAXHandler.getInstance(callData).push(_umProcessor);
+               } else if (name.equals(OpInfoProcessor.EVENT_LIST_TAG)) {
+                       // Our start tag: grab the counter number from the attributes
+                       _counter = Integer.parseInt(attrs.getValue(_ATTR_EVENT_LIST_COUNTER));
+               } else {
+                       super.startElement(name, attrs, callData);
+               }
+       }
+       
+       /**
+        * @see org.eclipse.linuxtools.oprofile.core.XMLProcessor#endElement(String)
+        */
+       public void endElement(String name, Object callData) {
+               if (name.equals(_EVENT_TAG)) {
+                       // Finished constructing an event. Add it to the list.
+                       _currentEventList.add(_currentEvent);
+               } else if (name.equals(_UNIT_MASK_TAG)) {
+                       // Set the event's unit mask
+                       _currentEvent._setUnitMask(_umProcessor.getResult());
+               } else if (name.equals(_NAME_TAG)) {
+                       // Set event's name
+                       _currentEvent._setText(_characters);
+               } else if (name.equals(_VALUE_TAG)) {
+                       // Set event's value
+                       _currentEvent._setNumber(Integer.parseInt(_characters));
+               } else if (name.equals(_DESCRIPTION_TAG)) {
+                       // Set event's description
+                       _currentEvent._setTextDescription(_characters);
+               } else if (name.equals(_MINIMUM_COUNT_TAG)) {
+                       // Set event's minimum count
+                       _currentEvent._setMinCount(Integer.parseInt(_characters));
+               } else if (name.equals(OpInfoProcessor.EVENT_LIST_TAG)) {
+                       OprofileSAXHandler.getInstance(callData).pop(name);
+               }
+       }
+       
+       public int getCounterNum() {
+               return _counter;
+       }
+       
+       public OpEvent[] getEvents() {
+               OpEvent[] events = new OpEvent[_currentEventList.size()];
+               _currentEventList.toArray(events);
+               return events;
+       }
+}
diff --git a/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/opxml/info/OpInfoProcessor.java b/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/opxml/info/OpInfoProcessor.java
new file mode 100644 (file)
index 0000000..c64b3af
--- /dev/null
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2004,2009 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Keith Seitz <keiths@redhat.com> - initial API and implementation
+ *    Kent Sebastian <ksebasti@redhat.com>
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.oprofile.core.opxml.info;
+
+import org.eclipse.linuxtools.oprofile.core.daemon.OpInfo;
+import org.eclipse.linuxtools.oprofile.core.opxml.OprofileSAXHandler;
+import org.eclipse.linuxtools.oprofile.core.opxml.XMLProcessor;
+import org.xml.sax.Attributes;
+
+
+/**
+ * Opxml processor for the "info" command.
+ * @see org.eclipse.linuxtools.oprofile.core.opxml.OpxmlRunner
+ */
+public class OpInfoProcessor extends XMLProcessor {
+       // Other XMLProcessors used by this processor
+       private DefaultsProcessor _defaultsProc;
+       private EventListProcessor _eventListProc;
+       
+       // XML tags processed by this processor
+       public static final String NUM_COUNTERS_TAG = "num-counters"; //$NON-NLS-1$
+       public static final String DEFAULTS_TAG = "defaults"; //$NON-NLS-1$
+       public static final String EVENT_LIST_TAG = "event-list"; //$NON-NLS-1$
+       public static final String CPU_FREQUENCY_TAG = "cpu-frequency"; //$NON-NLS-1$
+       public static final String TIMER_MODE = "timer-mode";  //$NON-NLS-1$
+
+       public OpInfoProcessor() {
+               _defaultsProc = new DefaultsProcessor();
+               _eventListProc = new EventListProcessor();
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.linuxtools.oprofile.core.opxml.XMLProcessor#startElement(java.lang.String, org.xml.sax.Attributes, java.lang.Object)
+        */
+       public void startElement(String name, Attributes attrs, Object callData) {
+               if (name.equals(DEFAULTS_TAG)) {
+                       OprofileSAXHandler.getInstance(callData).push(_defaultsProc);
+               } else if (name.equals(EVENT_LIST_TAG)) {
+                       OprofileSAXHandler.getInstance(callData).push(_eventListProc);
+                       _eventListProc.startElement(name, attrs, callData);
+               } else {
+                       super.startElement(name, attrs, callData);
+               }
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.linuxtools.oprofile.core.opxml.XMLProcessor#endElement(java.lang.String, java.lang.Object)
+        */
+       public void endElement(String name, Object callData) {
+               if (name.equals(CPU_FREQUENCY_TAG)) {
+                       double speed = Double.parseDouble(_characters);
+                       OpInfo info = (OpInfo) callData;
+                       info._setCPUSpeed(speed);
+               } else if (name.equals(TIMER_MODE)) {
+                       boolean timerMode = Boolean.parseBoolean(_characters);
+                       OpInfo info = (OpInfo) callData;
+                       info._setTimerMode(timerMode);
+               } else if (name.equals(NUM_COUNTERS_TAG)) {
+                       int numCounters = 0;
+                       try {
+                               numCounters = Integer.parseInt(_characters);
+                       } catch (NumberFormatException nfe) {
+                               nfe.printStackTrace();
+                       }
+                       OpInfo info = (OpInfo) callData;
+                       info._setNrCounters(numCounters);
+               } else if (name.equals(EVENT_LIST_TAG)) {
+                       OpInfo info = (OpInfo) callData;
+                       info._setEvents(_eventListProc.getCounterNum(), _eventListProc.getEvents());
+               }
+       }
+}
diff --git a/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/opxml/modeldata/DependentProcessor.java b/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/opxml/modeldata/DependentProcessor.java
new file mode 100644 (file)
index 0000000..1c40e22
--- /dev/null
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Kent Sebastian <ksebasti@redhat.com> - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.oprofile.core.opxml.modeldata;
+
+import java.util.ArrayList;
+
+import org.eclipse.linuxtools.oprofile.core.model.OpModelImage;
+import org.eclipse.linuxtools.oprofile.core.opxml.OprofileSAXHandler;
+import org.eclipse.linuxtools.oprofile.core.opxml.XMLProcessor;
+import org.xml.sax.Attributes;
+
+
+/**
+ * XML handler class for dependent images (<image> tags under <dependent>)
+ */
+public class DependentProcessor extends XMLProcessor {
+       //XML tags parsed by this processor
+       private static final String IMAGE_TAG = "image"; //$NON-NLS-1$
+       private static final String SYMBOLS_TAG = "symbols"; //$NON-NLS-1$
+       private static final String DEPENDENT_TAG = "dependent"; //$NON-NLS-1$
+       
+       //attribute tags
+       private static final String ATTR_IMAGENAME = "name"; //$NON-NLS-1$
+       private static final String ATTR_COUNT = "count"; //$NON-NLS-1$
+
+       //the current image being constructed
+       private OpModelImage _image;
+       //a list of all the dependent images
+       private ArrayList<OpModelImage> _imageList;
+
+       //processor used for symbols of an image
+       private SymbolsProcessor _symbolsProcessor = new SymbolsProcessor();
+
+       public void reset(Object callData) {
+               _image = new OpModelImage();
+               _imageList = new ArrayList<OpModelImage>();
+       }
+
+       public void startElement(String name, Attributes attrs, Object callData) {
+               if (name.equals(IMAGE_TAG)) {
+                       _image._setName(attrs.getValue(ATTR_IMAGENAME));
+                       _image._setCount(Integer.parseInt(attrs.getValue(ATTR_COUNT)));
+               } else if (name.equals(SYMBOLS_TAG)) {
+                       OprofileSAXHandler.getInstance(callData).push(_symbolsProcessor);
+               }
+       }
+       /**
+        * @see org.eclipse.linuxtools.oprofile.core.XMLProcessor#endElement(String)
+        */
+       public void endElement(String name, Object callData) {
+               if (name.equals(IMAGE_TAG)) {
+                       _imageList.add(_image);
+                       _image = new OpModelImage();
+               } else if (name.equals(SYMBOLS_TAG)) {
+                       _image._setSymbols(_symbolsProcessor.getSymbols());
+               } else if (name.equals(DEPENDENT_TAG)) {
+                       OprofileSAXHandler.getInstance(callData).pop(DEPENDENT_TAG);
+               }
+       }
+       
+       public OpModelImage[] getImages() {
+               OpModelImage[] images = new OpModelImage[_imageList.size()];
+               _imageList.toArray(images);
+               return images;
+       }
+
+}
diff --git a/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/opxml/modeldata/ModelDataProcessor.java b/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/opxml/modeldata/ModelDataProcessor.java
new file mode 100644 (file)
index 0000000..06a0011
--- /dev/null
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * Copyright (c) 2004,2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Keith Seitz <keiths@redhat.com> - initial API and implementation
+ *    Kent Sebastian <ksebasti@redhat.com> - 
+ *******************************************************************************/ 
+
+package org.eclipse.linuxtools.oprofile.core.opxml.modeldata;
+
+import org.eclipse.linuxtools.oprofile.core.model.OpModelImage;
+import org.eclipse.linuxtools.oprofile.core.opxml.OprofileSAXHandler;
+import org.eclipse.linuxtools.oprofile.core.opxml.XMLProcessor;
+import org.xml.sax.Attributes;
+
+
+/**
+ * A processor for `opxml samples`.
+ */
+public class ModelDataProcessor extends XMLProcessor {
+       //The resulting image compiled by the processor to be used by the caller.
+       public static class CallData {
+               public OpModelImage image;
+               public CallData(OpModelImage im) { image = im; }
+       }
+
+       //XML tags parsed by this processor
+       private static final String IMAGE_TAG = "image"; //$NON-NLS-1$
+       private static final String SYMBOLS_TAG = "symbols"; //$NON-NLS-1$
+       private static final String DEPENDENT_TAG = "dependent"; //$NON-NLS-1$
+       
+       //attribute tags
+       private static final String ATTR_IMAGENAME = "name"; //$NON-NLS-1$
+       private static final String ATTR_COUNT = "count"; //$NON-NLS-1$
+       private static final String ATTR_DEPCOUNT = "count"; //$NON-NLS-1$
+       
+       //the current image being constructed
+       private OpModelImage _image;
+       private int img_seen;   //for ensuring image singleton-ness
+
+       //processors used for symbols and dependent images
+       private SymbolsProcessor _symbolsProcessor = new SymbolsProcessor();
+       private DependentProcessor _dependentProcessor = new DependentProcessor();
+       
+       
+       public void reset(Object callData) {
+               _image = ((CallData) callData).image;
+               img_seen = 0;
+       }
+
+       public void startElement(String name, Attributes attrs, Object callData) {
+               if (name.equals(IMAGE_TAG)) {
+                       if (img_seen == 0) {
+                               _image._setName(attrs.getValue(ATTR_IMAGENAME));
+                               _image._setCount(Integer.parseInt(attrs.getValue(ATTR_COUNT)));
+                       }
+
+                       img_seen++;
+               } else if (name.equals(SYMBOLS_TAG)) {
+                       OprofileSAXHandler.getInstance(callData).push(_symbolsProcessor);
+               } else if (name.equals(DEPENDENT_TAG)) {
+                       _image._setDepCount(Integer.parseInt(attrs.getValue(ATTR_DEPCOUNT)));
+                       OprofileSAXHandler.getInstance(callData).push(_dependentProcessor);
+               } else {
+                       super.startElement(name, attrs, callData);
+               }
+       }
+       
+       public void endElement(String name, Object callData) {
+               if (name.equals(IMAGE_TAG)) {
+                       if (img_seen > 1) {
+                               //should only ever be one image, otherwise oprofile was run
+                               // outside of eclipse and the ui would not handle it properly
+                               _image._setCount(OpModelImage.IMAGE_PARSE_ERROR);
+                               _image._setDepCount(0);
+                               _image._setDependents(null);
+                               _image._setSymbols(null);
+                               _image._setName(""); //$NON-NLS-1$                              
+                       }
+               } else if (name.equals(SYMBOLS_TAG)){
+                       _image._setSymbols(_symbolsProcessor.getSymbols());
+               } else if (name.equals(DEPENDENT_TAG)){
+                       _image._setDependents(_dependentProcessor.getImages());
+               } else {
+                       super.endElement(name, callData);
+               }
+       }
+}
diff --git a/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/opxml/modeldata/SamplesProcessor.java b/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/opxml/modeldata/SamplesProcessor.java
new file mode 100644 (file)
index 0000000..a2bf5a4
--- /dev/null
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Kent Sebastian <ksebasti@redhat.com> - initial API and implementation
+ *      - Note: the original SetupParser class was removed, this is a new 
+ *        implementation 
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.oprofile.core.opxml.modeldata;
+
+import java.util.ArrayList;
+
+import org.eclipse.linuxtools.oprofile.core.model.OpModelSample;
+import org.eclipse.linuxtools.oprofile.core.opxml.OprofileSAXHandler;
+import org.eclipse.linuxtools.oprofile.core.opxml.XMLProcessor;
+
+
+/**
+ * XML handler class for <sample> tags (individual samples).
+ */
+public class SamplesProcessor extends XMLProcessor {
+       //XML tags parsed by this processor
+       private static final String SAMPLE_TAG = "sample"; //$NON-NLS-1$
+       private static final String COUNT_TAG = "count"; //$NON-NLS-1$
+       private static final String LINE_TAG = "line";  //$NON-NLS-1$
+       private static final String SYMBOL_TAG = "symbol";  //$NON-NLS-1$
+       
+       //the current sample being constructed
+       private OpModelSample _sample;
+       //a list of all samples (for this symbol)
+       private ArrayList<OpModelSample> _sampleList;
+
+       public void reset(Object callData) {
+               _sample = new OpModelSample();
+               _sampleList = new ArrayList<OpModelSample>();
+       }
+
+       /**
+        * @see org.eclipse.linuxtools.oprofile.core.XMLProcessor#endElement(String)
+        */
+       public void endElement(String name, Object callData) {
+               if (name.equals(COUNT_TAG)) {
+                       _sample._setCount(Integer.parseInt(_characters));
+               } else if (name.equals(LINE_TAG)) {
+                       _sample._setLine(Integer.parseInt(_characters));
+               } else if (name.equals(SAMPLE_TAG)) {
+                       _sampleList.add(_sample);
+                       _sample = new OpModelSample();
+               } else if (name.equals(SYMBOL_TAG)) {
+                       OprofileSAXHandler.getInstance(callData).pop(SYMBOL_TAG);
+               }
+       }
+       
+       public OpModelSample[] getSamples() {
+               OpModelSample[] samples = new OpModelSample[_sampleList.size()];
+               _sampleList.toArray(samples);
+               return samples;
+       }
+}
diff --git a/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/opxml/modeldata/SymbolsProcessor.java b/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/opxml/modeldata/SymbolsProcessor.java
new file mode 100644 (file)
index 0000000..43d5f2c
--- /dev/null
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Kent Sebastian <ksebasti@redhat.com> - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.oprofile.core.opxml.modeldata;
+
+import java.util.ArrayList;
+
+import org.eclipse.linuxtools.oprofile.core.model.OpModelSymbol;
+import org.eclipse.linuxtools.oprofile.core.opxml.OprofileSAXHandler;
+import org.eclipse.linuxtools.oprofile.core.opxml.XMLProcessor;
+import org.xml.sax.Attributes;
+
+/**
+ * A processor for the <symbols> tag from `opxml samples ..`
+ */
+public class SymbolsProcessor extends XMLProcessor {
+       //XML tags parsed by this processor
+       private static final String SYMBOLS_TAG = "symbols"; //$NON-NLS-1$
+       private static final String SYMBOL_TAG = "symbol";  //$NON-NLS-1$
+       private static final String SAMPLE_TAG = "sample"; //$NON-NLS-1$
+
+       //attribute tags
+       private static final String ATTR_NAME = "name"; //$NON-NLS-1$
+       private static final String ATTR_FILE = "file"; //$NON-NLS-1$
+       private static final String ATTR_COUNT = "count";        //$NON-NLS-1$
+       
+       //the current symbol being constructed
+       private OpModelSymbol _symbol;
+       //all the symbols in this <symbols> tag, to be returned to the calling ModelDataProcessor
+       private ArrayList<OpModelSymbol> _symbols;
+       
+       //the processor used for individual samples
+       private SamplesProcessor _samplesProcessor = new SamplesProcessor();
+       
+       
+       public void reset(Object callData) {
+               _symbol = new OpModelSymbol();
+               _symbols = new ArrayList<OpModelSymbol>();
+       }
+
+       /**
+        * @see org.eclipse.linuxtools.oprofile.core.XMLProcessor#startElement(String, Attributes)
+        */
+       public void startElement(String name, Attributes attrs, Object callData) {
+               if (name.equals(SYMBOL_TAG)) {
+                       _symbol._setName(attrs.getValue(ATTR_NAME));
+                       _symbol._setCount(Integer.parseInt(attrs.getValue(ATTR_COUNT)));
+                       _symbol._setFile(attrs.getValue(ATTR_FILE));
+               } else if (name.equals(SAMPLE_TAG)) {
+                       OprofileSAXHandler.getInstance(callData).push(_samplesProcessor);
+               }
+       }
+       
+       /**
+        * @see org.eclipse.linuxtools.oprofile.core.XMLProcessor#endElement(String)
+        */
+       public void endElement(String name, Object callData) {
+               if (name.equals(SYMBOL_TAG)) {
+                       _symbol._setSamples(_samplesProcessor.getSamples());
+                       _symbols.add(_symbol);
+                       _symbol = new OpModelSymbol();
+               } else if (name.equals(SYMBOLS_TAG)) {
+                       OprofileSAXHandler.getInstance(callData).pop(SYMBOLS_TAG);
+               }
+       }
+       
+       //return all parsed samples
+       public OpModelSymbol[] getSymbols() {
+               OpModelSymbol [] symbols = new OpModelSymbol[_symbols.size()];
+               _symbols.toArray(symbols);
+               return symbols;
+       }
+}
diff --git a/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/opxml/sessions/SessionsProcessor.java b/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/opxml/sessions/SessionsProcessor.java
new file mode 100644 (file)
index 0000000..7c3fcc8
--- /dev/null
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Keith Seitz <keiths@redhat.com> - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.oprofile.core.opxml.sessions;
+
+import java.util.ArrayList;
+
+import org.eclipse.linuxtools.oprofile.core.model.OpModelEvent;
+import org.eclipse.linuxtools.oprofile.core.model.OpModelSession;
+import org.eclipse.linuxtools.oprofile.core.opxml.XMLProcessor;
+import org.xml.sax.Attributes;
+
+
+/**
+ * A processor for sessions.
+ * @see org.eclipse.linuxtools.oprofile.core.opxml.OpxmlRunner
+ */
+public class SessionsProcessor extends XMLProcessor {
+       public static class SessionInfo {
+               // A list of SessionEvents
+               public ArrayList<OpModelEvent> list;
+               
+               public SessionInfo(ArrayList<OpModelEvent> _list){
+                       list = _list;
+               }
+       };
+       
+       // XML tags recognized by this processor
+       public static final String SESSION_TAG = "session"; //$NON-NLS-1$
+       private static final String _SESSION_NAME_ATTR = "name"; //$NON-NLS-1$
+       public static final String SAMPLE_COUNT_TAG = "count"; //$NON-NLS-1$
+       public static final String EVENT_TAG = "event"; //$NON-NLS-1$
+       private static final String _EVENT_NAME_ATTR = "name"; //$NON-NLS-1$
+       
+       // The current session being constructed
+       private OpModelSession _currentSession;
+       
+       // The current event being constructed
+       private OpModelEvent _currentEvent;
+       
+       // A list of all sessions
+       private ArrayList<OpModelSession> _sessionList;
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.linuxtools.oprofile.core.opxml.XMLProcessor#startElement(java.lang.String, org.xml.sax.Attributes, java.lang.Object)
+        */
+       public void startElement(String name, Attributes attrs, Object callData) {
+               if (name.equals(SESSION_TAG)) {
+                       String sessionName = attrs.getValue(_SESSION_NAME_ATTR);
+                       _currentSession = new OpModelSession(_currentEvent, sessionName);
+               } else if (name.equals(EVENT_TAG)) {
+                       String eventName = attrs.getValue(_EVENT_NAME_ATTR);
+                       _currentEvent = new OpModelEvent(eventName);
+                       _sessionList = new ArrayList<OpModelSession>();
+               } else {
+                       super.startElement(name, attrs, callData);
+               }
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.linuxtools.oprofile.core.opxml.XMLProcessor#endElement(java.lang.String, java.lang.Object)
+        */
+       public void endElement(String name, Object callData) {
+               if (name.equals(SESSION_TAG)) {
+                       // Got end of session -- save in session list
+                       _sessionList.add(_currentSession);
+                       _currentSession = null;
+               } else if (name.equals(EVENT_TAG)) {
+                       // Got end of event -- save session list into current OpModelEvent and
+                       // save current event into call data
+                       OpModelSession[] s = new OpModelSession[_sessionList.size()];
+                       _sessionList.toArray(s);
+                       _currentEvent._setSessions(s);
+                       SessionInfo info = (SessionInfo) callData;
+                       info.list.add(_currentEvent);
+                       _currentEvent = null;
+                       _sessionList = null;
+               } else {
+                       super.endElement(name, callData);
+               }
+       }
+}
diff --git a/org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/CommandManager.java b/org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/CommandManager.java
new file mode 100644 (file)
index 0000000..9580934
--- /dev/null
@@ -0,0 +1,228 @@
+package org.tizen.oprofile.core;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+
+import org.tizen.common.connection.ConnectionPlugin;
+import org.tizen.oprofile.core.CommonReceiver;
+import org.tizen.sdblib.IDevice;
+import org.tizen.sdblib.MultiLineReceiver;
+import org.tizen.sdblib.SdbCommandRejectedException;
+import org.tizen.sdblib.SdbShellProcess;
+import org.tizen.sdblib.ShellCommandUnresponsiveException;
+import org.tizen.sdblib.SyncService;
+import org.tizen.sdblib.SyncService.SyncResult;
+import org.tizen.sdblib.TimeoutException;
+
+class CommonReceiver extends MultiLineReceiver {
+
+       private String[] output = null;
+
+       public String[] getOutput() {
+               return output;
+       }
+
+       @Override
+       public void processNewLines(String[] lines) {
+               output = lines;
+       }
+
+}
+
+class OneStringReceiver extends MultiLineReceiver {
+
+       private String output = "";
+
+       public String getOutput() {
+               return output;
+       }
+
+       @Override
+       public void processNewLines(String[] lines) {
+               // output = lines;
+               StringBuilder out = new StringBuilder("");
+               for (int i = 0; i < lines.length; i++) {
+                       if (lines[i].equals(""))
+                               continue;
+                       out.append(lines[i]);
+                       out.append("\r\n");
+               }
+               output = output + out.toString();
+       }
+
+}
+
+public class CommandManager {
+       
+//     private static String getRealTargetPath(String path) {
+////           if (ConnectionPlugin.getDefault().getCurrentDevice().isEmulator()) {
+////                   return path;
+////           }
+//             if (path.contains("/usr/bin")) {
+//                     path = path
+//                                     .replace("/usr/bin", "/home/developer/sdk_tools/oprofile/usr/bin");
+//             }
+//             return path;
+//     }
+       
+       public static SdbShellProcess runApplication(String command){
+               IDevice device = ConnectionPlugin.getDefault().getCurrentDevice();
+               SdbShellProcess sdbShellProc = null;
+               
+               //command = getRealTargetPath(command);
+               
+               try {
+                       sdbShellProc = device.executeShellCommand(command);
+               } catch (IOException e) {
+                       e.printStackTrace();
+               }
+               return sdbShellProc;
+       }
+       
+       public static void runShell(String command) {
+               IDevice device = ConnectionPlugin.getDefault().getCurrentDevice();
+               SdbShellProcess sdbShellProc = null;
+               BufferedReader br = null;
+               
+               //command = getRealTargetPath(command);
+               
+               try {
+                       sdbShellProc = device.executeShellCommand(command);
+                       br = new BufferedReader(new InputStreamReader(
+                                       sdbShellProc.getInputStream()));
+
+               } catch (IOException e1) {
+                       e1.printStackTrace();
+               }
+
+               try {
+                       String message;
+                       while (null != (message = br.readLine())) {
+                               if (message.equals("start_ok")) {
+                                       break;
+                               }
+                       }
+               } catch (IOException e) {
+                       e.printStackTrace();
+               }
+       }
+
+       public static String runCommandReturningResult(String command) {
+               IDevice device = ConnectionPlugin.getDefault().getCurrentDevice();
+               OneStringReceiver oneStringReceiver = new OneStringReceiver();
+               
+               //command = getRealTargetPath(command);
+               
+               try {
+                       device.executeShellCommand(command, oneStringReceiver);
+               } catch (TimeoutException e) {
+                       e.printStackTrace();
+               } catch (SdbCommandRejectedException e) {
+                       e.printStackTrace();
+               } catch (ShellCommandUnresponsiveException e) {
+                       e.printStackTrace();
+               } catch (IOException e) {
+                       e.printStackTrace();
+               }
+               return oneStringReceiver.getOutput();
+       }
+
+       public static String[] runCommandReturningResultArray(String command) {
+               IDevice device = ConnectionPlugin.getDefault().getCurrentDevice();
+               CommonReceiver commonReceiver = new CommonReceiver();
+               
+               //command = getRealTargetPath(command);
+               
+               try {
+                       device.executeShellCommand(command, commonReceiver);
+               } catch (TimeoutException e) {
+                       e.printStackTrace();
+               } catch (SdbCommandRejectedException e) {
+                       e.printStackTrace();
+               } catch (ShellCommandUnresponsiveException e) {
+                       e.printStackTrace();
+               } catch (IOException e) {
+                       e.printStackTrace();
+               }
+               return commonReceiver.getOutput();
+       }
+
+       public static void runCommand(String command) {
+               
+               //command = getRealTargetPath(command);
+               
+               try {
+                       ConnectionPlugin.getDefault().getCurrentDevice()
+                                       .executeShellCommand(command);
+               } catch (SdbCommandRejectedException e) {
+                       e.printStackTrace();
+               } catch (IOException e) {
+                       e.printStackTrace();
+               }
+       }
+
+       public static boolean pull(String src, String dest) {
+               SyncService syncService = null;
+               try {
+                       syncService = ConnectionPlugin.getDefault().getCurrentDevice()
+                                       .getSyncService();
+               } catch (TimeoutException e) {
+                       e.printStackTrace();
+               } catch (SdbCommandRejectedException e) {
+                       e.printStackTrace();
+               } catch (IOException e) {
+                       e.printStackTrace();
+               }
+               SyncResult result = syncService.pullFile(src, dest,
+                               SyncService.getNullProgressMonitor());
+               if (SyncService.RESULT_OK == result.getCode()) {
+                       return true;
+               } else {
+                       return false;
+               }
+       }
+
+       public static boolean push(String src, String dest) {
+               SyncService syncService = null;
+               try {
+                       syncService = ConnectionPlugin.getDefault().getCurrentDevice()
+                                       .getSyncService();
+               } catch (TimeoutException e) {
+                       e.printStackTrace();
+               } catch (SdbCommandRejectedException e) {
+                       e.printStackTrace();
+               } catch (IOException e) {
+                       e.printStackTrace();
+               }
+               SyncResult result = syncService.pushFile(src, dest,
+                               SyncService.getNullProgressMonitor());
+               if (SyncService.RESULT_OK == result.getCode()) {
+                       return true;
+               } else {
+                       return false;
+               }
+       }
+
+       public static boolean isPathExist(String path) {
+               String[] result = runCommandReturningResultArray(path);
+               if (null != result && result[0].equals("No such file or directory")) {
+                       return false;
+               }
+               return true;
+       }
+
+       public static boolean isEmulator() {
+               return ConnectionPlugin.getDefault().getCurrentDevice().isEmulator();
+       }
+
+       public static boolean isRunSeccessfuly(String[] result) {
+               if (null != result && result.length > 0
+                               && !result[result.length - 1].contains("0")) {
+                       return false;
+               } else {
+                       return true;
+               }
+       }
+}
diff --git a/org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/OprofileComm.java b/org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/OprofileComm.java
new file mode 100644 (file)
index 0000000..562603f
--- /dev/null
@@ -0,0 +1,157 @@
+/*
+ *  OprofileComm
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Jaewon Lim <jaewon81.lim@samsung.com>
+ * Wonhyoung Park <wonhyoung2.park@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+
+package org.tizen.oprofile.core;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.linuxtools.oprofile.core.OprofileCorePlugin;
+import org.eclipse.linuxtools.oprofile.core.daemon.OpInfo;
+import org.eclipse.linuxtools.oprofile.core.model.OpModelEvent;
+import org.eclipse.linuxtools.oprofile.core.model.OpModelRoot;
+import org.eclipse.swt.widgets.Display;
+
+import org.tizen.oprofile.core.provider.OpcontrolDataProvider;
+
+public abstract class OprofileComm {
+
+       public static Boolean checkEvent(String event, int count, int unitmask) {
+               int[] result = new int[1];
+               try {
+                       IRunnableWithProgress opxml = OpcontrolDataProvider.checkEvent(event, count, unitmask, result);
+                       opxml.run(null);
+               } catch (InvocationTargetException e) {
+                       String error = "An error has occured during check event setting for OProfile";
+                       String reason = "An unexpected error occurred with parsing data. This might be caused by closed connection to target";
+                       showErrorDialog(error, reason , e); //$NON-NLS-1$
+               } catch (InterruptedException e) {
+                       String error = "An error has occured during check event setting for OProfile";
+                       String reason = "An unexpected error occurred with parsing data. This might be caused by closed connection to target";
+                       showErrorDialog(error, reason , e); //$NON-NLS-1$
+               }
+               
+               return (result[0] == 0);
+       }
+       
+       public static OpModelEvent[] getEventList() {
+               OpModelEvent[] events = null;
+               
+               ArrayList<OpModelEvent> eventList = new ArrayList<OpModelEvent>();
+               try {
+                       IRunnableWithProgress runner = OpcontrolDataProvider.getEventList(eventList);
+                       runner.run(null);
+                       events = new OpModelEvent[eventList.size()];
+                       eventList.toArray(events);
+               } catch (InvocationTargetException e) {
+                       String error = "An error has occured during get detailed information of supported event for OProfile";
+                       String reason = "An unexpected error occurred with parsing data. This might be caused by closed connection to target";
+                       showErrorDialog(error ,reason, e); //$NON-NLS-1$
+               } catch (InterruptedException e) {
+                       String error = "An error has occured during get detailed information of supported event for OProfile";
+                       String reason = "An unexpected error occurred with parsing data. This might be caused by closed connection to target";
+                       showErrorDialog(error ,reason, e); //$NON-NLS-1$
+               }
+               return events;
+       }
+       
+       public static OpModelRoot getModelData() {              
+               OpModelRoot model = new OpModelRoot();
+               try {
+                       IRunnableWithProgress runner = OpcontrolDataProvider.getModelData(model);
+                       runner.run(null);
+               } catch (InvocationTargetException e) {
+                       String error = "An error has occured during get reported data in current session";
+                       String reason = "An unexpected error occurred with parsing data. This might be caused by closed connection to target";
+                       showErrorDialog(error, reason, e); //$NON-NLS-1$
+                       return null;
+               } catch (InterruptedException e) {
+                       String error = "An error has occured during get reported data in current session";
+                       String reason = "An unexpected error occurred with parsing data. This might be caused by closed connection to target";
+                       showErrorDialog(error, reason, e); //$NON-NLS-1$
+                       return null;
+               }
+
+               return model;
+       }
+       
+       public static OpInfo getEventInfo() {           
+               OpInfo info = new OpInfo();
+
+               try {
+                       IRunnableWithProgress runner = OpcontrolDataProvider.getEventInfo(info);
+                       runner.run(null);
+
+               } catch (InvocationTargetException e) {
+                       String error = "An error has occured during get event list in current session";
+                       String reason = "An unexpected error occurred with parsing data. This might be caused by closed connection to target";
+                       showErrorDialog(error , reason, e); //$NON-NLS-1$
+               } catch (InterruptedException e) {
+                       String error = "An error has occured during get event list in current session";
+                       String reason = "An unexpected error occurred with parsing data. This might be caused by closed connection to target";
+                       showErrorDialog(error , reason, e); //$NON-NLS-1$
+               }       
+               return info;
+       }
+       
+       public static void showErrorDialog(final String errorMessage, final String reasonMessage, final Exception ex) {
+               
+               final String dialogTitle = "Oprofile Error";
+               final IStatus status = new Status(IStatus.ERROR, OprofileCorePlugin.getId(), IStatus.OK, reasonMessage, ex);
+               
+               Display.getDefault().syncExec(new Runnable() {
+                       public void run() {
+                               ErrorDialog.openError(null, dialogTitle, errorMessage, status);
+                       }
+               });
+
+       }
+       
+       
+       public static String getCommandString(String[] comm){
+               StringBuffer sb = new StringBuffer();
+               for(int i=0;i<comm.length;i++){
+                       sb.append(comm[i]);
+                       sb.append(" ");
+               }
+               return sb.toString();
+       }
+       
+//     // changed by greatim 2011.06.01 for fresh ide
+//     public static ISession getSession() throws InterruptedException{
+//             ISession session = null;
+//             try {
+//                     DeviceMachine selected = DeviceManager.getSelectedDevice();
+//                     if(selected.getMachineType().equals(IMachine.VIRTUAL_DEVICE))
+//                             session = SessionManager.getSession("OPROFILER_CONTROL_VIRTUAL", selected, new NullProgressMonitor());
+//                     else
+//                             session = SessionManager.getSession("OPROFILER_CONTROL_REAL", selected, new NullProgressMonitor());
+//             } catch (Exception e) {
+//
+//             }
+//             return session;
+//     }
+
+}
diff --git a/org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/OprofileCommonConstants.java b/org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/OprofileCommonConstants.java
new file mode 100644 (file)
index 0000000..c10818c
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ *  OprofileCommonConstants
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Jaewon Lim <jaewon81.lim@samsung.com>
+ * Wonhyoung Park <wonhyoung2.park@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.oprofile.core;
+
+import org.tizen.common.TizenPlatformConstants;
+
+public abstract class OprofileCommonConstants {
+
+       private static final String COMMAND_PATH = TizenPlatformConstants.TOOLS_TARGET_PATH + "/oprofile/usr/bin/";
+       
+       public static final String COMMAND_OPCONTROL = COMMAND_PATH+"opcontrol";
+       
+       public static final String COMMAND_OPREPORT = "LD_LIBRARY_PATH=" + COMMAND_PATH + " " + COMMAND_PATH + "opreport";
+       
+       public static final String COMMAND_OPHELP = COMMAND_PATH+"ophelp";
+       
+       public static final String COMMAND_OPXML = COMMAND_PATH+"opxml";
+       
+       public static final String LOG_PATH = "/var/lib/oprofile/samples/";
+       
+       public static final String LOG_DAEMON = LOG_PATH+"oprofiled.log";
+       
+       public static final String DEV_CPU_TYPE = "/dev/oprofile/cpu_type";
+}
diff --git a/org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/processor/checkevent/CheckEventsProcessor.java b/org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/processor/checkevent/CheckEventsProcessor.java
new file mode 100644 (file)
index 0000000..32c93ab
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ *  CheckEventsProcessor
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Jaewon Lim <jaewon81.lim@samsung.com>
+ * Wonhyoung Park <wonhyoung2.park@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.oprofile.core.processor.checkevent;
+
+import org.tizen.oprofile.core.CommandManager;
+import org.tizen.oprofile.core.OprofileCommonConstants;
+
+
+public class CheckEventsProcessor {
+
+       private final String COMMAND_CHECK_EVENT = OprofileCommonConstants.COMMAND_OPHELP
+                       + " -e";
+
+       public void parse(String event, int count, int unitmask, int[] result)
+                       throws InterruptedException {
+               String[] resultStr = null;
+
+                       resultStr = CommandManager
+                                       .runCommandReturningResultArray(COMMAND_CHECK_EVENT + " "
+                                                       + event + ":" + count + ":" + unitmask);
+
+               if (resultStr != null && resultStr.length > 0
+                               && resultStr[0].trim().length() > 0) {
+                       try {
+                               result[0] = Integer.parseInt(resultStr[0].trim());
+                       } catch (NumberFormatException e) {
+                               result[0] = -1;
+                       }
+               }
+
+       }
+
+}
diff --git a/org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/processor/checkkernel/CheckKernelProcessor.java b/org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/processor/checkkernel/CheckKernelProcessor.java
new file mode 100644 (file)
index 0000000..05f9d85
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ *  CheckKernel Processor
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Jaewon Lim <jaewon81.lim@samsung.com>
+ * Wonhyoung Park <wonhyoung2.park@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.oprofile.core.processor.checkkernel;
+
+
+import org.tizen.oprofile.core.CommandManager;
+import org.tizen.oprofile.core.OprofileCommonConstants;
+
+public class CheckKernelProcessor {
+
+       private final String COMMAND_CHECK_KERNEL = "cat "
+                       + OprofileCommonConstants.DEV_CPU_TYPE + " 2> /dev/null; echo";
+
+       public void parse(String[] result) throws InterruptedException {
+               String[] resultStr = null;
+
+               resultStr = CommandManager
+                                       .runCommandReturningResultArray(COMMAND_CHECK_KERNEL);
+
+               if (resultStr != null && resultStr.length > 0
+                               && resultStr[0].trim().length() > 0) {
+                       result[0] = resultStr[0].trim();
+               }
+
+       }
+
+}
diff --git a/org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/processor/eventinfo/EventListProcessor.java b/org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/processor/eventinfo/EventListProcessor.java
new file mode 100644 (file)
index 0000000..4e3c5ee
--- /dev/null
@@ -0,0 +1,208 @@
+/*
+ *  EventListProcessor
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Jaewon Lim <jaewon81.lim@samsung.com>
+ * Wonhyoung Park <wonhyoung2.park@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.oprofile.core.processor.eventinfo;
+
+import java.util.ArrayList;
+
+import org.eclipse.linuxtools.oprofile.core.daemon.OpEvent;
+import org.eclipse.linuxtools.oprofile.core.daemon.OpInfo;
+import org.eclipse.linuxtools.oprofile.core.daemon.OpUnitMask;
+import org.eclipse.linuxtools.oprofile.core.daemon.OpUnitMask.MaskInfo;
+
+import org.tizen.oprofile.core.CommandManager;
+import org.tizen.oprofile.core.OprofileCommonConstants;
+
+public class EventListProcessor {
+       private OpInfo info;
+       private ArrayList<OpEvent>[] eventList;
+
+       public EventListProcessor(OpInfo info) throws InterruptedException {
+               this.info = info;
+               initializeEventList();
+       }
+
+       private void initializeEventList() {
+               eventList = new ArrayList[info.getNrCounters()];
+               for (int i = 0; i < eventList.length; i++) {
+                       eventList[i] = new ArrayList<OpEvent>();
+               }
+       }
+
+       private static final String COMMAND_EVENT_LIST = OprofileCommonConstants.COMMAND_OPCONTROL
+                       + " -l 2> /dev/null";
+       private static final String EVENT_PATTERN = "^[A-Z1-9]+.*\\(counter: \\d+.*\\)$";
+       //private static final String EVENT_DETAIL_PATTERN = "^\\s+.*\\(min count: \\d+\\).*";
+       private static final String EVENT_DETAIL_PATTERN = ".*\\(min count: \\d+\\).*";
+       private static final String UNIT_MASK_PATTERN = "Unit masks \\(default: 0x..\\)$";
+       private static final String MASK_INFO_PATTERN = "0x..: .*";
+
+       public void parse() throws InterruptedException {
+               String resultStr = null;
+
+               resultStr = CommandManager.runCommandReturningResult(COMMAND_EVENT_LIST);                       
+
+               if (resultStr == null || resultStr.trim().length() == 0)
+                       return;
+
+               String eventStr[] = resultStr.split("\r?\n");
+               OpEvent event = null;
+               OpUnitMask unitMask = null;
+               ArrayList<MaskInfo> maskList = null;
+
+               boolean isDummy = true;
+               boolean isContinued = false;
+               String str = null;
+               String prevStr = null;
+
+               for (int i = 0; i < eventStr.length; i++) {
+
+                       if (isContinued && !isDummy) {
+                               str = prevStr + " " + eventStr[i].replaceFirst("^\\s*", "");
+                       } else {
+                               str = eventStr[i];
+                       }
+
+                       isContinued = false;
+
+                       if (str.matches(EVENT_PATTERN)) {
+                               setOpUnitMaskList(unitMask, maskList);
+
+                               event = new OpEvent();
+                               unitMask = new OpUnitMask();
+                               setOpEventUnitMask(event, unitMask);
+                               setOpEventName(event, str);
+                               setOpEventCounter(event, str);
+
+                               isDummy = false;
+                       } else if (str.matches(EVENT_DETAIL_PATTERN)) {
+                               setOpEventDescription(event, str);
+                               setOpEventMinCount(event, str);
+                       } else if (str.matches(UNIT_MASK_PATTERN)) {
+                               setOpUnitMaskDefault(unitMask, str);
+                               maskList = new ArrayList<MaskInfo>();
+                       } else if (str.matches(MASK_INFO_PATTERN)) {
+                               addMaskInfo(maskList, str);
+                       } else {
+                               isContinued = true;
+                               prevStr = eventStr[i];
+                       }
+
+               }
+
+               setOpInfoEventList();
+       }
+
+       private void setOpUnitMaskList(OpUnitMask unitMask,
+                       ArrayList<MaskInfo> maskList) {
+               if (unitMask == null || (unitMask != null && maskList == null))
+                       return;
+
+               unitMask._setMaskDescriptions(maskList.toArray(new MaskInfo[maskList
+                               .size()]));
+
+               boolean hasSameValue = false;
+               for (int i = 0; i < maskList.size(); i++) {
+                       MaskInfo info = maskList.get(i);
+                       if (info.value == unitMask.getMaskValue()) {
+                               hasSameValue = true;
+                               break;
+                       }
+               }
+
+               unitMask._setType(hasSameValue ? OpUnitMask.EXCLUSIVE
+                               : OpUnitMask.BITMASK);
+       }
+
+       private void addMaskInfo(ArrayList<MaskInfo> maskList, String str) {
+               int idx = str.indexOf(":");
+
+               String desc = str.substring(idx + 1, str.length()).trim();
+               int val = Integer.parseInt(str.substring(2, idx).trim(), 16);
+
+               MaskInfo maskInfo = new MaskInfo();
+               maskInfo.description = desc;
+               maskInfo.value = val;
+
+               maskList.add(maskInfo);
+       }
+
+       private void setOpInfoEventList() {
+               for (int i = 0; i < eventList.length; i++) {
+                       info._setEvents(i,
+                                       eventList[i].toArray(new OpEvent[eventList[i].size()]));
+               }
+       }
+
+       private void setOpEventUnitMask(OpEvent event, OpUnitMask unitMask) {
+               event._setUnitMask(unitMask);
+               unitMask._setType(OpUnitMask.MANDATORY);
+       }
+
+       private void setOpUnitMaskDefault(OpUnitMask unitMask, String str) {
+               String defaultUnitMask = str.substring(str.lastIndexOf("0x") + 2,
+                               str.lastIndexOf(")"));
+               unitMask._setDefault(Integer.parseInt(defaultUnitMask, 16));
+       }
+
+       private void setOpEventMinCount(OpEvent event, String str) {
+               String minCount = str.substring(str.lastIndexOf(":") + 1,
+                               str.lastIndexOf(")"));
+               event._setMinCount(Integer.parseInt(minCount.trim()));
+       }
+
+       private void setOpEventDescription(OpEvent event, String str) {
+               String eventDescription = str.substring(0, str.lastIndexOf("("));
+               event._setTextDescription(eventDescription.trim());
+       }
+
+       private void setOpEventCounter(OpEvent event, String str) {
+               String counters = str.substring(str.lastIndexOf(":") + 1,
+                               str.lastIndexOf(")"));
+               if (counters == null)
+                       return;
+
+               if (counters.trim().equals("all")) {
+                       for (int i = 0; i < eventList.length; i++) {
+                               eventList[i].add(event);
+                       }
+               } else {
+                       String[] counter = counters.trim().split(",");
+                       for (int i = 0; i < counter.length; i++) {
+                               eventList[Integer.parseInt(counter[i].trim())].add(event);
+                       }
+               }
+       }
+
+       private void setOpEventName(OpEvent event, String str) {
+               String eventName = str.substring(0, str.indexOf(":"));
+               event._setText(eventName.trim());
+       }
+
+       public static void main(String[] args) {
+               String str = "             500) ";
+               String convStr = str.replaceFirst("^\\s*", "");
+
+               System.out.println("[" + str + "]");
+               System.out.println("[" + convStr + "]");
+
+       }
+
+}
diff --git a/org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/processor/eventinfo/OpInfoProcessor.java b/org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/processor/eventinfo/OpInfoProcessor.java
new file mode 100644 (file)
index 0000000..c4a0f62
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ *  OpInfoProcessor
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Jaewon Lim <jaewon81.lim@samsung.com>
+ * Wonhyoung Park <wonhyoung2.park@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.oprofile.core.processor.eventinfo;
+
+import org.eclipse.linuxtools.oprofile.core.daemon.OpInfo;
+
+import org.tizen.oprofile.core.CommandManager;
+
+public class OpInfoProcessor {
+       private OpInfo info;
+
+       public OpInfoProcessor(OpInfo info) throws InterruptedException {
+               this.info = info;
+       }
+
+       private final String COMMAND_COUNTER_NO = "ls -d /dev/oprofile/[0-9] -c1 2> /dev/null";
+
+       public void parse() throws InterruptedException {
+               String[] resultStr = null;
+
+               resultStr = CommandManager.runCommandReturningResultArray(COMMAND_COUNTER_NO);
+
+               if (resultStr != null && resultStr.length >1) {
+                       // System.out.println("######## opcontrol -l : "+resultStr);
+                       //int cnt = resultStr.split("\r?\n").length;
+                       int cnt = resultStr.length;
+                       info._setNrCounters(cnt);
+                       info._setTimerMode(false);
+               } else {
+                       // System.out.println("######## opcontrol -l : no data");
+                       info._setNrCounters(0);
+                       info._setTimerMode(true);
+               }
+
+               // FIXME:jinu removed at 20090620
+               // this logic isn't exactly matched with real result
+               /*
+                * command = "grep  \"cpu MHz\" /proc/cpuinfo";
+                * 
+                * try { resultStr = session.run(command); } catch (Exception e) { throw
+                * new InterruptedException(); }
+                * 
+                * if(resultStr!=null&&resultStr.trim().length()>0){ String speed =
+                * resultStr.split(lineSeparator)[0].split(":")[1].trim();
+                * info._setCPUSpeed(Double.parseDouble(speed)); }else{
+                * info._setCPUSpeed(0); }
+                */
+
+       }
+
+}
diff --git a/org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/processor/modeldata/ModelDataProcessor.java b/org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/processor/modeldata/ModelDataProcessor.java
new file mode 100644 (file)
index 0000000..345e8c3
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ *  ModelDataProcessor
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Jaewon Lim <jaewon81.lim@samsung.com>
+ * Wonhyoung Park <wonhyoung2.park@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.oprofile.core.processor.modeldata;
+
+import java.io.IOException;
+import java.io.StringReader;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.eclipse.linuxtools.oprofile.core.model.OpModelRoot;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+import org.tizen.oprofile.core.CommandManager;
+import org.tizen.oprofile.core.OprofileCommonConstants;
+import org.tizen.oprofile.core.processor.modeldata.handler.OprofileSAXHandler;
+import org.tizen.sdblib.SdbPreferences;
+
+
+public class ModelDataProcessor{
+       private OpModelRoot root;
+       
+       public ModelDataProcessor(OpModelRoot root) throws InterruptedException{
+               this.root = root;
+       }
+       
+//     private final String DEFAULT_SESSION_NAME = "current";
+       private final String COMMAND_SESSION_EVENT =OprofileCommonConstants.COMMAND_OPREPORT+" -gdlfX 2> /dev/null" +" | sed 's/^\\s</</' | sed 's/&//g'";
+//     private final String COMMAND_SESSION_EVENT =OprofilerCommonConstants.COMMAND_OPREPORT+" -gdlfX 2> /dev/null" +" | sed 's/^[^<]*//' | sed 's/&//'";
+       
+       public void parse() throws InterruptedException, SAXException, IOException, ParserConfigurationException{
+               SAXParserFactory factory = SAXParserFactory.newInstance();
+               SAXParser saxParser = factory.newSAXParser();
+               
+               OprofileSAXHandler handler = new OprofileSAXHandler(root);
+               
+               String resultStr= null;
+               
+               //resultStr = session.run(COMMAND_SESSION_EVENT, null);
+               int orgtimeout = SdbPreferences.getTimeOut();
+               SdbPreferences.setTimeOut(60000);
+               resultStr = CommandManager.runCommandReturningResult(COMMAND_SESSION_EVENT);
+               SdbPreferences.setTimeOut(orgtimeout);
+                       
+               
+               if(resultStr==null||resultStr.trim().length() ==0){
+//                     root.reset();
+                       return;
+               }else{
+                       root.setXML(resultStr);
+               }
+               
+               try {
+                       saxParser.parse(new InputSource(new StringReader(resultStr)),handler);
+               } catch (SAXException e) {
+                       e.printStackTrace();
+               } catch (IOException e) {
+                       e.printStackTrace();
+               }
+               
+       }
+
+       
+}
diff --git a/org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/processor/modeldata/handler/OprofileSAXHandler.java b/org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/processor/modeldata/handler/OprofileSAXHandler.java
new file mode 100644 (file)
index 0000000..d7dfc43
--- /dev/null
@@ -0,0 +1,133 @@
+/*
+ *  OprofileSAXHandler
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Jaewon Lim <jaewon81.lim@samsung.com>
+ * Wonhyoung Park <wonhyoung2.park@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.oprofile.core.processor.modeldata.handler;
+
+import java.util.HashMap;
+
+import org.eclipse.linuxtools.oprofile.core.model.OpModelImage;
+import org.eclipse.linuxtools.oprofile.core.model.OpModelRoot;
+import org.eclipse.linuxtools.oprofile.core.model.OpModelSymbol;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+import org.tizen.oprofile.core.processor.modeldata.parser.BinaryParser;
+import org.tizen.oprofile.core.processor.modeldata.parser.ClassesParser;
+import org.tizen.oprofile.core.processor.modeldata.parser.DetailTableParser;
+import org.tizen.oprofile.core.processor.modeldata.parser.SetupParser;
+import org.tizen.oprofile.core.processor.modeldata.parser.SymbolTableParser;
+
+public class OprofileSAXHandler extends DefaultHandler {
+
+
+       private String _valueStr;
+       private XMLParser _subParser = null;
+       
+       // setup - eventsetup | timersetup
+       private String SETUP_TAG = "setup";
+       // classes - class
+       private String CLASSES_TAG = "classes";
+       // binary - count | symbol | module
+       //                           module - count | symbol
+       //                                            symbol - count
+       private String BINARY_TAG = "binary";
+       private String BINARY_NAME_ATTR = "name";
+       // symboltable - symboldata
+       private String SYMBOLTABLE_TAG = "symboltable";
+       // detailtable - symboldetails - detaildata - count
+       private String DETAILTABLE_TAG = "detailtable";
+       
+       private OpModelRoot _model;
+       private HashMap<String, OpModelImage> _imageMap;
+       private HashMap<String, OpModelSymbol> _symbolMap;
+       
+       public OprofileSAXHandler(OpModelRoot model){
+               this._model = model;
+       }
+       
+       public void startDocument() {
+               _subParser = null;
+               _imageMap  = new HashMap<String, OpModelImage>();
+               _symbolMap = new HashMap<String, OpModelSymbol>();
+       }
+       
+       public void startElement(String uri, String localName, String name,
+                       Attributes attrs) throws SAXException {
+               
+//             System.out.print("<"+name);
+//             for(int i=0;i<attrs.getLength();i++){
+//                     System.out.print(" "+attrs.getQName(i)+"=\""+attrs.getValue(i)+"\"");
+//             }
+//             System.out.print(" >");
+               
+               if(_subParser!=null)
+                       _subParser.startElement(name, attrs, null);
+               
+               if (name.equals(SETUP_TAG)) {
+                       _subParser = new SetupParser(_imageMap);
+               }else if(name.equals(CLASSES_TAG)) {
+                       _subParser = new ClassesParser(_imageMap);
+               }else if (name.equals(BINARY_TAG)) {
+                       String binaryName = attrs.getValue(BINARY_NAME_ATTR);
+                       _subParser = new BinaryParser(binaryName,_imageMap, _symbolMap);
+               }else if (name.equals(SYMBOLTABLE_TAG)) {
+                       _subParser = new SymbolTableParser(_imageMap,_symbolMap);
+               }else if (name.equals(DETAILTABLE_TAG)) {
+                       _subParser = new DetailTableParser(_symbolMap);
+               }
+               
+       }
+       
+       public void characters(char[] buf, int start, int length)
+                       throws SAXException {
+               _valueStr = new String(buf, start, length);
+               
+//             System.out.print(_valueStr);
+               
+               if(_subParser!=null)
+                       _subParser.characters(_valueStr.trim(), null);
+       }
+
+       public void endElement(String uri, String localName, String name)
+                       throws SAXException {
+               
+//             System.out.println("</"+name+">");
+               
+               if (name.equals(SETUP_TAG)) {
+                       _subParser.release(_model);
+                       _subParser = null;
+               }else if(name.equals(CLASSES_TAG)) {
+                       _subParser = null;
+               }else if (name.equals(BINARY_TAG)) {
+                       _subParser.release(null);
+                       _subParser = null;
+               }else if (name.equals(SYMBOLTABLE_TAG)) {
+                       _subParser = null;
+               }else if (name.equals(DETAILTABLE_TAG)) {
+                       _subParser = null;
+               }
+               
+               if(_subParser!=null)
+                       _subParser.endElement(name, null);
+       }
+
+       
+}
diff --git a/org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/processor/modeldata/handler/XMLParser.java b/org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/processor/modeldata/handler/XMLParser.java
new file mode 100644 (file)
index 0000000..2a615a4
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ *  XMLParser
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Jaewon Lim <jaewon81.lim@samsung.com>
+ * Wonhyoung Park <wonhyoung2.park@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.oprofile.core.processor.modeldata.handler;
+
+import org.xml.sax.Attributes;
+
+/**
+ * A class which (minimally) parses XML documents. This class provides only basic
+ * support for collecting information from XML documents. It is intended to be subclassed,
+ * providing only common functionality for all parser classes.
+ * @see org.eclipse.linuxtools.oprofile.core.opxml.OpxmlRunner
+ */
+public class XMLParser {
+       // The characters in the current tag
+       protected String _characters;
+       
+       /**
+        * This method is called whenever the SAXHandler is about to invoke the
+        * processor for the first time on a given document.
+        * @param callData call data for the processor (usually the result is stored here)
+        */
+       public void reset(Object callData) {
+       };
+       
+       //jinu added at 20090620
+       public void release(Object callData) {
+       };
+       
+       /**
+        * This method is called whenever a new tag is seen in the document. By default,
+        * this process will clear the characters collected for the tag. Processors will typically
+        * call this baseclass method to setup for collecting new character information for a
+        * tag.
+        * @param name the name of the tag
+        * @param attrs the tag's attributes
+        * @param callData call data for the processor (usually the result is stored here)
+        */
+       public void startElement(String name, Attributes attrs, Object callData) {
+               _characters = new String();
+       }
+       
+       /**
+        * This method is called whenever the closing tag for an element is seen in the
+        * document.
+        * @param name the element which is ending
+        * @param callData call data for the processor (usually the result is stored here)
+        */
+       public void endElement(String name, Object callData) {
+       }
+       
+       /**
+        * This method is called whenever characters are seen in the document that are not in
+        *  a markup tag.
+        * @param chars the characters read
+        * @param callData call data for the processor (usually the result is stored here)
+        */
+       public void characters(String chars, Object callData) {
+               _characters = chars;
+       }
+}
diff --git a/org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/processor/modeldata/parser/BinaryParser.java b/org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/processor/modeldata/parser/BinaryParser.java
new file mode 100644 (file)
index 0000000..66cd444
--- /dev/null
@@ -0,0 +1,145 @@
+/*
+ *  Binary Parser
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Jaewon Lim <jaewon81.lim@samsung.com>
+ * Wonhyoung Park <wonhyoung2.park@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.oprofile.core.processor.modeldata.parser;
+
+import java.util.HashMap;
+
+import org.eclipse.linuxtools.oprofile.core.model.OpModelImage;
+import org.eclipse.linuxtools.oprofile.core.model.OpModelSymbol;
+import org.xml.sax.Attributes;
+
+import org.tizen.oprofile.core.processor.modeldata.handler.XMLParser;
+import org.tizen.oprofile.core.processor.modeldata.util.ParserUtil;
+
+public class BinaryParser extends XMLParser {
+//     private static BinaryParser parser;
+       
+       private XMLParser _subParser;
+       private Attributes _attrs;
+       private String _valueStr;
+       private int _level;
+       
+       private static final String COUNT_TAG = "count";
+       private static final String SYMBOL_TAG = "symbol"; 
+       private static final String SYMBOL_IDREF_ATTR = "idref"; 
+       private static final String MODULE_TAG = "module";
+       private static final String MODULE_NAME_ATTR = "name"; 
+       
+       private String _binaryName;
+       private HashMap<String, OpModelImage> _imageMap;
+       private HashMap<String, OpModelSymbol> _symbolMap;
+
+       public BinaryParser(String binaryName, 
+                       HashMap<String, OpModelImage> imageMap, 
+                       HashMap<String, OpModelSymbol> symbolMap){
+
+               this._level = 0;
+               this._binaryName = binaryName;
+               this._imageMap = imageMap;
+               this._symbolMap = symbolMap;
+       }
+       
+       
+       
+       public void startElement(String name, Attributes attrs, Object callData) {
+               _attrs = attrs;
+               
+               if(_subParser!=null)
+                       _subParser.startElement(name, attrs, callData);
+               
+               if (_level<=1 && name.equals(COUNT_TAG)) {
+                       _level = 1;
+               }else if (_level<=2 && name.equals(SYMBOL_TAG)) {
+                       _level = 2;
+                       String symbolIdRef =  attrs.getValue(SYMBOL_IDREF_ATTR);
+                       _subParser = new SymbolParser(symbolIdRef, _imageMap, _symbolMap);
+               }else if (_level<=3 && name.equals(MODULE_TAG)) {
+                       _level = 3;
+                       String moduleName =  attrs.getValue(MODULE_NAME_ATTR);
+                       _subParser = new ModuleParser(moduleName, _imageMap, _symbolMap);
+               }
+       }
+
+       public void characters(String str, Object callData) {
+               set_valueStr(str);
+               if(_subParser!=null)
+                       _subParser.characters(str, callData);
+       }
+
+       public void endElement(String name, Object callData) {
+               
+               if (_level<=1 && name.equals(COUNT_TAG)) {
+                       OpModelImage image = ParserUtil.getImage(_imageMap, ParserUtil.getImageKey(_attrs));
+                       image._setName(_binaryName);
+               }else if (_level<=2 && name.equals(SYMBOL_TAG)) {
+                       _subParser = null;
+               }else if (_level<=3 && name.equals(MODULE_TAG)) {
+                       _subParser = null;
+               }
+               
+               if(_subParser!=null)
+                       _subParser.endElement(name, callData);
+               
+       
+       }
+       
+       public void release(Object callData) {
+               OpModelImage[] images = _imageMap.values().toArray(new OpModelImage[_imageMap.size()]);
+               
+               for(int i=0;i<images.length;i++){
+                       setTotalCount(images[i]);
+               }
+               
+       }
+
+       private void setTotalCount(OpModelImage image) {
+               int symbolTotalCount = 0;
+               int dependentTotalCount = 0;
+               
+               OpModelSymbol[] symbols = image.getSymbols();
+               for(int i=0;i<symbols.length;i++){
+                       symbolTotalCount+=symbols[i].getCount();
+               }
+               
+               OpModelImage[] dependents = image.getDependents();
+               for(int i=0;i<dependents.length;i++){
+                       dependentTotalCount+=dependents[i].getCount();
+               }
+               
+               image._setDepCount(dependentTotalCount);
+               image._setCount(dependentTotalCount+symbolTotalCount);
+       }
+
+
+
+       public void set_valueStr(String _valueStr) {
+               this._valueStr = _valueStr;
+       }
+
+
+
+       public String get_valueStr() {
+               return _valueStr;
+       }
+
+       
+       
+}
diff --git a/org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/processor/modeldata/parser/ClassesParser.java b/org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/processor/modeldata/parser/ClassesParser.java
new file mode 100644 (file)
index 0000000..b29fb10
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ *  Classes Parser
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Jaewon Lim <jaewon81.lim@samsung.com>
+ * Wonhyoung Park <wonhyoung2.park@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.oprofile.core.processor.modeldata.parser;
+
+import java.util.HashMap;
+
+import org.eclipse.linuxtools.oprofile.core.model.OpModelImage;
+import org.xml.sax.Attributes;
+
+import org.tizen.oprofile.core.processor.modeldata.handler.XMLParser;
+
+
+public class ClassesParser extends XMLParser {
+//     private static ClassesParser parser;
+       
+       private Attributes _attrs;
+       
+       private static final String CLASS_TAG = "class";
+       private static final String CLASS_NAME_ATTR = "name";
+       private static final String CLASS_EVENT_ATTR = "event";
+
+       private HashMap<String, OpModelImage> _imageMap;
+
+       public ClassesParser(HashMap<String, OpModelImage> imageMap) {
+
+               this._imageMap = imageMap;
+       }
+
+       public void startElement(String name, Attributes attrs, Object callData) {
+               _attrs = attrs;
+       }
+
+       public void endElement(String name, Object callData) {
+               if (name.equals(CLASS_TAG)) {
+                       changeImageId(_attrs.getValue(CLASS_EVENT_ATTR), _attrs.getValue(CLASS_NAME_ATTR));
+               }
+       }
+
+       private void changeImageId(String eventId, String imageId) {
+               OpModelImage image = _imageMap.get(eventId);
+               if(image!=null){
+                       _imageMap.remove(eventId);
+                       _imageMap.put(imageId, image);
+               }
+       }
+
+}
diff --git a/org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/processor/modeldata/parser/DetailDataParser.java b/org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/processor/modeldata/parser/DetailDataParser.java
new file mode 100644 (file)
index 0000000..1adb7c0
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ *  Detail Data Parser
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Jaewon Lim <jaewon81.lim@samsung.com>
+ * Wonhyoung Park <wonhyoung2.park@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.oprofile.core.processor.modeldata.parser;
+
+import java.util.HashMap;
+
+import org.eclipse.linuxtools.oprofile.core.model.OpModelSample;
+import org.eclipse.linuxtools.oprofile.core.model.OpModelSymbol;
+import org.xml.sax.Attributes;
+
+import org.tizen.oprofile.core.processor.modeldata.handler.XMLParser;
+import org.tizen.oprofile.core.processor.modeldata.util.ParserUtil;
+
+
+public class DetailDataParser extends XMLParser {
+//     private static DetailDataParser parser;
+       
+       private Attributes _attrs;
+       private String _valueStr;
+       
+       private static final String COUNT_TAG = "count";
+
+       private String _symbolId;
+       private int _sampleLine;
+       private HashMap<String, OpModelSymbol> _symbolMap;
+
+       public DetailDataParser(String symbolId, int sampleLine, 
+                       HashMap<String, OpModelSymbol> symbolMap){
+
+               this._symbolId = symbolId;
+               this._sampleLine = sampleLine;
+               this._symbolMap = symbolMap;
+       }
+
+       public void startElement(String name, Attributes attrs, Object callData) {
+               _attrs = attrs;
+       }
+       
+       public void characters(String str, Object callData) {
+               _valueStr = str;
+       }
+
+       public void endElement(String name, Object callData) {
+               if (name.equals(COUNT_TAG)) {
+                       
+                       int count = Integer.parseInt(_valueStr);
+                       
+                       String imageId = ParserUtil.getImageKey(_attrs);
+                       OpModelSymbol symbol = _symbolMap.get(ParserUtil.getSymbolKey(imageId,_symbolId));
+                       
+                       OpModelSample sample = getSample(symbol, _sampleLine);
+                       if(sample==null){
+                               sample = new OpModelSample();
+                               sample._setCount(count);
+                               sample._setLine(_sampleLine);
+                               
+                               symbol._addSample(sample);
+                       }else{
+                               sample._setCount(sample.getCount()+count);
+                       }
+                               
+               }
+       }
+
+       private OpModelSample getSample(OpModelSymbol symbol, int sampleLine) {
+               OpModelSample[] samples = symbol.getSamples();
+               
+               for(int i=0;i<samples.length;i++){
+                       int line = samples[i].getLine();
+                       if(sampleLine==line)
+                               return samples[i];
+               }
+               
+               return null;
+               
+       }
+
+       
+}
diff --git a/org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/processor/modeldata/parser/DetailTableParser.java b/org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/processor/modeldata/parser/DetailTableParser.java
new file mode 100644 (file)
index 0000000..add682d
--- /dev/null
@@ -0,0 +1,94 @@
+/*
+ *  Detail Table Parser
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Jaewon Lim <jaewon81.lim@samsung.com>
+ * Wonhyoung Park <wonhyoung2.park@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.oprofile.core.processor.modeldata.parser;
+
+import java.util.HashMap;
+
+import org.eclipse.linuxtools.oprofile.core.model.OpModelSymbol;
+import org.xml.sax.Attributes;
+
+import org.tizen.oprofile.core.processor.modeldata.handler.XMLParser;
+
+
+
+public class DetailTableParser extends XMLParser {
+//     private static DetailTableParser parser;
+       
+       private XMLParser _subParser;
+       private Attributes _attrs;
+       private String _valueStr;
+       
+       private static final String SYMBOL_DETAILS_TAG = "symboldetails";
+       private static final String SYMBOL_DETAILS_ID_ATTR = "id";
+       
+       private HashMap<String, OpModelSymbol> _symbolMap;
+
+       public DetailTableParser(HashMap<String, OpModelSymbol> symbolMap){
+
+               this._symbolMap = symbolMap;
+       }
+       
+       public void startElement(String name, Attributes attrs, Object callData) {
+               set_attrs(attrs);
+               
+               if(_subParser!=null)
+                       _subParser.startElement(name, attrs, callData);
+               
+               if (name.equals(SYMBOL_DETAILS_TAG)) {
+                       String symbolId =  attrs.getValue(SYMBOL_DETAILS_ID_ATTR);
+                       _subParser = new SymbolDetailsParser(symbolId, _symbolMap);
+               }
+       }
+
+       public void characters(String str, Object callData) {
+               set_valueStr(str);
+               if(_subParser!=null)
+                       _subParser.characters(str, callData);
+       }
+       
+       public void endElement(String name, Object callData) {
+
+               if (name.equals(SYMBOL_DETAILS_TAG)) {
+                       _subParser = null;
+               }
+               
+               if(_subParser!=null)
+                       _subParser.endElement(name, callData);
+       }
+
+       public void set_attrs(Attributes _attrs) {
+               this._attrs = _attrs;
+       }
+
+       public Attributes get_attrs() {
+               return _attrs;
+       }
+
+       public void set_valueStr(String _valueStr) {
+               this._valueStr = _valueStr;
+       }
+
+       public String get_valueStr() {
+               return _valueStr;
+       }
+       
+
+}
diff --git a/org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/processor/modeldata/parser/ModuleParser.java b/org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/processor/modeldata/parser/ModuleParser.java
new file mode 100644 (file)
index 0000000..cadba05
--- /dev/null
@@ -0,0 +1,104 @@
+/*
+ * Module Parser 
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Jaewon Lim <jaewon81.lim@samsung.com>
+ * Wonhyoung Park <wonhyoung2.park@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.oprofile.core.processor.modeldata.parser;
+
+import java.util.HashMap;
+
+import org.eclipse.linuxtools.oprofile.core.model.OpModelImage;
+import org.eclipse.linuxtools.oprofile.core.model.OpModelSymbol;
+import org.xml.sax.Attributes;
+
+import org.tizen.oprofile.core.processor.modeldata.handler.XMLParser;
+import org.tizen.oprofile.core.processor.modeldata.util.ParserUtil;
+
+
+
+public class ModuleParser extends XMLParser {
+//     private static ModuleParser parser;
+       
+       private XMLParser _subParser;
+       private Attributes _attrs;
+       private String _valueStr;
+       private int _level;
+       
+       private static final String COUNT_TAG = "count";
+       private static final String SYMBOL_TAG = "symbol"; 
+       private static final String SYMBOL_IDREF_ATTR = "idref"; 
+       
+       private String _moduleName;
+       private HashMap<String, OpModelImage> _imageMap;
+       private HashMap<String, OpModelSymbol> _symbolMap;
+       private HashMap<String, OpModelImage> _dependentMap = new HashMap<String, OpModelImage>();
+
+       public ModuleParser(String moduleName,
+                       HashMap<String, OpModelImage> imageMap, 
+                       HashMap<String, OpModelSymbol> symbolMap){
+
+               this._level = 0;
+               this._moduleName = moduleName;
+               this._imageMap = imageMap;
+               this._symbolMap = symbolMap;
+       }
+       
+       public void startElement(String name, Attributes attrs, Object callData) {
+               _attrs = attrs;
+               
+               if(_subParser!=null)
+                       _subParser.startElement(name, attrs, callData);
+               
+               if (_level<=1 && name.equals(COUNT_TAG)) {
+                       _level = 1;
+               }else if (_level<=2 && name.equals(SYMBOL_TAG)) {
+                       _level = 2;
+                       String symbolIdRef =  attrs.getValue(SYMBOL_IDREF_ATTR);
+                       _subParser = new ModuleSymbolParser(symbolIdRef, _dependentMap, _symbolMap);
+               }
+       }
+
+       public void characters(String str, Object callData) {
+               _valueStr = str;
+               if(_subParser!=null)
+                       _subParser.characters(str, callData);
+       }
+
+       public void endElement(String name, Object callData) {
+
+               if (_level<=1 && name.equals(COUNT_TAG)) {
+                       OpModelImage dependent = new OpModelImage();
+                       dependent._setCount(Integer.parseInt(_valueStr));
+                       dependent._setName(_moduleName);
+                       
+                       String imageId = ParserUtil.getImageKey(_attrs);
+                       
+                       OpModelImage image = ParserUtil.getImage(_imageMap, imageId);
+                       image._addDependent(dependent);
+                       
+                       _dependentMap.put(imageId, dependent);
+               }else if (_level<=2 && name.equals(SYMBOL_TAG)) {
+                       _subParser = null;
+               }
+               
+               if(_subParser!=null)
+                       _subParser.endElement(name, null);
+       }
+       
+       
+}
diff --git a/org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/processor/modeldata/parser/ModuleSymbolParser.java b/org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/processor/modeldata/parser/ModuleSymbolParser.java
new file mode 100644 (file)
index 0000000..faa9f80
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ *  Module Symbol Parser
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Jaewon Lim <jaewon81.lim@samsung.com>
+ * Wonhyoung Park <wonhyoung2.park@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.oprofile.core.processor.modeldata.parser;
+
+import java.util.HashMap;
+
+import org.eclipse.linuxtools.oprofile.core.model.OpModelImage;
+import org.eclipse.linuxtools.oprofile.core.model.OpModelSymbol;
+import org.xml.sax.Attributes;
+
+import org.tizen.oprofile.core.processor.modeldata.handler.XMLParser;
+import org.tizen.oprofile.core.processor.modeldata.util.ParserUtil;
+
+
+public class ModuleSymbolParser extends XMLParser {
+//     private static ModuleSymbolParser parser;
+       
+       private Attributes _attrs;
+       private String _valueStr;
+       
+       private static final String COUNT_TAG = "count";
+       
+       private String _idRef;
+       private HashMap<String, OpModelImage> _dependentMap;
+       private HashMap<String, OpModelSymbol> _symbolMap;
+       
+       public ModuleSymbolParser(String idRef,
+                       HashMap<String, OpModelImage> dependentMap, 
+                       HashMap<String, OpModelSymbol> symbolMap) {
+
+               this._idRef = idRef;
+               this._dependentMap = dependentMap;
+               this._symbolMap = symbolMap;
+       }
+
+
+       public void startElement(String name, Attributes attrs, Object callData) {
+               _attrs = attrs;
+       }
+       
+       public void characters(String str, Object callData) {
+               _valueStr = str;
+       }
+
+       public void endElement(String name, Object callData) {
+               if (name.equals(COUNT_TAG)) {
+                       OpModelSymbol symbol = new OpModelSymbol();
+                       symbol._setCount(Integer.parseInt(_valueStr));
+
+                       String imageId = ParserUtil.getImageKey(_attrs);
+                       OpModelImage dependent = ParserUtil.getImage(_dependentMap, imageId);
+                       dependent._addSymbol(symbol);
+                       
+                       _symbolMap.put(ParserUtil.getSymbolKey(imageId,_idRef), symbol);
+               }
+       }
+
+
+}
diff --git a/org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/processor/modeldata/parser/SetupParser.java b/org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/processor/modeldata/parser/SetupParser.java
new file mode 100644 (file)
index 0000000..6c841ae
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ * Setup Parser 
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Jaewon Lim <jaewon81.lim@samsung.com>
+ * Wonhyoung Park <wonhyoung2.park@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.oprofile.core.processor.modeldata.parser;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import org.eclipse.linuxtools.oprofile.core.model.OpModelEvent;
+import org.eclipse.linuxtools.oprofile.core.model.OpModelImage;
+import org.eclipse.linuxtools.oprofile.core.model.OpModelRoot;
+import org.eclipse.linuxtools.oprofile.core.model.OpModelSession;
+import org.xml.sax.Attributes;
+
+import org.tizen.oprofile.core.processor.modeldata.handler.XMLParser;
+import org.tizen.oprofile.core.processor.modeldata.util.ParserUtil;
+
+public class SetupParser extends XMLParser {
+//     private static SetupParser parser;
+       
+       private Attributes _attrs;
+       
+       private static final String EVENTSETUP_TAG = "eventsetup";
+       private static final String EVENTSETUP_EVENTNAME_ATTR = "eventname";
+       private static final String EVENTSETUP_ID_ATTR = "id";
+       private static final String TIMERSETUP_TAG = "timersetup";
+
+       private final String DEFAULT_SESSION_NAME = "current";
+       private final String TIMER_EVENT_NAME = "TIMER";
+
+       private ArrayList<OpModelEvent> _eventList = new ArrayList<OpModelEvent>();
+       private HashMap<String, OpModelImage> _imageMap;
+
+       public SetupParser(HashMap<String, OpModelImage> imageMap) {
+               this._imageMap = imageMap;
+       }
+
+
+       public void startElement(String name, Attributes attrs, Object callData) {
+               _attrs = attrs;
+       }
+
+       public void endElement(String name, Object callData) {
+               String eventName = _attrs.getValue(EVENTSETUP_EVENTNAME_ATTR);
+               String eventId = _attrs.getValue(EVENTSETUP_ID_ATTR)==null?ParserUtil.DEFAULT_EVENT_ID:_attrs.getValue(EVENTSETUP_ID_ATTR);
+               
+               if (name.equals(EVENTSETUP_TAG)) {
+                       addEvent(eventId, eventName);
+               } else if (name.equals(TIMERSETUP_TAG)) {
+                       addEvent(eventId, TIMER_EVENT_NAME);
+               }
+       }
+
+       private void addEvent(String eventId, String eventName) {
+               OpModelEvent event = new OpModelEvent(eventName);
+               OpModelImage image = new OpModelImage();
+
+               OpModelSession[] sessions = new OpModelSession[1];
+               sessions[0] = new OpModelSession(event, DEFAULT_SESSION_NAME);
+               sessions[0]._setImage(image);
+
+               event._setSessions(sessions);
+               
+               _eventList.add(event);
+               _imageMap.put(eventId,image);
+       }
+
+       public void release(Object data) {
+               changeImageId();
+               
+               OpModelRoot model = (OpModelRoot) data;
+               model._setEvents(_eventList.toArray(new OpModelEvent[_eventList.size()]));
+       }
+
+       private void changeImageId() {
+               if(_imageMap.size()==1){
+                       OpModelImage[] image = _imageMap.values().toArray(new OpModelImage[1]);
+                       _imageMap.remove(image[0]);
+                       _imageMap.put(ParserUtil.DEFAULT_EVENT_ID,image[0]);
+               }
+       }
+}
diff --git a/org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/processor/modeldata/parser/SymbolDetailsParser.java b/org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/processor/modeldata/parser/SymbolDetailsParser.java
new file mode 100644 (file)
index 0000000..989d02c
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+ *  Symbol Details Parser
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Jaewon Lim <jaewon81.lim@samsung.com>
+ * Wonhyoung Park <wonhyoung2.park@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.oprofile.core.processor.modeldata.parser;
+
+import java.util.HashMap;
+
+import org.eclipse.linuxtools.oprofile.core.model.OpModelSymbol;
+import org.xml.sax.Attributes;
+
+import org.tizen.oprofile.core.processor.modeldata.handler.XMLParser;
+
+
+
+public class SymbolDetailsParser extends XMLParser {
+//     private static SymbolDetailsParser parser;
+       
+       private XMLParser _subParser;
+       private Attributes _attrs;
+       private String _valueStr;
+       
+       private static final String DETAIL_DATA_TAG = "detaildata";
+       private static final String DETAIL_DATA_LINE_ATTR = "line";
+       
+       private String _symbolId;
+       private HashMap<String, OpModelSymbol> _symbolMap;
+
+       public SymbolDetailsParser(String symboldId,
+                       HashMap<String, OpModelSymbol> symbolMap){
+
+               this._symbolId = symboldId;
+               this._symbolMap = symbolMap;
+       }
+       
+       public void startElement(String name, Attributes attrs, Object callData) {
+               set_attrs(attrs);
+               
+               if(_subParser!=null)
+                       _subParser.startElement(name, attrs, callData);
+               
+               
+               if (name.equals(DETAIL_DATA_TAG)) {
+                       String sampleLine =  attrs.getValue(DETAIL_DATA_LINE_ATTR);
+                       int line = sampleLine==null?0:Integer.parseInt(sampleLine);
+                       _subParser = new DetailDataParser(_symbolId,line, _symbolMap);
+               }
+                
+       }
+
+       public void characters(String str, Object callData) {
+               set_valueStr(str);
+               if(_subParser!=null)
+                       _subParser.characters(str, callData);
+               
+       }
+       
+       public void endElement(String name, Object callData) {
+
+               if (name.equals(DETAIL_DATA_TAG))
+                       _subParser = null;
+               
+               
+               if(_subParser!=null)
+                       _subParser.endElement(name, callData);
+               
+       }
+
+       public void set_attrs(Attributes _attrs) {
+               this._attrs = _attrs;
+       }
+
+       public Attributes get_attrs() {
+               return _attrs;
+       }
+
+       public void set_valueStr(String _valueStr) {
+               this._valueStr = _valueStr;
+       }
+
+       public String get_valueStr() {
+               return _valueStr;
+       }
+       
+
+}
diff --git a/org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/processor/modeldata/parser/SymbolParser.java b/org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/processor/modeldata/parser/SymbolParser.java
new file mode 100644 (file)
index 0000000..c899e97
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ *  Symbol Parser
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Jaewon Lim <jaewon81.lim@samsung.com>
+ * Wonhyoung Park <wonhyoung2.park@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.oprofile.core.processor.modeldata.parser;
+
+import java.util.HashMap;
+
+import org.eclipse.linuxtools.oprofile.core.model.OpModelImage;
+import org.eclipse.linuxtools.oprofile.core.model.OpModelSymbol;
+import org.xml.sax.Attributes;
+
+import org.tizen.oprofile.core.processor.modeldata.handler.XMLParser;
+import org.tizen.oprofile.core.processor.modeldata.util.ParserUtil;
+
+
+public class SymbolParser extends XMLParser {
+//     private static SymbolParser parser;
+       
+       private Attributes _attrs;
+       private String _valueStr;
+       
+       private static final String COUNT_TAG = "count";
+       
+       private String _idRef;
+       private HashMap<String, OpModelImage> _imageMap;
+       private HashMap<String, OpModelSymbol> _symbolMap;
+       
+       public SymbolParser(String idRef,
+                       HashMap<String, OpModelImage> imageMap, 
+                       HashMap<String, OpModelSymbol> symbolMap) {
+
+               this._idRef = idRef;
+               this._imageMap = imageMap;
+               this._symbolMap = symbolMap;
+       }
+
+
+       public void startElement(String name, Attributes attrs, Object callData) {
+               _attrs = attrs;
+       }
+       
+       public void characters(String str, Object callData) {
+               _valueStr = str;
+       }
+
+       public void endElement(String name, Object callData) {
+               if (name.equals(COUNT_TAG)) {
+                       OpModelSymbol symbol = new OpModelSymbol();
+                       symbol._setCount(Integer.parseInt(_valueStr));
+
+                       String imageId = ParserUtil.getImageKey(_attrs);
+                       OpModelImage image = ParserUtil.getImage(_imageMap, imageId);
+                       image._addSymbol(symbol);
+                       
+                       _symbolMap.put(ParserUtil.getSymbolKey(imageId,_idRef), symbol);
+               }
+       }
+
+
+}
diff --git a/org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/processor/modeldata/parser/SymbolTableParser.java b/org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/processor/modeldata/parser/SymbolTableParser.java
new file mode 100644 (file)
index 0000000..5eaa14b
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ *  Symbol Table Parser
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Jaewon Lim <jaewon81.lim@samsung.com>
+ * Wonhyoung Park <wonhyoung2.park@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.oprofile.core.processor.modeldata.parser;
+
+import java.util.HashMap;
+
+import org.eclipse.linuxtools.oprofile.core.model.OpModelImage;
+import org.eclipse.linuxtools.oprofile.core.model.OpModelSymbol;
+import org.xml.sax.Attributes;
+
+import org.tizen.oprofile.core.processor.modeldata.handler.XMLParser;
+import org.tizen.oprofile.core.processor.modeldata.util.ParserUtil;
+
+
+public class SymbolTableParser extends XMLParser {
+//     private static SymbolTableParser parser;
+       
+       private Attributes _attrs;
+       
+       private static final String SYMBOLDATA_TAG = "symboldata";
+       private static final String SYMBOLDATA_ID_ATTR = "id";
+       private static final String SYMBOLDATA_NAME_ATTR = "name";
+       private static final String SYMBOLDATA_FILE_ATTR = "file";
+       private static final String SYMBOLDATA_LINE_ATTR = "line";
+
+       private String[] _imageIds;
+       private HashMap<String, OpModelSymbol> _symbolMap;
+
+       public SymbolTableParser(HashMap<String,OpModelImage> imageMap,
+                       HashMap<String, OpModelSymbol> symbolMap) {
+
+               this._imageIds = imageMap.keySet().toArray(new String[imageMap.size()]);
+               this._symbolMap = symbolMap;
+       }
+
+
+       public void startElement(String name, Attributes attrs, Object callData) {
+               _attrs = attrs;
+       }
+
+       public void endElement(String name, Object callData) {
+               if (name.equals(SYMBOLDATA_TAG)) {
+                       String symbolId = _attrs.getValue(SYMBOLDATA_ID_ATTR);
+                       String symbolName = _attrs.getValue(SYMBOLDATA_NAME_ATTR);
+                       String symbolFile = _attrs.getValue(SYMBOLDATA_FILE_ATTR);
+                       String symbolLine = _attrs.getValue(SYMBOLDATA_LINE_ATTR);
+                       
+                       setSymbolDetail(symbolId, symbolName, symbolFile, symbolLine);
+               }
+       }
+       
+
+       private void setSymbolDetail(String symbolId, String symbolName, String symbolFile, String symbolLine) {
+               for(String imageId : _imageIds){
+                       OpModelSymbol symbol = _symbolMap.get(ParserUtil.getSymbolKey(imageId,symbolId));
+                       if(symbol!=null){
+                               if(symbolFile!=null)
+                                       symbol._setFile(symbolFile);
+                               symbol._setName(symbolName);
+                       }
+               }
+       }
+
+}
diff --git a/org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/processor/modeldata/util/ParserUtil.java b/org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/processor/modeldata/util/ParserUtil.java
new file mode 100644 (file)
index 0000000..4063b2b
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ *  Parser Util
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Jaewon Lim <jaewon81.lim@samsung.com>
+ * Wonhyoung Park <wonhyoung2.park@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.oprofile.core.processor.modeldata.util;
+
+import java.util.HashMap;
+
+import org.eclipse.linuxtools.oprofile.core.model.OpModelImage;
+import org.xml.sax.Attributes;
+
+public abstract class ParserUtil {
+       
+       private static final String COUNT_CLASS_ATTR = "class";
+       public static final String DEFAULT_EVENT_ID = "";
+
+       public static String getImageKey(Attributes attrs) {
+               String key = attrs.getValue(COUNT_CLASS_ATTR);
+               return key==null?DEFAULT_EVENT_ID:key;
+       }
+       
+       public static String getSymbolKey(String imageId, String symbolId) {
+               if(imageId==null||imageId.equals(DEFAULT_EVENT_ID))
+                       return symbolId;
+               else
+                       return imageId+":"+symbolId;
+       }       
+       
+       public static OpModelImage getImage(HashMap<String, OpModelImage> imageMap, String imageId) {
+               String key = imageId==null?DEFAULT_EVENT_ID:imageId;
+               return imageMap.get(key);
+       }
+       
+       
+       
+}
diff --git a/org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/processor/sessions/SessionsProcessor.java b/org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/processor/sessions/SessionsProcessor.java
new file mode 100644 (file)
index 0000000..1839831
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * Sessions Processor 
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Jaewon Lim <jaewon81.lim@samsung.com>
+ * Wonhyoung Park <wonhyoung2.park@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.oprofile.core.processor.sessions;
+
+import java.util.ArrayList;
+
+import org.eclipse.linuxtools.oprofile.core.Oprofile;
+import org.eclipse.linuxtools.oprofile.core.model.OpModelEvent;
+import org.eclipse.linuxtools.oprofile.core.model.OpModelSession;
+
+import org.tizen.oprofile.core.CommandManager;
+import org.tizen.oprofile.core.OprofileCommonConstants;
+
+
+public class SessionsProcessor{
+       
+       public SessionsProcessor() throws InterruptedException{
+       }
+       
+       private final String DEFAULT_SESSION_NAME = "current";
+       private final String TIMER_EVENT = "TIMER";
+       private final String COMMAND_SESSION_EVENT =OprofileCommonConstants.COMMAND_OPCONTROL+" --status 2> /dev/null | grep ^Event";
+       
+       public void parse(ArrayList<OpModelEvent> eventList) throws InterruptedException{
+               if(Oprofile.getTimerMode()){
+                       addTimerEvent(eventList);
+                       return;
+               }
+               
+               String[] resultStr= null;
+               
+               resultStr = CommandManager.runCommandReturningResultArray(COMMAND_SESSION_EVENT);
+               
+               if(resultStr==null||resultStr.length == 0 )
+                       return;
+               
+               
+               for(int i=0;i<resultStr.length;i++){
+                       String str = resultStr[i];
+                       addEvent(eventList, str);
+               }
+}
+
+       private void addTimerEvent(ArrayList<OpModelEvent> eventList) {
+               OpModelEvent event = new OpModelEvent(TIMER_EVENT);
+               
+               OpModelSession[] sessions = new OpModelSession[1];
+               sessions[0] = new OpModelSession(event,DEFAULT_SESSION_NAME);
+               
+               event._setSessions(sessions);
+               
+               eventList.add(event);
+       }
+
+       private void addEvent(ArrayList<OpModelEvent> eventList, String str) {
+               String[] strs = str.split(":");
+               
+               if(strs.length<6)
+                       return;
+               
+               OpModelEvent event = new OpModelEvent(strs[1].trim());
+               
+               OpModelSession[] sessions = new OpModelSession[1];
+               sessions[0] = new OpModelSession(event,DEFAULT_SESSION_NAME);
+               
+               event._setSessions(sessions);
+               eventList.add(event);
+       }
+       
+       
+}
diff --git a/org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/provider/OpcontrolDataProvider.java b/org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/provider/OpcontrolDataProvider.java
new file mode 100644 (file)
index 0000000..9925475
--- /dev/null
@@ -0,0 +1,129 @@
+/*
+ *  Opcontrol Data Provider
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Jaewon Lim <jaewon81.lim@samsung.com>
+ * Wonhyoung Park <wonhyoung2.park@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.oprofile.core.provider;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.linuxtools.oprofile.core.daemon.OpInfo;
+import org.eclipse.linuxtools.oprofile.core.model.OpModelEvent;
+import org.eclipse.linuxtools.oprofile.core.model.OpModelRoot;
+
+import org.tizen.oprofile.core.processor.checkevent.CheckEventsProcessor;
+import org.tizen.oprofile.core.processor.checkkernel.CheckKernelProcessor;
+import org.tizen.oprofile.core.processor.eventinfo.EventListProcessor;
+import org.tizen.oprofile.core.processor.eventinfo.OpInfoProcessor;
+import org.tizen.oprofile.core.processor.modeldata.ModelDataProcessor;
+import org.tizen.oprofile.core.processor.sessions.SessionsProcessor;
+import org.xml.sax.SAXException;
+
+public abstract class OpcontrolDataProvider{
+       
+       
+       public static IRunnableWithProgress getEventInfo(final OpInfo info) {
+               IRunnableWithProgress runnable = new IRunnableWithProgress() {
+                       public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+//                             if(!OprofileComm.checkTarget()) return;
+                               
+                               new OpInfoProcessor(info).parse();
+                               
+                               if(!info.getTimerMode()){
+                                       new EventListProcessor(info).parse();
+                               }
+                       
+                       }
+               };
+               
+               return runnable;
+       }
+       
+       public static IRunnableWithProgress checkEvent(final String event, final int count, final int unitmask, final int[] result) {
+               IRunnableWithProgress runnable = new IRunnableWithProgress() {
+                       public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+//                             if(!OprofileComm.checkTarget()) return;
+
+                               new CheckEventsProcessor().parse(event,count, unitmask,result);
+                       
+                       }
+               };
+               
+               return runnable;
+       }
+       
+       
+       public static IRunnableWithProgress getEventList(final ArrayList<OpModelEvent> eventList) {
+               IRunnableWithProgress runnable = new IRunnableWithProgress() {
+                       public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+//                             if(!OprofileComm.checkTarget()) return;
+                               //ISession session = OprofileComm.getSession();
+                               
+                               new SessionsProcessor().parse(eventList);
+                       }
+               };
+               
+               return runnable;
+       }
+       
+       public static IRunnableWithProgress getModelData(final OpModelRoot model) {
+               IRunnableWithProgress runnable = new IRunnableWithProgress() {
+                       public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+//                             if(!OprofileComm.checkTarget()) return;
+                               //ISession session = OprofileComm.getSession();
+                               
+                               try {
+                                       new ModelDataProcessor(model).parse();
+                               } catch (InterruptedException e) {
+                                       throw new InterruptedException();
+                               } catch (SAXException e) {
+                                       throw new InterruptedException();
+                               } catch (IOException e) {
+                                       throw new InterruptedException();
+                               } catch (ParserConfigurationException e) {
+                                       throw new InterruptedException();
+                               }
+                       }
+               };
+               
+               return runnable;
+       }
+
+       public static IRunnableWithProgress checkKernelModule(final String[] result) {
+               IRunnableWithProgress runnable = new IRunnableWithProgress() {
+                       public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+//                             if(!OprofileComm.checkTarget()) return;
+                               //ISession session = OprofileComm.getSession();
+                               
+                               new CheckKernelProcessor().parse(result);
+                       
+                       }
+               };
+               
+               return runnable;
+       }
+       
+               
+       
+}
diff --git a/org.eclipse.linuxtools.oprofile.launch.exe/.classpath b/org.eclipse.linuxtools.oprofile.launch.exe/.classpath
new file mode 100644 (file)
index 0000000..4c62a80
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+       <classpathentry kind="src" path="src"/>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.eclipse.linuxtools.oprofile.launch.exe/.project b/org.eclipse.linuxtools.oprofile.launch.exe/.project
new file mode 100644 (file)
index 0000000..3f9c10a
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.eclipse.linuxtools.oprofile.launch.exe</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.ManifestBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.SchemaBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.pde.PluginNature</nature>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>
diff --git a/org.eclipse.linuxtools.oprofile.launch.exe/.settings/org.eclipse.core.resources.prefs b/org.eclipse.linuxtools.oprofile.launch.exe/.settings/org.eclipse.core.resources.prefs
new file mode 100644 (file)
index 0000000..fcc43a9
--- /dev/null
@@ -0,0 +1,3 @@
+#Wed Dec 01 09:13:21 CET 2010
+eclipse.preferences.version=1
+encoding/<project>=UTF-8
diff --git a/org.eclipse.linuxtools.oprofile.launch.exe/.settings/org.eclipse.core.runtime.prefs b/org.eclipse.linuxtools.oprofile.launch.exe/.settings/org.eclipse.core.runtime.prefs
new file mode 100644 (file)
index 0000000..f02480a
--- /dev/null
@@ -0,0 +1,3 @@
+#Tue Dec 14 16:36:28 CET 2010
+eclipse.preferences.version=1
+line.separator=\n
diff --git a/org.eclipse.linuxtools.oprofile.launch.exe/META-INF/MANIFEST.MF b/org.eclipse.linuxtools.oprofile.launch.exe/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..85e7045
--- /dev/null
@@ -0,0 +1,37 @@
+Manifest-Version: 1.0
+Require-Bundle: org.eclipse.core.runtime;bundle-version="3.4.0",
+ org.eclipse.ui;bundle-version="3.4.0",
+ org.eclipse.cdt.core;bundle-version="5.2.1",
+ org.eclipse.cdt.debug.core;bundle-version="5.0.1",
+ org.eclipse.cdt.launch;bundle-version="6.1.0",
+ org.eclipse.linuxtools.oprofile.core,
+ org.eclipse.linuxtools.oprofile.launch,
+ org.eclipse.debug.ui;bundle-version="3.4.2",
+ org.eclipse.linuxtools.profiling.launch,
+ org.tizen.common,
+ org.tizen.common.connection,
+ org.tizen.nativecommon
+Bundle-Vendor: Eclipse Linux Tools
+Bundle-Version: 1.3.18.qualifier
+Bundle-Name: Tizen SDK Oprofile Exe Launch
+Bundle-ManifestVersion: 2
+Import-Package: org.eclipse.cdt.debug.core,
+ org.eclipse.cdt.managedbuilder.core,
+ org.eclipse.debug.core,
+ org.eclipse.linuxtools.oprofile.core,
+ org.eclipse.linuxtools.oprofile.core.daemon,
+ org.eclipse.linuxtools.oprofile.ui,
+ org.eclipse.linuxtools.oprofile.ui.view,
+ org.eclipse.ui,
+ org.tizen.nativecommon.launch,
+ org.tizen.nativecommon.launch.ui,
+ org.tizen.sdblib
+Bundle-SymbolicName: org.eclipse.linuxtools.oprofile.launch.exe;singleton:=true
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-Activator: org.tizen.oprofile.launch.Activator
+Export-Package: org.tizen.oprofile.launch
+
+
+
+
+
diff --git a/org.eclipse.linuxtools.oprofile.launch.exe/NOTICE b/org.eclipse.linuxtools.oprofile.launch.exe/NOTICE
new file mode 100644 (file)
index 0000000..ece0184
--- /dev/null
@@ -0,0 +1,65 @@
+2010-01-25 Dawid Kozinski <d.kozinski@samsung.com>
+       * plugin.xml : add cnature property
+
+2010-02-03 SPRC SDK Team <d.kozinski@samsung.com>
+       * MANIFEST.MF : changed some package names
+       * plugin.xml : changed some package names
+
+2010-02-10 SPRC SDK Team <d.kozinski@samsung.com>
+       * MANIFEST.MF : remove Bundle-Localization, fix Bundle-Activator
+
+2010-07-14 HyungJong, Shin <hj_shin@samsung.com>
+       * plugin.xml : delete daemon property
+       
+2010-07-23 HyungJong, Shin <hj_shin@samsung.com>
+       * NormalOprofileDeployer.java : application launching exception message shows several times.==> solved
+       
+2010-11-05 sdk <sdk@sdk-laptop.(none)>
+       * MANIFEST.MF : changed some package name
+       * plugin.xml : changed some package name
+
+2010-11-09 DongGi Jang <dg0402.jang.samsung.com>
+       * MANIFEST.MF : changed launcher name
+
+2011-06-07 jaewon81.lim <jaewon81.lim@samsung.com>
+       * MANIFEST.MF : modify imported package name of freshide.common.ui
+
+2011-06-09 jaewon81.lim <jaewon81.lim@samsung.com>
+       * MANIFEST.MF : rearrange plugins dependency
+
+2011-07-13 jaewon81.lim <jaewon81.lim@samsung.com>
+       * MANIFEST.MF : modified import package name
+
+2011-08-22 joogwan.kim <joogwan.kim@samsung.com>
+       * MANIFEST.MF : Change plug-in name
+
+2011-08-25 wonhyoung2.park <wonhyoung2.park@samsung.com>
+       * MANIFEST.MF : plugin provider and name modified
+
+2011-09-28 wonhyoung2.park <wonhyoung2.park@samsung.com>
+       * SLPOprofileLaunchDelegate.java : add oprofile build configuration selection routine
+
+2011-11-16 wonhyoung2.park <wonhyoung2.park@samsung.com>
+       * MANIFEST.MF : Profiler sdb apply
+
+2011-11-22 taeyoung2.son <taeyoung2.son@samsung.com>
+       * MANIFEST.MF :  Modify SDK naming from "SLP(or Samsung Linux Platform)" to "Tizen"
+       * plugin.xml :  Modify SDK naming from "SLP(or Samsung Linux Platform)" to "Tizen"
+
+2011-11-29 wonhyoung2.park <wonhyoung2.park@samsung.com>
+       * MANIFEST.MF : chagne slp to tizen
+       * plugin.xml : chagne slp to tizen
+
+2011-12-02 taeyoung2.son <taeyoung2.son@samsung.com>
+       * MANIFEST.MF : Delete dependency feature's version value.
+
+2011-12-03 wonhyoung2.park <wonhyoung2.park@samsung.com>
+       * MANIFEST.MF : package instll routine chage
+
+2011-12-04 wonhyoung2.park <wonhyoung2.park@samsung.com>
+       * MANIFEST.MF : change oprofile install
+       * plugin.xml : change oprofile install
+
+2011-12-12 wonhyoung2.park <wonhyoung2.park@samsung.com>
+       * plugin.xml : profile menu only show in native perspective
+
diff --git a/org.eclipse.linuxtools.oprofile.launch.exe/build.properties b/org.eclipse.linuxtools.oprofile.launch.exe/build.properties
new file mode 100644 (file)
index 0000000..90406de
--- /dev/null
@@ -0,0 +1,8 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               .,\
+               plugin.xml,\
+               icons/
+javacSource = 1.6
+javacTarget = 1.6
diff --git a/org.eclipse.linuxtools.oprofile.launch.exe/icons/event_tab.gif b/org.eclipse.linuxtools.oprofile.launch.exe/icons/event_tab.gif
new file mode 100644 (file)
index 0000000..c91f254
Binary files /dev/null and b/org.eclipse.linuxtools.oprofile.launch.exe/icons/event_tab.gif differ
diff --git a/org.eclipse.linuxtools.oprofile.launch.exe/icons/global_tab.gif b/org.eclipse.linuxtools.oprofile.launch.exe/icons/global_tab.gif
new file mode 100644 (file)
index 0000000..ec6cca4
Binary files /dev/null and b/org.eclipse.linuxtools.oprofile.launch.exe/icons/global_tab.gif differ
diff --git a/org.eclipse.linuxtools.oprofile.launch.exe/icons/profile_run.png b/org.eclipse.linuxtools.oprofile.launch.exe/icons/profile_run.png
new file mode 100644 (file)
index 0000000..4f8488f
Binary files /dev/null and b/org.eclipse.linuxtools.oprofile.launch.exe/icons/profile_run.png differ
diff --git a/org.eclipse.linuxtools.oprofile.launch.exe/plugin.xml b/org.eclipse.linuxtools.oprofile.launch.exe/plugin.xml
new file mode 100644 (file)
index 0000000..86eb610
--- /dev/null
@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+       <extension
+         point="org.eclipse.debug.core.launchConfigurationTypes">
+      <launchConfigurationType
+            delegate="org.tizen.oprofile.launch.TizenOprofileLaunchDelegate"
+            id="org.eclipse.linuxtools.oprofile.launch.oprofile"
+            modes="profile"
+            name="Profile With OProfile"
+            public="true">
+      </launchConfigurationType>      
+   </extension>
+   <extension
+         point="org.eclipse.debug.ui.launchConfigurationTypeImages">
+      <launchConfigurationTypeImage
+            configTypeID="org.eclipse.linuxtools.oprofile.launch.oprofile"
+            icon="icons/profile_run.png"
+            id="org.eclipse.linuxtools.oprofile.launch.oprofileImage">
+      </launchConfigurationTypeImage>
+   </extension>        
+   <extension
+         point="org.eclipse.debug.ui.launchConfigurationTabGroups">
+      <launchConfigurationTabGroup
+            class="org.tizen.oprofile.launch.configuration.NormalOprofileLaunchConfigurationTabGroup"
+            id="org.eclipse.linuxtools.oprofile.launch.launchConfigurationTabGroup"
+            type="org.eclipse.linuxtools.oprofile.launch.oprofile">
+      </launchConfigurationTabGroup>
+   </extension>
+   <extension
+         point="org.eclipse.debug.ui.launchShortcuts">
+      <shortcut
+            class="org.tizen.oprofile.launch.NormalOprofileLaunchShortcut"
+            icon="icons/profile_run.png"
+            id="org.eclipse.linuxtools.oprofile.launch.profileshortcut"
+            label="Profile With OProfile"
+            modes="profile">
+        <contextualLaunch>
+            <enablement>
+                <with variable="selection">
+                <count value="1"/>
+                <iterate>
+                    <or>
+                        <instanceof value="org.eclipse.cdt.core.model.IBinary"/>
+                        <instanceof value="org.eclipse.cdt.core.model.ICProject"/>
+                        <test
+                            forcePluginActivation="true"
+                            property="org.eclipse.cdt.launch.isExecutable"/>
+                        <test
+                            forcePluginActivation="true"
+                            property="org.eclipse.cdt.launch.isCProject"/>
+                        <and>
+                            <instanceof value="org.eclipse.ui.IFileEditorInput"/>
+                            <adapt type="org.eclipse.core.resources.IResource">
+                                <adapt type="org.eclipse.cdt.core.model.ICElement"/>
+                            </adapt>
+                        </and>
+                    </or>
+                </iterate>
+                </with>
+            </enablement>
+        </contextualLaunch>
+        <description
+            mode="profile"
+            description="Profile a Tizen application with Oprofile"/>
+        <configurationType
+               id="org.eclipse.linuxtools.oprofile.launch.oprofile">
+        </configurationType>
+      </shortcut>
+   </extension>
+   <extension
+         id="org.tizen.oprofile.tool"
+         point="org.tizen.common.connection.tools">
+      <tools
+            packagename="oprofile"
+            sourcepath="/on-demand">
+      </tools>
+   </extension>
+   <extension
+         point="org.eclipse.ui.activities">
+      <activity
+            id="org.eclipse.linuxtools.oprofile.launch.exe.activity"
+            name="name">
+         <enabledWhen>
+            <with
+                  variable="activeWorkbenchWindow.activePerspective">
+               <and>
+                  <equals
+                        value="org.tizen.nativeapp.perspective">
+                  </equals>
+               </and>
+            </with>
+         </enabledWhen>
+      </activity>
+      <activityPatternBinding
+            activityId="org.eclipse.linuxtools.oprofile.launch.exe.activity"
+            pattern="org.eclipse.linuxtools.oprofile.launch.exe/org.eclipse.linuxtools.oprofile.launch.profileshortcut">
+      </activityPatternBinding>
+   </extension>
+</plugin>
+
diff --git a/org.eclipse.linuxtools.oprofile.launch.exe/src/org/tizen/oprofile/launch/Activator.java b/org.eclipse.linuxtools.oprofile.launch.exe/src/org/tizen/oprofile/launch/Activator.java
new file mode 100644 (file)
index 0000000..e7c6af8
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ *  Activator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Jaewon Lim <jaewon81.lim@samsung.com>
+ * Wonhyoung Park <wonhyoung2.park@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.oprofile.launch;
+
+import org.eclipse.core.runtime.Plugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends Plugin {
+
+       // The shared instance
+       private static Activator plugin;
+       
+       /**
+        * The constructor
+        */
+       public Activator() {
+       }
+
+       /*
+        * (non-Javadoc)
+        * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
+        */
+       public void start(BundleContext context) throws Exception {
+               super.start(context);
+               plugin = this;
+       }
+
+       /*
+        * (non-Javadoc)
+        * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
+        */
+       public void stop(BundleContext context) throws Exception {
+               plugin = null;
+               super.stop(context);
+       }
+
+       /**
+        * Returns the shared instance
+        *
+        * @return the shared instance
+        */
+       public static Activator getDefault() {
+               return plugin;
+       }
+
+}
diff --git a/org.eclipse.linuxtools.oprofile.launch.exe/src/org/tizen/oprofile/launch/NormalOprofileLaunchShortcut.java b/org.eclipse.linuxtools.oprofile.launch.exe/src/org/tizen/oprofile/launch/NormalOprofileLaunchShortcut.java
new file mode 100644 (file)
index 0000000..91b94c8
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ *  Normal Oprofile Launch Shortcut
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Jaewon Lim <jaewon81.lim@samsung.com>
+ * Wonhyoung Park <wonhyoung2.park@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.oprofile.launch;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.ui.IDebugUIConstants;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.linuxtools.oprofile.launch.OprofileLaunchMessages;
+import org.eclipse.linuxtools.oprofile.launch.OprofileLaunchPlugin;
+import org.eclipse.linuxtools.oprofile.launch.configuration.LaunchOptions;
+import org.eclipse.linuxtools.profiling.launch.ProfileLaunchPlugin;
+import org.eclipse.linuxtools.profiling.launch.ProfileLaunchShortcut;
+import org.eclipse.ui.IEditorPart;
+
+
+/**
+ * A class that takes care of the right-click -> profile with oprofile
+ *   shortcut, where the ProfileLaunchShortcut has the logic to automatically
+ *   find binaries and create a default launch if one doesn't exist.
+ */
+public class NormalOprofileLaunchShortcut extends ProfileLaunchShortcut {
+       
+       public void launch(IEditorPart editor, String mode) {
+               int targetResult = ProfileLaunchPlugin.checkTarget();
+               if(targetResult == 0)
+               {
+                       ProfileLaunchShortcut.showErrorDialog(OprofileLaunchMessages.getString("common.cannotrun"),
+                                       OprofileLaunchMessages.getString("common.notarget"), null);
+               }
+               else
+               {
+                       super.launch(editor, mode);
+               }
+       }
+
+       public void launch(ISelection selection, String mode) {
+               int targetResult = ProfileLaunchPlugin.checkTarget();
+               if(targetResult == 0)
+               {
+                       ProfileLaunchShortcut.showErrorDialog(OprofileLaunchMessages.getString("common.cannotrun"),
+                                       OprofileLaunchMessages.getString("common.notarget"), null);
+               }
+               else
+               {
+                       super.launch(selection, mode);
+               }
+       }
+       
+       @Override
+       protected ILaunchConfigurationType getLaunchConfigType() {
+               return getLaunchManager().getLaunchConfigurationType(OprofileLaunchPlugin.ID_LAUNCH_PROFILE);
+       }
+
+       /**
+        * Default settings for the OProfile-specific option tabs.
+        */
+       @Override
+       protected void setDefaultProfileAttributes(ILaunchConfigurationWorkingCopy wc) throws CoreException {
+               //default global setup options
+               LaunchOptions options = new LaunchOptions();
+               options.saveConfiguration(wc);
+
+               //default event option
+               wc.setAttribute(OprofileLaunchPlugin.ATTR_USE_DEFAULT_EVENT, true);
+       
+               // commented by greatim at 2011.06.01 for fresh ide
+               //jinu added at 20090618
+//             wc.setAttribute(ISMLCDTLaunchConstants.ATTR_LAUNCH_MODE, "oprofile");
+//             wc.setAttribute(ISMLCDTLaunchConstants.ATTR_SKIP_DOWNLOAD, false);
+               wc.setAttribute(IDebugUIConstants.ATTR_LAUNCH_IN_BACKGROUND, true);
+       }
+
+}
diff --git a/org.eclipse.linuxtools.oprofile.launch.exe/src/org/tizen/oprofile/launch/TizenOprofileLaunchDelegate.java b/org.eclipse.linuxtools.oprofile.launch.exe/src/org/tizen/oprofile/launch/TizenOprofileLaunchDelegate.java
new file mode 100644 (file)
index 0000000..04b03a0
--- /dev/null
@@ -0,0 +1,427 @@
+/*
+ *  Tizen Oprofile Launch Delegate
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Jaewon Lim <jaewon81.lim@samsung.com>
+ * Wonhyoung Park <wonhyoung2.park@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.oprofile.launch;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+
+import org.eclipse.cdt.debug.core.CDebugUtils;
+import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.core.ILaunchesListener2;
+import org.eclipse.linuxtools.oprofile.core.OpcontrolException;
+import org.eclipse.linuxtools.oprofile.core.Oprofile;
+import org.eclipse.linuxtools.oprofile.core.OprofileCorePlugin;
+import org.eclipse.linuxtools.oprofile.core.daemon.OprofileDaemonEvent;
+import org.eclipse.linuxtools.oprofile.launch.OprofileLaunchPlugin;
+import org.eclipse.linuxtools.oprofile.launch.configuration.LaunchOptions;
+import org.eclipse.linuxtools.oprofile.launch.configuration.OprofileCounter;
+import org.eclipse.linuxtools.oprofile.ui.OprofileUiPlugin;
+import org.eclipse.linuxtools.oprofile.ui.view.OprofileView;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.tizen.common.TizenPlatformConstants;
+import org.tizen.nativecommon.launch.IProjectLaunchCommand;
+import org.tizen.nativecommon.launch.TizenLaunchCommand;
+import org.tizen.nativecommon.launch.TizenLaunchDelegate;
+import org.tizen.nativecommon.launch.TizenLaunchMessages;
+import org.tizen.oprofile.core.CommandManager;
+import org.tizen.sdblib.SdbShellProcess;
+import org.tizen.nativecommon.Activator;
+import org.tizen.nativecommon.ProjectUtil;
+
+public class TizenOprofileLaunchDelegate extends TizenLaunchDelegate {
+
+       protected static final String MAKE_DIRECTORY_CMD = "mkdir -p ";
+       protected static final String CHANGE_DIRECTORY_CMD = "cd ";
+
+       protected static final String PACKAGE_NAME = "oprofile";
+       protected static final String PACKAGE_FILENAME_ARM = "oprofile_armel.deb";
+       protected static final String BADA_EXT = ".exe";
+
+       protected static String appName = null;
+
+       public static String getAppName() {
+               return appName;
+       }
+
+       public static void setAppName(String appName) {
+               TizenOprofileLaunchDelegate.appName = appName;
+       }
+
+       @Override
+       public void launch(ILaunchConfiguration config, String mode,
+                       ILaunch launch, IProgressMonitor monitor) throws CoreException {
+               if (monitor == null)
+                       monitor = new NullProgressMonitor();
+               try {
+
+                       monitor.beginTask(TizenLaunchMessages.LAUNCH_APPLICATION, 30);
+
+                       activateProgressView();
+
+                       verifyCProjectConfigurationSettings(config);
+                       verifyDeviceReachability(ProjectUtil.getProject(config),
+                                       new SubProgressMonitor(monitor, 9));
+                       verifyBuildConfiguration(config, mode, new SubProgressMonitor(
+                                       monitor, 11));
+
+                       setConsole(config);
+            tizenCommand = new TizenLaunchCommand(currentDevice, launchConsole);
+            // FIXME: ad-hoc code.
+            launchConsole.show();
+
+                       Oprofile.getOpInfo();
+
+                       // ISession session = getLaunchSession(config, new
+                       // SubProgressMonitor(monitor, 1));
+
+                       if (mode.equals(ILaunchManager.PROFILE_MODE)) {
+                               deployApplication(config, new SubProgressMonitor(monitor, 9));
+                               monitor.worked(1);
+
+                               launchApplicationWithOprofile(launch, config, monitor);
+                       } else {
+                               newCoreException(TizenLaunchMessages.CANNOT_LAUNCH, null);
+                       }
+               } finally {
+                       monitor.done();
+               }
+       }
+
+       protected void launchApplicationWithOprofile(ILaunch launch,
+                       ILaunchConfiguration config, IProgressMonitor monitor)
+                       throws CoreException {
+               try {
+                       // check oprofile tool
+                       checkProfilingTool(monitor);
+
+                       IProjectLaunchCommand manifest = ProjectUtil.getProjectManifest(ProjectUtil.getProject(config));
+                       String remoteExePath = TizenPlatformConstants.APP_INSTALL_PATH + "/" + manifest.getPackageName() + "/bin/";
+//                     String cmd = "cd " + remoteExePath + CMD_RESULT_CHECK;
+//                     // String resultRsp = session.run(cmd, null);
+//                     String[] resultRsp = CommandManager
+//                                     .runCommandReturningResultArray(cmd);
+//                     if (!CommandManager.isRunSeccessfuly(resultRsp))
+//                             newCoreException(TizenLaunchMessages.CANNOT_LAUNCH,
+//                                             new Exception("Cannot change to run-directory : "
+//                                                             + ". (Return Code: " + resultRsp + ")"));
+                       
+                       if (monitor.isCanceled())
+                               throw new OperationCanceledException();
+
+                       IPath exeFile = CDebugUtils.verifyProgramPath(config);
+                       remoteExePath += exeFile.toFile().getName();
+
+                       // for bada application
+                       // execute non-exe file instead of .exe file
+                       if(remoteExePath.endsWith(BADA_EXT))
+                       {
+                               remoteExePath = remoteExePath.substring(0, remoteExePath.length() - BADA_EXT.length());
+                       }
+
+                       String cmd = "ls " + remoteExePath + TizenPlatformConstants.CMD_SUFFIX;
+                       // resultRsp = session.run(cmd, null);
+                       String[] resultRsp = CommandManager.runCommandReturningResultArray(cmd);
+                       if (!CommandManager.isRunSeccessfuly(resultRsp))
+                               newCoreException(
+                                               TizenLaunchMessages.CANNOT_LAUNCH,
+                                               new Exception(
+                                                               "Executable does not exist on a valid path. You must install your application before running it."));
+
+                       if (monitor.isCanceled())
+                               throw new OperationCanceledException();
+                       
+                       monitor.worked(2);
+
+                       preProcedure(config, launch, monitor, remoteExePath);
+
+                       if (monitor.isCanceled())
+                               throw new OperationCanceledException();
+
+                       String arguments = config
+                                       .getAttribute(
+                                                       ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS,
+                                                       "");
+                       cmd = remoteExePath.trim();
+                       appName = remoteExePath;
+                       if (arguments != null && !arguments.equals(""))
+                               cmd += " " + arguments;
+
+                       // remoteShellProcess = session.launch(cmd, null);
+                       // CommandManager.runShell(cmd);
+                       runApplication(config, launch, cmd);
+
+                       if (monitor.isCanceled())
+                               throw new OperationCanceledException();
+
+                       postProcedure(config, launch, monitor);
+
+                       if (monitor.isCanceled())
+                               throw new OperationCanceledException();
+               } catch (CoreException e) {
+                       newCoreException(e.getMessage(), e.getCause());
+               } catch (OperationCanceledException e) {
+                       newCoreException("Operation canceled by user.", null);
+               } catch (Exception e) {
+                       newCoreException(TizenLaunchMessages.CANNOT_LAUNCH, e);
+               } finally {
+                       monitor.done();
+               }
+       }
+
+       private void runApplication(ILaunchConfiguration config, ILaunch launch,
+                       String command) {
+               SdbShellProcess oprofileProc = CommandManager.runApplication(command);
+               IPath exeFile = null;
+               try {
+                       exeFile = CDebugUtils.verifyProgramPath(config);
+                       DebugPlugin.newProcess(launch, oprofileProc, exeFile
+                                       .toFile().getName());
+                       BufferedReader br = new BufferedReader(new InputStreamReader(
+                                       oprofileProc.getInputStream()));
+                       while (null != br.readLine()) {
+                               ;
+                       }
+                       br.close();
+               } catch (CoreException e) {
+                       // TODO Auto-generated catch block
+                       e.printStackTrace();
+               } catch (IOException e) {
+                       // TODO Auto-generated catch block
+                       e.printStackTrace();
+               }
+
+       }
+
+       private void preProcedure(ILaunchConfiguration config, ILaunch launch,
+                       IProgressMonitor monitor, String imagePath) throws CoreException {
+               // FIXME: this assumes that project names are always the directory names
+               // in the workspace.
+               // this assumption may be wrong, but a shallow lookup seems ok
+               // jinu removed at 20090603
+               /*
+                * String workspacePath =
+                * ResourcesPlugin.getWorkspace().getRoot().getLocation().toString();
+                * String imagePath = workspacePath + Path.SEPARATOR +
+                * config.getAttribute
+                * (ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, "")
+                * //$NON-NLS-1$ + Path.SEPARATOR +
+                * config.getAttribute(ICDTLaunchConfigurationConstants
+                * .ATTR_PROGRAM_NAME, ""); //$NON-NLS-1$
+                */
+
+               LaunchOptions options = new LaunchOptions(); // default options created
+                                                                                                               // in the constructor
+               options.loadConfiguration(config);
+               options.setBinaryImage(imagePath);
+
+               // if daemonEvents null or zero size, the default event will be used
+               String defaultEvent = null;
+               OprofileDaemonEvent[] daemonEvents = null;
+               if (!config.getAttribute(OprofileLaunchPlugin.ATTR_USE_DEFAULT_EVENT,
+                               false)) {
+                       // get the events to profile from the counters
+                       OprofileCounter[] counters = OprofileCounter.getCounters(config);
+                       ArrayList<OprofileDaemonEvent> events = new ArrayList<OprofileDaemonEvent>();
+
+                       for (int i = 0; i < counters.length; ++i) {
+                               if (counters[i].getEnabled())
+                                       events.add(counters[i].getDaemonEvent());
+                       }
+
+                       daemonEvents = new OprofileDaemonEvent[events.size()];
+                       events.toArray(daemonEvents);
+               }
+               // jinu added at 20090602--------------------------------
+               else {
+                       String keyStr = config.getAttribute(
+                                       OprofileLaunchPlugin.ATTR_SELECTED_DEFAULT_SETTING, "");
+                       defaultEvent = DefaultSettingConstants.getSettingValue(keyStr);
+               }
+               // --------------------------------------
+
+               // set up and launch the oprofile daemon
+               try {
+
+                       // kill the daemon (it shouldn't be running already, but to be safe)
+                       OprofileCorePlugin.getDefault().getOpcontrolProvider()
+                                       .shutdownDaemon();
+
+                       // reset data from the (possibly) existing default session,
+                       // otherwise multiple runs will combine samples and results
+                       // won't make much sense
+                       OprofileCorePlugin.getDefault().getOpcontrolProvider().reset();
+
+                       // setup the events and other parameters
+                       // jinu modified at 20090603
+                       // OprofileCorePlugin.getDefault().getOpcontrolProvider().setupDaemon(options.getOprofileDaemonOptions(),
+                       // daemonEvents);
+                       OprofileCorePlugin
+                                       .getDefault()
+                                       .getOpcontrolProvider()
+                                       .setupDaemon(options.getOprofileDaemonOptions(),
+                                                       daemonEvents, defaultEvent);
+
+                       // start the daemon & collection of samples
+                       // note: since the daemon is only profiling for the specific image
+                       // we told
+                       // it to, no matter to start the daemon before the binary itself is
+                       // run
+                       OprofileCorePlugin.getDefault().getOpcontrolProvider()
+                                       .startCollection();
+
+               } catch (OpcontrolException oe) {
+                       OprofileCorePlugin.showErrorDialog("opcontrolProvider", oe); //$NON-NLS-1$
+                       return;
+               }
+
+       }
+
+       private void postProcedure(ILaunchConfiguration config, ILaunch launch,
+                       IProgressMonitor monitor) throws CoreException {
+               // ILaunchManager lmgr = DebugPlugin.getDefault().getLaunchManager();
+               // lmgr.addLaunchListener(new LaunchTerminationWatcher(launch));
+               OprofileCorePlugin.getDefault().getOpcontrolProvider().dumpSamples();
+               OprofileCorePlugin.getDefault().getOpcontrolProvider().shutdownDaemon();
+
+               // need to run this in the ui thread otherwise get SWT Exceptions
+               // based on concurrency issues
+               Display.getDefault().syncExec(new Runnable() {
+                       public void run() {
+                               OprofileView view = OprofileUiPlugin.getDefault()
+                                               .getOprofileView();
+                               if (view != null) {
+                                       view.refreshView();
+                               } else {
+                                       try {
+                                               PlatformUI.getWorkbench().getActiveWorkbenchWindow()
+                                                               .getActivePage()
+                                                               .showView(OprofileUiPlugin.ID_OPROFILE_VIEW);
+                                       } catch (PartInitException e) {
+                                               e.printStackTrace();
+                                       }
+                                       OprofileUiPlugin.getDefault().getOprofileView()
+                                                       .refreshView();
+                               }
+                       }
+               });
+       }
+
+       public static void checkProfilingTool(IProgressMonitor monitor)
+                       throws CoreException {
+               // find oprofile
+               String oprofileCmd = TizenPlatformConstants.TOOLS_TARGET_PATH + "/oprofile/usr/bin/opcontrol";
+               String cmd = "ls " + oprofileCmd + TizenPlatformConstants.CMD_SUFFIX;
+               // String resultRsp = session.run(cmd, null);
+               String[] resultRsp = CommandManager.runCommandReturningResultArray(cmd);
+               if (!CommandManager.isRunSeccessfuly(resultRsp)) {
+                       // if (CommandManager.isEmulator()) {
+               Status status = new Status(Status.ERROR, Activator.PLUGIN_ID,
+                               TizenLaunchMessages.CANNOT_LAUNCH,
+                                       new Exception(
+                                                       "No oprofile in this target (" + TizenPlatformConstants.TOOLS_TARGET_PATH + "/oprofile/usr/bin/opcontrol)."));
+               throw new CoreException(status);
+                       // } else {
+                       // transferProfilingToolPackage(monitor);
+                       // installProfilingToolPackage(monitor);
+                       // }
+               }
+       }
+
+       class LaunchTerminationWatcher implements ILaunchesListener2 {
+               private ILaunch launch;
+
+               public LaunchTerminationWatcher(ILaunch il) {
+                       launch = il;
+               }
+
+               public void launchesTerminated(ILaunch[] launches) {
+                       try {
+                               for (ILaunch l : launches) {
+                                       /**
+                                        * Dump samples from the daemon, shut down the daemon,
+                                        * activate the OProfile view (open it if it isn't already),
+                                        * refresh the view (which parses the data/ui model and
+                                        * displays it).
+                                        */
+                                       if (l.equals(launch)) {
+                                               OprofileCorePlugin.getDefault().getOpcontrolProvider()
+                                                               .dumpSamples();
+                                               OprofileCorePlugin.getDefault().getOpcontrolProvider()
+                                                               .shutdownDaemon();
+
+                                               // need to run this in the ui thread otherwise get SWT
+                                               // Exceptions
+                                               // based on concurrency issues
+                                               Display.getDefault().syncExec(new Runnable() {
+                                                       public void run() {
+                                                               OprofileView view = OprofileUiPlugin
+                                                                               .getDefault().getOprofileView();
+                                                               if (view != null) {
+                                                                       view.refreshView();
+                                                               } else {
+                                                                       try {
+                                                                               PlatformUI
+                                                                                               .getWorkbench()
+                                                                                               .getActiveWorkbenchWindow()
+                                                                                               .getActivePage()
+                                                                                               .showView(
+                                                                                                               OprofileUiPlugin.ID_OPROFILE_VIEW);
+                                                                       } catch (PartInitException e) {
+                                                                               e.printStackTrace();
+                                                                       }
+                                                                       OprofileUiPlugin.getDefault()
+                                                                                       .getOprofileView().refreshView();
+                                                               }
+                                                       }
+                                               });
+                                       }
+                               }
+                       } catch (OpcontrolException oe) {
+                               OprofileCorePlugin.showErrorDialog("opcontrolProvider", oe); //$NON-NLS-1$
+                       }
+               }
+
+               public void launchesAdded(ILaunch[] launches) { /* dont care */
+               }
+
+               public void launchesChanged(ILaunch[] launches) { /* dont care */
+               }
+
+               public void launchesRemoved(ILaunch[] launches) { /* dont care */
+               }
+       }
+
+}
diff --git a/org.eclipse.linuxtools.oprofile.launch.exe/src/org/tizen/oprofile/launch/configuration/NormalOprofileLaunchConfigurationTabGroup.java b/org.eclipse.linuxtools.oprofile.launch.exe/src/org/tizen/oprofile/launch/configuration/NormalOprofileLaunchConfigurationTabGroup.java
new file mode 100644 (file)
index 0000000..68a1e4b
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ *  Normal Oprofile Launch Configuration Tab Group
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Jaewon Lim <jaewon81.lim@samsung.com>
+ * Wonhyoung Park <wonhyoung2.park@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.oprofile.launch.configuration;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
+import org.eclipse.debug.ui.ILaunchConfigurationDialog;
+import org.eclipse.linuxtools.oprofile.launch.configuration.OprofileEventConfigTab;
+import org.eclipse.linuxtools.profiling.launch.ProfileLaunchConfigurationTabGroup;
+import org.tizen.nativecommon.launch.ui.TizenMainTab;
+import org.tizen.oprofile.launch.TizenOprofileLaunchDelegate;
+
+public class NormalOprofileLaunchConfigurationTabGroup extends ProfileLaunchConfigurationTabGroup {
+
+       public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
+               ArrayList<AbstractLaunchConfigurationTab> tabs = new ArrayList<AbstractLaunchConfigurationTab>();
+               tabs.add(new TizenMainTab());
+//             tabs.add(new TizenArgumentsTab());
+               tabs.addAll(Arrays.asList(getProfileTabs()));
+//             tabs.add(new TizenEnvironmentTab());
+//             tabs.add(new SourceLookupTab());
+               
+               setTabs(tabs.toArray(new AbstractLaunchConfigurationTab[tabs.size()]));
+               
+       }       
+       @Override
+       public AbstractLaunchConfigurationTab[] getProfileTabs() {
+               //jinu modified at 20090602
+               //return new AbstractLaunchConfigurationTab[] { new OprofileSetupTab(), new OprofileEventConfigTab() };
+
+               // added by greatim at 20110613
+               try{
+                       IProgressMonitor monitor = new NullProgressMonitor();
+                       
+                       TizenOprofileLaunchDelegate.checkProfilingTool(monitor);
+               } catch(CoreException e) {
+                       e.printStackTrace();
+               }
+               
+               return new AbstractLaunchConfigurationTab[] { new OprofileEventConfigTab() };
+       }
+
+}
diff --git a/org.eclipse.linuxtools.oprofile.launch/.classpath b/org.eclipse.linuxtools.oprofile.launch/.classpath
new file mode 100644 (file)
index 0000000..4c62a80
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+       <classpathentry kind="src" path="src"/>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.eclipse.linuxtools.oprofile.launch/.project b/org.eclipse.linuxtools.oprofile.launch/.project
new file mode 100644 (file)
index 0000000..7e16bda
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.eclipse.linuxtools.oprofile.launch</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.ManifestBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.SchemaBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.pde.PluginNature</nature>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>
diff --git a/org.eclipse.linuxtools.oprofile.launch/.settings/org.eclipse.core.resources.prefs b/org.eclipse.linuxtools.oprofile.launch/.settings/org.eclipse.core.resources.prefs
new file mode 100644 (file)
index 0000000..bd9cda7
--- /dev/null
@@ -0,0 +1,3 @@
+#Wed Dec 01 09:13:16 CET 2010
+eclipse.preferences.version=1
+encoding/<project>=UTF-8
diff --git a/org.eclipse.linuxtools.oprofile.launch/.settings/org.eclipse.core.runtime.prefs b/org.eclipse.linuxtools.oprofile.launch/.settings/org.eclipse.core.runtime.prefs
new file mode 100644 (file)
index 0000000..30f3872
--- /dev/null
@@ -0,0 +1,3 @@
+#Tue Dec 14 16:36:24 CET 2010
+eclipse.preferences.version=1
+line.separator=\n
diff --git a/org.eclipse.linuxtools.oprofile.launch/META-INF/MANIFEST.MF b/org.eclipse.linuxtools.oprofile.launch/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..39b7f4e
--- /dev/null
@@ -0,0 +1,38 @@
+Manifest-Version: 1.0
+Require-Bundle: org.eclipse.core.runtime;bundle-version="3.4.0",
+ org.eclipse.ui;bundle-version="3.4.0",
+ org.eclipse.cdt.core,
+ org.eclipse.cdt.launch;bundle-version="5.0.1",
+ org.eclipse.cdt.debug.core;bundle-version="5.0.1",
+ org.eclipse.linuxtools.oprofile.core,
+ org.tizen.common,
+ org.tizen.common.connection
+Bundle-Vendor: Eclipse Linux Tools
+Bundle-ActivationPolicy: lazy
+Bundle-Version: 1.3.18.qualifier
+Bundle-Localization: plugin
+Bundle-Name: Tizen SDK Oprofile Launch
+Bundle-Activator: org.eclipse.linuxtools.oprofile.launch.OprofileLaunc
+ hPlugin
+Bundle-ManifestVersion: 2
+Import-Package: org.eclipse.cdt.debug.core,
+ org.eclipse.cdt.launch,
+ org.eclipse.cdt.utils.pty,
+ org.eclipse.cdt.utils.spawner,
+ org.eclipse.core.resources,
+ org.eclipse.debug.core,
+ org.eclipse.debug.ui,
+ org.eclipse.linuxtools.oprofile.core,
+ org.eclipse.linuxtools.oprofile.core.daemon,
+ org.eclipse.linuxtools.oprofile.ui,
+ org.eclipse.linuxtools.oprofile.ui.view,
+ org.eclipse.linuxtools.profiling.launch,
+ org.eclipse.ui,
+ org.tizen.sdblib
+Bundle-SymbolicName: org.eclipse.linuxtools.oprofile.launch;singleton:
+ =true
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Export-Package: org.tizen.oprofile.launch,
+ org.eclipse.linuxtools.oprofile.launch,
+ org.eclipse.linuxtools.oprofile.launch.configuration
+
diff --git a/org.eclipse.linuxtools.oprofile.launch/META-INF/eclipse.inf b/org.eclipse.linuxtools.oprofile.launch/META-INF/eclipse.inf
new file mode 100644 (file)
index 0000000..92ffed2
--- /dev/null
@@ -0,0 +1,2 @@
+#Processed using Jarprocessor
+pack200.conditioned = true
diff --git a/org.eclipse.linuxtools.oprofile.launch/NOTICE b/org.eclipse.linuxtools.oprofile.launch/NOTICE
new file mode 100644 (file)
index 0000000..c91b2a1
--- /dev/null
@@ -0,0 +1,48 @@
+2010-02-03 SPRC SDK Team <d.kozinski@samsung.com>
+       * MANIFEST.MF : changed some package names
+
+2010-03-11 SPRC SDK Team <d.kozinski@samsung.com>
+       * OprofileEventConfigTab.java : add help string
+
+2010-11-05 sdk <sdk@sdk-laptop.(none)>
+       * MANIFEST.MF : changed some package name
+       * plugin.xml : changed some package name
+       * OprofileEventConfigTab.java : changed some package name
+       * OprofileLaunchConfigurationDelegate.java : changed some package name
+       * OprofileLaunchShortcut.java : changed some package name
+
+2010-11-09 DongGi Jang <dg0402.jang.samsung.com>
+       * MANIFEST.MF : changed launcher name
+
+2011-06-09 jaewon81.lim <jaewon81.lim@samsung.com>
+       * MANIFEST.MF : rearrange plugins dependency
+
+2011-06-13 jaewon81.lim <jaewon81.lim@samsung.com>
+       * OprofileEventConfigTab.java : some bug fix
+
+2011-07-13 jaewon81.lim <jaewon81.lim@samsung.com>
+       * MANIFEST.MF : modified import package name
+
+2011-08-22 joogwan.kim <joogwan.kim@samsung.com>
+       * MANIFEST.MF : Change plug-in name
+
+2011-08-25 wonhyoung2.park <wonhyoung2.park@samsung.com>
+       * MANIFEST.MF : plugin provider and name modified
+
+2011-11-16 wonhyoung2.park <wonhyoung2.park@samsung.com>
+       * MANIFEST.MF : Profiler sdb apply
+
+2011-11-22 taeyoung2.son <taeyoung2.son@samsung.com>
+       * MANIFEST.MF :  Modify SDK naming from "SLP(or Samsung Linux Platform)" to "Tizen"
+
+2011-11-29 wonhyoung2.park <wonhyoung2.park@samsung.com>
+       * MANIFEST.MF : chagne slp to tizen
+       * plugin.xml : chagne slp to tizen
+       * OprofileEventConfigTab.java : chagne slp to tizen
+       * OprofileLaunchConfigurationDelegate.java : chagne slp to tizen
+
+2011-12-02 taeyoung2.son <taeyoung2.son@samsung.com>
+       * MANIFEST.MF : Delete dependency feature's version value.
+
+2011-12-03 wonhyoung2.park <wonhyoung2.park@samsung.com>
+       * MANIFEST.MF : package instll routine chage
diff --git a/org.eclipse.linuxtools.oprofile.launch/about.html b/org.eclipse.linuxtools.oprofile.launch/about.html
new file mode 100644 (file)
index 0000000..bf06e8c
--- /dev/null
@@ -0,0 +1,33 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
+<html>
+<head>
+<title>About</title>
+<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+<p>8th September, 2004</p>     
+<h3>License</h3>
+<p>The Eclipse Software Foundation makes available all content in this plug-in (&quot;Content&quot;).  Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;).  A copy of the EPL is available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<h3>Contributions</h3>
+
+<p>If this Content is licensed to you under the terms and conditions of the EPL, any Contributions, as defined in the EPL, uploaded, submitted, or otherwise
+made available to the Eclipse Foundation, its members and/or the host of the Eclipse Foundation web site, by you that relate to such
+Content are provided under the terms and conditions of the <a href="http://www.eclipse.org/legal/termsofuse.html">Terms of Use</a>
+for the Eclipse Foundation web site and can be made available to others under the terms of the licenses as set out in the
+<a href="http://www.eclipse.org/legal/termsofuse.html">Terms of Use</a>.</p>
+
+<p>If this Content is licensed to you under license terms and conditions other than the EPL (&quot;Other License&quot;), any modifications, enhancements and/or
+other code and/or documentation (&quot;Modifications&quot;) uploaded, submitted, or otherwise made available to the Eclipse Foundation, its members and/or the
+host of the Eclipse Foundation web site, by you that relate to such Content are provided under terms and conditions of the Other License and can be made available
+to others under the terms of the Other License.  In addition, with regard to Modifications for which you are the copyright holder, you are also
+providing the Modifications under the terms and conditions of the <a href="http://www.eclipse.org/legal/termsofuse.html">Terms of Use</a>
+for the Eclipse Foundation web site and such Modifications can be made available to others under the terms of the licenses as set out in the
+<a href="http://www.eclipse.org/legal/termsofuse.html">Terms of Use</a>.</p>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/org.eclipse.linuxtools.oprofile.launch/build.properties b/org.eclipse.linuxtools.oprofile.launch/build.properties
new file mode 100644 (file)
index 0000000..6b70fb2
--- /dev/null
@@ -0,0 +1,10 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               .,\
+               plugin.xml,\
+               plugin.properties,\
+               icons/,\
+               about.html
+javacSource = 1.6
+javacTarget = 1.6
diff --git a/org.eclipse.linuxtools.oprofile.launch/icons/event_tab.gif b/org.eclipse.linuxtools.oprofile.launch/icons/event_tab.gif
new file mode 100644 (file)
index 0000000..c91f254
Binary files /dev/null and b/org.eclipse.linuxtools.oprofile.launch/icons/event_tab.gif differ
diff --git a/org.eclipse.linuxtools.oprofile.launch/icons/global_tab.gif b/org.eclipse.linuxtools.oprofile.launch/icons/global_tab.gif
new file mode 100644 (file)
index 0000000..ec6cca4
Binary files /dev/null and b/org.eclipse.linuxtools.oprofile.launch/icons/global_tab.gif differ
diff --git a/org.eclipse.linuxtools.oprofile.launch/icons/profile_run.png b/org.eclipse.linuxtools.oprofile.launch/icons/profile_run.png
new file mode 100644 (file)
index 0000000..4f8488f
Binary files /dev/null and b/org.eclipse.linuxtools.oprofile.launch/icons/profile_run.png differ
diff --git a/org.eclipse.linuxtools.oprofile.launch/plugin.properties b/org.eclipse.linuxtools.oprofile.launch/plugin.properties
new file mode 100644 (file)
index 0000000..fd1976b
--- /dev/null
@@ -0,0 +1,20 @@
+#*******************************************************************************
+# Copyright (c) 2008 Red Hat, Inc.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#    Red Hat, Inc. - initial API and implementation
+#*******************************************************************************
+pluginName=OProfile Launch Support
+launchconfigurationtype.label=Profile With OProfile
+
+launchgroup.label = OProfile
+launchgroup.titile = Select a run configuration to profile with OProfile
+
+launchmode.label = Profile
+launchmode.launchaslabel = Profile As
+
+launchshortcuts.label = Profile With OProfile
diff --git a/org.eclipse.linuxtools.oprofile.launch/plugin.xml b/org.eclipse.linuxtools.oprofile.launch/plugin.xml
new file mode 100644 (file)
index 0000000..ea3089e
--- /dev/null
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+
+        <extension
+              point="org.eclipse.ui.startup">
+           <startup
+                 class="org.tizen.oprofile.launch.listen.OprofileStartup">
+           </startup>
+        </extension>   
+  
+   
+   
+   
+</plugin>
diff --git a/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/oprofile/launch/OprofileLaunchMessages.java b/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/oprofile/launch/OprofileLaunchMessages.java
new file mode 100644 (file)
index 0000000..869bd29
--- /dev/null
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Keith Seitz <keiths@redhat.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.oprofile.launch;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class OprofileLaunchMessages {
+       private static final String BUNDLE_NAME = "org.eclipse.linuxtools.oprofile.launch.oprofilelaunch"; //$NON-NLS-1$
+       private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
+
+       private OprofileLaunchMessages() {
+       }
+
+       public static String getString(String key) {
+               try {
+                       return RESOURCE_BUNDLE.getString(key);
+               } catch (MissingResourceException e) {
+                       return '!' + key + '!';
+               }
+       }
+}
diff --git a/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/oprofile/launch/OprofileLaunchPlugin.java b/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/oprofile/launch/OprofileLaunchPlugin.java
new file mode 100644 (file)
index 0000000..fd46c29
--- /dev/null
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008, 2009 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Keith Seitz <keiths@redhat.com> - initial API and implementation
+ *    Kent Sebastian <ksebasti@redhat.com>
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.oprofile.launch;
+
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.linuxtools.oprofile.launch.configuration.EventConfigCache;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+
+/**
+ * The main plugin class to be used in the desktop.
+ */
+public class OprofileLaunchPlugin extends AbstractUIPlugin {
+       //The shared instance.
+       private static OprofileLaunchPlugin plugin;
+       //shared cache instance for configuration
+       private static EventConfigCache _eventConfigCache = null;
+
+       private static final String ID_PLUGIN = "org.eclipse.linuxtools.oprofile.launch"; //$NON-NLS-1$
+
+       // The launch type ID for profiling
+       public static final String ID_LAUNCH_PROFILE = ID_PLUGIN + ".oprofile"; //$NON-NLS-1$
+
+
+       /* Launch Configuration attributes */
+       
+       // Global options \\
+       public static final String ATTR_KERNEL_IMAGE_FILE = ID_LAUNCH_PROFILE + ".KERNEL_IMAGE";                        //$NON-NLS-1$
+       public static final String ATTR_SEPARATE_SAMPLES = ID_LAUNCH_PROFILE + ".SEPARATE_SAMPLES";             //$NON-NLS-1$
+       public static final String ATTR_USE_DEFAULT_EVENT = ID_LAUNCH_PROFILE + ".USE_DEFAULT_EVENT";           //$NON-NLS-1$
+       
+       //jinu added at 20090602
+       public static final String ATTR_SELECTED_DEFAULT_SETTING = ID_LAUNCH_PROFILE + ".SELECTED_DEFAULT_SETTING";             //$NON-NLS-1$
+       
+       // Counter Attributes \\
+       private static final String ATTR_COUNTER(int nr) { return ID_LAUNCH_PROFILE + ".COUNTER_" + nr; }                                       //$NON-NLS-1$
+       public static final String ATTR_COUNTER_ENABLED(int nr)  { return ATTR_COUNTER(nr) + ".ENABLED"; }                                      //$NON-NLS-1$
+       public static final String ATTR_COUNTER_EVENT(int nr) { return ATTR_COUNTER(nr)  + ".EVENT"; }                                          //$NON-NLS-1$
+       public static final String ATTR_COUNTER_PROFILE_KERNEL(int nr) { return ATTR_COUNTER(nr) + ".PROFILE_KERNEL"; }         //$NON-NLS-1$
+       public static final String ATTR_COUNTER_PROFILE_USER(int nr) { return ATTR_COUNTER(nr) + ".PROFILE_USER"; }             //$NON-NLS-1$
+       public static final String ATTR_COUNTER_COUNT(int nr) { return ATTR_COUNTER(nr) + ".COUNT"; }                                           //$NON-NLS-1$
+       public static final String ATTR_COUNTER_UNIT_MASK(int nr) { return  ATTR_COUNTER(nr) + ".UNIT_MASK"; }                          //$NON-NLS-1$
+       
+       
+       public static final String ICON_PATH = "icons/"; //$NON-NLS-1$
+       public static final String ICON_EVENT_TAB = ICON_PATH + "event_tab.gif"; //$NON-NLS-1$
+       public static final String ICON_GLOBAL_TAB = ICON_PATH + "global_tab.gif"; //$NON-NLS-1$
+       
+       
+       /**
+        * The constructor.
+        */
+       public OprofileLaunchPlugin() {
+               plugin = this;
+       }
+
+       public void start(BundleContext context) throws Exception {
+               super.start(context);
+       }
+
+       public void stop(BundleContext context) throws Exception {
+               super.stop(context);
+               plugin = null;
+       }       
+
+       public static OprofileLaunchPlugin getDefault() {
+               return plugin;
+       }
+
+       public static IWorkspace getWorkspace() {
+               return ResourcesPlugin.getWorkspace();
+       }
+       
+       public static String getUniqueIdentifier() {
+               return ID_PLUGIN;
+       }
+       
+       public static ImageDescriptor getImageDescriptor(String path) {
+               return imageDescriptorFromPlugin(ID_PLUGIN, path);
+       }
+
+       public static IWorkbenchWindow getActiveWorkbenchWindow() {
+               return getDefault().getWorkbench().getActiveWorkbenchWindow();
+       }
+       
+       public static Shell getActiveWorkbenchShell() {
+               IWorkbenchWindow window = getActiveWorkbenchWindow();
+               if (window != null) {
+                       return window.getShell();
+               }
+               return null;
+       }       
+
+       public static EventConfigCache getCache() {
+               if (_eventConfigCache == null) {
+                       _eventConfigCache = new EventConfigCache();
+               }
+               
+               return _eventConfigCache;
+       }
+
+}
diff --git a/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/oprofile/launch/configuration/EventConfigCache.java b/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/oprofile/launch/configuration/EventConfigCache.java
new file mode 100644 (file)
index 0000000..ea1d52c
--- /dev/null
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Kent Sebastian <ksebasti@redhat.com> - initial API and implementation
+ *    
+ *******************************************************************************/
+package org.eclipse.linuxtools.oprofile.launch.configuration;
+
+import java.util.HashMap;
+import org.eclipse.linuxtools.oprofile.core.Oprofile;
+
+/**
+ * Cache class for event configuration. Currently only used to cache the results
+ * of an `opxml check-event ..` run, since the isValid() method in the EventConfigTab
+ * needlessly spawns opxml dozens of times with the same values. Note that multiple
+ * checks of the same value will necessarily return the same result (for a given 
+ * processor) so there is no worry of an invalid cache entry.
+ */
+public class EventConfigCache {
+       //a cache entry for an event check, used as the hashmap key 
+       class CheckEventEntry {
+               public Integer counterNum, eventNum, maskValue;
+               
+               public CheckEventEntry(int counterNum, int eventNum, int maskValue) {
+                       this.counterNum = new Integer(counterNum);
+                       this.eventNum = new Integer(eventNum);
+                       this.maskValue = new Integer(maskValue);
+               }
+               
+               @Override
+               public boolean equals(Object obj) {
+                       if (obj instanceof CheckEventEntry) {
+                               CheckEventEntry other = (CheckEventEntry)obj;
+                               return (counterNum.equals(other.counterNum) && eventNum.equals(other.eventNum) && maskValue.equals(other.maskValue));
+                       } else {
+                               return false;
+                       }
+               }
+               
+               @Override
+               public int hashCode() {
+                       int prime = 11, result = 3;
+                       result = prime*result + counterNum.hashCode();
+                       result = prime*result + eventNum.hashCode();
+                       result = prime*result + maskValue.hashCode();
+                       return result;
+               }
+       }
+       
+       HashMap<CheckEventEntry, Boolean> validEventCache;
+
+       /**
+        * Default constructor, creates an empty cache.
+        */
+       public EventConfigCache() {
+               validEventCache = new HashMap<CheckEventEntry, Boolean>();
+       }
+
+       /**
+        * Method to be used to check the validity of an event. Will check
+        * the cache for the result of a previous check of the same values,
+        * or otherwise will spawn opxml to check properly.
+        * @param counter counter number
+        * @param event event number
+        * @param mask unit mask value
+        * @return true or false, depending if the event config is valid
+        */
+       public boolean checkEvent(int counter, int event, int mask) {
+               CheckEventEntry e = new CheckEventEntry(counter, event, mask);
+               Boolean result = null;
+               
+               result = validEventCache.get(e);
+               
+               if (result == null) {
+                       //not in the map, get its value and add it in
+                       result = Oprofile.checkEvent(counter, event, mask);
+                       
+                       //possible to be null if there is no opxmlProvider
+                       if (result != null) {
+                               validEventCache.put(e, result);
+                       }
+               }
+
+               return (result == null ? false : result);
+       }
+       
+}
diff --git a/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/oprofile/launch/configuration/LaunchOptions.java b/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/oprofile/launch/configuration/LaunchOptions.java
new file mode 100644 (file)
index 0000000..11ceeb4
--- /dev/null
@@ -0,0 +1,132 @@
+/*******************************************************************************
+ * Copyright (c) 2004,2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Keith Seitz <keiths@redhat.com> - initial API and implementation
+ *    Kent Sebastian <ksebasti@redhat.com> - 
+ *******************************************************************************/ 
+
+package org.eclipse.linuxtools.oprofile.launch.configuration;
+
+import java.io.File;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.linuxtools.oprofile.core.daemon.OprofileDaemonOptions;
+import org.eclipse.linuxtools.oprofile.launch.OprofileLaunchPlugin;
+
+/**
+ * This class wraps OProfile's global launch options for the
+ * Eclipse launcher facility.
+ */
+public class LaunchOptions {
+       
+       // The launch options for the daemon
+       private OprofileDaemonOptions _options;
+
+       public LaunchOptions() {
+               _options = new OprofileDaemonOptions();
+       }
+       
+       /**
+        * Determines whether the global oprofile options represented by this
+        * object are valid
+        * @return whether the options are valid
+        */
+       public boolean isValid() {
+               // The only point of contention is whether the specified vmlinux *file* exists.
+               String fn = _options.getKernelImageFile();
+               if (fn != null && fn.length() > 0) {
+                       File file = new File(_options.getKernelImageFile());
+                       return (file.exists() && file.isFile());
+               }
+               
+               return true;
+       }
+       
+       /**
+        * Saves the global options of this object into the specified launch
+        * configuration
+        * @param config        the launch configuration
+        */
+       public void saveConfiguration(ILaunchConfigurationWorkingCopy config) {
+               config.setAttribute(OprofileLaunchPlugin.ATTR_KERNEL_IMAGE_FILE, _options.getKernelImageFile());
+               config.setAttribute(OprofileLaunchPlugin.ATTR_SEPARATE_SAMPLES, _options.getSeparateProfilesMask());
+       }
+       
+       /**
+        * Loads this object with the global options in the given launch
+        * configuration
+        * @param config        the launch configuration
+        */
+       public void loadConfiguration(ILaunchConfiguration config) {
+               try {
+                       _options.setKernelImageFile(config.getAttribute(OprofileLaunchPlugin.ATTR_KERNEL_IMAGE_FILE, "")); //$NON-NLS-1$
+                       _options.setSeparateProfilesMask(config.getAttribute(OprofileLaunchPlugin.ATTR_SEPARATE_SAMPLES, OprofileDaemonOptions.SEPARATE_NONE));
+               } catch (CoreException e) {
+                       e.printStackTrace();
+               }
+       }
+       
+       /**
+        * Get the daemon launch options
+        * @return the OprofileDaemonOption
+        */
+       public OprofileDaemonOptions getOprofileDaemonOptions() {
+               return _options;
+       }
+       
+       /**
+        * Method getKernelImageFile.
+        * @return the kernel image file
+        */
+       public String getKernelImageFile() {
+               return _options.getKernelImageFile();
+       }
+       
+       /**
+        * Sets the kernel image file
+        * @param image the kernel image file
+        */
+       public void setKernelImageFile(String image) {
+               _options.setKernelImageFile(image);
+       }
+
+       /**
+        * Method getSeparateSamples.
+        * @return whether and how to separate samples for each distinct application
+        */
+       public int getSeparateSamples() {
+               return _options.getSeparateProfilesMask();
+       }
+
+       /**
+        * Sets whether/how to collect separate samples for each distinct application
+        * @param how   one of SEPARATE_{NONE, LIBRARY, KERNEL, THREAD, CPU}
+        */
+       public void setSeparateSamples(int how) {
+               _options.setSeparateProfilesMask(how);
+       }
+       
+       /**
+        * Returns the path of the binary to profile.
+        * @return the full path to the binary being profile
+        */
+       public String getBinaryImage() {
+               return _options.getBinaryImage();
+       }
+
+       /**
+        * Sets the binary to profile in this launch.
+        * @param _image string of the full path to the binary
+        */
+       public void setBinaryImage(String _image) {
+               _options.setBinaryImage(_image);
+       }
+
+}
diff --git a/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/oprofile/launch/configuration/OprofileCounter.java b/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/oprofile/launch/configuration/OprofileCounter.java
new file mode 100644 (file)
index 0000000..40745ef
--- /dev/null
@@ -0,0 +1,253 @@
+/*******************************************************************************
+ * Copyright (c) 2004,2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Keith Seitz <keiths@redhat.com> - initial API and implementation
+ *    Kent Sebastian <ksebasti@redhat.com>
+ *******************************************************************************/ 
+
+package org.eclipse.linuxtools.oprofile.launch.configuration;
+
+import java.text.MessageFormat;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.linuxtools.oprofile.core.Oprofile;
+import org.eclipse.linuxtools.oprofile.core.daemon.OpEvent;
+import org.eclipse.linuxtools.oprofile.core.daemon.OpUnitMask;
+import org.eclipse.linuxtools.oprofile.core.daemon.OprofileDaemonEvent;
+import org.eclipse.linuxtools.oprofile.launch.OprofileLaunchPlugin;
+import org.eclipse.linuxtools.oprofile.launch.OprofileLaunchMessages;
+
+/**
+ * This class represents an oprofile runtime configuration of a counter. It is
+ * used to construct arguments for launching op_start on the host. It
+ * simply wraps OprofileDaemonEvent.
+ */
+public class OprofileCounter {
+       private static final String COUNTER_STRING = OprofileLaunchMessages.getString("oprofileCounter.counterString"); //$NON-NLS-1$
+       
+       // The counter number
+       private int _number;
+       
+       // Is this counter enabled?
+       private boolean _enabled;
+       
+       // The event to collect on this counter
+       private OprofileDaemonEvent _daemonEvent;
+       
+       // List of valid events on this counter
+       private OpEvent[] _eventList = null;
+
+       /**
+        * Constructor for OprofileCounter.
+        * @param nr    the counter number
+        */
+       public OprofileCounter(int nr) {
+               _number = nr;
+               _enabled = false;
+               _eventList = Oprofile.getEvents(_number);
+               _daemonEvent = new OprofileDaemonEvent();
+       }
+
+       /**
+        * Constructs all of the counters in  the given launch configuration.
+        * @param config the launch configuration
+        * @return an array of all counters
+        */
+       public static OprofileCounter[] getCounters(ILaunchConfiguration config) {
+               OprofileCounter[] ctrs = new OprofileCounter[Oprofile.getNumberOfCounters()];
+               for (int i = 0; i < ctrs.length; i++)
+               {
+                       ctrs[i] = new OprofileCounter(i);
+                       if (config != null)
+                               ctrs[i].loadConfiguration(config);
+               }
+               
+               return ctrs;
+       }
+
+       /**
+        * Method setEnabled.
+        * @param enabled       whether to set this counter as enabled
+        */
+       public void setEnabled(boolean enabled) {
+               _enabled = enabled;
+       }
+       
+       /**
+        * Method setEvent.
+        * @param event the event for this counter
+        */
+       public void setEvent(OpEvent event) {
+               _daemonEvent.setEvent(event);
+       }
+       
+       /**
+        * Method setProfileKernel.
+        * @param profileKernel whether this counter should count kernel events
+        */
+       public void setProfileKernel(boolean profileKernel) {
+               _daemonEvent.setProfileKernel(profileKernel);
+       }
+       
+       /**
+        * Method setProfileUser.
+        * @param profileUser   whether this counter should count user events
+        */
+       public void setProfileUser(boolean profileUser) {
+               _daemonEvent.setProfileUser(profileUser);
+       }
+       
+       /**
+        * Method setCount.
+        * @param count the number of events between samples for this counter
+        */
+       public void setCount(int count) {
+               _daemonEvent.setResetCount(count);
+       }
+       
+       /**
+        * Saves this counter's configuration into the specified launch
+        * configuration.
+        * @param config        the launch configuration
+        */
+       public void saveConfiguration(ILaunchConfigurationWorkingCopy config) {
+               config.setAttribute(OprofileLaunchPlugin.ATTR_COUNTER_ENABLED(_number), _enabled);
+               if (_daemonEvent.getEvent() != null) {
+                       config.setAttribute(OprofileLaunchPlugin.ATTR_COUNTER_EVENT(_number), _daemonEvent.getEvent().getText());
+                       config.setAttribute(OprofileLaunchPlugin.ATTR_COUNTER_UNIT_MASK(_number), _daemonEvent.getEvent().getUnitMask().getMaskValue());
+               }
+               config.setAttribute(OprofileLaunchPlugin.ATTR_COUNTER_PROFILE_KERNEL(_number), _daemonEvent.getProfileKernel());
+               config.setAttribute(OprofileLaunchPlugin.ATTR_COUNTER_PROFILE_USER(_number), _daemonEvent.getProfileUser());
+               config.setAttribute(OprofileLaunchPlugin.ATTR_COUNTER_COUNT(_number), _daemonEvent.getResetCount());
+       }
+       
+       /**
+        * Loads a counter configuration from the specified launch configuration.
+        * @param config        the launch configuration
+        */
+       public void loadConfiguration(ILaunchConfiguration config) {
+               try {
+                       _enabled = config.getAttribute(OprofileLaunchPlugin.ATTR_COUNTER_ENABLED(_number), false);
+
+                       String str = config.getAttribute(OprofileLaunchPlugin.ATTR_COUNTER_EVENT(_number), ""); //$NON-NLS-1$
+                       _daemonEvent.setEvent(_eventFromString(str));
+
+                       if (_daemonEvent.getEvent() == null) {
+                               return;
+                       }
+                       
+                       
+                       int maskValue =  config.getAttribute(OprofileLaunchPlugin.ATTR_COUNTER_UNIT_MASK(_number), OpUnitMask.SET_DEFAULT_MASK);
+                       _daemonEvent.getEvent().getUnitMask().setMaskValue(maskValue);
+                       
+                       _daemonEvent.setProfileKernel(config.getAttribute(OprofileLaunchPlugin.ATTR_COUNTER_PROFILE_KERNEL(_number), false));
+                       _daemonEvent.setProfileUser(config.getAttribute(OprofileLaunchPlugin.ATTR_COUNTER_PROFILE_USER(_number), false));
+                       
+                       _daemonEvent.setResetCount(config.getAttribute(OprofileLaunchPlugin.ATTR_COUNTER_COUNT(_number), OprofileDaemonEvent.COUNT_UNINITIALIZED));
+               } catch (CoreException e) {
+                       e.printStackTrace();
+               }
+       }
+       
+       public OpUnitMask getUnitMask() {
+               OpEvent event = _daemonEvent.getEvent();
+               
+               if (event != null) {
+                       return event.getUnitMask();
+               } else {
+                       return null;
+               }
+       }
+       
+       /**
+        * Returns a textual label for this counter (used by UI)
+        * @return the label to use in widgets referring to this counter
+        */
+       public String getText() {
+               Object[] args = new Object[] {new Integer(_number)};
+               return MessageFormat.format(COUNTER_STRING, args);
+       }
+       
+       /**
+        * Method getNumber.
+        * @return the counter's number
+        */
+       public int getNumber() {
+               return _number;
+       }
+       
+       /**
+        * Method getEnabled.
+        * @return whether this counter is enabled
+        */
+       public boolean getEnabled() {
+               return _enabled;
+       }
+
+       /**
+        * Method getEvent.
+        * @return the event for this counter
+        */
+       public OpEvent getEvent() {
+               return _daemonEvent.getEvent();
+       }
+       
+       /**
+        * Method getProfileKernel.
+        * @return whether this counter is counting kernel events
+        */
+       public boolean getProfileKernel() {
+               return _daemonEvent.getProfileKernel();
+       }
+       
+       /**
+        * Method getProfileUser.
+        * @return whether this counter is counting user events
+        */
+       public boolean getProfileUser() {
+               return _daemonEvent.getProfileUser();
+       }
+
+       /**
+        * Method getCount.
+        * @return the number of events between samples for this counter
+        */
+       public int getCount() {
+               return _daemonEvent.getResetCount();
+       }
+       
+       /**
+        * Method getValidEvents.
+        * @return an array of all events that this counter can monitor
+        */
+       public OpEvent[] getValidEvents() {             
+               return _eventList;
+       }
+       
+       /**
+        * Gets the daemon event configuration for this counter.
+        * <B>Not</B> valid if this counter is not enabled!
+        * @return the OprofileDaemonEvent
+        */
+       public OprofileDaemonEvent getDaemonEvent() {
+               return _daemonEvent;
+       }
+
+       // Returns the event with the same label as the parameter STR
+       private OpEvent _eventFromString(String str) {
+               for (int i = 0; i < _eventList.length; i++) {
+                       if (_eventList[i].getText().equals(str))
+                               return _eventList[i];
+               }
+               
+               return null;
+       }
+}
+
diff --git a/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/oprofile/launch/configuration/OprofileEventConfigTab.java b/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/oprofile/launch/configuration/OprofileEventConfigTab.java
new file mode 100644 (file)
index 0000000..7ba1423
--- /dev/null
@@ -0,0 +1,916 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008, 2009 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Keith Seitz <keiths@redhat.com> - initial API and implementation
+ *    Kent Sebastian <ksebasti@redhat.com> -
+ *    
+ * CounterSubTab Contributors:
+ *    Keith Seitz <keiths@redhat.com> - initial API and implementation (before subclassing)
+ *    Kent Sebastian <ksebasti@redhat.com> - turned into a sub class,
+ *          changed layouts, fixed up some interactivity issues, ..
+ * 
+ * UnitMaskViewer Contributors:
+ *    Keith Seitz <keiths@redhat.com> - initial API and implementation
+ *    Kent Sebastian <ksebasti@redhat.com>
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.oprofile.launch.configuration;
+
+import java.text.MessageFormat;
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
+import org.eclipse.debug.ui.ILaunchConfigurationTab;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ListViewer;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.linuxtools.oprofile.core.Oprofile;
+import org.eclipse.linuxtools.oprofile.core.OprofileCorePlugin;
+import org.eclipse.linuxtools.oprofile.core.daemon.OpEvent;
+import org.eclipse.linuxtools.oprofile.core.daemon.OpUnitMask;
+import org.eclipse.linuxtools.oprofile.core.daemon.OprofileDaemonEvent;
+import org.eclipse.linuxtools.oprofile.launch.OprofileLaunchMessages;
+import org.eclipse.linuxtools.oprofile.launch.OprofileLaunchPlugin;
+import org.eclipse.linuxtools.profiling.launch.ProfileLaunchPlugin;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.ScrolledComposite;
+import org.eclipse.swt.custom.StackLayout;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.swt.widgets.TabItem;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
+
+import org.tizen.oprofile.core.OprofileComm;
+import org.tizen.oprofile.launch.DefaultSettingConstants;
+
+
+/**
+ * Thic class represents the event configuration tab of the launcher dialog.
+ */
+public class OprofileEventConfigTab extends AbstractLaunchConfigurationTab {
+       private Button _defaultEventCheck;
+       private OprofileCounter[] _counters ;
+       private CounterSubTab[] _counterSubTabs;
+       private StackLayout stackLayout = new StackLayout();
+       TabFolder tabFolder;
+       Group buttonGroup;
+
+       
+       
+       private boolean canInitialize; 
+
+       /**
+        * Essentially the constructor for this tab; creates the 'default event'
+        * checkbox and an appropriate number of counter tabs.
+        * @param parent the parent composite
+        */
+       public void createControl(Composite parent) {
+               Oprofile.initialize();
+               Composite top = new Composite(parent, SWT.NONE);
+               setControl(top);
+               top.setLayout(new GridLayout());
+               
+               // TODO : have to change help context id (temporarily empty string)
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), ""); //$NON-NLS-1$
+
+               //jinu added at 20090602----------------------
+               if(ProfileLaunchPlugin.checkTarget() == 0 || Oprofile.getOpInfo()==null){
+                       Label timerModeLabel = new Label(top, SWT.LEFT);
+                       timerModeLabel.setText(OprofileLaunchMessages.getString("common.notarget")); //$NON-NLS-1$
+                       canInitialize = false;
+                       return;
+               }else{
+                       canInitialize = true;
+               }
+               //--------------------------------------
+               
+               if (Oprofile.getTimerMode()) {
+                       Label timerModeLabel = new Label(top, SWT.LEFT);
+                       timerModeLabel.setText(OprofileLaunchMessages.getString("tab.event.timermode.no.options")); //$NON-NLS-1$
+               } else {
+                       createVerticalSpacer(top, 1);
+       
+                       _counters = OprofileCounter.getCounters(null);
+                       
+                       //default event checkbox
+                       _defaultEventCheck = new Button(top, SWT.CHECK);
+                       _defaultEventCheck.setText(OprofileLaunchMessages.getString("tab.event.defaultevent.button.text")); //$NON-NLS-1$
+                       _defaultEventCheck.setLayoutData(new GridData());
+                       _defaultEventCheck.addSelectionListener(new SelectionAdapter() {
+                               public void widgetSelected(SelectionEvent se) {
+                                       _handleEnabledToggle();
+                               }
+                       });
+       
+                       createVerticalSpacer(top, 1);
+                       
+                       //tabs for each of the counters
+                       OprofileCounter[] counters = OprofileCounter.getCounters(null);
+                       TabItem[] counterTabs = new TabItem[counters.length];
+                       _counterSubTabs = new CounterSubTab[counters.length];
+       
+                       //jinu added at 20090602 -------------------------------
+                       Composite stackComp = new Composite(top, SWT.NONE);
+                       stackComp.setLayout(stackLayout);
+                       stackComp.setLayoutData(new GridData(GridData.FILL_BOTH));
+                       
+                       buttonGroup = new Group(stackComp,SWT.BORDER);
+                       buttonGroup.setText("Supported Type");
+                       buttonGroup.setLayout(new GridLayout(1,false));
+                       
+                       String[][] defaultSettings = DefaultSettingConstants.getDefaultSettings();
+                       for(int i=0;i<defaultSettings.length;i++){
+                               Button button = new Button(buttonGroup, SWT.RADIO);
+                               button.setText(defaultSettings[i][0]);
+                               button.addSelectionListener(new SelectionAdapter() {
+                                       public void widgetSelected(SelectionEvent se) {
+                                               _handleDefaultSettingToggle();
+                                       }
+                               });
+                       }
+                       
+                       tabFolder = new TabFolder(stackComp, SWT.NONE);
+                       tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+                       //--------------------------------------
+       
+                       //jinu removed at 20090602
+                       /*
+                       TabFolder tabFolder = new TabFolder(top, SWT.NONE);
+                       tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+                        */
+       
+                       for (int i = 0; i < counters.length; i++) {
+                               Composite c = new Composite(tabFolder, SWT.NONE);
+                               CounterSubTab currentTab = new CounterSubTab(c, counters[i]);
+                               _counterSubTabs[i] = currentTab;
+                               
+                               counterTabs[i] = new TabItem(tabFolder, SWT.NONE);
+                               counterTabs[i].setControl(c);
+                               counterTabs[i].setText(OprofileLaunchMessages.getString("tab.event.counterTab.counterText") + String.valueOf(i)); //$NON-NLS-1$
+                       }
+                       
+               }
+       }
+       
+       //jinu added at 20090602
+       private void setButtonSelection(String keyStr){
+               Control[] controls = buttonGroup.getChildren();
+               for(int i=0;i<controls.length;i++){
+                       String str = ((Button)controls[i]).getText();
+                       
+                       if (str.equals(keyStr)){
+                               ((Button)controls[i]).setSelection(true);
+                               return;
+                       }
+               }
+               
+               if(controls.length>0)
+                       ((Button)controls[0]).setSelection(true);
+       }
+       
+       //jinu added at 20090602
+       private String getSelectedButton(){
+               Control[] controls = buttonGroup.getChildren();
+               String ret=null;
+               for(int i=0;i<controls.length;i++){
+                       boolean bool = ((Button)controls[i]).getSelection();
+                       
+                       if (bool){
+                               ret = ((Button)controls[i]).getText();
+                               break;
+                       }
+               }
+               
+               return ret;
+       }
+
+       //jinu added at 20090602
+       private void _handleDefaultSettingToggle(){
+               updateLaunchConfigurationDialog();
+       }
+       
+       /**
+        * @see ILaunchConfigurationTab#initializeFrom(ILaunchConfiguration)
+        */
+       public void initializeFrom(ILaunchConfiguration config) {
+               //jinu added at 20090602--------------------------------
+               if(!canInitialize){
+                       return;
+               }
+               //--------------------------------------
+               
+               if (!Oprofile.getTimerMode()) {
+                       try {
+                               for (int i = 0; i < _counters.length; i++) {
+                                       _counters[i].loadConfiguration(config);
+                               }
+                               
+                               for (CounterSubTab tab : _counterSubTabs) {
+                                       tab.initializeTab(config);
+                               }
+       
+                               boolean enabledState = config.getAttribute(OprofileLaunchPlugin.ATTR_USE_DEFAULT_EVENT, true);
+                               _defaultEventCheck.setSelection(enabledState);
+                               
+                               //jinu added at 20090602-----------------------------
+                               String type = config.getAttribute(OprofileLaunchPlugin.ATTR_SELECTED_DEFAULT_SETTING, "");
+                               setButtonSelection(type);
+                               //--------------------------------------
+                               
+                               setEnabledState(!enabledState);
+       
+                               updateLaunchConfigurationDialog();
+                       } catch (CoreException e) {
+                               e.printStackTrace();
+                       }
+               }
+       }
+
+       /**
+        * @see ILaunchConfigurationTab#isValid(ILaunchConfiguration)
+        */
+       public boolean isValid(ILaunchConfiguration config) {
+               //jinu added at 20090608--------------------------------
+               if(!canInitialize || ProfileLaunchPlugin.checkTarget() == 0){
+                       setErrorMessage(OprofileLaunchMessages.getString("common.notarget"));
+                       return false;
+               }
+               //--------------------------------------
+               
+               if (Oprofile.getTimerMode()) {
+                       return true;            //no options to check for validity
+               } else {
+                       int numEnabledEvents = 0;
+                       boolean valid = true;
+       
+                       try {
+                               if (config.getAttribute(OprofileLaunchPlugin.ATTR_USE_DEFAULT_EVENT, false)) {
+                                       numEnabledEvents = 1;
+                               } else {
+                                       //This seems like an odd way to validate, but since most of the validation
+                                       // is done with the OprofileDaemonEvent that the counter wraps, this
+                                       // is the easiest way.
+                                       OprofileCounter[] counters = new OprofileCounter[Oprofile.getNumberOfCounters()];
+                                       for (int i = 0; i < counters.length; i++) {
+                                               counters[i] = new OprofileCounter(i);
+                                               counters[i].loadConfiguration(config);
+                                               if (counters[i].getEnabled()) {
+                                                       ++numEnabledEvents;
+       
+                                                       if (counters[i].getEvent() == null) {
+                                                               valid = false;
+                                                               break;
+                                                       }
+       
+                                                       // First check min count
+                                                       int min = counters[i].getEvent().getMinCount();
+                                                       if (counters[i].getCount() < min) {
+                                                               valid = false;
+                                                               break;
+                                                       }
+       
+       
+                                                       // Next ask oprofile if it is valid
+                                                       //jinu removed at 20090618
+                                                       /*
+                                                       if (!OprofileLaunchPlugin.getCache().checkEvent(
+                                                                               counters[i].getNumber(), 
+                                                                               counters[i].getEvent().getNumber(),
+                                                                               counters[i].getEvent().getUnitMask().getMaskValue())) {
+                                                               valid = false;
+                                                               break;
+                                                       }
+                                                       */
+                                                       //jinu added but this is not unused. so remarked 
+                                                       /*
+                                                       if (!Oprofile.checkEvent(
+                                                                       counters[i].getEvent().getText(),
+                                                                       counters[i].getCount(),
+                                                                       counters[i].getEvent().getUnitMask().getMaskValue())) {
+                                                       valid = false;
+                                                       break;
+                                                       }
+                                                       */
+                                               }
+                                       }
+                               }
+                       } catch (CoreException e) {
+                               e.printStackTrace();
+                       }
+       
+                       return (numEnabledEvents > 0 && valid);
+               } 
+       }
+
+       /**
+        * @see ILaunchConfigurationTab#performApply(ILaunchConfigurationWorkingCopy)
+        */
+       public void performApply(ILaunchConfigurationWorkingCopy config) {
+               //jinu added at 20090602-------------------------------
+               if(!canInitialize || ProfileLaunchPlugin.checkTarget() == 0){
+                       return;
+               }
+               //--------------------------------------
+               
+               if (Oprofile.getTimerMode()) {
+                       config.setAttribute(OprofileLaunchPlugin.ATTR_USE_DEFAULT_EVENT, true);
+               } else {
+                       config.setAttribute(OprofileLaunchPlugin.ATTR_USE_DEFAULT_EVENT, _defaultEventCheck.getSelection());
+                       
+                       //jinu added at 20090602
+                       config.setAttribute(OprofileLaunchPlugin.ATTR_SELECTED_DEFAULT_SETTING, getSelectedButton());
+                       
+                       for (CounterSubTab cst : _counterSubTabs) {
+                               cst.performApply(config);
+                       }
+               }
+       }
+
+       /**
+        * @see ILaunchConfigurationTab#setDefaults(ILaunchConfigurationWorkingCopy)
+        */
+       
+       public void setDefaults(ILaunchConfigurationWorkingCopy config) {
+               // commented by greatim at 2011.06.01 for fresh ide
+               //jinu added at 20090616
+//             config.setAttribute(ISMLCDTLaunchConstants.ATTR_LAUNCH_MODE, "oprofile");
+               //config.setAttribute(ISMLCDTLaunchConstants.ATTR_SKIP_DOWNLOAD, false);
+               
+               //jinu removed at 20090616
+               /*
+               boolean useDefault = true;
+               
+               // When instantiated, the OprofileCounter will set defaults.
+               if(_counters!=null){
+                       for (int i = 0; i < _counters.length; i++) {
+                               _counters[i].saveConfiguration(config);
+                               if (_counters[i].getEnabled()) {
+                                       useDefault = false;
+                               }
+                       }
+               }
+
+               config.setAttribute(OprofileLaunchPlugin.ATTR_USE_DEFAULT_EVENT, useDefault);
+               */
+       }
+       
+       
+       /**
+        * @see ILaunchConfigurationTab#getName()
+        */
+       public String getName() {
+               return OprofileLaunchMessages.getString("tab.event.name"); //$NON-NLS-1$
+       }
+
+       /**
+        * @see ILaunchConfigurationTab#getImage()
+        */
+       @Override
+       public Image getImage() {
+               return OprofileLaunchPlugin.getImageDescriptor(OprofileLaunchPlugin.ICON_EVENT_TAB).createImage();
+       }
+
+       /**
+        * Handles the toggling of the default event check box. Not meant to be called
+        * directly.
+        */
+       private void _handleEnabledToggle() {
+               setEnabledState(!_defaultEventCheck.getSelection());
+               updateLaunchConfigurationDialog();
+       }
+       
+       /**
+        * Sets the state of the child counter tabs' widgets.
+        * @param state true for enabled, false for disabled
+        */
+       private void setEnabledState(boolean state) {
+               //jinu added at 20090602-------------------------------
+               if(!state)
+                       stackLayout.topControl = buttonGroup;
+               else
+                       stackLayout.topControl = tabFolder;
+               //--------------------------------------
+               
+               for (CounterSubTab cst : _counterSubTabs) {
+                       cst.setEnabledState(state);
+               }
+       }
+
+       
+       /**
+        * A sub-tab of the OprofileEventConfigTab launch configuration tab. 
+        * Essentially, it is a frontend to an OprofileCounter. This is an 
+        * inner class because it requires methods from the parent tab (such as
+        * updateLaunchConfigurationDialog() when a widget changes state).
+        */ 
+       class CounterSubTab {
+               private Button _enabledCheck;
+               private Button _profileKernelCheck;
+               private Button _profileUserCheck;
+               private Label _countTextLabel;
+               private Text _countText;
+               private Label _eventDescLabel;
+               private Text _eventDescText;
+               private UnitMaskViewer _unitMaskViewer;
+               private ListViewer _eventList;
+               private OprofileCounter _counter;
+               
+               private ScrolledComposite _scrolledTop;
+               private Composite _tabTopContainer;
+
+               /**
+                * Constructor for a subtab. Creates the layout and widgets for its content.
+                * @param parent composite the widgets will be created in 
+                * @param counter the associated OprofileCounter object
+                */
+               public CounterSubTab(Composite parent, OprofileCounter counter) {
+                       _counter = counter;
+
+                       parent.setLayout(new GridLayout());
+
+                       //scrollable composite on top
+                       ScrolledComposite scrolledContainer = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
+                       scrolledContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+                       GridLayout layout = new GridLayout();
+                       layout.marginHeight = 0;
+                       layout.marginWidth = 0;
+                       scrolledContainer.setLayout(layout);
+                       scrolledContainer.setExpandHorizontal(true);
+                       scrolledContainer.setExpandVertical(true);
+                       
+                       //composite to contain the rest of the tab
+                       Composite tabTopContainer = new Composite(scrolledContainer, SWT.NONE);
+                       scrolledContainer.setContent(tabTopContainer);
+                       layout = new GridLayout();
+                       layout.marginHeight = 0;
+                       layout.marginWidth = 0;
+                       layout.numColumns = 2;
+                       tabTopContainer.setLayout(layout);
+                       tabTopContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); 
+
+                       //top cell
+                       Composite topCellComp = new Composite(tabTopContainer, SWT.NONE);
+                       layout = new GridLayout();
+                       layout.marginHeight = 0;
+                       layout.marginWidth = 0;
+                       layout.numColumns = 2;
+                       topCellComp.setLayout(layout);
+                       topCellComp.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1));
+                       
+                       createTopCell(topCellComp);
+                       
+                       createVerticalSpacer(tabTopContainer, 2);
+                       
+                       //left side composite group for eventList
+                       Composite eventListComp = new Composite(tabTopContainer, SWT.NONE);
+                       layout = new GridLayout();
+                       layout.marginHeight = 0;
+                       layout.marginWidth = 0;
+                       eventListComp.setLayout(layout);
+                       //layoutdata is set later
+
+                       createLeftCell(eventListComp);
+                       
+                       
+                       //right side composite group for other event config and unit mask
+                       Composite eventConfigComp = new Composite(tabTopContainer, SWT.NONE);
+                       layout = new GridLayout();
+                       layout.numColumns = 2;
+                       layout.marginHeight = 0;
+                       layout.marginWidth = 0;
+                       eventConfigComp.setLayout(layout);
+                       eventConfigComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+                       
+                       createRightCell(eventConfigComp);
+
+                       
+                       //set the list's composite layout based on the right cell's size
+                       GridData data = new GridData(SWT.FILL, SWT.FILL, false, true);
+                       data.heightHint = eventConfigComp.getSize().x;
+                       eventListComp.setLayoutData(data);
+                       
+                       _scrolledTop = scrolledContainer;
+                       _tabTopContainer = tabTopContainer;
+               }
+               
+               /**
+                * Creates the "Enabled" checkbox, and the event description text.
+                * @param parent composite these widgets will be created in
+                */
+               private void createTopCell(Composite parent) {
+                       //checkbox
+                       _enabledCheck = new Button(parent, SWT.CHECK);
+                       _enabledCheck.setText(OprofileLaunchMessages.getString("tab.event.counterSettings.enabled.button.text")); //$NON-NLS-1$
+                       _enabledCheck.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
+                       _enabledCheck.addSelectionListener(new SelectionAdapter() {
+                               public void widgetSelected(SelectionEvent se) {
+                                       _counter.setEnabled(_enabledCheck.getSelection());
+                                       _setEnabledState(_counter.getEnabled());
+                                       updateLaunchConfigurationDialog();
+                               }
+                       });
+                       _enabledCheck.setEnabled(false);
+                       
+                       //label for textbox
+                       _eventDescLabel = new Label(parent, SWT.NONE);
+                       _eventDescLabel.setText(OprofileLaunchMessages.getString("tab.event.eventDescription.label.text")); //$NON-NLS-1$
+                       _eventDescLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
+
+                       //textbox
+                       _eventDescText = new Text(parent, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY);
+                       _eventDescText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+               }
+
+               /**
+                * Creates the event list widget.
+                * @param parent composite these widgets will be created in
+                */
+               private void createLeftCell(Composite parent) {
+                       _eventList = new ListViewer(parent, SWT.SINGLE | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
+                       _eventList.getList().setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, true));
+
+                       _eventList.setLabelProvider(new ILabelProvider(){
+                               public String getText(Object element) {
+                                       OpEvent e = (OpEvent) element;
+                                       return e.getText();
+                               }
+                               public Image getImage(Object element) { return null; }
+                               public void addListener(ILabelProviderListener listener) { }
+                               public void dispose() { }
+                               public boolean isLabelProperty(Object element, String property) { return false; }
+                               public void removeListener(ILabelProviderListener listener) { }
+                       });
+                       
+                       _eventList.setContentProvider(new IStructuredContentProvider() {
+                               public Object[] getElements(Object inputElement) {
+                                       OprofileCounter ctr = (OprofileCounter) inputElement;
+                                       return (OpEvent[]) ctr.getValidEvents();
+                               }
+                               public void dispose() { }
+                               public void inputChanged(Viewer arg0, Object arg1, Object arg2) { }
+                       });
+
+                       //adds the events to the list from the counter
+                       _eventList.setInput(_counter);
+                       
+                       _eventList.addSelectionChangedListener(new ISelectionChangedListener() {
+                               public void selectionChanged(SelectionChangedEvent sce) {
+                                       _handleEventListSelectionChange();
+                               }
+                       });
+               }
+               
+               /**
+                * Creates the 2 profile space checkboxes, event count and unit mask widget.
+                * @param parent composite these widgets will be created in
+                */
+               private void createRightCell(Composite parent) {
+                       //profile kernel checkbox
+                       _profileKernelCheck = new Button(parent, SWT.CHECK);
+                       _profileKernelCheck.setText(OprofileLaunchMessages.getString("tab.event.counterSettings.profileKernel.check.text")); //$NON-NLS-1$
+                       _profileKernelCheck.addSelectionListener(new SelectionAdapter() {
+                               public void widgetSelected(SelectionEvent se) {
+                                       _handleProfileKernelToggle();
+                               }
+                       });
+                       
+                       //profile user checkbox -- should this ever be disabled?
+                       _profileUserCheck = new Button(parent, SWT.CHECK);
+                       _profileUserCheck.setText(OprofileLaunchMessages.getString("tab.event.counterSettings.profileUser.check.text")); //$NON-NLS-1$
+                       _profileUserCheck.addSelectionListener(new SelectionAdapter() {
+                               public void widgetSelected(SelectionEvent se) {
+                                       _handleProfileUserToggle();
+                               }
+                       });
+                       
+                       //event count label/text 
+                       _countTextLabel = new Label(parent, SWT.NONE);
+                       _countTextLabel.setText(OprofileLaunchMessages.getString("tab.event.counterSettings.count.label.text")); //$NON-NLS-1$
+                       _countText = new Text(parent, SWT.SINGLE | SWT.BORDER);
+                       _countText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+                       _countText.addModifyListener(new ModifyListener() {
+                               public void modifyText(ModifyEvent me) {
+                                       _handleCountTextModify();
+                               }
+                       });
+
+                       //unit mask widget
+                       Composite unitMaskComp = new Composite(parent, SWT.NONE);
+                       GridLayout layout = new GridLayout();
+                       layout.marginHeight = 0;
+                       layout.marginWidth = 0;
+                       unitMaskComp.setLayout(layout);
+                       unitMaskComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
+
+                       _unitMaskViewer = new UnitMaskViewer(unitMaskComp);
+               }
+               
+               /**
+                * Initializes the tab on first creation.
+                * @param config default configuration for the counter and the associated widgets
+                */
+               public void initializeTab(ILaunchConfiguration config) {
+                       //make all controls inactive, since the 'default event' checkbox
+                       // is checked by default
+                       setEnabledState(false);
+                       
+                       if (config != null) {
+                               _counter.loadConfiguration(config);
+                       }
+
+                       boolean enabled = _counter.getEnabled();
+                       _enabledCheck.setSelection(enabled);
+
+                       if (_counter.getEvent() == null) {
+                               // Default to first in list
+                               _counter.setEvent(_counter.getValidEvents()[0]);
+                       }
+
+                       //load default states
+                       _profileKernelCheck.setSelection(_counter.getProfileKernel());
+                       _profileUserCheck.setSelection(_counter.getProfileUser());
+                       _countText.setText(Integer.toString(_counter.getCount()));
+                       _eventDescText.setText(_counter.getEvent().getTextDescription());
+                       _unitMaskViewer.displayEvent(_counter.getEvent());
+                       _eventList.setSelection(new StructuredSelection(_counter.getEvent()));
+               }
+               
+               /**
+                * Applies the tab's current state to the launch configuration.
+                * @param config launch config to apply to
+                */
+               public void performApply(ILaunchConfigurationWorkingCopy config) {
+                       _counter.saveConfiguration(config);
+               }
+
+               /**
+                * Enables/disables the widgets in this tab.
+                * @param state true to enable to the counter's state, false to disable all
+                */
+               public void setEnabledState(boolean state) {
+                       _enabledCheck.setEnabled(state);
+                       
+                       if (state) {
+                               _setEnabledState(_counter.getEnabled());
+                       } else {
+                               _setEnabledState(false);
+                       }
+               }
+               
+               /**
+                * Method split from setEnabledState to avoid code duplication.
+                * Not meant to be called directly.
+                * @param state true to enable all widgets, false to disable all widgets
+                */
+               private void _setEnabledState(boolean state) {
+                       _profileKernelCheck.setEnabled(state);
+                       _profileUserCheck.setEnabled(state);
+                       _countText.setEnabled(state);
+                       _eventDescText.setEnabled(state);
+                       _unitMaskViewer.setEnabled(state);
+                       _eventList.getList().setEnabled(state);
+               }
+
+               /**
+                * Handling method for the event list. Gets the selection from the listviewer 
+                * and updates the UnitMask and event description text box. 
+                */
+               private void _handleEventListSelectionChange() {
+                       int index = _eventList.getList().getSelectionIndex();
+                       OpEvent event = (OpEvent) _eventList.getElementAt(index);
+                       _counter.setEvent(event);
+                       _eventDescText.setText(event.getTextDescription());
+                       _unitMaskViewer.displayEvent(event);
+
+                       // Check the min count to update the error message (events can have
+                       // different minimum reset counts)
+                       int min = _counter.getEvent().getMinCount();
+                       if (_counter.getCount() < min) {
+                               setErrorMessage(getMinCountErrorMessage(min));
+                       }
+
+                       updateLaunchConfigurationDialog();
+               }
+               
+               /**
+                * Handles the toggling of the "profile user" button.
+                */
+               private void _handleProfileUserToggle() {
+                       _counter.setProfileUser(_profileUserCheck.getSelection());
+                       updateLaunchConfigurationDialog();
+               }
+
+               /**
+                * Handles the toggling of the "profile kernel" button.
+                */
+               private void _handleProfileKernelToggle() {
+                       _counter.setProfileKernel(_profileKernelCheck.getSelection());
+                       updateLaunchConfigurationDialog();
+               }
+               
+               /**
+                * Handles text modify events in the count text widget.
+                */
+               private void _handleCountTextModify() {
+                       String errorMessage = null;
+                       try {
+
+                               // This seems counter-intuitive, but we must save the count
+                               // so that isValid knows this launch config is invalid
+                               int count = Integer.parseInt(_countText.getText());
+                               _counter.setCount(count);
+
+                               // Check minimum count
+                               int min = _counter.getEvent().getMinCount();
+                               if (count < min) {
+                                       errorMessage = getMinCountErrorMessage(min);
+                               }
+                       } catch (NumberFormatException e) {
+                               errorMessage = OprofileLaunchMessages.getString("tab.event.counterSettings.count.invalid"); //$NON-NLS-1$
+                               _counter.setCount(OprofileDaemonEvent.COUNT_INVALID);
+                       } finally {
+                               setErrorMessage(errorMessage);
+                               updateLaunchConfigurationDialog();
+                       }
+               }
+               
+               /**
+                * Returns a string with the minimum allowed count, suitable foruse with setErrorMessage().
+                * @param min minimum count
+                * @return a String containing the error message
+                */
+               private String getMinCountErrorMessage(int min) {
+                       String msg = OprofileLaunchMessages.getString("tab.event.counterSettings.count.too-small"); //$NON-NLS-1$
+                       Object[] args = new Object[] { new Integer(min) };
+                       return MessageFormat.format(msg, args);
+               }
+               
+               /**
+                * Changes parameters for the top scrolled composite which makes the scroll bars
+                * appear when content overflows the visible area. Called by the UnitMaskViewer 
+                * whenever a new set of unit mask buttons are created, since the number of them is
+                * variable and there is no guarantee as to the default size of the launch configuration
+                * dialog in general.
+                */
+               private void resizeScrollContainer() {
+                       _scrolledTop.setMinSize(_tabTopContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT));
+               }
+               
+               
+               /**
+                * This class displays event unit masks via check boxes and appropriate labels.
+                */
+               class UnitMaskViewer {
+                       private Label _unitMaskLabel;
+                       private Composite _top;
+                       private Composite _maskListComp;
+                       private Button[] _unitMaskButtons;
+
+                       /**
+                        * Constructor, creates the widget.
+                        * @param parent composite the widget will be created in
+                        */
+                       public UnitMaskViewer(Composite parent) {
+                               //"Unit Mask:" label
+                               _unitMaskLabel = new Label(parent, SWT.NONE);
+                               _unitMaskLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
+                               _unitMaskLabel.setText(OprofileLaunchMessages.getString("unitmaskViewer.label.text")); //$NON-NLS-1$
+                               _unitMaskLabel.setVisible(true);
+
+                               //composite to contain the button widgets
+                               Composite top = new Composite(parent, SWT.NONE);
+                               top.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+                               GridLayout layout = new GridLayout();
+                               layout.marginHeight = 0;
+                               layout.marginWidth = 0;
+                               top.setLayout(layout);
+                               _top = top;
+                               
+                               _maskListComp = null;
+                               _unitMaskButtons = null;
+                       }
+
+                       /**
+                        * Handles button toggles; updates the counter's unit mask to the appropriate value.
+                        * @param maskButton the button object
+                        * @param index the button's mask index (used in OpUnitMask for a proper mask value) 
+                        */
+                       private void _handleToggle(Button maskButton, int index) {
+                               OpUnitMask mask = _counter.getUnitMask();
+                               if (mask != null) {
+                                       if (maskButton.getSelection()) {
+                                               mask.setMaskFromIndex(index);
+                                       } else {
+                                               mask.unSetMaskFromIndex(index);
+                                       }
+                               }
+
+                               //update the parent tab
+                               updateLaunchConfigurationDialog();
+                       }
+
+                       /**
+                        * Disposes of the old unit mask check list and creates a new one with 
+                        *   the appropriate default value. 
+                        * @param oe the event
+                        */
+                       public void displayEvent(OpEvent oe) {
+                               OpUnitMask mask = oe.getUnitMask();
+                               int totalMasks = mask.getNumMasks();
+                               
+                               if (_maskListComp != null) {
+                                       _maskListComp.dispose();
+                               }
+                               
+                               Composite newMaskComp = new Composite(_top, SWT.NONE);
+                               newMaskComp.setLayout(new GridLayout());
+                               newMaskComp.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, true));
+                               _maskListComp = newMaskComp;
+
+                               //creates these buttons with the default masks
+                               mask.setDefaultMaskValue();
+                               
+                               ArrayList<Button> maskButtons = new ArrayList<Button>();
+                               
+                               for (int i = 0; i < totalMasks; i++) {
+                                       Button maskButton;
+
+                                       if (mask.getType() == OpUnitMask.INVALID) {
+                                               //big problem, most likely parsing went awry or opxml output mangled
+                                               OprofileCorePlugin.showErrorDialog("opxmlParse", null); //$NON-NLS-1$
+                                               return;
+                                       } else if (mask.getType() == OpUnitMask.MANDATORY) {
+                                               maskButton = new Button(newMaskComp, SWT.RADIO);
+                                               maskButton.setEnabled(false);
+                                               maskButton.setText(mask.getText(i));
+                                               maskButton.setSelection(true);
+                                       } else {
+                                               int buttonType;
+                                               final int maskButtonIndex = i;
+                                               boolean selected = mask.isMaskSetFromIndex(maskButtonIndex);
+
+                                               if (mask.getType() == OpUnitMask.EXCLUSIVE) {
+                                                       buttonType = SWT.RADIO;
+                                               } else {        //mask type is OpUnitMask.BITMASK
+                                                       buttonType = SWT.CHECK;
+                                               }
+                                               
+                                               maskButton = new Button(newMaskComp, buttonType);
+                                               maskButton.setEnabled(true);
+                                               maskButton.setText(mask.getText(i));
+                                               maskButton.setSelection(selected);
+                                               maskButton.addSelectionListener(new SelectionAdapter() {
+                                                       public void widgetSelected(SelectionEvent se) {
+                                                               _handleToggle((Button)se.getSource(), maskButtonIndex);
+                                                       }
+                                               });
+                                               
+                                               maskButtons.add(maskButton);
+                                       }
+                               }
+                               
+                               _unitMaskButtons = new Button[maskButtons.size()];
+                               maskButtons.toArray(_unitMaskButtons);
+                               
+                               resizeScrollContainer();
+                       }
+
+                       /**
+                        * Enables and disables the viewer for UI input
+                        * @param enabled whether this viewer should be enabled
+                        */
+                       public void setEnabled(boolean enabled) {
+                               if (_unitMaskButtons != null) {
+                                       for (Button b : _unitMaskButtons) {
+                                               b.setEnabled(enabled);
+                                       }
+                               }
+                       }
+               }
+       }
+}
diff --git a/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/oprofile/launch/configuration/OprofileLaunchConfigurationTabGroup.java b/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/oprofile/launch/configuration/OprofileLaunchConfigurationTabGroup.java
new file mode 100644 (file)
index 0000000..9ab1ce1
--- /dev/null
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Kent Sebastian <ksebasti@redhat.com> - initial API and implementation 
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.oprofile.launch.configuration;
+
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
+import org.eclipse.linuxtools.profiling.launch.ProfileLaunchConfigurationTabGroup;
+
+public class OprofileLaunchConfigurationTabGroup extends ProfileLaunchConfigurationTabGroup {
+       @Override
+       public AbstractLaunchConfigurationTab[] getProfileTabs() {
+               //jinu modified at 20090602
+               //return new AbstractLaunchConfigurationTab[] { new OprofileSetupTab(), new OprofileEventConfigTab() };
+               return new AbstractLaunchConfigurationTab[] { new OprofileEventConfigTab() };
+       }
+}
diff --git a/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/oprofile/launch/configuration/OprofileSetupTab.java b/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/oprofile/launch/configuration/OprofileSetupTab.java
new file mode 100644 (file)
index 0000000..c1e97bf
--- /dev/null
@@ -0,0 +1,267 @@
+/*******************************************************************************
+ * Copyright (c) 2004,2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Keith Seitz <keiths@redhat.com> - initial API and implementation
+ *    Kent Sebastian <ksebasti@redhat.com> - 
+ *******************************************************************************/
+package org.eclipse.linuxtools.oprofile.launch.configuration;
+
+import java.io.File;
+import java.text.MessageFormat;
+
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
+import org.eclipse.linuxtools.oprofile.core.daemon.OprofileDaemonOptions;
+import org.eclipse.linuxtools.oprofile.launch.OprofileLaunchMessages;
+import org.eclipse.linuxtools.oprofile.launch.OprofileLaunchPlugin;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * This tab is used by the launcher to configure global oprofile run options.
+ */
+public class OprofileSetupTab extends AbstractLaunchConfigurationTab {
+       private Text _kernelImageFileText;
+       
+       private Button _checkSeparateLibrary;
+       private Button _checkSeparateKernel;
+       //maybe these later
+//     private Button _checkSeparateThread;
+//     private Button _checkSeparateCpu;
+
+       private static LaunchOptions _options = null;
+
+       public String getName() {
+               return OprofileLaunchMessages.getString("tab.global.name"); //$NON-NLS-1$
+       }
+
+       public boolean isValid(ILaunchConfiguration config) {
+               boolean b = _options.isValid();
+               // System.out.println("SetupTab isValid = " + b);
+               return b;
+       }
+
+       public void performApply(ILaunchConfigurationWorkingCopy config) {
+               _options.saveConfiguration(config);
+       }
+
+       public void initializeFrom(ILaunchConfiguration config) {
+               _options.loadConfiguration(config);
+               
+               int separate = _options.getSeparateSamples();
+               
+               if (separate == OprofileDaemonOptions.SEPARATE_NONE) {
+                       _checkSeparateLibrary.setSelection(false);
+                       _checkSeparateKernel.setSelection(false);
+               } else {
+                       //note that opcontrol will nicely ignore the trailing comma
+                       if ((separate & OprofileDaemonOptions.SEPARATE_LIBRARY) != 0)
+                               _checkSeparateLibrary.setSelection(true);
+                       if ((separate & OprofileDaemonOptions.SEPARATE_KERNEL) != 0)
+                               _checkSeparateKernel.setSelection(true);
+//                     if ((separate & OprofileDaemonOptions.SEPARATE_THREAD) != 0)
+//                             _checkSeparateThread.setSelection(true);
+//                     if ((separate & OprofileDaemonOptions.SEPARATE_CPU) != 0)
+//                             _checkSeparateCpu.setSelection(true);
+               }
+       }
+
+       public void setDefaults(ILaunchConfigurationWorkingCopy config) {
+               _options = new LaunchOptions();
+               _options.saveConfiguration(config);
+       }
+       
+       @Override
+       public Image getImage() {
+               return OprofileLaunchPlugin.getImageDescriptor(OprofileLaunchPlugin.ICON_GLOBAL_TAB).createImage();
+       }
+
+       public void createControl(Composite parent) {
+               _options = new LaunchOptions();
+
+               Composite top = new Composite(parent, SWT.NONE);
+               setControl(top);
+               top.setLayout(new GridLayout());
+
+               GridData data;
+               GridLayout layout;
+               createVerticalSpacer(top, 1);
+
+               // Create container for kernel image file selection
+               Composite p = new Composite(top, SWT.NONE);
+               layout = new GridLayout();
+               layout.numColumns = 2;
+               layout.marginHeight = 0;
+               layout.marginWidth = 0;
+               p.setLayout(layout);
+               data = new GridData(GridData.FILL_HORIZONTAL);
+               p.setLayoutData(data);
+
+               Label l = new Label(p, SWT.NONE);
+               l.setText(OprofileLaunchMessages.getString("tab.global.kernelImage.label.text")); //$NON-NLS-1$
+               data = new GridData();
+               data.horizontalSpan = 2;
+               l.setLayoutData(data);
+
+               _kernelImageFileText = new Text(p, SWT.SINGLE | SWT.BORDER);
+               data = new GridData(GridData.FILL_HORIZONTAL);
+               _kernelImageFileText.setLayoutData(data);
+               _kernelImageFileText.addModifyListener(new ModifyListener() {
+                       public void modifyText(ModifyEvent mev) {
+                               _handleKernelImageFileTextModify(_kernelImageFileText);
+                       };
+               });
+
+               Button button = createPushButton(p, OprofileLaunchMessages.getString("tab.global.kernelImage.browse.button.text"), null); //$NON-NLS-1$
+               final Shell shell = top.getShell();
+               button.addSelectionListener(new SelectionAdapter() {
+                       public void widgetSelected(SelectionEvent sev) {
+                               _showFileDialog(shell);
+                       }
+               });
+
+               createVerticalSpacer(top, 1);
+
+               // Create checkbox options container
+               p = new Composite(top, SWT.NONE);
+               layout = new GridLayout();
+               layout.numColumns = 1;
+               layout.marginHeight = 0;
+               layout.marginWidth = 0;
+               p.setLayout(layout);
+               data = new GridData(GridData.FILL_HORIZONTAL);
+               data.horizontalSpan = 2;
+               p.setLayoutData(data);
+
+               _checkSeparateLibrary = _createCheckButton(p, OprofileLaunchMessages.getString("tab.global.check.separateLibrary.text")); //$NON-NLS-1$
+               _checkSeparateKernel = _createCheckButton(p, OprofileLaunchMessages.getString("tab.global.check.separateKernel.text")); //$NON-NLS-1$
+//             _checkSeparateThread = _createCheckButton(p, OprofileLaunchMessages.getString("tab.global.check.separateThread.text")); //$NON-NLS-1$
+//             _checkSeparateCpu = _createCheckButton(p, OprofileLaunchMessages.getString("tab.global.check.separateCpu.text")); //$NON-NLS-1$
+       }
+
+       // convenience method to create radio buttons with the given label
+       private Button _createCheckButton(Composite parent, String label) {
+               final Button b = new Button(parent, SWT.CHECK);
+               b.setText(label);
+               b.addSelectionListener(new SelectionAdapter() {
+                       public void widgetSelected(SelectionEvent se) {
+                               _handleCheckSelected(b);
+                       }
+               });
+
+               return b;
+       }
+
+       //sets the proper separation mask for sample separation 
+       private void _handleCheckSelected(Button button) {
+               int oldSeparate = _options.getSeparateSamples();
+               int newSeparate = oldSeparate;          //initalize
+               
+               if (button == _checkSeparateLibrary) {
+                       if (button.getSelection()) {
+                               newSeparate = oldSeparate | OprofileDaemonOptions.SEPARATE_LIBRARY;
+                       } else {
+                               newSeparate = oldSeparate & ~OprofileDaemonOptions.SEPARATE_LIBRARY;
+                       }
+               } else if (button == _checkSeparateKernel) {
+                       if (button.getSelection()) {
+                               newSeparate = oldSeparate | OprofileDaemonOptions.SEPARATE_KERNEL;
+                       } else {
+                               newSeparate = oldSeparate & ~OprofileDaemonOptions.SEPARATE_KERNEL;
+                       }
+//             } else if (button == _checkSeparateThread) {
+//                     if (button.getSelection()) {
+//                             newSeparate = oldSeparate | OprofileDaemonOptions.SEPARATE_THREAD;
+//                     } else {
+//                             newSeparate = oldSeparate & ~OprofileDaemonOptions.SEPARATE_THREAD;
+//                     }
+//             } else if (button == _checkSeparateCpu) {
+//                     if (button.getSelection()) {
+//                             newSeparate = oldSeparate | OprofileDaemonOptions.SEPARATE_CPU;
+//                     } else {
+//                             newSeparate = oldSeparate & ~OprofileDaemonOptions.SEPARATE_CPU;
+//                     }
+               }
+               
+               _options.setSeparateSamples(newSeparate);
+
+               updateLaunchConfigurationDialog();
+       }
+
+       // handles text modification events for all text boxes in this tab
+       private void _handleKernelImageFileTextModify(Text text) {
+               String errorMessage = null;
+               String filename = text.getText();
+
+               if (filename.length() > 0) {
+                       File file = new File(filename);
+                       if (!file.exists() || !file.isFile()) {
+                               String msg = OprofileLaunchMessages.getString("tab.global.kernelImage.kernel.nonexistent"); //$NON-NLS-1$
+                               Object[] args = new Object[] { filename };
+                               errorMessage = MessageFormat.format(msg, args);
+                       }
+
+                       //seems odd, but must set it even if it is invalid so that performApply
+                       // and isValid work properly
+                       _options.setKernelImageFile(filename);
+               } else {
+                       // no kernel image file
+                       _options.setKernelImageFile(new String());
+               }
+
+               // Update dialog and error message
+               setErrorMessage(errorMessage);
+               updateLaunchConfigurationDialog();
+       }
+
+       // Displays a file dialog to allow the user to select the kernel image file
+       private void _showFileDialog(Shell shell) {
+               FileDialog d = new FileDialog(shell, SWT.OPEN);
+               File kernel = new File(_options.getKernelImageFile());
+               if (!kernel.exists()) {
+                       kernel = new File("/boot");     //$NON-NLS-1$
+                       if (!kernel.exists())
+                               kernel = new File("/");         //$NON-NLS-1$
+               }
+               d.setFileName(kernel.toString());
+               d.setText(OprofileLaunchMessages.getString("tab.global.selectKernelDialog.text")); //$NON-NLS-1$
+               String newKernel = d.open();
+               if (newKernel != null) {
+                       kernel = new File(newKernel);
+                       if (!kernel.exists()) {
+                               MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.RETRY | SWT.CANCEL);
+                               mb.setMessage(OprofileLaunchMessages.getString("tab.global.selectKernelDialog.error.kernelDoesNotExist.text"));         //$NON-NLS-1$
+                               switch (mb.open()) {
+                                       case SWT.RETRY:
+                                               // Ok, it's recursive, but it shouldn't matter
+                                               _showFileDialog(shell);
+                                               break;
+                                       default:
+                                       case SWT.CANCEL:
+                                               break;
+                               }
+                       } else {
+                               _kernelImageFileText.setText(newKernel);
+                       }
+               }
+       }
+}
diff --git a/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/oprofile/launch/launching/OprofileLaunchConfigurationDelegate.java b/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/oprofile/launch/launching/OprofileLaunchConfigurationDelegate.java
new file mode 100644 (file)
index 0000000..debae73
--- /dev/null
@@ -0,0 +1,235 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008, 2009 Red Hat, Inc. and others
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Kent Sebastian <ksebasti@redhat.com> - initial API and implementation
+ *    Keith Seitz <keiths@redhat.com> - setup code in launch the method, initially 
+ *        written in the now-defunct OprofileSession class
+ *    QNX Software Systems and others - the section of code marked in the launch 
+ *        method, and the exec method
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.oprofile.launch.launching;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+
+import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
+import org.eclipse.cdt.launch.AbstractCLaunchDelegate;
+import org.eclipse.cdt.utils.pty.PTY;
+import org.eclipse.cdt.utils.spawner.ProcessFactory;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.core.ILaunchesListener2;
+import org.eclipse.linuxtools.oprofile.core.OpcontrolException;
+import org.eclipse.linuxtools.oprofile.core.OprofileCorePlugin;
+import org.eclipse.linuxtools.oprofile.core.daemon.OprofileDaemonEvent;
+import org.eclipse.linuxtools.oprofile.launch.OprofileLaunchPlugin;
+import org.eclipse.linuxtools.oprofile.launch.configuration.LaunchOptions;
+import org.eclipse.linuxtools.oprofile.launch.configuration.OprofileCounter;
+import org.eclipse.linuxtools.oprofile.ui.OprofileUiPlugin;
+import org.eclipse.linuxtools.oprofile.ui.view.OprofileView;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+
+import org.tizen.oprofile.launch.DefaultSettingConstants;
+
+
+public class OprofileLaunchConfigurationDelegate extends AbstractCLaunchDelegate {
+
+       @Override
+       public void launch(ILaunchConfiguration config, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
+               //FIXME: this assumes that project names are always the directory names in the workspace.
+               //this assumption may be wrong, but a shallow lookup seems ok
+               String workspacePath = ResourcesPlugin.getWorkspace().getRoot().getLocation().toString();
+               String imagePath = workspacePath
+                               + Path.SEPARATOR
+                               + config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, "") //$NON-NLS-1$
+                               + Path.SEPARATOR
+                               + config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, ""); //$NON-NLS-1$
+               
+               LaunchOptions options = new LaunchOptions();            //default options created in the constructor
+               options.loadConfiguration(config);
+               options.setBinaryImage(imagePath);
+
+               //if daemonEvents null or zero size, the default event will be used
+               String defaultEvent = null;
+               OprofileDaemonEvent[] daemonEvents = null;
+               if (!config.getAttribute(OprofileLaunchPlugin.ATTR_USE_DEFAULT_EVENT, false)) {
+                       //get the events to profile from the counters
+                       OprofileCounter[] counters = OprofileCounter.getCounters(config);
+                       ArrayList<OprofileDaemonEvent> events = new ArrayList<OprofileDaemonEvent>();
+                       
+                       for (int i = 0; i < counters.length; ++i) {
+                               if (counters[i].getEnabled())
+                                       events.add(counters[i].getDaemonEvent());
+                       }
+                       
+                       daemonEvents = new OprofileDaemonEvent[events.size()];
+                       events.toArray(daemonEvents);
+               }
+               //jinu added at 20090602
+               else{
+                       String keyStr = config.getAttribute(OprofileLaunchPlugin.ATTR_SELECTED_DEFAULT_SETTING,"");
+                       defaultEvent = DefaultSettingConstants.getSettingValue(keyStr);
+               }
+
+               //set up and launch the oprofile daemon
+               try {
+                       //kill the daemon (it shouldn't be running already, but to be safe)
+                       OprofileCorePlugin.getDefault().getOpcontrolProvider().shutdownDaemon();
+                       
+                       //reset data from the (possibly) existing default session, 
+                       // otherwise multiple runs will combine samples and results
+                       // won't make much sense
+                       OprofileCorePlugin.getDefault().getOpcontrolProvider().reset();
+                       
+                       //setup the events and other parameters
+                       OprofileCorePlugin.getDefault().getOpcontrolProvider().setupDaemon(options.getOprofileDaemonOptions(), daemonEvents, defaultEvent);
+                       
+                       //start the daemon & collection of samples 
+                       //note: since the daemon is only profiling for the specific image we told 
+                       // it to, no matter to start the daemon before the binary itself is run
+                       OprofileCorePlugin.getDefault().getOpcontrolProvider().startCollection();
+               } catch (OpcontrolException oe) {
+                       OprofileCorePlugin.showErrorDialog("opcontrolProvider", oe); //$NON-NLS-1$
+                       return;
+               }
+
+               /* 
+                * this code written by QNX Software Systems and others and was 
+                * originally in the CDT under LocalCDILaunchDelegate::RunLocalApplication
+                */
+               //set up and launch the local c/c++ program
+               try {
+                       IPath exePath = verifyProgramPath( config );
+                       File wd = getWorkingDirectory( config );
+                       if ( wd == null ) {
+                               wd = new File( System.getProperty( "user.home", "." ) ); //$NON-NLS-1$ //$NON-NLS-2$
+                       }
+                       String arguments[] = getProgramArgumentsArray( config );
+                       ArrayList<String> command = new ArrayList<String>( 1 + arguments.length );
+                       command.add( exePath.toOSString() );
+                       command.addAll( Arrays.asList( arguments ) );
+                       String[] commandArray = (String[])command.toArray( new String[command.size()] );
+                       boolean usePty = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_USE_TERMINAL, ICDTLaunchConfigurationConstants.USE_TERMINAL_DEFAULT);
+                       Process process;
+                       process = exec( commandArray, getEnvironment( config ), wd, usePty );
+                       DebugPlugin.newProcess( launch, process, renderProcessLabel( commandArray[0] ) );
+               } catch (IOException e) {
+                       e.printStackTrace();
+               }
+               
+               //add a listener for termination of the launch
+               ILaunchManager lmgr = DebugPlugin.getDefault().getLaunchManager();
+               lmgr.addLaunchListener(new LaunchTerminationWatcher(launch));
+
+       }
+       
+       /**
+        * This code was adapted from code written by QNX Software Systems and others 
+        * and was originally in the CDT under LocalCDILaunchDelegate::exec
+        * 
+        * @param cmdLine
+        *            the command line
+        * @param workingDirectory
+        *            the working directory, or <code>null</code>
+        * @return the resulting process or <code>null</code> if the exec is
+        *         cancelled
+        * @see Runtime
+        */
+       protected Process exec( String[] cmdLine, String[] environ, File workingDirectory, boolean usePty ) throws CoreException, IOException {
+               Process p = null;
+               try {
+                       if ( workingDirectory == null ) {
+                               p = ProcessFactory.getFactory().exec( cmdLine, environ );
+                       }
+                       else {
+                               if ( usePty && PTY.isSupported() ) {
+                                       p = ProcessFactory.getFactory().exec( cmdLine, environ, workingDirectory, new PTY() );
+                               }
+                               else {
+                                       p = ProcessFactory.getFactory().exec( cmdLine, environ, workingDirectory );
+                               }
+                       }
+               }
+               catch( IOException e ) {
+                       if ( p != null ) {
+                               p.destroy();
+                       }
+                       throw e;
+               }
+               return p;
+       }
+
+       @Override
+       protected String getPluginID() {
+               return OprofileLaunchPlugin.getUniqueIdentifier();
+       }
+
+       
+       //A class used to listen for the termination of the current launch, and 
+       // run some functions when it is finished. 
+       class LaunchTerminationWatcher implements ILaunchesListener2 {
+               private ILaunch launch;
+               
+               public LaunchTerminationWatcher(ILaunch il) {
+                       launch = il;
+               }
+               
+               public void launchesTerminated(ILaunch[] launches) {
+                       try {
+                               for (ILaunch l : launches) {
+                                       /**
+                                        * Dump samples from the daemon,
+                                        * shut down the daemon,
+                                        * activate the OProfile view (open it if it isn't already),
+                                        * refresh the view (which parses the data/ui model and displays it).
+                                        */
+                                       if (l.equals(launch)) {
+                                               OprofileCorePlugin.getDefault().getOpcontrolProvider().dumpSamples();
+                                               OprofileCorePlugin.getDefault().getOpcontrolProvider().shutdownDaemon();
+
+                                               //need to run this in the ui thread otherwise get SWT Exceptions
+                                               // based on concurrency issues
+                                               Display.getDefault().syncExec(new Runnable() {
+                                                       public void run() {
+                                                               OprofileView view = OprofileUiPlugin.getDefault().getOprofileView();
+                                                               if (view != null) {
+                                                                       view.refreshView();
+                                                               } else {
+                                                                       try {
+                                                                               PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(OprofileUiPlugin.ID_OPROFILE_VIEW);
+                                                                       } catch (PartInitException e) {
+                                                                               e.printStackTrace();
+                                                                       }
+                                                                       OprofileUiPlugin.getDefault().getOprofileView().refreshView();
+                                                               }
+                                                       }
+                                               });
+                                       }
+                               }
+                       } catch (OpcontrolException oe) {
+                               OprofileCorePlugin.showErrorDialog("opcontrolProvider", oe); //$NON-NLS-1$
+                       }
+               }
+
+               public void launchesAdded(ILaunch[] launches) { /* dont care */}
+               public void launchesChanged(ILaunch[] launches) { /* dont care */ }
+               public void launchesRemoved(ILaunch[] launches) { /* dont care */ }
+       }       
+       
+}
diff --git a/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/oprofile/launch/launching/OprofileLaunchShortcut.java b/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/oprofile/launch/launching/OprofileLaunchShortcut.java
new file mode 100644 (file)
index 0000000..de7bd25
--- /dev/null
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Kent Sebastian <ksebasti@redhat.com> - initial API and implementation 
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.oprofile.launch.launching;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.linuxtools.oprofile.launch.OprofileLaunchPlugin;
+import org.eclipse.linuxtools.oprofile.launch.configuration.LaunchOptions;
+import org.eclipse.linuxtools.profiling.launch.ProfileLaunchShortcut;
+
+
+/**
+ * A class that takes care of the right-click -> profile with oprofile
+ *   shortcut, where the ProfileLaunchShortcut has the logic to automatically
+ *   find binaries and create a default launch if one doesn't exist.
+ */
+public class OprofileLaunchShortcut extends ProfileLaunchShortcut {
+       @Override
+       protected ILaunchConfigurationType getLaunchConfigType() {
+               return getLaunchManager().getLaunchConfigurationType(OprofileLaunchPlugin.ID_LAUNCH_PROFILE);
+       }
+
+       /**
+        * Default settings for the OProfile-specific option tabs.
+        */
+       @Override
+       protected void setDefaultProfileAttributes(ILaunchConfigurationWorkingCopy wc) throws CoreException {
+               //default global setup options
+               LaunchOptions options = new LaunchOptions();
+               options.saveConfiguration(wc);
+
+               //default event option
+               wc.setAttribute(OprofileLaunchPlugin.ATTR_USE_DEFAULT_EVENT, true);
+       
+               // commented by greatim at 2011.06.01 for fresh ide
+               //jinu added at 20090618
+//             wc.setAttribute(ICDTLaunchConstants.ATTR_LAUNCH_MODE, "oprofile");
+               //wc.setAttribute(ISMLCDTLaunchConstants.ATTR_SKIP_DOWNLOAD, false);
+       }
+
+}
diff --git a/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/oprofile/launch/oprofilelaunch.properties b/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/oprofile/launch/oprofilelaunch.properties
new file mode 100644 (file)
index 0000000..08d8604
--- /dev/null
@@ -0,0 +1,60 @@
+#####################################################################
+# Copyright (c) 2004,2008 Red Hat, Inc.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#    Keith Seitz <keiths@redhat.com> - initial implementation
+#    Kent Sebastian <ksebasti@redhat.com> - 
+###################################################################### 
+tab.claunch.name=&Application
+tab.claunch.launchConfig.label.text=C/C++ Launch &Configuration:
+tab.claunch.launchConfig.button.browse.text=&Browse...
+tab.claunch.launchConfigDialog.title=Launch Configuration Selection
+tab.claunch.launchConfigDialog.message=Choose a C/C++ Application Launch Configuration to profile:
+oprofileCounter.counterString=Counter: {0,number,integer}
+
+#jinu modified at 20090602
+#tab.event.name=Events
+tab.event.name=OProfile Options
+tab.event.counterSettings.label.text=Counter settings
+tab.event.counterSettings.enabled.button.text=Enabled
+tab.event.eventDescription.label.text=Event Description:
+tab.event.counterSettings.profileKernel.check.text=Profile kernel
+tab.event.counterSettings.profileUser.check.text=Profile user binaries
+tab.event.counterSettings.count.label.text=Count:
+tab.event.counterSettings.count.too-small=Minimum count must be at least {0,number,integer}
+tab.event.counterSettings.count.invalid=Invalid count value, must be an integer
+#jinu modified at 20090602
+#tab.event.defaultevent.button.text=Use default event
+tab.event.defaultevent.button.text=Use default setting
+#jinu modified at 20090602
+#tab.event.counterTab.counterText=Ctr 
+tab.event.counterTab.counterText=Counter 
+tab.event.timermode.no.options=OProfile is running in timer mode; no event options can be specified.
+
+tab.global.name=Global
+tab.global.kernelImage.label.text=&Kernel image file (optional):
+tab.global.kernelImage.kernel.nonexistent=Kernel image \"{0}\" does not exist
+tab.global.kernelImage.browse.button.text=&Browse...
+tab.global.selectKernelDialog.text=Select current kernel file
+tab.global.selectKernelDialog.error.kernelDoesNotExist.text=The selected kernel image file does not exist.
+tab.global.check.separateLibrary.text=Include dependent shared libraries 
+tab.global.check.separateKernel.text=Include dependent kernel modules (also includes libraries)
+tab.global.check.separateThread.text=Separate profiles per thread
+tab.global.check.separateCpu.text=Separate profiles per CPU
+
+common.cannotrun=Cannot run oprofile profiling.
+common.notarget=Target isn't connected. Please confirm it and retry.
+
+unitmaskViewer.label.text=Unit mask:
+
+launchshortcut.no_project_error=No project associated with selected element.
+launchshortcut.errordialog.title=OProfile Launcher
+launchshortcut.errordialog.no_launch_error=Error: No launch configurations exist for this project.
+
+launchshortcut.launchselectiondialog.no_project_name=<no name>
+launchshortcut.launchselectiondialog.title=Profile Configuration Selection
+launchshortcut.launchselectiondialog.message=Select a profiling launch configuration:
diff --git a/org.eclipse.linuxtools.oprofile.launch/src/org/tizen/oprofile/launch/DefaultSettingConstants.java b/org.eclipse.linuxtools.oprofile.launch/src/org/tizen/oprofile/launch/DefaultSettingConstants.java
new file mode 100644 (file)
index 0000000..0af40ad
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ *  Default Setting Constants
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Jaewon Lim <jaewon81.lim@samsung.com>
+ * Wonhyoung Park <wonhyoung2.park@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.oprofile.launch;
+
+import java.util.HashMap;
+
+import org.eclipse.linuxtools.oprofile.core.Oprofile;
+
+public abstract class DefaultSettingConstants {
+       
+       private static HashMap<String, String[][]> settingMap;
+       
+       private static void initialize() {
+               settingMap = new HashMap<String, String[][]>();
+               settingMap.put("i386/core_2", settingForCore2);
+               settingMap.put("arm/armv7", settingForARMv7);
+       }
+       
+       private static final String[] basicSetting = {
+               "Bottleneck Analysis", "--event=default"
+       };
+       
+       private static final String[][] settingForARMv7 = {
+               basicSetting,
+               {"Instruction Cache Efficiency Analysis", "--event=IFETCH_MISS:10000:0:1:1 --event=INSTR_EXECUTED:10000:0:1:1"}
+       };
+       
+       private  static final String[][] settingForCore2 = {
+               basicSetting
+       };
+       
+       public static String[][] getDefaultSettings(){
+               String[][] settings = getSetting(Oprofile.getCpuType());
+               
+               if(settings==null){
+                       settings = new String[1][];
+                       settings[0] = basicSetting;
+               }
+               
+               return settings;
+       }
+
+
+       public static String getSettingValue(String key){
+               String value = null;
+               String[][] settings = getSetting(Oprofile.getCpuType());
+               
+               if(settings!=null){
+                       for(int i=0;i<settings.length;i++){
+                               if(settings[i][0].equals(key)){
+                                       value = settings[i][1];
+                               }
+                       }
+               }else{
+                       value = basicSetting[1];
+               }
+               
+               return value;
+       }
+
+       private static String[][] getSetting(String cpuType) {
+               if(settingMap==null)
+                       initialize();
+               
+               return settingMap.get(cpuType);
+       }
+       
+}
diff --git a/org.eclipse.linuxtools.oprofile.launch/src/org/tizen/oprofile/launch/listen/OProfileTargetConnectionListener.java b/org.eclipse.linuxtools.oprofile.launch/src/org/tizen/oprofile/launch/listen/OProfileTargetConnectionListener.java
new file mode 100644 (file)
index 0000000..b77f69e
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ *  Oprofile target Connection Listener
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Jaewon Lim <jaewon81.lim@samsung.com>
+ * Wonhyoung Park <wonhyoung2.park@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.oprofile.launch.listen;
+
+import org.eclipse.linuxtools.oprofile.core.Oprofile;
+
+import org.tizen.common.connection.ConnectionPlugin;
+import org.tizen.common.connection.ConnectionPlugin.ISelectionListener;
+import org.tizen.sdblib.FileListingService.FileEntry;
+
+public class OProfileTargetConnectionListener  implements ISelectionListener{
+
+       @Override
+       public void selectionChanged(FileEntry selectedEntry) {
+               // TODO Auto-generated method stub
+               if(null == ConnectionPlugin.getDefault().getCurrentDevice()){
+                       Oprofile.initialize();
+               }               
+       }
+       
+}
diff --git a/org.eclipse.linuxtools.oprofile.launch/src/org/tizen/oprofile/launch/listen/OprofileStartup.java b/org.eclipse.linuxtools.oprofile.launch/src/org/tizen/oprofile/launch/listen/OprofileStartup.java
new file mode 100644 (file)
index 0000000..a73021d
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ *  Oprofile Startup
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Jaewon Lim <jaewon81.lim@samsung.com>
+ * Wonhyoung Park <wonhyoung2.park@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+
+package org.tizen.oprofile.launch.listen;
+
+import org.eclipse.ui.IStartup;
+
+import org.tizen.common.connection.ConnectionPlugin;
+
+public class OprofileStartup implements IStartup {
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.IStartup#earlyStartup()
+        */
+       private OProfileTargetConnectionListener mDeviceListener = null;
+//     
+       public void earlyStartup() {
+               mDeviceListener = new OProfileTargetConnectionListener();
+               ConnectionPlugin.getDefault().addSelectionListener(mDeviceListener);
+       }
+}
diff --git a/org.eclipse.linuxtools.oprofile.ui/.classpath b/org.eclipse.linuxtools.oprofile.ui/.classpath
new file mode 100644 (file)
index 0000000..121e527
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="src" path="src"/>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.eclipse.linuxtools.oprofile.ui/.project b/org.eclipse.linuxtools.oprofile.ui/.project
new file mode 100644 (file)
index 0000000..ed72d2c
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.eclipse.linuxtools.oprofile.ui</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.ManifestBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.SchemaBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.pde.PluginNature</nature>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>
diff --git a/org.eclipse.linuxtools.oprofile.ui/.settings/org.eclipse.core.resources.prefs b/org.eclipse.linuxtools.oprofile.ui/.settings/org.eclipse.core.resources.prefs
new file mode 100644 (file)
index 0000000..25df1f5
--- /dev/null
@@ -0,0 +1,3 @@
+#Wed Dec 01 09:13:25 CET 2010
+eclipse.preferences.version=1
+encoding/<project>=UTF-8
diff --git a/org.eclipse.linuxtools.oprofile.ui/.settings/org.eclipse.core.runtime.prefs b/org.eclipse.linuxtools.oprofile.ui/.settings/org.eclipse.core.runtime.prefs
new file mode 100644 (file)
index 0000000..0519b50
--- /dev/null
@@ -0,0 +1,3 @@
+#Tue Dec 14 16:36:33 CET 2010
+eclipse.preferences.version=1
+line.separator=\n
diff --git a/org.eclipse.linuxtools.oprofile.ui/META-INF/MANIFEST.MF b/org.eclipse.linuxtools.oprofile.ui/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..23d746b
--- /dev/null
@@ -0,0 +1,32 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Tizen SDK Oprofile UI
+Bundle-SymbolicName: org.eclipse.linuxtools.oprofile.ui;singleton:=true
+Bundle-Version: 1.3.18.qualifier
+Bundle-Vendor: Eclipse Linux Tools
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Require-Bundle: org.eclipse.ui;bundle-version="3.4.0",
+ org.eclipse.ui.forms;bundle-version="3.3.0",
+ org.eclipse.ui.editors;bundle-version="3.4.0",
+ org.eclipse.birt.chart.engine,
+ org.eclipse.core.resources;bundle-version="3.4.2",
+ org.eclipse.jface.text;bundle-version="3.4.2",
+ org.eclipse.linuxtools.oprofile.core,
+ org.eclipse.linuxtools.profiling.ui,
+ org.tizen.common
+Bundle-Activator: org.eclipse.linuxtools.oprofile.ui.OprofileUiPlugin
+Bundle-ActivationPolicy: lazy
+Bundle-Localization: plugin
+Export-Package: org.eclipse.linuxtools.oprofile.ui;
+  uses:="org.eclipse.jface.resource,
+   org.eclipse.ui,
+   org.eclipse.linuxtools.oprofile.ui.sample,
+   org.eclipse.linuxtools.oprofile.ui.system,
+   org.eclipse.ui.plugin,
+   org.eclipse.core.resources,
+   org.eclipse.jface.viewers,
+   org.eclipse.swt.graphics,
+   org.osgi.framework,
+   org.eclipse.swt.widgets",
+ org.eclipse.linuxtools.oprofile.ui.model,
+ org.eclipse.linuxtools.oprofile.ui.view
diff --git a/org.eclipse.linuxtools.oprofile.ui/META-INF/eclipse.inf b/org.eclipse.linuxtools.oprofile.ui/META-INF/eclipse.inf
new file mode 100644 (file)
index 0000000..92ffed2
--- /dev/null
@@ -0,0 +1,2 @@
+#Processed using Jarprocessor
+pack200.conditioned = true
diff --git a/org.eclipse.linuxtools.oprofile.ui/NOTICE b/org.eclipse.linuxtools.oprofile.ui/NOTICE
new file mode 100644 (file)
index 0000000..81f97c2
--- /dev/null
@@ -0,0 +1,71 @@
+2010-02-03 SPRC SDK Team <d.kozinski@samsung.com>
+       * plugin.xml : changed some package names and delete category
+       * OprofileView.java : bug fix
+
+2010-02-08 Lukasz Czaplinski <l.czaplinski@samsung.com>
+       * MANIFEST.MF : Removed not needed birt.chart plugin  dependency
+
+2010-02-10 SPRC SDK Team <d.kozinski@samsung.com>
+       * OprofileUiPlugin.java : remove some import
+       * IUiModelElement.java : remove some import
+       * UiModelImage.java : remove some import
+       * UiModelSymbol.java : remove some import
+       * OprofileView.java : remove some import
+       * OprofileViewDoubleClickListener.java : remove some import
+
+2010-02-11 Zbigniew Kosinski <z.kosinski@samsung.com>
+       * OprofileView.java : remove unnecessary import, Fix display output data in SDK oprofile
+
+2010-03-08 Zbigniew Kosinski <z.kosinski@samsung.com>
+       * OprofileEditor.java : Fix display output data in SDK oprofile after read from log
+
+2010-03-19 HyungJong, Shin <hj_shin@samsung.com>
+       * MANIFEST.MF : add some plugin dependency
+
+2010-03-22 HyungJong, Shin <hj_shin@samsung.com>
+       * MANIFEST.MF : remove unused dependencies.
+
+2010-04-05 HyungJong, Shin <hj_shin@samsung.com>
+       * OprofileSaveFileHandler.java : bugfix : add the code to check the write permission of folder to save a file adn to set default location to home folder.
+
+2010-04-06 HyungJong, Shin <hj_shin@samsung.com>
+       * OprofileSaveFileHandler.java : bugfix : for unintentional error message to save a file in syslog, oprofile, valgrind.
+
+2010-08-26 HyungJong, Shin <hj_shin@samsung.com>
+       * MANIFEST.MF : modify plugin dependency
+       * OprofileViewDoubleClickListener.java : modify some import, modify target control code
+       
+2010-11-05 sdk <sdk@sdk-laptop.(none)>
+       * MANIFEST.MF : changed some package name
+       * plugin.xml : changed some package name
+       * OprofileView.java : changed some package name
+       * OprofileViewDoubleClickListener.java : changed some package name
+
+2011-06-09 jaewon81.lim <jaewon81.lim@samsung.com>
+       * MANIFEST.MF : rearrange plugins dependency
+
+2011-07-13 jaewon81.lim <jaewon81.lim@samsung.com>
+       * MANIFEST.MF : modified import package name
+
+2011-08-22 joogwan.kim <joogwan.kim@samsung.com>
+       * MANIFEST.MF : Change plug-in name
+
+2011-08-25 wonhyoung2.park <wonhyoung2.park@samsung.com>
+       * MANIFEST.MF : plugin provider and name modified
+
+2011-09-17 YoonKi Park <yoonki.park@samsung.com>
+       * plugin.xml : change view category name to SLP SDK
+
+2011-11-22 taeyoung2.son <taeyoung2.son@samsung.com>
+       * MANIFEST.MF :  Modify SDK naming from "SLP(or Samsung Linux Platform)" to "Tizen"
+
+2011-11-29 wonhyoung2.park <wonhyoung2.park@samsung.com>
+       * MANIFEST.MF : chagne slp to tizen
+       * plugin.xml : chagne slp to tizen
+       * OprofileView.java : chagne slp to tizen
+
+2011-12-02 taeyoung2.son <taeyoung2.son@samsung.com>
+       * MANIFEST.MF : Delete dependency feature's version value.
+
+2011-12-03 wonhyoung2.park <wonhyoung2.park@samsung.com>
+       * MANIFEST.MF : package instll routine chage
diff --git a/org.eclipse.linuxtools.oprofile.ui/about.html b/org.eclipse.linuxtools.oprofile.ui/about.html
new file mode 100644 (file)
index 0000000..bf06e8c
--- /dev/null
@@ -0,0 +1,33 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
+<html>
+<head>
+<title>About</title>
+<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+<p>8th September, 2004</p>     
+<h3>License</h3>
+<p>The Eclipse Software Foundation makes available all content in this plug-in (&quot;Content&quot;).  Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;).  A copy of the EPL is available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<h3>Contributions</h3>
+
+<p>If this Content is licensed to you under the terms and conditions of the EPL, any Contributions, as defined in the EPL, uploaded, submitted, or otherwise
+made available to the Eclipse Foundation, its members and/or the host of the Eclipse Foundation web site, by you that relate to such
+Content are provided under the terms and conditions of the <a href="http://www.eclipse.org/legal/termsofuse.html">Terms of Use</a>
+for the Eclipse Foundation web site and can be made available to others under the terms of the licenses as set out in the
+<a href="http://www.eclipse.org/legal/termsofuse.html">Terms of Use</a>.</p>
+
+<p>If this Content is licensed to you under license terms and conditions other than the EPL (&quot;Other License&quot;), any modifications, enhancements and/or
+other code and/or documentation (&quot;Modifications&quot;) uploaded, submitted, or otherwise made available to the Eclipse Foundation, its members and/or the
+host of the Eclipse Foundation web site, by you that relate to such Content are provided under terms and conditions of the Other License and can be made available
+to others under the terms of the Other License.  In addition, with regard to Modifications for which you are the copyright holder, you are also
+providing the Modifications under the terms and conditions of the <a href="http://www.eclipse.org/legal/termsofuse.html">Terms of Use</a>
+for the Eclipse Foundation web site and such Modifications can be made available to others under the terms of the licenses as set out in the
+<a href="http://www.eclipse.org/legal/termsofuse.html">Terms of Use</a>.</p>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/org.eclipse.linuxtools.oprofile.ui/build.properties b/org.eclipse.linuxtools.oprofile.ui/build.properties
new file mode 100644 (file)
index 0000000..6b70fb2
--- /dev/null
@@ -0,0 +1,10 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               .,\
+               plugin.xml,\
+               plugin.properties,\
+               icons/,\
+               about.html
+javacSource = 1.6
+javacTarget = 1.6
diff --git a/org.eclipse.linuxtools.oprofile.ui/icons/chart.png b/org.eclipse.linuxtools.oprofile.ui/icons/chart.png
new file mode 100644 (file)
index 0000000..d65084d
Binary files /dev/null and b/org.eclipse.linuxtools.oprofile.ui/icons/chart.png differ
diff --git a/org.eclipse.linuxtools.oprofile.ui/icons/dependent.gif b/org.eclipse.linuxtools.oprofile.ui/icons/dependent.gif
new file mode 100644 (file)
index 0000000..122bada
Binary files /dev/null and b/org.eclipse.linuxtools.oprofile.ui/icons/dependent.gif differ
diff --git a/org.eclipse.linuxtools.oprofile.ui/icons/dump.gif b/org.eclipse.linuxtools.oprofile.ui/icons/dump.gif
new file mode 100644 (file)
index 0000000..d5b8001
Binary files /dev/null and b/org.eclipse.linuxtools.oprofile.ui/icons/dump.gif differ
diff --git a/org.eclipse.linuxtools.oprofile.ui/icons/event.gif b/org.eclipse.linuxtools.oprofile.ui/icons/event.gif
new file mode 100644 (file)
index 0000000..c91f254
Binary files /dev/null and b/org.eclipse.linuxtools.oprofile.ui/icons/event.gif differ
diff --git a/org.eclipse.linuxtools.oprofile.ui/icons/image.gif b/org.eclipse.linuxtools.oprofile.ui/icons/image.gif
new file mode 100644 (file)
index 0000000..8aa0162
Binary files /dev/null and b/org.eclipse.linuxtools.oprofile.ui/icons/image.gif differ
diff --git a/org.eclipse.linuxtools.oprofile.ui/icons/open_log.png b/org.eclipse.linuxtools.oprofile.ui/icons/open_log.png
new file mode 100644 (file)
index 0000000..60bf946
Binary files /dev/null and b/org.eclipse.linuxtools.oprofile.ui/icons/open_log.png differ
diff --git a/org.eclipse.linuxtools.oprofile.ui/icons/oprofile_view.png b/org.eclipse.linuxtools.oprofile.ui/icons/oprofile_view.png
new file mode 100644 (file)
index 0000000..4f8488f
Binary files /dev/null and b/org.eclipse.linuxtools.oprofile.ui/icons/oprofile_view.png differ
diff --git a/org.eclipse.linuxtools.oprofile.ui/icons/refresh.gif b/org.eclipse.linuxtools.oprofile.ui/icons/refresh.gif
new file mode 100644 (file)
index 0000000..4f884d7
Binary files /dev/null and b/org.eclipse.linuxtools.oprofile.ui/icons/refresh.gif differ
diff --git a/org.eclipse.linuxtools.oprofile.ui/icons/reset_log.gif b/org.eclipse.linuxtools.oprofile.ui/icons/reset_log.gif
new file mode 100644 (file)
index 0000000..b6922ac
Binary files /dev/null and b/org.eclipse.linuxtools.oprofile.ui/icons/reset_log.gif differ
diff --git a/org.eclipse.linuxtools.oprofile.ui/icons/sample.gif b/org.eclipse.linuxtools.oprofile.ui/icons/sample.gif
new file mode 100644 (file)
index 0000000..061161a
Binary files /dev/null and b/org.eclipse.linuxtools.oprofile.ui/icons/sample.gif differ
diff --git a/org.eclipse.linuxtools.oprofile.ui/icons/save_log.png b/org.eclipse.linuxtools.oprofile.ui/icons/save_log.png
new file mode 100644 (file)
index 0000000..5950473
Binary files /dev/null and b/org.eclipse.linuxtools.oprofile.ui/icons/save_log.png differ
diff --git a/org.eclipse.linuxtools.oprofile.ui/icons/session.gif b/org.eclipse.linuxtools.oprofile.ui/icons/session.gif
new file mode 100644 (file)
index 0000000..c2b41bd
Binary files /dev/null and b/org.eclipse.linuxtools.oprofile.ui/icons/session.gif differ
diff --git a/org.eclipse.linuxtools.oprofile.ui/icons/symbol.gif b/org.eclipse.linuxtools.oprofile.ui/icons/symbol.gif
new file mode 100644 (file)
index 0000000..6ae4604
Binary files /dev/null and b/org.eclipse.linuxtools.oprofile.ui/icons/symbol.gif differ
diff --git a/org.eclipse.linuxtools.oprofile.ui/plugin.properties b/org.eclipse.linuxtools.oprofile.ui/plugin.properties
new file mode 100644 (file)
index 0000000..bf32971
--- /dev/null
@@ -0,0 +1,26 @@
+#*******************************************************************************
+# Copyright (c) 2004, 2008 Red Hat, Inc.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#    Red Hat, Inc. - initial API and implementation
+#*******************************************************************************
+
+view.groupname=C/C++ Profiling
+view.name=OProfile
+
+view.annotate.toggle.label=Toggle Annotation
+view.annotate.toggle.tooltip=Toggle Annotation
+
+annotateCommand.name=Annotate
+lt.min.pct.label=OProfile Annotation: <0.01%
+lt.05.pct.label=OProfile Annotation: 0.01% - 4.99%
+lt.10.pct.label=OProfile Annotation: 05% - 9.99%
+lt.20.pct.label=OProfile Annotation: 10% - 19.99%
+lt.30.pct.label=OProfile Annotation: 20% - 29.99%
+lt.40.pct.label=OProfile Annotation: 30% - 39.99%
+lt.50.pct.label=OProfile Annotation: 40% - 49.99%
+gt.50.pct.label=OProfile Annotation: >50%
diff --git a/org.eclipse.linuxtools.oprofile.ui/plugin.xml b/org.eclipse.linuxtools.oprofile.ui/plugin.xml
new file mode 100644 (file)
index 0000000..3ac0db7
--- /dev/null
@@ -0,0 +1,184 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+   <extension
+         point="org.eclipse.ui.views">
+      <view
+            category="org.tizen.nativeapp.viewCategory"
+            class="org.eclipse.linuxtools.oprofile.ui.view.OprofileView"
+            icon="icons/oprofile_view.png"
+            id="org.eclipse.linuxtools.oprofile.ui.OProfileView"
+            name="Oprofile"
+            restorable="true">
+      </view>
+   </extension>
+   <!-- jinu added at 20090528-->
+   <extension
+         point="org.eclipse.ui.menus">
+      <menuContribution
+            locationURI="toolbar:org.eclipse.linuxtools.oprofile.ui.OProfileView?after=additions">
+                       <command
+               commandId="org.tizen.oprofile.ui.command.refreshView"
+               icon="icons/refresh.gif"
+               tooltip="Refresh">
+         </command>
+         <command
+               commandId="org.tizen.oprofile.ui.command.reset"
+               icon="icons/reset_log.gif"
+               tooltip="Reset">
+         </command>
+         <command
+               commandId="org.tizen.oprofile.ui.command.drawChart"
+               icon="icons/chart.png"
+               tooltip="Draw Chart">
+         </command>
+                       <separator
+               name="org.tizen.oprofile.ui.view.separator1"
+               visible="true">
+         </separator>
+                       <command
+               commandId="org.tizen.oprofile.command.saveFile"
+               icon="icons/save_log.png"
+               tooltip="Save file">
+            <parameter
+                  name="org.tizen.oprofile.command.saveFile.parameter"
+                  value="oprofile">
+            </parameter>
+         </command>
+         <command
+               commandId="org.tizen.common.command.openFile"
+               icon="icons/open_log.png"
+               tooltip="Open file">
+            <parameter
+                  name="org.tizen.common.command.openFile.parameter"
+                  value="oprofile">
+            </parameter>
+         </command>                  
+      </menuContribution>
+               <!--menuContribution
+            locationURI="menu:org.eclipse.linuxtools.oprofile.ui.OProfileView?after=additions">
+                       <command
+               commandId="org.tizen.oprofile.ui.command.openDaemonLog"
+               tooltip="Open Daemon Log">
+         </command>
+      </menuContribution-->
+   </extension>
+       <extension point="org.eclipse.ui.commands">
+      <category
+            description="Commands related to the Oprofile"
+            id="org.tizen.oprofile.ui.command.category"
+            name="Oprofile">
+      </category>
+      <command
+            categoryId="org.tizen.oprofile.ui.command.category"
+            id="org.tizen.oprofile.ui.command.refreshView"
+            name="Refresh View">
+      </command>
+      <command
+            categoryId="org.tizen.oprofile.ui.command.category"
+            id="org.tizen.oprofile.ui.command.drawChart"
+            name="Draw Chart">
+      </command>    
+        <command
+            categoryId="org.tizen.oprofile.ui.command.category"
+            id="org.tizen.oprofile.ui.command.openDaemonLog"
+            name="Open DaemonLog">
+      </command>
+      <command
+            categoryId="org.tizen.oprofile.ui.command.category"
+            id="org.tizen.oprofile.ui.command.reset"
+            name="Reset Log">
+      </command>
+               <command
+            categoryId="org.tizen.oprofile.ui.command.category"
+            description="Save"
+            id="org.tizen.oprofile.command.saveFile"
+            name="Save">
+         <commandParameter
+               id="org.tizen.oprofile.command.saveFile.parameter"
+               name="Extension"
+               optional="false">
+         </commandParameter>
+      </command>          
+       </extension>     
+       <extension point="org.eclipse.ui.handlers">
+      <handler class="org.tizen.oprofile.ui.handler.OprofileSaveFileHandler"
+            commandId="org.tizen.oprofile.command.saveFile">
+      </handler>       
+      <handler class="org.tizen.oprofile.ui.handler.OprofileRefreshViewHandler"
+            commandId="org.tizen.oprofile.ui.command.refreshView">
+         <activeWhen>
+                       <with
+                                       variable="org.tizen.connection.sourceProvider.TargetState">
+                                       <or>
+                                               <equals
+                                                       value="SIMULATOR_CONNECTED">  
+                                               </equals>
+                                               <equals
+                                                       value="REAL_DEVICE_CONNECTED">  
+                                               </equals>
+                                       </or>
+                               </with>
+         </activeWhen>
+      </handler>
+      <handler
+            class="org.tizen.oprofile.ui.handler.OprofileDrawChartHandler"
+            commandId="org.tizen.oprofile.ui.command.drawChart">
+         <activeWhen>
+                     <with
+                                       variable="selection">
+                               <count
+                                       value="1">
+                               </count>
+                     </with>
+         </activeWhen>
+      </handler>
+               <handler class="org.tizen.oprofile.ui.handler.OprofileResetHandler"
+            commandId="org.tizen.oprofile.ui.command.reset">
+         <activeWhen>
+                       <with
+                                       variable="org.tizen.connection.sourceProvider.TargetState">
+                                       <or>
+                                               <equals
+                                                       value="SIMULATOR_CONNECTED">  
+                                               </equals>
+                                               <equals
+                                                       value="REAL_DEVICE_CONNECTED">  
+                                               </equals>
+                                       </or>
+                               </with>
+         </activeWhen>
+      </handler>
+      <handler
+            class="org.tizen.oprofile.ui.handler.OprofileOpenDaemonLogHandler"
+            commandId="org.tizen.oprofile.ui.command.openDaemonLog">
+      </handler>                        
+       </extension>      
+   <extension
+         point="org.eclipse.ui.editors">
+      <editor
+            class="org.tizen.oprofile.ui.editor.ChartEditor"
+            default="false"
+            icon="icons/oprofile_view.png"
+            id="org.tizen.oprofile.ui.editor.ChartEditor"
+            name="Pie Chart for Oprofile">
+      </editor>
+               <editor
+                       class="org.tizen.oprofile.ui.editor.OprofileEditor"
+                       default="true"
+                       extensions="oprofile"
+                       icon="icons/oprofile_view.png"
+                       id="org.tizen.oprofile.ui.editor.OprofileEditor"
+                       name="Oprofile Editor">
+               </editor>      
+   </extension>         
+   <extension
+         point="org.eclipse.ui.perspectiveExtensions">
+      <perspectiveExtension
+            targetID="org.tizen.nativeapp.perspective">
+         <viewShortcut
+               id="org.eclipse.linuxtools.oprofile.ui.OProfileView">
+         </viewShortcut>
+      </perspectiveExtension>
+   </extension>    
+</plugin>
diff --git a/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/OprofileUiMessages.java b/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/OprofileUiMessages.java
new file mode 100644 (file)
index 0000000..dc195d4
--- /dev/null
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Keith Seitz <keiths@redhat.com> - initial API and implementation
+ *******************************************************************************/ 
+
+package org.eclipse.linuxtools.oprofile.ui;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class OprofileUiMessages
+{
+
+       private static final String BUNDLE_NAME = "org.eclipse.linuxtools.oprofile.ui.oprofileui"; //$NON-NLS-1$
+
+       private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
+
+       private OprofileUiMessages()
+       {
+       }
+
+       public static String getString(String key)
+       {
+               try
+               {
+                       return RESOURCE_BUNDLE.getString(key);
+               }
+               catch (MissingResourceException e)
+               {
+                       return '!' + key + '!';
+               }
+       }
+}
diff --git a/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/OprofileUiPlugin.java b/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/OprofileUiPlugin.java
new file mode 100644 (file)
index 0000000..3b4da4b
--- /dev/null
@@ -0,0 +1,161 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008, 2009 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Keith Seitz <keiths@redhat.com> - initial API and implementation
+ *    Kent Sebastian <ksebasti@redhat.com> - 
+ *******************************************************************************/ 
+
+package org.eclipse.linuxtools.oprofile.ui;
+
+import java.text.DecimalFormat;
+import java.text.NumberFormat;
+
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.linuxtools.oprofile.ui.view.OprofileView;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+
+/**
+ * The main plugin class to be used in the desktop.
+ */
+public class OprofileUiPlugin extends AbstractUIPlugin {
+       //The shared instance.
+       private static OprofileUiPlugin plugin;
+
+       private OprofileView _oprofileview = null;
+       
+       public static final String ID_PLUGIN = "org.eclipse.linuxtools.oprofile.ui"; //$NON-NLS-1$
+       public static final String ID_OPROFILE_VIEW = ID_PLUGIN + ".OProfileView"; //$NON-NLS-1$
+
+       private static final String ICON_PATH = "icons/"; //$NON-NLS-1$
+       public static final String SESSION_ICON = ICON_PATH + "session.gif"; //$NON-NLS-1$
+       public static final String EVENT_ICON = ICON_PATH + "event.gif"; //$NON-NLS-1$
+       public static final String IMAGE_ICON = ICON_PATH + "image.gif"; //$NON-NLS-1$
+       public static final String DEPENDENT_ICON = ICON_PATH + "dependent.gif"; //$NON-NLS-1$
+       public static final String SYMBOL_ICON = ICON_PATH + "symbol.gif"; //$NON-NLS-1$
+       public static final String SAMPLE_ICON = ICON_PATH + "sample.gif"; //$NON-NLS-1$
+       
+       public static final double MINIMUM_SAMPLE_PERCENTAGE = 0.0001;
+       public static final double MINIMUM_CHART_PERCENTAGE = 0.01;
+       
+       public static final String ANNOTATION_TYPE_LT_MIN_PERCENTAGE = "org.eclipse.linuxtools.oprofile.ui.annotation.lt.min.pct"; //$NON-NLS-1$
+       public static final String ANNOTATION_TYPE_LT_05 = "org.eclipse.linuxtools.oprofile.ui.annotation.lt.05.pct"; //$NON-NLS-1$
+       public static final String ANNOTATION_TYPE_LT_10 = "org.eclipse.linuxtools.oprofile.ui.annotation.lt.10.pct"; //$NON-NLS-1$
+       public static final String ANNOTATION_TYPE_LT_20 = "org.eclipse.linuxtools.oprofile.ui.annotation.lt.20.pct"; //$NON-NLS-1$
+       public static final String ANNOTATION_TYPE_LT_30 = "org.eclipse.linuxtools.oprofile.ui.annotation.lt.30.pct"; //$NON-NLS-1$
+       public static final String ANNOTATION_TYPE_LT_40 = "org.eclipse.linuxtools.oprofile.ui.annotation.lt.40.pct"; //$NON-NLS-1$
+       public static final String ANNOTATION_TYPE_LT_50 = "org.eclipse.linuxtools.oprofile.ui.annotation.lt.50.pct"; //$NON-NLS-1$
+       public static final String ANNOTATION_TYPE_GT_50 = "org.eclipse.linuxtools.oprofile.ui.annotation.gt.50.pct"; //$NON-NLS-1$
+       
+       /**
+        * The constructor.
+        */
+       public OprofileUiPlugin() {
+               plugin = this;
+       }
+
+       /**
+        * This method is called upon plug-in activation
+        */
+       public void start(BundleContext context) throws Exception {
+               super.start(context);
+       }
+
+       /**
+        * This method is called when the plug-in is stopped
+        */
+       public void stop(BundleContext context) throws Exception {
+               super.stop(context);
+               plugin = null;
+       }
+       
+       
+       /**
+        * Returns the shared instance.
+        */
+       public static OprofileUiPlugin getDefault() {
+               return plugin;
+       }
+
+       /**
+        * Returns the workspace instance.
+        */
+       public static IWorkspace getWorkspace() {
+               return ResourcesPlugin.getWorkspace();
+       }
+
+       /**     
+        * Returns an image descriptor for the image file at the given
+        * plug-in relative path
+        *
+        * @param path the path
+        * @return the image descriptor
+        */
+       public static ImageDescriptor getImageDescriptor(String path) {
+               return imageDescriptorFromPlugin(ID_PLUGIN, path);
+       }
+       
+       
+       public OprofileView getOprofileView() {
+               return _oprofileview;
+       }
+
+       public void setOprofileView(OprofileView _oprofileview) {
+               this._oprofileview = _oprofileview;
+       }
+
+       public static IWorkbenchWindow getActiveWorkbenchWindow() {
+               return getDefault().getWorkbench().getActiveWorkbenchWindow();
+       }
+       
+       public static Shell getActiveWorkbenchShell() {
+               IWorkbenchWindow window = getActiveWorkbenchWindow();
+               if (window != null) {
+                       return window.getShell();
+               }
+               return null;
+       }
+       
+       public static String getPercentageString(double percentage) {
+               NumberFormat nf = NumberFormat.getPercentInstance();
+               if (nf instanceof DecimalFormat) {
+                       nf.setMinimumFractionDigits(2);
+                       nf.setMaximumFractionDigits(2);
+               }
+               
+               if (percentage < OprofileUiPlugin.MINIMUM_SAMPLE_PERCENTAGE) {
+                       return "<" + nf.format(OprofileUiPlugin.MINIMUM_SAMPLE_PERCENTAGE); //$NON-NLS-1$
+               } else {
+                       return nf.format(percentage);
+               }
+       }
+       
+       
+//     jinu added at 20090526
+       public static String getPercentage(double percentage) {
+               String strValue = null;
+               if(percentage < OprofileUiPlugin.MINIMUM_SAMPLE_PERCENTAGE){
+                       strValue="< "+getDoubleFloor(OprofileUiPlugin.MINIMUM_SAMPLE_PERCENTAGE*100,2);
+               }else{
+                       strValue = String.valueOf( getDoubleFloor(percentage*100,2));                   
+               }
+               
+               return strValue;
+       }
+       
+       //jinu added at 20090602
+       public static double getDoubleFloor(double dblDigit, int position){
+               double dblCal = Math.pow(10, position);
+               return (int)(dblDigit*(int)dblCal) / dblCal;
+       }
+}
diff --git a/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/IUiModelElement.java b/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/IUiModelElement.java
new file mode 100644 (file)
index 0000000..4183b12
--- /dev/null
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Kent Sebastian <ksebasti@redhat.com> - initial API and implementation 
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.oprofile.ui.model;
+
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * Interface for all model elements to ease use with the tree viewer.
+ */
+public interface IUiModelElement {
+       /**
+        * Returns the text to display in the tree viewer as required by the label provider.
+        * @return text describing this element
+        */
+       String getLabelText();
+
+       /**
+        * Returns the children of this element.
+        * @return an array of IUiModelElements
+        */
+       IUiModelElement[] getChildren();
+       
+       /**
+        * Returns if this element has any children. Unless there is no data in
+        * a session, only samples should not have any children.
+        * @return true if children, false if no children
+        */
+       boolean hasChildren();
+       
+       /**
+        * Returns the parent element.
+        * @return the parent element
+        */
+       IUiModelElement getParent();
+
+       /**
+        * Returns the Image to display next to the text in the tree viewer.
+        * @return an Image object of the icon
+        */
+       Image getLabelImage();
+       
+       //jinu added at 20090602----------
+       double getPercentage();
+       String getName();
+       //-------------------------
+}
diff --git a/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelDependent.java b/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelDependent.java
new file mode 100644 (file)
index 0000000..8c2bfd1
--- /dev/null
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Kent Sebastian <ksebasti@redhat.com> - initial API and implementation 
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.oprofile.ui.model;
+
+import org.eclipse.linuxtools.oprofile.core.model.OpModelImage;
+import org.eclipse.linuxtools.oprofile.ui.OprofileUiMessages;
+import org.eclipse.linuxtools.oprofile.ui.OprofileUiPlugin;
+import org.eclipse.swt.graphics.Image;
+
+public class UiModelDependent implements IUiModelElement {
+       private IUiModelElement _parent;
+       private OpModelImage _dataModelDependents[];
+       private UiModelImage _dependents[];
+       private int _totalCount;
+       private int _depCount;
+       
+       public UiModelDependent(IUiModelElement parent, OpModelImage dependents[], int totalCount, int depCount) {
+               _parent = parent;
+               _dataModelDependents = dependents;
+               _dependents = null;
+               _totalCount = totalCount;
+               _depCount = depCount;
+               refreshModel();
+       }
+
+       private void refreshModel() {
+               _dependents = new UiModelImage[_dataModelDependents.length];
+               
+               for (int i = 0; i < _dataModelDependents.length; i++) {
+                       _dependents[i] = new UiModelImage(this, _dataModelDependents[i], _totalCount, 0);
+               }
+       }
+       
+       @Override
+       public String toString() {
+               double countPercentage = (double)_depCount / (double)_totalCount;
+               String percentage = OprofileUiPlugin.getPercentageString(countPercentage);
+
+               return percentage + " " + OprofileUiMessages.getString("uimodel.percentage.in") + OprofileUiMessages.getString("uimodel.dependent.dependent.images"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
+       }
+
+       /** IUiModelElement functions **/
+       public String getLabelText() {
+               return toString();
+       }
+
+       public IUiModelElement[] getChildren() {
+               return _dependents;
+       }
+
+       public boolean hasChildren() {
+               return true;    //must have children, or this object wouldn't be created
+       }
+
+       public IUiModelElement getParent() {
+               return _parent;
+       }
+
+       public Image getLabelImage() {
+               return OprofileUiPlugin.getImageDescriptor(OprofileUiPlugin.DEPENDENT_ICON).createImage();
+       }
+       
+//     jinu added at 20090526--------------------
+       public String getName(){
+               return null;
+       }
+       
+       public double getPercentage(){
+               return (double)_depCount / (double)_totalCount;
+       }
+//     ----------------------------------
+}
diff --git a/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelEvent.java b/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelEvent.java
new file mode 100644 (file)
index 0000000..8dec55f
--- /dev/null
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Kent Sebastian <ksebasti@redhat.com> - initial API and implementation 
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.oprofile.ui.model;
+
+import org.eclipse.linuxtools.oprofile.core.model.OpModelEvent;
+import org.eclipse.linuxtools.oprofile.core.model.OpModelSession;
+import org.eclipse.linuxtools.oprofile.ui.OprofileUiPlugin;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * Top level elements displayed in the view -- events that oprofile 
+ *  has profiled. Must have children sessions.
+ */
+public class UiModelEvent implements IUiModelElement {
+       private IUiModelElement _parent = null;         //parent node -- necessary?
+       private OpModelEvent _event;                            //the node in the data model
+       private UiModelSession _sessions[];                     //this node's children
+       
+       public UiModelEvent(OpModelEvent event) {
+               if (event != null) {
+                       _event = event;
+                       refreshModel();
+               }
+       }
+
+       /**
+        * Create the ui sessions from the data model.
+        */
+       private void refreshModel() {
+               OpModelSession dataModelSessions[] = _event.getSessions();
+               _sessions = new UiModelSession[dataModelSessions.length];
+               
+               for (int i = 0; i < dataModelSessions.length; i++) {
+                       _sessions[i] = new UiModelSession(this, dataModelSessions[i]);
+               }
+       }
+
+       @Override
+       public String toString() {
+               return (_event == null ? "" : _event.getName()); //$NON-NLS-1$
+       }
+
+       /** IUiModelElement functions **/
+       public String getLabelText() {
+               return toString();
+       }
+       
+       public IUiModelElement[] getChildren() {
+               return _sessions;
+       }
+
+       public boolean hasChildren() {
+               return (_sessions == null || _sessions.length == 0 ? false : true);
+       }
+
+       public IUiModelElement getParent() {
+               return _parent;
+       }
+
+       public Image getLabelImage() {
+               return OprofileUiPlugin.getImageDescriptor(OprofileUiPlugin.EVENT_ICON).createImage();
+       }
+       
+//     jinu added at 20090526-------------------
+       public String getName(){
+               return null;
+       }
+       
+       public double getPercentage(){
+               return -1;
+       }       
+//     -----------------------------
+}
diff --git a/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelImage.java b/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelImage.java
new file mode 100644 (file)
index 0000000..6fc87a5
--- /dev/null
@@ -0,0 +1,120 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Kent Sebastian <ksebasti@redhat.com> - initial API and implementation 
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.oprofile.ui.model;
+
+import org.eclipse.linuxtools.oprofile.core.model.OpModelImage;
+import org.eclipse.linuxtools.oprofile.core.model.OpModelSymbol;
+import org.eclipse.linuxtools.oprofile.ui.OprofileUiMessages;
+import org.eclipse.linuxtools.oprofile.ui.OprofileUiPlugin;
+import org.eclipse.swt.graphics.Image;
+
+
+/**
+ * Children of sessions in the view -- the binary which was profiled. 
+ * May or may not have child symbols. Note that although the dependent
+ * images are children of OpModelImages in the data model, for usability's
+ * sake they are children of the parent session in the tree.
+ */
+public class UiModelImage implements IUiModelElement {
+       private IUiModelElement _parent;                //parent element, may be UiModelSession or UiModelDependent
+       private OpModelImage _image;                    //the node in the data model
+       private UiModelSymbol _symbols[];               //this node's child (symbols)
+       private int _totalCount;                                //total number of samples 
+       private int _depCount;                                  //number of samples from dependent images
+
+       public UiModelImage(IUiModelElement parent, OpModelImage image, int totalCount, int depCount) {
+               _parent = parent;
+               _image = image;
+               _symbols = null;
+               _totalCount = totalCount;
+               _depCount = depCount;
+               refreshModel();
+               
+               //jinu added at 20090602                
+               //addChartModel();
+       }
+       
+       //jinu added at 20090602
+       /*
+       private void addChartModel(){
+               ChartModelRoot chartModel = ChartModelRoot.getDefault();
+               if(_parent instanceof UiModelDependent || _symbols==null){
+                       chartModel.addElement(this);
+               }
+       }
+       */
+
+       private void refreshModel() {
+               OpModelSymbol[] dataModelSymbols = _image.getSymbols();
+               
+               //dependent images may not have symbols
+               if (dataModelSymbols != null) {
+                       _symbols = new UiModelSymbol[dataModelSymbols.length];
+       
+                       for (int i = 0; i < dataModelSymbols.length; i++) {
+                               _symbols[i] = new UiModelSymbol(this, dataModelSymbols[i], _totalCount);
+                       }
+               }
+       }
+       
+       @Override
+       public String toString() {
+               if (_image.getCount() == OpModelImage.IMAGE_PARSE_ERROR) {
+                       return OprofileUiMessages.getString("opxmlParse.error.multipleImages"); //$NON-NLS-1$
+               } else {
+                       double countPercentage = (double)(_image.getCount() - _depCount) / (double)_totalCount;
+                       String percentage = OprofileUiPlugin.getPercentageString(countPercentage);
+                       
+                       return percentage + " " + OprofileUiMessages.getString("uimodel.percentage.in") + _image.getName(); //$NON-NLS-1$ //$NON-NLS-2$
+               }
+       }
+       
+       /** IUiModelElement functions **/
+       public String getLabelText() {
+               return toString();
+       }
+
+       public IUiModelElement[] getChildren() {
+               IUiModelElement children[] = null;
+               
+               if (_symbols != null) {
+                       children = new IUiModelElement[_symbols.length];
+                       
+                       for (int i = 0; i < _symbols.length; i++) {
+                               children[i] = _symbols[i];
+                       }
+               }
+               
+               return children;
+       }
+
+       public boolean hasChildren() {
+               return (_symbols == null || _symbols.length == 0 ? false : true);
+       }
+
+       public IUiModelElement getParent() {
+               return _parent;
+       }
+
+       public Image getLabelImage() {
+               return OprofileUiPlugin.getImageDescriptor(OprofileUiPlugin.IMAGE_ICON).createImage();
+       }
+       
+//     jinu added at 20090526--------------------------
+       public double getPercentage(){
+               return (double)(_image.getCount() - _depCount) / (double)_totalCount;
+       }
+       
+       public String getName(){
+               return  _image.getName();
+       }
+//     -----------------------------   
+}
diff --git a/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelRoot.java b/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelRoot.java
new file mode 100644 (file)
index 0000000..bceb693
--- /dev/null
@@ -0,0 +1,151 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Kent Sebastian <ksebasti@redhat.com> - initial API and implementation 
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.oprofile.ui.model;
+
+import org.eclipse.linuxtools.oprofile.core.model.OpModelEvent;
+import org.eclipse.linuxtools.oprofile.core.model.OpModelRoot;
+import org.eclipse.linuxtools.oprofile.core.model.OpModelSession;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * Convenience class for creating the UI model from the oprofile data model,
+ *  via a single point of access.
+ */
+public class UiModelRoot implements IUiModelElement {
+       //jinu removed at 20090704
+       //private static UiModelRoot _uiModelRoot = new UiModelRoot();  //singleton
+       private UiModelEvent[] _events;                                                 //this node's children
+
+
+       /** constructor, private for singleton use **/
+       //jinu removed at 20090704
+       /*
+       protected UiModelRoot() {
+//             refreshModel();
+               _events = null;
+//             _uiModelRoot = this;
+       }
+       */
+       
+       public UiModelRoot() {
+               _events = null;
+       }
+       
+       /**
+        * Get the instance of this ui model root.
+        * @return the ui model root object
+        */
+       //jinu removed at 20090704
+       /*
+       public static UiModelRoot getDefault() {
+               return _uiModelRoot;
+       }
+       */
+
+       /**
+        * Kick off creating the UI model from the data model. Meant to 
+        *      be called from UI code. The refreshModel() method is called for 
+        *  the child elements from their constructor.
+        */
+       //jinu removed at 20090704
+       /*
+       public void refreshModel() {
+               OpModelEvent dataModelEvents[] = getModelDataEvents();
+
+               if (dataModelEvents != null) {
+                       _events = new UiModelEvent[dataModelEvents.length];
+                       for (int i = 0; i < dataModelEvents.length; i++) {
+                               _events[i] = new UiModelEvent(dataModelEvents[i]);
+                       }
+               }
+       }
+       
+       
+       protected OpModelEvent[] getModelDataEvents() {
+               OpModelRoot modelRoot = OpModelRoot.getDefault();
+               return modelRoot.getEvents();
+       }
+       */
+
+       /** IUiModelElement functions **/
+       public String getLabelText() {
+               return null;
+       }
+
+       public IUiModelElement[] getChildren() {
+               return _events;
+       }
+
+       public boolean hasChildren() {
+               return (_events == null || _events.length == 0 ? false : true);
+       }
+
+       public IUiModelElement getParent() {
+               return null;
+       }
+
+       public Image getLabelImage() {
+               return null;
+       }
+       
+//     jinu added at 20090526-------------
+       public String getName(){
+               return null;
+       }
+       
+       public double getPercentage(){
+               return -1;
+       }
+       
+       public void refreshModel(OpModelRoot modelRoot ) {
+                       setXML(modelRoot.getXML());
+                       
+                       OpModelEvent dataModelEvents[] = modelRoot.getEvents();
+       
+                       if (dataModelEvents != null) {
+                               _events = new UiModelEvent[dataModelEvents.length];
+                               for (int i = 0; i < dataModelEvents.length; i++) {
+                                       _events[i] = new UiModelEvent(dataModelEvents[i]);
+                               }
+                       }else{
+                               String message = "There is no sample data.";
+                               _events = new UiModelEvent[1];
+                               OpModelEvent event = new OpModelEvent(message);
+                               event._setSessions(new OpModelSession[0]);
+                               _events[0] = new UiModelEvent(event);
+                       }
+               /*if(modelRoot==null)
+                       return;
+                       
+               setXML(modelRoot.getXML());
+               
+               OpModelEvent dataModelEvents[] = modelRoot.getEvents();
+
+               if (dataModelEvents != null) {
+                       _events = new UiModelEvent[dataModelEvents.length];
+                       for (int i = 0; i < dataModelEvents.length; i++) {
+                               _events[i] = new UiModelEvent(dataModelEvents[i]);
+                       }
+               }*/
+       }
+//--------------------------
+       //jinu added at 20090704----------------------
+       private String xmlStr;
+       public void setXML(String xmlStr) {
+               this.xmlStr = xmlStr;
+       }
+
+       public String getXML() {
+               return xmlStr;
+       }
+       //--------------------------------
+       
+}
diff --git a/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelSample.java b/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelSample.java
new file mode 100644 (file)
index 0000000..e52885b
--- /dev/null
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Kent Sebastian <ksebasti@redhat.com> - initial API and implementation 
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.oprofile.ui.model;
+
+import org.eclipse.linuxtools.oprofile.core.model.OpModelSample;
+import org.eclipse.linuxtools.oprofile.ui.OprofileUiMessages;
+import org.eclipse.linuxtools.oprofile.ui.OprofileUiPlugin;
+import org.eclipse.swt.graphics.Image;
+
+public class UiModelSample implements IUiModelElement {
+       private IUiModelElement _parent;                //parent element
+       private OpModelSample _sample;                  //the node in the data model
+       private int _totalCount;                                //total sample count for the parent session
+       
+       public UiModelSample(IUiModelElement parent, OpModelSample sample, int totalCount) {
+               _parent = parent;
+               _sample = sample;
+               _totalCount = totalCount;
+       }
+       
+       @Override
+       public String toString() {
+               double countPercentage = (double)_sample.getCount() / (double)_totalCount;
+               String percentage = OprofileUiPlugin.getPercentageString(countPercentage);
+               
+               return percentage + " " + OprofileUiMessages.getString("uimodel.sample.on.line") + Integer.toString(_sample.getLine()); //$NON-NLS-1$ //$NON-NLS-2$
+       }
+       
+       public int getLine() {
+               return _sample.getLine();
+       }
+       
+       public double getCountPercentage() {
+               return (double)_sample.getCount() / (double)_totalCount;
+       }
+       
+       /** IUiModelElement functions **/
+       public String getLabelText() {
+               return toString();
+       }
+
+       public IUiModelElement[] getChildren() {
+               return null;
+       }
+
+       public boolean hasChildren() {
+               return false;           //bottom level element
+       }
+
+       public IUiModelElement getParent() {
+               return _parent;
+       }
+
+       public Image getLabelImage() {
+               return OprofileUiPlugin.getImageDescriptor(OprofileUiPlugin.SAMPLE_ICON).createImage();
+       }
+       
+//     jinu added at 20090526-------------------------
+       public double getPercentage(){
+               return (double)_sample.getCount() / (double)_totalCount;
+       }
+       
+       public String getName(){
+               return  ((UiModelSymbol)_parent).getShortFileName() + " : "+Integer.toString(_sample.getLine());
+       }
+//     -----------------------------
+}
diff --git a/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelSession.java b/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelSession.java
new file mode 100644 (file)
index 0000000..fb7cd12
--- /dev/null
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Kent Sebastian <ksebasti@redhat.com> - initial API and implementation 
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.oprofile.ui.model;
+
+import org.eclipse.linuxtools.oprofile.core.model.OpModelImage;
+import org.eclipse.linuxtools.oprofile.core.model.OpModelSession;
+import org.eclipse.linuxtools.oprofile.ui.OprofileUiPlugin;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * Children of events in the view -- sessions containing images/symbols
+ *  for its parent event. Must have a child image. May also have dependent
+ *  images, which are children of the Image in the data model, but are 
+ *  displayed as children of the session in the view.
+ */
+public class UiModelSession implements IUiModelElement {
+       private IUiModelElement _parent;                //parent element
+       private OpModelSession _session;                //the node in the data model
+       private UiModelImage _image;                    //this node's child
+       private UiModelDependent _dependent;    //dependent images of the OpModelImage
+
+       //OProfile's default session name
+       private static final String DEFAULT_SESSION_NAME = "current"; //$NON-NLS-1$
+       
+       public UiModelSession(IUiModelElement parent, OpModelSession session) {
+               _parent = parent;
+               _session = session;
+               _image = null;
+               _dependent = null;
+               refreshModel();
+       }
+       
+       private void refreshModel() {
+               OpModelImage dataModelImage = _session.getImage();
+               if (dataModelImage != null) {
+                       _image = new UiModelImage(this, dataModelImage, dataModelImage.getCount(), dataModelImage.getDepCount());
+                       
+                       if (dataModelImage.hasDependents()) {
+                               _dependent = new UiModelDependent(this, dataModelImage.getDependents(), dataModelImage.getCount(), dataModelImage.getDepCount());
+                       }
+               }
+       }
+
+       @Override
+       public String toString() {
+               return _session.getName();
+       }
+       
+       public boolean isDefaultSession() {
+               return _session.getName().equalsIgnoreCase(DEFAULT_SESSION_NAME);
+       }
+
+       /** IUiModelElement functions **/
+       public String getLabelText() {
+               return toString();
+       }
+
+       public IUiModelElement[] getChildren() {
+               if (_dependent != null) {
+                       return new IUiModelElement[] {_image, _dependent};
+               } else {
+                       return new IUiModelElement[] {_image};
+               }
+       }
+
+       public boolean hasChildren() {
+               return (_image != null);
+       }
+
+       public IUiModelElement getParent() {
+               return _parent;
+       }
+
+       public Image getLabelImage() {
+               return OprofileUiPlugin.getImageDescriptor(OprofileUiPlugin.SESSION_ICON).createImage();
+       }
+       
+//     jinu added at 20090526-------------------
+       public String getName(){
+               return null;
+       }
+       
+       public double getPercentage(){
+               return -1;
+       }
+//     -----------------------------
+}
diff --git a/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelSymbol.java b/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelSymbol.java
new file mode 100644 (file)
index 0000000..5f2cf2c
--- /dev/null
@@ -0,0 +1,121 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Kent Sebastian <ksebasti@redhat.com> - initial API and implementation 
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.oprofile.ui.model;
+
+import java.io.File;
+import java.util.ArrayList;
+
+import org.eclipse.linuxtools.oprofile.core.model.OpModelSample;
+import org.eclipse.linuxtools.oprofile.core.model.OpModelSymbol;
+import org.eclipse.linuxtools.oprofile.ui.OprofileUiMessages;
+import org.eclipse.linuxtools.oprofile.ui.OprofileUiPlugin;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * Children of images in the view -- a function name in the profiled 
+ *  image's source code. May or may not have child samples.
+ */
+public class UiModelSymbol implements IUiModelElement {
+       private IUiModelElement _parent;        //parent element
+       private OpModelSymbol _symbol;          //the node in the data model
+       private UiModelSample _samples[];       //this node's children
+       private int _totalCount;                        //total count of samples for the parent session
+       
+       public UiModelSymbol(IUiModelElement parent, OpModelSymbol symbol, int totalCount) {
+               _parent = parent;
+               _symbol = symbol;
+               _samples = null;
+               _totalCount = totalCount;
+               refreshModel();
+               
+               //jinu added at 20090602                
+               //addChartModel();
+       }       
+       
+       //jinu added at 20090602
+       /*
+       private void addChartModel(){
+               ChartModelRoot chartModel = ChartModelRoot.getDefault();
+               if(_parent.getParent() instanceof UiModelSession){
+                       chartModel.addElement(this);
+               }
+       }
+       */
+       
+       private void refreshModel() {
+               ArrayList<UiModelSample> sampleList = new ArrayList<UiModelSample>();
+               OpModelSample dataModelSamples []= _symbol.getSamples();
+               
+               for (int i = 0; i < dataModelSamples.length; i++) {
+                       //dont display samples with line number of 0, meaning no line number
+                       // was correlated, more likely that no source file exists
+                       if (dataModelSamples[i].getLine() != 0) {
+                               sampleList.add(new UiModelSample(this, dataModelSamples[i], _totalCount));
+                       }
+               }
+               
+               _samples = new UiModelSample[sampleList.size()];
+               sampleList.toArray(_samples);
+       }
+       
+       @Override
+       public String toString() {
+               double countPercentage = (double)_symbol.getCount() / (double)_totalCount;
+               String percentage = OprofileUiPlugin.getPercentageString(countPercentage);
+               
+               //a hack to get `basename` type functionality
+               String fileName = (new File(_symbol.getFile())).getName();
+//             String fileName = _symbol.getFile();
+
+               return percentage + " " + OprofileUiMessages.getString("uimodel.percentage.in") + _symbol.getName() + (fileName.length() == 0 ? "" : " [" + fileName + "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+       }
+       
+       public String getFileName() {
+               return _symbol.getFile();
+       }
+
+       /** IUiModelElement functions **/
+       public String getLabelText() {
+               return toString();
+       }
+
+       public IUiModelElement[] getChildren() {
+               return _samples;
+       }
+
+       public boolean hasChildren() {
+               return (_samples == null || _samples.length == 0 ? false : true);
+       }
+
+       public IUiModelElement getParent() {
+               return _parent;
+       }
+
+       public Image getLabelImage() {
+               return OprofileUiPlugin.getImageDescriptor(OprofileUiPlugin.SYMBOL_ICON).createImage();
+       }
+       
+//     jinu added at 20090526--------------------
+       public double getPercentage(){
+               return (double)_symbol.getCount() / (double)_totalCount;
+       }
+       
+       public String getName(){
+               //String fileName = (new File(_symbol.getFile())).getName();
+               String fileName = getShortFileName();
+               return  _symbol.getName() + (fileName.length() == 0 ? "" : " [" + fileName + "]");
+       }
+       
+       public String getShortFileName() {
+               return (new File(getFileName())).getName();
+       }
+//     -----------------------------
+}
diff --git a/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/oprofileui.properties b/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/oprofileui.properties
new file mode 100644 (file)
index 0000000..a82ce3f
--- /dev/null
@@ -0,0 +1,38 @@
+######################################################################
+# Copyright (c) 2004,2008 Red Hat, Inc.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#    Keith Seitz <keiths@redhat.com> - initial implementation
+#    Kent Sebastian <ksebasti@redhat.com>
+###################################################################### 
+savedialog.title=Save Session
+savedialog.message=Enter the new name of the default session
+savedialog.initial=
+savedialog.validator.invalidChar={0} is an invalid character in session name \"{1}\".
+savedialog.validator.containsWhitespace=Session name \"{0}\" cannot contain whitespace.
+savedialog.validator.exists=Session \"{0}\" already exists.
+
+defaultsessiondialog.nodefaultsession.title=Error Saving Default Session
+defaultsessiondialog.nodefaultsession.message=No default session exists.
+
+view.dialog.parsing.text=Parsing OProfile Data
+view.actions.refresh.label=Refresh View
+view.actions.logreader.label=Open OProfile Daemon Log
+view.actions.savedefaultsession.label=Save Default Session
+
+oprofiled.logreader.dialog.title=OProfiled Log
+oprofiled.logreader.error.fileNotFound=Log file empty or does not exist.
+oprofiled.logreader.error.io=Error reading log file.
+
+uimodel.percentage.in=in 
+uimodel.sample.on.line=on line 
+uimodel.dependent.dependent.images=dependent images
+
+opxmlParse.error.multipleImages=Error: samples not created from Eclipse-OProfile plugin. Please remove this session.
+
+annotation.text.from=from event 
+annotation.text.in=in session 
diff --git a/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/view/OprofileView.java b/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/view/OprofileView.java
new file mode 100644 (file)
index 0000000..c67c978
--- /dev/null
@@ -0,0 +1,246 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Kent Sebastian <ksebasti@redhat.com> - initial API and implementation 
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.oprofile.ui.view;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.linuxtools.oprofile.core.model.OpModelRoot;
+import org.eclipse.linuxtools.oprofile.ui.OprofileUiMessages;
+import org.eclipse.linuxtools.oprofile.ui.OprofileUiPlugin;
+import org.eclipse.linuxtools.oprofile.ui.model.UiModelRoot;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.GC;
+// commented by greatim 2011.06.01
+//import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeColumn;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.Section;
+import org.eclipse.ui.part.ViewPart;
+
+import org.tizen.oprofile.core.OprofileComm;
+import org.tizen.oprofile.ui.view.OprofileViewLabelProvider;
+
+/**
+ * The view for the OProfile plugin. Shows the elements gathered by the data model
+ *   in a tree viewer, parsed by the ui model (in the model package). The hierarchy
+ *   (as it is displayed) looks like:
+ *   
+ *   UiModelRoot (not shown in the view)
+ *   \_ UiModelEvent
+ *   \_ ...
+ *   \_ UiModelEvent
+ *      \_ UiModelSession
+ *      \_ ...
+ *      \_ UiModelSession
+ *         \_ UiModelImage
+ *         |  \_ UiModelSymbol
+ *         |  \_ ...
+ *         |  \_ UiModelSymbol
+ *         |     \_ UiModelSample
+ *         |     \_ ...
+ *         |     \_ UiModelSample
+ *         \_ UiModelDependent
+ *            \_ UiModelImage
+ *            |  \_ ... (see above)
+ *            \_ ...
+ * 
+ * The refreshView() function takes care of launching the data model parsing and
+ *   ui model parsing in a separate thread.
+ */
+public class OprofileView extends ViewPart {
+       private TreeViewer _viewer;
+       private FormToolkit toolkit;
+       
+       @Override
+       public void createPartControl(Composite parent) {
+               //jinu removed at 20090602              
+//             _createTreeViewer(parent);
+//             _createActionMenu();
+               
+               //jinu added at 20090616------------------------------
+               Display display = parent.getDisplay();
+               toolkit = new FormToolkit(display);
+               parent.setLayout(new GridLayout(1, false));
+               parent.setBackground(display.getSystemColor(SWT.COLOR_WHITE));
+               
+               createTitle(parent);
+               createTreeViewer(parent);
+               //--------------------------------------
+
+               OprofileUiPlugin.getDefault().setOprofileView(this);
+       }
+       
+       //jinu added at 20090526
+       private void createTitle(Composite parent) {
+               Section section = toolkit.createSection(parent, Section.TITLE_BAR);
+               section.setText("Profiling Information");
+               section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               toolkit.createCompositeSeparator(section);
+               
+               //String text = "Sampling data from oprofiler daemon is shown on treeview as following";
+               //toolkit.createLabel(parent, text);
+               
+       }
+       
+       private void createTreeViewer(Composite parent) {
+               _viewer = new TreeViewer(parent, SWT.SINGLE|SWT.H_SCROLL|SWT.FULL_SELECTION);
+               
+               final Tree tree = _viewer.getTree();
+               tree.setHeaderVisible(true);
+               tree.setLinesVisible(true);
+               tree.setLayoutData(new GridData(GridData.FILL_BOTH));
+               
+               String[] columnNames = {"Type", "Percent(%)", "Name"};
+               int[] columnWidths = {250,100,100}; 
+               
+               final TreeColumn[] column = new TreeColumn[columnNames.length];
+               
+               for(int i=0;i<column.length;i++){
+                       column[i] = new TreeColumn(tree, SWT.LEFT);
+                       column[i].setText(columnNames[i]);
+                       column[i].setWidth(columnWidths[i]);
+               }
+               
+               final int targetColumnIdx = 1;
+               
+               tree.addListener(SWT.PaintItem, new Listener() {
+                       public void handleEvent(Event event) {
+                               if (event.index == targetColumnIdx) {
+                                       GC gc = event.gc;
+                                       
+                                       String text = ((TreeItem)(event.item)).getText(targetColumnIdx);
+                                       int percent = 0;
+                                       if( !(text==null||text.length()<=0||text.startsWith("<"))){
+                                               percent = (int)Double.parseDouble(text);
+                                       }
+                                       int width = column[targetColumnIdx].getWidth() * percent / 100;
+
+                                       if(width>5){
+                                               Display display = Display.getCurrent();
+                                               gc.setForeground(display.getSystemColor(SWT.COLOR_GREEN));
+                                               gc.setBackground(display.getSystemColor(SWT.COLOR_DARK_CYAN));
+                                               gc.fillGradientRectangle(event.x+40, event.y, width-5, event.height, true);
+                                               
+                                               Rectangle rect = new Rectangle(event.x+40, event.y, width-5, event.height-1);
+                                               gc.drawRectangle(rect);
+                                               gc.setForeground(display.getSystemColor(SWT.COLOR_LIST_FOREGROUND));
+                                       }
+
+                                       // commented by greatim at 2011.06.01
+//                                     Point size = gc.textExtent(text);                                       
+//                                     int offset = Math.max(0, (event.height - size.y) / 2);
+                                       //gc.drawText(text, event.x+2, event.y+offset, true);
+                               }
+                       }
+               });             
+               
+               _viewer.setContentProvider(new OprofileViewContentProvider());
+               _viewer.setLabelProvider(new OprofileViewLabelProvider());
+               _viewer.addDoubleClickListener(new OprofileViewDoubleClickListener());
+               getSite().setSelectionProvider(_viewer);
+       }
+       
+       //jinu removed at 20090526
+       /*
+       private void _createTreeViewer(Composite parent) {
+               _viewer = new TreeViewer(parent, SWT.SINGLE);
+               _viewer.setContentProvider(new OprofileViewContentProvider());
+               _viewer.setLabelProvider(new OprofileViewLabelProvider());
+               _viewer.addDoubleClickListener(new OprofileViewDoubleClickListener());
+       }
+       */
+
+       //jinu removed at 20090707
+       /*
+       private void _createActionMenu() {
+               IMenuManager manager = getViewSite().getActionBars().getMenuManager();
+               manager.add(new OprofileViewLogReaderAction());
+               manager.add(new OprofileViewRefreshAction());
+               manager.add(new OprofileViewSaveDefaultSessionAction());
+       }
+       */
+       
+       private TreeViewer getTreeViewer() {
+               return _viewer;
+       }
+       
+       /**
+        * Extremely convoluted way of getting the running and parsing to happen in 
+        *   a separate thread, with a progress monitor. In most cases and on fast 
+        *   machines this will probably only be a blip.
+        */
+       public void refreshView() {
+               try {
+                       PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(OprofileUiPlugin.ID_OPROFILE_VIEW);
+               } catch (PartInitException e) {
+                       e.printStackTrace();
+               }
+
+               IRunnableWithProgress refreshRunner = new IRunnableWithProgress() {
+                       public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+                               monitor.beginTask(OprofileUiMessages.getString("view.dialog.parsing.text"), 2); //$NON-NLS-1$
+
+                               //jinu added at 20090622
+                               //ChartModelRoot.getDefault().clear();
+                               
+                               //jinu modified at 20090704                             
+//                             OpModelRoot dataModelRoot = OpModelRoot.getDefault();
+//                             dataModelRoot.refreshModel();
+                               OpModelRoot opModel = OprofileComm.getModelData();
+                               
+//                             System.out.println(dataModelRoot);      //debugging
+                               monitor.worked(1);
+
+                               final UiModelRoot UiRoot = new UiModelRoot();
+                               UiRoot.refreshModel(opModel);
+                               
+                               Display.getDefault().asyncExec(new Runnable() {
+                                       public void run() {
+                                                       OprofileUiPlugin.getDefault().getOprofileView().getTreeViewer().setInput(UiRoot);
+                                       }
+                               });
+                               monitor.worked(1);
+
+                               monitor.done();
+                       }
+               };
+               
+               ProgressMonitorDialog dialog = new ProgressMonitorDialog(null);
+               try {
+                       dialog.run(true, false, refreshRunner);
+               } catch (InvocationTargetException e) {
+                       e.printStackTrace();
+               } catch (InterruptedException e) {
+                       e.printStackTrace();
+               }
+       }
+       
+       @Override
+       public void setFocus() {
+               // TODO Auto-generated method stub
+       }
+
+}
diff --git a/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/view/OprofileViewContentProvider.java b/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/view/OprofileViewContentProvider.java
new file mode 100644 (file)
index 0000000..8db2dcb
--- /dev/null
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Kent Sebastian <ksebasti@redhat.com> - initial API and implementation,
+ *     adapted from Keith Seitz's ProfileContentProvider 
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.oprofile.ui.view;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.linuxtools.oprofile.ui.model.IUiModelElement;
+
+/**
+ * Content provider for the OprofileView's tree viewer.
+ */
+public class OprofileViewContentProvider implements ITreeContentProvider {
+
+       public Object[] getChildren(Object element) {
+               Assert.isLegal(element instanceof IUiModelElement, "in OprofileViewContentProvider"); //$NON-NLS-1$
+                       return ((IUiModelElement) element).getChildren();
+       }
+
+       public Object getParent(Object element) {
+               Assert.isLegal(element instanceof IUiModelElement, "in OprofileViewContentProvider"); //$NON-NLS-1$
+               return ((IUiModelElement) element).getParent();
+       }
+
+       public boolean hasChildren(Object element) {
+               Assert.isLegal(element instanceof IUiModelElement, "in OprofileViewContentProvider"); //$NON-NLS-1$
+                       return ((IUiModelElement) element).hasChildren();
+       }
+
+       public Object[] getElements(Object parentElement) {
+               return getChildren(parentElement);
+       }
+       
+       public void dispose() {
+               // TODO Auto-generated method stub
+       }
+
+       public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+               // TODO Auto-generated method stub
+       }
+
+}
diff --git a/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/view/OprofileViewDoubleClickListener.java b/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/view/OprofileViewDoubleClickListener.java
new file mode 100644 (file)
index 0000000..c6183b3
--- /dev/null
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Kent Sebastian <ksebasti@redhat.com> - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.oprofile.ui.view;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.TreeSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.linuxtools.oprofile.ui.model.IUiModelElement;
+import org.eclipse.linuxtools.oprofile.ui.model.UiModelEvent;
+import org.eclipse.linuxtools.oprofile.ui.model.UiModelImage;
+import org.eclipse.linuxtools.oprofile.ui.model.UiModelSample;
+import org.eclipse.linuxtools.oprofile.ui.model.UiModelSession;
+import org.eclipse.linuxtools.oprofile.ui.model.UiModelSymbol;
+import org.eclipse.linuxtools.profiling.ui.ProfileUIUtils;
+import org.eclipse.ui.PartInitException;
+
+/**
+ * Listener for the oprofile view when a user double clicks on an element in the tree.
+ * 
+ * Different things occur based on the event:
+ *   
+ *   UiModelEvent              - nothing (?)
+ *   UiModelSession    - save the session to a different name
+ *   UiModelImage              - nothing (?)
+ *   UiModelSymbol             - nothing (?)
+ *   UiModelSample             - go to line number in appropriate file
+ */
+public class OprofileViewDoubleClickListener implements IDoubleClickListener {
+       public void doubleClick(DoubleClickEvent event) {
+               IUiModelElement element = (IUiModelElement)((TreeSelection)((TreeViewer)event.getSource()).getSelection()).getFirstElement();
+/*             
+               if (element instanceof UiModelEvent) {
+//                     UiModelEvent event = (UiModelEvent)element;
+               } else if (element instanceof UiModelSession) {
+                       // moved into an action menu
+               } else if (element instanceof UiModelImage) {
+//                     UiModelImage image = (UiModelImage)element;
+               } else if (element instanceof UiModelSymbol) {
+                       // disable this.. for binary section such as .plt, 
+                       // this will open the binary in an editor = bad
+
+                       //jump to 1st line in the file
+//                     UiModelSymbol symbol = (UiModelSymbol)element;
+//                     String fileName = symbol.getFileName();
+//                     
+//                     if (fileName.length() > 0) {
+//                             try {
+//                                     ProfileUIUtils.openEditorAndSelect(fileName, 1);
+//                             } catch (PartInitException e) {
+//                                     e.printStackTrace();
+//                             } catch (BadLocationException e) {
+//                                     e.printStackTrace();
+//                             }
+//                     }
+               } else
+*/
+               if (element instanceof UiModelSample) {
+                       //jump to line number in the appropriate file
+                       UiModelSample sample = (UiModelSample)element;
+                       int line = sample.getLine();
+                       
+                       //get file name from the parent sample 
+                       String fileName = ((UiModelSymbol)sample.getParent()).getFileName();
+                       
+                       //fixed for sb2
+                       //String filePath = ScratchboxTargetControl.getHostpathFromSboxpath(fileName);
+                       String filePath = fileName;
+                       //--------------------------------
+                       
+                       try {
+                               ProfileUIUtils.openEditorAndSelect(filePath, line);
+                       } catch (PartInitException e) {
+                               e.printStackTrace();
+                       } catch (BadLocationException e) {
+                               e.printStackTrace();
+                       }
+               }
+       }
+}
diff --git a/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/view/OprofileViewLabelProvider.java b/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/view/OprofileViewLabelProvider.java
new file mode 100644 (file)
index 0000000..2cb4f9a
--- /dev/null
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Kent Sebastian <ksebasti@redhat.com> - initial API and implementation,
+ *     adapted from Keith Seitz's ProfileLabelProvider 
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.oprofile.ui.view;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.linuxtools.oprofile.ui.model.IUiModelElement;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * Content provider for OprofileView's tree viewer.
+ */
+public class OprofileViewLabelProvider implements ILabelProvider {
+
+       public Image getImage(Object element) {
+               Assert.isLegal(element instanceof IUiModelElement, "in OprofileViewLabelProvider"); //$NON-NLS-1$
+               return ((IUiModelElement) element).getLabelImage();
+       }
+
+       public String getText(Object element) {
+               Assert.isLegal(element instanceof IUiModelElement, "in OprofileViewLabelProvider"); //$NON-NLS-1$
+               return ((IUiModelElement) element).getLabelText();
+       }
+
+       public void addListener(ILabelProviderListener listener) {
+               // TODO Auto-generated method stub
+       }
+
+       public void dispose() {
+               // TODO Auto-generated method stub
+       }
+
+       public boolean isLabelProperty(Object element, String property) {
+               return false;
+       }
+
+       public void removeListener(ILabelProviderListener listener) {
+               // TODO Auto-generated method stub
+       }
+
+}
diff --git a/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/view/OprofileViewLogReaderAction.java b/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/view/OprofileViewLogReaderAction.java
new file mode 100644 (file)
index 0000000..07ec62e
--- /dev/null
@@ -0,0 +1,142 @@
+/*******************************************************************************
+ * Copyright (c) 2004,2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Kent Sebastian <ksebasti@redhat.com> - initial API and implementation 
+ *    Keith Seitz <keiths@redhat.com> - much of the code in the LogReader class
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.oprofile.ui.view;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.linuxtools.oprofile.core.Oprofile;
+import org.eclipse.linuxtools.oprofile.ui.OprofileUiMessages;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Layout;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * Log reader action. Reads /var/lib/oprofile/samples/oprofiled.log and displays
+ *  it in a nice dialog. Although the log is of dubious utility, it might be useful 
+ *  to some.
+ */
+public class OprofileViewLogReaderAction extends Action {
+       public OprofileViewLogReaderAction() {
+               super(OprofileUiMessages.getString("view.actions.logreader.label")); //$NON-NLS-1$
+       }
+       
+       @Override
+       public void run() {
+               Shell activeShell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
+               LogReader log = new LogReader();
+               
+               try {
+                       new ProgressMonitorDialog(activeShell).run(true, false, log);
+               } catch (InvocationTargetException e) {
+                       e.printStackTrace();
+               } catch (InterruptedException e) {
+                       e.printStackTrace();
+               }
+           
+               //open custom log dialog
+           OprofiledLogDialog odlg = new OprofiledLogDialog(activeShell, log.getLogContents());
+           odlg.open();
+       }
+}
+
+/**
+ * A Runnable to read oprofiled's logfile 
+ */
+class LogReader implements Runnable, IRunnableWithProgress {
+       private static long _lastModified = -1;
+       private static String _contents = null;
+
+       public void run() {
+               File logFile = new File(Oprofile.getLogFile());
+               long modified = logFile.lastModified();
+               
+               //only reread it if it has been modified since the last run
+               if (modified != _lastModified) {
+                       _lastModified = modified;
+                       _contents = new String();
+                       
+                       try {
+                               BufferedReader reader = new BufferedReader(new FileReader(logFile));
+                               String line;
+                               while ((line = reader.readLine()) != null) {
+                                       _contents += line + "\n"; //$NON-NLS-1$
+                               }
+                       } catch (FileNotFoundException e) {
+                               // The file doesn't exist or was erased. Try again next time.
+                               _contents = OprofileUiMessages.getString("oprofiled.logreader.error.fileNotFound"); //$NON-NLS-1$
+                       } catch (IOException e) {
+                               // Error reading log. Try again next time.
+                               _lastModified = 0;
+                               _contents = OprofileUiMessages.getString("oprofiled.logreader.error.io"); //$NON-NLS-1$
+                       }
+               }
+       }
+       
+       public String getLogContents() {
+               return _contents;
+       }
+
+
+       public void run(IProgressMonitor monitor) throws InvocationTargetException,
+                       InterruptedException {
+               this.run();
+       }
+}
+
+/**
+ * A custom dialog box to display the oprofiled log file.
+ */
+class OprofiledLogDialog extends MessageDialog {
+       //string to contain the log file
+       String textContent = null;
+       
+       final int GRID_WIDTH = 350;
+       final int GRID_HEIGHT = 400;
+       
+       public OprofiledLogDialog (Shell parentShell, String dialogMessage) {
+               super(parentShell, OprofileUiMessages.getString("oprofiled.logreader.dialog.title"), null, null, MessageDialog.NONE, new String[] { IDialogConstants.OK_LABEL }, 0); //$NON-NLS-1$
+               textContent = dialogMessage;
+       }
+       
+       @Override
+    protected Control createCustomArea(Composite parent) {
+               Composite area = new Composite(parent, 0);
+               Layout layout = new GridLayout(1, true);
+               GridData gd = new GridData(GRID_WIDTH, GRID_HEIGHT);
+               
+               area.setLayout(layout);
+               area.setLayoutData(gd);
+               
+               Text txt = new Text(area, SWT.READ_ONLY | SWT.MULTI | SWT.V_SCROLL | SWT.BORDER);
+               txt.setText(textContent);
+               txt.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+               
+        return area;
+    }
+}
diff --git a/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/view/OprofileViewRefreshAction.java b/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/view/OprofileViewRefreshAction.java
new file mode 100644 (file)
index 0000000..5f554cd
--- /dev/null
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Kent Sebastian <ksebasti@redhat.com> - initial API and implementation 
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.oprofile.ui.view;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.linuxtools.oprofile.ui.OprofileUiMessages;
+import org.eclipse.linuxtools.oprofile.ui.OprofileUiPlugin;
+
+/**
+ * Refresh menu item. 
+ */
+public class OprofileViewRefreshAction extends Action {
+       public OprofileViewRefreshAction() {
+               super(OprofileUiMessages.getString("view.actions.refresh.label")); //$NON-NLS-1$
+       }
+       
+       @Override
+       public void run() {
+               OprofileUiPlugin.getDefault().getOprofileView().refreshView();
+       }
+}
diff --git a/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/view/OprofileViewSaveDefaultSessionAction.java b/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/view/OprofileViewSaveDefaultSessionAction.java
new file mode 100644 (file)
index 0000000..d9c2c11
--- /dev/null
@@ -0,0 +1,126 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2009 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Kent Sebastian <ksebasti@redhat.com> - initial API and implementation 
+ *    Keith Seitz <keiths@redhat.com> - SaveSessionValidator code 
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.oprofile.ui.view;
+
+import java.io.File;
+import java.text.MessageFormat;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.dialogs.IInputValidator;
+import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.window.Window;
+import org.eclipse.linuxtools.oprofile.core.OpcontrolException;
+import org.eclipse.linuxtools.oprofile.core.Oprofile;
+import org.eclipse.linuxtools.oprofile.core.OprofileCorePlugin;
+import org.eclipse.linuxtools.oprofile.ui.OprofileUiMessages;
+import org.eclipse.linuxtools.oprofile.ui.OprofileUiPlugin;
+import org.eclipse.linuxtools.oprofile.ui.model.IUiModelElement;
+import org.eclipse.linuxtools.oprofile.ui.model.UiModelRoot;
+import org.eclipse.linuxtools.oprofile.ui.model.UiModelSession;
+
+/**
+ * Menu item to save the default session. Moved from a double-click in the view
+ * on the default session for consistency (since non-default sessions can't be saved). 
+ */
+public class OprofileViewSaveDefaultSessionAction extends Action {
+       public OprofileViewSaveDefaultSessionAction() {
+               super(OprofileUiMessages.getString("view.actions.savedefaultsession.label")); //$NON-NLS-1$
+       }
+       
+       @Override
+       public void run() {
+               boolean defaultSessionExists = false;
+               //jinu modified at 20090705. this class isn't used any more. 
+               //this statement is commented temporary to avoid compile error 
+               //UiModelRoot modelRoot = UiModelRoot.getDefault();
+               UiModelRoot modelRoot = null;
+
+               if (modelRoot.hasChildren()) {
+                       IUiModelElement[] events = modelRoot.getChildren();
+                       for (IUiModelElement e : events) {
+                               IUiModelElement[] sessions = e.getChildren();
+                               for (IUiModelElement s : sessions) {
+                                       if (((UiModelSession)s).isDefaultSession()) {
+                                               defaultSessionExists = true;
+                                               break;
+                                       }
+                               }
+                               if (defaultSessionExists)
+                                       break;
+                       }
+               }
+               
+               if (defaultSessionExists) {
+                       //the following code was originially written by Keith Seitz
+                       InputDialog dialog = new InputDialog(OprofileUiPlugin.getActiveWorkbenchShell(),
+                                       OprofileUiMessages.getString("savedialog.title"),    //$NON-NLS-1$
+                                       OprofileUiMessages.getString("savedialog.message"),    //$NON-NLS-1$
+                                       OprofileUiMessages.getString("savedialog.initial"),   //$NON-NLS-1$
+                                       new SaveSessionValidator());
+                       
+                       int result = dialog.open();
+                       if (result == Window.OK) {
+                               try {
+                                       OprofileCorePlugin.getDefault().getOpcontrolProvider().saveSession(dialog.getValue());
+                                       OprofileUiPlugin.getDefault().getOprofileView().refreshView();
+                               } catch (OpcontrolException oe) {
+                                       OprofileCorePlugin.showErrorDialog("opcontrolProvider", oe); //$NON-NLS-1$
+                               }
+                       }
+               } else {
+                       MessageDialog.openError(OprofileUiPlugin.getActiveWorkbenchShell(),
+                                       OprofileUiMessages.getString("defaultsessiondialog.nodefaultsession.title"),  //$NON-NLS-1$
+                                       OprofileUiMessages.getString("defaultsessiondialog.nodefaultsession.message")); //$NON-NLS-1$
+               }
+       }
+       
+       //Original author: Keith Seitz <keiths@redhat.com>
+       private class SaveSessionValidator implements IInputValidator {
+               public String isValid(String newText) {
+                       // Sanity check
+                       if (newText.length() == 0) {
+                               return ""; //$NON-NLS-1$
+                       }
+                       
+                       // Cannot contain invalid characters
+                       int index = newText.indexOf('/');
+                       if (index == -1) {
+                               index = newText.indexOf('\\');
+                       }
+                       
+                       if (index != -1) {
+                               String format = OprofileUiMessages.getString("savedialog.validator.invalidChar"); //$NON-NLS-1$
+                               Object[] fmtArgs = new Object[] { newText.substring(index, index + 1), newText };
+                               return MessageFormat.format(format, fmtArgs);
+                       }
+                               
+                       // Cannot contain whitespace
+                       if (newText.contains(" ") || newText.contains("\t")) { //$NON-NLS-1$ //$NON-NLS-2$
+                               String format = OprofileUiMessages.getString("savedialog.validator.containsWhitespace"); //$NON-NLS-1$
+                               Object[] fmtArgs = new Object[] { newText };
+                               return MessageFormat.format(format, fmtArgs);
+                       }
+                       
+                       // Must not already exist (opcontrol doesn't allow it)
+                       File file = new File(Oprofile.getDefaultSamplesDirectory(), newText);
+                       if (file.exists()) {
+                               String format = OprofileUiMessages.getString("savedialog.validator.exists"); //$NON-NLS-1$
+                               Object[] fmtArgs = new Object[] { newText };
+                               return MessageFormat.format(format, fmtArgs);
+                       }
+
+                       // Everything OK
+                       return null;
+               }
+       };
+}
diff --git a/org.eclipse.linuxtools.oprofile.ui/src/org/tizen/oprofile/ui/chart/ChartControl.java b/org.eclipse.linuxtools.oprofile.ui/src/org/tizen/oprofile/ui/chart/ChartControl.java
new file mode 100644 (file)
index 0000000..f9bf6b5
--- /dev/null
@@ -0,0 +1,222 @@
+/*
+ *  Chart Control
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Jaewon Lim <jaewon81.lim@samsung.com>
+ * Wonhyoung Park <wonhyoung2.park@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.oprofile.ui.chart;
+
+import org.eclipse.birt.chart.device.IDeviceRenderer;
+import org.eclipse.birt.chart.exception.ChartException;
+import org.eclipse.birt.chart.factory.GeneratedChartState;
+import org.eclipse.birt.chart.factory.Generator;
+import org.eclipse.birt.chart.factory.RunTimeContext;
+import org.eclipse.birt.chart.model.Chart;
+import org.eclipse.birt.chart.model.attribute.Bounds;
+import org.eclipse.birt.chart.model.attribute.impl.BoundsImpl;
+import org.eclipse.birt.chart.util.PluginSettings;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ControlEvent;
+import org.eclipse.swt.events.ControlListener;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+
+public class ChartControl extends Canvas implements PaintListener, ControlListener{
+
+       private Chart cm = null;
+
+       private transient boolean bIsPainting = false;
+
+       private transient Image buffer;
+
+       private static int X_OFFSET = 3;
+
+       private static int Y_OFFSET = 3;
+
+       public ChartControl(Composite parent, Chart chart) {
+               super(parent, SWT.BORDER);
+               this.cm = chart;
+               setLayoutData(new GridData(GridData.FILL_BOTH));
+               setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
+
+               addPaintListener(this);
+               addControlListener(this);
+               
+               updateBuffer( );
+               
+               StringBuffer str = new StringBuffer();
+               str.lastIndexOf("", -1);
+
+       }
+
+       public void setChart(Chart chart){
+               this.cm = chart;
+               updateBuffer( );
+       }
+       
+       /**
+        * Generate and render the chart model,the chart image is stored in a
+        * buffer. The buffer will be updated only when the chart model is changed.
+        */
+       private void updateBuffer( )
+       {
+               if ( bIsPainting )
+               {
+                       return;
+               }
+               Throwable paintError = null;
+
+               Rectangle re = this.getClientArea( );
+               final Rectangle adjustedRe = new Rectangle( 0, 0, re.width, re.height );
+
+               if ( adjustedRe.width - 2 * X_OFFSET <= 0
+                               || adjustedRe.height - 2 * Y_OFFSET <= 0 )
+               {
+                       if ( buffer != null && !buffer.isDisposed( ) )
+                       {
+                               buffer.dispose( );
+                               buffer = null;
+                       }
+                       return;
+               }
+
+               if ( cm == null )
+               {
+                       buffer = null;
+               }
+               else
+               {
+                       bIsPainting = true;
+                       Image oldBuffer = null;
+                       if ( buffer == null )
+                       {
+                               buffer = new Image( Display.getDefault( ), adjustedRe );
+                       }
+                       else
+                       {
+                               Rectangle ore = buffer.getBounds( );
+
+                               oldBuffer = buffer;
+
+                               if ( !adjustedRe.equals( ore ) )
+                               {
+                                       buffer = new Image( Display.getDefault( ), adjustedRe );
+                               }
+                       }
+
+                       GC gc = new GC( buffer );
+
+                       // fill default backgournd as white.
+                       gc.setForeground( Display.getDefault( )
+                                       .getSystemColor( SWT.COLOR_WHITE ) );
+                       gc.fillRectangle( buffer.getBounds( ) );
+
+                       final Bounds bo = BoundsImpl.create( X_OFFSET,
+                                       Y_OFFSET,
+                                       adjustedRe.width - 2 * X_OFFSET,
+                                       adjustedRe.height - 2 * Y_OFFSET );
+
+                       IDeviceRenderer deviceRenderer = null;
+                       try
+                       {
+                               deviceRenderer = PluginSettings.instance( )
+                                               .getDevice( "dv.SWT" ); //$NON-NLS-1$
+                               deviceRenderer.setProperty( IDeviceRenderer.GRAPHICS_CONTEXT,
+                                               gc );
+                               bo.scale( 72d / deviceRenderer.getDisplayServer( )
+                                               .getDpiResolution( ) ); // CONVERT
+                               // TO
+                               // POINTS
+
+                               // GENERATE AND RENDER THE CHART
+                               final Generator gr = Generator.instance( );
+                               RunTimeContext rtc = new RunTimeContext( );
+
+                               GeneratedChartState state = gr.build( deviceRenderer.getDisplayServer( ),
+                                               cm,
+                                               bo,
+                                               null,
+                                               rtc,
+                                               null );
+
+                               gr.render( deviceRenderer, state );
+                       }
+                       catch ( ChartException ex )
+                       {
+                               paintError = ex;
+                       }
+                       finally
+                       {
+                               gc.dispose( );
+                               if ( deviceRenderer != null )
+                               {
+                                       deviceRenderer.dispose( );
+                               }
+                       }
+
+                       if ( paintError != null )
+                       {
+                               buffer = oldBuffer;
+                       }
+                       if ( oldBuffer != null && oldBuffer != buffer )
+                       {
+                               oldBuffer.dispose( );
+                       }
+                       bIsPainting = false;
+               }
+
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.swt.events.PaintListener#paintControl(org.eclipse.swt.events.PaintEvent)
+        */
+       public void paintControl( PaintEvent pe )
+       {
+               GC gc = pe.gc;
+               if ( buffer != null )
+               {
+                       gc.drawImage( buffer, 0, 0 );
+               }
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.swt.events.ControlListener#controlMoved(org.eclipse.swt.events.ControlEvent)
+        */
+       public void controlMoved( ControlEvent e )
+       {
+               // TODO Auto-generated method stub
+               
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.swt.events.ControlListener#controlResized(org.eclipse.swt.events.ControlEvent)
+        */
+       public void controlResized( ControlEvent e )
+       {
+                       updateBuffer( );
+                       this.redraw( );
+       }
+}
diff --git a/org.eclipse.linuxtools.oprofile.ui/src/org/tizen/oprofile/ui/chart/ChartEditorInput.java b/org.eclipse.linuxtools.oprofile.ui/src/org/tizen/oprofile/ui/chart/ChartEditorInput.java
new file mode 100644 (file)
index 0000000..ca7a8a7
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ *  Chart Editor Input
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Jaewon Lim <jaewon81.lim@samsung.com>
+ * Wonhyoung Park <wonhyoung2.park@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.oprofile.ui.chart;
+
+import org.eclipse.birt.chart.model.Chart;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IPersistableElement;
+
+public class ChartEditorInput implements IEditorInput {
+       
+       protected Chart chart;
+       protected String name;
+
+       public ChartEditorInput(Chart chart, String name) {
+               this.chart = chart;
+               this.name = name;
+       }
+
+       public boolean exists() {
+               return false;
+       }
+
+       public ImageDescriptor getImageDescriptor() {
+               return null; //$NON-NLS-1$
+       }
+
+       public String getName() {               
+               return name;
+       }
+
+       public IPersistableElement getPersistable() {
+               return null;
+       }
+
+       public String getToolTipText() {
+               return getName();
+       }
+
+       public Object getAdapter(Class adapter) {
+               return null;
+       }
+       
+       public Chart getChart() {
+               return chart;
+       }
+
+}
diff --git a/org.eclipse.linuxtools.oprofile.ui/src/org/tizen/oprofile/ui/chart/ChartModelRoot.java b/org.eclipse.linuxtools.oprofile.ui/src/org/tizen/oprofile/ui/chart/ChartModelRoot.java
new file mode 100644 (file)
index 0000000..8106062
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+ *  Chart Model Root
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Jaewon Lim <jaewon81.lim@samsung.com>
+ * Wonhyoung Park <wonhyoung2.park@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.oprofile.ui.chart;
+
+import java.util.ArrayList;
+
+import org.eclipse.linuxtools.oprofile.ui.OprofileUiPlugin;
+import org.eclipse.linuxtools.oprofile.ui.model.IUiModelElement;
+import org.eclipse.linuxtools.oprofile.ui.model.UiModelEvent;
+
+/**
+ * Convenience class for creating the data model model from the oprofile chart,
+ */
+public class ChartModelRoot{
+       private ArrayList<IUiModelElement> list ;
+
+       public ChartModelRoot() {
+               list = new ArrayList<IUiModelElement>();
+       }
+       
+       public IUiModelElement[] getElements() {
+               return list.toArray(new IUiModelElement[list.size()]);
+       }
+       
+       public void addElement(IUiModelElement element){
+               double percentage = element.getPercentage();
+               if (percentage > OprofileUiPlugin.MINIMUM_CHART_PERCENTAGE)
+                       list.add(element);
+       }
+       
+       public void refreshModel(UiModelEvent event){
+//             IUiModelElement[] events = root.getChildren();
+//             if(events==null||events.length==0)
+//                     return;
+               
+               IUiModelElement[] sessions = event.getChildren();
+               if(sessions==null||sessions.length==0)
+                       return;
+               
+               IUiModelElement[] images = sessions[0].getChildren();
+               if(images==null||images.length==0)
+                       return;
+               
+               for(int i=0;i<images.length;i++){
+                       IUiModelElement element = images[i];
+                       addChartModel(element);
+               }
+               
+       }
+
+       private void addChartModel(IUiModelElement element) {
+               IUiModelElement[] symbols = element.getChildren();
+               if(symbols!=null){
+                       for(int j=0;j<symbols.length;j++){
+                               addElement(symbols[j]);
+                       }
+               }
+       }
+       
+       public int size(){
+               return list.size();
+       }
+       
+       public void clear(){
+               list.clear();
+       }
+
+       public String[] getCategorys(){
+               String[] categorys = new String[list.size()];  
+               for(int i=0;i<list.size();i++){
+                       categorys[i] = list.get(i).getName();
+               }
+               return categorys;
+       }
+
+       public double[] getValues(){
+               double[] values = new double[list.size()];  
+               for(int i=0;i<list.size();i++){
+                       double tmp = list.get(i).getPercentage();
+                       values[i] = OprofileUiPlugin.getDoubleFloor(tmp*100,2);
+               }
+               return values;
+       }
+}
diff --git a/org.eclipse.linuxtools.oprofile.ui/src/org/tizen/oprofile/ui/chart/PieChart.java b/org.eclipse.linuxtools.oprofile.ui/src/org/tizen/oprofile/ui/chart/PieChart.java
new file mode 100644 (file)
index 0000000..4f7809c
--- /dev/null
@@ -0,0 +1,114 @@
+/*
+ *  Pie Chart
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Jaewon Lim <jaewon81.lim@samsung.com>
+ * Wonhyoung Park <wonhyoung2.park@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.oprofile.ui.chart;
+
+import org.eclipse.birt.chart.model.Chart;
+import org.eclipse.birt.chart.model.ChartWithoutAxes;
+import org.eclipse.birt.chart.model.attribute.ChartDimension;
+import org.eclipse.birt.chart.model.component.Series;
+import org.eclipse.birt.chart.model.component.impl.SeriesImpl;
+import org.eclipse.birt.chart.model.data.BaseSampleData;
+import org.eclipse.birt.chart.model.data.DataFactory;
+import org.eclipse.birt.chart.model.data.NumberDataSet;
+import org.eclipse.birt.chart.model.data.OrthogonalSampleData;
+import org.eclipse.birt.chart.model.data.SampleData;
+import org.eclipse.birt.chart.model.data.SeriesDefinition;
+import org.eclipse.birt.chart.model.data.TextDataSet;
+import org.eclipse.birt.chart.model.data.impl.NumberDataSetImpl;
+import org.eclipse.birt.chart.model.data.impl.SeriesDefinitionImpl;
+import org.eclipse.birt.chart.model.data.impl.TextDataSetImpl;
+import org.eclipse.birt.chart.model.impl.ChartWithoutAxesImpl;
+import org.eclipse.birt.chart.model.type.PieSeries;
+import org.eclipse.birt.chart.model.type.impl.PieSeriesImpl;
+
+public class PieChart
+{
+
+       public static final Chart createPie(ChartModelRoot modelRoot)
+       {
+               ChartWithoutAxes cwoaPie = ChartWithoutAxesImpl.create( );
+               cwoaPie.setDimension( ChartDimension.TWO_DIMENSIONAL_WITH_DEPTH_LITERAL );
+               cwoaPie.setType( "Pie Chart" ); //$NON-NLS-1$   
+               cwoaPie.setSubType( "Standard Pie Chart" ); //$NON-NLS-1$
+               
+               // Plot
+               cwoaPie.setSeriesThickness( 10 );
+
+               // Legend
+               //jinu modified at 20090528
+               //Legend lg = cwoaPie.getLegend( );
+               //lg.getOutline( ).setVisible( true );
+
+               // Title
+               cwoaPie.getTitle( ).getLabel( ).getCaption( ).setValue( "Pie Chart for OProfile" );//$NON-NLS-1$
+
+               // Data Set
+               //jinu modified at 20090528
+               /*
+               TextDataSet categoryValues = TextDataSetImpl.create( new String[]{
+                               "slow_multiply[multiply.c]", "/lib/libc.so", "fast_multiply[multiply.c]", "/lib/ld.so", "main[multiply.c]"} );//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+               NumberDataSet seriesOneValues = NumberDataSetImpl.create( new double[]{
+                               89.94, 0.06, 5.75, 0.25, 4.00
+               } );
+               */
+               TextDataSet categoryValues = TextDataSetImpl.create(modelRoot.getCategorys()); 
+               NumberDataSet seriesOneValues = NumberDataSetImpl.create(modelRoot.getValues());
+               
+               SampleData sdata = DataFactory.eINSTANCE.createSampleData( );
+               
+               BaseSampleData sdBase = DataFactory.eINSTANCE.createBaseSampleData( );
+               sdBase.setDataSetRepresentation( "sdBase" );//$NON-NLS-1$
+               sdata.getBaseSampleData( ).add( sdBase );
+
+               OrthogonalSampleData sdOrthogonal = DataFactory.eINSTANCE.createOrthogonalSampleData( );
+               sdOrthogonal.setDataSetRepresentation( "sdOrthogonal" );//$NON-NLS-1$
+               sdOrthogonal.setSeriesDefinitionIndex( 0 );
+               sdata.getOrthogonalSampleData( ).add( sdOrthogonal );
+
+               cwoaPie.setSampleData( sdata );
+
+               // Base Series
+               Series seCategory = SeriesImpl.create( );
+               seCategory.setDataSet( categoryValues );
+
+               SeriesDefinition sd = SeriesDefinitionImpl.create( );
+               sd.getSeriesPalette( ).shift( 0 );
+               sd.getSeries( ).add( seCategory );
+               cwoaPie.getSeriesDefinitions( ).add( sd );
+
+               // Orthogonal Series
+               PieSeries sePie = (PieSeries) PieSeriesImpl.create( );
+               sePie.setDataSet( seriesOneValues );
+               sePie.setExplosion( 5 );
+               
+               //jinu modified at 20090528
+               //sePie.setSeriesIdentifier( "..." );//$NON-NLS-1$ 
+               
+               SeriesDefinition sdCity = SeriesDefinitionImpl.create( );
+               sdCity.getSeries( ).add( sePie );
+               sd.getSeriesDefinitions( ).add( sdCity );
+               
+
+               return cwoaPie;
+       }
+
+}
diff --git a/org.eclipse.linuxtools.oprofile.ui/src/org/tizen/oprofile/ui/editor/ChartEditor.java b/org.eclipse.linuxtools.oprofile.ui/src/org/tizen/oprofile/ui/editor/ChartEditor.java
new file mode 100644 (file)
index 0000000..ce9f884
--- /dev/null
@@ -0,0 +1,96 @@
+/*
+ *  Chart Editor
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Jaewon Lim <jaewon81.lim@samsung.com>
+ * Wonhyoung Park <wonhyoung2.park@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.oprofile.ui.editor;
+
+import org.eclipse.birt.chart.model.Chart;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.swt.SWT; 
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.part.EditorPart;
+
+import org.tizen.oprofile.ui.chart.ChartControl;
+import org.tizen.oprofile.ui.chart.ChartEditorInput;
+
+public class ChartEditor extends EditorPart {
+       protected ChartControl control;
+
+       @Override
+       public void doSave(IProgressMonitor monitor) {
+       }
+
+       @Override
+       public void doSaveAs() {
+       }
+
+       @Override
+       public void init(IEditorSite site, IEditorInput input)
+                       throws PartInitException {
+               if (input instanceof ChartEditorInput) {
+                       setInput(input);
+                       setSite(site);
+                       setPartName(input.getName()); //$NON-NLS-1$
+               }
+               else {
+                       throw new PartInitException(ChartEditorInput.class.getName()); //$NON-NLS-1$
+               }
+       }
+
+       @Override
+       public boolean isDirty() {
+               return false;
+       }
+
+       @Override
+       public boolean isSaveAsAllowed() {
+               return false;
+       }
+
+       @Override
+       public void createPartControl(Composite parent) {
+               Composite top = new Composite(parent, SWT.NONE);
+               top.setLayout(new GridLayout());
+               top.setLayoutData(new GridData(GridData.FILL_BOTH));
+               
+               ChartEditorInput input = (ChartEditorInput) getEditorInput();
+               Chart chart = input.getChart();
+               control = new ChartControl(top, chart);
+
+       }
+       
+       public void redraw(Chart chart) {
+               control.setChart(chart);
+               control.redraw();
+       }
+
+       @Override
+       public void setFocus() {
+               if (control != null) {
+                       control.setFocus();
+               }
+       }
+       
+
+}
diff --git a/org.eclipse.linuxtools.oprofile.ui/src/org/tizen/oprofile/ui/editor/OprofileEditor.java b/org.eclipse.linuxtools.oprofile.ui/src/org/tizen/oprofile/ui/editor/OprofileEditor.java
new file mode 100644 (file)
index 0000000..9ef40e6
--- /dev/null
@@ -0,0 +1,250 @@
+/*
+ *  Oprofile Editor
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Jaewon Lim <jaewon81.lim@samsung.com>
+ * Wonhyoung Park <wonhyoung2.park@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.oprofile.ui.editor;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.linuxtools.oprofile.core.model.OpModelRoot;
+import org.eclipse.linuxtools.oprofile.ui.model.UiModelRoot;
+import org.eclipse.linuxtools.oprofile.ui.view.OprofileViewContentProvider;
+import org.eclipse.linuxtools.oprofile.ui.view.OprofileViewDoubleClickListener;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Cursor;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeColumn;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.editors.text.TextEditor;
+import org.eclipse.ui.part.MultiPageEditorPart;
+import org.eclipse.ui.progress.UIJob;
+
+import org.tizen.oprofile.core.processor.modeldata.handler.OprofileSAXHandler;
+import org.tizen.oprofile.ui.view.OprofileViewLabelProvider;
+import org.xml.sax.SAXException;
+
+
+public class OprofileEditor extends MultiPageEditorPart {
+       private TreeViewer _viewer;
+       private TextEditor sourceEditor;
+
+       private String fileName;
+       private String filePath;
+       Cursor waitCursor;
+       
+       private void initialize(){
+               waitCursor = Display.getCurrent().getSystemCursor(SWT.CURSOR_WAIT);
+               fileName = getEditorInput().getName();
+               filePath = getEditorInput().getToolTipText();
+       }
+       
+       @Override
+       public void init(IEditorSite site, IEditorInput input)
+                       throws PartInitException {
+               super.init(site, input);
+               initialize();
+       }
+
+       @Override
+       public boolean isDirty() {
+               return false;
+       }
+       
+
+       @Override
+       public void createPages() {
+               createOprofilePage();
+               createSourcePage();
+               updateTitle();
+               
+               try {
+                       loadOprofileData();
+               } catch (InvocationTargetException e) {
+                       e.printStackTrace();
+               } catch (InterruptedException e) {
+                       e.printStackTrace();
+               }
+       }
+       
+       private void createOprofilePage(){
+               Composite parent = new Composite(getContainer(), SWT.NULL);
+               parent.setLayout(new FillLayout());
+               
+               createTable(parent);
+               
+               int index = addPage(parent);
+               setPageText(index, "Oprofile");
+       }
+       
+       private void createTable(Composite parent){
+               _viewer = new TreeViewer(parent, SWT.SINGLE|SWT.H_SCROLL|SWT.FULL_SELECTION);
+               
+               final Tree tree = _viewer.getTree();
+               tree.setHeaderVisible(true);
+               tree.setLinesVisible(true);
+               tree.setLayoutData(new GridData(GridData.FILL_BOTH));
+               
+               String[] columnNames = {"Type", "Percent(%)", "Name"};
+               int[] columnWidths = {250,100,100}; 
+               
+               final TreeColumn[] column = new TreeColumn[columnNames.length];
+               
+               for(int i=0;i<column.length;i++){
+                       column[i] = new TreeColumn(tree, SWT.LEFT);
+                       column[i].setText(columnNames[i]);
+                       column[i].setWidth(columnWidths[i]);
+               }
+               
+               final int targetColumnIdx = 1;
+               
+               tree.addListener(SWT.PaintItem, new Listener() {
+                       public void handleEvent(Event event) {
+                               if (event.index == targetColumnIdx) {
+                                       GC gc = event.gc;
+                                       
+                                       String text = ((TreeItem)(event.item)).getText(targetColumnIdx);
+                                       int percent = 0;
+                                       if( !(text==null||text.length()<=0||text.startsWith("<"))){
+                                               percent = (int)Double.parseDouble(text);
+                                       }
+                                       int width = column[targetColumnIdx].getWidth() * percent / 100;
+
+                                       if(width>5){
+                                               Display display = Display.getCurrent();
+                                               gc.setForeground(display.getSystemColor(SWT.COLOR_GREEN));
+                                               gc.setBackground(display.getSystemColor(SWT.COLOR_DARK_CYAN));
+                                               gc.fillGradientRectangle(event.x+40, event.y, width-5, event.height, true);     
+                                               
+                                               Rectangle rect = new Rectangle(event.x+40, event.y, width-5, event.height-1);
+                                               gc.drawRectangle(rect);
+                                               gc.setForeground(display.getSystemColor(SWT.COLOR_LIST_FOREGROUND));
+                                       }
+                                       
+//                                     Point size = 
+                                       gc.textExtent(text);                                    
+//                                     int offset = Math.max(0, (event.height - size.y) / 2);
+//                                     gc.drawText(text, event.x+2, event.y+offset, true);
+                               }
+                       }
+               });             
+               
+               _viewer.setContentProvider(new OprofileViewContentProvider());
+               _viewer.setLabelProvider(new OprofileViewLabelProvider());
+               _viewer.addDoubleClickListener(new OprofileViewDoubleClickListener());
+               getSite().setSelectionProvider(_viewer);
+       }
+       
+       private void createSourcePage(){
+               try{
+                       sourceEditor = new TextEditor();
+                       int index = addPage(sourceEditor, getEditorInput());
+                       setPageText(index, "Source");
+               }catch(PartInitException e)     {
+                       e.printStackTrace();
+               }
+       }
+       
+       private void updateTitle(){
+               setPartName(fileName);
+               setTitleToolTip(filePath);
+       }
+
+       private void loadOprofileData() throws InvocationTargetException, InterruptedException{
+               UiModelRoot uiModel = new UiModelRoot();
+               loadData(uiModel);
+               refreshView(uiModel);
+       }
+       
+       private void loadData(final UiModelRoot uiModel) throws InvocationTargetException, InterruptedException{
+               getSite().getWorkbenchWindow().run(false, false, new IRunnableWithProgress(){
+                       public void run(IProgressMonitor monitor) {
+                               monitor.beginTask("Load data", 100);
+                               
+                               OpModelRoot opModel = new OpModelRoot();
+                               try {
+                                       SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser();
+                                       saxParser.parse(new File(filePath),new OprofileSAXHandler(opModel));
+                               } catch (ParserConfigurationException e) {
+                                       e.printStackTrace();
+                               } catch (SAXException e) {
+                                       e.printStackTrace();
+                               } catch (IOException e) {
+                                       e.printStackTrace();
+                               }       
+                               
+                               monitor.worked(1);
+                               
+                               uiModel.refreshModel(opModel);
+                               
+                               monitor.worked(1);
+                               monitor.done();
+                       }
+               });
+       }
+       
+       public void refreshView(final UiModelRoot uiModel){
+               UIJob refreshView = new UIJob("Refresh View"){
+                       @Override
+                       public IStatus runInUIThread(IProgressMonitor monitor) {
+                               _viewer.getControl().setCursor(waitCursor);
+                               _viewer.setInput(uiModel);
+                               _viewer.refresh();
+                               _viewer.getControl().setCursor(null);
+                               return Status.OK_STATUS;
+                       }
+               };
+               refreshView.schedule();
+       }
+       
+       @Override
+       public void doSave(IProgressMonitor monitor) {
+       }
+
+       @Override
+       public void doSaveAs() {
+       }
+
+       @Override
+       public boolean isSaveAsAllowed() {
+               return false;
+       }
+}
diff --git a/org.eclipse.linuxtools.oprofile.ui/src/org/tizen/oprofile/ui/handler/OprofileDrawChartHandler.java b/org.eclipse.linuxtools.oprofile.ui/src/org/tizen/oprofile/ui/handler/OprofileDrawChartHandler.java
new file mode 100644 (file)
index 0000000..0cd615b
--- /dev/null
@@ -0,0 +1,119 @@
+/*
+ *  Oprofile Draw Chart Handler
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Jaewon Lim <jaewon81.lim@samsung.com>
+ * Wonhyoung Park <wonhyoung2.park@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.oprofile.ui.handler;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.linuxtools.oprofile.ui.model.IUiModelElement;
+import org.eclipse.linuxtools.oprofile.ui.model.UiModelEvent;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IEditorReference;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+import org.tizen.common.core.application.StatusLineMessageManager;
+import org.tizen.oprofile.ui.chart.ChartEditorInput;
+import org.tizen.oprofile.ui.chart.ChartModelRoot;
+import org.tizen.oprofile.ui.chart.PieChart;
+import org.tizen.oprofile.ui.editor.ChartEditor;
+
+public class OprofileDrawChartHandler extends AbstractHandler {
+       private IViewPart part;
+//     private Shell shell; 
+       private StatusLineMessageManager statusLine;
+//     private TreeViewer viewer;
+       private UiModelEvent uiModel;
+       private String editorId = "org.tizen.oprofile.ui.editor.ChartEditor";
+       
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+
+               part = (IViewPart) HandlerUtil.getActivePart(event);
+               statusLine = new StatusLineMessageManager(part);
+               
+               IStructuredSelection selection = (IStructuredSelection)HandlerUtil.getCurrentSelection(event);
+               
+               IUiModelElement element = (IUiModelElement)selection.getFirstElement();
+               if(element==null){
+                       statusLine.setErrorMessage("There is no selected event");
+                       return null;
+               }else{
+                       statusLine.setErrorMessage("");
+               }
+               
+               uiModel = findEvent(element);
+               if(uiModel.getChildren().length==0){
+                       statusLine.setErrorMessage("There is no selected event");
+                       return null;
+               }else{
+                       statusLine.setErrorMessage("");
+               }
+               
+               drawChart();
+               return null;
+       }
+
+       private UiModelEvent findEvent(IUiModelElement element) {
+               if(element instanceof UiModelEvent)
+                       return (UiModelEvent)element;
+               else 
+                       return findEvent(element.getParent());
+       }
+
+       private void drawChart() {
+               Display.getDefault().syncExec(new Runnable() {
+                       public void run() {
+                               try {
+                                       ChartModelRoot chartModel = new ChartModelRoot();
+                                       chartModel.refreshModel(uiModel);
+                                       
+                                       openEditor(chartModel);
+                               } catch (PartInitException e) {
+                                       e.printStackTrace();
+                               }
+                       }
+               });
+       }
+       
+       public void openEditor(ChartModelRoot chartModel) throws PartInitException{
+               IWorkbenchPage page = PlatformUI.getWorkbench()
+               .getActiveWorkbenchWindow().getActivePage();
+               
+               IEditorReference[] editors = page.getEditorReferences();
+               
+               for(int i=0;i<editors.length;i++){
+                       IEditorPart editor = editors[i].getEditor(true);
+                       if(editor instanceof ChartEditor){
+                               ((ChartEditor)editor).redraw(PieChart.createPie(chartModel));
+                               page.activate(editor);
+                               return;
+                       }
+               }
+               
+               ChartEditorInput chartInput = new ChartEditorInput(PieChart.createPie(chartModel), "Chart");
+               page.openEditor(chartInput, editorId);
+       } 
+}
diff --git a/org.eclipse.linuxtools.oprofile.ui/src/org/tizen/oprofile/ui/handler/OprofileOpenDaemonLogHandler.java b/org.eclipse.linuxtools.oprofile.ui/src/org/tizen/oprofile/ui/handler/OprofileOpenDaemonLogHandler.java
new file mode 100644 (file)
index 0000000..b30cf67
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ *  Oprofile Open Deamon Log Handler
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Jaewon Lim <jaewon81.lim@samsung.com>
+ * Wonhyoung Park <wonhyoung2.park@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.oprofile.ui.handler;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.linuxtools.profiling.ui.ProfileUIUtils;
+import org.eclipse.ui.PartInitException;
+
+import org.tizen.oprofile.core.OprofileCommonConstants;
+
+public class OprofileOpenDaemonLogHandler extends AbstractHandler {
+
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+               resetSession();
+               return null;
+       }
+
+       private void resetSession() {
+               try {
+                       ProfileUIUtils.openEditorAndSelect(OprofileCommonConstants.LOG_DAEMON, 0);
+               } catch (PartInitException e) {
+                       e.printStackTrace();
+               } catch (BadLocationException e) {
+                       e.printStackTrace();
+               }
+       }
+}
diff --git a/org.eclipse.linuxtools.oprofile.ui/src/org/tizen/oprofile/ui/handler/OprofileRefreshViewHandler.java b/org.eclipse.linuxtools.oprofile.ui/src/org/tizen/oprofile/ui/handler/OprofileRefreshViewHandler.java
new file mode 100644 (file)
index 0000000..92638f0
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ *  Oprofile Refresh Voew Handler
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Jaewon Lim <jaewon81.lim@samsung.com>
+ * Wonhyoung Park <wonhyoung2.park@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.oprofile.ui.handler;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.linuxtools.oprofile.ui.view.OprofileView;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+public class OprofileRefreshViewHandler extends AbstractHandler {
+       private IViewPart part;
+//     private Shell shell;
+
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+
+               part = (IViewPart) HandlerUtil.getActivePart(event);
+               
+               refreshView();
+               return null;
+       }
+
+       private void refreshView() {
+               ((OprofileView)part).refreshView();
+       }
+}
diff --git a/org.eclipse.linuxtools.oprofile.ui/src/org/tizen/oprofile/ui/handler/OprofileResetHandler.java b/org.eclipse.linuxtools.oprofile.ui/src/org/tizen/oprofile/ui/handler/OprofileResetHandler.java
new file mode 100644 (file)
index 0000000..8fb4fb5
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ *  Oprofile Reset Handler
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Jaewon Lim <jaewon81.lim@samsung.com>
+ * Wonhyoung Park <wonhyoung2.park@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.oprofile.ui.handler;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.linuxtools.oprofile.core.OpcontrolException;
+import org.eclipse.linuxtools.oprofile.core.OprofileCorePlugin;
+import org.eclipse.linuxtools.oprofile.ui.view.OprofileView;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+public class OprofileResetHandler extends AbstractHandler {
+       private IViewPart part;
+//     private Shell shell;
+
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+
+               part = (IViewPart) HandlerUtil.getActivePart(event);
+               
+               resetSession();
+               return null;
+       }
+
+       private void resetSession() {
+               try {
+                       OprofileCorePlugin.getDefault().getOpcontrolProvider().reset();
+                       ((OprofileView)part).refreshView();
+               } catch (OpcontrolException e) {
+                       OprofileCorePlugin.showErrorDialog("opcontrolProvider", e);
+               }
+       }
+}
diff --git a/org.eclipse.linuxtools.oprofile.ui/src/org/tizen/oprofile/ui/handler/OprofileSaveFileHandler.java b/org.eclipse.linuxtools.oprofile.ui/src/org/tizen/oprofile/ui/handler/OprofileSaveFileHandler.java
new file mode 100644 (file)
index 0000000..44ce316
--- /dev/null
@@ -0,0 +1,140 @@
+/*
+ *  Oprofile Save File Handler
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Jaewon Lim <jaewon81.lim@samsung.com>
+ * Wonhyoung Park <wonhyoung2.park@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.oprofile.ui.handler;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.linuxtools.oprofile.ui.model.UiModelRoot;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+import org.tizen.common.core.application.StatusLineMessageManager;
+import org.tizen.common.util.DialogUtil;
+
+public class OprofileSaveFileHandler extends AbstractHandler {
+       private IViewPart part;
+       private TreeViewer viewer;
+       private String fileName;
+       private Shell shell;
+       private StatusLineMessageManager statusLine;
+       private UiModelRoot uiModel;
+       
+       private final String title = "Save File";
+       private final String PARAMETER_ID = "org.tizen.oprofile.command.saveFile.parameter";
+
+
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+
+               part = (IViewPart)HandlerUtil.getActivePart(event);
+               shell = part.getSite().getShell();
+               statusLine = new StatusLineMessageManager(part);
+               
+               viewer = (TreeViewer)part.getSite().getSelectionProvider();
+               uiModel = (UiModelRoot)viewer.getInput();
+               
+               String extension = event.getParameter(PARAMETER_ID);
+               
+               if(uiModel==null||!uiModel.hasChildren()){
+                       statusLine.setErrorMessage("There is no data");
+                       return null;
+               }else{
+                       statusLine.setErrorMessage("");
+               }
+               
+               try {
+                       saveFile(extension);
+               } catch (InvocationTargetException e) {
+                       e.printStackTrace();
+               } catch (InterruptedException e) {
+                       e.printStackTrace();
+               }
+
+               return null;
+       }
+
+       private void saveFile(String extension) throws InvocationTargetException, InterruptedException {
+               fileName = getSaveFileName(extension);
+               
+               if(fileName==null)
+                       return;
+               
+               if(!fileName.endsWith("."+extension))
+                       fileName= fileName+"."+extension;
+               
+               if(!(new File(fileName).getParentFile().canWrite())){
+                       DialogUtil.openErrorDialog("You can store a file into the direcotry that has write permission. please select another directory");
+                       return;
+               }
+               
+               part.getSite().getWorkbenchWindow().run(false, false, new IRunnableWithProgress(){
+                       public void run(IProgressMonitor monitor) {
+                               monitor.beginTask("Save File", 100);
+                               writeData();
+                               monitor.done();
+                       }
+               });
+               
+       }
+
+       private String getSaveFileName(String extension) {
+               String[] extFilter = {"*."+extension,"*.*"};
+               
+               FileDialog dialog = new FileDialog(shell, SWT.SAVE);
+               dialog.setFilterExtensions(extFilter);
+               dialog.setText(title);
+               dialog.setOverwrite(true);
+               dialog.setFilterPath(System.getProperty("user.home"));
+               dialog.setFileName("untitled."+extension);
+               return dialog.open();
+       }
+       
+       private void writeData() {
+               FileWriter writer = null;
+               
+               try {
+                       writer = new FileWriter(fileName);
+                       writer.write(uiModel.getXML());
+               }catch (IOException e) {
+                       e.printStackTrace();
+               }finally{
+                       try {
+                               if (writer != null)
+                                       writer.close();
+                       } catch (IOException e) {
+                               e.printStackTrace();
+                       }
+               }
+       }
+       
+}
+
diff --git a/org.eclipse.linuxtools.oprofile.ui/src/org/tizen/oprofile/ui/view/OprofileViewDoubleClickListener.java b/org.eclipse.linuxtools.oprofile.ui/src/org/tizen/oprofile/ui/view/OprofileViewDoubleClickListener.java
new file mode 100644 (file)
index 0000000..21a2fca
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+ * Oprofile View Double Click Listener 
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Jaewon Lim <jaewon81.lim@samsung.com>
+ * Wonhyoung Park <wonhyoung2.park@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.oprofile.ui.view;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.TreeSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.linuxtools.oprofile.ui.model.IUiModelElement;
+import org.eclipse.linuxtools.oprofile.ui.model.UiModelEvent;
+import org.eclipse.linuxtools.oprofile.ui.model.UiModelImage;
+import org.eclipse.linuxtools.oprofile.ui.model.UiModelSample;
+import org.eclipse.linuxtools.oprofile.ui.model.UiModelSession;
+import org.eclipse.linuxtools.oprofile.ui.model.UiModelSymbol;
+import org.eclipse.linuxtools.profiling.ui.ProfileUIUtils;
+import org.eclipse.ui.PartInitException;
+
+/**
+ * Listener for the oprofile view when a user double clicks on an element in the tree.
+ * 
+ * Different things occur based on the event:
+ *   
+ *   UiModelEvent              - nothing (?)
+ *   UiModelSession    - save the session to a different name
+ *   UiModelImage              - nothing (?)
+ *   UiModelSymbol             - nothing (?)
+ *   UiModelSample             - go to line number in appropriate file
+ */
+public class OprofileViewDoubleClickListener implements IDoubleClickListener {
+       public void doubleClick(DoubleClickEvent event) {
+               IUiModelElement element = (IUiModelElement)((TreeSelection)((TreeViewer)event.getSource()).getSelection()).getFirstElement();
+/*
+               if (element instanceof UiModelEvent) {
+//                     UiModelEvent event = (UiModelEvent)element;
+
+               } else if (element instanceof UiModelSession) {
+                       // moved into an action menu
+               } else if (element instanceof UiModelImage) {
+//                     UiModelImage image = (UiModelImage)element;
+       
+               } else if (element instanceof UiModelSymbol) {
+                       // disable this.. for binary section such as .plt, 
+                       // this will open the binary in an editor = bad 
+
+                       //jump to 1st line in the file
+//                     UiModelSymbol symbol = (UiModelSymbol)element;
+//                     String fileName = symbol.getFileName();
+//                     
+//                     if (fileName.length() > 0) {
+//                             try {
+//                                     ProfileUIUtils.openEditorAndSelect(fileName, 1);
+//                             } catch (PartInitException e) {
+//                                     e.printStackTrace();
+//                             } catch (BadLocationException e) {
+//                                     e.printStackTrace();
+//                             }
+//                     }
+               } else
+*/             
+               if (element instanceof UiModelSample) {
+                       //jump to line number in the appropriate file
+                       UiModelSample sample = (UiModelSample)element;
+                       int line = sample.getLine();
+                       
+                       //get file name from the parent sample 
+                       String fileName = ((UiModelSymbol)sample.getParent()).getFileName();
+                       //jinu added at 20090602
+                       //fixed for sb2
+                       //String strpath = ScratchboxTargetControl.getHostpathFromSboxpath(fileName);
+                       String strpath = fileName;
+                       
+                       try {
+                               //jinu modified at 20090602
+                               //ProfileUIUtils.openEditorAndSelect(fileName, line);
+                               ProfileUIUtils.openEditorAndSelect(strpath, line);
+                       } catch (PartInitException e) {
+                               e.printStackTrace();
+                       } catch (BadLocationException e) {
+                               e.printStackTrace();
+                       }
+               }
+       }
+}
diff --git a/org.eclipse.linuxtools.oprofile.ui/src/org/tizen/oprofile/ui/view/OprofileViewLabelProvider.java b/org.eclipse.linuxtools.oprofile.ui/src/org/tizen/oprofile/ui/view/OprofileViewLabelProvider.java
new file mode 100644 (file)
index 0000000..4c7a568
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ *  Oprofile View Label Provider
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Jaewon Lim <jaewon81.lim@samsung.com>
+ * Wonhyoung Park <wonhyoung2.park@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.oprofile.ui.view;
+
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.linuxtools.oprofile.ui.OprofileUiPlugin;
+import org.eclipse.linuxtools.oprofile.ui.model.IUiModelElement;
+import org.eclipse.linuxtools.oprofile.ui.model.UiModelDependent;
+import org.eclipse.linuxtools.oprofile.ui.model.UiModelImage;
+import org.eclipse.linuxtools.oprofile.ui.model.UiModelSample;
+import org.eclipse.linuxtools.oprofile.ui.model.UiModelSymbol;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * Content provider for OprofileView's tree viewer.
+ */
+public class OprofileViewLabelProvider extends LabelProvider implements ITableLabelProvider {
+
+       public Image getColumnImage(Object element, int columnIndex) {
+               if(columnIndex==0){
+                       return ((IUiModelElement) element).getLabelImage();
+               }
+               
+               return null;
+       }
+
+       public String getColumnText(Object element, int columnIndex) {
+               IUiModelElement modelElement = (IUiModelElement) element;
+               
+               if(columnIndex==0){
+                       if(modelElement instanceof UiModelDependent){
+                               return "dependent library";
+                       }else if(modelElement instanceof UiModelImage){
+                               return "module";
+                       }else if(modelElement instanceof UiModelSymbol){
+                               return "symbol";
+                       }else if(modelElement instanceof UiModelSample){
+                               return "detailed code";
+                       }else{
+                               return modelElement.getLabelText();
+                       }
+               }else if(columnIndex==1){
+                       double value = modelElement.getPercentage();
+                       return value<0?null:OprofileUiPlugin.getPercentage(value);
+               }else   if(columnIndex==2){
+                       return modelElement.getName();
+               }
+               
+               return null;
+       }
+
+}
diff --git a/org.eclipse.linuxtools.profiling.launch/.classpath b/org.eclipse.linuxtools.profiling.launch/.classpath
new file mode 100644 (file)
index 0000000..ad32c83
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+       <classpathentry kind="src" path="src"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.eclipse.linuxtools.profiling.launch/.project b/org.eclipse.linuxtools.profiling.launch/.project
new file mode 100644 (file)
index 0000000..539406b
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.eclipse.linuxtools.profiling.launch</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.ManifestBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.SchemaBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.pde.PluginNature</nature>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>
diff --git a/org.eclipse.linuxtools.profiling.launch/.settings/org.eclipse.core.resources.prefs b/org.eclipse.linuxtools.profiling.launch/.settings/org.eclipse.core.resources.prefs
new file mode 100644 (file)
index 0000000..b36707a
--- /dev/null
@@ -0,0 +1,3 @@
+#Wed Dec 01 09:13:30 CET 2010
+eclipse.preferences.version=1
+encoding/<project>=UTF-8
diff --git a/org.eclipse.linuxtools.profiling.launch/.settings/org.eclipse.core.runtime.prefs b/org.eclipse.linuxtools.profiling.launch/.settings/org.eclipse.core.runtime.prefs
new file mode 100644 (file)
index 0000000..52ac048
--- /dev/null
@@ -0,0 +1,3 @@
+#Tue Dec 14 16:36:39 CET 2010
+eclipse.preferences.version=1
+line.separator=\n
diff --git a/org.eclipse.linuxtools.profiling.launch/META-INF/MANIFEST.MF b/org.eclipse.linuxtools.profiling.launch/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..00521f3
--- /dev/null
@@ -0,0 +1,26 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Tizen SDK Profiling Launch
+Bundle-SymbolicName: org.eclipse.linuxtools.profiling.launch;singleton:=true
+Bundle-Version: 1.3.18.qualifier
+Bundle-Activator: org.eclipse.linuxtools.profiling.launch.ProfileLaunchPlugin
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.tizen.common,
+ org.tizen.common.connection
+Bundle-ActivationPolicy: lazy
+Import-Package: org.eclipse.cdt.core.model,
+ org.eclipse.cdt.debug.core,
+ org.eclipse.cdt.launch,
+ org.eclipse.cdt.launch.ui,
+ org.eclipse.cdt.managedbuilder.core,
+ org.eclipse.cdt.ui,
+ org.eclipse.core.resources,
+ org.eclipse.debug.core,
+ org.eclipse.debug.ui,
+ org.eclipse.debug.ui.sourcelookup,
+ org.tizen.sdblib
+Export-Package: org.eclipse.linuxtools.profiling.launch
+Bundle-Localization: plugin
+Bundle-Vendor: Eclipse Linux Tools
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
diff --git a/org.eclipse.linuxtools.profiling.launch/META-INF/eclipse.inf b/org.eclipse.linuxtools.profiling.launch/META-INF/eclipse.inf
new file mode 100644 (file)
index 0000000..92ffed2
--- /dev/null
@@ -0,0 +1,2 @@
+#Processed using Jarprocessor
+pack200.conditioned = true
diff --git a/org.eclipse.linuxtools.profiling.launch/NOTICE b/org.eclipse.linuxtools.profiling.launch/NOTICE
new file mode 100644 (file)
index 0000000..0212f4b
--- /dev/null
@@ -0,0 +1,13 @@
+2010-02-10 SPRC SDK Team <d.kozinski@samsung.com>
+       * .classpath : change java version
+       * org.eclipse.jdt.core.prefs : remove file
+       * ProfileLaunchShortcut.java : commented some member, remove some import
+       
+2010-11-05 sdk <sdk@sdk-laptop.(none)>
+       * MANIFEST.MF : changed some package name
+
+2011-06-09 jaewon81.lim <jaewon81.lim@samsung.com>
+       * MANIFEST.MF : rearrange plugins dependency
+
+2011-11-30 wonhyoung2.park <wonhyoung2.park@samsung.com>
+       * MANIFEST.MF : provider and plugin name modify
diff --git a/org.eclipse.linuxtools.profiling.launch/about.html b/org.eclipse.linuxtools.profiling.launch/about.html
new file mode 100644 (file)
index 0000000..e6a2741
--- /dev/null
@@ -0,0 +1,26 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"><head>
+
+
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>About</title>
+</head><body lang="EN-US">
+<h2>About This Content</h2>
+<p>October 24, 2008</p>        
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in ("Content").  Unless otherwise 
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 ("EPL").  A copy of the EPL is available 
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, "Program" will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is 
+being redistributed by another party ("Redistributor") and different terms and conditions may
+apply to your use of any object code in the Content.  Check the Redistributor's license that was 
+provided with the Content.  If no such license exists, contact the Redistributor.  Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body></html>
\ No newline at end of file
diff --git a/org.eclipse.linuxtools.profiling.launch/build.properties b/org.eclipse.linuxtools.profiling.launch/build.properties
new file mode 100644 (file)
index 0000000..137629f
--- /dev/null
@@ -0,0 +1,8 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               .,\
+               plugin.properties,\
+               about.html
+javacSource = 1.6
+javacTarget = 1.6
diff --git a/org.eclipse.linuxtools.profiling.launch/plugin.properties b/org.eclipse.linuxtools.profiling.launch/plugin.properties
new file mode 100644 (file)
index 0000000..cf239fe
--- /dev/null
@@ -0,0 +1,3 @@
+#Properties file for org.eclipse.linuxtools.profiling.launch
+Bundle-Vendor.0 = Eclipse.org
+Bundle-Name.0 = Profiling Launch Plug-in (Incubation)
\ No newline at end of file
diff --git a/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/Messages.java b/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/Messages.java
new file mode 100644 (file)
index 0000000..9b3604c
--- /dev/null
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Elliott Baron <ebaron@redhat.com> - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.profiling.launch;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class Messages {
+       private static final String BUNDLE_NAME = "org.eclipse.linuxtools.profiling.launch.messages"; //$NON-NLS-1$
+
+       private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
+                       .getBundle(BUNDLE_NAME);
+
+       private Messages() {
+       }
+
+       public static String getString(String key) {
+               try {
+                       return RESOURCE_BUNDLE.getString(key);
+               } catch (MissingResourceException e) {
+                       return '!' + key + '!';
+               }
+       }
+}
diff --git a/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/ProfileLaunchConfigurationTabGroup.java b/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/ProfileLaunchConfigurationTabGroup.java
new file mode 100644 (file)
index 0000000..bf117d1
--- /dev/null
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Elliott Baron <ebaron@redhat.com> - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.profiling.launch;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+
+import org.eclipse.cdt.launch.ui.CArgumentsTab;
+import org.eclipse.cdt.launch.ui.CMainTab;
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
+import org.eclipse.debug.ui.CommonTab;
+import org.eclipse.debug.ui.EnvironmentTab;
+import org.eclipse.debug.ui.ILaunchConfigurationDialog;
+import org.eclipse.debug.ui.sourcelookup.SourceLookupTab;
+
+public abstract class ProfileLaunchConfigurationTabGroup extends AbstractLaunchConfigurationTabGroup {
+
+       public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
+               ArrayList<AbstractLaunchConfigurationTab> tabs = new ArrayList<AbstractLaunchConfigurationTab>();
+               tabs.add(new CMainTab());
+               tabs.add(new CArgumentsTab());
+               
+               tabs.addAll(Arrays.asList(getProfileTabs()));
+               
+               tabs.add(new EnvironmentTab());
+               tabs.add(new SourceLookupTab());
+               tabs.add(new CommonTab());
+               
+               setTabs(tabs.toArray(new AbstractLaunchConfigurationTab[tabs.size()]));
+       }
+       
+       public abstract AbstractLaunchConfigurationTab[] getProfileTabs();
+
+}
\ No newline at end of file
diff --git a/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/ProfileLaunchPlugin.java b/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/ProfileLaunchPlugin.java
new file mode 100644 (file)
index 0000000..d3c92e9
--- /dev/null
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Elliott Baron <ebaron@redhat.com> - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.profiling.launch;
+
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+import org.tizen.common.connection.ConnectionPlugin;
+import org.tizen.sdblib.IDevice;
+
+
+public class ProfileLaunchPlugin extends AbstractUIPlugin {
+
+       // The plug-in ID
+       public static final String PLUGIN_ID = "org.eclipse.linuxtools.profiling.launch"; //$NON-NLS-1$
+
+       // The shared instance
+       private static ProfileLaunchPlugin plugin;
+       
+       /**
+        * The constructor
+        */
+       public ProfileLaunchPlugin() {
+       }
+
+       /*
+        * (non-Javadoc)
+        * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+        */
+       public void start(BundleContext context) throws Exception {
+               super.start(context);
+               plugin = this;
+       }
+
+       /*
+        * (non-Javadoc)
+        * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+        */
+       public void stop(BundleContext context) throws Exception {
+               plugin = null;
+               super.stop(context);
+       }
+
+       /**
+        * Returns the shared instance
+        *
+        * @return the shared instance
+        */
+       public static ProfileLaunchPlugin getDefault() {
+               return plugin;
+       }
+
+       public static Shell getActiveWorkbenchShell() {
+               return getDefault().getWorkbench().getActiveWorkbenchWindow().getShell();
+       }
+
+       // added by Jaewon Lim at 20120904
+       // return 0 if no device is connected
+       // return 1 if current device is real target
+       // return 2 if current device is emulator
+       public static int checkTarget() {
+               IDevice device = ConnectionPlugin.getDefault().getCurrentDevice();
+               if(device == null)
+               {
+                       return 0;
+               }
+               else
+               {
+                        if(device.isEmulator())
+                                return 2;
+                        else
+                                return 1;
+               }
+       }
+
+}
diff --git a/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/ProfileLaunchShortcut.java b/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/ProfileLaunchShortcut.java
new file mode 100644 (file)
index 0000000..7bdef3a
--- /dev/null
@@ -0,0 +1,336 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ * Ken Ryall (Nokia) - bug 178731
+ * Elliott Baron <ebaron@redhat.com> - Modified implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.profiling.launch;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.IBinary;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
+import org.eclipse.cdt.launch.AbstractCLaunchDelegate;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.ui.CElementLabelProvider;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.debug.ui.IDebugModelPresentation;
+import org.eclipse.debug.ui.ILaunchShortcut;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.dialogs.ElementListSelectionDialog;
+import org.eclipse.ui.dialogs.TwoPaneElementSelector;
+
+
+public abstract class ProfileLaunchShortcut implements ILaunchShortcut {
+
+//     private boolean canInitialize; //bery 20090715
+       
+       public void launch(IEditorPart editor, String mode) {
+               
+               searchAndLaunch(new Object[] { editor.getEditorInput() }, mode);
+       }
+
+       public void launch(ISelection selection, String mode) {
+       
+               if (selection instanceof IStructuredSelection) {
+                       searchAndLaunch(((IStructuredSelection) selection).toArray(), mode);
+               }
+       }
+
+       public void launch(IBinary bin, String mode) {
+//             ITargetControl tc = ScratchboxPlugin.getTargetControl();
+               
+/*
+               if(tc.isSimulator()){
+                       canInitialize = true;
+               }else{
+                       String error = "The Valgrind does not support the ARM target ";
+                       String reason = "An error occurred when the real target is selected. Please check whether your target is Simulator(i686)";
+                       showErrorDialog(error, reason , null); //$NON-NLS-1$
+                       canInitialize = false;
+       //              return;
+               }
+*/
+               ILaunchConfiguration config = findLaunchConfiguration(bin, mode);
+               if (config != null) {
+                       DebugUITools.launch(config, mode);
+               }
+       }
+
+public static void showErrorDialog(final String errorMessage, final String reasonMessage, final Exception ex) {
+               
+               final String dialogTitle = "Valgrind Error";
+               final String toolname = Messages.getString("ProfileLaunchShortcut.targetcheck");
+               final IStatus status = new Status(IStatus.ERROR, toolname, IStatus.OK, reasonMessage, ex);
+               
+               Display.getDefault().syncExec(new Runnable() {
+                       public void run() {
+                               ErrorDialog.openError(null, dialogTitle, errorMessage, status);
+                       }
+               });
+
+       }
+
+       /**
+        * Locate a configuration to relaunch for the given type.  If one cannot be found, create one.
+        * 
+        * @return a re-useable config or <code>null</code> if none
+        */
+       protected ILaunchConfiguration findLaunchConfiguration(IBinary bin, String mode) {
+               ILaunchConfiguration configuration = null;
+               ILaunchConfigurationType configType = getLaunchConfigType();
+               List<ILaunchConfiguration> candidateConfigs = Collections.emptyList();
+               try {
+                       ILaunchConfiguration[] configs = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurations(configType);
+                       candidateConfigs = new ArrayList<ILaunchConfiguration>(configs.length);
+                       for (int i = 0; i < configs.length; i++) {
+                               ILaunchConfiguration config = configs[i];
+                               IPath programPath = AbstractCLaunchDelegate.getProgramPath(config);
+                               String projectName = AbstractCLaunchDelegate.getProjectName(config);
+                               IPath binPath = bin.getResource().getProjectRelativePath();
+                               if (programPath != null && programPath.equals(binPath)) {
+                                       if (projectName != null && projectName.equals(bin.getCProject().getProject().getName())) {
+                                               candidateConfigs.add(config);
+                                       }
+                               }
+                       }
+               } catch (CoreException e) {
+                       e.printStackTrace();
+               }
+       
+               // If there are no existing configs associated with the IBinary, create one.
+               // If there is exactly one config associated with the IBinary, return it.
+               // Otherwise, if there is more than one config associated with the IBinary, prompt the
+               // user to choose one.
+               int candidateCount = candidateConfigs.size();
+               if (candidateCount < 1) {
+                       configuration = createConfiguration(bin);
+               } else if (candidateCount == 1) {
+                       configuration = (ILaunchConfiguration) candidateConfigs.get(0);
+               } else {
+                       // Prompt the user to choose a config.  A null result means the user
+                       // cancelled the dialog, in which case this method returns null,
+                       // since cancelling the dialog should also cancel launching anything.
+                       configuration = chooseConfiguration(candidateConfigs, mode);
+               }
+               return configuration;
+       }
+
+       protected abstract ILaunchConfigurationType getLaunchConfigType();
+       
+       protected abstract void setDefaultProfileAttributes(ILaunchConfigurationWorkingCopy wc) throws CoreException;
+
+       protected ILaunchConfiguration createConfiguration(IBinary bin) {
+               ILaunchConfiguration config = null;
+               try {
+                       String projectName = bin.getResource().getProjectRelativePath().toString();
+                       ILaunchConfigurationType configType = getLaunchConfigType();
+                       ILaunchConfigurationWorkingCopy wc = configType.newInstance(null, getLaunchManager().generateUniqueLaunchConfigurationNameFrom(bin.getElementName()));
+       
+                       wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, projectName);
+                       wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, bin.getCProject().getElementName());
+                       wc.setMappedResources(new IResource[] {bin.getResource(), bin.getResource().getProject()});
+                       wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String) null);
+       
+                       setDefaultProfileAttributes(wc);
+       
+                       config = wc.doSave();
+               } catch (CoreException e) {
+                       e.printStackTrace();
+               }
+               return config;
+       }
+
+       protected ILaunchManager getLaunchManager() {
+               return DebugPlugin.getDefault().getLaunchManager();
+       }
+
+       /**
+        * Method searchAndLaunch.
+        * @param objects
+        * @param mode
+        */
+       private void searchAndLaunch(final Object[] elements, String mode) {
+               if (elements != null && elements.length > 0) {
+                       IBinary bin = null;
+                       if (elements.length == 1 && elements[0] instanceof IBinary) {
+                               bin = (IBinary) elements[0];
+                       } else {
+                               final List<IBinary> results = new ArrayList<IBinary>();
+                               ProgressMonitorDialog dialog = new ProgressMonitorDialog(getActiveWorkbenchShell());
+                               IRunnableWithProgress runnable = new IRunnableWithProgress() {
+                                       public void run(IProgressMonitor pm) throws InterruptedException {
+                                               int nElements = elements.length;
+                                               pm.beginTask(Messages.getString("ProfileLaunchShortcut.Looking_for_executables"), nElements); //$NON-NLS-1$
+                                               try {
+                                                       IProgressMonitor sub = new SubProgressMonitor(pm, 1);
+                                                       for (int i = 0; i < nElements; i++) {
+                                                               if (elements[i] instanceof IAdaptable) {
+                                                                       IResource r = (IResource) ((IAdaptable) elements[i]).getAdapter(IResource.class);
+                                                                       if (r != null) {
+                                                                               ICProject cproject = CoreModel.getDefault().create(r.getProject());
+                                                                               if (cproject != null) {
+                                                                                       try {
+                                                                                               IBinary[] bins = cproject.getBinaryContainer().getBinaries();
+                                                                                               IConfiguration config = ManagedBuildManager.getBuildInfo(r.getProject()).getDefaultConfiguration();
+                                                                                               String activeBuildConfiguration = config.toString();
+       
+                                                                                               for (int j = 0; j < bins.length; j++) {
+                                                                                                       if (bins[j].isExecutable() || bins[j].isSharedLib()) {
+                                                                                                               String parentDirName = bins[j].getPath().removeLastSegments(1).lastSegment();
+                                                                                                               if (parentDirName.equals(activeBuildConfiguration))
+                                                                                                                       results.add(bins[j]);
+                                                                                                       }
+                                                                                               }
+                                                                                       } catch (CModelException e) {
+                                                                                               e.printStackTrace();
+                                                                                       }
+                                                                               }
+                                                                       }
+                                                               }
+                                                               if (pm.isCanceled()) {
+                                                                       throw new InterruptedException();
+                                                               }
+                                                               sub.done();
+                                                       }
+                                               } finally {
+                                                       pm.done();
+                                               }
+                                       }
+                               };
+                               try {
+                                       dialog.run(true, true, runnable);
+                               } catch (InterruptedException e) {
+                                       return;
+                               } catch (InvocationTargetException e) {
+                                       handleFail(e.getMessage());
+                                       return;
+                               }
+                               int count = results.size();
+                               if (count == 0) {                                       
+                                       handleFail(Messages.getString("ProfileLaunchShortcut.Binary_not_found")); //$NON-NLS-1$
+                               } else if (count > 1) {
+                                       bin = chooseBinary(results, mode);
+                               } else {
+                                       bin = (IBinary)results.get(0);
+                               }
+                       }
+                       if (bin != null) {
+                               launch(bin, mode);
+                       }
+               } else {
+                       handleFail(Messages.getString("ProfileLaunchShortcut.no_project_selected")); //$NON-NLS-1$
+               }
+       }
+
+       protected void handleFail(String message) {
+               MessageDialog.openError(getActiveWorkbenchShell(), Messages.getString("ProfileLaunchShortcut.Valgrind_Launcher"), message); //$NON-NLS-1$
+       }
+
+       /**
+        * Prompts the user to select a  binary
+        * 
+        * @return the selected binary or <code>null</code> if none.
+        */
+       protected IBinary chooseBinary(List<IBinary> binList, String mode) {
+               ILabelProvider programLabelProvider = new CElementLabelProvider() {
+                       public String getText(Object element) {
+                               if (element instanceof IBinary) {
+                                       IBinary bin = (IBinary)element;
+                                       StringBuffer name = new StringBuffer();
+                                       name.append(bin.getPath().lastSegment());
+                                       return name.toString();
+                               }
+                               return super.getText(element);
+                       }
+               };
+       
+               ILabelProvider qualifierLabelProvider = new CElementLabelProvider() {
+                       public String getText(Object element) {
+                               if (element instanceof IBinary) {
+                                       IBinary bin = (IBinary)element;
+                                       StringBuffer name = new StringBuffer();
+                                       name.append(bin.getCPU() + (bin.isLittleEndian() ? "le" : "be")); //$NON-NLS-1$ //$NON-NLS-2$
+                                       name.append(" - "); //$NON-NLS-1$
+                                       name.append(bin.getPath().toString());
+                                       return name.toString();
+                               }
+                               return super.getText(element);
+                       }
+               };
+       
+               TwoPaneElementSelector dialog = new TwoPaneElementSelector(getActiveWorkbenchShell(), programLabelProvider, qualifierLabelProvider);
+               dialog.setElements(binList.toArray());
+               dialog.setTitle(Messages.getString("ProfileLaunchShortcut.Profile_With_Valgrind")); //$NON-NLS-1$
+               dialog.setMessage(Messages.getString("ProfileLaunchShortcut.Choose_a_local_application")); //$NON-NLS-1$
+               dialog.setUpperListLabel(Messages.getString("ProfileLaunchShortcut.Binaries")); //$NON-NLS-1$
+               dialog.setLowerListLabel(Messages.getString("ProfileLaunchShortcut.Qualifier")); //$NON-NLS-1$
+               dialog.setMultipleSelection(false);
+               if (dialog.open() == Window.OK) {
+                       return (IBinary) dialog.getFirstResult();
+               }
+       
+               return null;
+       }
+
+       /**
+        * Show a selection dialog that allows the user to choose one of the specified
+        * launch configurations.  Return the chosen config, or <code>null</code> if the
+        * user cancelled the dialog.
+        */
+       protected ILaunchConfiguration chooseConfiguration(List<ILaunchConfiguration> configList, String mode) {
+               IDebugModelPresentation labelProvider = DebugUITools.newDebugModelPresentation();
+               ElementListSelectionDialog dialog = new ElementListSelectionDialog(getActiveWorkbenchShell(), labelProvider);
+               dialog.setElements(configList.toArray());
+               dialog.setTitle(Messages.getString("ProfileLaunchShortcut.Launch_Configuration_Selection"));  //$NON-NLS-1$
+               dialog.setMessage(Messages.getString("ProfileLaunchShortcut.Choose_a_launch_configuration"));  //$NON-NLS-1$
+               dialog.setMultipleSelection(false);
+               int result = dialog.open();
+               labelProvider.dispose();
+               if (result == Window.OK) {
+                       return (ILaunchConfiguration) dialog.getFirstResult();
+               }
+               return null;
+       }
+
+       protected Shell getActiveWorkbenchShell() {
+               return ProfileLaunchPlugin.getActiveWorkbenchShell();
+       }
+
+}
diff --git a/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/messages.properties b/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/messages.properties
new file mode 100644 (file)
index 0000000..e022c3b
--- /dev/null
@@ -0,0 +1,17 @@
+ProfileLaunchShortcut.Binaries=Binaries:
+ProfileLaunchShortcut.Binary_not_found=Launch failed. Binary not found.
+ProfileLaunchShortcut.Choose_a_launch_configuration=Choose a launch configuration to profile
+ProfileLaunchShortcut.Choose_a_local_application=Choose a local application to profile
+ProfileLaunchShortcut.Launch_Configuration_Selection=Launch Configuration Selection
+ProfileLaunchShortcut.Looking_for_executables=Looking for executables
+ProfileLaunchShortcut.no_project_selected=Launch failed no project selected
+ProfileLaunchShortcut.Profile_With_Valgrind=Profile With Valgrind
+ProfileLaunchShortcut.Qualifier=Qualifer:
+ProfileLaunchShortcut.Valgrind_Launcher=Valgrind Launcher
+ProfileLaunchShortcut.targetcheck=MemoryProfiler
+ProfileLaunch.TRANSFER_PROFILING_TOOL=Transferring profiling tool package...
+ProfileLaunch.INSTALL_PROFILEING_TOOL=Installing profiling tool package...
+ProfileLaunch.FAIL_TO_DOWNLOAD = Fail to download profiling tool package files from HOST. \n 1. Check whether your device is connected or not. \n 2. Check whether your simulator runs or not.  \n
+ProfileLaunch.FAIL_TO_TRANSFER = Fail to transfer profiling tool package into target.\n Click the details button for the details.\n
+ProfileLaunch.FAIL_TO_INSTALL = Fail to install profiling tool package. \n Please, click the details button for the details. \n
+ProfileLaunch.FAIL_TO_FIND_PACKAGE     = Fail to find profiling tool package. \n Check your SDK's resources. \n
diff --git a/org.eclipse.linuxtools.profiling.ui/.classpath b/org.eclipse.linuxtools.profiling.ui/.classpath
new file mode 100644 (file)
index 0000000..ad32c83
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+       <classpathentry kind="src" path="src"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.eclipse.linuxtools.profiling.ui/.project b/org.eclipse.linuxtools.profiling.ui/.project
new file mode 100644 (file)
index 0000000..e85d27c
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.eclipse.linuxtools.profiling.ui</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.ManifestBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.SchemaBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.pde.PluginNature</nature>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>
diff --git a/org.eclipse.linuxtools.profiling.ui/.settings/org.eclipse.core.resources.prefs b/org.eclipse.linuxtools.profiling.ui/.settings/org.eclipse.core.resources.prefs
new file mode 100644 (file)
index 0000000..f1f3a6e
--- /dev/null
@@ -0,0 +1,3 @@
+#Wed Dec 01 09:13:34 CET 2010
+eclipse.preferences.version=1
+encoding/<project>=UTF-8
diff --git a/org.eclipse.linuxtools.profiling.ui/.settings/org.eclipse.core.runtime.prefs b/org.eclipse.linuxtools.profiling.ui/.settings/org.eclipse.core.runtime.prefs
new file mode 100644 (file)
index 0000000..b1cc158
--- /dev/null
@@ -0,0 +1,3 @@
+#Tue Dec 14 16:36:43 CET 2010
+eclipse.preferences.version=1
+line.separator=\n
diff --git a/org.eclipse.linuxtools.profiling.ui/META-INF/MANIFEST.MF b/org.eclipse.linuxtools.profiling.ui/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..8dcac68
--- /dev/null
@@ -0,0 +1,17 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Tizen SDK Profile UI
+Bundle-SymbolicName: org.eclipse.linuxtools.profiling.ui;singleton:=true
+Bundle-Version: 1.3.18.qualifier
+Bundle-Activator: org.eclipse.linuxtools.profiling.ui.ProfileUIPlugin
+Bundle-Vendor: Eclipse Linux Tools
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime
+Bundle-ActivationPolicy: lazy
+Bundle-Localization: plugin
+Export-Package: org.eclipse.linuxtools.profiling.ui
+Import-Package: org.eclipse.core.filesystem,
+ org.eclipse.jface.text,
+ org.eclipse.ui.ide,
+ org.eclipse.ui.texteditor
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
diff --git a/org.eclipse.linuxtools.profiling.ui/META-INF/eclipse.inf b/org.eclipse.linuxtools.profiling.ui/META-INF/eclipse.inf
new file mode 100644 (file)
index 0000000..92ffed2
--- /dev/null
@@ -0,0 +1,2 @@
+#Processed using Jarprocessor
+pack200.conditioned = true
diff --git a/org.eclipse.linuxtools.profiling.ui/NOTICE b/org.eclipse.linuxtools.profiling.ui/NOTICE
new file mode 100644 (file)
index 0000000..9568d07
--- /dev/null
@@ -0,0 +1,21 @@
+2010-02-10 SPRC SDK Team <d.kozinski@samsung.com>
+       * .classpath : change java runtime environment
+       * org.eclipse.jdt.core.prefs : remove file
+       
+2010-11-05 sdk <sdk@sdk-laptop.(none)>
+       * plugin.xml : changed some package name
+
+2011-06-09 jaewon81.lim <jaewon81.lim@samsung.com>
+       * MANIFEST.MF : rearrange plugins dependency
+
+2011-08-25 wonhyoung2.park <wonhyoung2.park@samsung.com>
+       * MANIFEST.MF : plugin provider and name modified
+
+2011-09-17 YoonKi Park <yoonki.park@samsung.com>
+       * plugin.xml : change view category name to SLP SDK
+
+2011-11-22 taeyoung2.son <taeyoung2.son@samsung.com>
+       * MANIFEST.MF :  Modify SDK naming from "SLP(or Samsung Linux Platform)" to "Tizen"
+
+2011-11-29 wonhyoung2.park <wonhyoung2.park@samsung.com>
+       * plugin.xml : chagne slp to tizen
diff --git a/org.eclipse.linuxtools.profiling.ui/about.html b/org.eclipse.linuxtools.profiling.ui/about.html
new file mode 100644 (file)
index 0000000..e6a2741
--- /dev/null
@@ -0,0 +1,26 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"><head>
+
+
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>About</title>
+</head><body lang="EN-US">
+<h2>About This Content</h2>
+<p>October 24, 2008</p>        
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in ("Content").  Unless otherwise 
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 ("EPL").  A copy of the EPL is available 
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, "Program" will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is 
+being redistributed by another party ("Redistributor") and different terms and conditions may
+apply to your use of any object code in the Content.  Check the Redistributor's license that was 
+provided with the Content.  If no such license exists, contact the Redistributor.  Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body></html>
\ No newline at end of file
diff --git a/org.eclipse.linuxtools.profiling.ui/build.properties b/org.eclipse.linuxtools.profiling.ui/build.properties
new file mode 100644 (file)
index 0000000..fbc0ad4
--- /dev/null
@@ -0,0 +1,9 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               .,\
+               plugin.xml,\
+               plugin.properties,\
+               about.html
+javacSource = 1.6
+javacTarget = 1.6
diff --git a/org.eclipse.linuxtools.profiling.ui/plugin.properties b/org.eclipse.linuxtools.profiling.ui/plugin.properties
new file mode 100644 (file)
index 0000000..db6c314
--- /dev/null
@@ -0,0 +1,4 @@
+#Properties file for org.eclipse.linuxtools.profiling.ui
+category.name.0 = Profiling
+Bundle-Vendor.0 = Eclipse.org
+Bundle-Name.0 = Profiling UI Plug-in (Incubation)
\ No newline at end of file
diff --git a/org.eclipse.linuxtools.profiling.ui/plugin.xml b/org.eclipse.linuxtools.profiling.ui/plugin.xml
new file mode 100644 (file)
index 0000000..07a0894
--- /dev/null
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+   <extension
+         point="org.eclipse.ui.views">
+      <category
+            id="org.tizen.nativeide.viewCategory"
+            name="%category.name.0">
+      </category>
+   </extension>
+   <extension
+         point="org.eclipse.ui.perspectiveExtensions">
+      <perspectiveExtension
+            targetID="org.tizen.nativeapp.perspective">
+         <actionSet
+               id="org.eclipse.debug.ui.profileActionSet">
+         </actionSet>
+      </perspectiveExtension>
+   </extension>
+</plugin>
diff --git a/org.eclipse.linuxtools.profiling.ui/src/org/eclipse/linuxtools/profiling/ui/ProfileUIPlugin.java b/org.eclipse.linuxtools.profiling.ui/src/org/eclipse/linuxtools/profiling/ui/ProfileUIPlugin.java
new file mode 100644 (file)
index 0000000..46b8bca
--- /dev/null
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Elliott Baron <ebaron@redhat.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.profiling.ui;
+
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class ProfileUIPlugin extends AbstractUIPlugin {
+
+       // The plug-in ID
+       public static final String PLUGIN_ID = "org.eclipse.linuxtools.profiling.ui"; //$NON-NLS-1$
+
+       // The shared instance
+       private static ProfileUIPlugin plugin;
+       
+       /**
+        * The constructor
+        */
+       public ProfileUIPlugin() {
+       }
+
+       /*
+        * (non-Javadoc)
+        * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+        */
+       public void start(BundleContext context) throws Exception {
+               super.start(context);
+               plugin = this;
+       }
+
+       /*
+        * (non-Javadoc)
+        * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+        */
+       public void stop(BundleContext context) throws Exception {
+               plugin = null;
+               super.stop(context);
+       }
+
+       /**
+        * Returns the shared instance
+        *
+        * @return the shared instance
+        */
+       public static ProfileUIPlugin getDefault() {
+               return plugin;
+       }
+       
+       public static Shell getActiveWorkbenchShell() {
+               IWorkbenchWindow window = getDefault().getWorkbench().getActiveWorkbenchWindow();
+               if (window != null) {
+                       return window.getShell();
+               }
+               return null;
+       }
+
+}
diff --git a/org.eclipse.linuxtools.profiling.ui/src/org/eclipse/linuxtools/profiling/ui/ProfileUIUtils.java b/org.eclipse.linuxtools.profiling.ui/src/org/eclipse/linuxtools/profiling/ui/ProfileUIUtils.java
new file mode 100644 (file)
index 0000000..c44fa8a
--- /dev/null
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Elliott Baron <ebaron@redhat.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.profiling.ui;
+
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.ui.texteditor.IDocumentProvider;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+public class ProfileUIUtils {
+       
+       /**
+        * Opens the specified file in an editor (or selects an already open
+        * editor) and highlights the specified line.
+        * @param path - absolute path of file to open
+        * @param line - line number to select, 0 to not select a line
+        * @throws PartInitException - Failed to open editor
+        * @throws BadLocationException - Line number not valid in file
+        */
+       public static void openEditorAndSelect(String path, int line) throws PartInitException, BadLocationException {
+               Path p = new Path(path);
+
+               if (p.toFile().exists()) {
+                       IWorkbenchPage activePage = ProfileUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
+                       IFileStore file = EFS.getLocalFileSystem().getStore(p);
+
+                       IEditorPart editor = IDE.openEditorOnFileStore(activePage, file);
+                       if (editor instanceof ITextEditor) {
+                               ITextEditor textEditor = (ITextEditor) editor;
+
+                               if (line > 0) {
+                                       IDocumentProvider provider = textEditor.getDocumentProvider();
+                                       IDocument document = provider.getDocument(textEditor.getEditorInput());
+
+                                       int start = document.getLineOffset(line - 1); //zero-indexed
+                                       textEditor.selectAndReveal(start, 0);
+                               }
+                       }
+               }
+       }
+}
diff --git a/org.eclipse.linuxtools.valgrind.core/.classpath b/org.eclipse.linuxtools.valgrind.core/.classpath
new file mode 100644 (file)
index 0000000..ad32c83
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+       <classpathentry kind="src" path="src"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.eclipse.linuxtools.valgrind.core/.project b/org.eclipse.linuxtools.valgrind.core/.project
new file mode 100644 (file)
index 0000000..d813748
--- /dev/null
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.eclipse.linuxtools.valgrind.core</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.ManifestBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.SchemaBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.api.tools.apiAnalysisBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.pde.PluginNature</nature>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+               <nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature>
+       </natures>
+</projectDescription>
diff --git a/org.eclipse.linuxtools.valgrind.core/.settings/org.eclipse.core.resources.prefs b/org.eclipse.linuxtools.valgrind.core/.settings/org.eclipse.core.resources.prefs
new file mode 100644 (file)
index 0000000..4d6c540
--- /dev/null
@@ -0,0 +1,3 @@
+#Wed Dec 01 09:13:41 CET 2010
+eclipse.preferences.version=1
+encoding/<project>=UTF-8
diff --git a/org.eclipse.linuxtools.valgrind.core/.settings/org.eclipse.core.runtime.prefs b/org.eclipse.linuxtools.valgrind.core/.settings/org.eclipse.core.runtime.prefs
new file mode 100644 (file)
index 0000000..53a5a9f
--- /dev/null
@@ -0,0 +1,3 @@
+#Tue Dec 14 16:36:47 CET 2010
+eclipse.preferences.version=1
+line.separator=\n
diff --git a/org.eclipse.linuxtools.valgrind.core/ChangeLog b/org.eclipse.linuxtools.valgrind.core/ChangeLog
new file mode 100644 (file)
index 0000000..21183ff
--- /dev/null
@@ -0,0 +1,12 @@
+2009-01-13  Elliott Baron  <ebaron@redhat.com>
+
+       * AbstractValgrindTextParser: New. Helpful starting point for text parsers.
+
+2009-01-09  Elliott Baron  <ebaron@redhat.com>
+
+       * ValgrindCommand: Added static method findValgrind() to call `which valgrind`.
+
+2009-01-05  Elliott Baron  <ebaron@redhat.com>
+
+       * META-INF/MANIFEST.MF: Changed version to 0.1.0.
+       * build.properties: Include about.html.
\ No newline at end of file
diff --git a/org.eclipse.linuxtools.valgrind.core/META-INF/MANIFEST.MF b/org.eclipse.linuxtools.valgrind.core/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..0869534
--- /dev/null
@@ -0,0 +1,14 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Tizen SDK Valgrind Core
+Bundle-SymbolicName: org.eclipse.linuxtools.valgrind.core;singleton:=true
+Bundle-Version: 1.3.18.qualifier
+Bundle-Activator: org.eclipse.linuxtools.valgrind.core.ValgrindPlugin
+Bundle-Vendor: Eclipse Linux Tools
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.cdt.core
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-ActivationPolicy: lazy
+Export-Package: org.eclipse.linuxtools.valgrind.core,
+ org.eclipse.linuxtools.valgrind.core.utils
+Bundle-Localization: plugin
diff --git a/org.eclipse.linuxtools.valgrind.core/NOTICE b/org.eclipse.linuxtools.valgrind.core/NOTICE
new file mode 100644 (file)
index 0000000..d563627
--- /dev/null
@@ -0,0 +1,15 @@
+2009-10-02 SPRC SDK Team <d.kozinski@samsung.com>
+       * MANIFEST.MF : modify dependency plugins
+
+2010-02-10 SPRC SDK Team <d.kozinski@samsung.com>
+       * .classpath : change java runtime environment
+       * org.eclipse.jdt.core.prefs : remove file
+
+2010-07-19 HyungJong, Shin <hj_shin@samsung.com>
+       * ValgrindCommand.java : valgrind version change ( 3.4 -> 3.5 ) : xml output enable officially.
+
+2011-06-09 jaewon81.lim <jaewon81.lim@samsung.com>
+       * MANIFEST.MF : rearrange plugins dependency
+
+2011-11-30 wonhyoung2.park <wonhyoung2.park@samsung.com>
+       * MANIFEST.MF : provider and plugin name modify
diff --git a/org.eclipse.linuxtools.valgrind.core/about.html b/org.eclipse.linuxtools.valgrind.core/about.html
new file mode 100644 (file)
index 0000000..e6a2741
--- /dev/null
@@ -0,0 +1,26 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"><head>
+
+
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>About</title>
+</head><body lang="EN-US">
+<h2>About This Content</h2>
+<p>October 24, 2008</p>        
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in ("Content").  Unless otherwise 
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 ("EPL").  A copy of the EPL is available 
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, "Program" will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is 
+being redistributed by another party ("Redistributor") and different terms and conditions may
+apply to your use of any object code in the Content.  Check the Redistributor's license that was 
+provided with the Content.  If no such license exists, contact the Redistributor.  Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body></html>
\ No newline at end of file
diff --git a/org.eclipse.linuxtools.valgrind.core/build.properties b/org.eclipse.linuxtools.valgrind.core/build.properties
new file mode 100644 (file)
index 0000000..137629f
--- /dev/null
@@ -0,0 +1,8 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               .,\
+               plugin.properties,\
+               about.html
+javacSource = 1.6
+javacTarget = 1.6
diff --git a/org.eclipse.linuxtools.valgrind.core/plugin.properties b/org.eclipse.linuxtools.valgrind.core/plugin.properties
new file mode 100644 (file)
index 0000000..255bd1f
--- /dev/null
@@ -0,0 +1,3 @@
+#Properties file for org.eclipse.linuxtools.valgrind.core
+Bundle-Vendor.0 = Eclipse.org
+Bundle-Name.0 = Valgrind Core Plug-in (Incubation)
\ No newline at end of file
diff --git a/org.eclipse.linuxtools.valgrind.core/src/org/eclipse/linuxtools/valgrind/core/AbstractValgrindTextParser.java b/org.eclipse.linuxtools.valgrind.core/src/org/eclipse/linuxtools/valgrind/core/AbstractValgrindTextParser.java
new file mode 100644 (file)
index 0000000..45c5263
--- /dev/null
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Elliott Baron <ebaron@redhat.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.valgrind.core;
+
+import java.io.IOException;
+
+import org.eclipse.osgi.util.NLS;
+
+public class AbstractValgrindTextParser {
+
+       public AbstractValgrindTextParser() {
+               super();
+       }
+
+       protected Long parseLongValue(String line, String delim)
+                       throws IOException {
+                               Long result = null;
+                               String[] parts = line.split(delim);
+                               if (parts.length > 1 && isNumber(parts[1])) {
+                                       result = Long.parseLong(parts[1]);
+                               }
+                               else {
+                                       fail(line);
+                               }
+                               return result;
+                       }
+
+       protected String parseStrValue(String line, String delim)
+                       throws IOException {
+                               String result = null;
+                               String[] parts = line.split(delim);
+                               if (parts.length > 1) {
+                                       result = parts[1];
+                               }
+                               else {
+                                       fail(line);
+                               }
+                               return result;
+                       }
+
+       protected void fail(String line) throws IOException {
+               throw new IOException(NLS.bind(Messages.getString("AbstractValgrindTextParser.Parsing_output_failed"), line)); //$NON-NLS-1$
+       }
+
+       protected boolean isNumber(String string) {
+               boolean result = true;
+               char[] chars = string.toCharArray();
+               for (int i = 0; i < chars.length; i++) {
+                       if (!Character.isDigit(chars[i])) {
+                               result = false;
+                       }
+               }
+               return result;
+       }
+
+}
\ No newline at end of file
diff --git a/org.eclipse.linuxtools.valgrind.core/src/org/eclipse/linuxtools/valgrind/core/ConsoleWriterThread.java b/org.eclipse.linuxtools.valgrind.core/src/org/eclipse/linuxtools/valgrind/core/ConsoleWriterThread.java
new file mode 100644 (file)
index 0000000..75d2dc3
--- /dev/null
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Red Hat, Inc. - initial API and implementation
+ *    Elliott Baron <ebaron@redhat.com> - modification
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.valgrind.core;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+
+public class ConsoleWriterThread extends Thread {
+       InputStreamReader in;
+       OutputStream out;
+
+       public ConsoleWriterThread(InputStream in, OutputStream out) {
+               this.out = out;
+               this.in = new InputStreamReader(in);
+       }
+
+       public void run() {
+               int ch;
+               try {
+                       while ((ch = in.read()) != -1) {
+                               out.write(ch);
+                       }
+               } catch (IOException e) {
+                       e.printStackTrace();
+               }
+       }
+
+}
diff --git a/org.eclipse.linuxtools.valgrind.core/src/org/eclipse/linuxtools/valgrind/core/Messages.java b/org.eclipse.linuxtools.valgrind.core/src/org/eclipse/linuxtools/valgrind/core/Messages.java
new file mode 100644 (file)
index 0000000..2dea736
--- /dev/null
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Elliott Baron <ebaron@redhat.com> - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.valgrind.core;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class Messages {
+       private static final String BUNDLE_NAME = "org.eclipse.linuxtools.valgrind.core.messages"; //$NON-NLS-1$
+
+       private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
+                       .getBundle(BUNDLE_NAME);
+
+       private Messages() {
+       }
+
+       public static String getString(String key) {
+               try {
+                       return RESOURCE_BUNDLE.getString(key);
+               } catch (MissingResourceException e) {
+                       return '!' + key + '!';
+               }
+       }
+}
diff --git a/org.eclipse.linuxtools.valgrind.core/src/org/eclipse/linuxtools/valgrind/core/StreamReaderThread.java b/org.eclipse.linuxtools.valgrind.core/src/org/eclipse/linuxtools/valgrind/core/StreamReaderThread.java
new file mode 100644 (file)
index 0000000..8e55e2b
--- /dev/null
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2005-2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Red Hat, Inc. - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.valgrind.core;
+
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.InputStream;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * Thread for reading input and output streams
+ */
+public class StreamReaderThread extends Thread {
+       StringBuffer out;
+       InputStreamReader in;
+
+       public StreamReaderThread(InputStream in, StringBuffer out) {
+               this.out = out;
+               this.in = new InputStreamReader(in);
+       }
+
+       public void run() {
+               int ch;
+               try {
+                       while ((ch = in.read()) != -1) {
+                               out.append((char) ch);
+                       }
+               } catch (IOException e) {
+                       out.append("\n" + NLS.bind(Messages.getString("StreamReaderThread.Read_error"), e.getMessage())); //$NON-NLS-1$ //$NON-NLS-2$
+               }
+       }
+}
diff --git a/org.eclipse.linuxtools.valgrind.core/src/org/eclipse/linuxtools/valgrind/core/ValgrindCommand.java b/org.eclipse.linuxtools.valgrind.core/src/org/eclipse/linuxtools/valgrind/core/ValgrindCommand.java
new file mode 100644 (file)
index 0000000..d4546ae
--- /dev/null
@@ -0,0 +1,134 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Elliott Baron <ebaron@redhat.com> - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.valgrind.core;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.eclipse.cdt.utils.pty.PTY;
+import org.eclipse.cdt.utils.spawner.ProcessFactory;
+import org.eclipse.osgi.util.NLS;
+
+public class ValgrindCommand {
+       protected static final String WHICH_CMD = "which"; //$NON-NLS-1$
+       protected static final String VALGRIND_CMD = "valgrind"; //$NON-NLS-1$
+
+       public static final String OPT_TOOL = "--tool"; //$NON-NLS-1$
+
+       public static final String OPT_XML = "--xml"; //$NON-NLS-1$
+       public static final String OPT_LOGFILE = "--log-file"; //$NON-NLS-1$
+       public static final String OPT_XMLFILE = "--xml-file"; //$NON-NLS-1$
+
+       public static final String OPT_TRACECHILD = "--trace-children"; //$NON-NLS-1$
+       public static final String OPT_CHILDSILENT = "--child-silent-after-fork"; //$NON-NLS-1$
+       public static final String OPT_TRACKFDS = "--track-fds"; //$NON-NLS-1$
+       public static final String OPT_TIMESTAMP = "--time-stamp"; //$NON-NLS-1$
+       public static final String OPT_FREERES = "--run-libc-freeres"; //$NON-NLS-1$
+       public static final String OPT_DEMANGLE = "--demangle"; //$NON-NLS-1$
+       public static final String OPT_NUMCALLERS = "--num-callers"; //$NON-NLS-1$
+       public static final String OPT_ERRLIMIT = "--error-limit"; //$NON-NLS-1$
+       public static final String OPT_BELOWMAIN = "--show-below-main"; //$NON-NLS-1$
+       public static final String OPT_MAXFRAME = "--max-stackframe"; //$NON-NLS-1$
+       public static final String OPT_SUPPFILE = "--suppressions"; //$NON-NLS-1$
+
+       protected File datadir;
+       protected Process process;
+       protected String[] args;
+
+       public ValgrindCommand(File outputDir) throws IOException {
+               datadir = outputDir;
+       }
+
+       public static String whichValgrind() throws IOException {
+               StringBuffer out = new StringBuffer();
+               Process p = Runtime.getRuntime().exec(WHICH_CMD + " " + VALGRIND_CMD); //$NON-NLS-1$
+               boolean success;
+               InputStream in;
+               try {
+                       if (success = (p.waitFor() == 0)) {
+                               in = p.getInputStream();
+                       }
+                       else {
+                               in = p.getErrorStream();
+                       }
+                       int ch;
+                       while ((ch = in.read()) != -1) {
+                               out.append((char) ch);
+                       }
+                       if (!success) {
+                               throw new IOException(out.toString());
+                       }
+               } catch (InterruptedException e) {
+                       e.printStackTrace();
+               }
+               return out.toString().trim();
+       }
+
+       public void execute(String[] commandArray, String[] env, File wd, boolean usePty) throws IOException {
+               args = commandArray;
+               try {
+                       createDatadir();
+                       if (wd == null) {
+                               process = ProcessFactory.getFactory().exec(commandArray, env);
+                       }
+                       else {
+                               if (PTY.isSupported() && usePty) {
+                                       process = ProcessFactory.getFactory().exec(commandArray, env, wd, new PTY());
+                               }
+                               else {
+                                       process = ProcessFactory.getFactory().exec(commandArray, env, wd);
+                               }
+                       }
+               }
+               catch (IOException e) {
+                       if (process != null) {
+                               process.destroy();
+                       }
+                       throw e;                
+               }
+       }
+
+       public File getDatadir() {
+               return datadir;
+       }
+
+       protected void createDatadir() throws IOException {
+               if (datadir.exists()) {
+                       // delete any preexisting files
+                       deleteFiles();
+               }
+               else if (!datadir.mkdir()) {
+                       throw new IOException(NLS.bind(Messages.getString("ValgrindCommand.Couldnt_create"), datadir.getAbsolutePath())); //$NON-NLS-1$
+               }
+       }
+
+
+       protected void deleteFiles() throws IOException {
+               for (File output : datadir.listFiles()) {
+                       if (!output.delete()) {
+                               throw new IOException(NLS.bind(Messages.getString("ValgrindCommand.Couldnt_delete"), output.getCanonicalPath())); //$NON-NLS-1$
+                       }
+               }
+       }
+
+       public Process getProcess() {
+               return process;
+       }
+
+       public String getCommandLine() {
+               StringBuffer ret = new StringBuffer();
+               for (String arg : args) {
+                       ret.append(arg + " "); //$NON-NLS-1$
+               }
+               return ret.toString().trim();
+       }
+}
diff --git a/org.eclipse.linuxtools.valgrind.core/src/org/eclipse/linuxtools/valgrind/core/ValgrindPlugin.java b/org.eclipse.linuxtools.valgrind.core/src/org/eclipse/linuxtools/valgrind/core/ValgrindPlugin.java
new file mode 100644 (file)
index 0000000..9890f98
--- /dev/null
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Elliott Baron <ebaron@redhat.com> - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.valgrind.core;
+
+import org.eclipse.core.runtime.Plugin;
+import org.osgi.framework.BundleContext;
+
+public class ValgrindPlugin extends Plugin {
+
+       // The plug-in ID
+       public static final String PLUGIN_ID = "org.eclipse.linuxtools.valgrind.core"; //$NON-NLS-1$
+
+       // The shared instance
+       private static ValgrindPlugin plugin;
+       
+       /**
+        * The constructor
+        */
+       public ValgrindPlugin() {
+       }
+
+       /*
+        * (non-Javadoc)
+        * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
+        */
+       public void start(BundleContext context) throws Exception {
+               super.start(context);
+               plugin = this;
+       }
+
+       /*
+        * (non-Javadoc)
+        * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
+        */
+       public void stop(BundleContext context) throws Exception {
+               plugin = null;
+               super.stop(context);
+       }
+
+       /**
+        * Returns the shared instance
+        *
+        * @return the shared instance
+        */
+       public static ValgrindPlugin getDefault() {
+               return plugin;
+       }
+
+}
diff --git a/org.eclipse.linuxtools.valgrind.core/src/org/eclipse/linuxtools/valgrind/core/messages.properties b/org.eclipse.linuxtools.valgrind.core/src/org/eclipse/linuxtools/valgrind/core/messages.properties
new file mode 100644 (file)
index 0000000..461c2a2
--- /dev/null
@@ -0,0 +1,4 @@
+StreamReaderThread.Read_error=Read error: {0}
+ValgrindCommand.Couldnt_create=Couldn't create {0}
+ValgrindCommand.Couldnt_delete=Couldn't delete {0}
+AbstractValgrindTextParser.Parsing_output_failed=Parsing output failed on line: {0}
diff --git a/org.eclipse.linuxtools.valgrind.core/src/org/eclipse/linuxtools/valgrind/core/utils/LaunchConfigurationConstants.java b/org.eclipse.linuxtools.valgrind.core/src/org/eclipse/linuxtools/valgrind/core/utils/LaunchConfigurationConstants.java
new file mode 100644 (file)
index 0000000..63c33ea
--- /dev/null
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Elliott Baron <ebaron@redhat.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.valgrind.core.utils;
+
+public final class LaunchConfigurationConstants {
+
+       // LaunchConfiguration constants
+       private static final String PLUGIN_ID = "org.eclipse.linuxtools.valgrind.launch"; //$NON-NLS-1$
+       
+       public static final String ATTR_TOOL = PLUGIN_ID + ".TOOL"; //$NON-NLS-1$
+
+       public static final String ATTR_GENERAL_TRACECHILD = PLUGIN_ID + ".GENERAL_TRACECHILD"; //$NON-NLS-1$
+       public static final String ATTR_GENERAL_CHILDSILENT = PLUGIN_ID + ".GENERAL_CHILDSILENT"; //$NON-NLS-1$
+       //      public static final String ATTR_GENERAL_TRACKFDS = PLUGIN_ID + ".GENERAL_TRACKFDS";
+       //      public static final String ATTR_GENERAL_TIMESTAMP = PLUGIN_ID + ".GENERAL_TIMESTAMP";
+       public static final String ATTR_GENERAL_FREERES = PLUGIN_ID + ".GENERAL_FREERES"; //$NON-NLS-1$
+       public static final String ATTR_GENERAL_DEMANGLE = PLUGIN_ID + ".GENERAL_DEMANGLE"; //$NON-NLS-1$
+
+       public static final String ATTR_GENERAL_NUMCALLERS = PLUGIN_ID + ".GENERAL_NUMCALLERS"; //$NON-NLS-1$
+       public static final String ATTR_GENERAL_ERRLIMIT = PLUGIN_ID + ".GENERAL_ERRLIMIT"; //$NON-NLS-1$
+       public static final String ATTR_GENERAL_BELOWMAIN = PLUGIN_ID + ".GENERAL_BELOWMAIN"; //$NON-NLS-1$
+       public static final String ATTR_GENERAL_MAXFRAME = PLUGIN_ID + ".GENERAL_MAXFRAME"; //$NON-NLS-1$
+       public static final String ATTR_GENERAL_SUPPFILE = PLUGIN_ID + ".GENERAL_SUPPFILE"; //$NON-NLS-1$
+
+}
diff --git a/org.eclipse.linuxtools.valgrind.launch.exe/.classpath b/org.eclipse.linuxtools.valgrind.launch.exe/.classpath
new file mode 100644 (file)
index 0000000..4c62a80
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+       <classpathentry kind="src" path="src"/>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.eclipse.linuxtools.valgrind.launch.exe/.project b/org.eclipse.linuxtools.valgrind.launch.exe/.project
new file mode 100644 (file)
index 0000000..482dd69
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.eclipse.linuxtools.valgrind.launch.exe</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.ManifestBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.SchemaBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.pde.PluginNature</nature>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>
diff --git a/org.eclipse.linuxtools.valgrind.launch.exe/.settings/org.eclipse.core.resources.prefs b/org.eclipse.linuxtools.valgrind.launch.exe/.settings/org.eclipse.core.resources.prefs
new file mode 100644 (file)
index 0000000..77aef41
--- /dev/null
@@ -0,0 +1,3 @@
+#Wed Dec 01 09:13:50 CET 2010
+eclipse.preferences.version=1
+encoding/<project>=UTF-8
diff --git a/org.eclipse.linuxtools.valgrind.launch.exe/.settings/org.eclipse.core.runtime.prefs b/org.eclipse.linuxtools.valgrind.launch.exe/.settings/org.eclipse.core.runtime.prefs
new file mode 100644 (file)
index 0000000..028faa0
--- /dev/null
@@ -0,0 +1,3 @@
+#Tue Dec 14 16:36:55 CET 2010
+eclipse.preferences.version=1
+line.separator=\n
diff --git a/org.eclipse.linuxtools.valgrind.launch.exe/META-INF/MANIFEST.MF b/org.eclipse.linuxtools.valgrind.launch.exe/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..02279b7
--- /dev/null
@@ -0,0 +1,28 @@
+Manifest-Version: 1.0
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.debug.ui,
+ org.eclipse.cdt.core;bundle-version="5.2.1",
+ org.eclipse.cdt.debug.core,
+ org.eclipse.cdt.launch,
+ org.tizen.common,
+ org.tizen.common.connection,
+ org.eclipse.linuxtools.valgrind.core;bundle-version="1.3.18",
+ org.eclipse.linuxtools.valgrind.ui;bundle-version="1.3.18",
+ org.eclipse.linuxtools.valgrind.launch;bundle-version="1.3.18",
+ org.eclipse.linuxtools.profiling.launch;bundle-version="1.3.18",
+ org.tizen.nativecommon
+Bundle-Vendor: Eclipse Linux Tools
+Bundle-Version: 1.3.18.qualifier
+Bundle-Localization: plugin
+Bundle-Name: Tizen SDK Valgrind Exe Launch
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: org.eclipse.linuxtools.valgrind.launch.exe;singleton:=true
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Export-Package: org.eclipse.linuxtools.valgrind.launch
+Import-Package: org.eclipse.cdt.managedbuilder.core,
+ org.tizen.nativecommon.launch,
+ org.tizen.nativecommon.launch.ui,
+ org.tizen.sdblib
+
+
diff --git a/org.eclipse.linuxtools.valgrind.launch.exe/NOTICE b/org.eclipse.linuxtools.valgrind.launch.exe/NOTICE
new file mode 100644 (file)
index 0000000..7ceff5a
--- /dev/null
@@ -0,0 +1,165 @@
+2009-10-02 SPRC SDK Team <d.kozinski@samsung.com>
+       * MANIFEST.MF : modify dependency plugins
+       * ValgrindDeployer.java : code refactoring
+
+2010-01-25 Dawid Kozinski <d.kozinski@samsung.com>
+       * plugin.xml : add cnature property
+
+2010-02-03 SPRC SDK Team <d.kozinski@samsung.com>
+       * MANIFEST.MF : changed some package names
+       * plugin.xml : changed some package names
+       * ValgrindLaunchShortcut.java : bug fix
+
+2010-02-08 SPRC SDK Team <d.kozinski@samsung.com>
+       * ValgrindDeployer.java : add error message and fix for valgrind ui view display
+
+2010-02-10 SPRC SDK Team <d.kozinski@samsung.com>
+       * ValgrindDeployer.java : some encapsulation
+       * ValgrindLaunchConfigurationTabGroup.java : remove unnecessary import
+       * ValgrindLaunchShortcut.java : some encapsulation
+
+2010-07-14 HyungJong, Shin <hj_shin@samsung.com>
+       * plugin.xml : delete daemon property
+
+2010-07-19 HyungJong, Shin <hj_shin@samsung.com>
+       * ValgrindDeployer.java : valgrind version change ( 3.4 -> 3.5 ) : xml output enable officially.
+       
+2010-07-23 HyungJong, Shin <hj_shin@samsung.com>
+       * ValgrindDeployer.java : application launching exception message shows several times.==> solved
+
+2010-08-26 HyungJong, Shin <hj_shin@samsung.com>
+       * ValgrindDeployer.java : modify some import, modify target control code
+       * ValgrindLaunchShortcut.java : modify some import, modify target control code
+
+2010-10-07 DongGi Jang <dg0402.jang.samsung.com>
+       * ValgrindDeployer.java : Enabling to lauch valgrind profiler in a real device
+       * ValgrindLaunchShortcut.java  :Enabling to lauch valgrind profiler in a real device
+       
+2010-10-21 HyungJong, Shin <hj_shin@samsung.com>
+       * ValgrindDeployer.java : modify Boilerplate
+       * ValgrindLaunchConfigurationTabGroup.java : modify Boilerplate
+       * ValgrindLaunchShortcut.java : modify Boilerplate
+
+2010-11-02 HyungJong, Shin <hj_shin@samsung.com>
+       * ValgrindDeployer.java : modify Boilerplate
+       * ValgrindLaunchConfigurationTabGroup.java : modify Boilerplate
+       * ValgrindLaunchShortcut.java : modify Boilerplate
+
+2010-11-03 HyungJong, Shin <hj_shin@samsung.com>
+       * ValgrindDeployer.java : modify session code
+       
+2010-11-05 sdk <sdk@sdk-laptop.(none)>
+       * MANIFEST.MF : changed some package name
+       * plugin.xml : changed some package name
+       * ValgrindDeployer.java : changed some package name
+       * ValgrindLaunchConfigurationTabGroup.java : changed some package name
+       * ValgrindLaunchShortcut.java : changed some package name
+       
+2010-11-09 DongGi Jang <dg0402.jang.samsung.com>
+       * MANIFEST.MF : changed launcher name
+
+2011-06-07 jaewon81.lim <jaewon81.lim@samsung.com>
+       * MANIFEST.MF : modify imported package name of freshide.common.ui
+       * SLPValgrindLaunchDelegate.java : modify path configuration of oprofile and valgrind tool
+       * ValgrindLaunchConfigurationTabGroup.java : modify imported package name of freshide.common.ui
+
+2011-06-09 jaewon81.lim <jaewon81.lim@samsung.com>
+       * MANIFEST.MF : rearrange plugins dependency
+
+2011-06-13 jaewon81.lim <jaewon81.lim@samsung.com>
+       * SLPValgrindLaunchDelegate.java : some bug fix
+
+2011-06-16 jaewon81.lim <jaewon81.lim@samsung.com>
+       * SLPValgrindLaunchDelegate.java : modify for profiling tool installation
+
+2011-06-22 jaewon81.lim <jaewon81.lim@samsung.com>
+       * SLPValgrindLaunchDelegate.java : update some code by fresh-ide update
+
+2011-07-13 jaewon81.lim <jaewon81.lim@samsung.com>
+       * MANIFEST.MF : modified import package name
+       * SLPValgrindLaunchDelegate.java : modified import package name
+
+2011-07-27 jaewon81.lim <jaewon81.lim@samsung.com>
+       * SLPValgrindLaunchDelegate.java : plugin source license cleanup
+
+2011-08-16 jaewon81.lim <jaewon81.lim@samsung.com>
+       * SLPValgrindLaunchDelegate.java : source license cleanup
+       * ValgrindLaunchConfigurationTabGroup.java : source license cleanup
+       * ValgrindLaunchShortcut.java : source license cleanup
+       
+2011-08-22 joogwan.kim <joogwan.kim@samsung.com>
+       * MANIFEST.MF : Change plug-in name
+       * SLPValgrindLaunchDelegate.java : Change plug-in name
+       * ValgrindLaunchConfigurationTabGroup.java : Change plug-in name
+
+2011-08-25 wonhyoung2.park <wonhyoung2.park@samsung.com>
+       * MANIFEST.MF : plugin provider and name modified
+
+2011-09-28 wonhyoung2.park <wonhyoung2.park@samsung.com>
+       * plugin.properties : add "Profile As" at the "Run" main menu
+       * plugin.xml : add "Profile As" at the "Run" main menu
+       * SLPValgrindLaunchDelegate.java : add configure selection routine
+
+2011-09-28 wonhyoung2.park <wonhyoung2.park@samsung.com>
+       * plugin.xml : Add "Profile As" menu
+
+2011-10-14 wonhyoung2.park <wonhyoung2.park@samsung.com>
+       * PathParser.java : profile bug fix for window
+       * SLPValgrindLaunchDelegate.java : profile bug fix for window
+
+2011-11-16 wonhyoung2.park <wonhyoung2.park@samsung.com>
+       * MANIFEST.MF : Profiler sdb apply
+       * CommandManager.java : added new file
+       * PathParser.java : deleted file
+       * SLPValgrindLaunchDelegate.java : Profiler sdb apply
+
+2011-11-18 wonhyoung2.park <wonhyoung2.park@samsung.com>
+       * SLPValgrindLaunchDelegate.java : add value removed from native ide
+
+2011-11-22 taeyoung2.son <taeyoung2.son@samsung.com>
+       * MANIFEST.MF :  Modify SDK naming from "SLP(or Samsung Linux Platform)" to "Tizen"
+
+2011-11-29 wonhyoung2.park <wonhyoung2.park@samsung.com>
+       * MANIFEST.MF : chagne slp to tizen
+       * plugin.xml : chagne slp to tizen
+       * CommandManager.java : chagne slp to tizen
+       * TizenValgrindLaunchDelegate.java : chagne slp to tizen
+       * ValgrindLaunchConfigurationTabGroup.java : chagne slp to tizen
+       * ValgrindLaunchShortcut.java : chagne slp to tizen
+
+2011-11-30 wonhyoung2.park <wonhyoung2.park@samsung.com>
+       * ValgrindLaunchConfigurationTabGroup.java : configure tab modify
+
+2011-12-01 wonhyoung2.park <wonhyoung2.park@samsung.com>
+       * ValgrindLaunchConfigurationTabGroup.java : unused import remove
+
+2011-12-02 taeyoung2.son <taeyoung2.son@samsung.com>
+       * MANIFEST.MF : Delete dependency feature's version value.
+
+2011-12-03 wonhyoung2.park <wonhyoung2.park@samsung.com>
+       * MANIFEST.MF : package instll routine chage
+       * plugin.xml : package instll routine chage
+       * CommandManager.java : package instll routine chage
+
+2011-12-05 wonhyoung2.park <wonhyoung2.park@samsung.com>
+       * CommandManager.java : add console (profile stop available)
+       * TizenValgrindLaunchDelegate.java : add console (profile stop available)
+       * TizenValgrindLaunchDelegate.java : remove valgrind blocking routine for window emulator
+
+2011-12-12 wonhyoung2.park <wonhyoung2.park@samsung.com>
+       * TizenValgrindLaunchDelegate.java : profile stop routine modify
+       * ValgrindDebugPlugin.java : added new file
+       * ValgrindRuntimeProcess.java : added new file
+       * plugin.xml : profile menu only show in native perspective
+
+2011-12-13 wonhyoung2.park <wonhyoung2.park@samsung.com>
+       * TizenValgrindLaunchDelegate.java : unused package remove
+
+2011-12-14 wonhyoung2.park <wonhyoung2.park@samsung.com>
+       * TizenValgrindLaunchDelegate.java : unnecessary code remove
+
+2011-12-19 wonhyoung2.park <wonhyoung2.park@samsung.com>
+       * CommandManager.java : add package for emulator
+       * ValgrindRuntimeProcess.java : add package for emulator
+       * CommandManager.java : package path setting modify
+       * TizenValgrindLaunchDelegate.java :package path setting modify
diff --git a/org.eclipse.linuxtools.valgrind.launch.exe/build.properties b/org.eclipse.linuxtools.valgrind.launch.exe/build.properties
new file mode 100644 (file)
index 0000000..b97395e
--- /dev/null
@@ -0,0 +1,9 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               .,\
+               plugin.xml,\
+               plugin.properties,\
+               icons/
+javacSource = 1.6
+javacTarget = 1.6
diff --git a/org.eclipse.linuxtools.valgrind.launch.exe/icons/valgrind-icon.png b/org.eclipse.linuxtools.valgrind.launch.exe/icons/valgrind-icon.png
new file mode 100644 (file)
index 0000000..dc1dede
Binary files /dev/null and b/org.eclipse.linuxtools.valgrind.launch.exe/icons/valgrind-icon.png differ
diff --git a/org.eclipse.linuxtools.valgrind.launch.exe/plugin.properties b/org.eclipse.linuxtools.valgrind.launch.exe/plugin.properties
new file mode 100644 (file)
index 0000000..f6c7acd
--- /dev/null
@@ -0,0 +1,10 @@
+#Properties file for org.eclipse.linuxtools.valgrind.launch
+launchConfigurations.label.0 = Profile Configurations...
+launch.label.0 = Profile As
+launchHistory.label.0 = Profile History 
+launchConfigurationType.name.0 = Profile With Valgrind
+launchConfigurationTabGroup.description.0 = Profile C/C++ Application Using Valgrind
+shortcut.label.0 = Profile With Valgrind
+Bundle-Vendor.0 = Eclipse.org
+Bundle-Name.0 = Valgrind Launch Plug-in (Incubation)
+extension-point.name.0 = valgrindTools
\ No newline at end of file
diff --git a/org.eclipse.linuxtools.valgrind.launch.exe/plugin.xml b/org.eclipse.linuxtools.valgrind.launch.exe/plugin.xml
new file mode 100644 (file)
index 0000000..1ab4199
--- /dev/null
@@ -0,0 +1,123 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+   <extension-point id="org.eclipse.linuxtools.valgrind.launch.valgrindTools" name="%extension-point.name.0" schema="schema/org.eclipse.linuxtools.valgrind.launch.valgrindTools.exsd"/>
+   <extension
+         point="org.eclipse.debug.core.launchConfigurationTypes">
+      <launchConfigurationType
+            delegate="org.eclipse.linuxtools.valgrind.launch.TizenValgrindLaunchDelegate"
+            id="org.eclipse.linuxtools.valgrind.launch.valgrindLaunch"
+            modes="profile"
+            name="%launchConfigurationType.name.0"
+            public="true">
+      </launchConfigurationType>
+   </extension>
+   <extension
+         point="org.eclipse.debug.ui.launchConfigurationTabGroups">
+      <launchConfigurationTabGroup
+            class="org.eclipse.linuxtools.valgrind.launch.ValgrindLaunchConfigurationTabGroup"
+            description="%launchConfigurationTabGroup.description.0"
+            id="org.eclipse.linuxtools.valgrind.launch.valgrindTabGroup"
+            type="org.eclipse.linuxtools.valgrind.launch.valgrindLaunch">
+      </launchConfigurationTabGroup>
+   </extension>
+   <extension
+         point="org.eclipse.debug.ui.launchConfigurationTypeImages">
+      <launchConfigurationTypeImage
+            configTypeID="org.eclipse.linuxtools.valgrind.launch.valgrindLaunch"
+            icon="icons/valgrind-icon.png"
+            id="org.eclipse.linuxtools.valgrind.launch.valgrindImage">
+      </launchConfigurationTypeImage>
+   </extension>
+   <extension
+         point="org.eclipse.debug.ui.launchShortcuts">
+      <shortcut
+            class="org.eclipse.linuxtools.valgrind.launch.ValgrindLaunchShortcut"
+            icon="icons/valgrind-icon.png"
+            id="org.eclipse.linuxtools.valgrind.launch.shortcut1"
+            label="%shortcut.label.0"
+            modes="profile">
+        <contextualLaunch>
+            <enablement>
+                <with variable="selection">
+                <count value="1"/>
+                <iterate>
+                    <or>
+                        <instanceof value="org.eclipse.cdt.core.model.IBinary"/>
+                        <instanceof value="org.eclipse.cdt.core.model.ICProject"/>
+                        <test
+                            forcePluginActivation="true"
+                            property="org.eclipse.cdt.launch.isExecutable"/>
+                        <test
+                            forcePluginActivation="true"
+                            property="org.eclipse.cdt.launch.isCProject"/>
+                        <and>
+                            <instanceof value="org.eclipse.ui.IFileEditorInput"/>
+                            <adapt type="org.eclipse.core.resources.IResource">
+                                <adapt type="org.eclipse.cdt.core.model.ICElement"/>
+                            </adapt>
+                        </and>
+                    </or>
+                </iterate>
+                </with>
+            </enablement>
+        </contextualLaunch>
+        <description
+            mode="profile"
+            description="Profile a Tizen application with Valgrind"/>
+        <configurationType
+               id="org.eclipse.linuxtools.valgrind.launch.valgrindLaunch">
+        </configurationType>
+      </shortcut>
+   </extension>
+   <extension
+         id="org.tizen.valgrind.tool"
+         point="org.tizen.common.connection.tools">
+      <tools
+            packagename="valgrind"
+            sourcepath="/on-demand">
+      </tools>
+   </extension>
+   <extension
+         id="org.tizen.libc6-dbg"
+         point="org.tizen.common.connection.tools">
+      <tools
+            packagename="libc6-dbg"
+            sourcepath="/on-demand">
+      </tools>
+   </extension>
+   <extension
+         id="org.tizen.eglibc-debuginfo"
+         point="org.tizen.common.connection.tools">
+      <tools
+            packagename="eglibc-debuginfo"
+            sourcepath="/on-demand">
+      </tools>
+   </extension>
+
+   <extension
+         point="org.eclipse.ui.activities">
+      <activity
+            id="org.eclipse.linuxtools.valgrind.launch.exe.activity"
+            name="name">
+         <enabledWhen>
+            <with
+                  variable="activeWorkbenchWindow.activePerspective">
+               <and>
+                  <equals
+                        value="org.tizen.nativeapp.perspective">
+                  </equals>
+               </and>
+            </with>
+         </enabledWhen>
+      </activity>
+      <activityPatternBinding
+            activityId="org.eclipse.linuxtools.valgrind.launch.exe.activity"
+            pattern="org.eclipse.linuxtools.valgrind.launch.exe/org.eclipse.linuxtools.valgrind.launch.shortcut1">
+      </activityPatternBinding>
+      <activityPatternBinding
+            activityId="org.eclipse.linuxtools.valgrind.launch.exe.activityPatternBinding6"
+            pattern="org.eclipse.linuxtools.valgrind.launch.exe/org.eclipse.linuxtools.valgrind.launch.exe.actionSet1">
+      </activityPatternBinding>
+   </extension>
+</plugin>
diff --git a/org.eclipse.linuxtools.valgrind.launch.exe/src/org/eclipse/linuxtools/valgrind/launch/CommandManager.java b/org.eclipse.linuxtools.valgrind.launch.exe/src/org/eclipse/linuxtools/valgrind/launch/CommandManager.java
new file mode 100644 (file)
index 0000000..d772c12
--- /dev/null
@@ -0,0 +1,164 @@
+package org.eclipse.linuxtools.valgrind.launch;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+import org.tizen.common.connection.ConnectionPlugin;
+import org.tizen.sdblib.IDevice;
+import org.tizen.sdblib.MultiLineReceiver;
+import org.tizen.sdblib.SdbCommandRejectedException;
+import org.tizen.sdblib.SdbShellProcess;
+import org.tizen.sdblib.ShellCommandUnresponsiveException;
+import org.tizen.sdblib.SyncService;
+import org.tizen.sdblib.SyncService.SyncResult;
+import org.tizen.sdblib.TimeoutException;
+
+class CommonReceiver extends MultiLineReceiver {
+
+       private String[] output;
+
+       public String[] getOutput() {
+               return output;
+       }
+
+       @Override
+       public void processNewLines(String[] lines) {
+               output = lines;
+       }
+}
+
+public class CommandManager {
+       
+       public static SdbShellProcess runApplication(String command){
+               IDevice device = ConnectionPlugin.getDefault().getCurrentDevice();
+               SdbShellProcess sdbShellProc = null;
+               
+               try {
+                       sdbShellProc = device.executeShellCommand(command);
+               } catch (IOException e) {
+                       e.printStackTrace();
+               }
+               return sdbShellProc;
+       }
+
+       public static String runShell(String command) {
+               IDevice device = ConnectionPlugin.getDefault().getCurrentDevice();
+               SdbShellProcess sdbShellProc = null;
+               BufferedReader br = null;
+
+               try {
+                       sdbShellProc = device.executeShellCommand(command);
+                       br = new BufferedReader(new InputStreamReader(
+                                       sdbShellProc.getInputStream()));
+
+               } catch (IOException e1) {
+                       e1.printStackTrace();
+               }
+               String out = null;
+               String lastOut = null;
+               try {
+                       while (null != (out = br.readLine())) {
+                               lastOut = out;
+                       }
+               } catch (IOException e) {
+                       e.printStackTrace();
+               }
+               return lastOut;
+       }
+
+       public static String[] runCommandReturningResult(String command) {
+               IDevice device = ConnectionPlugin.getDefault().getCurrentDevice();
+               CommonReceiver commonReceiver = new CommonReceiver();
+
+               try {
+                       device.executeShellCommand(command, commonReceiver);
+               } catch (TimeoutException e) {
+                       e.printStackTrace();
+               } catch (SdbCommandRejectedException e) {
+                       e.printStackTrace();
+               } catch (ShellCommandUnresponsiveException e) {
+                       e.printStackTrace();
+               } catch (IOException e) {
+                       e.printStackTrace();
+               }
+               return commonReceiver.getOutput();
+       }
+
+       public static void runCommand(String command) {
+
+               try {
+                       ConnectionPlugin.getDefault().getCurrentDevice()
+                                       .executeShellCommand(command);
+               } catch (SdbCommandRejectedException e) {
+                       e.printStackTrace();
+               } catch (IOException e) {
+                       e.printStackTrace();
+               }
+       }
+
+       public static boolean pull(String src, String dest) {
+               SyncService syncService = null;
+
+               try {
+                       syncService = ConnectionPlugin.getDefault().getCurrentDevice()
+                                       .getSyncService();
+               } catch (TimeoutException e) {
+                       e.printStackTrace();
+               } catch (SdbCommandRejectedException e) {
+                       e.printStackTrace();
+               } catch (IOException e) {
+                       e.printStackTrace();
+               }
+               SyncResult result = syncService.pullFile(src, dest,
+                               SyncService.getNullProgressMonitor());
+               if (SyncService.RESULT_OK == result.getCode()) {
+                       return true;
+               } else {
+                       return false;
+               }
+       }
+
+       public static boolean push(String src, String dest) {
+               SyncService syncService = null;
+               try {
+                       syncService = ConnectionPlugin.getDefault().getCurrentDevice()
+                                       .getSyncService();
+               } catch (TimeoutException e) {
+                       e.printStackTrace();
+               } catch (SdbCommandRejectedException e) {
+                       e.printStackTrace();
+               } catch (IOException e) {
+                       e.printStackTrace();
+               }
+               SyncResult result = syncService.pushFile(src, dest,
+                               SyncService.getNullProgressMonitor());
+               if (SyncService.RESULT_OK == result.getCode()) {
+                       return true;
+               } else {
+                       return false;
+               }
+       }
+
+       public static boolean isPathExist(String path) {
+               String[] result = runCommandReturningResult(path);
+               if (null != result && result[0].equals("No such file or directory")) {
+                       return false;
+               }
+               return true;
+       }
+
+       public static boolean isEmulator() {
+               return ConnectionPlugin.getDefault().getCurrentDevice().isEmulator();
+       }
+
+       public static boolean isRunSeccessfuly(String[] result) {
+               if (null != result && result.length > 0
+                               && !result[result.length - 1].contains("0")) {
+                       return false;
+               } else {
+                       return true;
+               }
+
+       }
+}
diff --git a/org.eclipse.linuxtools.valgrind.launch.exe/src/org/eclipse/linuxtools/valgrind/launch/TizenValgrindLaunchDelegate.java b/org.eclipse.linuxtools.valgrind.launch.exe/src/org/eclipse/linuxtools/valgrind/launch/TizenValgrindLaunchDelegate.java
new file mode 100644 (file)
index 0000000..92ce1fc
--- /dev/null
@@ -0,0 +1,382 @@
+/*
+ *  Tizen Valgrind Launch Delegate
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Jaewon Lim <jaewon81.lim@samsung.com>
+ * Wonhyoung Park <wonhyoung2.park@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.eclipse.linuxtools.valgrind.launch;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.Arrays;
+
+import org.eclipse.cdt.debug.core.CDebugUtils;
+import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
+import org.eclipse.cdt.launch.LaunchUtils;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.core.model.IProcess;
+import org.eclipse.linuxtools.valgrind.core.ValgrindCommand;
+import org.eclipse.linuxtools.valgrind.core.utils.LaunchConfigurationConstants;
+import org.eclipse.linuxtools.valgrind.ui.ValgrindUIPlugin;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.tizen.common.TizenPlatformConstants;
+import org.tizen.common.connection.ConnectionPlugin;
+import org.tizen.nativecommon.ProjectUtil;
+import org.tizen.nativecommon.launch.IProjectLaunchCommand;
+import org.tizen.nativecommon.launch.TizenLaunchCommand;
+import org.tizen.nativecommon.launch.TizenLaunchDelegate;
+import org.tizen.nativecommon.launch.TizenLaunchMessages;
+import org.tizen.sdblib.IDevice;
+import org.tizen.sdblib.SdbShellProcess;
+
+public class TizenValgrindLaunchDelegate extends TizenLaunchDelegate {
+
+       protected static final String MAKE_DIRECTORY_CMD = "mkdir -p ";
+       protected static final String CHANGE_DIRECTORY_CMD = "cd ";
+
+       protected IValgrindLaunchDelegate dynamicDelegate;
+       protected ValgrindCommand command;
+
+       protected static final String EQUALS = "=";
+       protected static final String EMPTY_STRING = "";
+       protected static final String NO = "no";
+       protected static final String YES = "yes";
+       protected static final String LOG_FILE = "valgrind.xml";
+       protected static final String BADA_EXT = ".exe";
+
+       protected static final String PACKAGE_NAME = "valgrind";
+       protected static final String PACKAGE_FILENAME_ARM = "valgrind_armel.deb";
+
+       protected String toolID;
+       protected int confirmMsg = 0;
+
+       @Override
+       public void launch(ILaunchConfiguration config, String mode,
+                       ILaunch launch, IProgressMonitor monitor) throws CoreException
+       {
+               if (monitor == null)
+                       monitor = new NullProgressMonitor();
+               
+               try {
+                       IDevice device = ConnectionPlugin.getDefault().getCurrentDevice();
+                       if(!device.isEmulator())
+                       {
+                               newCoreException("Valgrind profiling is available in emulator only.", null);
+                       }
+                       
+                       monitor.beginTask(TizenLaunchMessages.LAUNCH_APPLICATION, 30);
+
+                       activateProgressView();
+
+                       verifyCProjectConfigurationSettings(config);
+                       verifyDeviceReachability(ProjectUtil.getProject(config),
+                                       new SubProgressMonitor(monitor, 9));
+                       verifyBuildConfiguration(config, mode, new SubProgressMonitor(monitor, 11));
+
+                       setConsole(config);
+            tizenCommand = new TizenLaunchCommand(currentDevice, launchConsole);
+            // FIXME: ad-hoc code.
+            launchConsole.show();
+
+                       // getLaunchSession(config, new SubProgressMonitor(monitor, 1));
+
+                       if (mode.equals(ILaunchManager.PROFILE_MODE)) {
+                               deployApplication(config, new SubProgressMonitor(monitor, 9));
+                               monitor.worked(1);
+
+                               launchApplicationWithValgrind(launch, config, monitor);
+                       } else {
+                               newCoreException(TizenLaunchMessages.CANNOT_LAUNCH, null);
+                       }
+               } finally {
+                       monitor.done();
+               }
+       }
+
+       protected void launchApplicationWithValgrind(ILaunch launch, ILaunchConfiguration config,
+                       IProgressMonitor monitor) throws CoreException
+       {
+               // Process remoteShellProcess = null;
+
+               try {
+                       // find Valgrind executable
+                       String valgrindCmd = TizenPlatformConstants.TOOLS_TARGET_PATH + "/valgrind/usr/bin/valgrind";
+                       String cmd = "ls " + valgrindCmd + TizenPlatformConstants.CMD_SUFFIX;
+                       String[] resultRsp = CommandManager.runCommandReturningResult(cmd);
+                       if (!CommandManager.isRunSeccessfuly(resultRsp)) {
+                               newCoreException(TizenLaunchMessages.CANNOT_LAUNCH,     new Exception(
+                                               "No valgrind in this target (" + TizenPlatformConstants.TOOLS_TARGET_PATH + "/valgrind/usr/bin/valgrind)."));
+                       }
+
+                       if (monitor.isCanceled())
+                               throw new OperationCanceledException();
+
+                       // verify target app path
+                       IProjectLaunchCommand manifest = ProjectUtil.getProjectManifest(ProjectUtil.getProject(config));
+                       String remoteExePath = TizenPlatformConstants.APP_INSTALL_PATH + "/" + manifest.getPackageName() + "/bin/";
+                       IPath exeFile = CDebugUtils.verifyProgramPath(config);
+                       remoteExePath += exeFile.toFile().getName();
+                       
+                       // for bada application
+                       // execute non-exe file instead of .exe file
+                       if(remoteExePath.endsWith(BADA_EXT))
+                       {
+                               remoteExePath = remoteExePath.substring(0, remoteExePath.length() - BADA_EXT.length());
+                       }
+                       
+                       cmd = "ls " + remoteExePath + TizenPlatformConstants.CMD_SUFFIX;
+                       resultRsp = CommandManager.runCommandReturningResult(cmd);
+                       if (!CommandManager.isRunSeccessfuly(resultRsp))
+                       {
+                               newCoreException(TizenLaunchMessages.CANNOT_LAUNCH,     new Exception(
+                                               "Executable does not exist on a valid path. You must install your application before running it."));
+                       }
+                       
+                       if (monitor.isCanceled())
+                               throw new OperationCanceledException();
+                       
+                       monitor.worked(3);
+
+                       // remove and remake valgrind result directory
+                       cmd = "rm -rf" + " " + ValgrindLaunchPlugin.RESULT_DIR;
+                       CommandManager.runShell(cmd);
+                       cmd = "mkdir -p" + " " + ValgrindLaunchPlugin.RESULT_DIR;
+                       CommandManager.runShell(cmd);
+
+                       if (monitor.isCanceled())
+                               throw new OperationCanceledException();
+
+                       monitor.worked(1);
+
+                       // ask tool (that was launched) extension for arguments
+                       toolID = getTool(config);
+                       dynamicDelegate = ValgrindLaunchPlugin.getDefault().getToolDelegate(toolID);
+                       String[] opts = getValgrindArgumentsArray(config);
+                       String[] arguments = getProgramArgumentsArray(config);
+
+                       ArrayList<String> cmdLine = new ArrayList<String>(1 + arguments.length);
+                       cmdLine.add(valgrindCmd);
+                       cmdLine.addAll(Arrays.asList(opts));
+                       cmdLine.add(remoteExePath.toString());
+                       cmdLine.addAll(Arrays.asList(arguments));
+                       String[] commandArray = (String[]) cmdLine.toArray(new String[cmdLine.size()]);
+
+                       // compose full command of valgrind
+                       String fullcommand = "";
+                       for (int i = 0; i < commandArray.length; i++) {
+                               fullcommand += commandArray[i] + " ";
+                       }
+
+                       config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_USE_TERMINAL,
+                                       ICDTLaunchConfigurationConstants.USE_TERMINAL_DEFAULT);
+                       
+                       if (monitor.isCanceled())
+                               throw new OperationCanceledException();
+
+                       // run application with valgrind
+                       runApplication(config, launch, fullcommand, monitor);
+
+                       monitor.worked(2);
+
+                       // process = DebugPlugin.newProcess(launch, remoteShellProcess, "valgrind");
+
+                       // create launch summary string to distinguish this launch
+                       String launchStr = createLaunchStr(config);
+
+                       // create view
+                       ValgrindUIPlugin.getDefault().createView(launchStr, toolID);
+
+                       monitor.worked(1);
+
+                       // pass off control to extender
+                       command = new ValgrindCommand(new File(ValgrindLaunchPlugin.RESULT_DIR));
+                       dynamicDelegate.launch(command, config, launch, new SubProgressMonitor(monitor, 15));
+
+                       monitor.worked(1);
+                       
+                       // refresh view
+                       ValgrindUIPlugin.getDefault().refreshView();
+
+                       monitor.worked(2);
+
+                       Display.getDefault().syncExec(new Runnable() {
+                               public void run() {
+                                       try {
+                                               PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
+                                                               .showView(ValgrindUIPlugin.VIEW_ID);
+                                       } catch (PartInitException e) {
+                                               e.printStackTrace();
+                                       }
+                               }
+                       });
+               } catch (ValgrindCanceledException e) {
+                       e.printStackTrace();
+               } catch (OperationCanceledException e) {
+                       newCoreException("Operation canceled by user.", null);
+               } catch (CoreException e) {
+                       newCoreException(e.getMessage(), e.getCause());
+               } catch (IOException e) {
+                       newCoreException(TizenLaunchMessages.CANNOT_LAUNCH, e);
+               } catch (Exception e) {
+                       newCoreException(TizenLaunchMessages.CANNOT_LAUNCH, e);
+               } finally {
+                       monitor.done();
+               }
+       }
+
+       private void runApplication(ILaunchConfiguration config, ILaunch launch,
+                       String command, IProgressMonitor monitor) throws ValgrindCanceledException
+       {
+               SdbShellProcess valgrindProc = CommandManager.runApplication(command);
+               IPath exeFile = null;
+               try {
+                       exeFile = CDebugUtils.verifyProgramPath(config);
+                       IProcess vproc = ValgrindDebugPlugin.newProcess(launch, valgrindProc, exeFile.toFile().getName());
+//                     BufferedReader br = new BufferedReader(new InputStreamReader(valgrindProc.getInputStream()));
+                       
+                       while (true)
+                       {
+                               if (monitor.isCanceled())
+                               {
+                                       valgrindProc.destroy();
+                                       
+                                       Display.getDefault().syncExec(new Runnable() {
+                                               public void run() {
+                                                       IWorkbenchWindow wbench = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+                                                       MessageBox confirm = new MessageBox(wbench.getShell(), SWT.ICON_WARNING | SWT.OK);
+                                                       confirm.setMessage(Messages.getString("ValgrindLaunchPlugin.Confirm_cancel"));
+                                                       confirm.open();
+                                               }
+                                       });
+                                       
+                                       throw new ValgrindCanceledException();
+                               }
+                               else if(vproc.isTerminated())
+                               {
+                                       monitor.worked(2);
+                                       break;
+                               }
+                               
+                               Thread.sleep(250);
+                       }
+               } catch (CoreException e) {
+                       e.printStackTrace();
+               } catch (InterruptedException e) {
+                       e.printStackTrace();
+               }
+       }
+
+       private String[] getValgrindArgumentsArray(ILaunchConfiguration config) throws IOException, CoreException
+       {
+               ArrayList<String> opts = new ArrayList<String>();
+               opts.add(ValgrindCommand.OPT_TOOL + EQUALS + ValgrindLaunchPlugin.getDefault().getToolName(toolID));
+
+               // opts.add(ValgrindCommand.OPT_LOGFILE + EQUALS + ValgrindLaunchPlugin.RESULT_DIR + LOG_FILE);
+               opts.add(ValgrindCommand.OPT_XMLFILE + EQUALS + ValgrindLaunchPlugin.RESULT_DIR + LOG_FILE);
+               // opts.add(ValgrindCommand.OPT_LOGFILE + EQUALS + "/home" + File.separator + LOG_FILE);
+
+               opts.add(ValgrindCommand.OPT_TRACECHILD + EQUALS +
+                               (config.getAttribute(LaunchConfigurationConstants.ATTR_GENERAL_TRACECHILD, false) ? YES : NO));
+               opts.add(ValgrindCommand.OPT_CHILDSILENT + EQUALS + YES);
+                       //  (config.getAttribute(ValgrindLaunchPlugin.ATTR_GENERAL_CHILDSILENT, false) ? YES : NO));
+               
+               // opts.add(ValgrindCommand.OPT_TRACKFDS + EQUALS +
+                       //  (config.getAttribute(ValgrindLaunchPlugin.ATTR_GENERAL_TRACKFDS, false) ? YES : NO));
+               // opts.add(ValgrindCommand.OPT_TIMESTAMP + EQUALS +
+                       //  (config.getAttribute(ValgrindLaunchPlugin.ATTR_GENERAL_TIMESTAMP, false) ? YES : NO));
+               opts.add(ValgrindCommand.OPT_FREERES + EQUALS +
+                               (config.getAttribute(LaunchConfigurationConstants.ATTR_GENERAL_FREERES, true) ? YES : NO));
+
+               opts.add(ValgrindCommand.OPT_DEMANGLE + EQUALS +
+                               (config.getAttribute(LaunchConfigurationConstants.ATTR_GENERAL_DEMANGLE, true) ? YES : NO));
+               opts.add(ValgrindCommand.OPT_NUMCALLERS + EQUALS +
+                               config.getAttribute(LaunchConfigurationConstants.ATTR_GENERAL_NUMCALLERS, 12));
+               opts.add(ValgrindCommand.OPT_ERRLIMIT + EQUALS +
+                               (config.getAttribute(LaunchConfigurationConstants.ATTR_GENERAL_ERRLIMIT, true) ? YES : NO));
+               opts.add(ValgrindCommand.OPT_BELOWMAIN + EQUALS +
+                               (config.getAttribute(LaunchConfigurationConstants.ATTR_GENERAL_BELOWMAIN, false) ? YES : NO));
+               opts.add(ValgrindCommand.OPT_MAXFRAME + EQUALS +
+                               config.getAttribute(LaunchConfigurationConstants.ATTR_GENERAL_MAXFRAME, 2000000));
+
+               String strpath = config.getAttribute(LaunchConfigurationConstants.ATTR_GENERAL_SUPPFILE, EMPTY_STRING);
+               if (!strpath.equals(EMPTY_STRING)) {
+                       File suppfile = ValgrindLaunchPlugin.getDefault().parseWSPath(strpath);
+                       if (suppfile != null) {
+                               String escapedPath = null;
+                               try {
+                                       escapedPath = ValgrindLaunchPlugin.getDefault().escapeAndQuote(suppfile.getCanonicalPath());
+                               } catch (IOException e) {
+                                       e.printStackTrace();
+                               }
+                               opts.add(ValgrindCommand.OPT_SUPPFILE + EQUALS + escapedPath);
+                       }
+               }
+
+               opts.addAll(Arrays.asList(dynamicDelegate.getCommandArray(command, config)));
+
+               String[] ret = new String[opts.size()];
+               return opts.toArray(ret);
+       }
+
+       protected String getTool(ILaunchConfiguration config) throws CoreException
+       {
+               return config.getAttribute(LaunchConfigurationConstants.ATTR_TOOL,
+                               ValgrindLaunchPlugin.TOOL_EXT_DEFAULT);
+       }
+
+       protected String getPluginID()
+       {
+               return ValgrindLaunchPlugin.PLUGIN_ID;
+       }
+
+       public String[] getProgramArgumentsArray(ILaunchConfiguration config) throws CoreException
+       {
+               return LaunchUtils.getProgramArgumentsArray(config);
+       }
+
+       protected String createLaunchStr(ILaunchConfiguration config) throws CoreException
+       {
+               return config.getName() + " [" + ValgrindLaunchPlugin.getDefault().getToolName(toolID) + "] ";
+       }
+       
+       
+       class ValgrindCanceledException extends Exception
+       {
+               private static final long serialVersionUID = 1L;
+               
+               public ValgrindCanceledException() {
+                       super();
+               }
+       }
+}
diff --git a/org.eclipse.linuxtools.valgrind.launch.exe/src/org/eclipse/linuxtools/valgrind/launch/ValgrindDebugPlugin.java b/org.eclipse.linuxtools.valgrind.launch.exe/src/org/eclipse/linuxtools/valgrind/launch/ValgrindDebugPlugin.java
new file mode 100644 (file)
index 0000000..aafb5ac
--- /dev/null
@@ -0,0 +1,1601 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.valgrind.launch;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.FactoryConfigurationError;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.TransformerException;
+
+import org.eclipse.core.resources.ISaveContext;
+import org.eclipse.core.resources.ISaveParticipant;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IAdapterManager;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.ISafeRunnable;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.ListenerList;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.PlatformObject;
+import org.eclipse.core.runtime.Plugin;
+import org.eclipse.core.runtime.SafeRunner;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.debug.core.DebugEvent;
+import org.eclipse.debug.core.IBreakpointManager;
+import org.eclipse.debug.core.IDebugEventFilter;
+import org.eclipse.debug.core.IDebugEventSetListener;
+import org.eclipse.debug.core.IExpressionManager;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.core.ILogicalStructureType;
+import org.eclipse.debug.core.IMemoryBlockManager;
+import org.eclipse.debug.core.IProcessFactory;
+import org.eclipse.debug.core.IStatusHandler;
+import org.eclipse.debug.core.model.IDebugElement;
+import org.eclipse.debug.core.model.IDisconnect;
+import org.eclipse.debug.core.model.IDropToFrame;
+import org.eclipse.debug.core.model.IProcess;
+import org.eclipse.debug.core.model.IStep;
+import org.eclipse.debug.core.model.IStepFilters;
+import org.eclipse.debug.core.model.ISuspendResume;
+import org.eclipse.debug.core.model.ITerminate;
+import org.eclipse.debug.core.model.IValue;
+import org.eclipse.debug.core.model.RuntimeProcess;
+import org.eclipse.debug.internal.core.BreakpointManager;
+import org.eclipse.debug.internal.core.DebugCoreMessages;
+import org.eclipse.debug.internal.core.DebugOptions;
+import org.eclipse.debug.internal.core.ExpressionManager;
+import org.eclipse.debug.internal.core.IConfigurationElementConstants;
+import org.eclipse.debug.internal.core.IInternalDebugCoreConstants;
+import org.eclipse.debug.internal.core.LaunchManager;
+import org.eclipse.debug.internal.core.LogicalStructureManager;
+import org.eclipse.debug.internal.core.MemoryBlockManager;
+import org.eclipse.debug.internal.core.Preferences;
+import org.eclipse.debug.internal.core.StepFilterManager;
+import org.eclipse.debug.internal.core.commands.CommandAdapterFactory;
+import org.eclipse.debug.internal.core.sourcelookup.SourceLookupUtils;
+import org.eclipse.osgi.service.environment.Constants;
+import org.osgi.framework.BundleContext;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+/**
+ * There is one instance of the debug plug-in available from
+ * <code>DebugPlugin.getDefault()</code>. The debug plug-in provides:
+ * <ul>
+ * <li>access to the breakpoint manager</li>
+ * <li>access to the launch manager</li>
+ * <li>access to the expression manager</li>
+ * <li>access to the registered launcher extensions</li>
+ * <li>access to the memory block manager</li>
+ * <li>debug event notification</li>
+ * <li>status handlers</li>
+ * </ul>
+ * 
+ * @noinstantiate This class is not intended to be instantiated by clients.
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class ValgrindDebugPlugin extends Plugin {
+
+       /**
+        * Unique identifier constant (value <code>"org.eclipse.debug.core"</code>)
+        * for the Debug Core plug-in.
+        */
+       private static final String PI_DEBUG_CORE = "org.eclipse.debug.core"; //$NON-NLS-1$
+
+       /**
+        * Simple identifier constant (value <code>"launchConfigurationTypes"</code>
+        * ) for the launch configuration types extension point.
+        * 
+        * @since 2.0
+        */
+       public static final String EXTENSION_POINT_LAUNCH_CONFIGURATION_TYPES = "launchConfigurationTypes"; //$NON-NLS-1$       
+
+       /**
+        * Simple identifier constant (value
+        * <code>"launchConfigurationComparators"</code>) for the launch
+        * configuration comparators extension point.
+        * 
+        * @since 2.0
+        */
+       public static final String EXTENSION_POINT_LAUNCH_CONFIGURATION_COMPARATORS = "launchConfigurationComparators"; //$NON-NLS-1$           
+
+       /**
+        * Simple identifier constant (value <code>"breakpoints"</code>) for the
+        * breakpoints extension point.
+        * 
+        * @since 2.0
+        */
+       public static final String EXTENSION_POINT_BREAKPOINTS = "breakpoints"; //$NON-NLS-1$
+
+       /**
+        * Simple identifier constant (value <code>"statusHandlers"</code>) for the
+        * status handlers extension point.
+        * 
+        * @since 2.0
+        */
+       public static final String EXTENSION_POINT_STATUS_HANDLERS = "statusHandlers"; //$NON-NLS-1$    
+
+       /**
+        * Simple identifier constant (value <code>"sourceLocators"</code>) for the
+        * source locators extension point.
+        * 
+        * @since 2.0
+        */
+       public static final String EXTENSION_POINT_SOURCE_LOCATORS = "sourceLocators"; //$NON-NLS-1$    
+
+       /**
+        * Simple identifier constant (value <code>"launchModes"</code>) for the
+        * source modes extension point.
+        * 
+        * @since 3.0
+        */
+       public static final String EXTENSION_POINT_LAUNCH_MODES = "launchModes"; //$NON-NLS-1$  
+
+       /**
+        * Simple identifier constant (value <code>"launchDelegates"</code>) for the
+        * launch delegates extension point.
+        * 
+        * @since 3.0
+        */
+       public static final String EXTENSION_POINT_LAUNCH_DELEGATES = "launchDelegates"; //$NON-NLS-1$
+
+       /**
+        * Simple identifier constant (value <code>"processFactories"</code>) for
+        * the process factories extension point.
+        * 
+        * @since 3.0
+        */
+       public static final String EXTENSION_POINT_PROCESS_FACTORIES = "processFactories"; //$NON-NLS-1$
+
+       /**
+        * Simple identifier constant (value <code>"logicalStructureTypes"</code>)
+        * for the logical structure types extension point.
+        * 
+        * @since 3.0
+        */
+       public static final String EXTENSION_POINT_LOGICAL_STRUCTURE_TYPES = "logicalStructureTypes"; //$NON-NLS-1$
+
+       /**
+        * Simple identifier constant (value
+        * <code>"logicalStructureProviders"</code>) for the logical structure types
+        * extension point.
+        * 
+        * @since 3.1
+        */
+       public static final String EXTENSION_POINT_LOGICAL_STRUCTURE_PROVIDERS = "logicalStructureProviders"; //$NON-NLS-1$
+
+       /**
+        * Simple identifier constant (value <code>"sourceContainerTypes"</code>)
+        * for the source container types extension point.
+        * 
+        * @since 3.0
+        */
+       public static final String EXTENSION_POINT_SOURCE_CONTAINER_TYPES = "sourceContainerTypes"; //$NON-NLS-1$
+
+       /**
+        * Simple identifier constant (value <code>"sourcePathComputers"</code>) for
+        * the source path computers extension point.
+        * 
+        * @since 3.0
+        */
+       public static final String EXTENSION_POINT_SOURCE_PATH_COMPUTERS = "sourcePathComputers"; //$NON-NLS-1$
+
+       /**
+        * Simple identifier constant for the launch options extension point
+        * 
+        * @since 3.3
+        */
+       public static final String EXTENSION_POINT_LAUNCH_OPTIONS = "launchOptions"; //$NON-NLS-1$
+
+       /**
+        * Simple identifier constant for the breakpoint import participant
+        * extension point
+        * 
+        * @since 3.5
+        */
+       public static final String EXTENSION_POINT_BREAKPOINT_IMPORT_PARTICIPANTS = "breakpointImportParticipants"; //$NON-NLS-1$
+
+       /**
+        * Status code indicating an unexpected error.
+        * 
+        * @since 3.4
+        */
+       public static final int ERROR = 125;
+
+       /**
+        * Status code indicating an unexpected internal error. Internal errors
+        * should never be displayed to the user in dialogs or status text. Internal
+        * error messages are not translated.
+        */
+       public static final int INTERNAL_ERROR = 120;
+
+       /**
+        * Status code indicating that the Eclipse runtime does not support
+        * launching a program with a working directory. This feature is only
+        * available if Eclipse is run on a 1.3 runtime or higher.
+        * <p>
+        * A status handler may be registered for this error condition, and should
+        * return a <code>Boolean</code> indicating whether the program should be
+        * re-launched with the default working directory.
+        * </p>
+        */
+       public static final int ERR_WORKING_DIRECTORY_NOT_SUPPORTED = 115;
+
+       /**
+        * The launch configuration attribute that designates the process factory ID
+        * for the process factory to be used when creating a new process as a
+        * result of launching the launch configuration.
+        * 
+        * @since 3.0
+        */
+       public static final String ATTR_PROCESS_FACTORY_ID = "process_factory_id"; //$NON-NLS-1$
+
+       /**
+        * The launch attribute that designates whether or not it's associated
+        * launch should capture output. Value is a string representing a boolean -
+        * <code>true</code> or <code>false</code>. When unspecified, the default
+        * value is considered <code>true</code>.
+        * 
+        * @since 3.1
+        */
+       public static final String ATTR_CAPTURE_OUTPUT = PI_DEBUG_CORE
+                       + ".capture_output"; //$NON-NLS-1$
+
+       /**
+        * The launch attribute that stores the time stamp of when a launch
+        * configuration was launched. Value is {@link Long#toString(long)} of
+        * {@link System#currentTimeMillis()}.
+        * 
+        * @since 3.6
+        */
+       public static final String ATTR_LAUNCH_TIMESTAMP = PI_DEBUG_CORE
+                       + ".launch.timestamp"; //$NON-NLS-1$
+
+       /**
+        * This launch attribute designates the encoding to be used by the console
+        * associated with the launch.
+        * <p>
+        * For release 3.3, the system encoding is used when unspecified. Since 3.4,
+        * the inherited encoding is used when unspecified. See
+        * {@link ILaunchManager} for a description in
+        * <code>getEncoding(ILaunchConfiguration)</code>.
+        * </p>
+        * <p>
+        * Value of this constant is the same as the value of the old
+        * <code>IDebugUIConstants.ATTR_CONSOLE_ENCODING</code> constant for
+        * backward compatibility.
+        * </p>
+        * 
+        * @since 3.3
+        */
+       public static final String ATTR_CONSOLE_ENCODING = "org.eclipse.debug.ui.ATTR_CONSOLE_ENCODING"; //$NON-NLS-1$
+
+       /**
+        * Boolean preference key (value
+        * <code>org.eclipse.debug.core.PREF_DELETE_CONFIGS_ON_PROJECT_DELETE</code>
+        * ) that controls whether to delete associated configurations when a
+        * project is deleted. Default value is <code>false</code>.
+        * 
+        * @since 3.7
+        */
+       public static final String PREF_DELETE_CONFIGS_ON_PROJECT_DELETE = ValgrindDebugPlugin
+                       .getUniqueIdentifier() + ".PREF_DELETE_CONFIGS_ON_PROJECT_DELETE"; //$NON-NLS-1$
+
+       /**
+        * Deleted breakpoint marker attribute (value
+        * <code>"org.eclipse.debug.core.breakpointIsDeleted"</code>). The attribute
+        * is a <code>boolean</code> corresponding to the deleted state of a
+        * breakpoint.
+        * 
+        * @see org.eclipse.core.resources.IMarker#getAttribute(String, boolean)
+        * @since 3.7
+        */
+       public static final String ATTR_BREAKPOINT_IS_DELETED = ValgrindDebugPlugin
+                       .getUniqueIdentifier() + ".breakpointIsDeleted"; //$NON-NLS-1$
+
+       /**
+        * The singleton debug plug-in instance.
+        */
+       private static ValgrindDebugPlugin fgDebugPlugin = null;
+
+       /**
+        * The singleton breakpoint manager.
+        */
+       private BreakpointManager fBreakpointManager;
+
+       /**
+        * The singleton expression manager.
+        */
+       private ExpressionManager fExpressionManager;
+
+       /**
+        * The singleton launch manager.
+        */
+       private LaunchManager fLaunchManager;
+
+       /**
+        * The singleton memory block manager.
+        * 
+        * @since 3.1
+        */
+       private MemoryBlockManager fMemoryBlockManager;
+
+       /**
+        * The collection of debug event listeners.
+        */
+       private ListenerList fEventListeners = new ListenerList();
+
+       /**
+        * Event filters, or <code>null</code> if none.
+        */
+       private ListenerList fEventFilters = new ListenerList();
+
+       /**
+        * Whether this plug-in is in the process of shutting down.
+        */
+       private boolean fShuttingDown = false;
+
+       /**
+        * Table of status handlers. Keys are {plug-in identifier, status code}
+        * pairs, and values are associated <code>IConfigurationElement</code>s.
+        */
+       private HashMap fStatusHandlers = null;
+
+       /**
+        * Map of process factories. Keys are process factory IDs and values are
+        * associated <code>IConfigurationElement</code>s.
+        * 
+        * @since 3.0
+        */
+       private HashMap fProcessFactories = null;
+
+       /**
+        * Mode constants for the event notifier
+        */
+       private static final int NOTIFY_FILTERS = 0;
+       private static final int NOTIFY_EVENTS = 1;
+
+       /**
+        * Queue of debug events to fire to listeners and asynchronous runnables to
+        * execute in the order received.
+        * 
+        * @since 3.1
+        */
+       private List fEventQueue = new ArrayList();
+
+       /**
+        * Job to fire events to listeners.
+        * 
+        * @since 3.1
+        */
+       private EventDispatchJob fEventDispatchJob = new EventDispatchJob();
+
+       /**
+        * Event dispatch job. Processes event queue of debug events and runnables.
+        * 
+        * @since 3.1
+        */
+       class EventDispatchJob extends Job {
+
+               EventNotifier fNotifier = new EventNotifier();
+               AsynchRunner fRunner = new AsynchRunner();
+
+               /**
+                * Creates a new event dispatch job.
+                */
+               public EventDispatchJob() {
+                       super(DebugCoreMessages.DebugPlugin_1);
+                       setPriority(Job.INTERACTIVE);
+                       setSystem(true);
+               }
+
+               /*
+                * (non-Javadoc)
+                * 
+                * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.
+                * IProgressMonitor)
+                */
+               protected IStatus run(IProgressMonitor monitor) {
+
+                       while (!fEventQueue.isEmpty()) {
+                               Object next = null;
+                               synchronized (fEventQueue) {
+                                       if (!fEventQueue.isEmpty()) {
+                                               next = fEventQueue.remove(0);
+                                       }
+                               }
+                               if (next instanceof Runnable) {
+                                       fRunner.async((Runnable) next);
+                               } else if (next != null) {
+                                       fNotifier.dispatch((DebugEvent[]) next);
+                               }
+                       }
+                       return Status.OK_STATUS;
+               }
+
+               /*
+                * (non-Javadoc)
+                * 
+                * @see org.eclipse.core.runtime.jobs.Job#shouldRun()
+                */
+               public boolean shouldRun() {
+                       return shouldSchedule();
+               }
+
+               /*
+                * (non-Javadoc)
+                * 
+                * @see org.eclipse.core.internal.jobs.InternalJob#shouldSchedule()
+                */
+               public boolean shouldSchedule() {
+                       return !(isShuttingDown() || fEventListeners.isEmpty());
+               }
+
+       }
+
+       /**
+        * Returns the singleton instance of the debug plug-in.
+        * 
+        * @return the debug plug-in
+        */
+       public static ValgrindDebugPlugin getDefault() {
+               return fgDebugPlugin;
+       }
+
+       /**
+        * Sets the singleton instance of the debug plug-in.
+        * 
+        * @param plugin
+        *            the debug plug-in, or <code>null</code> when shutting down
+        */
+       private static void setDefault(ValgrindDebugPlugin plugin) {
+               fgDebugPlugin = plugin;
+       }
+
+       /**
+        * Convenience method which returns the unique identifier of this plug-in.
+        * 
+        * @return debug plug-in identifier
+        */
+       public static String getUniqueIdentifier() {
+               return PI_DEBUG_CORE;
+       }
+
+       /**
+        * Constructs the debug plug-in.
+        * <p>
+        * An instance of this plug-in runtime class is automatically created when
+        * the facilities provided by this plug-in are required. <b>Clients must
+        * never explicitly instantiate a plug-in runtime class.</b>
+        * </p>
+        */
+       public ValgrindDebugPlugin() {
+               super();
+               setDefault(this);
+       }
+
+       /**
+        * Adds the given listener to the collection of registered debug event
+        * listeners. Has no effect if an identical listener is already registered.
+        * 
+        * @param listener
+        *            the listener to add
+        * @since 2.0
+        */
+       public void addDebugEventListener(IDebugEventSetListener listener) {
+               fEventListeners.add(listener);
+       }
+
+       /**
+        * Notifies all registered debug event set listeners of the given debug
+        * events. Events which are filtered by a registered debug event filter are
+        * not fired.
+        * 
+        * @param events
+        *            array of debug events to fire
+        * @see IDebugEventFilter
+        * @see IDebugEventSetListener
+        * @since 2.0
+        */
+       public void fireDebugEventSet(DebugEvent[] events) {
+               if (isShuttingDown() || events == null || fEventListeners.isEmpty())
+                       return;
+               synchronized (fEventQueue) {
+                       fEventQueue.add(events);
+               }
+               fEventDispatchJob.schedule();
+       }
+
+       /**
+        * Asynchronously executes the given runnable in a separate thread, after
+        * debug event dispatch has completed. If debug events are not currently
+        * being dispatched, the runnable is scheduled to run in a separate thread
+        * immediately.
+        * 
+        * @param r
+        *            runnable to execute asynchronously
+        * @since 2.1
+        */
+       public void asyncExec(Runnable r) {
+               synchronized (fEventQueue) {
+                       fEventQueue.add(r);
+               }
+               fEventDispatchJob.schedule();
+       }
+
+       /**
+        * Returns the breakpoint manager.
+        * 
+        * @return the breakpoint manager
+        * @see IBreakpointManager
+        */
+       public synchronized IBreakpointManager getBreakpointManager() {
+               if (fBreakpointManager == null) {
+                       fBreakpointManager = new BreakpointManager();
+               }
+               return fBreakpointManager;
+       }
+
+       /**
+        * Returns the launch manager.
+        * 
+        * @return the launch manager
+        * @see ILaunchManager
+        */
+       public synchronized ILaunchManager getLaunchManager() {
+               if (fLaunchManager == null) {
+                       fLaunchManager = new LaunchManager();
+               }
+               return fLaunchManager;
+       }
+
+       /**
+        * Returns the memory block manager.
+        * 
+        * @return the memory block manager.
+        * @see IMemoryBlockManager
+        * @since 3.1
+        */
+       public synchronized IMemoryBlockManager getMemoryBlockManager() {
+               if (fMemoryBlockManager == null) {
+                       fMemoryBlockManager = new MemoryBlockManager();
+               }
+               return fMemoryBlockManager;
+       }
+
+       /**
+        * Returns the status handler registered for the given status, or
+        * <code>null</code> if none.
+        * 
+        * @param status
+        *            status for which a status handler has been requested
+        * @return the status handler registered for the given status, or
+        *         <code>null</code> if none
+        * @since 2.0
+        */
+       public IStatusHandler getStatusHandler(IStatus status) {
+               boolean enabled = Platform.getPreferencesService().getBoolean(
+                               ValgrindDebugPlugin.getUniqueIdentifier(),
+                               IInternalDebugCoreConstants.PREF_ENABLE_STATUS_HANDLERS, true,
+                               null);
+               if (!enabled) {
+                       return null;
+               }
+               StatusHandlerKey key = new StatusHandlerKey(status.getPlugin(),
+                               status.getCode());
+               if (fStatusHandlers == null) {
+                       initializeStatusHandlers();
+               }
+               IConfigurationElement config = (IConfigurationElement) fStatusHandlers
+                               .get(key);
+               if (config != null) {
+                       try {
+                               Object handler = config
+                                               .createExecutableExtension(IConfigurationElementConstants.CLASS);
+                               if (handler instanceof IStatusHandler) {
+                                       return (IStatusHandler) handler;
+                               }
+                               invalidStatusHandler(
+                                               null,
+                                               MessageFormat
+                                                               .format("Registered status handler {0} does not implement required interface IStatusHandler.", new String[] { config.getDeclaringExtension().getUniqueIdentifier() })); //$NON-NLS-1$
+                       } catch (CoreException e) {
+                               log(e);
+                       }
+               }
+               return null;
+       }
+
+       /**
+        * Returns the expression manager.
+        * 
+        * @return the expression manager
+        * @see IExpressionManager
+        * @since 2.0
+        */
+       public synchronized IExpressionManager getExpressionManager() {
+               if (fExpressionManager == null) {
+                       fExpressionManager = new ExpressionManager();
+               }
+               return fExpressionManager;
+       }
+
+       /**
+        * Removes the given listener from the collection of registered debug event
+        * listeners. Has no effect if an identical listener is not already
+        * registered.
+        * 
+        * @param listener
+        *            the listener to remove
+        * @since 2.0
+        */
+       public void removeDebugEventListener(IDebugEventSetListener listener) {
+               fEventListeners.remove(listener);
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see
+        * org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+        */
+       public void stop(BundleContext context) throws Exception {
+               try {
+                       setShuttingDown(true);
+
+                       if (fLaunchManager != null) {
+                               fLaunchManager.shutdown();
+                       }
+                       if (fBreakpointManager != null) {
+                               fBreakpointManager.shutdown();
+                       }
+                       if (fMemoryBlockManager != null) {
+                               fMemoryBlockManager.shutdown();
+                       }
+
+                       fEventListeners.clear();
+                       fEventFilters.clear();
+
+                       SourceLookupUtils.shutdown();
+                       Preferences.savePreferences(ValgrindDebugPlugin
+                                       .getUniqueIdentifier());
+                       ResourcesPlugin.getWorkspace().removeSaveParticipant(
+                                       getUniqueIdentifier());
+               } finally {
+                       super.stop(context);
+                       setDefault(null);
+               }
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see
+        * org.eclipse.core.runtime.Plugin#start(org.osgi.framework.BundleContext)
+        */
+       public void start(BundleContext context) throws Exception {
+               super.start(context);
+               DebugOptions.initDebugOptions();
+               ResourcesPlugin.getWorkspace().addSaveParticipant(
+                               getUniqueIdentifier(), new ISaveParticipant() {
+                                       public void saving(ISaveContext saveContext)
+                                                       throws CoreException {
+                                               if (fExpressionManager != null) {
+                                                       fExpressionManager.storeWatchExpressions();
+                                               }
+                                               Preferences.savePreferences(ValgrindDebugPlugin
+                                                               .getUniqueIdentifier());
+                                       }
+
+                                       public void rollback(ISaveContext saveContext) {
+                                       }
+
+                                       public void prepareToSave(ISaveContext saveContext)
+                                                       throws CoreException {
+                                       }
+
+                                       public void doneSaving(ISaveContext saveContext) {
+                                       }
+                               });
+               // command adapters
+               IAdapterManager manager = Platform.getAdapterManager();
+               CommandAdapterFactory actionFactory = new CommandAdapterFactory();
+               manager.registerAdapters(actionFactory, IDisconnect.class);
+               manager.registerAdapters(actionFactory, IDropToFrame.class);
+               manager.registerAdapters(actionFactory, IStep.class);
+               manager.registerAdapters(actionFactory, IStepFilters.class);
+               manager.registerAdapters(actionFactory, ISuspendResume.class);
+               manager.registerAdapters(actionFactory, ITerminate.class);
+               manager.registerAdapters(actionFactory, ILaunch.class);
+               manager.registerAdapters(actionFactory, IProcess.class);
+               manager.registerAdapters(actionFactory, IDebugElement.class);
+       }
+
+       /**
+        * Creates and returns a new process representing the given
+        * <code>java.lang.Process</code>. A streams proxy is created for the I/O
+        * streams in the system process. The process is added to the given launch.
+        * <p>
+        * If the launch configuration associated with the given launch specifies a
+        * process factory, it will be used to instantiate the new process.
+        * </p>
+        * 
+        * @param launch
+        *            the launch the process is contained in
+        * @param process
+        *            the system process to wrap
+        * @param label
+        *            the label assigned to the process
+        * @return the process
+        * @see IProcess
+        * @see IProcessFactory
+        */
+       public static IProcess newProcess(ILaunch launch, Process process,
+                       String label) {
+               return newProcess(launch, process, label, null);
+       }
+
+       /**
+        * Creates and returns a new process representing the given
+        * <code>java.lang.Process</code>. A streams proxy is created for the I/O
+        * streams in the system process. The process is added to the given launch,
+        * and the process is initialized with the given attribute map.
+        * <p>
+        * If the launch configuration associated with the given launch specifies a
+        * process factory, it will be used to instantiate the new process.
+        * </p>
+        * 
+        * @param launch
+        *            the launch the process is contained in
+        * @param process
+        *            the system process to wrap
+        * @param label
+        *            the label assigned to the process
+        * @param attributes
+        *            initial values for the attribute map
+        * @return the process <code>null</code> can be returned if errors occur
+        *         dealing with the process factory designated to create the
+        *         process.
+        * @see IProcess
+        * @see IProcessFactory
+        * @since 2.1
+        */
+       public static IProcess newProcess(ILaunch launch, Process process,
+                       String label, Map attributes) {
+               ILaunchConfiguration config = launch.getLaunchConfiguration();
+               String processFactoryID = null;
+               if (config != null) {
+                       try {
+                               processFactoryID = config.getAttribute(ATTR_PROCESS_FACTORY_ID,
+                                               (String) null);
+                       } catch (CoreException e) {
+                               e.printStackTrace();
+                       }
+               }
+               if (processFactoryID != null) {
+                       ValgrindDebugPlugin plugin = ValgrindDebugPlugin.getDefault();
+                       if (plugin.fProcessFactories == null) {
+                               plugin.initializeProcessFactories();
+                       }
+                       IConfigurationElement element = (IConfigurationElement) plugin.fProcessFactories
+                                       .get(processFactoryID);
+                       if (element == null) {
+                               return null;
+                       }
+                       IProcessFactory processFactory = null;
+                       try {
+                               processFactory = (IProcessFactory) element
+                                               .createExecutableExtension(IConfigurationElementConstants.CLASS);
+                       } catch (CoreException exception) {
+                               log(exception);
+                               return null;
+                       }
+                       return processFactory
+                                       .newProcess(launch, process, label, attributes);
+               }
+               return new ValgrindRuntimeProcess(launch, process, label, attributes);
+       }
+
+       /**
+        * Returns any logical structure types that have been contributed for the
+        * given value.
+        * 
+        * @param value
+        *            the value for which logical structure types have been
+        *            requested
+        * @return logical structure types that have been contributed for the given
+        *         value, possibly an empty collection
+        * 
+        * @since 3.0
+        */
+       public static ILogicalStructureType[] getLogicalStructureTypes(IValue value) {
+               return LogicalStructureManager.getDefault().getLogicalStructureTypes(
+                               value);
+       }
+
+       /**
+        * Returns the default logical structure type among the given combination of
+        * logical structure types, or <code>null</code> if none. When the given
+        * combination of logical structure type is applicable for a value, the
+        * default logical structure type is used to display a value.
+        * 
+        * @param types
+        *            a combination of structures applicable to a value
+        * @return the default structure that should be used to display the value or
+        *         <code>null</code> if none
+        * 
+        * @since 3.1
+        */
+       public static ILogicalStructureType getDefaultStructureType(
+                       ILogicalStructureType[] types) {
+               return LogicalStructureManager.getDefault().getSelectedStructureType(
+                               types);
+       }
+
+       /**
+        * Sets the default logical structure type among the given combination of
+        * logical structure types. The logical structure types provided should all
+        * be applicable to a single value. Specifying <code>null</code> indicates
+        * there is no default logical structure for the given combination of types.
+        * 
+        * @param types
+        *            a combination of logical structure types applicable to a value
+        * @param def
+        *            the default logical structure among the given combination of
+        *            types or <code>null</code> if none
+        * 
+        * @since 3.1
+        */
+       public static void setDefaultStructureType(ILogicalStructureType[] types,
+                       ILogicalStructureType def) {
+               LogicalStructureManager.getDefault().setEnabledType(types, def);
+       }
+
+       /**
+        * Convenience method that performs a runtime exec on the given command line
+        * in the context of the specified working directory, and returns the
+        * resulting process. If the current runtime does not support the
+        * specification of a working directory, the status handler for error code
+        * <code>ERR_WORKING_DIRECTORY_NOT_SUPPORTED</code> is queried to see if the
+        * exec should be re-executed without specifying a working directory.
+        * 
+        * @param cmdLine
+        *            the command line
+        * @param workingDirectory
+        *            the working directory, or <code>null</code>
+        * @return the resulting process or <code>null</code> if the exec is
+        *         canceled
+        * @exception CoreException
+        *                if the exec fails
+        * @see Runtime
+        * 
+        * @since 2.1
+        */
+       public static Process exec(String[] cmdLine, File workingDirectory)
+                       throws CoreException {
+               return exec(cmdLine, workingDirectory, null);
+       }
+
+       /**
+        * Convenience method that performs a runtime exec on the given command line
+        * in the context of the specified working directory, and returns the
+        * resulting process. If the current runtime does not support the
+        * specification of a working directory, the status handler for error code
+        * <code>ERR_WORKING_DIRECTORY_NOT_SUPPORTED</code> is queried to see if the
+        * exec should be re-executed without specifying a working directory.
+        * 
+        * @param cmdLine
+        *            the command line
+        * @param workingDirectory
+        *            the working directory, or <code>null</code>
+        * @param envp
+        *            the environment variables set in the process, or
+        *            <code>null</code>
+        * @return the resulting process or <code>null</code> if the exec is
+        *         canceled
+        * @exception CoreException
+        *                if the exec fails
+        * @see Runtime
+        * 
+        * @since 3.0
+        */
+       public static Process exec(String[] cmdLine, File workingDirectory,
+                       String[] envp) throws CoreException {
+               Process p = null;
+               try {
+                       if (workingDirectory == null) {
+                               p = Runtime.getRuntime().exec(cmdLine, envp);
+                       } else {
+                               p = Runtime.getRuntime().exec(cmdLine, envp, workingDirectory);
+                       }
+               } catch (IOException e) {
+                       Status status = new Status(IStatus.ERROR, getUniqueIdentifier(),
+                                       ERROR, DebugCoreMessages.DebugPlugin_0, e);
+                       throw new CoreException(status);
+               } catch (NoSuchMethodError e) {
+                       // attempting launches on 1.2.* - no ability to set working
+                       // directory
+                       IStatus status = new Status(
+                                       IStatus.ERROR,
+                                       getUniqueIdentifier(),
+                                       ERR_WORKING_DIRECTORY_NOT_SUPPORTED,
+                                       DebugCoreMessages.DebugPlugin_Eclipse_runtime_does_not_support_working_directory_2,
+                                       e);
+                       IStatusHandler handler = ValgrindDebugPlugin.getDefault()
+                                       .getStatusHandler(status);
+
+                       if (handler != null) {
+                               Object result = handler.handleStatus(status, null);
+                               if (result instanceof Boolean
+                                               && ((Boolean) result).booleanValue()) {
+                                       p = exec(cmdLine, null);
+                               }
+                       }
+               }
+               return p;
+       }
+
+       /**
+        * Returns whether this plug-in is in the process of being shutdown.
+        * 
+        * @return whether this plug-in is in the process of being shutdown
+        */
+       private boolean isShuttingDown() {
+               return fShuttingDown;
+       }
+
+       /**
+        * Sets whether this plug-in is in the process of being shutdown.
+        * 
+        * @param value
+        *            whether this plug-in is in the process of being shutdown
+        */
+       private void setShuttingDown(boolean value) {
+               fShuttingDown = value;
+       }
+
+       /**
+        * Returns the collection of debug event listeners registered with this
+        * plug-in.
+        * 
+        * @return list of registered debug event listeners, instances of
+        *         <code>IDebugEventSetListeners</code>
+        */
+       private Object[] getEventListeners() {
+               return fEventListeners.getListeners();
+       }
+
+       /**
+        * Adds the given debug event filter to the registered event filters. Has no
+        * effect if an identical filter is already registered.
+        * 
+        * @param filter
+        *            debug event filter
+        * @since 2.0
+        */
+       public void addDebugEventFilter(IDebugEventFilter filter) {
+               fEventFilters.add(filter);
+       }
+
+       /**
+        * Removes the given debug event filter from the registered event filters.
+        * Has no effect if an identical filter is not already registered.
+        * 
+        * @param filter
+        *            debug event filter
+        * @since 2.0
+        */
+       public void removeDebugEventFilter(IDebugEventFilter filter) {
+               fEventFilters.remove(filter);
+       }
+
+       /**
+        * Logs the given message if in debug mode.
+        * 
+        * @param message
+        *            the message to log
+        * @since 2.0
+        */
+       public static void logDebugMessage(String message) {
+               if (getDefault().isDebugging()) {
+                       // this message is intentionally not externalized, as an exception
+                       // may
+                       // be due to the resource bundle itself
+                       log(new Status(IStatus.ERROR, getUniqueIdentifier(), ERROR,
+                                       MessageFormat.format(DebugCoreMessages.DebugPlugin_2,
+                                                       new String[] { message }), null));
+               }
+       }
+
+       /**
+        * Logs the given message with this plug-in's log and the given throwable or
+        * <code>null</code> if none.
+        * 
+        * @param message
+        *            the message to log
+        * @param throwable
+        *            the exception that occurred or <code>null</code> if none
+        */
+       public static void logMessage(String message, Throwable throwable) {
+               log(new Status(IStatus.ERROR, getUniqueIdentifier(), ERROR, message,
+                               throwable));
+       }
+
+       /**
+        * Logs the specified status with this plug-in's log.
+        * 
+        * @param status
+        *            status to log
+        * @since 2.0
+        */
+       public static void log(IStatus status) {
+               getDefault().getLog().log(status);
+       }
+
+       /**
+        * Logs the specified throwable with this plug-in's log.
+        * 
+        * @param t
+        *            throwable to log
+        * @since 2.0
+        */
+       public static void log(Throwable t) {
+               IStatus status = new Status(IStatus.ERROR, getUniqueIdentifier(),
+                               ERROR, DebugCoreMessages.DebugPlugin_3, t);
+               log(status);
+       }
+
+       /**
+        * Register status handlers.
+        * 
+        */
+       private void initializeStatusHandlers() {
+               IExtensionPoint extensionPoint = Platform.getExtensionRegistry()
+                               .getExtensionPoint(ValgrindDebugPlugin.PI_DEBUG_CORE,
+                                               EXTENSION_POINT_STATUS_HANDLERS);
+               IConfigurationElement[] infos = extensionPoint
+                               .getConfigurationElements();
+               fStatusHandlers = new HashMap(infos.length);
+               for (int i = 0; i < infos.length; i++) {
+                       IConfigurationElement configurationElement = infos[i];
+                       String id = configurationElement.getAttribute("plugin"); //$NON-NLS-1$
+                       String code = configurationElement.getAttribute("code"); //$NON-NLS-1$
+
+                       if (id != null && code != null) {
+                               try {
+                                       StatusHandlerKey key = new StatusHandlerKey(id,
+                                                       Integer.parseInt(code));
+                                       fStatusHandlers.put(key, configurationElement);
+                               } catch (NumberFormatException e) {
+                                       // invalid status handler
+                                       invalidStatusHandler(e,
+                                                       configurationElement.getAttribute("id")); //$NON-NLS-1$
+                               }
+                       } else {
+                               // invalid status handler
+                               invalidStatusHandler(null,
+                                               configurationElement.getAttribute("id")); //$NON-NLS-1$
+                       }
+               }
+       }
+
+       /**
+        * Register process factories.
+        * 
+        */
+       private void initializeProcessFactories() {
+               IExtensionPoint extensionPoint = Platform.getExtensionRegistry()
+                               .getExtensionPoint(ValgrindDebugPlugin.PI_DEBUG_CORE,
+                                               EXTENSION_POINT_PROCESS_FACTORIES);
+               IConfigurationElement[] infos = extensionPoint
+                               .getConfigurationElements();
+               fProcessFactories = new HashMap(infos.length);
+               for (int i = 0; i < infos.length; i++) {
+                       IConfigurationElement configurationElement = infos[i];
+                       String id = configurationElement.getAttribute("id"); //$NON-NLS-1$
+                       String clss = configurationElement.getAttribute("class"); //$NON-NLS-1$
+                       if (id != null && clss != null) {
+                               fProcessFactories.put(id, configurationElement);
+                       } else {
+                               // invalid process factory
+                               String badDefiner = infos[i].getContributor().getName();
+                               log(new Status(IStatus.ERROR,
+                                               ValgrindDebugPlugin.PI_DEBUG_CORE, ERROR,
+                                               MessageFormat.format(DebugCoreMessages.DebugPlugin_4,
+                                                               new String[] { badDefiner, id }), null));
+                       }
+               }
+       }
+
+       private void invalidStatusHandler(Exception e, String id) {
+               log(new Status(IStatus.ERROR, ValgrindDebugPlugin.PI_DEBUG_CORE, ERROR,
+                               MessageFormat.format(DebugCoreMessages.DebugPlugin_5,
+                                               new String[] { id }), e));
+       }
+
+       /**
+        * Key for status handler extensions - a plug-in identifier/code pair
+        */
+       class StatusHandlerKey {
+
+               String fPluginId;
+               int fCode;
+
+               StatusHandlerKey(String pluginId, int code) {
+                       fPluginId = pluginId;
+                       fCode = code;
+               }
+
+               public int hashCode() {
+                       return fPluginId.hashCode() + fCode;
+               }
+
+               public boolean equals(Object obj) {
+                       if (obj instanceof StatusHandlerKey) {
+                               StatusHandlerKey s = (StatusHandlerKey) obj;
+                               return fCode == s.fCode && fPluginId.equals(s.fPluginId);
+                       }
+                       return false;
+               }
+       }
+
+       /**
+        * Executes runnables after event dispatch is complete.
+        * 
+        * @since 3.0
+        */
+       class AsynchRunner implements ISafeRunnable {
+
+               private Runnable fRunnable = null;
+
+               void async(Runnable runnable) {
+                       fRunnable = runnable;
+                       SafeRunner.run(this);
+                       fRunnable = null;
+
+               }
+
+               /*
+                * (non-Javadoc)
+                * 
+                * @see
+                * org.eclipse.core.runtime.ISafeRunnable#handleException(java.lang.
+                * Throwable)
+                */
+               public void handleException(Throwable exception) {
+                       IStatus status = new Status(IStatus.ERROR, getUniqueIdentifier(),
+                                       ERROR, DebugCoreMessages.DebugPlugin_6, exception);
+                       log(status);
+               }
+
+               /*
+                * (non-Javadoc)
+                * 
+                * @see org.eclipse.core.runtime.ISafeRunnable#run()
+                */
+               public void run() throws Exception {
+                       fRunnable.run();
+               }
+
+       }
+
+       /**
+        * Filters and dispatches events in a safe runnable to handle any
+        * exceptions.
+        */
+       class EventNotifier implements ISafeRunnable {
+
+               private DebugEvent[] fEvents;
+               private IDebugEventSetListener fListener;
+               private IDebugEventFilter fFilter;
+               private int fMode;
+
+               /**
+                * @see org.eclipse.core.runtime.ISafeRunnable#handleException(java.lang.Throwable)
+                */
+               public void handleException(Throwable exception) {
+                       switch (fMode) {
+                       case NOTIFY_FILTERS:
+                               IStatus status = new Status(IStatus.ERROR,
+                                               getUniqueIdentifier(), ERROR,
+                                               DebugCoreMessages.DebugPlugin_7, exception);
+                               log(status);
+                               break;
+                       case NOTIFY_EVENTS:
+                               status = new Status(IStatus.ERROR, getUniqueIdentifier(),
+                                               ERROR, DebugCoreMessages.DebugPlugin_8, exception);
+                               log(status);
+                               break;
+                       default:
+                               break;
+                       }
+               }
+
+               /**
+                * @see org.eclipse.core.runtime.ISafeRunnable#run()
+                */
+               public void run() throws Exception {
+                       switch (fMode) {
+                       case NOTIFY_FILTERS:
+                               fEvents = fFilter.filterDebugEvents(fEvents);
+                               break;
+                       case NOTIFY_EVENTS:
+                               fListener.handleDebugEvents(fEvents);
+                               break;
+                       default:
+                               break;
+                       }
+               }
+
+               /**
+                * Filter and dispatch the given events. If an exception occurs in one
+                * listener, events are still fired to subsequent listeners.
+                * 
+                * @param events
+                *            debug events
+                */
+               void dispatch(DebugEvent[] events) {
+                       fEvents = events;
+                       Object[] filters = fEventFilters.getListeners();
+                       if (filters.length > 0) {
+                               fMode = NOTIFY_FILTERS;
+                               for (int i = 0; i < filters.length; i++) {
+                                       fFilter = (IDebugEventFilter) filters[i];
+                                       SafeRunner.run(this);
+                                       if (fEvents == null || fEvents.length == 0) {
+                                               return;
+                                       }
+                               }
+                       }
+
+                       fMode = NOTIFY_EVENTS;
+                       Object[] listeners = getEventListeners();
+                       if (DebugOptions.DEBUG_EVENTS) {
+                               for (int i = 0; i < fEvents.length; i++) {
+                                       System.out.println(fEvents[i]);
+                               }
+                       }
+                       for (int i = 0; i < listeners.length; i++) {
+                               fListener = (IDebugEventSetListener) listeners[i];
+                               SafeRunner.run(this);
+                       }
+                       fEvents = null;
+                       fFilter = null;
+                       fListener = null;
+               }
+
+       }
+
+       /**
+        * Creates and returns a new XML document.
+        * 
+        * @return a new XML document
+        * @throws CoreException
+        *             if unable to create a new document
+        * @since 3.0
+        */
+       public static Document newDocument() throws CoreException {
+               try {
+                       return LaunchManager.getDocument();
+               } catch (ParserConfigurationException e) {
+                       abort("Unable to create new XML document.", e); //$NON-NLS-1$
+               }
+               return null;
+       }
+
+       /**
+        * Serializes the given XML document into a string.
+        * 
+        * @param document
+        *            XML document to serialize
+        * @return a string representing the given document
+        * @throws CoreException
+        *             if unable to serialize the document
+        * @since 3.0
+        */
+       public static String serializeDocument(Document document)
+                       throws CoreException {
+               try {
+                       return LaunchManager.serializeDocument(document);
+               } catch (TransformerException e) {
+                       abort("Unable to serialize XML document.", e); //$NON-NLS-1$
+               } catch (IOException e) {
+                       abort("Unable to serialize XML document.", e); //$NON-NLS-1$
+               }
+               return null;
+       }
+
+       /**
+        * Parses the given string representing an XML document, returning its root
+        * element.
+        * 
+        * @param document
+        *            XML document as a string
+        * @return the document's root element
+        * @throws CoreException
+        *             if unable to parse the document
+        * @since 3.0
+        */
+       public static Element parseDocument(String document) throws CoreException {
+               Element root = null;
+               InputStream stream = null;
+               try {
+                       DocumentBuilder parser = DocumentBuilderFactory.newInstance()
+                                       .newDocumentBuilder();
+                       parser.setErrorHandler(new DefaultHandler());
+                       stream = new ByteArrayInputStream(document.getBytes("UTF8")); //$NON-NLS-1$
+                       root = parser.parse(stream).getDocumentElement();
+               } catch (ParserConfigurationException e) {
+                       abort("Unable to parse XML document.", e); //$NON-NLS-1$
+               } catch (FactoryConfigurationError e) {
+                       abort("Unable to parse XML document.", e); //$NON-NLS-1$
+               } catch (SAXException e) {
+                       abort("Unable to parse XML document.", e); //$NON-NLS-1$
+               } catch (IOException e) {
+                       abort("Unable to parse XML document.", e); //$NON-NLS-1$
+               } finally {
+                       try {
+                               if (stream != null) {
+                                       stream.close();
+                               }
+                       } catch (IOException e) {
+                               abort("Unable to parse XML document.", e); //$NON-NLS-1$
+                       }
+               }
+               return root;
+       }
+
+       /**
+        * Throws an exception with the given message and underlying exception.
+        * 
+        * @param message
+        *            error message
+        * @param exception
+        *            underlying exception, or <code>null</code>
+        * @throws CoreException
+        */
+       private static void abort(String message, Throwable exception)
+                       throws CoreException {
+               IStatus status = new Status(IStatus.ERROR,
+                               ValgrindDebugPlugin.getUniqueIdentifier(),
+                               ValgrindDebugPlugin.ERROR, message, exception);
+               throw new CoreException(status);
+       }
+
+       /**
+        * Utility class to parse command line arguments.
+        * 
+        * @since 3.1
+        */
+       private static class ArgumentParser {
+               private String fArgs;
+               private int fIndex = 0;
+               private int ch = -1;
+
+               public ArgumentParser(String args) {
+                       fArgs = args;
+               }
+
+               public String[] parseArguments() {
+                       List v = new ArrayList();
+
+                       ch = getNext();
+                       while (ch > 0) {
+                               if (Character.isWhitespace((char) ch)) {
+                                       ch = getNext();
+                               } else {
+                                       if (ch == '"') {
+                                               StringBuffer buf = new StringBuffer();
+                                               buf.append(parseString());
+                                               if (buf.length() == 0
+                                                               && Platform.getOS().equals(Constants.OS_WIN32)) {
+                                                       // empty string on windows platform
+                                                       buf.append("\"\""); //$NON-NLS-1$
+                                               }
+                                               v.add(buf.toString());
+                                       } else {
+                                               v.add(parseToken());
+                                       }
+                               }
+                       }
+
+                       String[] result = new String[v.size()];
+                       v.toArray(result);
+                       return result;
+               }
+
+               private int getNext() {
+                       if (fIndex < fArgs.length())
+                               return fArgs.charAt(fIndex++);
+                       return -1;
+               }
+
+               private String parseString() {
+                       ch = getNext();
+                       if (ch == '"') {
+                               ch = getNext();
+                               return ""; //$NON-NLS-1$
+                       }
+                       StringBuffer buf = new StringBuffer();
+                       while (ch > 0 && ch != '"') {
+                               if (ch == '\\') {
+                                       ch = getNext();
+                                       if (ch != '"') { // Only escape double quotes
+                                               buf.append('\\');
+                                       } else {
+                                               if (Platform.getOS().equals(Constants.OS_WIN32)) {
+                                                       // @see Bug 26870. Windows requires an extra escape
+                                                       // for embedded strings
+                                                       buf.append('\\');
+                                               }
+                                       }
+                               }
+                               if (ch > 0) {
+                                       buf.append((char) ch);
+                                       ch = getNext();
+                               }
+                       }
+                       ch = getNext();
+                       return buf.toString();
+               }
+
+               private String parseToken() {
+                       StringBuffer buf = new StringBuffer();
+
+                       while (ch > 0 && !Character.isWhitespace((char) ch)) {
+                               if (ch == '\\') {
+                                       ch = getNext();
+                                       if (Character.isWhitespace((char) ch)) {
+                                               // end of token, don't lose trailing backslash
+                                               buf.append('\\');
+                                               return buf.toString();
+                                       }
+                                       if (ch > 0) {
+                                               if (ch != '"') { // Only escape double quotes
+                                                       buf.append('\\');
+                                               } else {
+                                                       if (Platform.getOS().equals(Constants.OS_WIN32)) {
+                                                               // @see Bug 26870. Windows requires an extra
+                                                               // escape for embedded strings
+                                                               buf.append('\\');
+                                                       }
+                                               }
+                                               buf.append((char) ch);
+                                               ch = getNext();
+                                       } else if (ch == -1) { // Don't lose a trailing backslash
+                                               buf.append('\\');
+                                       }
+                               } else if (ch == '"') {
+                                       buf.append(parseString());
+                               } else {
+                                       buf.append((char) ch);
+                                       ch = getNext();
+                               }
+                       }
+                       return buf.toString();
+               }
+       }
+
+       /**
+        * Parses the given command line into separate arguments that can be passed
+        * to <code>DebugPlugin.exec(String[], File)</code>. Embedded quotes and
+        * slashes are escaped.
+        * 
+        * @param args
+        *            command line arguments as a single string
+        * @return individual arguments
+        * @since 3.1
+        */
+       public static String[] parseArguments(String args) {
+               if (args == null)
+                       return new String[0];
+               ArgumentParser parser = new ArgumentParser(args);
+               String[] res = parser.parseArguments();
+
+               return res;
+       }
+
+       /**
+        * Sets whether step filters should be applied to step commands. This
+        * setting is a global option applied to all registered debug targets.
+        * 
+        * @param useStepFilters
+        *            whether step filters should be applied to step commands
+        * @since 3.3
+        * @see org.eclipse.debug.core.model.IStepFilters
+        */
+       public static void setUseStepFilters(boolean useStepFilters) {
+               getStepFilterManager().setUseStepFilters(useStepFilters);
+       }
+
+       /**
+        * Returns whether step filters are applied to step commands.
+        * 
+        * @return whether step filters are applied to step commands
+        * @since 3.3
+        * @see org.eclipse.debug.core.model.IStepFilters
+        * @see org.eclipse.debug.core.commands.IStepFiltersHandler
+        */
+       public static boolean isUseStepFilters() {
+               return getStepFilterManager().isUseStepFilters();
+       }
+
+       /**
+        * Returns the step filter manager.
+        * 
+        * @return step filter manager
+        */
+       private static StepFilterManager getStepFilterManager() {
+               return ((LaunchManager) getDefault().getLaunchManager())
+                               .getStepFilterManager();
+       }
+
+       /**
+        * Returns an adapter of the specified type for the given object or
+        * <code>null</code> if none. The object itself is returned if it is an
+        * instance of the specified type. If the object is adaptable and does not
+        * subclass <code>PlatformObject</code>, and does not provide the specified
+        * adapter directly, the platform's adapter manager is consulted for an
+        * adapter.
+        * 
+        * @param element
+        *            element to retrieve adapter for
+        * @param type
+        *            adapter type
+        * @return adapter or <code>null</code>
+        * @since 3.4
+        */
+       public static Object getAdapter(Object element, Class type) {
+               Object adapter = null;
+               if (element != null) {
+                       if (type.isInstance(element)) {
+                               return element;
+                       } else {
+                               if (element instanceof IAdaptable) {
+                                       adapter = ((IAdaptable) element).getAdapter(type);
+                               }
+                               // for objects that don't subclass PlatformObject, check the
+                               // platform's adapter manager
+                               if (adapter == null && !(element instanceof PlatformObject)) {
+                                       adapter = Platform.getAdapterManager().getAdapter(element,
+                                                       type);
+                               }
+                               // force load the adapter in case it really is available
+                               if (adapter == null) {
+                                       adapter = Platform.getAdapterManager().loadAdapter(element,
+                                                       type.getName());
+                               }
+                       }
+               }
+               return adapter;
+       }
+
+}
diff --git a/org.eclipse.linuxtools.valgrind.launch.exe/src/org/eclipse/linuxtools/valgrind/launch/ValgrindLaunchConfigurationTabGroup.java b/org.eclipse.linuxtools.valgrind.launch.exe/src/org/eclipse/linuxtools/valgrind/launch/ValgrindLaunchConfigurationTabGroup.java
new file mode 100644 (file)
index 0000000..28e7606
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ *  Valgrind Launch Configuration Tab Group
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Jaewon Lim <jaewon81.lim@samsung.com>
+ * Wonhyoung Park <wonhyoung2.park@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.eclipse.linuxtools.valgrind.launch;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
+import org.eclipse.debug.ui.ILaunchConfigurationDialog;
+import org.eclipse.linuxtools.profiling.launch.ProfileLaunchConfigurationTabGroup;
+import org.tizen.nativecommon.launch.ui.TizenMainTab;
+
+public class ValgrindLaunchConfigurationTabGroup extends ProfileLaunchConfigurationTabGroup {
+
+       public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
+//             ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] {
+//                             new SMLCDTMainTab(false, true),
+//                             new CArgumentsTab(),
+//                             new ValgrindOptionsTab(),
+//                             new SMLCDTEnvironmentTab(),
+//                     //      new SboxSourceLookupTab()
+//                     };
+//                     
+//                     setTabs(tabs);
+//             
+//     }       
+               ArrayList<AbstractLaunchConfigurationTab> tabs = new ArrayList<AbstractLaunchConfigurationTab>();
+               tabs.add(new TizenMainTab());
+//             tabs.add(new TizenArgumentsTab());
+               tabs.addAll(Arrays.asList(getProfileTabs()));
+//             tabs.add(new TizenEnvironmentTab());
+//             tabs.add(new SboxSourceLookupTab());
+               
+               setTabs(tabs.toArray(new AbstractLaunchConfigurationTab[tabs.size()]));
+       
+}
+       
+               @Override
+       public AbstractLaunchConfigurationTab[] getProfileTabs() {
+               //bery at 20090715
+               return new AbstractLaunchConfigurationTab[] { new ValgrindOptionsTab() };
+       }
+}
diff --git a/org.eclipse.linuxtools.valgrind.launch.exe/src/org/eclipse/linuxtools/valgrind/launch/ValgrindLaunchShortcut.java b/org.eclipse.linuxtools.valgrind.launch.exe/src/org/eclipse/linuxtools/valgrind/launch/ValgrindLaunchShortcut.java
new file mode 100644 (file)
index 0000000..bb4c59c
--- /dev/null
@@ -0,0 +1,113 @@
+/*
+ *  Valgrind Launch Shortcut
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Jaewon Lim <jaewon81.lim@samsung.com>
+ * Wonhyoung Park <wonhyoung2.park@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+
+package org.eclipse.linuxtools.valgrind.launch;
+
+import org.eclipse.core.runtime.CoreException;
+
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.ui.IDebugUIConstants;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.linuxtools.profiling.launch.ProfileLaunchPlugin;
+import org.eclipse.linuxtools.profiling.launch.ProfileLaunchShortcut;
+import org.eclipse.ui.IEditorPart;
+
+
+public class ValgrindLaunchShortcut extends ProfileLaunchShortcut {
+       private boolean canInitialize; //bery 20090715
+       
+       public void launch(IEditorPart editor, String mode) {
+               int targetResult = ProfileLaunchPlugin.checkTarget();
+               if(targetResult == 0)
+               {
+                       ProfileLaunchShortcut.showErrorDialog(Messages.getString("ValgrindOptionsTab.cannotrun"),
+                                       Messages.getString("ValgrindOptionsTab.noemul"), null);
+               }
+               else if(targetResult == 1)
+               {
+                       ProfileLaunchShortcut.showErrorDialog(Messages.getString("ValgrindOptionsTab.cannotrun"),
+                                       Messages.getString("ValgrindOptionsTab.noemul") + "\n" +
+                                       Messages.getString("ValgrindOptionsTab.inemul"), null);
+               }
+               else
+               {
+                       super.launch(editor, mode);
+               }
+       }
+
+       public void launch(ISelection selection, String mode) {
+               int targetResult = ProfileLaunchPlugin.checkTarget();
+               if(targetResult == 0)
+               {
+                       ProfileLaunchShortcut.showErrorDialog(Messages.getString("ValgrindOptionsTab.cannotrun"),
+                                       Messages.getString("ValgrindOptionsTab.noemul"), null);
+               }
+               else if(targetResult == 1)
+               {
+                       ProfileLaunchShortcut.showErrorDialog(Messages.getString("ValgrindOptionsTab.cannotrun"),
+                                       Messages.getString("ValgrindOptionsTab.noemul") + "\n" +
+                                       Messages.getString("ValgrindOptionsTab.inemul"), null);
+               }
+               else
+               {
+                       super.launch(selection, mode);
+               }
+       }
+
+       @Override
+       protected ILaunchConfigurationType getLaunchConfigType() {
+               
+               return getLaunchManager().getLaunchConfigurationType("org.eclipse.linuxtools.valgrind.launch.valgrindLaunch");
+       }
+
+       @Override
+       protected void setDefaultProfileAttributes(
+                       ILaunchConfigurationWorkingCopy wc) throws CoreException {
+               //-- bery 20090715
+//             if(TargetConnectionControl.isSimulator()){
+                       setCanInitialize(true);
+/*                     
+               }else{
+                       String error = "The Valgrind does not support the ARM target ";
+                       String reason = "An error occurred when the real target is selected. Please check whether your target is Simulator(i686)";
+                       ValgrindOptionsTab.showErrorDialog(error, reason , null); //$NON-NLS-1$
+                       setCanInitialize(false);
+       //              return;
+               }
+*/
+               // commented by greatim at 2011.06.01 for fresh ide
+               //-- bery 20090715
+//             wc.setAttribute(ISMLCDTLaunchConstants.ATTR_LAUNCH_MODE, "valgrind");
+//             wc.setAttribute(ISMLCDTLaunchConstants.ATTR_SKIP_DOWNLOAD, false);
+//             wc.setAttribute(ISMLCDTLaunchConstants.ATTR_GDBSERVER_PORT, "9999");
+               wc.setAttribute(IDebugUIConstants.ATTR_LAUNCH_IN_BACKGROUND, true);
+       }
+
+       public void setCanInitialize(boolean canInitialize) {
+               this.canInitialize = canInitialize;
+       }
+
+       public boolean isCanInitialize() {
+               return canInitialize;
+       }
+}
diff --git a/org.eclipse.linuxtools.valgrind.launch.exe/src/org/eclipse/linuxtools/valgrind/launch/ValgrindRuntimeProcess.java b/org.eclipse.linuxtools.valgrind.launch.exe/src/org/eclipse/linuxtools/valgrind/launch/ValgrindRuntimeProcess.java
new file mode 100644 (file)
index 0000000..6fe049c
--- /dev/null
@@ -0,0 +1,468 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.valgrind.launch;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.PlatformObject;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.DebugEvent;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.model.IDebugTarget;
+import org.eclipse.debug.core.model.IProcess;
+import org.eclipse.debug.core.model.IStreamsProxy;
+import org.eclipse.debug.internal.core.DebugCoreMessages;
+import org.eclipse.debug.internal.core.NullStreamsProxy;
+import org.eclipse.debug.internal.core.StreamsProxy;
+
+import org.tizen.common.connection.ConnectionPlugin;
+import org.tizen.sdblib.SdbCommandRejectedException;
+
+/**
+ * Standard implementation of an <code>IProcess</code> that wrappers a system
+ * process (<code>java.lang.Process</code>).
+ * <p>
+ * Clients may subclass this class. Clients that need to replace the
+ * implementation of a streams proxy associated with an <code>IProcess</code>
+ * should subclass this class. Generally clients should not instantiate this
+ * class directly, but should instead call
+ * <code>DebugPlugin.newProcess(...)</code>, which can delegate to an
+ * <code>IProcessFactory</code> if one is referenced by the associated launch
+ * configuration.
+ * </p>
+ * 
+ * @see org.eclipse.debug.core.model.IProcess
+ * @see org.eclipse.debug.core.IProcessFactory
+ * @since 3.0
+ */
+public class ValgrindRuntimeProcess extends PlatformObject implements IProcess {
+
+       private static final int MAX_WAIT_FOR_DEATH_ATTEMPTS = 10;
+       private static final int TIME_TO_WAIT_FOR_THREAD_DEATH = 500; // ms
+
+       /**
+        * The launch this process is contained in
+        */
+       private ILaunch fLaunch;
+
+       /**
+        * The system process represented by this <code>IProcess</code>
+        */
+       private Process fProcess;
+
+       /**
+        * This process's exit value
+        */
+       private int fExitValue;
+
+       /**
+        * The monitor which listens for this runtime process' system process to
+        * terminate.
+        */
+       private ProcessMonitorThread fMonitor;
+
+       /**
+        * The streams proxy for this process
+        */
+       private IStreamsProxy fStreamsProxy;
+
+       /**
+        * The name of the process
+        */
+       private String fName;
+
+       /**
+        * Whether this process has been terminated
+        */
+       private boolean fTerminated;
+
+       /**
+        * Table of client defined attributes
+        */
+       private Map fAttributes;
+
+       /**
+        * Whether output from the process should be captured or swallowed
+        */
+       private boolean fCaptureOutput = true;
+
+       /**
+        * Constructs a RuntimeProcess on the given system process with the given
+        * name, adding this process to the given launch.
+        * 
+        * @param launch
+        *            the parent launch of this process
+        * @param process
+        *            underlying system process
+        * @param name
+        *            the label used for this process
+        * @param attributes
+        *            map of attributes used to initialize the attributes of this
+        *            process, or <code>null</code> if none
+        */
+       public ValgrindRuntimeProcess(ILaunch launch, Process process, String name,
+                       Map attributes) {
+               setLaunch(launch);
+               initializeAttributes(attributes);
+               fProcess = process;
+               fName = name;
+               fTerminated = true;
+               try {
+                       fExitValue = process.exitValue();
+               } catch (IllegalThreadStateException e) {
+                       fTerminated = false;
+               }
+
+               String captureOutput = launch
+                               .getAttribute(DebugPlugin.ATTR_CAPTURE_OUTPUT);
+               fCaptureOutput = !("false".equals(captureOutput)); //$NON-NLS-1$
+
+               fStreamsProxy = createStreamsProxy();
+               fMonitor = new ProcessMonitorThread(this);
+               fMonitor.start();
+               launch.addProcess(this);
+               fireCreationEvent();
+       }
+
+       /**
+        * Initialize the attributes of this process to those in the given map.
+        * 
+        * @param attributes
+        *            attribute map or <code>null</code> if none
+        */
+       private void initializeAttributes(Map attributes) {
+               if (attributes != null) {
+                       Iterator keys = attributes.keySet().iterator();
+                       while (keys.hasNext()) {
+                               String key = (String) keys.next();
+                               setAttribute(key, (String) attributes.get(key));
+                       }
+               }
+       }
+
+       /**
+        * @see ITerminate#canTerminate()
+        */
+       public synchronized boolean canTerminate() {
+               return !fTerminated;
+       }
+
+       /**
+        * @see IProcess#getLabel()
+        */
+       public String getLabel() {
+               return fName;
+       }
+
+       /**
+        * Sets the launch this process is contained in
+        * 
+        * @param launch
+        *            the launch this process is contained in
+        */
+       protected void setLaunch(ILaunch launch) {
+               fLaunch = launch;
+       }
+
+       /**
+        * @see IProcess#getLaunch()
+        */
+       public ILaunch getLaunch() {
+               return fLaunch;
+       }
+
+       /**
+        * Returns the underlying system process associated with this process.
+        * 
+        * @return system process
+        */
+       protected Process getSystemProcess() {
+               return fProcess;
+       }
+
+       /**
+        * @see ITerminate#isTerminated()
+        */
+       public synchronized boolean isTerminated() {
+               return fTerminated;
+       }
+
+       public static void runCommand(String command) {
+
+               try {
+                       ConnectionPlugin.getDefault().getCurrentDevice()
+                                       .executeShellCommand(command);
+               } catch (SdbCommandRejectedException e) {
+                       e.printStackTrace();
+               } catch (IOException e) {
+                       e.printStackTrace();
+               }
+       }
+
+       /**
+        * @see ITerminate#terminate()
+        */
+       public void terminate() throws DebugException {
+               runCommand("ps | grep valgrind | grep -v grep | awk '{print \"kill -3 \" $1}' | sh");
+               runCommand("ps ax | grep valgrind | grep -v grep | awk '{print \"kill -3 \" $1}' | sh");
+       }
+
+       /**
+        * Notification that the system process associated with this process has
+        * terminated.
+        */
+       protected void terminated() {
+               if (fStreamsProxy instanceof StreamsProxy) {
+                       ((StreamsProxy) fStreamsProxy).close();
+               }
+
+               // Avoid calling IProcess.exitValue() inside a sync section (Bug
+               // 311813).
+               int exitValue = -1;
+               boolean running = false;
+               try {
+                       exitValue = fProcess.exitValue();
+               } catch (IllegalThreadStateException ie) {
+                       running = true;
+               }
+
+               synchronized (this) {
+                       fTerminated = true;
+                       if (!running) {
+                               fExitValue = exitValue;
+                       }
+                       fProcess = null;
+               }
+               fireTerminateEvent();
+       }
+
+       /**
+        * @see IProcess#getStreamsProxy()
+        */
+       public IStreamsProxy getStreamsProxy() {
+               if (!fCaptureOutput) {
+                       return null;
+               }
+               return fStreamsProxy;
+       }
+
+       /**
+        * Creates and returns the streams proxy associated with this process.
+        * 
+        * @return streams proxy
+        */
+       protected IStreamsProxy createStreamsProxy() {
+               if (!fCaptureOutput) {
+                       return new NullStreamsProxy(getSystemProcess());
+               }
+               String encoding = getLaunch().getAttribute(
+                               DebugPlugin.ATTR_CONSOLE_ENCODING);
+               return new StreamsProxy(getSystemProcess(), encoding);
+       }
+
+       /**
+        * Fires a creation event.
+        */
+       protected void fireCreationEvent() {
+               fireEvent(new DebugEvent(this, DebugEvent.CREATE));
+       }
+
+       /**
+        * Fires the given debug event.
+        * 
+        * @param event
+        *            debug event to fire
+        */
+       protected void fireEvent(DebugEvent event) {
+               DebugPlugin manager = DebugPlugin.getDefault();
+               if (manager != null) {
+                       manager.fireDebugEventSet(new DebugEvent[] { event });
+               }
+       }
+
+       /**
+        * Fires a terminate event.
+        */
+       protected void fireTerminateEvent() {
+               fireEvent(new DebugEvent(this, DebugEvent.TERMINATE));
+       }
+
+       /**
+        * Fires a change event.
+        */
+       protected void fireChangeEvent() {
+               fireEvent(new DebugEvent(this, DebugEvent.CHANGE));
+       }
+
+       /**
+        * @see IProcess#setAttribute(String, String)
+        */
+       public void setAttribute(String key, String value) {
+               if (fAttributes == null) {
+                       fAttributes = new HashMap(5);
+               }
+               Object origVal = fAttributes.get(key);
+               if (origVal != null && origVal.equals(value)) {
+                       return; // nothing changed.
+               }
+
+               fAttributes.put(key, value);
+               fireChangeEvent();
+       }
+
+       /**
+        * @see IProcess#getAttribute(String)
+        */
+       public String getAttribute(String key) {
+               if (fAttributes == null) {
+                       return null;
+               }
+               return (String) fAttributes.get(key);
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
+        */
+       public Object getAdapter(Class adapter) {
+               if (adapter.equals(IProcess.class)) {
+                       return this;
+               }
+               if (adapter.equals(IDebugTarget.class)) {
+                       ILaunch launch = getLaunch();
+                       IDebugTarget[] targets = launch.getDebugTargets();
+                       for (int i = 0; i < targets.length; i++) {
+                               if (this.equals(targets[i].getProcess())) {
+                                       return targets[i];
+                               }
+                       }
+                       return null;
+               }
+               if (adapter.equals(ILaunch.class)) {
+                       return getLaunch();
+               }
+               // CONTEXTLAUNCHING
+               if (adapter.equals(ILaunchConfiguration.class)) {
+                       return getLaunch().getLaunchConfiguration();
+               }
+               return super.getAdapter(adapter);
+       }
+
+       /**
+        * @see IProcess#getExitValue()
+        */
+       public synchronized int getExitValue() throws DebugException {
+               if (isTerminated()) {
+                       return fExitValue;
+               }
+               throw new DebugException(
+                               new Status(
+                                               IStatus.ERROR,
+                                               DebugPlugin.getUniqueIdentifier(),
+                                               DebugException.TARGET_REQUEST_FAILED,
+                                               DebugCoreMessages.RuntimeProcess_Exit_value_not_available_until_process_terminates__1,
+                                               null));
+       }
+
+       /**
+        * Monitors a system process, waiting for it to terminate, and then notifies
+        * the associated runtime process.
+        */
+       class ProcessMonitorThread extends Thread {
+
+               /**
+                * Whether the thread has been told to exit.
+                */
+               protected boolean fExit;
+               /**
+                * The underlying <code>java.lang.Process</code> being monitored.
+                */
+               protected Process fOSProcess;
+               /**
+                * The <code>IProcess</code> which will be informed when this monitor
+                * detects that the underlying process has terminated.
+                */
+               protected ValgrindRuntimeProcess fRuntimeProcess;
+
+               /**
+                * The <code>Thread</code> which is monitoring the underlying process.
+                */
+               protected Thread fThread;
+
+               /**
+                * A lock protecting access to <code>fThread</code>.
+                */
+               private final Object fThreadLock = new Object();
+
+               /**
+                * @see Thread#run()
+                */
+               public void run() {
+                       synchronized (fThreadLock) {
+                               if (fExit) {
+                                       return;
+                               }
+                               fThread = Thread.currentThread();
+                       }
+                       while (fOSProcess != null) {
+                               try {
+                                       fOSProcess.waitFor();
+                               } catch (InterruptedException ie) {
+                                       // clear interrupted state
+                                       Thread.interrupted();
+                               } finally {
+                                       fOSProcess = null;
+                                       fRuntimeProcess.terminated();
+                               }
+                       }
+                       fThread = null;
+               }
+
+               /**
+                * Creates a new process monitor and starts monitoring the process for
+                * termination.
+                * 
+                * @param process
+                *            process to monitor for termination
+                */
+               public ProcessMonitorThread(ValgrindRuntimeProcess process) {
+                       super(DebugCoreMessages.ProcessMonitorJob_0);
+                       setDaemon(true);
+                       fRuntimeProcess = process;
+                       fOSProcess = process.getSystemProcess();
+               }
+
+               /**
+                * Kills the monitoring thread.
+                * 
+                * This method is to be useful for dealing with the error case of an
+                * underlying process which has not informed this monitor of its
+                * termination.
+                */
+               protected void killThread() {
+                       synchronized (fThreadLock) {
+                               if (fThread == null) {
+                                       fExit = true;
+                               } else {
+                                       fThread.interrupt();
+                               }
+                       }
+               }
+       }
+}
diff --git a/org.eclipse.linuxtools.valgrind.launch/.classpath b/org.eclipse.linuxtools.valgrind.launch/.classpath
new file mode 100644 (file)
index 0000000..ad32c83
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+       <classpathentry kind="src" path="src"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.eclipse.linuxtools.valgrind.launch/.project b/org.eclipse.linuxtools.valgrind.launch/.project
new file mode 100644 (file)
index 0000000..21b8833
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.eclipse.linuxtools.valgrind.launch</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.ManifestBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.SchemaBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.pde.PluginNature</nature>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>
diff --git a/org.eclipse.linuxtools.valgrind.launch/.settings/org.eclipse.core.resources.prefs b/org.eclipse.linuxtools.valgrind.launch/.settings/org.eclipse.core.resources.prefs
new file mode 100644 (file)
index 0000000..069ae7e
--- /dev/null
@@ -0,0 +1,3 @@
+#Wed Dec 01 09:13:45 CET 2010
+eclipse.preferences.version=1
+encoding/<project>=UTF-8
diff --git a/org.eclipse.linuxtools.valgrind.launch/.settings/org.eclipse.core.runtime.prefs b/org.eclipse.linuxtools.valgrind.launch/.settings/org.eclipse.core.runtime.prefs
new file mode 100644 (file)
index 0000000..0c50a64
--- /dev/null
@@ -0,0 +1,3 @@
+#Tue Dec 14 16:36:51 CET 2010
+eclipse.preferences.version=1
+line.separator=\n
diff --git a/org.eclipse.linuxtools.valgrind.launch/ChangeLog b/org.eclipse.linuxtools.valgrind.launch/ChangeLog
new file mode 100644 (file)
index 0000000..dfceaf7
--- /dev/null
@@ -0,0 +1,11 @@
+2009-01-05  Elliott Baron  <ebaron@redhat.com>
+
+       * ValgrindLaunchConfigurationDelegate: Graceful handling for absence of
+       Valgrind. Also Valgrind view will display the absolute path of valgrind
+       that was launched.
+       * messages.properties: New key.
+
+2009-01-05  Elliott Baron  <ebaron@redhat.com>
+
+       * META-INF/MANIFEST.MF: Changed version to 0.1.0.
+       * build.properties: Include about.html and icons.
\ No newline at end of file
diff --git a/org.eclipse.linuxtools.valgrind.launch/META-INF/MANIFEST.MF b/org.eclipse.linuxtools.valgrind.launch/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..4a6864b
--- /dev/null
@@ -0,0 +1,19 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Tizen SDK Valgrind Launch
+Bundle-SymbolicName: org.eclipse.linuxtools.valgrind.launch;singleton:=true
+Bundle-Version: 1.3.18.qualifier
+Bundle-Activator: org.eclipse.linuxtools.valgrind.launch.ValgrindLaunchPlugin
+Bundle-Vendor: Eclipse Linux Tools
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime;bundle-version="3.4.0",
+ org.eclipse.core.variables;bundle-version="3.2.100",
+ org.eclipse.debug.ui;bundle-version="3.4.2",
+ org.eclipse.ui.ide;bundle-version="3.4.2",
+ org.eclipse.cdt.launch;bundle-version="5.0.2",
+ org.eclipse.linuxtools.profiling.launch,
+ org.eclipse.linuxtools.valgrind.core
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-ActivationPolicy: lazy
+Export-Package: org.eclipse.linuxtools.valgrind.launch
+Bundle-Localization: plugin
diff --git a/org.eclipse.linuxtools.valgrind.launch/NOTICE b/org.eclipse.linuxtools.valgrind.launch/NOTICE
new file mode 100644 (file)
index 0000000..6126989
--- /dev/null
@@ -0,0 +1,50 @@
+2009-10-02 SPRC SDK Team <d.kozinski@samsung.com>
+       * MANIFEST.MF : modify dependency plugins
+       * ValgrindLaunchPlugin.java : code refactoring
+
+2010-02-10 SPRC SDK Team <d.kozinski@samsung.com>
+       * .classpath : change java runtime environment
+       * org.eclipse.jdt.core.prefs : remove file
+       * ValgrindOptionsTab.java : commented some instruction
+
+2010-03-11 SPRC SDK Team <d.kozinski@samsung.com>
+       * ValgrindOptionsTab.java : add help string
+
+2010-03-29 HyungJong, Shin <hj_shin@samsung.com>
+       * ValgrindOptionsTab.java : bugfix : make the OptionTab of valgrind scrollable.
+
+2010-03-29 Lukasz Czaplinski <l.czaplinski@daily-build.(none)>
+       * ValgrindOptionsTab.java : Fixes for sshconnectorservice debugging
+
+2010-08-26 HyungJong, Shin <hj_shin@samsung.com>
+       * ValgrindOptionsTab.java : modify some import, modify target control code
+
+2010-10-07 DongGi Jang <dg0402.jang.samsung.com>
+       * ValgrindOptionsTab.java : Enabling to lauch valgrind profiler in a real device
+       
+2010-11-05 sdk <sdk@sdk-laptop.(none)>
+       * MANIFEST.MF : changed some package name
+       * IValgrindLaunchDelegate.java : changed some package name
+       * ValgrindOptionsTab.java : changed some package name
+       
+2011-06-09 jaewon81.lim <jaewon81.lim@samsung.com>
+       * MANIFEST.MF : rearrange plugins dependency
+
+2011-07-13 jaewon81.lim <jaewon81.lim@samsung.com>
+       * MANIFEST.MF : modified import package name
+       * IValgrindLaunchDelegate.java : modified import package name
+       
+2011-08-22 joogwan.kim <joogwan.kim@samsung.com>
+       * MANIFEST.MF : Change plug-in name
+       * IValgrindLaunchDelegate.java : Change plug-in name
+
+2011-11-16 wonhyoung2.park <wonhyoung2.park@samsung.com>
+       * IValgrindLaunchDelegate.java : Profiler sdb apply
+       * ValgrindOptionsTab.java : Profiler sdb apply
+       * MANIFEST.MF : remove dependency of unused plugin
+
+2011-11-30 wonhyoung2.park <wonhyoung2.park@samsung.com>
+       * MANIFEST.MF : provider and plugin name modify
+
+2011-12-19 wonhyoung2.park <wonhyoung2.park@samsung.com>
+       * ValgrindLaunchPlugin.java :package path setting modify
diff --git a/org.eclipse.linuxtools.valgrind.launch/about.html b/org.eclipse.linuxtools.valgrind.launch/about.html
new file mode 100644 (file)
index 0000000..e6a2741
--- /dev/null
@@ -0,0 +1,26 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"><head>
+
+
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>About</title>
+</head><body lang="EN-US">
+<h2>About This Content</h2>
+<p>October 24, 2008</p>        
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in ("Content").  Unless otherwise 
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 ("EPL").  A copy of the EPL is available 
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, "Program" will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is 
+being redistributed by another party ("Redistributor") and different terms and conditions may
+apply to your use of any object code in the Content.  Check the Redistributor's license that was 
+provided with the Content.  If no such license exists, contact the Redistributor.  Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body></html>
\ No newline at end of file
diff --git a/org.eclipse.linuxtools.valgrind.launch/build.properties b/org.eclipse.linuxtools.valgrind.launch/build.properties
new file mode 100644 (file)
index 0000000..37dea1a
--- /dev/null
@@ -0,0 +1,10 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               .,\
+               plugin.properties,\
+               about.html,\
+               icons/,\
+               schema/
+javacSource = 1.6
+javacTarget = 1.6
diff --git a/org.eclipse.linuxtools.valgrind.launch/icons/valgrind-icon.png b/org.eclipse.linuxtools.valgrind.launch/icons/valgrind-icon.png
new file mode 100644 (file)
index 0000000..dc1dede
Binary files /dev/null and b/org.eclipse.linuxtools.valgrind.launch/icons/valgrind-icon.png differ
diff --git a/org.eclipse.linuxtools.valgrind.launch/icons/valgrind-icon.png.1 b/org.eclipse.linuxtools.valgrind.launch/icons/valgrind-icon.png.1
new file mode 100644 (file)
index 0000000..099bbda
Binary files /dev/null and b/org.eclipse.linuxtools.valgrind.launch/icons/valgrind-icon.png.1 differ
diff --git a/org.eclipse.linuxtools.valgrind.launch/plugin.properties b/org.eclipse.linuxtools.valgrind.launch/plugin.properties
new file mode 100644 (file)
index 0000000..c47b2b6
--- /dev/null
@@ -0,0 +1,7 @@
+#Properties file for org.eclipse.linuxtools.valgrind.launch
+launchConfigurationType.name.0 = Profile With Valgrind
+launchConfigurationTabGroup.description.0 = Profile C/C++ Application Using Valgrind
+shortcut.label.0 = Profile With Valgrind
+Bundle-Vendor.0 = Eclipse.org
+Bundle-Name.0 = Valgrind Launch Plug-in (Incubation)
+extension-point.name.0 = valgrindTools
\ No newline at end of file
diff --git a/org.eclipse.linuxtools.valgrind.launch/schema/org.eclipse.linuxtools.valgrind.launch.valgrindTools.exsd b/org.eclipse.linuxtools.valgrind.launch/schema/org.eclipse.linuxtools.valgrind.launch.valgrindTools.exsd
new file mode 100644 (file)
index 0000000..85568d5
--- /dev/null
@@ -0,0 +1,127 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.linuxtools.valgrind.launch" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+      <appinfo>
+         <meta.schema plugin="org.eclipse.linuxtools.valgrind.launch" id="valgrindTool" name="Valgrind Tool"/>
+      </appinfo>
+      <documentation>
+         This extension point provides Valgrind tools the ability to contribute options to the Valgrind &lt;code&gt;ILaunchConfigurationTab&lt;/code&gt; and to deploy UI to the Valgrind view.
+      </documentation>
+   </annotation>
+
+   <element name="extension">
+      <annotation>
+         <appinfo>
+            <meta.element />
+         </appinfo>
+      </annotation>
+      <complexType>
+         <sequence minOccurs="1" maxOccurs="unbounded">
+            <element ref="tool"/>
+         </sequence>
+         <attribute name="point" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="id" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appinfo>
+                  <meta.attribute translatable="true"/>
+               </appinfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <element name="tool">
+      <complexType>
+         <attribute name="id" type="string" use="required">
+            <annotation>
+               <documentation>
+                  The unique identifier for this tool
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string" use="required">
+            <annotation>
+               <documentation>
+                  The name of this tool as Valgrind expects it as an argument to &lt;code&gt;--tool&lt;/code&gt;
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="page" type="string" use="required">
+            <annotation>
+               <documentation>
+                  Class to contribute controls used to add options for this tool in the &lt;code&gt;ILaunchConfigurationTab&lt;/code&gt; for Valgrind.
+Must implement &lt;code&gt;IValgrindToolPage&lt;/code&gt;
+               </documentation>
+               <appinfo>
+                  <meta.attribute kind="java" basedOn=":org.eclipse.linuxtools.valgrind.launch.IValgrindToolPage"/>
+               </appinfo>
+            </annotation>
+         </attribute>
+         <attribute name="delegate" type="string" use="required">
+            <annotation>
+               <documentation>
+                  The class that will receive control from the &lt;code&gt;ValgrindLaunchConfigurationDelegate&lt;/code&gt; once Valgrind has launched.
+               </documentation>
+               <appinfo>
+                  <meta.attribute kind="java" basedOn=":org.eclipse.linuxtools.valgrind.launch.IValgrindLaunchDelegate"/>
+               </appinfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="since"/>
+      </appinfo>
+      <documentation>
+         [Enter the first release in which this extension point appears.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="examples"/>
+      </appinfo>
+      <documentation>
+         [Enter extension point usage example here.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="apiinfo"/>
+      </appinfo>
+      <documentation>
+         [Enter API information here.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="implementation"/>
+      </appinfo>
+      <documentation>
+         [Enter information about supplied implementation of this extension point.]
+      </documentation>
+   </annotation>
+
+
+</schema>
diff --git a/org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/valgrind/launch/IValgrindLaunchDelegate.java b/org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/valgrind/launch/IValgrindLaunchDelegate.java
new file mode 100644 (file)
index 0000000..5ffd3e8
--- /dev/null
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Elliott Baron <ebaron@redhat.com> - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.valgrind.launch;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.linuxtools.valgrind.core.ValgrindCommand;
+/**
+ * Interface for declaring a tool-specific delegate for a Valgrind
+ * <code>LaunchConfiguration</code>.
+ */
+public interface IValgrindLaunchDelegate {
+
+       /**
+        * To be called after Valgrind has been called for a given launch.
+        * This method is responsible for parsing Valgrind's output as needed
+        * by this tool
+        * @param command - The Valgrind instance that just ran
+        * @param config - the configuration to launch
+        * @param launch - the launch object to contribute processes and debug
+        *  targets to
+        * @param monitor - to report progress
+        * @throws CoreException - if this method fails
+        * @throws Exception 
+        */
+       public void launch(ValgrindCommand command, ILaunchConfiguration config, ILaunch launch, IProgressMonitor monitor) throws CoreException, Exception;
+
+       /**
+        * Parses attributes of an <code>ILaunchConfiguration</code> into an array
+        * of arguments to be passed to Valgrind
+        * @param command - The Valgrind instance about to run
+        * @param config - the <code>ILaunchConfiguration</code>
+        * @return an array of arguments that can appended to a <code>valgrind</code> command
+        * @throws CoreException - retrieving attributes from config failed
+        */
+       public String[] getCommandArray(ValgrindCommand command, ILaunchConfiguration config) throws CoreException;
+       
+}
diff --git a/org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/valgrind/launch/IValgrindToolPage.java b/org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/valgrind/launch/IValgrindToolPage.java
new file mode 100644 (file)
index 0000000..2b02a20
--- /dev/null
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Elliott Baron <ebaron@redhat.com> - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.valgrind.launch;
+
+import org.eclipse.debug.ui.ILaunchConfigurationTab;
+
+/**
+ * Interface for declaring the specifics of integrating a Valgrind tool
+ * into this plugin.
+ */
+public interface IValgrindToolPage extends ILaunchConfigurationTab {
+       
+}
diff --git a/org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/valgrind/launch/Messages.java b/org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/valgrind/launch/Messages.java
new file mode 100644 (file)
index 0000000..399a126
--- /dev/null
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Elliott Baron <ebaron@redhat.com> - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.valgrind.launch;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class Messages {
+       private static final String BUNDLE_NAME = "org.eclipse.linuxtools.valgrind.launch.messages"; //$NON-NLS-1$
+
+       private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
+                       .getBundle(BUNDLE_NAME);
+
+       private Messages() {
+       }
+
+       public static String getString(String key) {
+               try {
+                       return RESOURCE_BUNDLE.getString(key);
+               } catch (MissingResourceException e) {
+                       return '!' + key + '!';
+               }
+       }
+}
diff --git a/org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/valgrind/launch/ValgrindLaunchPlugin.java b/org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/valgrind/launch/ValgrindLaunchPlugin.java
new file mode 100644 (file)
index 0000000..312fc8d
--- /dev/null
@@ -0,0 +1,178 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Elliott Baron <ebaron@redhat.com> - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.valgrind.launch;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.Set;
+
+import org.eclipse.cdt.launch.LaunchUtils;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+public class ValgrindLaunchPlugin extends AbstractUIPlugin {
+
+       // The plug-in ID
+       public static final String PLUGIN_ID = "org.eclipse.linuxtools.valgrind.launch"; //$NON-NLS-1$
+       public static final String LAUNCH_ID = PLUGIN_ID + ".valgrindLaunch"; //$NON-NLS-1$
+       
+       public static final String RESULT_DIR = "/tmp/valgrind_result/";
+       
+       // Extension point constants
+       public static final String TOOL_EXT_ID = "valgrindTools"; //$NON-NLS-1$
+       public static final String TOOL_EXT_DEFAULT = PLUGIN_ID + ".memcheck"; //$NON-NLS-1$
+       //public static final String TOOL_EXT_DEFAULT = PLUGIN_ID + ".massif"; //$NON-NLS-1$
+       
+       protected static final String EXT_ELEMENT = "tool"; //$NON-NLS-1$
+       protected static final String EXT_ATTR_NAME = "name"; //$NON-NLS-1$
+       protected static final String EXT_ATTR_ID = "id"; //$NON-NLS-1$
+       protected static final String EXT_ATTR_PAGE = "page"; //$NON-NLS-1$
+       protected static final String EXT_ATTR_DELEGATE = "delegate"; //$NON-NLS-1$
+       
+       protected HashMap<String, IConfigurationElement> toolMap; 
+       
+       // The shared instance
+       private static ValgrindLaunchPlugin plugin;
+       
+       /**
+        * The constructor
+        */
+       public ValgrindLaunchPlugin() {
+       }
+
+       /*
+        * (non-Javadoc)
+        * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+        */
+       public void start(BundleContext context) throws Exception {
+               super.start(context);
+               plugin = this;
+       }
+
+       /*
+        * (non-Javadoc)
+        * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+        */
+       public void stop(BundleContext context) throws Exception {
+               plugin = null;
+               super.stop(context);
+       }
+
+       /**
+        * Returns the shared instance
+        *
+        * @return the shared instance
+        */
+       public static ValgrindLaunchPlugin getDefault() {
+               return plugin;
+       }
+       
+       public String[] getRegisteredToolIDs() {
+               Set<String> ids = getToolMap().keySet();
+               return ids.toArray(new String[ids.size()]);
+       }
+       
+       public String getToolName(String id) {
+               String name = null;
+               IConfigurationElement config = getToolMap().get(id);
+               if (config != null) {
+                       name = config.getAttribute(EXT_ATTR_NAME);
+               }
+               return name;
+       }
+       
+       public IValgrindToolPage getToolPage(String id) throws CoreException {
+               IValgrindToolPage tab = null;
+               IConfigurationElement config = getToolMap().get(id);
+               if (config != null) {
+                       Object obj = config.createExecutableExtension(EXT_ATTR_PAGE);
+                       if (obj instanceof IValgrindToolPage) {
+                               tab = (IValgrindToolPage) obj;
+                       }
+               }
+               if (tab == null) {
+                       throw new CoreException(new Status(IStatus.ERROR, PLUGIN_ID, Messages.getString("ValgrindLaunchPlugin.Cannot_retrieve_page"))); //$NON-NLS-1$
+               }
+               return tab;
+       }
+       
+       public IValgrindLaunchDelegate getToolDelegate(String id) throws CoreException {
+               IValgrindLaunchDelegate delegate = null;
+               IConfigurationElement config = getToolMap().get(id);
+               if (config != null) {
+                       Object obj = config.createExecutableExtension(EXT_ATTR_DELEGATE);
+                       if (obj instanceof IValgrindLaunchDelegate) {
+                               delegate = (IValgrindLaunchDelegate) obj;
+                       }
+               }
+               if (delegate == null) {
+                       throw new CoreException(new Status(IStatus.ERROR, PLUGIN_ID, Messages.getString("ValgrindLaunchPlugin.Cannot_retrieve_delegate"))); //$NON-NLS-1$
+               }
+               return delegate;
+       }
+       
+       public File parseWSPath(String strpath) throws CoreException {
+               strpath = LaunchUtils.getStringVariableManager().performStringSubstitution(strpath);
+               IPath path = new Path(strpath);
+               File suppfile = null;
+               if (path.isAbsolute()) {
+                       suppfile = new File(path.toOSString());
+               }
+               else {
+                       IResource res = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
+                       if (res != null) {
+                               IPath absPath = res.getLocation();
+                               if (absPath != null) {
+                                       suppfile = absPath.toFile();
+                               }
+                       }
+               }               
+               return suppfile;
+       }
+       
+       protected void initializeToolMap() {
+               toolMap = new HashMap<String, IConfigurationElement>();
+               IExtensionPoint extPoint = Platform.getExtensionRegistry().getExtensionPoint(PLUGIN_ID, TOOL_EXT_ID);
+               IConfigurationElement[] configs = extPoint.getConfigurationElements();
+               for (IConfigurationElement config : configs) {
+                       if (config.getName().equals(EXT_ELEMENT)) {
+                               String id = config.getAttribute(EXT_ATTR_ID);
+                               if (id != null && config.getAttribute(EXT_ATTR_NAME) != null
+                                               && config.getAttribute(EXT_ATTR_PAGE) != null
+                                               && config.getAttribute(EXT_ATTR_DELEGATE) != null) {
+                                       toolMap.put(id, config);
+                               }
+                       }
+               }
+       }
+
+       protected HashMap<String, IConfigurationElement> getToolMap() {
+               if (toolMap == null) {
+                       initializeToolMap();
+               }
+               return toolMap;
+       }
+
+       public String escapeAndQuote(String canonicalPath) {
+               String ret = canonicalPath.replaceAll(" ", "\\ "); //$NON-NLS-1$ //$NON-NLS-2$
+               return ret;
+       }
+}
diff --git a/org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/valgrind/launch/ValgrindOptionsTab.java b/org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/valgrind/launch/ValgrindOptionsTab.java
new file mode 100644 (file)
index 0000000..f337f9b
--- /dev/null
@@ -0,0 +1,786 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Elliott Baron <ebaron@redhat.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.valgrind.launch;
+
+import java.io.File;
+
+import javax.swing.ButtonGroup;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.variables.VariablesPlugin;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
+import org.eclipse.debug.ui.ILaunchConfigurationTab;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.linuxtools.profiling.launch.ProfileLaunchPlugin;
+import org.eclipse.linuxtools.valgrind.core.utils.LaunchConfigurationConstants;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.ScrolledComposite;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Spinner;
+import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.swt.widgets.TabItem;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
+import org.eclipse.ui.model.WorkbenchContentProvider;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+import org.eclipse.ui.views.navigator.ResourceComparator;
+
+
+public class ValgrindOptionsTab extends AbstractLaunchConfigurationTab {
+       protected static final String EMPTY_STRING = ""; //$NON-NLS-1$
+       // Start controls
+       private ScrolledComposite scrContainer;
+
+       protected Button collectData1Button;
+       protected Button collectData2Button;
+       protected Button mempsButton;
+
+       // General controls
+       protected Button traceChildrenButton;
+       protected Button childSilentButton;
+       // protected Button trackFdsButton;
+       // protected Button timeStampButton;
+       protected Button runFreeresButton;
+       protected Button demangleButton;
+       protected Spinner numCallersSpinner;
+       protected Button errorLimitButton;
+       protected Button showBelowMainButton;
+       protected Spinner maxStackFrameSpinner;
+       protected Text suppFileText;
+
+       protected String tool;
+       protected String[] tools;
+       protected Combo toolsCombo;
+       protected Composite top;
+
+       protected ScrolledComposite scrollTop;
+
+       protected ILaunchConfigurationWorkingCopy launchConfigurationWorkingCopy;
+       protected ILaunchConfiguration launchConfiguration;
+
+       protected ILaunchConfigurationTab dynamicTab;
+       protected Composite dynamicTabHolder;
+
+       protected boolean isInitializing = false;
+       protected boolean initDefaults = false;
+
+       private boolean canInitialize; // bery 20090715
+
+       protected SelectionListener selectListener = new SelectionAdapter() {
+               @Override
+               public void widgetSelected(SelectionEvent e) {
+                       updateLaunchConfigurationDialog();
+               }
+       };
+       protected ModifyListener modifyListener = new ModifyListener() {
+               public void modifyText(ModifyEvent e) {
+                       updateLaunchConfigurationDialog();
+               }
+       };
+
+       public void createControl(Composite parent) {
+               // added by Jaewon Lim at 20120904
+               int targettype = ProfileLaunchPlugin.checkTarget();
+               
+               if(targettype != 2) {
+                       Composite top = new Composite(parent, SWT.NONE);
+                       setControl(top);
+                       top.setLayout(new GridLayout());
+                       
+                       // TODO : have to change help context id (temporarily empty string)
+                       PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), "");
+                                               
+                       Label impossibleLabel = new Label(top, SWT.LEFT);
+                       if(targettype == 0)
+                       {
+                               String message = Messages.getString("ValgrindOptionsTab.noemul") 
+                                               + "\n" + Messages.getString("ValgrindOptionsTab.inemul");
+                               impossibleLabel.setText(message);
+                       }
+                       else if(targettype == 1)
+                       {
+                               impossibleLabel.setText(Messages.getString("ValgrindOptionsTab.inemul"));
+                       }
+//                     else
+//                     {
+                               // impossible
+//                     }
+                               
+                       canInitialize = false;
+                       return;
+               }
+               
+               canInitialize = true;
+               
+               /**
+                * Scrollable Options tab is implemented .
+                */
+               scrContainer = new ScrolledComposite(parent, SWT.V_SCROLL
+                               | SWT.H_SCROLL);
+               FillLayout flayout = new FillLayout();
+               scrContainer.setLayout(flayout);
+               GridData gd = new GridData(GridData.FILL_BOTH);
+               scrContainer.setLayoutData(gd);
+               scrContainer.setExpandHorizontal(true);
+               scrContainer.setExpandVertical(true);
+
+               top = new Composite(scrContainer, SWT.NONE);
+               setControl(scrContainer);
+
+               top.setLayout(new GridLayout());
+
+               // changed by greatim at 2011.06.01 for fresh ide
+               // TODO : change help context id (temporarily empty string)
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), ""); //$NON-NLS-1$
+               
+               createVerticalSpacer(top, 1);
+               createVerticalSpacer(top, 1);
+
+               TabFolder optionsFolder = new TabFolder(top, SWT.BORDER);
+               optionsFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+               // start tab add
+
+               TabItem startTab = new TabItem(optionsFolder, SWT.NONE);
+               startTab.setText(Messages.getString("ValgrindOptionsTab.Start")); //$NON-NLS-1$
+
+               Composite startTop = new Composite(optionsFolder, SWT.NONE);
+               startTop.setLayout(new GridLayout());
+               startTop.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+               createStartOptions(startTop, true);
+               createVerticalSpacer(startTop, 1);
+               startTab.setControl(startTop);
+
+               // start tab add by bery
+
+               // "general" tab
+               TabItem generalTab = new TabItem(optionsFolder, SWT.NONE);
+               generalTab.setText(Messages.getString("ValgrindOptionsTab.General")); //$NON-NLS-1$
+
+               Composite generalTop = new Composite(optionsFolder, SWT.NONE);
+               generalTop.setLayout(new GridLayout());
+               generalTop.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+               createBasicOptions(generalTop);
+
+               createVerticalSpacer(generalTop, 1);
+
+               createErrorOptions(generalTop);
+
+               createVerticalSpacer(generalTop, 1);
+
+               createSuppressionsOption(generalTop);
+
+               generalTab.setControl(generalTop);
+
+               // "tool" tab
+               TabItem toolTab = new TabItem(optionsFolder, SWT.NONE);
+               toolTab.setText(Messages.getString("ValgrindOptionsTab.Tool")); //$NON-NLS-1$
+
+               dynamicTabHolder = new Composite(optionsFolder, SWT.NONE);
+               dynamicTabHolder.setLayout(new GridLayout());
+               dynamicTabHolder.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+               toolTab.setControl(dynamicTabHolder);
+
+               scrContainer.setContent(top);
+
+               scrContainer.setMinSize(top.computeSize(SWT.DEFAULT, SWT.DEFAULT));
+       }
+
+       /*
+        * private void createToolCombo(Composite top) { Composite comboTop = new
+        * Composite(top, SWT.NONE); comboTop.setLayout(new GridLayout(2, false));
+        * Label toolLabel = new Label(comboTop, SWT.NONE);
+        * toolLabel.setText(Messages.getString("ValgrindOptionsTab.Tool_to_run"));
+        * //$NON-NLS-1$ toolsCombo = new Combo(comboTop, SWT.READ_ONLY); tools =
+        * ValgrindLaunchPlugin.getDefault().getRegisteredToolIDs();
+        * 
+        * String[] names = new String[tools.length]; for (int i = 0; i <
+        * names.length; i++) { names[i] =
+        * ValgrindLaunchPlugin.getDefault().getToolName(tools[i]); }
+        * toolsCombo.setItems(names);
+        * 
+        * toolsCombo.addSelectionListener(new SelectionAdapter() {
+        * 
+        * @Override public void widgetDefaultSelected(SelectionEvent e) {
+        * widgetSelected(e); }
+        * 
+        * @Override public void widgetSelected(SelectionEvent e) { // user selected
+        * change, set defaults in new tool if (!isInitializing) { initDefaults =
+        * true; int ix = toolsCombo.getSelectionIndex(); tool = tools[ix];
+        * handleToolChanged(); updateLaunchConfigurationDialog(); } } }); }
+        */
+       // bery
+       protected void createStartOptions(Composite top, boolean selected) {
+
+               tools = ValgrindLaunchPlugin.getDefault().getRegisteredToolIDs();
+
+               final String[] names = new String[tools.length];
+               for (int i = 0; i < names.length; i++) {
+                       names[i] = ValgrindLaunchPlugin.getDefault().getToolName(tools[i]);
+               }
+
+               Group startGroup = new Group(top, SWT.NONE);
+               startGroup.setLayout(new GridLayout());
+               startGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               startGroup.setText(Messages
+                               .getString("ValgrindOptionsTab.Collect_Options")); //$NON-NLS-1$
+
+               Composite startTop = new Composite(startGroup, SWT.NONE);
+               startTop.setLayout(new GridLayout(8, false));
+               startTop.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+               // Label collectData1Label = new Label(startTop, SWT.NONE);
+               //  collectData1Label.setText(Messages.getString("ValgrindOptionsTab.collect_data1")); //$NON-NLS-1$
+               collectData1Button = new Button(startTop, SWT.RADIO);
+               collectData1Button.setText(Messages
+                               .getString("ValgrindOptionsTab.collect_data1")); //$NON-NLS-1$
+
+               // collectData1Button.addSelectionListener(selectListener);
+
+               collectData1Button.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetDefaultSelected(SelectionEvent e) {
+                               widgetSelected(e);
+                       }
+
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               // user selected change, set defaults in new tool
+                               // bery added at 20090715----------------------
+                               // if(TargetConnectionControl.isSimulator()){
+                               canInitialize = true;
+                               /*
+                                * }else{ String error =
+                                * "The Valgrind does not support the ARM target "; String
+                                * reason =
+                                * "An error occurred when the real target is selected. Please check whether your target is Simulator(i686)"
+                                * ; showErrorDialog(error, reason , null); //$NON-NLS-1$
+                                * canInitialize = false; return; }
+                                */
+                               // --------------------------------------
+                               // bery added at 20090715--------------------------------
+                               if (!canInitialize) {
+                                       return;
+                               }
+                               // --------------------------------------
+
+                               if (!isInitializing) {
+                                       // initDefaults = true;
+                                       tool = "org.eclipse.linuxtools.valgrind.launch.memcheck";
+                                       // tool = tools[0];
+                                       handleToolChanged();
+                                       updateLaunchConfigurationDialog();
+                               }
+                       }
+               });
+
+               // Must be on to prevent mangled XML output
+               // Label collectData2Label = new Label(startTop, SWT.NONE);
+               //collectData2Label.setText(Messages.getString("ValgrindOptionsTab.collect_data2")); //$NON-NLS-1$
+               collectData2Button = new Button(startTop, SWT.RADIO);
+               collectData2Button.setText(Messages
+                               .getString("ValgrindOptionsTab.collect_data2")); //$NON-NLS-1$
+               // collectData2Button.addSelectionListener(selectListener);
+
+               collectData2Button.addSelectionListener(new SelectionAdapter() {
+                       // @Override
+                       // public void widgetDefaultSelected(SelectionEvent e) {
+                       // widgetSelected(e);
+                       // }
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               // user selected change, set defaults in new tool
+
+                               if (!isInitializing) {
+                                       // initDefaults = false;
+                                       tool = "org.eclipse.linuxtools.valgrind.launch.massif";
+                                       // tool = tools[1];
+
+                                       handleToolChanged();
+                                       updateLaunchConfigurationDialog();
+                               }
+                       }
+               });
+
+       }
+
+       protected void createBasicOptions(Composite top) {
+               Group basicGroup = new Group(top, SWT.NONE);
+               basicGroup.setLayout(new GridLayout());
+               basicGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               basicGroup.setText(Messages
+                               .getString("ValgrindOptionsTab.Basic_Options")); //$NON-NLS-1$
+
+               Composite basicTop = new Composite(basicGroup, SWT.NONE);
+               basicTop.setLayout(new GridLayout(2, true));
+               basicTop.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+               traceChildrenButton = new Button(basicTop, SWT.CHECK);
+               traceChildrenButton.setText(Messages
+                               .getString("ValgrindOptionsTab.trace_children")); //$NON-NLS-1$
+               traceChildrenButton.addSelectionListener(selectListener);
+               traceChildrenButton
+                               .setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+               // Must be on to prevent mangled XML output
+               childSilentButton = new Button(basicTop, SWT.CHECK);
+               childSilentButton.setText(Messages
+                               .getString("ValgrindOptionsTab.child_silent")); //$NON-NLS-1$
+               childSilentButton.setSelection(true);
+               childSilentButton.setEnabled(false);
+               childSilentButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+               runFreeresButton = new Button(basicTop, SWT.CHECK);
+               runFreeresButton.setText(Messages
+                               .getString("ValgrindOptionsTab.run_freeres")); //$NON-NLS-1$
+               runFreeresButton.addSelectionListener(selectListener);
+               runFreeresButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+       }
+
+       protected void createErrorOptions(Composite top) {
+               Group errorGroup = new Group(top, SWT.NONE);
+               errorGroup.setLayout(new GridLayout());
+               errorGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               errorGroup.setText(Messages
+                               .getString("ValgrindOptionsTab.Error_Options")); //$NON-NLS-1$
+
+               Composite errorTop = new Composite(errorGroup, SWT.NONE);
+               errorTop.setLayout(new GridLayout(2, true));
+               errorTop.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+               demangleButton = new Button(errorTop, SWT.CHECK);
+               demangleButton.setText(Messages
+                               .getString("ValgrindOptionsTab.demangle")); //$NON-NLS-1$
+               demangleButton.addSelectionListener(selectListener);
+               demangleButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+               Composite numCallersTop = new Composite(errorTop, SWT.NONE);
+               numCallersTop.setLayout(new GridLayout(2, false));
+               Label numCallersLabel = new Label(numCallersTop, SWT.NONE);
+               numCallersLabel.setText(Messages
+                               .getString("ValgrindOptionsTab.num_callers")); //$NON-NLS-1$
+               numCallersSpinner = new Spinner(numCallersTop, SWT.BORDER);
+               numCallersSpinner.setMaximum(50);
+               numCallersSpinner.addModifyListener(modifyListener);
+               numCallersSpinner.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+               errorLimitButton = new Button(errorTop, SWT.CHECK);
+               errorLimitButton.setText(Messages
+                               .getString("ValgrindOptionsTab.limit_errors")); //$NON-NLS-1$
+               errorLimitButton.addSelectionListener(selectListener);
+               errorLimitButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+               showBelowMainButton = new Button(errorTop, SWT.CHECK);
+               showBelowMainButton.setText(Messages
+                               .getString("ValgrindOptionsTab.show_errors_below_main")); //$NON-NLS-1$
+               showBelowMainButton.addSelectionListener(selectListener);
+               showBelowMainButton
+                               .setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+               Composite maxStackFrameTop = new Composite(errorTop, SWT.NONE);
+               maxStackFrameTop.setLayout(new GridLayout(2, false));
+               Label maxStackFrameLabel = new Label(maxStackFrameTop, SWT.NONE);
+               maxStackFrameLabel.setText(Messages
+                               .getString("ValgrindOptionsTab.max_size_of_stack_frame")); //$NON-NLS-1$
+               maxStackFrameSpinner = new Spinner(maxStackFrameTop, SWT.BORDER);
+               maxStackFrameSpinner.setMaximum(Integer.MAX_VALUE);
+               maxStackFrameSpinner.addModifyListener(modifyListener);
+               maxStackFrameSpinner.setLayoutData(new GridData(
+                               GridData.FILL_HORIZONTAL));
+       }
+
+       protected void createSuppressionsOption(Composite top) {
+               Group suppGroup = new Group(top, SWT.NONE);
+               suppGroup.setLayout(new GridLayout());
+               suppGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               suppGroup
+                               .setText(Messages.getString("ValgrindOptionsTab.Suppressions")); //$NON-NLS-1$
+
+               Composite browseTop = new Composite(suppGroup, SWT.NONE);
+               browseTop.setLayout(new GridLayout(4, false));
+               GridData browseData = new GridData(GridData.FILL_HORIZONTAL);
+               browseTop.setLayoutData(browseData);
+
+               Label suppFileLabel = new Label(browseTop, SWT.NONE);
+               suppFileLabel.setText(Messages
+                               .getString("ValgrindOptionsTab.suppressions_file")); //$NON-NLS-1$
+
+               suppFileText = new Text(browseTop, SWT.BORDER);
+               suppFileText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               suppFileText.addModifyListener(modifyListener);
+
+               Button workspaceBrowseButton = createPushButton(browseTop,
+                               Messages.getString("ValgrindOptionsTab.Workspace"), null); //$NON-NLS-1$
+               workspaceBrowseButton.addSelectionListener(new SelectionAdapter() {
+                       public void widgetSelected(SelectionEvent e) {
+                               ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(
+                                               getShell(), new WorkbenchLabelProvider(),
+                                               new WorkbenchContentProvider());
+                               dialog.setTitle(Messages
+                                               .getString("ValgrindOptionsTab.Select_a_Resource")); //$NON-NLS-1$
+                               dialog.setMessage(Messages
+                                               .getString("ValgrindOptionsTab.Select_a_Suppressions_File")); //$NON-NLS-1$
+                               dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
+                               dialog.setComparator(new ResourceComparator(
+                                               ResourceComparator.NAME));
+                               if (dialog.open() == IDialogConstants.OK_ID) {
+                                       IResource resource = (IResource) dialog.getFirstResult();
+                                       String arg = resource.getFullPath().toString();
+                                       String fileLoc = VariablesPlugin.getDefault()
+                                                       .getStringVariableManager()
+                                                       .generateVariableExpression("workspace_loc", arg); //$NON-NLS-1$
+                                       suppFileText.setText(fileLoc);
+                               }
+                       }
+               });
+               Button fileBrowseButton = createPushButton(browseTop,
+                               Messages.getString("ValgrindOptionsTab.File_System"), null); //$NON-NLS-1$
+               fileBrowseButton.addSelectionListener(new SelectionAdapter() {
+                       public void widgetSelected(SelectionEvent e) {
+                               String filePath = suppFileText.getText();
+                               FileDialog dialog = new FileDialog(getShell(), SWT.SAVE);
+                               filePath = dialog.open();
+                               if (filePath != null) {
+                                       suppFileText.setText(filePath);
+                               }
+                       }
+               });
+       }
+
+       protected void handleToolChanged() {
+               try {
+                       // create dynamicTab
+                       loadDynamicArea();
+
+                       if (launchConfigurationWorkingCopy == null) {
+                               if (launchConfiguration.isWorkingCopy()) {
+                                       launchConfigurationWorkingCopy = (ILaunchConfigurationWorkingCopy) launchConfiguration;
+                               } else {
+                                       launchConfigurationWorkingCopy = launchConfiguration
+                                                       .getWorkingCopy();
+                               }
+                       }
+
+                       // setDefaults called on this tab so call on dynamicTab OR
+                       // user changed tool, not just restoring state
+                       if (initDefaults) {
+                               dynamicTab.setDefaults(launchConfigurationWorkingCopy);
+                       }
+                       initDefaults = false;
+                       dynamicTab.initializeFrom(launchConfigurationWorkingCopy);
+               } catch (CoreException e) {
+                       e.printStackTrace();
+               }
+       }
+
+       private void loadDynamicArea() throws CoreException {
+               for (Control child : dynamicTabHolder.getChildren()) {
+                       child.dispose();
+               }
+
+               dynamicTab = ValgrindLaunchPlugin.getDefault().getToolPage(tool);
+               if (dynamicTab == null) {
+                       throw new CoreException(
+                                       new Status(
+                                                       IStatus.ERROR,
+                                                       ValgrindLaunchPlugin.PLUGIN_ID,
+                                                       Messages.getString("ValgrindOptionsTab.No_options_tab_found") + tool)); //$NON-NLS-1$
+               }
+               dynamicTab.setLaunchConfigurationDialog(getLaunchConfigurationDialog());
+               dynamicTab.createControl(dynamicTabHolder);
+
+               dynamicTabHolder.layout(true);
+       }
+
+       public String getName() {
+               return Messages.getString("ValgrindOptionsTab.Valgrind_Options"); //$NON-NLS-1$
+       }
+
+       @Override
+       public Image getImage() {
+               return ValgrindLaunchPlugin
+                               .imageDescriptorFromPlugin(ValgrindLaunchPlugin.PLUGIN_ID,
+                                               "icons/valgrind-icon.png").createImage(); //$NON-NLS-1$
+       }
+
+       public void initializeFrom(ILaunchConfiguration configuration) {
+               // added by Jaewon Lim at 20120904
+               if(!canInitialize) {
+                       return;
+               }
+               
+               isInitializing = true;
+               getControl().setRedraw(false);
+               launchConfiguration = configuration;
+               launchConfigurationWorkingCopy = null;
+
+               try {
+                       tool = configuration.getAttribute(
+                                       LaunchConfigurationConstants.ATTR_TOOL,
+                                       ValgrindLaunchPlugin.TOOL_EXT_DEFAULT);
+
+                       int select = -1;
+                       if (tool.contains("memcheck")) {
+                               select = 0;
+                       } else if (tool.contains("massif")) {
+                               select = 1;
+                       }
+
+                       if (select == 0) {
+                               collectData1Button.setSelection(true);
+                               collectData2Button.setSelection(false);
+                       } else if (select == 1) {
+                               collectData2Button.setSelection(true);
+                               collectData1Button.setSelection(false);
+
+                       }
+
+                       handleToolChanged();
+                       initializeGeneral(configuration);
+               } catch (CoreException e) {
+                       e.printStackTrace();
+               }
+               getControl().setRedraw(true);
+               isInitializing = false;
+       }
+
+       protected void initializeGeneral(ILaunchConfiguration configuration)
+                       throws CoreException {
+
+               traceChildrenButton.setSelection(configuration.getAttribute(
+                               LaunchConfigurationConstants.ATTR_GENERAL_TRACECHILD, false));
+               // childSilentButton.setSelection(configuration.getAttribute(ValgrindLaunchPlugin.ATTR_GENERAL_CHILDSILENT,
+               // false));
+               // trackFdsButton.setSelection(configuration.getAttribute(ValgrindLaunchPlugin.ATTR_GENERAL_TRACKFDS,
+               // false));
+               // timeStampButton.setSelection(configuration.getAttribute(ValgrindLaunchPlugin.ATTR_GENERAL_TIMESTAMP,
+               // false));
+               runFreeresButton.setSelection(configuration.getAttribute(
+                               LaunchConfigurationConstants.ATTR_GENERAL_FREERES, true));
+               demangleButton.setSelection(configuration.getAttribute(
+                               LaunchConfigurationConstants.ATTR_GENERAL_DEMANGLE, true));
+               numCallersSpinner.setSelection(configuration.getAttribute(
+                               LaunchConfigurationConstants.ATTR_GENERAL_NUMCALLERS, 12));
+               errorLimitButton.setSelection(configuration.getAttribute(
+                               LaunchConfigurationConstants.ATTR_GENERAL_ERRLIMIT, true));
+               showBelowMainButton.setSelection(configuration.getAttribute(
+                               LaunchConfigurationConstants.ATTR_GENERAL_BELOWMAIN, false));
+               maxStackFrameSpinner.setSelection(configuration.getAttribute(
+                               LaunchConfigurationConstants.ATTR_GENERAL_MAXFRAME, 2000000));
+               suppFileText.setText(configuration.getAttribute(
+                               LaunchConfigurationConstants.ATTR_GENERAL_SUPPFILE,
+                               EMPTY_STRING));
+       }
+
+       @Override
+       public boolean isValid(ILaunchConfiguration launchConfig) {
+               // added by Jaewon Lim at 20120904
+               if(!canInitialize || ProfileLaunchPlugin.checkTarget() == 0){
+                       setErrorMessage(Messages.getString("ValgrindOptionsTab.noemul"));
+                       return false;
+               }
+
+               setErrorMessage(null);
+               boolean result = false;
+               if (result = isGeneralValid() && dynamicTab != null) {
+                       result = dynamicTab.isValid(launchConfig);
+               }
+               return result;
+       }
+
+       protected boolean isGeneralValid() {
+               String strpath = suppFileText.getText();
+               boolean result = false;
+               if (strpath.equals(EMPTY_STRING)) {
+                       result = true;
+               } else {
+                       try {
+                               File suppfile = ValgrindLaunchPlugin.getDefault().parseWSPath(
+                                               strpath);
+                               if (suppfile != null && suppfile.exists()) {
+                                       result = true;
+                               }
+                       } catch (CoreException e) {
+                               e.printStackTrace();
+                       }
+               }
+
+               if (!result) {
+                       setErrorMessage(NLS
+                                       .bind(Messages
+                                                       .getString("ValgrindOptionsTab.suppressions_file_doesnt_exist"), strpath)); //$NON-NLS-1$
+               }
+               return result;
+       }
+
+       public void performApply(ILaunchConfigurationWorkingCopy configuration) {
+               // added by Jaewon Lim at 20120904
+               if(!canInitialize || ProfileLaunchPlugin.checkTarget() == 0){
+                       return;
+               }
+
+               configuration.setAttribute(LaunchConfigurationConstants.ATTR_TOOL, tool);
+               // commented by greatim at 2011.06.01 for fresh ide
+               // configuration.setAttribute(ISMLCDTLaunchConstants.ATTR_LAUNCH_MODE,
+               // "valgrind" );
+               applyGeneralAttributes(configuration);
+               if (dynamicTab != null) {
+                       dynamicTab.performApply(configuration);
+               }
+       }
+
+       protected void applyGeneralAttributes(
+                       ILaunchConfigurationWorkingCopy configuration) {
+               configuration.setAttribute(
+                               LaunchConfigurationConstants.ATTR_GENERAL_TRACECHILD,
+                               traceChildrenButton.getSelection());
+               // configuration.setAttribute(ValgrindLaunchPlugin.ATTR_GENERAL_CHILDSILENT,
+               // childSilentButton.getSelection());
+               // configuration.setAttribute(ValgrindLaunchPlugin.ATTR_GENERAL_TRACKFDS,
+               // trackFdsButton.getSelection());
+               // configuration.setAttribute(ValgrindLaunchPlugin.ATTR_GENERAL_TIMESTAMP,
+               // timeStampButton.getSelection());
+               configuration.setAttribute(
+                               LaunchConfigurationConstants.ATTR_GENERAL_FREERES,
+                               runFreeresButton.getSelection());
+
+               configuration.setAttribute(
+                               LaunchConfigurationConstants.ATTR_GENERAL_DEMANGLE,
+                               demangleButton.getSelection());
+               configuration.setAttribute(
+                               LaunchConfigurationConstants.ATTR_GENERAL_NUMCALLERS,
+                               numCallersSpinner.getSelection());
+               configuration.setAttribute(
+                               LaunchConfigurationConstants.ATTR_GENERAL_ERRLIMIT,
+                               errorLimitButton.getSelection());
+               configuration.setAttribute(
+                               LaunchConfigurationConstants.ATTR_GENERAL_BELOWMAIN,
+                               showBelowMainButton.getSelection());
+               configuration.setAttribute(
+                               LaunchConfigurationConstants.ATTR_GENERAL_MAXFRAME,
+                               maxStackFrameSpinner.getSelection());
+               configuration.setAttribute(
+                               LaunchConfigurationConstants.ATTR_GENERAL_SUPPFILE,
+                               suppFileText.getText());
+       }
+
+       public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
+               launchConfigurationWorkingCopy = configuration;
+
+               setDefaultGeneralAttributes(configuration);
+               if (dynamicTab != null) {
+                       dynamicTab.setDefaults(configuration);
+                       initDefaults = false;
+               }
+       }
+
+       public static void setDefaultGeneralAttributes(
+                       ILaunchConfigurationWorkingCopy configuration) {
+
+               // commented by greatim at 2011.06.01 for fresh ide
+               // configuration.setAttribute(ISMLCDTLaunchConstants.ATTR_LAUNCH_MODE,
+               // "valgrind");
+
+               configuration.setAttribute(LaunchConfigurationConstants.ATTR_TOOL,
+                               ValgrindLaunchPlugin.TOOL_EXT_DEFAULT);
+               configuration.setAttribute(
+                               LaunchConfigurationConstants.ATTR_GENERAL_TRACECHILD, false);
+               // configuration.setAttribute(ValgrindLaunchPlugin.ATTR_GENERAL_CHILDSILENT,
+               // false);
+               // configuration.setAttribute(ValgrindLaunchPlugin.ATTR_GENERAL_TRACKFDS,
+               // false);
+               // configuration.setAttribute(ValgrindLaunchPlugin.ATTR_GENERAL_TIMESTAMP,
+               // false);
+               configuration.setAttribute(
+                               LaunchConfigurationConstants.ATTR_GENERAL_FREERES, true);
+
+               configuration.setAttribute(
+                               LaunchConfigurationConstants.ATTR_GENERAL_DEMANGLE, true);
+               configuration.setAttribute(
+                               LaunchConfigurationConstants.ATTR_GENERAL_NUMCALLERS, 12);
+               configuration.setAttribute(
+                               LaunchConfigurationConstants.ATTR_GENERAL_ERRLIMIT, true);
+               configuration.setAttribute(
+                               LaunchConfigurationConstants.ATTR_GENERAL_BELOWMAIN, false);
+               configuration.setAttribute(
+                               LaunchConfigurationConstants.ATTR_GENERAL_MAXFRAME, 2000000);
+               configuration.setAttribute(
+                               LaunchConfigurationConstants.ATTR_GENERAL_SUPPFILE,
+                               EMPTY_STRING);
+       }
+
+       @Override
+       public void dispose() {
+               if (dynamicTab != null) {
+                       dynamicTab.dispose();
+               }
+               super.dispose();
+       }
+
+       protected void createHorizontalSpacer(Composite comp, int numlines) {
+               Label lbl = new Label(comp, SWT.NONE);
+               GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+               gd.horizontalSpan = numlines;
+               lbl.setLayoutData(gd);
+       }
+
+       @Override
+       protected void updateLaunchConfigurationDialog() {
+               if (!isInitializing) {
+                       super.updateLaunchConfigurationDialog();
+               }
+       }
+
+       public static void showErrorDialog(final String errorMessage,
+                       final String reasonMessage, final Exception ex) {
+
+               final String dialogTitle = "Valgrind Error";
+               final String toolname = Messages.getString("ValgrindOptionsTab.Tool");
+               final IStatus status = new Status(IStatus.ERROR, toolname, IStatus.OK,
+                               reasonMessage, ex);
+
+               Display.getDefault().syncExec(new Runnable() {
+                       public void run() {
+                               ErrorDialog.openError(null, dialogTitle, errorMessage, status);
+                       }
+               });
+
+       }
+
+}
diff --git a/org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/valgrind/launch/messages.properties b/org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/valgrind/launch/messages.properties
new file mode 100644 (file)
index 0000000..02ca739
--- /dev/null
@@ -0,0 +1,38 @@
+ValgrindLaunchConfigurationDelegate.Error_starting_process=Error starting process
+ValgrindLaunchConfigurationDelegate.Profiling_Local_CCPP_Application=Profiling Local C/C++ Application
+ValgrindLaunchConfigurationDelegate.Saving_Valgrind_output=Saving Valgrind output
+ValgrindLaunchConfigurationDelegate.Please_ensure_Valgrind=Please ensure Valgrind is installed and in your path.
+ValgrindLaunchPlugin.Cannot_retrieve_delegate=Cannot retrieve delegate from extension
+ValgrindLaunchPlugin.Cannot_retrieve_page=Cannot retrieve page from extension
+ValgrindLaunchPlugin.Confirm_cancel=Operation canceled.\nPlease note that the profiling with valgrind usually takes long time to launch the application.
+ValgrindOptionsTab.Basic_Options=Basic Options
+ValgrindOptionsTab.Collect_Options=Collect Options:
+ValgrindOptionsTab.child_silent=child silent after fork:
+ValgrindOptionsTab.demangle=demangle C++ names:
+ValgrindOptionsTab.Error_Options=Error Options
+ValgrindOptionsTab.File_System=File Syste&m...
+ValgrindOptionsTab.General=General setting
+ValgrindOptionsTab.Start=Collect data
+ValgrindOptionsTab.limit_errors=limit errors reported:
+ValgrindOptionsTab.max_size_of_stack_frame=max size of stack frame:
+ValgrindOptionsTab.No_options_tab_found=No options tab found for tool 
+ValgrindOptionsTab.num_callers=num callers in stack trace:
+ValgrindOptionsTab.run_freeres=run __libc_freeres() on exit:
+ValgrindOptionsTab.Select_a_Resource=Select a Resource:
+ValgrindOptionsTab.Select_a_Suppressions_File=Select a Suppressions File:
+ValgrindOptionsTab.show_errors_below_main=show errors below main:
+ValgrindOptionsTab.suppressions_file=suppressions file:
+ValgrindOptionsTab.suppressions_file_doesnt_exist=suppressions file: {0}  doesn't exist.
+ValgrindOptionsTab.Suppressions=Suppressions
+ValgrindOptionsTab.Tool=Tool Advanced setting
+ValgrindOptionsTab.Tool_to_run=Tool to run: 
+ValgrindOptionsTab.trace_children=trace children on exec:
+ValgrindOptionsTab.Valgrind_Options=Memory Profile Options
+ValgrindOptionsTab.Workspace=&Workspace...
+ValgrindOptionsTab.collect_data1=Memory Error and Memory Leak data
+ValgrindOptionsTab.collect_data2=Heap Memory Profiling
+ValgrindOptionsTab.memps=Memory Usage data
+ValgrindOptionsTab.inemul=Please note that valgrind profiling is available in emulator only.
+ValgrindOptionsTab.noemul=Emulator isn't connected or activated.
+ValgrindOptionsTab.cannotrun=Cannot run valgrind profiling.
+
diff --git a/org.eclipse.linuxtools.valgrind.massif/.classpath b/org.eclipse.linuxtools.valgrind.massif/.classpath
new file mode 100644 (file)
index 0000000..ad32c83
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+       <classpathentry kind="src" path="src"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.eclipse.linuxtools.valgrind.massif/.project b/org.eclipse.linuxtools.valgrind.massif/.project
new file mode 100644 (file)
index 0000000..e2fc222
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.eclipse.linuxtools.valgrind.massif</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.ManifestBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.SchemaBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.pde.PluginNature</nature>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>
diff --git a/org.eclipse.linuxtools.valgrind.massif/.settings/org.eclipse.core.resources.prefs b/org.eclipse.linuxtools.valgrind.massif/.settings/org.eclipse.core.resources.prefs
new file mode 100644 (file)
index 0000000..5d18c87
--- /dev/null
@@ -0,0 +1,3 @@
+#Wed Dec 01 09:13:54 CET 2010
+eclipse.preferences.version=1
+encoding/<project>=UTF-8
diff --git a/org.eclipse.linuxtools.valgrind.massif/.settings/org.eclipse.core.runtime.prefs b/org.eclipse.linuxtools.valgrind.massif/.settings/org.eclipse.core.runtime.prefs
new file mode 100644 (file)
index 0000000..d3439cf
--- /dev/null
@@ -0,0 +1,3 @@
+#Tue Dec 14 16:37:00 CET 2010
+eclipse.preferences.version=1
+line.separator=\n
diff --git a/org.eclipse.linuxtools.valgrind.massif/ChangeLog b/org.eclipse.linuxtools.valgrind.massif/ChangeLog
new file mode 100644 (file)
index 0000000..f0bdb46
--- /dev/null
@@ -0,0 +1,37 @@
+2009-01-20  Elliott Baron  <ebaron@redhat.com>
+
+       * MassifLaunchDelegate: Changed to handle multiple pids.
+       * MassifOutput: New, organizes multiple snapshot arrays by pid.
+       * MassifParser: Added parsing for pid.
+       * MassifPidMenuAction: UI to switch between pids.
+       * MassifViewPart: Added handling for multiple pids.
+       * messages.properties: New key.
+       * ChartEditorInput: Store pid for EditorInput caching.
+
+2009-01-13  Elliott Baron  <ebaron@redhat.com>
+
+       * MassifParser: Implements new abstract parser.
+
+2009-01-09  Elliott Baron  <ebaron@redhat.com>
+
+       * MassifSnapshot: New convenience method isDetailed().
+       * MassifViewPart: Changed visibility of setTopControl to public.
+       * ChartControl: Integrated with ChartRenderer, implementer of ICallBackNotifier must
+       also extend Composite.
+       * ChartRenderer: Deleted.
+       * HeapChart: Added triggers for single click.
+       * META-INF/MANIFEST.MF: Added all needed BIRT plugins to required bundles.
+
+2009-01-08  Elliott Baron  <ebaron@redhat.com>
+
+       * META-INF/MANIFEST.MF: Added org.eclipse.birt.device.swt to required bundles.
+
+2009-01-05  Elliott Baron  <ebaron@redhat.com>
+
+       * MassifViewPart: Chart now opens upon launch; EditorInput is cached once
+       created.
+       * ChartControl: Catches ChartException.
+       * ChartRenderer: First attempt at callbacks
+       * HeapChart: Likewise.
+       * META-INF/MANIFEST.MF: Changed version to 0.1.0.
+       * build.properties: Include about.html and icons.
\ No newline at end of file
diff --git a/org.eclipse.linuxtools.valgrind.massif/META-INF/MANIFEST.MF b/org.eclipse.linuxtools.valgrind.massif/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..603a446
--- /dev/null
@@ -0,0 +1,29 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Tizen SDK Valgrind Massif
+Bundle-SymbolicName: org.eclipse.linuxtools.valgrind.massif;singleton:=true
+Bundle-Version: 1.3.18.qualifier
+Bundle-Activator: org.eclipse.linuxtools.valgrind.massif.MassifPlugin
+Bundle-Vendor: Eclipse Linux Tools
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.ui.editors,
+ org.eclipse.ui.forms,
+ org.eclipse.jface.text,
+ org.eclipse.debug.ui,
+ org.eclipse.cdt.debug.core,
+ org.eclipse.cdt.launch;bundle-version="6.1.0",
+ org.eclipse.birt.chart.engine,
+ org.eclipse.linuxtools.profiling.ui,
+ org.eclipse.linuxtools.valgrind.core,
+ org.eclipse.linuxtools.valgrind.launch,
+ org.eclipse.linuxtools.valgrind.ui,
+ org.eclipse.linuxtools.valgrind.launch.exe
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-ActivationPolicy: lazy
+Bundle-Localization: plugin
+Export-Package: org.tizen.valgrind.massif.editor,
+ org.eclipse.linuxtools.valgrind.massif,
+ org.eclipse.linuxtools.valgrind.massif.birt;uses:="org.eclipse.swt.events,org.eclipse.swt.widgets,org.eclipse.birt.chart.model"
+Import-Package: org.eclipse.cdt.core,
+ org.eclipse.cdt.managedbuilder.core,
+ org.tizen.nativecommon.launch
diff --git a/org.eclipse.linuxtools.valgrind.massif/NOTICE b/org.eclipse.linuxtools.valgrind.massif/NOTICE
new file mode 100644 (file)
index 0000000..8412790
--- /dev/null
@@ -0,0 +1,69 @@
+2009-10-02 SPRC SDK Team <d.kozinski@samsung.com>
+       * MANIFEST.MF : modify dependency plugins
+       * MassifLaunchDelegate.java : code refactoring
+       * MassifTreeViewer.java : code refactoring
+
+2010-02-08 Lukasz Czaplinski <l.czaplinski@samsung.com>
+       * MANIFEST.MF : Removed not needed birt.chart plugin  dependency
+
+2010-02-10 SPRC SDK Team <d.kozinski@samsung.com>
+       * .classpath : change java runtime environment
+       * org.eclipse.jdt.core.prefs : remove file
+       * MassifLaunchDelegate.java : remove some unnecessary import
+       * MassifParser.java : remove some unnecessary import, commented DOT member variable
+       * MassifToolPage.java : remove "@SuppressWarnings("unchecked")"
+       * ChartEditorInput.java : remove "@SuppressWarnings("unchecked")"
+       * HeapChart.java : remove "@SuppressWarnings("unchecked")"
+       * MANIFEST.MF : Conflicts mainly resolved
+
+2010-03-19 HyungJong, Shin <hj_shin@samsung.com>
+       * MANIFEST.MF : add some plugin dependency
+
+2010-03-22 HyungJong, Shin <hj_shin@samsung.com>
+       * MANIFEST.MF : remove unused dependencies.
+
+2010-04-16 Zbigniew Kosinski <z.kosinski@samsung.com>
+       * MassifParser.java : Massif Parser, set dot as default Decimal Separator
+
+2010-04-19 HyungJong, Shin <hj_shin@samsung.com>
+       * MassifParser.java : import some module
+
+2010-11-05 sdk <sdk@sdk-laptop.(none)>
+       * MANIFEST.MF : changed some package name
+       * plugin.xml : changed some package name
+       * MassifLaunchDelegate.java : changed some package name
+
+2011-06-09 jaewon81.lim <jaewon81.lim@samsung.com>
+       * MANIFEST.MF : rearrange plugins dependency
+
+2011-07-13 jaewon81.lim <jaewon81.lim@samsung.com>
+       * MANIFEST.MF : modified import package name
+       * MassifLaunchDelegate.java : modified import package name
+
+2011-08-22 joogwan.kim <joogwan.kim@samsung.com>
+       * MANIFEST.MF : Change plug-in name
+       * MassifLaunchDelegate.java : Change plug-in name
+
+2011-08-25 wonhyoung2.park <wonhyoung2.park@samsung.com>
+       * MANIFEST.MF : plugin provider and name modified
+
+2011-11-16 wonhyoung2.park <wonhyoung2.park@samsung.com>
+       * MANIFEST.MF : Profiler sdb apply
+       * MassifLaunchDelegate.java : Profiler sdb apply
+       
+2011-11-22 taeyoung2.son <taeyoung2.son@samsung.com>
+       * MANIFEST.MF :  Modify SDK naming from "SLP(or Samsung Linux Platform)" to "Tizen"
+
+2011-11-29 wonhyoung2.park <wonhyoung2.park@samsung.com>
+       * MANIFEST.MF : chagne slp to tizen
+       * plugin.xml : chagne slp to tizen
+       * MassifLaunchDelegate.java : chagne slp to tizen
+
+2011-12-02 taeyoung2.son <taeyoung2.son@samsung.com>
+       * MANIFEST.MF : Delete dependency feature's version value.
+
+2011-12-03 wonhyoung2.park <wonhyoung2.park@samsung.com>
+       * MANIFEST.MF : package instll routine chage
+
+2011-12-05 wonhyoung2.park <wonhyoung2.park@samsung.com>
+       * MassifLaunchDelegate.java : add console (profile stop available)
diff --git a/org.eclipse.linuxtools.valgrind.massif/about.html b/org.eclipse.linuxtools.valgrind.massif/about.html
new file mode 100644 (file)
index 0000000..e6a2741
--- /dev/null
@@ -0,0 +1,26 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"><head>
+
+
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>About</title>
+</head><body lang="EN-US">
+<h2>About This Content</h2>
+<p>October 24, 2008</p>        
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in ("Content").  Unless otherwise 
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 ("EPL").  A copy of the EPL is available 
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, "Program" will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is 
+being redistributed by another party ("Redistributor") and different terms and conditions may
+apply to your use of any object code in the Content.  Check the Redistributor's license that was 
+provided with the Content.  If no such license exists, contact the Redistributor.  Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body></html>
\ No newline at end of file
diff --git a/org.eclipse.linuxtools.valgrind.massif/build.properties b/org.eclipse.linuxtools.valgrind.massif/build.properties
new file mode 100644 (file)
index 0000000..a8ee0b8
--- /dev/null
@@ -0,0 +1,10 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               .,\
+               plugin.properties,\
+               plugin.xml,\
+               about.html,\
+               icons/
+javacSource = 1.6
+javacTarget = 1.6
diff --git a/org.eclipse.linuxtools.valgrind.massif/icons/barcharticon.gif b/org.eclipse.linuxtools.valgrind.massif/icons/barcharticon.gif
new file mode 100644 (file)
index 0000000..2137d3f
Binary files /dev/null and b/org.eclipse.linuxtools.valgrind.massif/icons/barcharticon.gif differ
diff --git a/org.eclipse.linuxtools.valgrind.massif/icons/call_hierarchy.gif b/org.eclipse.linuxtools.valgrind.massif/icons/call_hierarchy.gif
new file mode 100644 (file)
index 0000000..7c7dca8
Binary files /dev/null and b/org.eclipse.linuxtools.valgrind.massif/icons/call_hierarchy.gif differ
diff --git a/org.eclipse.linuxtools.valgrind.massif/icons/class_hi.gif b/org.eclipse.linuxtools.valgrind.massif/icons/class_hi.gif
new file mode 100644 (file)
index 0000000..17f927e
Binary files /dev/null and b/org.eclipse.linuxtools.valgrind.massif/icons/class_hi.gif differ
diff --git a/org.eclipse.linuxtools.valgrind.massif/icons/linecharticon.gif b/org.eclipse.linuxtools.valgrind.massif/icons/linecharticon.gif
new file mode 100644 (file)
index 0000000..9603d2c
Binary files /dev/null and b/org.eclipse.linuxtools.valgrind.massif/icons/linecharticon.gif differ
diff --git a/org.eclipse.linuxtools.valgrind.massif/icons/memory_view.gif b/org.eclipse.linuxtools.valgrind.massif/icons/memory_view.gif
new file mode 100644 (file)
index 0000000..7ce1112
Binary files /dev/null and b/org.eclipse.linuxtools.valgrind.massif/icons/memory_view.gif differ
diff --git a/org.eclipse.linuxtools.valgrind.massif/plugin.properties b/org.eclipse.linuxtools.valgrind.massif/plugin.properties
new file mode 100644 (file)
index 0000000..f2bf748
--- /dev/null
@@ -0,0 +1,4 @@
+#Properties file for org.eclipse.linuxtools.valgrind.massif
+Bundle-Vendor.0 = Eclipse.org
+Bundle-Name.0 = Massif Plug-in (Incubation)
+editor.name.0 = Heap Chart
\ No newline at end of file
diff --git a/org.eclipse.linuxtools.valgrind.massif/plugin.xml b/org.eclipse.linuxtools.valgrind.massif/plugin.xml
new file mode 100644 (file)
index 0000000..99d37ec
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+  <extension
+         point="org.eclipse.linuxtools.valgrind.launch.valgrindTools">
+      <tool
+            delegate="org.eclipse.linuxtools.valgrind.massif.MassifLaunchDelegate"
+            id="org.eclipse.linuxtools.valgrind.launch.massif"
+            name="massif"
+            page="org.eclipse.linuxtools.valgrind.massif.MassifToolPage">
+      </tool>
+   </extension>
+   <extension
+         point="org.eclipse.linuxtools.valgrind.ui.valgrindToolViews">
+      <view
+            class="org.eclipse.linuxtools.valgrind.massif.MassifViewPart"
+            definitionId="org.eclipse.linuxtools.valgrind.launch.massif">
+      </view>
+   </extension>
+   <extension
+         point="org.eclipse.ui.editors">
+      <editor
+            class="org.eclipse.linuxtools.valgrind.massif.birt.ChartEditor"
+            default="false"
+            icon="icons/linecharticon.gif"
+            id="org.eclipse.linuxtools.valgrind.massif.chartEditor"
+            name="%editor.name.0">
+      </editor>
+      <editor
+            class="org.tizen.valgrind.massif.editor.MassifEditor"
+            default="true"
+            extensions="massif"
+            icon="icons/memory_view.gif"
+            id="org.tizen.valgrind.memcheck.editor.MassifEditor"
+            name="Massif Editor">
+      </editor>
+   </extension>
+   <!--
+   <extension
+         point="org.eclipse.linuxtools.valgrind.history.statePersisters">
+      <persister
+            class="org.eclipse.linuxtools.valgrind.massif.MassifLaunchDelegate"
+            tool="org.eclipse.linuxtools.valgrind.launch.massif">
+      </persister>
+   </extension>
+   -->
+</plugin>
diff --git a/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/valgrind/massif/MassifHeapTreeNode.java b/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/valgrind/massif/MassifHeapTreeNode.java
new file mode 100644 (file)
index 0000000..24b8b6d
--- /dev/null
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Elliott Baron <ebaron@redhat.com> - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.valgrind.massif;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class MassifHeapTreeNode {
+       protected MassifHeapTreeNode parent;
+       protected String text;
+       protected String filename;
+       protected int line;
+       protected List<MassifHeapTreeNode> children;
+       
+       public MassifHeapTreeNode(MassifHeapTreeNode parent, String text) {
+               this.parent = parent;
+               this.text = text;
+               children = new ArrayList<MassifHeapTreeNode>();
+       }
+       
+       public void addChild(MassifHeapTreeNode child) {
+               children.add(child);
+       }
+       
+       public MassifHeapTreeNode getParent() {
+               return parent;
+       }
+       
+       public MassifHeapTreeNode[] getChildren() {
+               return children.toArray(new MassifHeapTreeNode[children.size()]);
+       }
+       
+       public String getText() {
+               return text;
+       }
+       
+       protected void setText(String text) {
+               this.text = text;
+       }
+       
+       public String getFilename() {
+               return filename;
+       }
+       
+       protected void setFilename(String filename) {
+               this.filename = filename;
+       }
+       
+       public int getLine() {
+               return line;
+       }
+       
+       protected void setLine(int line) {
+               this.line = line;
+       }
+       
+       @Override
+       public String toString() {
+               return text;
+       }
+
+       public boolean hasSourceFile() {
+               return filename != null;
+       }
+}
diff --git a/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/valgrind/massif/MassifLaunchDelegate.java b/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/valgrind/massif/MassifLaunchDelegate.java
new file mode 100644 (file)
index 0000000..501d8d4
--- /dev/null
@@ -0,0 +1,197 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Elliott Baron <ebaron@redhat.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.valgrind.massif;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.linuxtools.valgrind.core.ValgrindCommand;
+import org.eclipse.linuxtools.valgrind.launch.CommandManager;
+import org.eclipse.linuxtools.valgrind.launch.IValgrindLaunchDelegate;
+import org.eclipse.linuxtools.valgrind.launch.ValgrindLaunchPlugin;
+import org.eclipse.linuxtools.valgrind.ui.IValgrindToolView;
+import org.eclipse.linuxtools.valgrind.ui.ValgrindUIPlugin;
+import org.eclipse.linuxtools.valgrind.ui.ValgrindViewPart;
+import org.tizen.nativecommon.launch.TizenLaunchCommand;
+import org.tizen.nativecommon.launch.TizenLaunchDelegate;
+
+public class MassifLaunchDelegate extends TizenLaunchDelegate implements
+               IValgrindLaunchDelegate {
+       // valgrind
+
+       protected static final String EMPTY_STRING = ""; //$NON-NLS-1$
+       protected static final String NO = "no"; //$NON-NLS-1$
+       protected static final String YES = "yes"; //$NON-NLS-1$
+       protected static final String EQUALS = "="; //$NON-NLS-1$
+
+       protected static final String LOG_PREFIX = "valgrind_"; //$NON-NLS-1$
+       protected static final String LOG_FILE = LOG_PREFIX + "%p.xml"; //$NON-NLS-1$
+       protected static final FileFilter LOG_FILTER = new FileFilter() {
+               public boolean accept(File pathname) {
+                       // return pathname.getName().startsWith(LOG_PREFIX);
+                       return pathname.getName().endsWith("xml");
+
+               }
+       };
+
+       protected static final String OUT_PREFIX = "massif_"; //$NON-NLS-1$
+       //protected static final String OUT_FILE = OUT_PREFIX + "%p.txt"; //$NON-NLS-1$
+       protected static final String OUT_FILE = "massif_000.txt"; //$NON-NLS-1$
+       protected static final FileFilter MASSIF_FILTER = new FileFilter() {
+               public boolean accept(File pathname) {
+                       return pathname.getName().startsWith(OUT_PREFIX);
+               }
+       };
+
+       // Valgrind program arguments
+       public static final String OPT_MASSIF_OUTFILE = "--massif-out-file"; //$NON-NLS-1$
+       public static final String OPT_HEAP = "--heap"; //$NON-NLS-1$
+       public static final String OPT_HEAPADMIN = "--heap-admin"; //$NON-NLS-1$
+       public static final String OPT_STACKS = "--stacks"; //$NON-NLS-1$
+       public static final String OPT_DEPTH = "--depth"; //$NON-NLS-1$
+       public static final String OPT_ALLOCFN = "--alloc-fn"; //$NON-NLS-1$
+       public static final String OPT_THRESHOLD = "--threshold"; //$NON-NLS-1$
+       public static final String OPT_PEAKINACCURACY = "--peak-inaccuracy"; //$NON-NLS-1$
+       public static final String OPT_TIMEUNIT = "--time-unit"; //$NON-NLS-1$
+       public static final String OPT_DETAILEDFREQ = "--detailed-freq"; //$NON-NLS-1$
+       public static final String OPT_MAXSNAPSHOTS = "--max-snapshots"; //$NON-NLS-1$
+       public static final String OPT_ALIGNMENT = "--alignment"; //$NON-NLS-1$
+
+       protected MassifOutput output;
+
+       public void launch(ValgrindCommand command, ILaunchConfiguration config,
+                       ILaunch launch, IProgressMonitor monitor) throws Exception {
+               MassifPlugin.getDefault().setConfig(config);
+               MassifPlugin.getDefault().setSourceLocator(launch.getSourceLocator());
+               try {
+                       //command.getProcess().waitFor();
+
+                       // remoteShellProcess.waitFor();
+
+                       String ValgrindHostdir = ValgrindUIPlugin.getDefault()
+                                       .getStateLocation().toOSString();
+                       String targetlog_massif = ValgrindLaunchPlugin.RESULT_DIR
+                                       + OUT_FILE;
+                       String hostlog_massif = ValgrindHostdir + File.separator + OUT_FILE;
+
+                       // --bery sftp dowonload
+                       // session.downloadFile(targetlog_massif,hostlog_massif);
+                       File file = new File(hostlog_massif);
+                       if (file.exists()) {
+                               file.delete();
+                       }
+                       CommandManager.pull(targetlog_massif, hostlog_massif);
+                       parseOutput(hostlog_massif);
+               } catch (IOException e) {
+                       e.printStackTrace();
+                       abort(Messages
+                                       .getString("MassifLaunchDelegate.Error_parsing_output"), e, ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR); //$NON-NLS-1$
+               }
+
+       }
+
+       protected void parseOutput(String hostlog_massif) throws IOException {
+               output = new MassifOutput();
+               // for (File file : hostlog_massif) {
+               MassifParser parser = new MassifParser(hostlog_massif);
+               output.putSnapshots(parser.getPid(), parser.getSnapshots());
+               // }
+
+               ValgrindViewPart view = ValgrindUIPlugin.getDefault().getView();
+               IValgrindToolView massifPart = view.getDynamicView();
+               if (massifPart instanceof MassifViewPart) {
+                       ((MassifViewPart) massifPart).setOutput(output);
+                       // initialize to first pid
+                       ((MassifViewPart) massifPart).setPid(output.getPids()[0]);
+               }
+       }
+
+       public String[] getCommandArray(ValgrindCommand command,
+                       ILaunchConfiguration config) throws CoreException {
+               ArrayList<String> opts = new ArrayList<String>();
+
+               opts.add(OPT_MASSIF_OUTFILE + EQUALS + ValgrindLaunchPlugin.RESULT_DIR
+                               + OUT_FILE);
+
+               opts.add(OPT_HEAP
+                               + EQUALS
+                               + (config.getAttribute(MassifToolPage.ATTR_MASSIF_HEAP, true) ? YES
+                                               : NO));
+               opts.add(OPT_HEAPADMIN + EQUALS
+                               + config.getAttribute(MassifToolPage.ATTR_MASSIF_HEAPADMIN, 8));
+               opts.add(OPT_STACKS
+                               + EQUALS
+                               + (config
+                                               .getAttribute(MassifToolPage.ATTR_MASSIF_STACKS, false) ? YES
+                                               : NO));
+               opts.add(OPT_DEPTH + EQUALS
+                               + config.getAttribute(MassifToolPage.ATTR_MASSIF_DEPTH, 30));
+               List<String> allocFns = config.getAttribute(
+                               MassifToolPage.ATTR_MASSIF_ALLOCFN, Collections.EMPTY_LIST);
+               for (String func : allocFns) {
+                       opts.add(OPT_ALLOCFN + EQUALS + func);
+               }
+               opts.add(OPT_THRESHOLD + EQUALS
+                               + config.getAttribute(MassifToolPage.ATTR_MASSIF_THRESHOLD, 10)
+                               / 10.0);
+               opts.add(OPT_PEAKINACCURACY
+                               + EQUALS
+                               + config.getAttribute(
+                                               MassifToolPage.ATTR_MASSIF_PEAKINACCURACY, 10) / 10.0);
+               opts.add(OPT_TIMEUNIT
+                               + EQUALS
+                               + config.getAttribute(MassifToolPage.ATTR_MASSIF_TIMEUNIT,
+                                               MassifToolPage.TIME_I));
+               opts.add(OPT_DETAILEDFREQ
+                               + EQUALS
+                               + config.getAttribute(MassifToolPage.ATTR_MASSIF_DETAILEDFREQ,
+                                               10));
+               opts.add(OPT_MAXSNAPSHOTS
+                               + EQUALS
+                               + config.getAttribute(MassifToolPage.ATTR_MASSIF_MAXSNAPSHOTS,
+                                               100));
+               opts.add(OPT_ALIGNMENT + EQUALS
+                               + config.getAttribute(MassifToolPage.ATTR_MASSIF_ALIGNMENT, 8));
+
+               return opts.toArray(new String[opts.size()]);
+       }
+
+       // public void restoreState(HistoryEntry entry) throws CoreException {
+       // try {
+       // Map<?, ?> config = entry.getAttributes();
+       // MassifPlugin.getDefault().setConfig(config);
+       //
+       // // retrieve or create sourceLocator
+       // ILaunch launch = new Launch(config, ILaunchManager.PROFILE_MODE, null);
+       // setDefaultSourceLocator(launch, config);
+       // MassifPlugin.getDefault().setSourceLocator(launch.getSourceLocator());
+       //
+       // File[] massifOutputs = entry.getDatadir().listFiles(MASSIF_FILTER);
+       // parseOutput(massifOutputs);
+       // } catch (IOException e) {
+       // e.printStackTrace();
+       //                      abort(Messages.getString("MassifLaunchDelegate.Error_parsing_output"), e, ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR); //$NON-NLS-1$
+       // }
+       // }
+       //
+       // public void saveState(HistoryEntry entry) throws CoreException {
+       // }
+
+}
diff --git a/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/valgrind/massif/MassifOutput.java b/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/valgrind/massif/MassifOutput.java
new file mode 100644 (file)
index 0000000..33a94ea
--- /dev/null
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Elliott Baron <ebaron@redhat.com> - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.valgrind.massif;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class MassifOutput {
+       protected Map<Integer, MassifSnapshot[]> pidMap;
+       
+       public MassifOutput() {
+               pidMap = new HashMap<Integer, MassifSnapshot[]>();
+       }
+       
+       public void putSnapshots(Integer pid, MassifSnapshot[] snapshots) {
+               pidMap.put(pid, snapshots);
+       }
+       
+       public MassifSnapshot[] getSnapshots(Integer pid) {
+               return pidMap.get(pid);
+       }
+       
+       public Integer[] getPids() {
+               return pidMap.keySet().toArray(new Integer[pidMap.size()]);
+       }
+}
diff --git a/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/valgrind/massif/MassifParser.java b/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/valgrind/massif/MassifParser.java
new file mode 100644 (file)
index 0000000..4f9e09b
--- /dev/null
@@ -0,0 +1,261 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Elliott Baron <ebaron@redhat.com> - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.valgrind.massif;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.IOException;
+import java.text.DecimalFormat;
+import java.text.DecimalFormatSymbols;
+import java.util.ArrayList;
+
+import org.eclipse.linuxtools.valgrind.core.AbstractValgrindTextParser;
+import org.eclipse.linuxtools.valgrind.massif.MassifSnapshot.SnapshotType;
+import org.eclipse.linuxtools.valgrind.massif.MassifSnapshot.TimeUnit;
+import org.eclipse.osgi.util.NLS;
+
+public class MassifParser extends AbstractValgrindTextParser {
+       private static final String CMD = "cmd"; //$NON-NLS-1$
+       private static final String TIME_UNIT = "time_unit"; //$NON-NLS-1$
+       private static final String SNAPSHOT = "snapshot"; //$NON-NLS-1$
+       private static final String TIME = "time"; //$NON-NLS-1$
+       private static final String MEM_HEAP_B = "mem_heap_B"; //$NON-NLS-1$
+       private static final String MEM_HEAP_EXTRA_B = "mem_heap_extra_B"; //$NON-NLS-1$
+       private static final String MEM_STACKS_B = "mem_stacks_B"; //$NON-NLS-1$
+       private static final String HEAP_TREE = "heap_tree"; //$NON-NLS-1$
+       
+       private static final String INSTRUCTIONS = "i"; //$NON-NLS-1$
+       private static final String MILLISECONDS = "ms"; //$NON-NLS-1$
+       private static final String BYTES = "B"; //$NON-NLS-1$
+       private static final String PEAK = "peak"; //$NON-NLS-1$
+       private static final String DETAILED = "detailed"; //$NON-NLS-1$
+       private static final String EMPTY = "empty"; //$NON-NLS-1$
+
+       private static final String COLON = ":"; //$NON-NLS-1$
+       private static final String SPACE = " "; //$NON-NLS-1$
+       private static final String EQUALS = "="; //$NON-NLS-1$
+//     private static final String DOT = "."; //$NON-NLS-1$
+
+       protected Integer pid;
+       protected MassifSnapshot[] snapshots;
+
+       public MassifParser(String hostlog_massif) throws IOException {
+               ArrayList<MassifSnapshot> list = new ArrayList<MassifSnapshot>();
+               BufferedReader br = new BufferedReader(new FileReader(hostlog_massif));
+               String line;
+               MassifSnapshot snapshot = null;
+               String cmd = null;
+               TimeUnit unit = null;  
+               int n = 0;
+               
+               // retrive PID from filename
+               //String filename = hostlog_massif;
+               //String filename = MassifLaunchDelegate.OUT_FILE;
+               //String filename = hostlog_massif.substring(MassifLaunchDelegate.OUT_PREFIX.length(), hostlog_massif.indexOf(DOT));
+               //String filename = hostlog_massif.substring("massif".length(), hostlog_massif.indexOf("/"));
+               
+               //String pidstr = filename.substring(MassifLaunchDelegate.OUT_PREFIX.length(), filename.indexOf(DOT));
+               String pidstr ="000";
+               if (isNumber(pidstr)) {
+                       pid = new Integer(pidstr);
+                       }
+               else {
+                       throw new IOException(Messages.getString("MassifParser.Cannot_parse_PID")); //$NON-NLS-1$
+               }
+               
+               // parse contents of file
+               while ((line = br.readLine()) != null) {
+                       if (line.startsWith(CMD + COLON)){
+                               cmd = parseStrValue(line, COLON + SPACE);
+                       }
+                       else if (line.startsWith(TIME_UNIT + COLON)) {
+                               unit = parseTimeUnit(line);
+                       }                       
+                       else if (line.startsWith(SNAPSHOT)) {
+                               if (snapshot != null) {
+                                       // this snapshot finished parsing
+                                       list.add(snapshot);
+                                       n++;
+                               }
+                               snapshot = new MassifSnapshot(n);
+                               snapshot.setCmd(cmd);
+                               snapshot.setUnit(unit);
+                       }
+                       else if (line.startsWith(TIME + EQUALS)) {
+                               snapshot.setTime(parseLongValue(line, EQUALS));
+                       }
+                       else if (line.startsWith(MEM_HEAP_B + EQUALS)) {
+                               snapshot.setHeapBytes(parseLongValue(line, EQUALS));
+                       }
+                       else if (line.startsWith(MEM_HEAP_EXTRA_B + EQUALS)) {
+                               snapshot.setHeapExtra(parseLongValue(line, EQUALS));
+                       }
+                       else if (line.startsWith(MEM_STACKS_B + EQUALS)) {
+                               snapshot.setStacks(parseLongValue(line, EQUALS));
+                       }
+                       else if (line.startsWith(HEAP_TREE + EQUALS)) {
+                               SnapshotType type = parseSnapshotType(line);
+                               snapshot.setType(type);
+                               if(type.equals(SnapshotType.DETAILED) || type.equals(SnapshotType.PEAK)) {
+                                       MassifHeapTreeNode node = parseTree(snapshot, null, br);
+                                       node.setText(NLS.bind(Messages.getString("MassifParser.Snapshot_n"), n, node.getText())); // prepend snapshot number //$NON-NLS-1$
+                                       snapshot.setRoot(node);
+                               }       
+                       }
+               }
+               if (snapshot != null) {
+                       // last snapshot that finished parsing
+                       list.add(snapshot);
+               }
+               snapshots = list.toArray(new MassifSnapshot[list.size()]);
+       }
+
+       private MassifHeapTreeNode parseTree(MassifSnapshot snapshot, MassifHeapTreeNode parent, BufferedReader br) throws IOException {
+               String line = br.readLine();
+               if (line == null) {
+                       throw new IOException(Messages.getString("MassifParser.Unexpected_EOF")); //$NON-NLS-1$
+               }
+               line = line.trim(); // remove leading whitespace
+               String[] parts = line.split(" "); //$NON-NLS-1$
+               Integer numChildren = parseNumChildren(parts[0]);
+               if (numChildren == null) {
+                       fail(line);
+               }
+
+               StringBuffer nodeText = new StringBuffer();
+               Long numBytes = parseNumBytes(parts[1]);
+               if (numBytes == null) {
+                       fail(line);
+               }
+               
+               double percentage;
+               if (numBytes.intValue() == 0) {
+                       percentage = 0;
+               }
+               else {
+                       percentage = numBytes.doubleValue() / snapshot.getTotal() * 100;
+               }
+               
+               DecimalFormatSymbols unusualSymbols = new DecimalFormatSymbols();
+               unusualSymbols.setDecimalSeparator('.');
+               nodeText.append(Double.valueOf( new DecimalFormat("##.##",unusualSymbols).format(percentage) ) + "%");
+               nodeText.append(" ("); //$NON-NLS-1$
+               nodeText.append(new DecimalFormat("#,##0").format(numBytes.longValue()) + "B"); //$NON-NLS-1$ //$NON-NLS-2$
+               nodeText.append(")"); //$NON-NLS-1$
+               
+               // append the rest
+               for (int i = 2; i < parts.length; i++) {
+                       nodeText.append(" "); //$NON-NLS-1$
+                       nodeText.append(parts[i]);
+               }
+               
+               MassifHeapTreeNode node = new MassifHeapTreeNode(parent, nodeText.toString());
+               
+               // Parse source file if specified
+               parseSourceFile(node, line);
+               for (int i = 0; i < numChildren.intValue(); i++) {
+                       node.addChild(parseTree(snapshot, node, br));
+               }
+               return node;
+       }
+
+       /*
+        * Assumes syntax is: "\(.*:[0-9]+\)$"
+        */
+       private void parseSourceFile(MassifHeapTreeNode node, String line) {
+               int ix = line.indexOf("("); //$NON-NLS-1$
+               if (ix >= 0) {
+                       String part = line.substring(ix, line.length());
+                       part = part.substring(1, part.length() - 1); // remove leading and trailing parentheses
+                       if ((ix = part.lastIndexOf(":")) >= 0 && ix < part.length()) { //$NON-NLS-1$            
+                               String strLineNo = part.substring(ix + 1);
+                               if (isNumber(strLineNo)) {
+                                       int lineNo = Integer.parseInt(strLineNo);
+                                       String filename = part.substring(0, ix);
+                                       node.setFilename(filename);
+                                       node.setLine(lineNo);
+                               }
+                       }
+               }
+       }
+       
+       private Long parseNumBytes(String string) {
+               Long result = null;
+               if (isNumber(string)) {
+                       result = Long.parseLong(string);
+               }
+               return result;
+       }
+
+       /*
+        * format is "n[0-9]+:"
+        */
+       private Integer parseNumChildren(String string) {
+               Integer result = null;
+               if (string.length() >= 3) {
+                       String number = string.substring(1, string.length() - 1);
+                       if (isNumber(number)) {
+                               result = Integer.parseInt(number);
+                       }
+               }
+               return result;
+       }
+
+       public Integer getPid() {
+               return pid;
+       }
+       
+       public MassifSnapshot[] getSnapshots() {
+               return snapshots;
+       }
+
+       protected SnapshotType parseSnapshotType(String line) throws IOException {
+               SnapshotType result = null;
+               String[] parts = line.split(EQUALS);
+               if (parts.length > 1) {
+                       String type = parts[1];
+                       if (type.equals(EMPTY)) {
+                               result = SnapshotType.EMPTY;
+                       }
+                       else if (type.equals(DETAILED)) {
+                               result = SnapshotType.DETAILED;
+                       }
+                       else if (type.equals(PEAK)) {
+                               result = SnapshotType.PEAK;
+                       }
+               }
+               if (result == null) {
+                       fail(line);
+               }
+               return result;
+       }
+       
+       protected TimeUnit parseTimeUnit(String line) throws IOException {
+               TimeUnit result = null;
+               String[] parts = line.split(COLON + SPACE);
+               if (parts.length > 1) {
+                       String type = parts[1];
+                       if (type.equals(INSTRUCTIONS)) {
+                               result = TimeUnit.INSTRUCTIONS;
+                       }
+                       else if (type.equals(MILLISECONDS)) {
+                               result = TimeUnit.MILLISECONDS;
+                       }
+                       else if (type.equals(BYTES)) {
+                               result = TimeUnit.BYTES;
+                       }
+               }
+               if (result == null) {
+                       fail(line);
+               }
+               return result;
+       }
+}
diff --git a/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/valgrind/massif/MassifPidMenuAction.java b/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/valgrind/massif/MassifPidMenuAction.java
new file mode 100644 (file)
index 0000000..14998fb
--- /dev/null
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Elliott Baron <ebaron@redhat.com> - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.valgrind.massif;
+
+import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.debug.ui.IDebugUIConstants;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.ActionContributionItem;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuCreator;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+
+public class MassifPidMenuAction extends Action implements IMenuCreator {
+
+       protected Menu menu;
+       protected MassifViewPart view;
+       protected Integer[] pids;
+
+       public MassifPidMenuAction(MassifViewPart view) {
+               super(Messages.getString("MassifPidMenuAction.Select_Process_ID"), IAction.AS_DROP_DOWN_MENU); //$NON-NLS-1$
+               this.view = view;
+
+               setToolTipText(Messages.getString("MassifPidMenuAction.Select_Process_ID")); //$NON-NLS-1$
+               setImageDescriptor(DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_OBJS_THREAD_RUNNING));
+               setMenuCreator(this);
+       }
+
+       public void dispose() {
+               if (menu != null) {
+                       menu.dispose();
+               }
+       }
+
+       public Menu getMenu(Control parent) {
+               if (menu == null) {
+                       if (pids != null) {
+                               menu = new Menu(parent);
+                               for (int i = 0; i < pids.length; i++) {
+                                       final Integer pid = pids[i];
+                                       ActionContributionItem item = new ActionContributionItem(new Action("PID " + String.valueOf(pids[i]), IAction.AS_RADIO_BUTTON) { //$NON-NLS-1$
+                                               @Override
+                                               public void run() {
+                                                       view.setPid(pid);                                               
+                                                       Display.getDefault().syncExec(new Runnable() {
+                                                               public void run() {
+                                                                       view.refreshView();
+                                                                       MenuItem[] items = menu.getItems();
+                                                                       for (int j = 0; j < items.length; j++) {
+                                                                               items[j].setSelection(false);
+                                                                       }
+                                                                       setChecked(true);
+                                                               }                                                       
+                                                       });
+                                               }
+                                       });
+                                       item.fill(menu, -1);
+                               }       
+                               menu.getItem(0).setSelection(true);
+                       }
+               }
+               return menu;
+       }
+
+       public Menu getMenu(Menu parent) {
+               return null;
+       }
+
+       public void setPids(Integer[] pids) {
+               this.pids = pids;
+       }
+
+}
diff --git a/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/valgrind/massif/MassifPlugin.java b/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/valgrind/massif/MassifPlugin.java
new file mode 100644 (file)
index 0000000..b4753d8
--- /dev/null
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Elliott Baron <ebaron@redhat.com> - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.valgrind.massif;
+
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.model.ISourceLocator;
+import org.eclipse.linuxtools.valgrind.launch.ValgrindLaunchPlugin;
+import org.eclipse.swt.graphics.FontMetrics;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+public class MassifPlugin extends AbstractUIPlugin {
+
+       // The plug-in ID
+       public static final String PLUGIN_ID = "org.eclipse.linuxtools.valgrind.massif"; //$NON-NLS-1$
+       public static final String EDITOR_ID = PLUGIN_ID + ".chartEditor"; //$NON-NLS-1$
+
+       // The shared instance
+       private static MassifPlugin plugin;
+       
+       protected ILaunchConfiguration config;
+       
+       // Needed for source lookup on massif output, since massif only supplies filenames
+       // and not full paths
+       protected ISourceLocator locator;
+
+       public static final String TOOL_ID = ValgrindLaunchPlugin.PLUGIN_ID + ".massif"; //$NON-NLS-1$
+       
+       /**
+        * The constructor
+        */
+       public MassifPlugin() {
+       }
+
+       /*
+        * (non-Javadoc)
+        * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+        */
+       public void start(BundleContext context) throws Exception {
+               super.start(context);
+               plugin = this;
+       }
+
+       /*
+        * (non-Javadoc)
+        * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+        */
+       public void stop(BundleContext context) throws Exception {
+               plugin = null;
+               super.stop(context);
+       }
+
+       public static FontMetrics getFontMetrics(Control control) {
+                GC gc = new GC(control);
+                gc.setFont(control.getFont());
+                FontMetrics fontMetrics = gc.getFontMetrics();
+                gc.dispose();
+                return fontMetrics;
+       }
+       
+       public ISourceLocator getSourceLocator() {
+               return locator;
+       }
+       
+       protected void setSourceLocator(ISourceLocator locator) {
+               this.locator = locator;
+       }
+       
+       public ILaunchConfiguration getConfig() {
+               return config;
+       }
+       
+       public void setConfig(ILaunchConfiguration config) {
+               this.config = config;
+       }
+
+       /**
+        * Returns the shared instance
+        *
+        * @return the shared instance
+        */
+       public static MassifPlugin getDefault() {
+               return plugin;
+       }
+
+}
diff --git a/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/valgrind/massif/MassifSnapshot.java b/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/valgrind/massif/MassifSnapshot.java
new file mode 100644 (file)
index 0000000..32b8adc
--- /dev/null
@@ -0,0 +1,107 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Elliott Baron <ebaron@redhat.com> - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.valgrind.massif;
+
+public class MassifSnapshot {
+       public static enum TimeUnit { INSTRUCTIONS, MILLISECONDS, BYTES };
+       public static enum SnapshotType { EMPTY, DETAILED, PEAK };
+       
+       protected long number;
+       protected long time;
+       protected long heapBytes;
+       protected long heapExtra;
+       protected long stacks;
+       
+       protected String cmd;
+       protected TimeUnit unit;
+       protected SnapshotType type;
+       protected MassifHeapTreeNode root;
+               
+       public MassifSnapshot(int number) {
+               this.number = number;
+       }
+       
+       public long getNumber() {
+               return number;
+       }
+
+       public long getHeapBytes() {
+               return heapBytes;
+       }
+       
+       public long getHeapExtra() {
+               return heapExtra;
+       }
+       
+       public long getStacks() {
+               return stacks;
+       }
+       
+       public long getTime() {
+               return time;
+       }
+       
+       public long getTotal() {
+               return heapBytes + heapExtra + stacks;
+       }
+       
+       public SnapshotType getType() {
+               return type;
+       }
+       
+       public String getCmd() {
+               return cmd;
+       }
+       
+       public TimeUnit getUnit() {
+               return unit;
+       }
+       
+       public MassifHeapTreeNode getRoot() {
+               return root;
+       }
+       
+       public boolean isDetailed() {
+               return !type.equals(SnapshotType.EMPTY);
+       }
+       
+       protected void setTime(long time) {
+               this.time = time;
+       }
+
+       protected void setHeapBytes(long heapBytes) {
+               this.heapBytes = heapBytes;
+       }
+
+       protected void setHeapExtra(long heapExtra) {
+               this.heapExtra = heapExtra;
+       }
+
+       protected void setStacks(long stacks) {
+               this.stacks = stacks;
+       }
+       
+       protected void setType(SnapshotType type) {
+               this.type = type;
+       }
+       
+       protected void setCmd(String cmd) {
+               this.cmd = cmd;
+       }
+       
+       protected void setUnit(TimeUnit unit) {
+               this.unit = unit;
+       }
+       
+       protected void setRoot(MassifHeapTreeNode root) {
+               this.root = root;
+       }
+}
diff --git a/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/valgrind/massif/MassifToolPage.java b/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/valgrind/massif/MassifToolPage.java
new file mode 100644 (file)
index 0000000..ccbc0df
--- /dev/null
@@ -0,0 +1,368 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Elliott Baron <ebaron@redhat.com> - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.valgrind.massif;
+
+import java.util.Arrays;
+import java.util.Collections;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.jface.window.Window;
+import org.eclipse.linuxtools.valgrind.launch.IValgrindToolPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.ScrolledComposite;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.FontMetrics;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.List;
+import org.eclipse.swt.widgets.Spinner;
+
+public class MassifToolPage extends AbstractLaunchConfigurationTab
+               implements IValgrindToolPage {
+       public static final String MASSIF = "massif"; //$NON-NLS-1$
+       public static final String PLUGIN_ID = MassifPlugin.PLUGIN_ID;
+       
+       public static final String TIME_I = "i"; //$NON-NLS-1$
+       public static final String TIME_MS = "ms"; //$NON-NLS-1$
+       public static final String TIME_B = "B"; //$NON-NLS-1$
+       
+       // Massif controls
+       protected Button heapButton;
+       protected Spinner heapAdminSpinner;
+       protected Button stacksButton;
+       protected Spinner depthSpinner;
+       protected List allocFnList;
+       protected Spinner thresholdSpinner;
+       protected Spinner peakInaccuracySpinner;
+       protected Combo timeUnitCombo;
+       protected Spinner detailedFreqSpinner;
+       protected Spinner maxSnapshotsSpinner;
+       protected PowerOfTwoSpinner alignmentSpinner;
+       
+       // LaunchConfiguration attributes
+       public static final String ATTR_MASSIF_OUTFILE = PLUGIN_ID + ".MASSIF_OUTFILE"; //$NON-NLS-1$
+       
+       public static final String ATTR_MASSIF_HEAP = PLUGIN_ID + ".MASSIF_HEAP"; //$NON-NLS-1$
+       public static final String ATTR_MASSIF_HEAPADMIN = PLUGIN_ID + ".MASSIF_HEAPADMIN"; //$NON-NLS-1$
+       public static final String ATTR_MASSIF_STACKS = PLUGIN_ID + ".MASSIF_STACKS"; //$NON-NLS-1$
+       public static final String ATTR_MASSIF_DEPTH = PLUGIN_ID + ".MASSIF_DEPTH"; //$NON-NLS-1$
+       public static final String ATTR_MASSIF_ALLOCFN = PLUGIN_ID + ".MASSIF_ALLOCFN"; //$NON-NLS-1$
+       public static final String ATTR_MASSIF_THRESHOLD = PLUGIN_ID + ".MASSIF_THRESHOLD"; //$NON-NLS-1$
+       public static final String ATTR_MASSIF_PEAKINACCURACY = PLUGIN_ID + ".MASSIF_PEAKINACCURACY"; //$NON-NLS-1$
+       public static final String ATTR_MASSIF_TIMEUNIT = PLUGIN_ID + ".MASSIF_TIMEUNIT"; //$NON-NLS-1$
+       public static final String ATTR_MASSIF_DETAILEDFREQ = PLUGIN_ID + ".MASSIF_DETAILEDFREQ"; //$NON-NLS-1$
+       public static final String ATTR_MASSIF_MAXSNAPSHOTS = PLUGIN_ID + ".MASSIF_MAXSNAPSHOTS"; //$NON-NLS-1$
+       public static final String ATTR_MASSIF_ALIGNMENT = PLUGIN_ID + ".MASSIF_ALIGNMENT"; //$NON-NLS-1$
+       
+       protected boolean isInitializing = false;
+       protected SelectionListener selectListener = new SelectionAdapter() {
+               @Override
+               public void widgetSelected(SelectionEvent e) {
+                       updateLaunchConfigurationDialog();
+               }
+       };
+       protected ModifyListener modifyListener = new ModifyListener() {
+               public void modifyText(ModifyEvent e) {
+                       updateLaunchConfigurationDialog();      
+               }                       
+       };
+       
+       public void createControl(Composite parent) {
+               ScrolledComposite sc = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
+               sc.setLayoutData(new GridData(GridData.FILL_BOTH));
+               sc.setExpandHorizontal(true);
+               sc.setExpandVertical(true);
+               Composite top = new Composite(sc, SWT.NONE);
+               
+               GridLayout topLayout = new GridLayout(2, true);
+               topLayout.horizontalSpacing = 10;
+               top.setLayout(topLayout);
+               top.setLayoutData(new GridData(GridData.FILL_BOTH));
+               
+               Composite heapTop = new Composite(top, SWT.NONE);
+               heapTop.setLayout(new GridLayout(2, false));
+               
+//             Label heapLabel = new Label(heapTop, SWT.NONE);
+//             heapLabel.setText(Messages.getString("MassifToolPage.profile_heap")); //$NON-NLS-1$
+//             
+//             heapButton = new Button(heapTop, SWT.CHECK);
+//             heapButton.addSelectionListener(selectListener);                
+//             
+
+               heapButton = new Button(heapTop, SWT.CHECK);
+               heapButton.setText(Messages.getString("MassifToolPage.profile_heap")); //$NON-NLS-1$
+               heapButton.addSelectionListener(selectListener);                
+               
+               Composite heapAdminTop = new Composite(top, SWT.NONE);
+               heapAdminTop.setLayout(new GridLayout(2, false));
+               
+               Label heapAdminLabel = new Label(heapAdminTop, SWT.NONE);
+               heapAdminLabel.setText(Messages.getString("MassifToolPage.administrative_bytes")); //$NON-NLS-1$
+               
+               heapAdminSpinner = new Spinner(heapAdminTop, SWT.BORDER);               
+               heapAdminSpinner.addModifyListener(modifyListener);
+                       
+               Composite stacksTop = new Composite(top, SWT.NONE);
+               stacksTop.setLayout(new GridLayout(2, false));
+               
+//             Label stacksLabel = new Label(stacksTop, SWT.NONE);
+//             stacksLabel.setText(Messages.getString("MassifToolPage.profile_stack")); //$NON-NLS-1$
+//             
+//             stacksButton = new Button(stacksTop, SWT.CHECK);
+//             stacksButton.addSelectionListener(selectListener);
+               
+               stacksButton = new Button(stacksTop, SWT.CHECK);
+               stacksButton.setText(Messages.getString("MassifToolPage.profile_stack")); //$NON-NLS-1$
+               stacksButton.addSelectionListener(selectListener);
+               
+               Composite depthTop = new Composite(top, SWT.NONE);
+               depthTop.setLayout(new GridLayout(2, false));
+               
+               Label depthLabel = new Label(depthTop, SWT.NONE);
+               depthLabel.setText(Messages.getString("MassifToolPage.allocation_tree_depth")); //$NON-NLS-1$
+               
+               depthSpinner = new Spinner(depthTop, SWT.BORDER);               
+               depthSpinner.addModifyListener(modifyListener);
+               
+               Composite thresholdTop = new Composite(top, SWT.NONE);
+               thresholdTop.setLayout(new GridLayout(3, false));
+               
+               Label thresholdLabel = new Label(thresholdTop, SWT.NONE);
+               thresholdLabel.setText(Messages.getString("MassifToolPage.heap_allocation_threshold")); //$NON-NLS-1$
+               
+               thresholdSpinner = new Spinner(thresholdTop, SWT.BORDER);
+               thresholdSpinner.setDigits(1);
+               thresholdSpinner.setMaximum(1000);
+               thresholdSpinner.addModifyListener(modifyListener);
+               
+               Label thresholdPercentLabel = new Label(thresholdTop, SWT.NONE);
+               thresholdPercentLabel.setText("%"); //$NON-NLS-1$
+               
+               Composite peakInaccuracyTop = new Composite(top, SWT.NONE);
+               peakInaccuracyTop.setLayout(new GridLayout(3, false));
+               
+               Label peakInaccuracyLabel = new Label(peakInaccuracyTop, SWT.NONE);
+               peakInaccuracyLabel.setText(Messages.getString("MassifToolPage.allocation_peak_inaccuracy")); //$NON-NLS-1$
+               
+               peakInaccuracySpinner = new Spinner(peakInaccuracyTop, SWT.BORDER);
+               peakInaccuracySpinner.setDigits(1);
+               peakInaccuracySpinner.setMaximum(1000);
+               peakInaccuracySpinner.addModifyListener(modifyListener);
+               
+               Label peakInaccuracyPercentLabel = new Label(peakInaccuracyTop, SWT.NONE);
+               peakInaccuracyPercentLabel.setText("%"); //$NON-NLS-1$
+               
+               Composite timeUnitTop = new Composite(top, SWT.NONE);
+               timeUnitTop.setLayout(new GridLayout(2, false));
+               
+               Label timeUnitLabel = new Label(timeUnitTop, SWT.NONE);
+               timeUnitLabel.setText(Messages.getString("MassifToolPage.time_unit")); //$NON-NLS-1$
+               
+               timeUnitCombo = new Combo(timeUnitTop, SWT.READ_ONLY);
+               String[] items = new String[] { Messages.getString("MassifToolPage.instructions"), Messages.getString("MassifToolPage.milliseconds"), Messages.getString("MassifToolPage.bytes") }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+               timeUnitCombo.setItems(items);
+               timeUnitCombo.addSelectionListener(selectListener);
+               
+               Composite detailedFreqTop = new Composite(top, SWT.NONE);
+               detailedFreqTop.setLayout(new GridLayout(2, false));
+               
+               Label detailedFreqLabel = new Label(detailedFreqTop, SWT.NONE);
+               detailedFreqLabel.setText(Messages.getString("MassifToolPage.detailed_snapshot_freq")); //$NON-NLS-1$
+               
+               detailedFreqSpinner = new Spinner(detailedFreqTop, SWT.BORDER);
+               detailedFreqSpinner.setMaximum(Integer.MAX_VALUE);
+               detailedFreqSpinner.addModifyListener(modifyListener);
+               
+               Composite maxSnapshotsTop = new Composite(top, SWT.NONE);
+               maxSnapshotsTop.setLayout(new GridLayout(2, false));
+               
+               Label maxSnapshotsLabel = new Label(maxSnapshotsTop, SWT.NONE);
+               maxSnapshotsLabel.setText(Messages.getString("MassifToolPage.max_snapshots")); //$NON-NLS-1$
+               
+               maxSnapshotsSpinner = new Spinner(maxSnapshotsTop, SWT.BORDER);
+               maxSnapshotsSpinner.setMaximum(Integer.MAX_VALUE);
+               maxSnapshotsSpinner.addModifyListener(modifyListener);
+               
+               Composite alignmentTop = new Composite(top, SWT.NONE);
+               alignmentTop.setLayout(new GridLayout(2, false));
+               
+               Label alignmentLabel = new Label(alignmentTop, SWT.NONE);
+               alignmentLabel.setText(Messages.getString("MassifToolPage.minimum_heap_block")); //$NON-NLS-1$
+               
+               alignmentSpinner = new PowerOfTwoSpinner(alignmentTop, SWT.BORDER);
+               alignmentSpinner.setMinimum(8);
+               alignmentSpinner.setMaximum(4096);
+               alignmentSpinner.addModifyListener(modifyListener);
+               
+               Composite allocFnTop = new Composite(top, SWT.NONE);
+               allocFnTop.setLayout(new GridLayout(3, false));
+               allocFnTop.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false, 2, 1));
+               
+               Label allocFnLabel = new Label(allocFnTop, SWT.NONE);
+               allocFnLabel.setText(Messages.getString("MassifToolPage.allocation_functions")); //$NON-NLS-1$
+               allocFnLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false));
+                               
+               createAllocFnControls(allocFnTop);
+               
+               sc.setContent(top);
+               sc.setMinSize(top.computeSize(SWT.DEFAULT, SWT.DEFAULT));
+       }
+
+       private void createAllocFnControls(Composite top) {
+                       
+               allocFnList = new List(top, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);              
+               FontMetrics fm = MassifPlugin.getFontMetrics(allocFnList);
+               allocFnList.setLayoutData(new GridData(Dialog.convertWidthInCharsToPixels(fm, 50), Dialog.convertHeightInCharsToPixels(fm, 5)));
+               
+               Composite allocButtons = new Composite(top, SWT.NONE);
+               GridLayout allocButtonsLayout = new GridLayout();
+               allocButtonsLayout.marginWidth = allocButtonsLayout.marginHeight = 0;
+               allocButtons.setLayout(allocButtonsLayout);
+               allocButtons.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false));
+               
+               Button newButton = new Button(allocButtons, SWT.PUSH);
+               newButton.setText(Messages.getString("MassifToolPage.New")); //$NON-NLS-1$
+               newButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               newButton.addSelectionListener(new SelectionAdapter() {
+                       public void widgetSelected(SelectionEvent e) {
+                               handleNewButtonPressed();
+                               updateLaunchConfigurationDialog();
+                       }                       
+               });
+                               
+               Button removeButton = new Button(allocButtons, SWT.PUSH);
+               removeButton.setText(Messages.getString("MassifToolPage.Remove")); //$NON-NLS-1$
+               removeButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               removeButton.addSelectionListener(new SelectionAdapter() {
+                       public void widgetSelected(SelectionEvent e) {
+                               handleRemoveButtonPressed();
+                               updateLaunchConfigurationDialog();
+                       }                       
+               });
+       }
+
+       protected void handleNewButtonPressed() {
+               InputDialog dialog = new InputDialog(getShell(), Messages.getString("MassifToolPage.New_Allocation_Function"), Messages.getString("MassifToolPage.Function_name"), "", null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+               if (dialog.open() == Window.OK) {
+                       String function = dialog.getValue();
+                       if (!function.equals("")) { //$NON-NLS-1$
+                               allocFnList.add(function);
+                       }
+               }
+       }
+
+       protected void handleRemoveButtonPressed() {
+                int[] selections = allocFnList.getSelectionIndices();
+                allocFnList.remove(selections);
+       }
+
+       public String getName() {
+               return Messages.getString("MassifToolPage.Massif_Options"); //$NON-NLS-1$
+       }
+
+       public void initializeFrom(ILaunchConfiguration configuration) {
+               isInitializing = true;
+               try {
+                       heapButton.setSelection(configuration.getAttribute(ATTR_MASSIF_HEAP, true));
+                       heapAdminSpinner.setSelection(configuration.getAttribute(ATTR_MASSIF_HEAPADMIN, 8));
+                       stacksButton.setSelection(configuration.getAttribute(ATTR_MASSIF_STACKS, false));
+                       depthSpinner.setSelection(configuration.getAttribute(ATTR_MASSIF_DEPTH, 30));
+                       java.util.List<String> allocFns = configuration.getAttribute(ATTR_MASSIF_ALLOCFN, Collections.EMPTY_LIST);
+                       allocFnList.setItems(allocFns.toArray(new String[allocFns.size()]));
+                       thresholdSpinner.setSelection(configuration.getAttribute(ATTR_MASSIF_THRESHOLD, 10));
+                       peakInaccuracySpinner.setSelection(configuration.getAttribute(ATTR_MASSIF_PEAKINACCURACY, 10));
+                       String timeUnit = configuration.getAttribute(ATTR_MASSIF_TIMEUNIT, TIME_I);
+                       if (timeUnit.equals(TIME_I)) {
+                               timeUnitCombo.select(0);
+                       }
+                       else if (timeUnit.equals(TIME_MS)) {
+                               timeUnitCombo.select(1);
+                       }
+                       else {
+                               timeUnitCombo.select(2);
+                       }
+                       detailedFreqSpinner.setSelection(configuration.getAttribute(ATTR_MASSIF_DETAILEDFREQ, 10));
+                       maxSnapshotsSpinner.setSelection(configuration.getAttribute(ATTR_MASSIF_MAXSNAPSHOTS, 100));
+                       int alignment = configuration.getAttribute(ATTR_MASSIF_ALIGNMENT, 8);
+                       alignmentSpinner.setSelection(alignment);
+               } catch (CoreException e) {
+                       e.printStackTrace();
+               }
+               isInitializing = false;
+       }
+
+       public void performApply(ILaunchConfigurationWorkingCopy configuration) {
+               configuration.setAttribute(ATTR_MASSIF_HEAP, heapButton.getSelection());
+               configuration.setAttribute(ATTR_MASSIF_HEAPADMIN, heapAdminSpinner.getSelection());
+               configuration.setAttribute(ATTR_MASSIF_STACKS, stacksButton.getSelection());
+               configuration.setAttribute(ATTR_MASSIF_DEPTH, depthSpinner.getSelection());
+               configuration.setAttribute(ATTR_MASSIF_ALLOCFN, Arrays.asList(allocFnList.getItems()));
+               configuration.setAttribute(ATTR_MASSIF_THRESHOLD, thresholdSpinner.getSelection());
+               configuration.setAttribute(ATTR_MASSIF_PEAKINACCURACY, peakInaccuracySpinner.getSelection());
+               int ix = timeUnitCombo.getSelectionIndex();
+               String value;
+               if (ix == 0) {
+                       value = TIME_I;
+               }
+               else if (ix == 1) {
+                       value = TIME_MS;
+               }
+               else {
+                       value = TIME_B;
+               }
+               configuration.setAttribute(ATTR_MASSIF_TIMEUNIT, value);
+               configuration.setAttribute(ATTR_MASSIF_DETAILEDFREQ, detailedFreqSpinner.getSelection());
+               configuration.setAttribute(ATTR_MASSIF_MAXSNAPSHOTS, maxSnapshotsSpinner.getSelection());
+               configuration.setAttribute(ATTR_MASSIF_ALIGNMENT, alignmentSpinner.getSelection());
+       }
+
+       public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
+               configuration.setAttribute(ATTR_MASSIF_HEAP, true);
+               configuration.setAttribute(ATTR_MASSIF_HEAPADMIN, 8);
+               configuration.setAttribute(ATTR_MASSIF_STACKS, false);
+               configuration.setAttribute(ATTR_MASSIF_DEPTH, 30);
+               configuration.setAttribute(ATTR_MASSIF_ALLOCFN, Collections.EMPTY_LIST);
+               configuration.setAttribute(ATTR_MASSIF_THRESHOLD, 10);
+               configuration.setAttribute(ATTR_MASSIF_PEAKINACCURACY, 10);
+               configuration.setAttribute(ATTR_MASSIF_TIMEUNIT, TIME_I);
+               configuration.setAttribute(ATTR_MASSIF_DETAILEDFREQ, 10);
+               configuration.setAttribute(ATTR_MASSIF_MAXSNAPSHOTS, 100);
+               configuration.setAttribute(ATTR_MASSIF_ALIGNMENT, 8);
+       }
+       
+       protected void createHorizontalSpacer(Composite comp, int numlines) {
+               Label lbl = new Label(comp, SWT.NONE);
+               GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+               gd.horizontalSpan = numlines;
+               lbl.setLayoutData(gd);
+       }
+       
+       @Override
+       protected void updateLaunchConfigurationDialog() {
+               if (!isInitializing) {
+                       super.updateLaunchConfigurationDialog();
+               }
+       }
+
+}
diff --git a/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/valgrind/massif/MassifTreeViewer.java b/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/valgrind/massif/MassifTreeViewer.java
new file mode 100644 (file)
index 0000000..53fa9c7
--- /dev/null
@@ -0,0 +1,114 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Elliott Baron <ebaron@redhat.com> - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.valgrind.massif;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.debug.core.model.ISourceLocator;
+import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector;
+import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.debug.ui.IDebugUIConstants;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TreeSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.linuxtools.profiling.ui.ProfileUIUtils;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.PartInitException;
+
+public class MassifTreeViewer extends TreeViewer {
+
+       protected IDoubleClickListener doubleClickListener;
+       protected ITreeContentProvider contentProvider;
+
+       public MassifTreeViewer(Composite parent) {
+               super(parent);
+               
+               contentProvider = new ITreeContentProvider() {
+                       public Object[] getChildren(Object parentElement) {
+                               return ((MassifHeapTreeNode) parentElement).getChildren();
+                       }
+
+                       public Object getParent(Object element) {
+                               return ((MassifHeapTreeNode) element).getParent();
+                       }
+
+                       public boolean hasChildren(Object element) {
+                               MassifHeapTreeNode[] children = ((MassifHeapTreeNode) element).getChildren();
+                               return children != null && children.length > 0;
+                       }
+
+                       public Object[] getElements(Object inputElement) {
+                               return (Object[]) inputElement;
+                       }
+
+                       public void dispose() {}
+
+                       public void inputChanged(Viewer viewer, Object oldInput,
+                                       Object newInput) {}
+
+               };
+               setContentProvider(contentProvider);
+
+               setLabelProvider(new LabelProvider() {
+                       @Override
+                       public String getText(Object element) {
+                               return ((MassifHeapTreeNode) element).getText();
+                       }
+
+                       @Override
+                       public Image getImage(Object element) {
+                               Image img = null;
+                               if (((MassifHeapTreeNode) element).getParent() == null) { // only show for root elements
+                                       img = MassifPlugin.imageDescriptorFromPlugin(MassifPlugin.PLUGIN_ID, "icons/memory_view.gif").createImage(); //$NON-NLS-1$
+                               } else { // stack frame
+                                       img = DebugUITools.getImage(IDebugUIConstants.IMG_OBJS_STACKFRAME);
+                               }
+                               return img;
+                       }
+               });
+
+               doubleClickListener = new IDoubleClickListener() {
+                       public void doubleClick(DoubleClickEvent event) {
+                               MassifHeapTreeNode element = (MassifHeapTreeNode) ((TreeSelection) event.getSelection()).getFirstElement();
+                               if (element.hasSourceFile()) {
+                                       // do source lookup
+                                       ISourceLocator sourceLocator = MassifPlugin.getDefault().getSourceLocator();
+                                       if (sourceLocator instanceof ISourceLookupDirector) {
+                                               Object obj = ((ISourceLookupDirector) sourceLocator).getSourceElement(element.getFilename());
+                                               if (obj != null && obj instanceof IFile) {
+                                                       try {
+                                                               ProfileUIUtils.openEditorAndSelect(((IFile) obj).getLocation().toOSString(), element.getLine());
+                                                       } catch (PartInitException e) {
+                                                               e.printStackTrace();
+                                                       } catch (org.eclipse.jface.text.BadLocationException e) {
+                                                               // TODO Auto-generated catch block
+                                                               e.printStackTrace();
+                                                       }
+                                               }
+                                       }
+                               } 
+                               if (contentProvider.hasChildren(element)) {
+                                       expandToLevel(element, 1);
+                               }
+                       }                       
+               };
+               addDoubleClickListener(doubleClickListener);
+       }
+
+       public IDoubleClickListener getDoubleClickListener() {
+               return doubleClickListener;
+       }
+
+}
diff --git a/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/valgrind/massif/MassifViewPart.java b/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/valgrind/massif/MassifViewPart.java
new file mode 100644 (file)
index 0000000..22254ce
--- /dev/null
@@ -0,0 +1,432 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Elliott Baron <ebaron@redhat.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.valgrind.massif;
+
+import java.text.DecimalFormat;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.IFontProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerComparator;
+import org.eclipse.linuxtools.valgrind.massif.MassifSnapshot.SnapshotType;
+import org.eclipse.linuxtools.valgrind.massif.birt.ChartEditorInput;
+import org.eclipse.linuxtools.valgrind.massif.birt.HeapChart;
+import org.eclipse.linuxtools.valgrind.ui.IValgrindToolView;
+import org.eclipse.linuxtools.valgrind.ui.ValgrindUIPlugin;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StackLayout;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.ViewPart;
+
+public class MassifViewPart extends ViewPart implements IValgrindToolView {
+
+       protected static final String TITLE_STACKS = Messages
+       .getString("MassifViewPart.Stacks"); //$NON-NLS-1$
+       protected static final String TITLE_EXTRA = Messages
+       .getString("MassifViewPart.Extra_Heap"); //$NON-NLS-1$
+       protected static final String TITLE_USEFUL = Messages
+       .getString("MassifViewPart.Useful_Heap"); //$NON-NLS-1$
+       protected static final String TITLE_TOTAL = Messages
+       .getString("MassifViewPart.Total"); //$NON-NLS-1$
+       protected static final String TITLE_TIME = Messages
+       .getString("MassifViewPart.Time"); //$NON-NLS-1$
+       protected static final String TITLE_NUMBER = Messages
+       .getString("MassifViewPart.Snapshot"); //$NON-NLS-1$
+       protected static final String TREE_ACTION = MassifPlugin.PLUGIN_ID
+       + ".treeAction"; //$NON-NLS-1$
+       public static final String CHART_ACTION = MassifPlugin.PLUGIN_ID
+       + ".chartAction"; //$NON-NLS-1$
+       public static final String PID_ACTION = MassifPlugin.PLUGIN_ID
+       + ".pidAction"; //$NON-NLS-1$
+
+       protected MassifOutput output;
+       protected Integer pid;
+
+       protected Composite top;
+       protected StackLayout stackLayout;
+       protected TableViewer viewer;
+       protected MassifTreeViewer treeViewer;
+       protected MassifHeapTreeNode[] nodes;
+
+       protected static final int COLUMN_SIZE = 125;
+
+       protected Action treeAction;
+       protected Action chartAction;
+       protected MassifPidMenuAction pidAction;
+       
+       protected List<ChartEditorInput> chartInputs;
+
+       @Override
+       public void createPartControl(Composite parent) {
+               chartInputs = new ArrayList<ChartEditorInput>();
+               
+               top = new Composite(parent, SWT.NONE);
+               stackLayout = new StackLayout();
+               top.setLayout(stackLayout);
+               top.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+               viewer = new TableViewer(top, SWT.SINGLE | SWT.BORDER
+                               | SWT.FULL_SELECTION);
+
+               Table table = viewer.getTable();
+               table.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+
+               String[] columnTitles = { TITLE_NUMBER, TITLE_TIME, TITLE_TOTAL,
+                               TITLE_USEFUL, TITLE_EXTRA, TITLE_STACKS };
+
+               for (int i = 0; i < columnTitles.length; i++) {
+                       TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
+                       column.getColumn().setText(columnTitles[i]);
+                       column.getColumn().setWidth(COLUMN_SIZE);
+                       column.getColumn().setResizable(true);
+                       column.getColumn().addSelectionListener(getHeaderListener());
+               }
+               table.setHeaderVisible(true);
+               table.setLinesVisible(true);
+
+               viewer.setContentProvider(new ArrayContentProvider());
+               viewer.setLabelProvider(new MassifLabelProvider());
+
+               treeViewer = new MassifTreeViewer(top);
+               treeViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
+
+               viewer.addDoubleClickListener(new IDoubleClickListener() {
+                       public void doubleClick(DoubleClickEvent event) {
+                               MassifSnapshot snapshot = (MassifSnapshot) ((IStructuredSelection) event
+                                               .getSelection()).getFirstElement();
+                               if (snapshot.getType() != SnapshotType.EMPTY) {
+                                       treeAction.setChecked(true);
+                                       setTopControl(treeViewer.getControl());
+                                       treeViewer.setSelection(new StructuredSelection(snapshot
+                                                       .getRoot()), true);
+                                       treeViewer.expandToLevel(snapshot.getRoot(),
+                                                       TreeViewer.ALL_LEVELS);
+                               }
+                       }
+               });
+
+               setTopControl(viewer.getControl());
+       }
+
+       private String getUnitString(MassifSnapshot[] snapshots) {
+               String result;
+               MassifSnapshot snapshot = snapshots[0];
+               switch (snapshot.getUnit()) {
+               case BYTES:
+                       result = "B"; //$NON-NLS-1$
+                       break;
+               case INSTRUCTIONS:
+                       result = "i"; //$NON-NLS-1$
+                       break;
+               default:
+                       result = "ms"; //$NON-NLS-1$
+               break;
+               }
+               return result;
+       }
+
+       private SelectionListener getHeaderListener() {
+               return new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               TableColumn column = (TableColumn) e.widget;
+                               Table table = viewer.getTable();
+                               if (column.equals(table.getSortColumn())) {
+                                       int direction = table.getSortDirection() == SWT.UP ? SWT.DOWN
+                                                       : SWT.UP;
+                                       table.setSortDirection(direction);
+                               } else {
+                                       table.setSortDirection(SWT.DOWN);
+                               }
+                               table.setSortColumn(column);
+                               viewer.setComparator(new ViewerComparator() {
+                                       @Override
+                                       public int compare(Viewer viewer, Object o1, Object o2) {
+                                               Table table = ((TableViewer) viewer).getTable();
+                                               int direction = table.getSortDirection();
+                                               MassifSnapshot s1 = (MassifSnapshot) o1;
+                                               MassifSnapshot s2 = (MassifSnapshot) o2;
+                                               long result;
+                                               TableColumn column = table.getSortColumn();
+                                               if (column.getText().equals(TITLE_NUMBER)) {
+                                                       result = s1.getNumber() - s2.getNumber();
+                                               } else if (column.getText().startsWith(TITLE_TIME)) {
+                                                       result = s1.getTime() - s2.getTime();
+                                               } else if (column.getText().equals(TITLE_TOTAL)) {
+                                                       result = s1.getTotal() - s2.getTotal();
+                                               } else if (column.getText().equals(TITLE_USEFUL)) {
+                                                       result = s1.getHeapBytes() - s2.getHeapBytes();
+                                               } else if (column.getText().equals(TITLE_EXTRA)) {
+                                                       result = s1.getHeapExtra() - s2.getHeapExtra();
+                                               } else {
+                                                       result = s1.getStacks() - s2.getStacks();
+                                               }
+
+                                               // overflow check
+                                               if (result > Integer.MAX_VALUE) {
+                                                       result = Integer.MAX_VALUE;
+                                               } else if (result < Integer.MIN_VALUE) {
+                                                       result = Integer.MIN_VALUE;
+                                               }
+                                               return (int) (direction == SWT.DOWN ? result : -result);
+                                       }
+                               });
+                       }
+               };
+       }
+
+       public IAction[] getToolbarActions() {
+               pidAction = new MassifPidMenuAction(this);
+               pidAction.setId(PID_ACTION);
+               
+               chartAction = new Action(
+                               Messages.getString("MassifViewPart.Display_Heap_Allocation"), IAction.AS_PUSH_BUTTON) { //$NON-NLS-1$
+                       @Override
+                       public void run() {
+                               ChartEditorInput input = getChartInput(pid);
+                               if (input != null) {                                    
+                                       displayChart(input);
+                               }
+                       }
+               };
+               chartAction.setId(CHART_ACTION);
+               chartAction.setImageDescriptor(MassifPlugin.imageDescriptorFromPlugin(
+                               MassifPlugin.PLUGIN_ID, "icons/linecharticon.gif")); //$NON-NLS-1$
+               chartAction.setToolTipText(Messages
+                               .getString("MassifViewPart.Display_Heap_Allocation")); //$NON-NLS-1$
+
+               treeAction = new Action(
+                               Messages.getString("MassifViewPart.Show_Heap_Tree"), IAction.AS_CHECK_BOX) { //$NON-NLS-1$
+                       @Override
+                       public void run() {
+                               if (isChecked()) {
+                                       setTopControl(treeViewer.getControl());
+                               } else {
+                                       setTopControl(viewer.getControl());
+                               }
+                       }
+               };
+               treeAction.setId(TREE_ACTION);
+               treeAction.setImageDescriptor(MassifPlugin.imageDescriptorFromPlugin(
+                               MassifPlugin.PLUGIN_ID, "icons/call_hierarchy.gif")); //$NON-NLS-1$
+               treeAction.setToolTipText(Messages
+                               .getString("MassifViewPart.Show_Heap_Tree")); //$NON-NLS-1$
+
+               return new IAction[] { pidAction, chartAction, treeAction };
+       }
+
+       protected void createChart(MassifSnapshot[] snapshots) {
+               HeapChart chart = new HeapChart(snapshots);
+               String title = ValgrindUIPlugin.getDefault().getView().getContentDescription() + " [PID: " + pid + "]";  //$NON-NLS-1$//$NON-NLS-2$
+               chart.getTitle().getLabel().getCaption().setValue(title);
+
+               String name = getInputName(title);
+               ChartEditorInput input = new ChartEditorInput(chart, name, pid);
+               chartInputs.add(input);
+
+               // open the editor
+               displayChart(input);
+       }
+
+       protected void displayChart(final ChartEditorInput chartInput) {
+               Display.getDefault().syncExec(new Runnable() {
+                       public void run() {
+                               try {
+                                       IWorkbenchPage page = PlatformUI.getWorkbench()
+                                       .getActiveWorkbenchWindow().getActivePage();
+                                       page.openEditor(chartInput, MassifPlugin.EDITOR_ID);
+                               } catch (PartInitException e) {
+                                       e.printStackTrace();
+                               }
+                       }
+               });
+       }
+
+       protected String getInputName(String description) {
+               String launchName = description.substring(0, description
+                               .indexOf("[massif]")); //$NON-NLS-1$
+               return launchName.trim();
+       }
+
+       @Override
+       public void setFocus() {
+               viewer.getTable().setFocus();
+       }
+
+       public void refreshView() {
+               if (output != null && pid != null) {
+                       MassifSnapshot[] snapshots = output.getSnapshots(pid);
+                       pidAction.setPids(output.getPids());
+                       if (snapshots != null) {
+                               viewer.setInput(snapshots);
+
+                               String timeWithUnit = TITLE_TIME + " (" + getUnitString(snapshots) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+                               for (TableColumn column : viewer.getTable().getColumns()) {
+                                       if (column.getText().startsWith(TITLE_TIME)) {
+                                               column.setText(timeWithUnit);
+                                       }
+                                       viewer.getTable().layout(true);
+                               }
+                               MassifSnapshot[] detailed = getDetailed(snapshots);
+                               nodes = new MassifHeapTreeNode[detailed.length];
+                               for (int i = 0; i < detailed.length; i++) {
+                                       nodes[i] = detailed[i].getRoot();
+                               }
+                               treeViewer.setInput(nodes);
+
+                               // create and display chart
+                               if (snapshots.length > 0) {
+                                       ChartEditorInput input = getChartInput(pid);
+                                       if (input == null) {
+                                               createChart(snapshots);
+                                       }
+                                       else {
+                                               displayChart(input);
+                                       }
+                               }
+                       }
+               }
+       }
+
+       public void setTopControl(Control control) {
+               stackLayout.topControl = control;
+               top.layout(true);
+       }
+
+       public void setOutput(MassifOutput output) {
+               this.output = output;
+       }
+
+       public void setPid(Integer pid) {
+               this.pid = pid;
+       }
+       
+       public MassifSnapshot[] getSnapshots() {
+               return output != null && pid != null ? output.getSnapshots(pid) : null;
+       }
+
+       public TableViewer getTableViewer() {
+               return viewer;
+       }
+
+       public TreeViewer getTreeViewer() {
+               return treeViewer;
+       }
+
+       public class MassifLabelProvider extends LabelProvider implements
+       ITableLabelProvider, IFontProvider {
+
+               public Image getColumnImage(Object element, int columnIndex) {
+                       Image image = null;
+                       if (columnIndex == 0) {
+                               MassifSnapshot snapshot = (MassifSnapshot) element;
+                               switch (snapshot.getType()) {
+                               case EMPTY:
+                                       break;
+                               case PEAK:
+                               case DETAILED:
+                                       image = MassifPlugin
+                                       .imageDescriptorFromPlugin(MassifPlugin.PLUGIN_ID,
+                                       "icons/call_hierarchy.gif").createImage(); //$NON-NLS-1$
+                                       break;
+                               default:
+                                       break;
+                               }
+                       }
+                       return image;
+               }
+
+               public String getColumnText(Object element, int columnIndex) {
+                       MassifSnapshot snapshot = (MassifSnapshot) element;
+                       DecimalFormat df = new DecimalFormat("#,##0"); //$NON-NLS-1$
+                       switch (columnIndex) {
+                       case 0:
+                               return df.format(snapshot.getNumber());
+                       case 1:
+                               return df.format(snapshot.getTime());
+                       case 2:
+                               return df.format(snapshot.getTotal());
+                       case 3:
+                               return df.format(snapshot.getHeapBytes());
+                       case 4:
+                               return df.format(snapshot.getHeapExtra());
+                       default:
+                               return df.format(snapshot.getStacks());
+                       }
+               }
+
+               public Font getFont(Object element) {
+                       Font font = null;
+                       MassifSnapshot snapshot = (MassifSnapshot) element;
+                       switch (snapshot.getType()) {
+                       case EMPTY:
+                       case DETAILED:
+                               break;
+                       case PEAK:
+                               font = JFaceResources.getFontRegistry().getBold(
+                                               JFaceResources.DIALOG_FONT);
+                               break;
+                       default:
+                               break;
+                       }
+                       return font;
+               }
+       }
+
+       private MassifSnapshot[] getDetailed(MassifSnapshot[] snapshots) {
+               ArrayList<MassifSnapshot> list = new ArrayList<MassifSnapshot>();
+               for (MassifSnapshot snapshot : snapshots) {
+                       if (snapshot.getType() != SnapshotType.EMPTY) {
+                               list.add(snapshot);
+                       }
+               }
+               return list.toArray(new MassifSnapshot[list.size()]);
+       }
+       
+       private ChartEditorInput getChartInput(Integer pid) {
+               ChartEditorInput result = null;
+               for (int i = 0; i < chartInputs.size(); i++) {
+                       ChartEditorInput input = chartInputs.get(i);
+                       if (input.getPid().equals(pid)) {
+                               result = input;
+                       }
+               }
+               return result;
+       }
+}
diff --git a/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/valgrind/massif/Messages.java b/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/valgrind/massif/Messages.java
new file mode 100644 (file)
index 0000000..56fb907
--- /dev/null
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Elliott Baron <ebaron@redhat.com> - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.valgrind.massif;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class Messages {
+       private static final String BUNDLE_NAME = "org.eclipse.linuxtools.valgrind.massif.messages"; //$NON-NLS-1$
+
+       private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
+                       .getBundle(BUNDLE_NAME);
+
+       private Messages() {
+       }
+
+       public static String getString(String key) {
+               try {
+                       return RESOURCE_BUNDLE.getString(key);
+               } catch (MissingResourceException e) {
+                       return '!' + key + '!';
+               }
+       }
+}
diff --git a/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/valgrind/massif/PowerOfTwoSpinner.java b/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/valgrind/massif/PowerOfTwoSpinner.java
new file mode 100644 (file)
index 0000000..64cba23
--- /dev/null
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Elliott Baron <ebaron@redhat.com> - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.valgrind.massif;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Spinner;
+
+public class PowerOfTwoSpinner {
+       protected Spinner spinner;
+       protected int previous;
+       
+       public PowerOfTwoSpinner(Composite parent, int style) {
+               spinner = new Spinner(parent, style | SWT.READ_ONLY);
+               spinner.addSelectionListener(new SelectionAdapter() {
+                       public void widgetSelected(SelectionEvent e) {
+                               int selection = spinner.getSelection();
+                               if (selection > previous) {
+                                       setSelection((selection - 1) << 1); 
+                               }
+                               else {
+                                       setSelection((selection + 1) >> 1); 
+                               }
+                       }                       
+               });
+               spinner.setPageIncrement(1);
+               previous = 0;
+       }
+       
+       public void setSelection(int value) {
+               previous = value;
+               spinner.setSelection(value);
+       }
+       
+       public void addModifyListener(ModifyListener listener) {
+               spinner.addModifyListener(listener);
+       }
+       
+       public void setMaximum(int value) {
+               spinner.setMaximum(value);
+       }
+       
+       public void setMinimum(int value) {
+               spinner.setMinimum(value);
+       }
+       
+       public int getSelection() {
+               return spinner.getSelection();
+       }
+}
diff --git a/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/valgrind/massif/birt/ChartControl.java b/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/valgrind/massif/birt/ChartControl.java
new file mode 100644 (file)
index 0000000..a3dc57f
--- /dev/null
@@ -0,0 +1,223 @@
+/***********************************************************************
+ * Copyright (c) 2004, 2005 Actuate Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Actuate Corporation - initial API and implementation
+ * Elliott Baron <ebaron@redhat.com> - Modified implementation
+ ***********************************************************************/
+package org.eclipse.linuxtools.valgrind.massif.birt;
+
+import org.eclipse.birt.chart.computation.DataPointHints;
+import org.eclipse.birt.chart.device.ICallBackNotifier;
+import org.eclipse.birt.chart.device.IDeviceRenderer;
+import org.eclipse.birt.chart.event.WrappedStructureSource;
+import org.eclipse.birt.chart.exception.ChartException;
+import org.eclipse.birt.chart.factory.GeneratedChartState;
+import org.eclipse.birt.chart.factory.Generator;
+import org.eclipse.birt.chart.factory.RunTimeContext;
+import org.eclipse.birt.chart.model.Chart;
+import org.eclipse.birt.chart.model.attribute.Bounds;
+import org.eclipse.birt.chart.model.attribute.CallBackValue;
+import org.eclipse.birt.chart.model.attribute.impl.BoundsImpl;
+import org.eclipse.birt.chart.util.PluginSettings;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.linuxtools.valgrind.massif.MassifViewPart;
+import org.eclipse.linuxtools.valgrind.ui.ValgrindUIPlugin;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ControlEvent;
+import org.eclipse.swt.events.ControlListener;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+
+public class ChartControl extends Canvas implements PaintListener, ControlListener, ICallBackNotifier {
+
+       private transient boolean bIsPainting = false;
+
+       private transient Image buffer;
+
+       private static int X_OFFSET = 3;
+
+       private static int Y_OFFSET = 3;
+
+       protected Chart cm = null;
+
+       protected GeneratedChartState state = null;
+
+       protected IDeviceRenderer deviceRenderer = null;
+
+       private boolean needsGeneration = true;
+
+       public ChartControl(Composite parent, Chart chart, int style) {
+               super(parent, SWT.BORDER);
+               cm = chart;
+               setLayoutData(new GridData(GridData.FILL_BOTH));
+               setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
+
+               try {
+                       deviceRenderer = PluginSettings.instance().getDevice("dv.SWT"); //$NON-NLS-1$
+                       deviceRenderer.setProperty(IDeviceRenderer.UPDATE_NOTIFIER, this);
+
+                       addDisposeListener(new DisposeListener() {
+                               public void widgetDisposed(DisposeEvent e) {
+                                       deviceRenderer.dispose();
+                               }                               
+                       });
+
+                       addPaintListener(this);
+                       addControlListener(this);
+               } catch (ChartException e) {
+                       e.printStackTrace();
+               }
+       }
+
+       public void callback(Object event, Object source, CallBackValue value) {
+               DataPointHints point = ((DataPointHints)((WrappedStructureSource)source).getSource());
+               MassifViewPart view = (MassifViewPart) ValgrindUIPlugin.getDefault().getView().getDynamicView();
+               // select the corresponding snapshot in the TableViewer
+               TableViewer viewer = view.getTableViewer();
+               view.setTopControl(viewer.getControl());
+               viewer.setSelection(new StructuredSelection(viewer.getElementAt(point.getIndex())));
+       }
+
+       public Chart getDesignTimeModel() {
+               return cm;
+       }
+
+       public Chart getRunTimeModel() {
+               return state.getChartModel();
+       }
+
+       public Object peerInstance() {
+               return this;
+       }
+
+       public void regenerateChart() {
+               needsGeneration = true;
+               redraw();
+       }
+
+       public void repaintChart() {
+               redraw();
+       }
+
+       public void paintControl(PaintEvent pe) {
+               if (bIsPainting) {
+                       return;
+               }
+               Throwable paintError = null;
+
+               Rectangle re = getClientArea();
+               final Rectangle adjustedRe = new Rectangle(0, 0, re.width, re.height);
+
+               if (adjustedRe.width - 2 * X_OFFSET <= 0
+                               || adjustedRe.height - 2 * Y_OFFSET <= 0) {
+                       if (buffer != null && !buffer.isDisposed()) {
+                               buffer.dispose();
+                               buffer = null;
+                       }
+                       return;
+               }
+
+               if (cm == null) {
+                       buffer = null;
+               } else {
+                       bIsPainting = true;
+                       Image oldBuffer = null;
+                       if (buffer == null) {
+                               buffer = new Image(Display.getDefault(), adjustedRe);
+                       } else {
+                               Rectangle ore = buffer.getBounds();
+
+                               oldBuffer = buffer;
+
+                               if (!adjustedRe.equals(ore)) {
+                                       buffer = new Image(Display.getDefault(), adjustedRe);
+                               }
+                       }
+
+                       GC gcImage = new GC(buffer);
+
+                       // fill default backgournd as white.
+                       gcImage.setForeground(Display.getDefault().getSystemColor(
+                                       SWT.COLOR_WHITE));
+                       gcImage.fillRectangle(buffer.getBounds());
+
+                       Bounds bo = BoundsImpl.create(X_OFFSET, Y_OFFSET,
+                                       adjustedRe.width - 2 * X_OFFSET, adjustedRe.height - 2
+                                       * Y_OFFSET);
+
+                       try {
+                               deviceRenderer.setProperty(IDeviceRenderer.GRAPHICS_CONTEXT, gcImage);
+
+                               bo.scale(72d / deviceRenderer.getDisplayServer()
+                                               .getDpiResolution()); // convert to points
+
+                               // generate and render the cart
+                               Generator gr = Generator.instance();
+                               if (needsGeneration) {
+                                       needsGeneration = false;
+                                       RunTimeContext rtc = new RunTimeContext();
+
+                                       state = gr.build(deviceRenderer
+                                                       .getDisplayServer(), cm, bo, null, rtc, null);
+
+                               }
+                               gr.render(deviceRenderer, state);
+                               if (paintError != null) {
+                                       buffer = oldBuffer;
+                               }
+                               if (oldBuffer != null && oldBuffer != buffer) {
+                                       oldBuffer.dispose();
+                               }
+                               GC gc = pe.gc;
+                               if (buffer != null) {
+                                       gc.drawImage(buffer, 0, 0);
+                               }
+                       } catch (ChartException ex) {
+                               paintError = ex;
+                       } finally {
+                               gcImage.dispose();
+                       }                       
+                       bIsPainting = false;
+               }
+
+
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see
+        * org.eclipse.swt.events.ControlListener#controlMoved(org.eclipse.swt.events
+        * .ControlEvent)
+        */
+       public void controlMoved(ControlEvent e) {
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see
+        * org.eclipse.swt.events.ControlListener#controlResized(org.eclipse.swt
+        * .events.ControlEvent)
+        */
+       public void controlResized(ControlEvent e) {
+               needsGeneration = true;
+               redraw();
+       }
+
+}
diff --git a/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/valgrind/massif/birt/ChartEditor.java b/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/valgrind/massif/birt/ChartEditor.java
new file mode 100644 (file)
index 0000000..2d2ed7c
--- /dev/null
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Elliott Baron <ebaron@redhat.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.valgrind.massif.birt;
+
+import org.eclipse.birt.chart.model.Chart;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.part.EditorPart;
+
+public class ChartEditor extends EditorPart {
+       protected ChartControl control;
+
+       @Override
+       public void doSave(IProgressMonitor monitor) {
+       }
+
+       @Override
+       public void doSaveAs() {
+       }
+
+       @Override
+       public void init(IEditorSite site, IEditorInput input)
+                       throws PartInitException {
+               if (input instanceof ChartEditorInput) {
+                       setInput(input);
+                       setSite(site);
+                       setPartName(NLS.bind(Messages.getString("ChartEditor.Heap_Chart"), input.getName())); //$NON-NLS-1$
+               }
+               else {
+                       throw new PartInitException(NLS.bind(Messages.getString("ChartEditor.Editor_input_must_be"), ChartEditorInput.class.getName())); //$NON-NLS-1$
+               }
+       }
+
+       @Override
+       public boolean isDirty() {
+               return false;
+       }
+
+       @Override
+       public boolean isSaveAsAllowed() {
+               return false;
+       }
+
+       @Override
+       public void createPartControl(Composite parent) {
+               Composite top = new Composite(parent, SWT.NONE);
+               top.setLayout(new GridLayout());
+               top.setLayoutData(new GridData(GridData.FILL_BOTH));
+               ChartEditorInput input = (ChartEditorInput) getEditorInput();
+               Chart chart = input.getChart();
+               control = new ChartControl(top, chart, SWT.NONE);
+       }
+
+       @Override
+       public void setFocus() {
+               if (control != null) {
+                       control.setFocus();
+               }
+       }
+       
+       @Override
+       public void dispose() {
+               super.dispose();
+               control.dispose();
+       }
+
+}
diff --git a/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/valgrind/massif/birt/ChartEditorInput.java b/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/valgrind/massif/birt/ChartEditorInput.java
new file mode 100644 (file)
index 0000000..631b6a0
--- /dev/null
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Elliott Baron <ebaron@redhat.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.valgrind.massif.birt;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.linuxtools.valgrind.massif.MassifPlugin;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IPersistableElement;
+
+public class ChartEditorInput implements IEditorInput {
+       
+       protected HeapChart chart;
+       protected String name;
+       protected Integer pid;
+
+       public ChartEditorInput(HeapChart chart, String name, Integer pid) {
+               this.chart = chart;
+               this.name = name;
+               this.pid = pid;
+       }
+
+       public boolean exists() {
+               return false;
+       }
+
+       public ImageDescriptor getImageDescriptor() {
+               return MassifPlugin.imageDescriptorFromPlugin(MassifPlugin.PLUGIN_ID, "icons/linecharticon.gif"); //$NON-NLS-1$
+       }
+
+       public String getName() {               
+               return name;
+       }
+       
+       public Integer getPid() {
+               return pid;
+       }
+
+       public IPersistableElement getPersistable() {
+               return null;
+       }
+
+       public String getToolTipText() {
+               return NLS.bind(Messages.getString("ChartEditorInput.Heap_allocation_chart_for"), name); //$NON-NLS-1$
+       }
+
+       public Object getAdapter(Class adapter) {
+               return null;
+       }
+       
+       public HeapChart getChart() {
+               return chart;
+       }
+
+}
diff --git a/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/valgrind/massif/birt/HeapChart.java b/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/valgrind/massif/birt/HeapChart.java
new file mode 100644 (file)
index 0000000..f7f1872
--- /dev/null
@@ -0,0 +1,401 @@
+/***********************************************************************
+ * Copyright (c) 2004, 2005 Actuate Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Actuate Corporation - initial API and implementation
+ * Elliott Baron <ebaron@redhat.com> - Modified implementation
+ ***********************************************************************/
+package org.eclipse.linuxtools.valgrind.massif.birt;
+
+import org.eclipse.birt.chart.model.attribute.ActionType;
+import org.eclipse.birt.chart.model.attribute.AxisType;
+import org.eclipse.birt.chart.model.attribute.ChartDimension;
+import org.eclipse.birt.chart.model.attribute.FontDefinition;
+import org.eclipse.birt.chart.model.attribute.IntersectionType;
+import org.eclipse.birt.chart.model.attribute.Marker;
+import org.eclipse.birt.chart.model.attribute.MarkerType;
+import org.eclipse.birt.chart.model.attribute.Orientation;
+import org.eclipse.birt.chart.model.attribute.Position;
+import org.eclipse.birt.chart.model.attribute.TickStyle;
+import org.eclipse.birt.chart.model.attribute.TriggerCondition;
+import org.eclipse.birt.chart.model.attribute.impl.CallBackValueImpl;
+import org.eclipse.birt.chart.model.attribute.impl.ColorDefinitionImpl;
+import org.eclipse.birt.chart.model.component.Axis;
+import org.eclipse.birt.chart.model.component.Series;
+import org.eclipse.birt.chart.model.component.impl.SeriesImpl;
+import org.eclipse.birt.chart.model.data.BaseSampleData;
+import org.eclipse.birt.chart.model.data.DataFactory;
+import org.eclipse.birt.chart.model.data.NumberDataSet;
+import org.eclipse.birt.chart.model.data.OrthogonalSampleData;
+import org.eclipse.birt.chart.model.data.SampleData;
+import org.eclipse.birt.chart.model.data.SeriesDefinition;
+import org.eclipse.birt.chart.model.data.impl.ActionImpl;
+import org.eclipse.birt.chart.model.data.impl.NumberDataSetImpl;
+import org.eclipse.birt.chart.model.data.impl.SeriesDefinitionImpl;
+import org.eclipse.birt.chart.model.data.impl.TriggerImpl;
+import org.eclipse.birt.chart.model.impl.ChartWithAxesImpl;
+import org.eclipse.birt.chart.model.layout.Legend;
+import org.eclipse.birt.chart.model.layout.Plot;
+import org.eclipse.birt.chart.model.type.LineSeries;
+import org.eclipse.birt.chart.model.type.impl.LineSeriesImpl;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.linuxtools.valgrind.massif.MassifSnapshot;
+import org.eclipse.linuxtools.valgrind.massif.MassifSnapshot.TimeUnit;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
+
+public class HeapChart extends ChartWithAxesImpl {
+
+       private static String[] byteUnits = { Messages.getString("HeapChart.B"), //$NON-NLS-1$
+                       Messages.getString("HeapChart.KiB"), //$NON-NLS-1$
+                       Messages.getString("HeapChart.MiB"), //$NON-NLS-1$
+                       Messages.getString("HeapChart.GiB"), //$NON-NLS-1$
+                       Messages.getString("HeapChart.TiB") //$NON-NLS-1$
+       };
+       private static String[] instrUnits = { Messages.getString("HeapChart.i"), //$NON-NLS-1$
+                       Messages.getString("HeapChart.Ki"), //$NON-NLS-1$
+                       Messages.getString("HeapChart.Mi"), //$NON-NLS-1$
+                       Messages.getString("HeapChart.Gi"), //$NON-NLS-1$
+                       Messages.getString("HeapChart.Ti") //$NON-NLS-1$
+       };
+       private static String[] secondUnits = { Messages.getString("HeapChart.ms"), //$NON-NLS-1$
+                       Messages.getString("HeapChart.s") //$NON-NLS-1$
+       };
+
+       protected static final int BYTE_MULT = 1024;
+       protected static final int BYTE_LIMIT = byteUnits.length - 1;
+       protected static final int INSTR_MULT = 1000;
+       protected static final int INSTR_LIMIT = instrUnits.length - 1;
+       protected static final int MS_MULT = 1000;
+       protected static final int MS_LIMIT = secondUnits.length - 1;
+
+       protected static final int SCALING_THRESHOLD = 20;
+
+       protected String xUnits;
+       protected String yUnits;
+
+       public HeapChart(MassifSnapshot[] snapshots) {
+               TimeUnit timeUnit = snapshots[0].getUnit();
+               long xScaling = getXScaling(snapshots, timeUnit);
+               long yScaling = getYScaling(snapshots);
+
+               double[] time = new double[snapshots.length];
+               double[] dataUseful = new double[snapshots.length];
+               double[] dataExtra = new double[snapshots.length];
+               double[] dataStacks = null;
+
+               boolean isStack = isStackProfiled(snapshots);
+               if (isStack) {
+                       dataStacks = new double[snapshots.length];
+               }
+               double[] dataTotal = new double[snapshots.length];
+               for (int i = 0; i < snapshots.length; i++) {
+                       time[i] = snapshots[i].getTime() / xScaling;
+                       dataUseful[i] = snapshots[i].getHeapBytes() / yScaling;
+                       dataExtra[i] = snapshots[i].getHeapExtra() / yScaling;
+                       dataTotal[i] = dataUseful[i] + dataExtra[i];
+                       if (isStack) {
+                               dataStacks[i] = snapshots[i].getStacks() / yScaling;
+                               dataStacks[i] += dataStacks[i];
+                       }
+               }
+
+               initialize();
+               setDimension(ChartDimension.TWO_DIMENSIONAL_LITERAL);
+               setType("Line Chart"); //$NON-NLS-1$
+               setSubType("Overlay"); //$NON-NLS-1$
+
+               Font font = JFaceResources.getDialogFont();
+               FontData fd = font.getFontData()[0];
+
+               // Title
+               FontDefinition titleFont = getTitle().getLabel().getCaption().getFont();
+               titleFont.setName(fd.getName());
+               titleFont.setSize(fd.getHeight() + 2);
+
+               // Plot
+               getBlock().setBackground(ColorDefinitionImpl.WHITE());
+               Plot p = getPlot();
+               p.getClientArea().setBackground(
+                               ColorDefinitionImpl.create(255, 255, 225));
+
+               // X-Axis
+               Axis xAxisPrimary = getPrimaryBaseAxes()[0];
+               xAxisPrimary.setType(AxisType.LINEAR_LITERAL);
+               xAxisPrimary.getMajorGrid().setTickStyle(TickStyle.BELOW_LITERAL);
+               xAxisPrimary.getOrigin().setType(IntersectionType.VALUE_LITERAL);
+               xAxisPrimary.getTitle().getCaption().setValue(xUnits);
+               xAxisPrimary.getTitle().setVisible(true);
+
+               FontDefinition xAxisFont = xAxisPrimary.getTitle().getCaption()
+                               .getFont();
+               xAxisFont.setName(fd.getName());
+               xAxisFont.setSize(fd.getHeight());
+
+               xAxisFont = xAxisPrimary.getLabel().getCaption().getFont();
+               xAxisFont.setName(fd.getName());
+               xAxisFont.setSize(fd.getHeight());
+
+               // Y-Axis
+               Axis yAxisPrimary = getPrimaryOrthogonalAxis(xAxisPrimary);
+               yAxisPrimary.getMajorGrid().setTickStyle(TickStyle.LEFT_LITERAL);
+               yAxisPrimary.getMajorGrid().getLineAttributes().setVisible(true);
+               yAxisPrimary.getTitle().getCaption().setValue(yUnits);
+               yAxisPrimary.getTitle().setVisible(true);
+
+               FontDefinition yAxisFont = yAxisPrimary.getTitle().getCaption()
+                               .getFont();
+               yAxisFont.setName(fd.getName());
+               yAxisFont.setSize(fd.getHeight());
+
+               yAxisFont = yAxisPrimary.getLabel().getCaption().getFont();
+               yAxisFont.setName(fd.getName());
+               yAxisFont.setSize(fd.getHeight());
+
+               // // Z-Axis
+               // Axis zAxis = AxisImpl.create(Axis.ANCILLARY_BASE);
+               // zAxis.setType(AxisType.LINEAR_LITERAL);
+               // zAxis.setLabelPosition(Position.BELOW_LITERAL);
+               // zAxis.setTitlePosition(Position.BELOW_LITERAL);
+               // zAxis.getMajorGrid().setTickStyle(TickStyle.BELOW_LITERAL);
+               // zAxis.setOrientation(Orientation.HORIZONTAL_LITERAL);
+               // xAxisPrimary.getAncillaryAxes().add(zAxis);
+
+               // Legend
+               Legend legend = getLegend();
+               legend.setPosition(Position.BELOW_LITERAL);
+               legend.setOrientation(Orientation.HORIZONTAL_LITERAL);
+
+               FontDefinition legendFont = legend.getText().getFont();
+               legendFont.setName(fd.getName());
+               legendFont.setSize(fd.getHeight());
+
+               // Data Set
+               NumberDataSet mainValues = NumberDataSetImpl.create(time);
+               NumberDataSet orthoValues1 = NumberDataSetImpl.create(dataUseful);
+               NumberDataSet orthoValues2 = NumberDataSetImpl.create(dataExtra);
+               NumberDataSet orthoValuesS = null;
+               if (isStack) {
+                       orthoValuesS = NumberDataSetImpl.create(dataStacks);
+               }
+               NumberDataSet orthoValues3 = NumberDataSetImpl.create(dataTotal);
+
+               SampleData sd = DataFactory.eINSTANCE.createSampleData();
+               BaseSampleData sdBase = DataFactory.eINSTANCE.createBaseSampleData();
+               sdBase.setDataSetRepresentation("");//$NON-NLS-1$
+               sd.getBaseSampleData().add(sdBase);
+
+               OrthogonalSampleData sdOrthogonal1 = DataFactory.eINSTANCE
+                               .createOrthogonalSampleData();
+               sdOrthogonal1.setDataSetRepresentation("");//$NON-NLS-1$
+               sdOrthogonal1.setSeriesDefinitionIndex(0);
+               sd.getOrthogonalSampleData().add(sdOrthogonal1);
+
+               OrthogonalSampleData sdOrthogonal2 = DataFactory.eINSTANCE
+                               .createOrthogonalSampleData();
+               sdOrthogonal2.setDataSetRepresentation("");//$NON-NLS-1$
+               sdOrthogonal2.setSeriesDefinitionIndex(1);
+               sd.getOrthogonalSampleData().add(sdOrthogonal2);
+
+               if (isStack) {
+                       OrthogonalSampleData sdOrthogonalS = DataFactory.eINSTANCE
+                                       .createOrthogonalSampleData();
+                       sdOrthogonalS.setDataSetRepresentation("");//$NON-NLS-1$
+                       sdOrthogonalS.setSeriesDefinitionIndex(2);
+                       sd.getOrthogonalSampleData().add(sdOrthogonalS);
+               }
+
+               OrthogonalSampleData sdOrthogonal3 = DataFactory.eINSTANCE
+                               .createOrthogonalSampleData();
+               sdOrthogonal3.setDataSetRepresentation("");//$NON-NLS-1$
+               sdOrthogonal3.setSeriesDefinitionIndex(isStack ? 3 : 2);
+               sd.getOrthogonalSampleData().add(sdOrthogonal3);
+
+               setSampleData(sd);
+
+               // X-Series
+               Series seCategory = SeriesImpl.create();
+               seCategory.setDataSet(mainValues);
+               SeriesDefinition sdX = SeriesDefinitionImpl.create();
+               xAxisPrimary.getSeriesDefinitions().add(sdX);
+               sdX.getSeries().add(seCategory);
+
+               // Y-Series
+               LineSeries ls1 = (LineSeries) LineSeriesImpl.create();
+               ls1.setDataSet(orthoValues1);
+               ls1.getLineAttributes().setColor(ColorDefinitionImpl.CREAM());
+               for (int i = 0; i < ls1.getMarkers().size(); i++) {
+                       Marker marker = (Marker) ls1.getMarkers().get(i);
+                       marker.setType(MarkerType.DIAMOND_LITERAL);
+               }
+
+               ls1.setPaletteLineColor(true);
+               ls1.setSeriesIdentifier(Messages.getString("HeapChart.Useful_Heap")); //$NON-NLS-1$     
+               ls1.getTriggers().add(
+                               TriggerImpl.create(TriggerCondition.ONCLICK_LITERAL, ActionImpl
+                                               .create(ActionType.CALL_BACK_LITERAL, CallBackValueImpl
+                                                               .create(String.valueOf(ls1
+                                                                               .getSeriesIdentifier())))));
+
+               // Y-Series
+               LineSeries ls2 = (LineSeries) LineSeriesImpl.create();
+               ls2.setDataSet(orthoValues2);
+               ls2.getLineAttributes().setColor(ColorDefinitionImpl.CREAM());
+               for (int i = 0; i < ls2.getMarkers().size(); i++) {
+                       Marker marker = (Marker) ls2.getMarkers().get(i);
+                       marker.setType(MarkerType.DIAMOND_LITERAL);
+               }
+               ls2.setPaletteLineColor(true);
+               ls2.setSeriesIdentifier(Messages.getString("HeapChart.Extra_Heap")); //$NON-NLS-1$
+               ls2.getTriggers().add(
+                               TriggerImpl.create(TriggerCondition.ONCLICK_LITERAL, ActionImpl
+                                               .create(ActionType.CALL_BACK_LITERAL, CallBackValueImpl
+                                                               .create(String.valueOf(ls2
+                                                                               .getSeriesIdentifier())))));
+
+               // Y-Series
+               LineSeries lsS = null;
+               if (isStack) {
+                       lsS = (LineSeries) LineSeriesImpl.create();
+                       lsS.setDataSet(orthoValuesS);
+                       lsS.getLineAttributes().setColor(ColorDefinitionImpl.CREAM());
+                       for (int i = 0; i < lsS.getMarkers().size(); i++) {
+                               Marker marker = (Marker) lsS.getMarkers().get(i);
+                               marker.setType(MarkerType.DIAMOND_LITERAL);
+                       }
+                       lsS.setPaletteLineColor(true);
+                       lsS.setSeriesIdentifier(Messages.getString("HeapChart.Stacks")); //$NON-NLS-1$
+                       lsS.getTriggers().add(
+                                       TriggerImpl.create(TriggerCondition.ONCLICK_LITERAL, ActionImpl
+                                                       .create(ActionType.CALL_BACK_LITERAL, CallBackValueImpl
+                                                                       .create(String.valueOf(lsS
+                                                                                       .getSeriesIdentifier())))));
+               }
+
+               // Y-Series
+               LineSeries ls3 = (LineSeries) LineSeriesImpl.create();
+               ls3.setDataSet(orthoValues3);
+               ls3.getLineAttributes().setColor(ColorDefinitionImpl.CREAM());
+               for (int i = 0; i < ls3.getMarkers().size(); i++) {
+                       Marker marker = (Marker) ls3.getMarkers().get(i);
+                       marker.setType(MarkerType.DIAMOND_LITERAL);
+               }
+               ls3.setPaletteLineColor(true);
+               ls3.setSeriesIdentifier(Messages.getString("HeapChart.Total_Heap")); //$NON-NLS-1$
+               ls3.getTriggers().add(
+                               TriggerImpl.create(TriggerCondition.ONCLICK_LITERAL, ActionImpl
+                                               .create(ActionType.CALL_BACK_LITERAL, CallBackValueImpl
+                                                               .create(String.valueOf(ls3
+                                                                               .getSeriesIdentifier())))));
+
+               SeriesDefinition sdY = SeriesDefinitionImpl.create();
+               sdY.getSeriesPalette().shift(-1);
+               yAxisPrimary.getSeriesDefinitions().add(sdY);
+               sdY.getSeries().add(ls1);
+               sdY.getSeries().add(ls2);
+               if (isStack) {
+                       sdY.getSeries().add(lsS);
+               }
+               sdY.getSeries().add(ls3);
+
+               // // Z-Series
+               // SeriesDefinition sdZ = SeriesDefinitionImpl.create();
+               // zAxis.getSeriesDefinitions().add(sdZ);
+       }
+
+       private boolean isStackProfiled(MassifSnapshot[] snapshots) {
+               return getMaxStack(snapshots) > 0;
+       }
+
+       private long getYScaling(MassifSnapshot[] snapshots) {
+               long max = getMaxValue(snapshots);
+
+               int count = 0;
+               while (max > BYTE_MULT * SCALING_THRESHOLD && count < BYTE_LIMIT) {
+                       max /= BYTE_MULT;
+                       count++;
+               }
+
+               yUnits = byteUnits[count];
+
+               return (long) Math.pow(BYTE_MULT, count);
+       }
+
+       private long getXScaling(MassifSnapshot[] snapshots, TimeUnit unit) {
+               long max = snapshots[snapshots.length - 1].getTime();
+               int mult, limit;
+               String[] units;
+               switch (unit) {
+               case BYTES:
+                       mult = BYTE_MULT;
+                       limit = BYTE_LIMIT;
+                       units = byteUnits;
+                       break;
+               case INSTRUCTIONS:
+                       mult = INSTR_MULT;
+                       limit = INSTR_LIMIT;
+                       units = instrUnits;
+                       break;
+               default:
+                       mult = MS_MULT;
+                       limit = MS_LIMIT;
+                       units = secondUnits;
+                       break;
+               }
+
+               int count = 0;
+               while (max > mult * SCALING_THRESHOLD && count < limit) {
+                       max /= mult;
+                       count++;
+               }
+
+               xUnits = units[count];
+
+               return (long) Math.pow(mult, count);
+       }
+
+       private static long getMaxValue(MassifSnapshot[] snapshots) {
+               long max = 0;
+               for (MassifSnapshot snapshot : snapshots) {
+                       if (snapshot.getTotal() > max) {
+                               max = snapshot.getTotal();
+                       }
+               }
+               return max;
+       }
+
+       private static long getMaxStack(MassifSnapshot[] snapshots) {
+               long max = 0;
+               for (MassifSnapshot snapshot : snapshots) {
+                       if (snapshot.getTotal() > max) {
+                               max = snapshot.getStacks();
+                       }
+               }
+               return max;
+       }
+
+       public String getXUnits() {
+               return xUnits;
+       }
+
+       public String getYUnits() {
+               return yUnits;
+       }
+
+       public static String[] getByteUnits() {
+               return byteUnits;
+       }
+
+       public static String[] getInstrUnits() {
+               return instrUnits;
+       }
+
+       public static String[] getSecondUnits() {
+               return secondUnits;
+       }
+
+}
diff --git a/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/valgrind/massif/birt/Messages.java b/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/valgrind/massif/birt/Messages.java
new file mode 100644 (file)
index 0000000..e9a5b28
--- /dev/null
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Elliott Baron <ebaron@redhat.com> - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.valgrind.massif.birt;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class Messages {
+       private static final String BUNDLE_NAME = "org.eclipse.linuxtools.valgrind.massif.birt.messages"; //$NON-NLS-1$
+
+       private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
+                       .getBundle(BUNDLE_NAME);
+
+       private Messages() {
+       }
+
+       public static String getString(String key) {
+               try {
+                       return RESOURCE_BUNDLE.getString(key);
+               } catch (MissingResourceException e) {
+                       return '!' + key + '!';
+               }
+       }
+}
diff --git a/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/valgrind/massif/birt/messages.properties b/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/valgrind/massif/birt/messages.properties
new file mode 100644 (file)
index 0000000..834f49a
--- /dev/null
@@ -0,0 +1,19 @@
+HeapChart.B=bytes (B)
+HeapChart.Extra_Heap=Extra Heap
+HeapChart.Gi=instructions (billions)
+HeapChart.GiB=gibibytes (GiB)
+HeapChart.i=instructions
+HeapChart.Ki=instructions (thousands)
+HeapChart.KiB=kibibytes (KiB)
+HeapChart.Mi=instructions (millions)
+HeapChart.MiB=mebibytes (MiB)
+HeapChart.ms=milliseconds (ms)
+HeapChart.s=seconds (s)
+HeapChart.Ti=instructions (trillions)
+HeapChart.TiB=tebibytes (TiB)
+HeapChart.Total_Heap=Total Heap
+HeapChart.Useful_Heap=Useful Heap
+HeapChart.Stacks=Stacks
+ChartEditor.Editor_input_must_be=Editor input must be of type {0}
+ChartEditor.Heap_Chart=Heap Chart - {0}
+ChartEditorInput.Heap_allocation_chart_for=Heap allocation chart for {0}
diff --git a/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/valgrind/massif/messages.properties b/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/valgrind/massif/messages.properties
new file mode 100644 (file)
index 0000000..0cad3e5
--- /dev/null
@@ -0,0 +1,35 @@
+MassifLaunchDelegate.Error_parsing_output=Error parsing output
+MassifLaunchDelegate.Retrieving_massif_data_dir=Retrieving massif data dir failed.
+MassifParser.Cannot_parse_PID=Cannot parse PID from output file
+MassifParser.Parsing_massif_output_failed=Parsing massif output failed on line: {0}
+MassifParser.Snapshot_n=Snapshot {0} - {1}
+MassifParser.Unexpected_EOF=Unexpected EOF
+MassifPidMenuAction.Select_Process_ID=Select Process ID
+MassifToolPage.administrative_bytes=administrative bytes per block:
+MassifToolPage.allocation_functions=allocation functions:
+MassifToolPage.allocation_peak_inaccuracy=allocation peak inaccuracy:
+MassifToolPage.allocation_tree_depth=allocation tree depth:
+MassifToolPage.bytes=bytes
+MassifToolPage.detailed_snapshot_freq=detailed snapshot frequency:
+MassifToolPage.Edit=E&dit
+MassifToolPage.Function_name=Function name: 
+MassifToolPage.heap_allocation_threshold=heap allocation threshold:
+MassifToolPage.instructions=instructions
+MassifToolPage.Massif_Options=Massif Options
+MassifToolPage.max_snapshots=max snapshots:
+MassifToolPage.milliseconds=milliseconds
+MassifToolPage.minimum_heap_block=minimum heap block alignment:
+MassifToolPage.New=N&ew
+MassifToolPage.New_Allocation_Function=New Allocation Function
+MassifToolPage.profile_heap=profile heap:
+MassifToolPage.profile_stack=profile stack:
+MassifToolPage.Remove=Rem&ove
+MassifToolPage.time_unit=time unit:
+MassifViewPart.Display_Heap_Allocation=Display Heap Allocation Graph
+MassifViewPart.Extra_Heap=Extra Heap (B)
+MassifViewPart.Show_Heap_Tree=Show Heap Tree
+MassifViewPart.Snapshot=Snapshot
+MassifViewPart.Stacks=Stacks (B)
+MassifViewPart.Time=Time
+MassifViewPart.Total=Total (B)
+MassifViewPart.Useful_Heap=Useful Heap (B)
diff --git a/org.eclipse.linuxtools.valgrind.massif/src/org/tizen/valgrind/massif/editor/MassifEditor.java b/org.eclipse.linuxtools.valgrind.massif/src/org/tizen/valgrind/massif/editor/MassifEditor.java
new file mode 100644 (file)
index 0000000..681d625
--- /dev/null
@@ -0,0 +1,615 @@
+/*
+ *  Massif Editor
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Jaewon Lim <jaewon81.lim@samsung.com>
+ * Wonhyoung Park <wonhyoung2.park@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.valgrind.massif.editor;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.text.DecimalFormat;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.eclipse.birt.chart.model.Chart;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.IFontProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerComparator;
+import org.eclipse.linuxtools.valgrind.massif.MassifHeapTreeNode;
+import org.eclipse.linuxtools.valgrind.massif.MassifOutput;
+import org.eclipse.linuxtools.valgrind.massif.MassifParser;
+import org.eclipse.linuxtools.valgrind.massif.MassifPidMenuAction;
+import org.eclipse.linuxtools.valgrind.massif.MassifPlugin;
+import org.eclipse.linuxtools.valgrind.massif.MassifSnapshot;
+import org.eclipse.linuxtools.valgrind.massif.MassifTreeViewer;
+import org.eclipse.linuxtools.valgrind.massif.Messages;
+import org.eclipse.linuxtools.valgrind.massif.MassifSnapshot.SnapshotType;
+import org.eclipse.linuxtools.valgrind.massif.birt.ChartControl;
+import org.eclipse.linuxtools.valgrind.massif.birt.ChartEditorInput;
+import org.eclipse.linuxtools.valgrind.massif.birt.HeapChart;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.ScrolledComposite;
+import org.eclipse.swt.custom.StackLayout;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Cursor;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.editors.text.TextEditor;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.Section;
+import org.eclipse.ui.part.MultiPageEditorPart;
+import org.xml.sax.SAXException;
+
+
+public class MassifEditor extends MultiPageEditorPart{
+
+
+       protected static final String TITLE_STACKS = Messages
+       .getString("MassifViewPart.Stacks"); //$NON-NLS-1$
+       protected static final String TITLE_EXTRA = Messages
+       .getString("MassifViewPart.Extra_Heap"); //$NON-NLS-1$
+       protected static final String TITLE_USEFUL = Messages
+       .getString("MassifViewPart.Useful_Heap"); //$NON-NLS-1$
+       protected static final String TITLE_TOTAL = Messages
+       .getString("MassifViewPart.Total"); //$NON-NLS-1$
+       protected static final String TITLE_TIME = Messages
+       .getString("MassifViewPart.Time"); //$NON-NLS-1$
+       protected static final String TITLE_NUMBER = Messages
+       .getString("MassifViewPart.Snapshot"); //$NON-NLS-1$
+       protected static final String TREE_ACTION = MassifPlugin.PLUGIN_ID
+       + ".treeAction"; //$NON-NLS-1$
+       public static final String CHART_ACTION = MassifPlugin.PLUGIN_ID
+       + ".chartAction"; //$NON-NLS-1$
+//     public static final String PID_ACTION = MassifPlugin.PLUGIN_ID
+//     + ".pidAction"; //$NON-NLS-1$
+
+       protected static final String EMPTY_STRING = ""; //$NON-NLS-1$
+       protected static final String NO = "no"; //$NON-NLS-1$
+       protected static final String YES = "yes"; //$NON-NLS-1$
+       protected static final String EQUALS = "="; //$NON-NLS-1$
+       
+       protected static final String OUT_PREFIX = "massif_";    //$NON-NLS-1$
+       //protected static final String OUT_FILE = OUT_PREFIX + "%p.txt"; //$NON-NLS-1$
+       protected static final String OUT_FILE = "massif_000.txt"; //$NON-NLS-1$
+       protected static final FileFilter MASSIF_FILTER = new FileFilter() {
+               public boolean accept(File pathname) {
+                       return pathname.getName().startsWith(OUT_PREFIX);
+               }
+       };
+
+       // Valgrind program arguments
+       public static final String OPT_MASSIF_OUTFILE = "--massif-out-file"; //$NON-NLS-1$
+       public static final String OPT_HEAP = "--heap"; //$NON-NLS-1$
+       public static final String OPT_HEAPADMIN = "--heap-admin"; //$NON-NLS-1$
+       public static final String OPT_STACKS = "--stacks"; //$NON-NLS-1$
+       public static final String OPT_DEPTH = "--depth"; //$NON-NLS-1$
+       public static final String OPT_ALLOCFN = "--alloc-fn"; //$NON-NLS-1$
+       public static final String OPT_THRESHOLD = "--threshold"; //$NON-NLS-1$
+       public static final String OPT_PEAKINACCURACY = "--peak-inaccuracy"; //$NON-NLS-1$
+       public static final String OPT_TIMEUNIT = "--time-unit"; //$NON-NLS-1$
+       public static final String OPT_DETAILEDFREQ = "--detailed-freq"; //$NON-NLS-1$
+       public static final String OPT_MAXSNAPSHOTS = "--max-snapshots"; //$NON-NLS-1$
+       public static final String OPT_ALIGNMENT = "--alignment"; //$NON-NLS-1$
+
+
+       protected MassifSnapshot[] snapshots;
+       protected MassifOutput output;
+       protected Integer pid= 000;
+
+       protected Composite top;
+       protected StackLayout stackLayout;
+       protected TableViewer viewer;
+       protected MassifTreeViewer treeViewer;
+       protected MassifHeapTreeNode[] nodes;
+
+       protected static final int COLUMN_SIZE = 125;
+
+       protected Action treeAction;
+       protected Action chartAction;
+       protected MassifPidMenuAction pidAction;
+       
+       protected List<ChartEditorInput> chartInputs;
+       
+       
+       protected ScrolledComposite scrolledComposite;
+       protected Composite mainComposite;
+
+       protected ChartControl control;
+       
+       private TextEditor sourceEditor;
+
+       private String fileName;
+       private String filePath;
+       Cursor waitCursor;
+       
+       protected Chart cm = null;
+       
+       private void initialize(){
+               waitCursor = Display.getCurrent().getSystemCursor(SWT.CURSOR_WAIT);
+               fileName = getEditorInput().getName();
+               filePath = getEditorInput().getToolTipText();
+       }
+       
+       @Override
+       public void init(IEditorSite site, IEditorInput input)
+                       throws PartInitException {
+               super.init(site, input);
+               initialize();
+       }
+
+       @Override
+       public boolean isDirty() {
+               return false;
+       }
+       
+
+       @Override
+       public void createPages() {
+               createMassifTablePage();
+               createMassifTreeViewPage();
+               createSourcePage();
+                               
+               updateTitle();
+               
+               try {
+                       loadMassifData();
+               } catch (FileNotFoundException e) {
+                       e.printStackTrace();
+               } catch (ParserConfigurationException e) {
+                       e.printStackTrace();
+               } catch (IOException e) {
+                       e.printStackTrace();
+               } catch (CoreException e) {
+                       e.printStackTrace();
+               } catch (SAXException e) {
+                       e.printStackTrace();
+               }
+       }
+       
+
+       private void createMassifTablePage(){
+               Composite parent = new Composite(getContainer(), SWT.NULL);
+               parent.setLayout(new FillLayout());
+                               
+               top = new Composite(parent, SWT.NONE);
+               stackLayout = new StackLayout();
+               top.setLayout(stackLayout);
+               top.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+               viewer = new TableViewer(top, SWT.SINGLE | SWT.BORDER
+                               | SWT.FULL_SELECTION);
+
+               Table table = viewer.getTable();
+               table.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+
+               String[] columnTitles = { TITLE_NUMBER, TITLE_TIME, TITLE_TOTAL,
+                               TITLE_USEFUL, TITLE_EXTRA, TITLE_STACKS };
+
+               for (int i = 0; i < columnTitles.length; i++) {
+                       TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
+                       column.getColumn().setText(columnTitles[i]);
+                       column.getColumn().setWidth(COLUMN_SIZE);
+                       column.getColumn().setResizable(true);
+                       column.getColumn().addSelectionListener(getHeaderListener());
+               }
+               table.setHeaderVisible(true);
+               table.setLinesVisible(true);
+
+               viewer.setContentProvider(new ArrayContentProvider());
+               viewer.setLabelProvider(new MassifLabelProvider());
+               
+               setTopControl(viewer.getControl());
+               
+               int index = addPage(parent);
+               setPageText(index, "Table Viewer");
+       }
+       
+       private void createMassifTreeViewPage(){
+               Composite parent = new Composite(getContainer(), SWT.NULL);
+               parent.setLayout(new FillLayout());
+               
+               top = new Composite(parent, SWT.NONE);
+               stackLayout = new StackLayout();
+               top.setLayout(stackLayout);
+               top.setLayoutData(new GridData(GridData.FILL_BOTH));
+       
+               treeViewer = new MassifTreeViewer(top);
+               treeViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
+
+               setTopControl(treeViewer.getControl());
+               
+               int index = addPage(parent);
+               setPageText(index, "Snapshot TreeViewer");
+       
+       }
+
+
+       protected void createTitle(Composite parent, FormToolkit toolkit) {
+               Section section = toolkit.createSection(parent, Section.TITLE_BAR);
+               section.setText("Heap Memory Information");
+               section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               toolkit.createCompositeSeparator(section);
+       }
+       
+       private String getUnitString(MassifSnapshot[] snapshots) {
+               String result;
+               MassifSnapshot snapshot = snapshots[0];
+               switch (snapshot.getUnit()) {
+               case BYTES:
+                       result = "B"; //$NON-NLS-1$
+                       break;
+               case INSTRUCTIONS:
+                       result = "i"; //$NON-NLS-1$
+                       break;
+               default:
+                       result = "ms"; //$NON-NLS-1$
+               break;
+               }
+               return result;
+       }
+
+       private SelectionListener getHeaderListener() {
+               return new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               TableColumn column = (TableColumn) e.widget;
+                               Table table = viewer.getTable();
+                               if (column.equals(table.getSortColumn())) {
+                                       int direction = table.getSortDirection() == SWT.UP ? SWT.DOWN
+                                                       : SWT.UP;
+                                       table.setSortDirection(direction);
+                               } else {
+                                       table.setSortDirection(SWT.DOWN);
+                               }
+                               table.setSortColumn(column);
+                               viewer.setComparator(new ViewerComparator() {
+                                       @Override
+                                       public int compare(Viewer viewer, Object o1, Object o2) {
+                                               Table table = ((TableViewer) viewer).getTable();
+                                               int direction = table.getSortDirection();
+                                               MassifSnapshot s1 = (MassifSnapshot) o1;
+                                               MassifSnapshot s2 = (MassifSnapshot) o2;
+                                               long result;
+                                               TableColumn column = table.getSortColumn();
+                                               if (column.getText().equals(TITLE_NUMBER)) {
+                                                       result = s1.getNumber() - s2.getNumber();
+                                               } else if (column.getText().startsWith(TITLE_TIME)) {
+                                                       result = s1.getTime() - s2.getTime();
+                                               } else if (column.getText().equals(TITLE_TOTAL)) {
+                                                       result = s1.getTotal() - s2.getTotal();
+                                               } else if (column.getText().equals(TITLE_USEFUL)) {
+                                                       result = s1.getHeapBytes() - s2.getHeapBytes();
+                                               } else if (column.getText().equals(TITLE_EXTRA)) {
+                                                       result = s1.getHeapExtra() - s2.getHeapExtra();
+                                               } else {
+                                                       result = s1.getStacks() - s2.getStacks();
+                                               }
+
+                                               // overflow check
+                                               if (result > Integer.MAX_VALUE) {
+                                                       result = Integer.MAX_VALUE;
+                                               } else if (result < Integer.MIN_VALUE) {
+                                                       result = Integer.MIN_VALUE;
+                                               }
+                                               return (int) (direction == SWT.DOWN ? result : -result);
+                                       }
+                               });
+                       }
+               };
+       }
+
+       public IAction[] getToolbarActions() {
+//             pidAction = new MassifPidMenuAction(this);
+//             pidAction.setId(PID_ACTION);
+               
+//             chartAction = new Action(
+//                             Messages.getString("MassifViewPart.Display_Heap_Allocation"), IAction.AS_PUSH_BUTTON) { //$NON-NLS-1$
+//                     @Override
+//                     public void run() {
+//                             ChartEditorInput input = getChartInput(pid);
+//                             if (input != null) {                                    
+//                                     displayChart(input);
+//                             }
+//                     }
+//             };
+//             chartAction.setId(CHART_ACTION);
+//             chartAction.setImageDescriptor(MassifPlugin.imageDescriptorFromPlugin(
+//                             MassifPlugin.PLUGIN_ID, "icons/linecharticon.gif")); //$NON-NLS-1$
+//             chartAction.setToolTipText(Messages
+//                             .getString("MassifViewPart.Display_Heap_Allocation")); //$NON-NLS-1$
+
+//             treeAction = new Action(
+//                             Messages.getString("MassifViewPart.Show_Heap_Tree"), IAction.AS_CHECK_BOX) { //$NON-NLS-1$
+//                     @Override
+//                     public void run() {
+//                             if (isChecked()) {
+//                                     setTopControl(treeViewer.getControl());
+//                             } else {
+//                                     setTopControl(viewer.getControl());
+//                             }
+//                     }
+//             };
+//             treeAction.setId(TREE_ACTION);
+//             treeAction.setImageDescriptor(MassifPlugin.imageDescriptorFromPlugin(
+//                             MassifPlugin.PLUGIN_ID, "icons/call_hierarchy.gif")); //$NON-NLS-1$
+//             treeAction.setToolTipText(Messages
+//                             .getString("MassifViewPart.Show_Heap_Tree")); //$NON-NLS-1$
+//
+//     //      return new IAction[] { pidAction, chartAction, treeAction };
+//             return new IAction[] { chartAction, treeAction };
+               return null;
+       }
+
+       protected void createChart(MassifSnapshot[] snapshots) {
+               HeapChart chart = new HeapChart(snapshots);
+               //String title = ValgrindUIPlugin.getDefault().getView().getContentDescription() + " [PID: " + pid + "]";  //$NON-NLS-1$//$NON-NLS-2$
+               //String title = "Heapchart";  //$NON-NLS-1$//$NON-NLS-2$
+               String title = fileName.toString();
+               chart.getTitle().getLabel().getCaption().setValue(title);
+
+       //      String name = getInputName(title);
+               String name =fileName.toString();
+               ChartEditorInput input = new ChartEditorInput(chart, name, pid);
+               chartInputs.add(input);
+//             // open the editor
+               displayChart(input);
+       }
+
+       protected void displayChart(final ChartEditorInput chartInput) {
+               Display.getDefault().syncExec(new Runnable() {
+                       public void run() {
+                               IWorkbenchPage page = PlatformUI.getWorkbench()
+                               .getActiveWorkbenchWindow().getActivePage();
+                               try {
+                                       page.openEditor(chartInput, MassifPlugin.EDITOR_ID);
+                               } catch (PartInitException e) {
+                                       // TODO Auto-generated catch block
+                                       e.printStackTrace();
+                               }
+                       }
+               });
+       }
+
+       protected String getInputName(String description) {
+               String launchName = description.substring(0, description
+                               .indexOf("[massif]")); //$NON-NLS-1$
+               return launchName.trim();
+       }
+
+       @Override
+       public void setFocus() {
+               viewer.getTable().setFocus();
+       }
+
+       public void refreshView() {
+               if (output != null && pid != null) {
+                       MassifSnapshot[] snapshots = output.getSnapshots(pid);
+               //      pidAction.setPids(output.getPids());
+                       if (snapshots != null) {
+                               viewer.setInput(snapshots);
+
+                               String timeWithUnit = TITLE_TIME + " (" + getUnitString(snapshots) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+                               for (TableColumn column : viewer.getTable().getColumns()) {
+                                       if (column.getText().startsWith(TITLE_TIME)) {
+                                               column.setText(timeWithUnit);
+                                       }
+                                       viewer.getTable().layout(true);
+                               }
+                               MassifSnapshot[] detailed = getDetailed(snapshots);
+                               nodes = new MassifHeapTreeNode[detailed.length];
+                               for (int i = 0; i < detailed.length; i++) {
+                                       nodes[i] = detailed[i].getRoot();
+                               }
+                               treeViewer.setInput(nodes);
+
+                               // create and display chart
+                               if (snapshots.length > 0) {
+                                       ChartEditorInput input = getChartInput(pid);
+                                       if (input == null) {
+                                               createChart(snapshots);
+                                       }
+                                       else {
+                                               displayChart(input);
+                                       }
+                               }
+                       }
+               }
+       }
+
+       public void setTopControl(Control control) {
+               stackLayout.topControl = control;
+               top.layout(true);
+       }
+
+       public void setOutput(MassifOutput output) {
+               this.output = output;
+       }
+
+       public void setPid(Integer pid) {
+               this.pid = pid;
+       }
+       
+       public MassifSnapshot[] getSnapshots() {
+               return output != null && pid != null ? output.getSnapshots(pid) : null;
+       }
+
+       public TableViewer getTableViewer() {
+               return viewer;
+       }
+
+       public TreeViewer getTreeViewer() {
+               return treeViewer;
+       }
+
+       protected class MassifLabelProvider extends LabelProvider implements
+       ITableLabelProvider, IFontProvider {
+
+               public Image getColumnImage(Object element, int columnIndex) {
+                       Image image = null;
+                       if (columnIndex == 0) {
+                               MassifSnapshot snapshot = (MassifSnapshot) element;
+                               switch (snapshot.getType()) {
+                               case EMPTY:
+                                       break;
+                               case PEAK:
+                               case DETAILED:
+                                       image = MassifPlugin
+                                       .imageDescriptorFromPlugin(MassifPlugin.PLUGIN_ID,
+                                       "icons/call_hierarchy.gif").createImage(); //$NON-NLS-1$
+                                       break;
+                               default:
+                                       break;
+                               }
+                       }
+                       return image;
+               }
+
+               public String getColumnText(Object element, int columnIndex) {
+                       MassifSnapshot snapshot = (MassifSnapshot) element;
+                       DecimalFormat df = new DecimalFormat("#,##0"); //$NON-NLS-1$
+                       switch (columnIndex) {
+                       case 0:
+                               return df.format(snapshot.getNumber());
+                       case 1:
+                               return df.format(snapshot.getTime());
+                       case 2:
+                               return df.format(snapshot.getTotal());
+                       case 3:
+                               return df.format(snapshot.getHeapBytes());
+                       case 4:
+                               return df.format(snapshot.getHeapExtra());
+                       default:
+                               return df.format(snapshot.getStacks());
+                       }
+               }
+
+               public Font getFont(Object element) {
+                       Font font = null;
+                       MassifSnapshot snapshot = (MassifSnapshot) element;
+                       switch (snapshot.getType()) {
+                       case EMPTY:
+                       case DETAILED:
+                               break;
+                       case PEAK:
+                               font = JFaceResources.getFontRegistry().getBold(
+                                               JFaceResources.DIALOG_FONT);
+                               break;
+                       default:
+                               break;
+                       }
+                       return font;
+               }
+       }
+
+       private MassifSnapshot[] getDetailed(MassifSnapshot[] snapshots) {
+               ArrayList<MassifSnapshot> list = new ArrayList<MassifSnapshot>();
+               for (MassifSnapshot snapshot : snapshots) {
+                       if (snapshot.getType() != SnapshotType.EMPTY) {
+                               list.add(snapshot);
+                       }
+               }
+               return list.toArray(new MassifSnapshot[list.size()]);
+       }
+       
+       private ChartEditorInput getChartInput(Integer pid) {
+               ChartEditorInput result = null;
+               for (int i = 0; i < chartInputs.size(); i++) {
+                       ChartEditorInput input = chartInputs.get(i);
+                       if (input.getPid().equals(pid)) {
+                               result = input;
+                       }
+               }
+               return result;
+       }
+       
+       private void createSourcePage(){
+               try{
+                       sourceEditor = new TextEditor();
+                       int index = addPage(sourceEditor, getEditorInput());
+                       setPageText(index, "Source");
+               }catch(PartInitException e){
+                       e.printStackTrace();
+               }
+       }
+       
+       private void updateTitle(){
+               setPartName(fileName);
+               setTitleToolTip(filePath);
+       }
+       private void loadMassifData() throws FileNotFoundException, ParserConfigurationException, IOException, CoreException, SAXException{
+               loadData();
+               refreshView();
+       }
+       
+       
+       private void loadData() throws FileNotFoundException, ParserConfigurationException, IOException, CoreException, SAXException {
+               ArrayList<MassifSnapshot> list = new ArrayList<MassifSnapshot>();
+               chartInputs = new ArrayList<ChartEditorInput>();
+               
+               String filename =this.filePath;
+               MassifParser parser = new MassifParser(filename);
+               output = new MassifOutput();
+               output.putSnapshots(parser.getPid(), parser.getSnapshots());
+               
+               snapshots = list.toArray(new MassifSnapshot[list.size()]) ;
+
+       }
+
+       @Override
+       public void doSave(IProgressMonitor monitor) {
+       }
+
+       @Override
+       public void doSaveAs() {
+       }
+
+       @Override
+       public boolean isSaveAsAllowed() {
+               return false;
+       }
+}
diff --git a/org.eclipse.linuxtools.valgrind.memcheck/.classpath b/org.eclipse.linuxtools.valgrind.memcheck/.classpath
new file mode 100644 (file)
index 0000000..ad32c83
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+       <classpathentry kind="src" path="src"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.eclipse.linuxtools.valgrind.memcheck/.project b/org.eclipse.linuxtools.valgrind.memcheck/.project
new file mode 100644 (file)
index 0000000..edeca93
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.eclipse.linuxtools.valgrind.memcheck</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.ManifestBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.SchemaBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.pde.PluginNature</nature>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>
diff --git a/org.eclipse.linuxtools.valgrind.memcheck/.settings/org.eclipse.core.resources.prefs b/org.eclipse.linuxtools.valgrind.memcheck/.settings/org.eclipse.core.resources.prefs
new file mode 100644 (file)
index 0000000..d7ea6b7
--- /dev/null
@@ -0,0 +1,3 @@
+#Wed Dec 01 09:13:58 CET 2010
+eclipse.preferences.version=1
+encoding/<project>=UTF-8
diff --git a/org.eclipse.linuxtools.valgrind.memcheck/.settings/org.eclipse.core.runtime.prefs b/org.eclipse.linuxtools.valgrind.memcheck/.settings/org.eclipse.core.runtime.prefs
new file mode 100644 (file)
index 0000000..dfe4853
--- /dev/null
@@ -0,0 +1,3 @@
+#Tue Dec 14 16:37:05 CET 2010
+eclipse.preferences.version=1
+line.separator=\n
diff --git a/org.eclipse.linuxtools.valgrind.memcheck/ChangeLog b/org.eclipse.linuxtools.valgrind.memcheck/ChangeLog
new file mode 100644 (file)
index 0000000..513f9ca
--- /dev/null
@@ -0,0 +1,4 @@
+2009-01-05  Elliott Baron  <ebaron@redhat.com>
+
+       * META-INF/MANIFEST.MF: Changed version to 0.1.0.
+       * build.properties: Include about.html.
\ No newline at end of file
diff --git a/org.eclipse.linuxtools.valgrind.memcheck/META-INF/MANIFEST.MF b/org.eclipse.linuxtools.valgrind.memcheck/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..cec3291
--- /dev/null
@@ -0,0 +1,30 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Tizen SDK Valgrind Memcheck
+Bundle-SymbolicName: org.eclipse.linuxtools.valgrind.memcheck;singleton:=true
+Bundle-Version: 1.3.18.qualifier
+Bundle-Activator: org.eclipse.linuxtools.valgrind.memcheck.MemcheckPlugin
+Bundle-Vendor: Eclipse Linux Tools
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.ui.editors;bundle-version="3.4.0",
+ org.eclipse.ui.forms;bundle-version="3.3.103",
+ org.eclipse.jface.text;bundle-version="3.4.2",
+ org.eclipse.core.runtime;bundle-version="3.4.0",
+ org.eclipse.debug.ui;bundle-version="3.4.2",
+ org.eclipse.cdt.debug.core;bundle-version="5.0.2",
+ org.eclipse.cdt.launch;bundle-version="5.0.2",
+ org.eclipse.linuxtools.profiling.ui,
+ org.eclipse.linuxtools.valgrind.core,
+ org.eclipse.linuxtools.valgrind.launch,
+ org.eclipse.linuxtools.valgrind.ui,
+ org.tizen.nativecpp,
+ org.eclipse.linuxtools.valgrind.launch.exe,
+ org.tizen.common
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-ActivationPolicy: lazy
+Bundle-Localization: plugin
+Export-Package: org.eclipse.linuxtools.valgrind.memcheck,
+ org.eclipse.linuxtools.valgrind.memcheck.model
+Import-Package: org.eclipse.cdt.core,
+ org.eclipse.cdt.managedbuilder.core,
+ org.tizen.nativecommon.launch
diff --git a/org.eclipse.linuxtools.valgrind.memcheck/NOTICE b/org.eclipse.linuxtools.valgrind.memcheck/NOTICE
new file mode 100644 (file)
index 0000000..d32f995
--- /dev/null
@@ -0,0 +1,86 @@
+2009-10-02 SPRC SDK Team <d.kozinski@samsung.com>
+       * MANIFEST.MF : modify dependency plugins
+       * MemcheckLaunchDelegate.java : code refactoring
+
+2010-02-10 SPRC SDK Team <d.kozinski@samsung.com>
+       * .classpath : change java runtime environment
+       * org.eclipse.jdt.core.prefs : remove file
+       * MemcheckLaunchDelegate.java : remove unnecessary import
+
+2010-03-31 HyungJong, Shin <hj_shin@samsung.com>
+       * MemcheckLaunchDelegate.java : change : Valgrind Error allocation mechanism
+
+2010-07-15 HyungJong, Shin <hj_shin@samsung.com>
+       * MANIFEST.MF : modify dependency
+       * MemcheckLaunchDelegate.java : bugfix : when an application is terminated during valgrind, the profiling doesn't complete
+
+2010-07-19 HyungJong, Shin <hj_shin@samsung.com>
+       * ValgrindError.java : valgrind version change ( 3.4 -> 3.5 ) : xml output enable officially.
+       * ValgrindErrorDesc.java : add new file
+       
+2010-08-26 HyungJong, Shin <hj_shin@samsung.com>
+       * MANIFEST.MF : modify plugin dependency
+       * MemcheckViewPart.java : modify some import, modify target control code
+       
+2010-10-21 HyungJong, Shin <hj_shin@samsung.com>
+       * ValgrindErrorDesc.java : modify Boilerplate
+
+2010-11-02 HyungJong, Shin <hj_shin@samsung.com>
+       * ValgrindErrorDesc.java : modify Boilerplate
+       
+2010-11-05 sdk <sdk@sdk-laptop.(none)>
+       * MANIFEST.MF : changed some package name
+       * plugin.xml : changed some package name
+       * MemcheckLaunchDelegate.java : changed some package name
+       * MemcheckViewPart.java : changed some package name
+
+2011-06-09 jaewon81.lim <jaewon81.lim@samsung.com>
+       * MANIFEST.MF : rearrange plugins dependency
+
+2011-07-13 jaewon81.lim <jaewon81.lim@samsung.com>
+       * MANIFEST.MF : modified import package name
+       * MemcheckLaunchDelegate.java : modified import package name
+
+2011-07-28 jaewon81.lim <jaewon81.lim@samsung.com>
+       * MemcheckLaunchDelegate.java : add valgrind error message for real device execution
+
+2011-08-16 jaewon81.lim <jaewon81.lim@samsung.com>
+       * ValgrindErrorDesc.java : source license cleanup
+
+2011-08-22 joogwan.kim <joogwan.kim@samsung.com>
+       * MANIFEST.MF : Change plug-in name
+       * MemcheckLaunchDelegate.java : Change plug-in name
+
+2011-08-25 wonhyoung2.park <wonhyoung2.park@samsung.com>
+       * MANIFEST.MF : plugin provider and name modified
+
+2011-08-31 wonhyoung2.park <wonhyoung2.park@samsung.com>
+       * MemcheckLaunchDelegate.java : --undef-value-error option default setting modify
+       * MemcheckToolPage.java : --undef-value-error option default setting modify
+
+2011-09-23 wonhyoung2.park <wonhyoung2.park@samsung.com>
+       * MemcheckLaunchDelegate.java : remove repetition memssage
+
+2011-10-31 wonhyoung2.park <wonhyoung2.park@samsung.com>
+       * MemcheckLaunchDelegate.java : raise exception when the valgrind run in emulator. (for window
+
+2011-11-16 wonhyoung2.park <wonhyoung2.park@samsung.com>
+       * MANIFEST.MF : Profiler sdb apply
+       * MemcheckLaunchDelegate.java : Profiler sdb apply
+
+2011-11-22 taeyoung2.son <taeyoung2.son@samsung.com>
+       * MANIFEST.MF :  Modify SDK naming from "SLP(or Samsung Linux Platform)" to "Tizen"
+
+2011-11-29 wonhyoung2.park <wonhyoung2.park@samsung.com>
+       * MANIFEST.MF : chagne slp to tizen
+       * plugin.xml : chagne slp to tizen
+       * MemcheckLaunchDelegate.java : chagne slp to tizen
+
+2011-12-02 taeyoung2.son <taeyoung2.son@samsung.com>
+       * MANIFEST.MF : Delete dependency feature's version value.
+
+2011-12-03 wonhyoung2.park <wonhyoung2.park@samsung.com>
+       * MANIFEST.MF : package instll routine chage
+
+2011-12-05 wonhyoung2.park <wonhyoung2.park@samsung.com>
+       * MemcheckLaunchDelegate.java : add console (profile stop available)
diff --git a/org.eclipse.linuxtools.valgrind.memcheck/about.html b/org.eclipse.linuxtools.valgrind.memcheck/about.html
new file mode 100644 (file)
index 0000000..e6a2741
--- /dev/null
@@ -0,0 +1,26 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"><head>
+
+
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>About</title>
+</head><body lang="EN-US">
+<h2>About This Content</h2>
+<p>October 24, 2008</p>        
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in ("Content").  Unless otherwise 
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 ("EPL").  A copy of the EPL is available 
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, "Program" will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is 
+being redistributed by another party ("Redistributor") and different terms and conditions may
+apply to your use of any object code in the Content.  Check the Redistributor's license that was 
+provided with the Content.  If no such license exists, contact the Redistributor.  Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body></html>
\ No newline at end of file
diff --git a/org.eclipse.linuxtools.valgrind.memcheck/build.properties b/org.eclipse.linuxtools.valgrind.memcheck/build.properties
new file mode 100644 (file)
index 0000000..4e52019
--- /dev/null
@@ -0,0 +1,10 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               .,\
+               plugin.xml,\
+               plugin.properties,\
+               about.html,\
+               icons/
+javacSource = 1.6
+javacTarget = 1.6
diff --git a/org.eclipse.linuxtools.valgrind.memcheck/icons/valgrind-icon.png b/org.eclipse.linuxtools.valgrind.memcheck/icons/valgrind-icon.png
new file mode 100644 (file)
index 0000000..d4391c0
Binary files /dev/null and b/org.eclipse.linuxtools.valgrind.memcheck/icons/valgrind-icon.png differ
diff --git a/org.eclipse.linuxtools.valgrind.memcheck/icons/warning.gif b/org.eclipse.linuxtools.valgrind.memcheck/icons/warning.gif
new file mode 100644 (file)
index 0000000..8e054d0
Binary files /dev/null and b/org.eclipse.linuxtools.valgrind.memcheck/icons/warning.gif differ
diff --git a/org.eclipse.linuxtools.valgrind.memcheck/plugin.properties b/org.eclipse.linuxtools.valgrind.memcheck/plugin.properties
new file mode 100644 (file)
index 0000000..24ef157
--- /dev/null
@@ -0,0 +1,4 @@
+#Properties file for org.eclipse.linuxtools.valgrind.memcheck
+Bundle-Vendor.0 = Eclipse.org
+Bundle-Name.0 = Memcheck Plug-in (Incubation)
+marker.name = Memcheck Problem
\ No newline at end of file
diff --git a/org.eclipse.linuxtools.valgrind.memcheck/plugin.xml b/org.eclipse.linuxtools.valgrind.memcheck/plugin.xml
new file mode 100644 (file)
index 0000000..659a689
--- /dev/null
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+       <extension
+         point="org.eclipse.linuxtools.valgrind.launch.valgrindTools">
+      <tool
+            delegate="org.eclipse.linuxtools.valgrind.memcheck.MemcheckLaunchDelegate"
+            id="org.eclipse.linuxtools.valgrind.launch.memcheck"
+            name="memcheck"
+            page="org.eclipse.linuxtools.valgrind.memcheck.MemcheckToolPage">
+      </tool>
+   </extension>
+   <extension
+         point="org.eclipse.linuxtools.valgrind.ui.valgrindToolViews">
+      <view
+            class="org.eclipse.linuxtools.valgrind.memcheck.MemcheckViewPart"
+            definitionId="org.eclipse.linuxtools.valgrind.launch.memcheck">
+      </view>
+   </extension>
+      <extension
+         id="org.eclipse.linuxtools.valgrind.memcheck.marker"
+         name="%marker.name"
+         point="org.eclipse.core.resources.markers">
+      <super
+            type="org.eclipse.cdt.core.task">
+      </super>
+   </extension>
+   <!--
+   <extension
+         point="org.eclipse.linuxtools.valgrind.history.statePersisters">
+      <persister
+            class="org.eclipse.linuxtools.valgrind.memcheck.MemcheckLaunchDelegate"
+            tool="org.eclipse.linuxtools.valgrind.launch.memcheck">
+      </persister>
+   </extension>
+   -->
+   <extension
+         point="org.eclipse.ui.editors">
+               <editor
+                       class="org.tizen.valgrind.memcheck.editor.MemcheckEditor"
+                       default="true"
+                       extensions="memcheck"
+                       icon="icons/valgrind-icon.png"
+                       id="org.tizen.valgrind.memcheck.editor.MemcheckEditor"
+                       name="Memcheck Editor">
+               </editor>      
+   </extension>
+</plugin>
diff --git a/org.eclipse.linuxtools.valgrind.memcheck/src/org/eclipse/linuxtools/valgrind/memcheck/MemcheckLaunchDelegate.java b/org.eclipse.linuxtools.valgrind.memcheck/src/org/eclipse/linuxtools/valgrind/memcheck/MemcheckLaunchDelegate.java
new file mode 100644 (file)
index 0000000..cbffe30
--- /dev/null
@@ -0,0 +1,146 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Elliott Baron <ebaron@redhat.com> - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.valgrind.memcheck;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.linuxtools.valgrind.core.ValgrindCommand;
+import org.eclipse.linuxtools.valgrind.launch.CommandManager;
+import org.eclipse.linuxtools.valgrind.launch.IValgrindLaunchDelegate;
+import org.eclipse.linuxtools.valgrind.launch.ValgrindLaunchPlugin;
+import org.eclipse.linuxtools.valgrind.ui.IValgrindToolView;
+import org.eclipse.linuxtools.valgrind.ui.ValgrindUIPlugin;
+import org.eclipse.linuxtools.valgrind.ui.ValgrindViewPart;
+import org.tizen.nativecommon.launch.TizenLaunchCommand;
+import org.tizen.nativecommon.launch.TizenLaunchDelegate;
+import org.xml.sax.SAXException;
+
+public class MemcheckLaunchDelegate extends TizenLaunchDelegate implements IValgrindLaunchDelegate {
+       // Valgrind program arguments
+       public static final String OPT_LEAKCHECK = "--leak-check"; //$NON-NLS-1$
+       public static final String OPT_SHOWREACH = "--show-reachable"; //$NON-NLS-1$
+       public static final String OPT_LEAKRES = "--leak-resolution"; //$NON-NLS-1$
+       public static final String OPT_FREELIST = "--freelist-vol"; //$NON-NLS-1$
+       public static final String OPT_GCCWORK = "--workaround-gcc296-bugs"; //$NON-NLS-1$
+       public static final String OPT_PARTIAL = "--partial-loads-ok"; //$NON-NLS-1$
+       public static final String OPT_UNDEF = "--undef-value-errors"; //$NON-NLS-1$
+
+       protected static final String EMPTY_STRING = ""; //$NON-NLS-1$
+       protected static final String NO = "no"; //$NON-NLS-1$
+       protected static final String YES = "yes"; //$NON-NLS-1$
+       protected static final String EQUALS = "="; //$NON-NLS-1$
+
+       protected ArrayList<ValgrindError> errors;
+       protected ValgrindError error;
+
+       @Override
+       public void launch(ValgrindCommand command, ILaunchConfiguration config, ILaunch launch, IProgressMonitor monitor) throws Exception {
+
+           // wait for Valgrind to exit
+           try {
+                   //String ValgrindHostdir = ValgrindUIPlugin.getDefault().getStateLocation().append("Valgrind_XML").toOSString();
+                   String ValgrindHostdir = ValgrindUIPlugin.getDefault().getStateLocation().toOSString();
+                   String targetlog=ValgrindLaunchPlugin.RESULT_DIR +"valgrind.xml";
+                   String hostlog =ValgrindHostdir + File.separator + "valgrind_out.xml";
+
+                               //--bery sftp dowonload
+                   File file = new File(hostlog);
+                   if(file.exists()){
+                       file.delete();
+                   }               
+                   CommandManager.pull(targetlog, hostlog);
+                   //----bery parsing the xml output file
+                   parseOutput(hostlog);                               
+                   } catch (ParserConfigurationException e) {
+                               abort(Messages.getString("MemcheckLaunchDelegate.Error_parsing_output"), e, ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR); //$NON-NLS-1$
+                               e.printStackTrace();
+                       } catch (IOException e) {
+                               abort(Messages.getString("MemcheckLaunchDelegate.Error_parsing_output"), e, ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR); //$NON-NLS-1$
+                               e.printStackTrace();
+                       } catch (SAXException e) {
+                               Exception te;
+                               if(!CommandManager.isEmulator())
+                               {
+                                       te = new Exception("Currently valgrind profiling is not supported in 'Real Device'. Please use valgrind profiling in 'Emulator'.");
+                                       throw(te);
+                               }
+                               else
+                                       te = e;
+
+                               abort(Messages.getString("MemcheckLaunchDelegate.Error_parsing_output"), te, ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR); //$NON-NLS-1$
+                               e.printStackTrace();
+                       }
+               
+       }
+
+       protected void parseOutput(String hostlog)
+                       throws ParserConfigurationException, IOException, CoreException,
+                       SAXException {
+
+               ValgrindXMLParser parser;
+               parser = new ValgrindXMLParser(new FileInputStream(hostlog));
+               errors = parser.getErrors();
+
+               ValgrindViewPart view = ValgrindUIPlugin.getDefault().getView();
+               IValgrindToolView memcheckPart = view.getDynamicView();
+               if (memcheckPart instanceof MemcheckViewPart) {
+                       ((MemcheckViewPart) memcheckPart).setErrors(errors.toArray(new ValgrindError[errors.size()]));
+               }
+       }
+       
+       public String[] getCommandArray(ValgrindCommand command, ILaunchConfiguration config) throws CoreException {
+               ArrayList<String> opts = new ArrayList<String>();
+               opts.add(ValgrindCommand.OPT_XML + EQUALS + YES);
+               
+               opts.add(OPT_LEAKCHECK + EQUALS + YES);//config.getAttribute(ATTR_MEMCHECK_LEAKCHECK, "summary"));
+               opts.add(OPT_SHOWREACH + EQUALS + (config.getAttribute(MemcheckToolPage.ATTR_MEMCHECK_SHOWREACH, false) ? YES : NO));
+               opts.add(OPT_LEAKRES + EQUALS + config.getAttribute(MemcheckToolPage.ATTR_MEMCHECK_LEAKRES, "low")); //$NON-NLS-1$
+               opts.add(OPT_FREELIST + EQUALS + config.getAttribute(MemcheckToolPage.ATTR_MEMCHECK_FREELIST, 10000000));
+               opts.add(OPT_GCCWORK + EQUALS + (config.getAttribute(MemcheckToolPage.ATTR_MEMCHECK_GCCWORK, false) ? YES : NO));
+               opts.add(OPT_PARTIAL + EQUALS + (config.getAttribute(MemcheckToolPage.ATTR_MEMCHECK_PARTIAL, false) ? YES : NO));
+               opts.add(OPT_UNDEF + EQUALS + (config.getAttribute(MemcheckToolPage.ATTR_MEMCHECK_UNDEF, true) ? YES : NO));
+
+               return opts.toArray(new String[opts.size()]);
+       }
+
+
+
+//     public void restoreState(HistoryEntry entry) throws CoreException {             
+//             try {
+//                     File[] outputFiles = entry.getDatadir().listFiles(LOG_FILTER);
+//                     
+//                     parseOutput(outputFiles);
+//             } catch (ParserConfigurationException e) {
+//                     abort(Messages.getString("MemcheckLaunchDelegate.Error_parsing_output"), e, ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR); //$NON-NLS-1$
+//                     e.printStackTrace();
+//             } catch (IOException e) {
+//                     abort(Messages.getString("MemcheckLaunchDelegate.Error_parsing_output"), e, ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR); //$NON-NLS-1$
+//                     e.printStackTrace();
+//             } catch (SAXException e) {
+//                     abort(Messages.getString("MemcheckLaunchDelegate.Error_parsing_output"), e, ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR); //$NON-NLS-1$
+//                     e.printStackTrace();
+//             }
+//     }
+//
+//     public void saveState(HistoryEntry entry) throws CoreException {
+//     }
+
+}
diff --git a/org.eclipse.linuxtools.valgrind.memcheck/src/org/eclipse/linuxtools/valgrind/memcheck/MemcheckPlugin.java b/org.eclipse.linuxtools.valgrind.memcheck/src/org/eclipse/linuxtools/valgrind/memcheck/MemcheckPlugin.java
new file mode 100644 (file)
index 0000000..4b51113
--- /dev/null
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Elliott Baron <ebaron@redhat.com> - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.valgrind.memcheck;
+
+import org.eclipse.linuxtools.valgrind.launch.ValgrindLaunchPlugin;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+public class MemcheckPlugin extends AbstractUIPlugin {
+
+       // The plug-in ID
+       public static final String PLUGIN_ID = "org.eclipse.linuxtools.valgrind.memcheck"; //$NON-NLS-1$
+       public static final String MARKER_TYPE = PLUGIN_ID + ".marker"; //$NON-NLS-1$
+
+       // The shared instance
+       private static MemcheckPlugin plugin;
+       public static final String TOOL_ID = ValgrindLaunchPlugin.PLUGIN_ID + ".memcheck"; //$NON-NLS-1$
+       
+       /**
+        * The constructor
+        */
+       public MemcheckPlugin() {
+       }
+
+       /*
+        * (non-Javadoc)
+        * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+        */
+       public void start(BundleContext context) throws Exception {
+               super.start(context);
+               plugin = this;
+       }
+
+       /*
+        * (non-Javadoc)
+        * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+        */
+       public void stop(BundleContext context) throws Exception {
+               plugin = null;
+               super.stop(context);
+       }
+
+       /**
+        * Returns the shared instance
+        *
+        * @return the shared instance
+        */
+       public static MemcheckPlugin getDefault() {
+               return plugin;
+       }
+
+}
diff --git a/org.eclipse.linuxtools.valgrind.memcheck/src/org/eclipse/linuxtools/valgrind/memcheck/MemcheckToolPage.java b/org.eclipse.linuxtools.valgrind.memcheck/src/org/eclipse/linuxtools/valgrind/memcheck/MemcheckToolPage.java
new file mode 100644 (file)
index 0000000..9021624
--- /dev/null
@@ -0,0 +1,216 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Elliott Baron <ebaron@redhat.com> - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.valgrind.memcheck;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
+import org.eclipse.linuxtools.valgrind.launch.IValgrindToolPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Spinner;
+
+public class MemcheckToolPage extends AbstractLaunchConfigurationTab implements IValgrindToolPage {
+       public static final String MEMCHECK = "memcheck"; //$NON-NLS-1$
+       public static final String PLUGIN_ID = MemcheckPlugin.PLUGIN_ID;
+       
+       // MEMCHECK controls
+       protected Combo leakCheckCombo;
+       protected Combo leakResCombo;
+       protected Button showReachableButton;
+       protected Spinner freelistSpinner;
+       protected Button partialLoadsButton;
+       protected Button undefValueButton;
+       protected Button gccWorkaroundButton;
+       protected Spinner alignmentSpinner;
+       
+       // LaunchConfiguration attributes
+       public static final String ATTR_MEMCHECK_LEAKCHECK = PLUGIN_ID + ".MEMCHECK_LEAKCHECK"; //$NON-NLS-1$
+       public static final String ATTR_MEMCHECK_LEAKRES = PLUGIN_ID + ".MEMCHECK_LEAKRES"; //$NON-NLS-1$
+       public static final String ATTR_MEMCHECK_SHOWREACH = PLUGIN_ID + ".MEMCHECK_SHOWREACH"; //$NON-NLS-1$
+       public static final String ATTR_MEMCHECK_PARTIAL = PLUGIN_ID + ".MEMCHECK_PARTIAL"; //$NON-NLS-1$
+       public static final String ATTR_MEMCHECK_UNDEF = PLUGIN_ID + ".MEMCHECK_UNDEF"; //$NON-NLS-1$
+       public static final String ATTR_MEMCHECK_FREELIST = PLUGIN_ID + ".MEMCHECK_FREELIST"; //$NON-NLS-1$
+       public static final String ATTR_MEMCHECK_GCCWORK = PLUGIN_ID + ".MEMCHECK_GCCWORK"; //$NON-NLS-1$
+       
+       protected static final String EMPTY_STRING = ""; //$NON-NLS-1$
+       protected static final String NO = "no"; //$NON-NLS-1$
+       protected static final String YES = "yes"; //$NON-NLS-1$
+       protected static final String EQUALS = "="; //$NON-NLS-1$
+       
+       protected boolean isInitializing = false;
+       protected SelectionListener selectListener = new SelectionAdapter() {
+               @Override
+               public void widgetSelected(SelectionEvent e) {
+                       updateLaunchConfigurationDialog();
+               }
+       };
+       protected ModifyListener modifyListener = new ModifyListener() {
+               public void modifyText(ModifyEvent e) {
+                       updateLaunchConfigurationDialog();      
+               }                       
+       };
+       
+       public void createControl(Composite parent) {
+               Composite memcheckTop = new Composite(parent, SWT.NONE);
+               GridLayout memcheckLayout = new GridLayout(2,true);
+               memcheckTop.setLayout(memcheckLayout);
+               memcheckTop.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               
+               //setControl(memcheckTop);
+               
+               Composite leakCheckTop= new Composite(memcheckTop, SWT.NONE);
+               leakCheckTop.setLayout(new GridLayout(2, false));
+               leakCheckTop.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               
+               Label leakCheckLabel = new Label(leakCheckTop, SWT.NONE);
+               leakCheckLabel.setText(Messages.getString("MemcheckToolPage.leak_check")); //$NON-NLS-1$
+               leakCheckCombo = new Combo(leakCheckTop, SWT.READ_ONLY);
+               //leakCheckCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               String[] leakCheckOpts = { "no", "summary", "yes", "full" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+               leakCheckCombo.setItems(leakCheckOpts);
+               leakCheckCombo.addSelectionListener(selectListener);
+
+               Composite leakResTop = new Composite(memcheckTop, SWT.NONE);
+               leakResTop.setLayout(new GridLayout(2, false));
+               leakResTop.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               
+               Label leakResLabel = new Label(leakResTop, SWT.NONE);
+               leakResLabel.setText(Messages.getString("MemcheckToolPage.leak_resolution")); //$NON-NLS-1$
+               leakResCombo = new Combo(leakResTop, SWT.READ_ONLY);
+               String[] leakResOpts = { "low", "med", "high"};
+               leakResCombo.setItems(leakResOpts);
+               leakResCombo.addSelectionListener(selectListener);
+
+               Composite freelistTop = new Composite(memcheckTop, SWT.NONE);
+               freelistTop.setLayout(new GridLayout(2, false));
+               freelistTop.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               
+               Label freelistLabel = new Label(freelistTop, SWT.NONE);
+               freelistLabel.setText(Messages.getString("MemcheckToolPage.freelist_size")); //$NON-NLS-1$
+               freelistSpinner = new Spinner(freelistTop, SWT.BORDER);
+               freelistSpinner.setMaximum(Integer.MAX_VALUE);
+               freelistSpinner.addModifyListener(modifyListener);
+               
+               showReachableButton = new Button(memcheckTop, SWT.CHECK);
+               showReachableButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               showReachableButton.setText(Messages.getString("MemcheckToolPage.show_reachable")); //$NON-NLS-1$
+               showReachableButton.addSelectionListener(selectListener);
+               
+
+               partialLoadsButton = new Button(memcheckTop, SWT.CHECK);
+               partialLoadsButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               partialLoadsButton.setText(Messages.getString("MemcheckToolPage.allow_partial")); //$NON-NLS-1$
+               partialLoadsButton.addSelectionListener(selectListener);
+               
+
+               undefValueButton = new Button(memcheckTop, SWT.CHECK);
+               undefValueButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               undefValueButton.setText(Messages.getString("MemcheckToolPage.undef_value_errors")); //$NON-NLS-1$
+               undefValueButton.addSelectionListener(selectListener);
+//             
+//
+//             gccWorkaroundButton = new Button(memcheckTop, SWT.CHECK);
+//             gccWorkaroundButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+//             gccWorkaroundButton.setText(Messages.getString("MemcheckToolPage.gcc_296_workarounds")); //$NON-NLS-1$
+//             gccWorkaroundButton.addSelectionListener(selectListener);
+//             
+
+               Composite alignmentTop = new Composite(memcheckTop, SWT.NONE);
+               alignmentTop.setLayout(new GridLayout(2, false));
+               alignmentTop.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               
+//             Label alignmentLabel = new Label(alignmentTop, SWT.NONE);
+//             alignmentLabel.setText(Messages.getString("MemcheckToolPage.minimum_heap_block")); //$NON-NLS-1$                
+//             alignmentSpinner = new Spinner(alignmentTop, SWT.BORDER);
+//             alignmentSpinner.setMinimum(8);
+//             alignmentSpinner.setMaximum(4096);
+//             alignmentSpinner.addModifyListener(modifyListener);
+               
+       }
+
+
+       public String getName() {
+               return Messages.getString("MemcheckToolPage.Memcheck_Options"); //$NON-NLS-1$
+       }
+
+       public void initializeFrom(ILaunchConfiguration configuration) {
+               isInitializing = true;
+               try {
+                       initializeMemcheck(configuration);
+               } catch (CoreException e) {
+                       e.printStackTrace();
+               }
+               isInitializing = false;
+       }
+
+       protected void initializeMemcheck(ILaunchConfiguration configuration)
+       throws CoreException {
+               leakCheckCombo.setText(configuration.getAttribute(ATTR_MEMCHECK_LEAKCHECK, "summary"));
+               leakResCombo.setText(configuration.getAttribute(ATTR_MEMCHECK_LEAKRES, "low")); //$NON-NLS-1$
+               showReachableButton.setSelection(configuration.getAttribute(ATTR_MEMCHECK_SHOWREACH, false));
+               freelistSpinner.setSelection(configuration.getAttribute(ATTR_MEMCHECK_FREELIST, 10000000));
+               partialLoadsButton.setSelection(configuration.getAttribute(ATTR_MEMCHECK_PARTIAL, false));
+               undefValueButton.setSelection(configuration.getAttribute(ATTR_MEMCHECK_UNDEF, true));
+       //      gccWorkaroundButton.setSelection(configuration.getAttribute(ATTR_MEMCHECK_GCCWORK, false));
+       }
+       
+       public void performApply(ILaunchConfigurationWorkingCopy configuration) {
+               configuration.setAttribute(ATTR_MEMCHECK_LEAKCHECK, leakCheckCombo.getText());
+               configuration.setAttribute(ATTR_MEMCHECK_LEAKRES, leakResCombo.getText());
+               configuration.setAttribute(ATTR_MEMCHECK_SHOWREACH, showReachableButton.getSelection());
+               configuration.setAttribute(ATTR_MEMCHECK_FREELIST, freelistSpinner.getSelection());
+               configuration.setAttribute(ATTR_MEMCHECK_PARTIAL, partialLoadsButton.getSelection());           
+           configuration.setAttribute(ATTR_MEMCHECK_UNDEF, undefValueButton.getSelection());
+       //      configuration.setAttribute(ATTR_MEMCHECK_GCCWORK, gccWorkaroundButton.getSelection());  
+       }
+
+       public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
+               setDefaultToolAttributes(configuration);
+       }
+       
+       protected static void setDefaultToolAttributes(
+                       ILaunchConfigurationWorkingCopy configuration) {
+               configuration.setAttribute(ATTR_MEMCHECK_LEAKCHECK, "yes");
+               configuration.setAttribute(ATTR_MEMCHECK_LEAKRES, "low"); //$NON-NLS-1$
+               configuration.setAttribute(ATTR_MEMCHECK_SHOWREACH, false);
+               configuration.setAttribute(ATTR_MEMCHECK_FREELIST, 10000000);
+               configuration.setAttribute(ATTR_MEMCHECK_PARTIAL, false);
+               configuration.setAttribute(ATTR_MEMCHECK_UNDEF, true);
+               configuration.setAttribute(ATTR_MEMCHECK_GCCWORK, false);
+       }
+       
+       protected void createHorizontalSpacer(Composite comp, int numlines) {
+               Label lbl = new Label(comp, SWT.NONE);
+               GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+               gd.horizontalSpan = numlines;
+               lbl.setLayoutData(gd);
+       }
+       
+       @Override
+       protected void updateLaunchConfigurationDialog() {
+               if (!isInitializing) {
+                       super.updateLaunchConfigurationDialog();
+               }
+       }
+
+}
diff --git a/org.eclipse.linuxtools.valgrind.memcheck/src/org/eclipse/linuxtools/valgrind/memcheck/MemcheckViewPart.java b/org.eclipse.linuxtools.valgrind.memcheck/src/org/eclipse/linuxtools/valgrind/memcheck/MemcheckViewPart.java
new file mode 100644 (file)
index 0000000..80abb87
--- /dev/null
@@ -0,0 +1,738 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Elliott Baron <ebaron@redhat.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.valgrind.memcheck;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.ITreeViewerListener;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TreeSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.TreeExpansionEvent;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.linuxtools.valgrind.ui.IValgrindToolView;
+import org.eclipse.linuxtools.profiling.ui.ProfileUIUtils;
+import org.eclipse.linuxtools.valgrind.memcheck.model.RootTreeElement;
+import org.eclipse.linuxtools.valgrind.memcheck.model.AuxErrorTreeElement;
+import org.eclipse.linuxtools.valgrind.memcheck.model.ErrorTreeElement;
+import org.eclipse.linuxtools.valgrind.memcheck.model.StackFrameTreeElement;
+import org.eclipse.linuxtools.valgrind.memcheck.model.ValgrindTreeElement;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.ScrolledComposite;
+import org.eclipse.swt.events.ControlEvent;
+import org.eclipse.swt.events.ControlListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeColumn;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.part.ViewPart;
+import org.eclipse.ui.forms.events.ExpansionEvent;
+import org.eclipse.ui.forms.events.IExpansionListener;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.Section;
+
+
+public class MemcheckViewPart extends ViewPart implements IValgrindToolView {
+       protected TreeViewer memoryErrorTreeViewer;
+       protected Section memoryErrorSection;
+
+       protected TreeViewer memoryLeakTreeViewer;
+       protected Section memoryLeakSection;
+
+       protected ScrolledComposite scrolledComposite;
+       protected Composite mainComposite;
+
+       protected ValgrindError[] errors;
+       
+       private ArrayList <String> projectfilelist;
+
+       @Override
+       public void createPartControl(Composite parent) {
+               scrolledComposite = new ScrolledComposite(parent, SWT.V_SCROLL
+                               | SWT.H_SCROLL);
+               scrolledComposite.setLayout(new GridLayout(1, false));
+               scrolledComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+               FormToolkit toolkit = new FormToolkit(scrolledComposite.getDisplay());
+               mainComposite = toolkit.createComposite(scrolledComposite, SWT.BORDER);
+               mainComposite.setLayout(new GridLayout(1, false));
+               mainComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
+               createTitle(mainComposite, toolkit);
+               createMemoryErrorPart(mainComposite, toolkit);
+               createMemoryLeakPart(mainComposite, toolkit);
+               projectfilelist = new ArrayList<String>();      
+       }
+
+       protected void createTitle(Composite parent, FormToolkit toolkit) {
+               Section section = toolkit.createSection(parent, Section.TITLE_BAR);
+               section.setText("Memory Error and Leak Information");
+               section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               toolkit.createCompositeSeparator(section);
+       }
+
+       protected Section createSection(String title, Composite parent,
+                       FormToolkit toolkit) {
+               Section section = toolkit.createSection(parent, Section.EXPANDED
+                               | Section.TREE_NODE | Section.TITLE_BAR);
+               section.setText(title);
+               section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               return section;
+       }
+
+       protected void createMemoryErrorPart(Composite parent, FormToolkit toolkit) {
+               memoryErrorSection = createSection("Memory Error", parent, toolkit);
+
+               Composite subComposite = toolkit.createComposite(memoryErrorSection);
+               memoryErrorSection.setClient(subComposite);
+               memoryErrorSection.addExpansionListener(new SectionExpansionListener());
+               subComposite.setLayout(new GridLayout(1, false));
+               subComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+               Label label = new Label(subComposite, SWT.NONE);
+               label
+                               .setText("All reads and writes of memory are checked, and calls to malloc/new/free/delete are intercepted");
+
+               createMemoryErrorTree(subComposite);
+       }
+
+       protected void createMemoryErrorTree(Composite parent) {
+               memoryErrorTreeViewer = new TreeViewer(parent, SWT.H_SCROLL);
+               Tree localTree = memoryErrorTreeViewer.getTree();
+               localTree.setHeaderVisible(true);
+               localTree.setLinesVisible(true);
+               localTree.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+               String[] columnNames = new String[] { "Memory error", "Function name",
+                               "Sizes", "Address", "Location", "pid", "tid" };
+               int[] columnWidths = new int[] { 125, 150, 50, 80, 405, 80, 50 };
+               TreeColumn[] memoryErrorTreeColumn = new TreeColumn[columnNames.length];
+
+               for (int cnt = 0; cnt < columnNames.length; cnt++) {
+                       memoryErrorTreeColumn[cnt] = new TreeColumn(memoryErrorTreeViewer
+                                       .getTree(), SWT.LEFT);
+                       memoryErrorTreeColumn[cnt].setText(columnNames[cnt]);
+                       memoryErrorTreeColumn[cnt].setWidth(columnWidths[cnt]);
+                       memoryErrorTreeColumn[cnt]
+                                       .addControlListener(new ControlListener() {
+                                               public void controlMoved(ControlEvent e) {
+
+                                               }
+
+                                               public void controlResized(ControlEvent e) {
+                                                       memoryErrorSection.layout(true);
+                                                       resizeComposite();
+                                               }
+                                       });
+               }
+               memoryErrorTreeViewer.setContentProvider(new TreeContentProvider());
+               memoryErrorTreeViewer.setLabelProvider(new ErrorTreeLabelProvider());
+               memoryErrorTreeViewer.addDoubleClickListener(new DoubleClickListener(
+                               memoryErrorTreeViewer, memoryErrorSection));
+               memoryErrorTreeViewer.addTreeListener(new TreeViewerListener(
+                               memoryErrorTreeViewer, memoryErrorSection));
+       }
+
+       protected void createMemoryLeakPart(Composite parent, FormToolkit toolkit) {
+               memoryLeakSection = createSection("Memory Leak", parent, toolkit);
+               Composite subComposite = toolkit.createComposite(memoryLeakSection);
+               memoryLeakSection.setClient(subComposite);
+               memoryLeakSection.addExpansionListener(new SectionExpansionListener());
+               subComposite.setLayout(new GridLayout(1, false));
+               subComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+               Label label = new Label(subComposite, SWT.NONE);
+               label
+                               .setText("Definitely Lost: The worst outcome is that no pointer to the block can be found.\n"
+                                               + "Possibly Lost: A pointer to the interior of the block is found.");
+
+               createMemoryLeakTree(subComposite);
+       }
+
+       protected void createMemoryLeakTree(Composite parent) {
+               memoryLeakTreeViewer = new TreeViewer(parent, SWT.H_SCROLL);
+               Tree localTree = memoryLeakTreeViewer.getTree();
+               localTree.setHeaderVisible(true);
+               localTree.setLinesVisible(true);
+               localTree.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+               String[] columnNames = new String[] { "Memory leak", "Function name",
+                               "Blocks", "Sizes", "Address", "Location", "pid", "tid" };
+               int[] columnWidths = new int[] { 135, 100, 80, 80, 80, 325, 80, 50 };
+               TreeColumn[] memoryLeakTreeColumn = new TreeColumn[columnNames.length];
+
+               for (int cnt = 0; cnt < columnNames.length; cnt++) {
+                       memoryLeakTreeColumn[cnt] = new TreeColumn(memoryLeakTreeViewer
+                                       .getTree(), SWT.LEFT);
+                       memoryLeakTreeColumn[cnt].setText(columnNames[cnt]);
+                       memoryLeakTreeColumn[cnt].setWidth(columnWidths[cnt]);
+                       memoryLeakTreeColumn[cnt].addControlListener(new ControlListener() {
+                               public void controlMoved(ControlEvent e) {
+                                       return;
+                               }
+
+                               public void controlResized(ControlEvent e) {
+                                       memoryLeakSection.layout(true);
+                                       resizeComposite();
+                               }
+                       });
+               }
+
+               memoryLeakTreeViewer.setContentProvider(new TreeContentProvider());
+               memoryLeakTreeViewer.setLabelProvider(new LeakTreeLabelProvider());
+               memoryLeakTreeViewer.addDoubleClickListener(new DoubleClickListener(
+                               memoryLeakTreeViewer, memoryLeakSection));
+               memoryLeakTreeViewer.addTreeListener(new TreeViewerListener(
+                               memoryLeakTreeViewer, memoryLeakSection));
+       }
+
+       public void setErrors(ValgrindError[] errors) {
+               this.errors = errors;
+       }
+
+       @Override
+       public void setFocus() {
+               //viewer.getTree().setFocus();
+       }
+
+       protected void resizeComposite() {
+               scrolledComposite.setMinSize(mainComposite.computeSize(SWT.DEFAULT,
+                               SWT.DEFAULT));
+       }
+       
+       public void getFilelistInProjects() {   
+               this.projectfilelist.clear();
+               IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
+               for(IProject prj: projects) {
+                       try {
+                               // Skip closed projects.
+                               if(!prj.isOpen()) continue;
+                               IResource[] members = prj.getFolder("src").members();
+
+                               for (IResource r : members) {
+                                       if (r.getType() == IResource.FILE && (r.getFileExtension().equalsIgnoreCase("cpp") || r.getFileExtension().equalsIgnoreCase("c"))) {
+                                               
+                                               this.projectfilelist.add(r.getName());
+                                       }
+                               }
+               
+                       } catch (CoreException e) {
+                               e.printStackTrace();
+                       }
+               }
+       }
+
+       public void refreshView() {
+                               
+               IRunnableWithProgress mprefreshRunner = new IRunnableWithProgress() {
+                       public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+                               monitor.beginTask(Messages.getString("MemcheckLaunchDelegate.Error_parsing_output"), 2); //$NON-NLS-1$
+               
+                               Display.getDefault().asyncExec(new Runnable() {
+                                       public void run() {
+                                                       if (errors != null) {
+                                               int max = errors.length;
+                                               ArrayList<ValgrindError> memoryErrorArray = new ArrayList<ValgrindError>();
+                                               ArrayList<ValgrindError> memoryLeakArray = new ArrayList<ValgrindError>();
+                                               for (int cnt = 0; cnt < max; cnt++) {
+                                                       if (errors[cnt].getKind().startsWith("Invalid")) {
+                                                               memoryErrorArray.add(errors[cnt]);
+                                                       } else {
+                                                               memoryLeakArray.add(errors[cnt]);
+                                                       }
+                                               }
+                                               
+                                               getFilelistInProjects(); 
+                                               
+                                               int cnt_defact = 0;
+                                               
+                                               int cnt_def = 0;
+                                               int cnt_def_byte = 0;
+                                               int cnt_def_block = 0;
+                                               int cnt_def_defact = 0;
+                                                       
+                                               int cnt_poss = 0;
+                                               int cnt_poss_byte = 0;
+                                               int cnt_poss_block = 0;
+                                               int cnt_poss_defact = 0;
+                                               
+                                               for (int cnt = 0; cnt < memoryErrorArray.size(); cnt++) {
+                                                       ValgrindError val_tmp = memoryErrorArray.get(cnt);
+                                                       for (int i = 0; i < val_tmp.getFrames().size(); i++){
+                                                               ValgrindStackFrame obj_frame = val_tmp.getFrames().get(i);
+                                                               if(obj_frame.getFile() != null){
+                                                                       for (int j = 0; j < projectfilelist.size(); j++){
+                                                                               if(obj_frame.getFile().compareToIgnoreCase(projectfilelist.get(j)) == 0){
+                                                                                       cnt_defact++;
+                                                                                       i = val_tmp.getFrames().size(); // exit condition 
+                                                                                       break;
+                                                                               }       
+                                                                       }
+                                                               }                                       
+                                                       }                       
+                                               }
+                                               
+                                               
+                                               String str_data = "*** Memory Error Summary ***\n\n";
+                                               str_data += "[ " + memoryErrorArray.size() + " ] errors \n";
+                                               str_data += "\t from [ " + cnt_defact + " ] defect \n";
+                                               str_data += "\t from [ " + (memoryErrorArray.size() - cnt_defact) + " ] system library";
+                                               memoryErrorSection.setToolTipText(str_data);
+                                               
+                                                       
+                                               for (int cnt = 0; cnt < memoryLeakArray.size(); cnt++) {
+                                                       ValgrindError tmp = memoryLeakArray.get(cnt);
+                                                       if(tmp.getKind().startsWith("Leak_DefinitelyLost"))
+                                                       {
+                                                               cnt_def++;
+                                                               String what = tmp.getWhat();
+                                                               int end = what.indexOf(" byte");
+                                                               if (what != null && end >= 0){
+                                                                       String temp_byte = what.substring(0,end);
+                                                                       try{
+                                                                               cnt_def_byte += Integer.valueOf(temp_byte);
+                                                                       }
+                                                                       catch(NumberFormatException e){
+                                                                               try{
+                                                                                       temp_byte = temp_byte.replace(",", "");
+                                                                                       cnt_def_byte += Integer.valueOf(temp_byte);
+                                                                               }
+                                                                               catch(NumberFormatException e1){
+                                                                                       temp_byte = temp_byte.substring(0, temp_byte.indexOf(" ("));
+                                                                                       cnt_def_byte += Integer.valueOf(temp_byte);
+                                                                               }
+                                                                               
+                                                                       }
+                                                               }
+                                                               // block
+                                                               int start = what.indexOf(" in ");
+                                                               end = what.indexOf(" block");
+                                                               if (what != null && start >= 0 && end >= 0){
+                                                                       String temp_block = what.substring(start + 3, end).trim();
+                                                                       try{
+                                                                               cnt_def_block += Integer.valueOf(temp_block);
+                                                                       }
+                                                                       catch(NumberFormatException e){
+                                                                               temp_block = temp_block.replace(",", "");
+                                                                               cnt_def_block += Integer.valueOf(temp_block);
+                                                                       }
+                                                               }
+                                                               
+                                                               // defect                       
+                                                               for (int i = 0; i < tmp.getFrames().size(); i++){
+                                                                       ValgrindStackFrame obj_frame = tmp.getFrames().get(i);
+                                                                       if(obj_frame.getFile() != null){
+                                                                               for (int j = 0; j < projectfilelist.size(); j++){
+                                                                                       if(obj_frame.getFile().compareToIgnoreCase(projectfilelist.get(j)) == 0){
+                                                                                               cnt_def_defact++;
+                                                                                               i = tmp.getFrames().size(); // exit condition 
+                                                                                               break;
+                                                                                       }       
+                                                                               }
+                                                                       }                                       
+                                                               }                       
+                                                       
+                                                               
+                                                               
+                                                       }if(tmp.getKind().startsWith("Leak_PossiblyLost"))
+                                                       {
+                                                               cnt_poss++;
+                                                               String what = tmp.getWhat();
+                                                               int end = what.indexOf(" byte");
+                                                               if (what != null && end >= 0){
+                                                                       String temp_byte = what.substring(0,end);
+                                                                       try{
+                                                                               cnt_poss_byte += Integer.valueOf(temp_byte);
+                                                                       }
+                                                                       catch(NumberFormatException e){
+                                                                               temp_byte = temp_byte.replace(",", "");
+                                                                               cnt_poss_byte += Integer.valueOf(temp_byte);
+                                                                               
+                                                                       }
+                                                               }
+                                                               
+                                                               // block
+                                                               int start = what.indexOf(" in ");
+                                                               end = what.indexOf(" block");
+                                                               if (what != null && start >= 0 && end >= 0){
+                                                                       String temp_block = what.substring(start + 3, end).trim();
+                                                                       try{
+                                                                               cnt_poss_block += Integer.valueOf(temp_block);
+                                                                       }
+                                                                       catch(NumberFormatException e){
+                                                                               temp_block = temp_block.replace(",", "");
+                                                                               cnt_poss_block += Integer.valueOf(temp_block);
+                                                                       }
+                                                               }
+                                                               
+                                                               // defect                       
+                                                               for (int i = 0; i < tmp.getFrames().size(); i++){
+                                                                       ValgrindStackFrame obj_frame = tmp.getFrames().get(i);
+                                                                       if(obj_frame.getFile() != null){
+                                                                               for (int j = 0; j < projectfilelist.size(); j++){
+                                                                                       if(obj_frame.getFile().compareToIgnoreCase(projectfilelist.get(j)) == 0){
+                                                                                               cnt_poss_defact++;
+                                                                                               i = tmp.getFrames().size(); // exit condition 
+                                                                                               break;
+                                                                                       }       
+                                                                               }
+                                                                       }                                       
+                                                               }                       
+                                                       }                               
+                                               }
+                                               
+                                               str_data = "*** Memory Leak Summary ***\n\n";
+                                               str_data += "[ " + cnt_def + " ] definitely lost: [ " + String.format("%,d", cnt_def_byte) + " ] bytes in [ " + String.format("%,d", cnt_def_block) +" ] blocks.\n";
+                                               str_data += "\t from [ " + cnt_def_defact + " ] defect \n";
+                                               str_data += "\t from [ " + (cnt_def - cnt_def_defact) + " ] system library\n\n";
+                                               str_data += "[ " + cnt_poss + " ] possibly lost: [ " + String.format("%,d", cnt_poss_byte) + " ] bytes in [ " + String.format("%,d", cnt_poss_block) +" ] blocks. \n";
+                                               str_data += "\t from [ " + cnt_poss_defact + " ] defect \n";
+                                               str_data += "\t from [ " + (cnt_poss - cnt_poss_defact) + " ] system library \n";
+                                                                       
+                                               memoryLeakSection.setToolTipText(str_data);
+                                               
+                                               RootTreeElement memoryErrorTree = new RootTreeElement(
+                                                               memoryErrorArray.toArray(new ValgrindError[memoryErrorArray
+                                                                               .size()]));
+                                               RootTreeElement memoryLeakTree = new RootTreeElement(
+                                                               memoryLeakArray.toArray(new ValgrindError[memoryLeakArray
+                                                                               .size()]));
+                       
+                                               
+                                               memoryErrorTreeViewer.setInput(memoryErrorTree);
+                                               memoryLeakTreeViewer.setInput(memoryLeakTree);
+                                               scrolledComposite.setContent(mainComposite);
+                                               scrolledComposite.setMinSize(mainComposite.computeSize(SWT.DEFAULT,
+                                                               SWT.DEFAULT));
+                                               scrolledComposite.setExpandVertical(true);
+                                               scrolledComposite.setExpandHorizontal(true);
+                                       }
+                                       }
+                               });
+                               monitor.worked(1);
+
+                               monitor.done();
+                       }
+               };
+               ProgressMonitorDialog dialog = new ProgressMonitorDialog(null);
+               try {
+                       dialog.run(true, false, mprefreshRunner);
+               } catch (InvocationTargetException e) {
+                       e.printStackTrace();
+               } catch (InterruptedException e) {
+                       e.printStackTrace();
+               }                               
+       }
+
+       public IAction[] getToolbarActions() {
+               return null;
+       }
+
+       protected class SectionExpansionListener implements IExpansionListener {
+               public void expansionStateChanged(ExpansionEvent e) {
+                       resizeComposite();
+               }
+
+               public void expansionStateChanging(ExpansionEvent e) {
+               }
+       }
+
+       protected class ErrorTreeLabelProvider extends LabelProvider implements
+                       ITableLabelProvider {
+               public Image getColumnImage(Object element, int columnIndex) {
+                       if (columnIndex == 0)
+                               return ((ValgrindTreeElement) element).getImage();
+                       else
+                               return null;
+               }
+
+               public String getColumnText(Object element, int columnIndex) {
+                       if (element instanceof ErrorTreeElement) {
+                               ErrorTreeElement treeElement = (ErrorTreeElement) element;
+                               switch (columnIndex) {
+                               case 0:
+                                       return treeElement.getKind().replaceFirst("Invalid",
+                                                       "Invalid ");
+                               case 1:
+                                       return treeElement.getFunction();
+                               case 2:
+                                       String what = treeElement.getWhat();
+                                       int start = what.indexOf("size ");
+                                       if (what == null || start < 0)
+                                               return "-";
+                                       else
+                                               return what.substring(start + 5);
+                               case 3:
+                                       return treeElement.getAddress();
+                               case 4:
+                                       return treeElement.getLocation();
+                               case 5:
+                                       return treeElement.getPid();
+                               case 6:
+                                       return treeElement.getTid();
+                               default:
+                                       return null;
+                               }
+                       }
+                       if (element instanceof StackFrameTreeElement) {
+                               ValgrindStackFrame stackElement = ((StackFrameTreeElement) element)
+                                               .getFrame();
+                               switch (columnIndex) {
+                               case 1:
+                                       return stackElement.getFunc();
+                               case 3:
+                                       return stackElement.getPC().toUpperCase().replaceFirst("X",
+                                                       "x");
+                               case 4:
+                                       if (stackElement.getDir() == null
+                                                       || stackElement.getFile() == null)
+                                               //return "***";//stackElement.getObj();
+                                       return stackElement.getObj();
+                                       else
+                                               return stackElement.getFile() + ":"
+                                                               + stackElement.getLine();
+                               default:
+                                       return null;
+                               }
+                       }
+                       if (element instanceof AuxErrorTreeElement) {
+                               AuxErrorTreeElement auxError = (AuxErrorTreeElement) element;
+                               String temp;
+                               switch (columnIndex) {
+                               case 0:
+                                       temp = auxError.getText();
+                                       if (temp.indexOf("size") > 0) {
+                                               String last = temp.substring(temp.indexOf("size") + 5);
+                                               return temp.substring(temp.indexOf("bytes ") + 6, temp
+                                                               .indexOf(" a "))
+                                                               + " "
+                                                               + last.substring(last.indexOf(" ") + 1)
+                                                               + " area";
+                                       } else {
+                                               return temp.substring(temp.indexOf("is") + 3);
+                                       }
+                               case 1:
+                                       return auxError.getFunction();
+                               case 2:
+                                       temp = auxError.getText();
+                                       if (temp.indexOf("size") > 0) {
+                                               String last = temp.substring(temp.indexOf("size") + 5);
+                                               return temp.substring(temp.indexOf("is") + 3, temp
+                                                               .indexOf(" byte"))
+                                                               + "/"
+                                                               + last.substring(0, last.indexOf(" ") - 1);
+                                       }
+                                       return null;
+                               case 3:
+                                       temp = auxError.getText();
+                                       return temp.substring(temp.indexOf("Address") + 8,
+                                                       temp.indexOf(" is")).toUpperCase().replaceFirst(
+                                                       "X", "x");
+                               case 4:
+                                       return auxError.getLocation();
+                               default:
+                                       return null;
+                               }
+                       }
+                       return null;
+               }
+       }
+
+       protected class LeakTreeLabelProvider extends LabelProvider implements
+                       ITableLabelProvider {
+               public Image getColumnImage(Object element, int columnIndex) {
+                       if (columnIndex == 0)
+                               return ((ValgrindTreeElement) element).getImage();
+                       else
+                               return null;
+               }
+
+               public String getColumnText(Object element, int columnIndex) {
+                       if (element instanceof ErrorTreeElement) {
+                               ErrorTreeElement treeElement = (ErrorTreeElement) element;
+                               String what;
+                               int start, end;
+                               switch (columnIndex) {
+                               case 0:
+                                       return treeElement.getKind().replaceFirst("Leak_", "")
+                                                       .replaceAll("Lost", " Lost");
+                               case 1:
+                                       return treeElement.getFunction();
+                               case 2:
+                                       what = treeElement.getWhat();
+                                       start = what.indexOf(" in ");
+                                       end = what.indexOf(" block");
+                                       if (what != null && start >= 0 && end >= 0)
+                                               return what.substring(start + 3, end);
+                                       return null;
+                               case 3:
+                                       what = treeElement.getWhat();
+                                       end = what.indexOf(" byte");
+                                       if (what != null && end >= 0)
+                                               return what.substring(0, end);
+                                       return null;
+                               case 4:
+                                       return treeElement.getAddress();
+                               case 5:
+                                       return treeElement.getLocation();
+                               case 6:
+                                       return treeElement.getPid();
+                               case 7:
+                                       return treeElement.getTid();
+                               default:
+                                       return null;
+                               }
+                       }
+                       if (element instanceof StackFrameTreeElement) {
+                               ValgrindStackFrame stackElement = ((StackFrameTreeElement) element)
+                                               .getFrame();
+                               switch (columnIndex) {
+                               case 1:
+                                       return stackElement.getFunc();
+                               case 4:
+                                       return stackElement.getPC().toUpperCase().replaceFirst("X",
+                                                       "x");
+                               case 5:
+                                       if (stackElement.getDir() == null
+                                                       || stackElement.getFile() == null){
+                                       //      return "***";//stackElement.getObj();
+                                               return stackElement.getObj();}
+                                       else{
+                                               return stackElement.getFile() + ":"
+                                                               + stackElement.getLine();
+                                       }default:
+                                       return null;
+                               }
+                       }
+                       return null;
+               }
+       }
+
+       protected class TreeContentProvider implements ITreeContentProvider {
+               public Object[] getChildren(Object parentElement) {
+                       return ((ValgrindTreeElement) parentElement).getChildren();
+               }
+
+               public Object getParent(Object element) {
+                       return ((ValgrindTreeElement) element).getParent();
+               }
+
+               public boolean hasChildren(Object element) {
+                       return getChildren(element).length > 0;
+               }
+
+               public Object[] getElements(Object inputElement) {
+                       return getChildren(inputElement);
+               }
+
+               public void dispose() {
+               }
+
+               public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+               }
+       }
+
+       protected class TreeViewerListener implements ITreeViewerListener {
+               protected TreeViewer viewer;
+               protected Section section;
+
+               public TreeViewerListener(TreeViewer input, Section sec) {
+                       viewer = input;
+                       section = sec;
+               }
+
+               public void treeCollapsed(TreeExpansionEvent event) {
+                       section.getClient().getDisplay().asyncExec(new ResizingRunnable());
+               }
+
+               public void treeExpanded(TreeExpansionEvent event) {
+                       section.getClient().getDisplay().asyncExec(new ResizingRunnable());
+               }
+
+               protected class ResizingRunnable implements Runnable {
+                       public void run() {
+                               try {
+                                       while (viewer.isBusy()) {
+                                               Thread.sleep(10);
+                                       }
+                               } catch (InterruptedException e) {
+                                       e.printStackTrace();
+                               }
+                               section.layout(true);
+                               resizeComposite();
+                       }
+               }
+       }
+
+       protected class DoubleClickListener implements IDoubleClickListener {
+               private TreeViewer viewer;
+               private Section section;
+
+               public DoubleClickListener(TreeViewer input, Section sec) {
+                       viewer = input;
+                       section = sec;
+               }
+
+               public void doubleClick(DoubleClickEvent event) {
+                       Object element = ((TreeSelection) event.getSelection())
+                                       .getFirstElement();
+                       if (element instanceof StackFrameTreeElement) {
+                               ValgrindStackFrame frame = ((StackFrameTreeElement) element)
+                                               .getFrame();
+                               if (frame.getFile() != null) {
+                                       String sb_strpath = frame.getDir() + Path.SEPARATOR
+                                                       + frame.getFile();
+                                       //fixed for sb2
+                                       //String strpath = ScratchboxTargetControl.getHostpathFromSboxpath(sb_strpath);
+                                       String strpath = sb_strpath;
+
+                                       int line = frame.getLine();
+                                       try {
+                                               ProfileUIUtils.openEditorAndSelect(strpath, line);
+                                       } catch (PartInitException e) {
+                                               e.printStackTrace();
+                                       } catch (BadLocationException e) {
+                                               e.printStackTrace();
+                                       }
+                               }
+                       } else {
+                               if (!viewer.isExpandable(element))
+                                       return;
+                               if (viewer.getExpandedState(element)) {
+                                       viewer.collapseToLevel(element, TreeViewer.ALL_LEVELS);
+                               } else {
+                                       viewer.expandToLevel(element, 1);
+                               }
+                               section.layout(true);
+                               resizeComposite();
+                       }
+               }
+       }
+}
\ No newline at end of file
diff --git a/org.eclipse.linuxtools.valgrind.memcheck/src/org/eclipse/linuxtools/valgrind/memcheck/Messages.java b/org.eclipse.linuxtools.valgrind.memcheck/src/org/eclipse/linuxtools/valgrind/memcheck/Messages.java
new file mode 100644 (file)
index 0000000..2fd2852
--- /dev/null
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Elliott Baron <ebaron@redhat.com> - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.valgrind.memcheck;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class Messages {
+       private static final String BUNDLE_NAME = "org.eclipse.linuxtools.valgrind.memcheck.messages"; //$NON-NLS-1$
+
+       private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
+                       .getBundle(BUNDLE_NAME);
+
+       private Messages() {
+       }
+
+       public static String getString(String key) {
+               try {
+                       return RESOURCE_BUNDLE.getString(key);
+               } catch (MissingResourceException e) {
+                       return '!' + key + '!';
+               }
+       }
+}
diff --git a/org.eclipse.linuxtools.valgrind.memcheck/src/org/eclipse/linuxtools/valgrind/memcheck/ValgrindError.java b/org.eclipse.linuxtools.valgrind.memcheck/src/org/eclipse/linuxtools/valgrind/memcheck/ValgrindError.java
new file mode 100644 (file)
index 0000000..27883d0
--- /dev/null
@@ -0,0 +1,154 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Elliott Baron <ebaron@redhat.com> - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.valgrind.memcheck;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Path;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+public class ValgrindError {
+       protected String unique;
+       protected String tid;
+       protected String kind;
+       protected String what;
+       protected String pid; 
+       protected ArrayList<ValgrindStackFrame> frames;
+       protected String auxwhat;
+       protected ArrayList<ValgrindStackFrame> auxframes;
+
+       public ValgrindError(Node errorNode) throws CoreException, IOException {
+               pid = findPid(errorNode);
+
+               NodeList list = errorNode.getChildNodes();
+               for (int i = 0; i < list.getLength(); i++) {
+                       Node n = list.item(i);
+                       if (n.getNodeName().equals("unique")) { //$NON-NLS-1$
+                               unique = n.getTextContent();
+                       }
+                       else if (n.getNodeName().equals("tid")) { //$NON-NLS-1$
+                               tid = n.getTextContent();
+                       }
+                       else if (n.getNodeName().equals("kind")) { //$NON-NLS-1$
+                               kind = n.getTextContent();
+                       }
+                       else if (n.getNodeName().equals("what")) { //$NON-NLS-1$
+                               what = n.getTextContent();
+                       }
+                       else if (n.getNodeName().equals("xwhat")) { //$NON-NLS-1$
+                               NodeList errorNodes =  n.getChildNodes();
+                               for(int j= 0; j<errorNodes.getLength(); j++) {
+                                       Node iN = errorNodes.item(j);
+                                       if(iN.getNodeName().equals("text")) {
+                                               what = iN.getTextContent();
+//                                     } else if(iN.getNodeName().equals("leakedbytes")) {
+//                                     } else if(iN.getNodeName().equals("leakedblocks")) {
+                                       }
+                               }
+                       }
+                       else if (n.getNodeName().equals("stack")) { //$NON-NLS-1$
+                               NodeList frameNodes = n.getChildNodes();
+                               // main stack or aux stack?
+                               ArrayList<ValgrindStackFrame> stack;
+                               if (auxwhat == null) {
+                                       frames = new ArrayList<ValgrindStackFrame>();
+                                       stack = frames;
+                               }
+                               else {
+                                       auxframes = new ArrayList<ValgrindStackFrame>();
+                                       stack = auxframes;
+                               }
+                               for (int j = 0; j < frameNodes.getLength(); j++) {
+                                       Node m = frameNodes.item(j);
+                                       if (m.getNodeName().equals("frame")) { //$NON-NLS-1$
+                                               stack.add(new ValgrindStackFrame(m));   
+                                       }
+                               }
+                       }
+                       else if (n.getNodeName().equals("auxwhat")) { //$NON-NLS-1$
+                               auxwhat = n.getTextContent();
+                       }
+               }
+               
+               createMarker();
+       }
+
+       protected void createMarker() throws CoreException, IOException {
+               IMarker marker = null;          
+               // find the topmost stack frame within the workspace to annotate with marker
+               for (int i = 0; i < frames.size() && marker == null; i++) {
+                       ValgrindStackFrame frame = frames.get(i);
+                       if (frame.getDir() != null && frame.getFile() != null && frame.getLine() > 0) {
+                               String strpath = frame.getDir() + Path.SEPARATOR + frame.getFile();
+                               File file = new File(strpath);
+                               Path path = new Path(file.getAbsolutePath());
+                               
+                               IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+                               IFile resource = root.getFileForLocation(path);
+                               if (resource != null && resource.exists()) {
+                                       marker = resource.createMarker(MemcheckPlugin.MARKER_TYPE);
+                                       marker.setAttribute(IMarker.MESSAGE, what);
+                                       marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
+                                       marker.setAttribute(IMarker.LINE_NUMBER, frame.getLine());
+                               }
+                       }
+               }
+       }
+
+       protected String findPid(Node errorNode) {
+               String pid = null;
+               NodeList pidList = errorNode.getOwnerDocument().getElementsByTagName("pid"); //$NON-NLS-1$
+               if (pidList.getLength() > 0) {
+                       pid = pidList.item(0).getTextContent();
+               }
+               return pid;
+       }
+
+       public ArrayList<ValgrindStackFrame> getFrames() {
+               return frames;
+       }
+
+       public String getKind() {
+               return kind;
+       }
+
+       public String getTid() {
+               return tid;
+       }
+
+       public String getUnique() {
+               return unique;
+       }
+
+       public String getWhat() {
+               return what;
+       }
+
+       public String getPid() {
+               return pid;
+       }
+       
+       public String getAuxWhat() {
+               return auxwhat;
+       }
+       
+       public ArrayList<ValgrindStackFrame> getAuxFrames() {
+               return auxframes;
+       }
+}
diff --git a/org.eclipse.linuxtools.valgrind.memcheck/src/org/eclipse/linuxtools/valgrind/memcheck/ValgrindErrorDesc.java b/org.eclipse.linuxtools.valgrind.memcheck/src/org/eclipse/linuxtools/valgrind/memcheck/ValgrindErrorDesc.java
new file mode 100644 (file)
index 0000000..4036d10
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Valgrind Error Description 
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Jaewon Lim <jaewon81.lim@samsung.com>
+ * Wonhyoung Park <wonhyoung2.park@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.eclipse.linuxtools.valgrind.memcheck;
+
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+public class ValgrindErrorDesc {
+       private String text;
+       private int leakedBytes;
+       private int leakedBlocks;
+
+       public ValgrindErrorDesc(Node descNode) {
+               NodeList list = descNode.getChildNodes();
+               for (int i = 0; i < list.getLength(); i++) {
+                       Node n = list.item(i);
+                       if (n.getNodeName().equals("text")) { //$NON-NLS-1$
+                               text = n.getTextContent();
+                       }
+                       else if (n.getNodeName().equals("leakedbytes")) { //$NON-NLS-1$
+                               leakedBytes = Integer.parseInt(n.getTextContent());
+                       }
+                       else if (n.getNodeName().equals("leakedblocks")) { //$NON-NLS-1$
+                               leakedBlocks =  Integer.parseInt(n.getTextContent());
+                       }
+               }
+       }
+
+       public String getText() {
+               return text;
+       }
+
+       public int getLeakedBytes() {
+               return leakedBytes;
+       }
+
+       public int getLeakedBlocks() {
+               return leakedBlocks;
+       }
+}
diff --git a/org.eclipse.linuxtools.valgrind.memcheck/src/org/eclipse/linuxtools/valgrind/memcheck/ValgrindStackFrame.java b/org.eclipse.linuxtools.valgrind.memcheck/src/org/eclipse/linuxtools/valgrind/memcheck/ValgrindStackFrame.java
new file mode 100644 (file)
index 0000000..2b3af9b
--- /dev/null
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Elliott Baron <ebaron@redhat.com> - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.valgrind.memcheck;
+
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+public class ValgrindStackFrame {
+       protected String pc;
+       protected String obj;
+       protected String func;
+       protected String dir;
+       protected String file;
+       protected int line;
+       
+       public ValgrindStackFrame(Node frameNode) {
+               NodeList list = frameNode.getChildNodes();
+               for (int i = 0; i < list.getLength(); i++) {
+                       Node n = list.item(i);
+                       if (n.getNodeName().equals("ip")) { //$NON-NLS-1$
+                               pc = n.getTextContent();
+                       }
+                       else if (n.getNodeName().equals("obj")) { //$NON-NLS-1$
+                               obj = n.getTextContent();
+                       }
+                       else if (n.getNodeName().equals("fn")) { //$NON-NLS-1$
+                               func = n.getTextContent();
+                       }
+                       else if (n.getNodeName().equals("dir")) { //$NON-NLS-1$
+                               dir = n.getTextContent();
+                       }
+                       else if (n.getNodeName().equals("file")) { //$NON-NLS-1$
+                               file = n.getTextContent();
+                       }
+                       else if (n.getNodeName().equals("line")) { //$NON-NLS-1$
+                               line = Integer.parseInt(n.getTextContent());
+                       }
+               }
+       }
+       
+       public String getDir() {
+               return dir;
+       }
+       
+       public String getFile() {
+               return file;
+       }
+       
+       public String getFunc() {
+               return func;
+       }
+       
+       public int getLine() {
+               return line;
+       }
+       
+       public String getObj() {
+               return obj;
+       }
+       
+       public String getPC() {
+               return pc;
+       }
+       
+}
diff --git a/org.eclipse.linuxtools.valgrind.memcheck/src/org/eclipse/linuxtools/valgrind/memcheck/ValgrindXMLParser.java b/org.eclipse.linuxtools.valgrind.memcheck/src/org/eclipse/linuxtools/valgrind/memcheck/ValgrindXMLParser.java
new file mode 100644 (file)
index 0000000..6136b1b
--- /dev/null
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Elliott Baron <ebaron@redhat.com> - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.valgrind.memcheck;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.linuxtools.valgrind.core.ValgrindPlugin;
+import org.w3c.dom.Document;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+public class ValgrindXMLParser {
+       protected static final String END_TAG = "</valgrindoutput>"; //$NON-NLS-1$
+
+       protected DocumentBuilder builder;
+       protected ArrayList<ValgrindError> errors;
+
+       public ValgrindXMLParser(InputStream in) throws ParserConfigurationException, IOException, CoreException, SAXException {
+               builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+               errors = new ArrayList<ValgrindError>();
+
+               StringBuffer xmlBuf = new StringBuffer();
+               StringBuffer plainBuf = new StringBuffer();
+               separateOutput(in, xmlBuf, plainBuf);
+
+               // any plaintext in memcheck output is an error
+               String err = plainBuf.toString().trim();
+               if (err.length() > 0) {
+                       throw new CoreException(new Status(IStatus.ERROR, ValgrindPlugin.PLUGIN_ID, err));
+               }
+
+               InputSource is = new InputSource(new ByteArrayInputStream(xmlBuf.toString().getBytes()));
+               Document doc = builder.parse(is);
+
+               NodeList nodes = doc.getElementsByTagName("error"); //$NON-NLS-1$
+               for (int i = 0; i < nodes.getLength(); i++) {
+                       errors.add(new ValgrindError(nodes.item(i)));
+               }
+       }
+
+       /*
+        * Currently only memcheck works with xml output so core messages such as fatal errors
+        * will result in malformed xml documents.
+        */
+       protected void separateOutput(InputStream in, StringBuffer xmlBuf, StringBuffer plainBuf) throws IOException {
+               BufferedReader br = new BufferedReader(new InputStreamReader(in));
+
+               boolean xml = false;
+               String line;
+               while ((line = br.readLine()) != null) {
+                       if (line.startsWith("<?xml")) { //$NON-NLS-1$
+                               xml = true;
+                       }
+                       if (xml) {
+                               xmlBuf.append(line + "\n"); //$NON-NLS-1$
+                       }
+                       else {
+                               plainBuf.append(line + "\n"); //$NON-NLS-1$
+                       }
+                       if (line.equals(END_TAG)) {
+                               xml = false;
+                       }
+               }
+
+       }
+
+       public ArrayList<ValgrindError> getErrors() {
+               return errors;
+       }
+}
diff --git a/org.eclipse.linuxtools.valgrind.memcheck/src/org/eclipse/linuxtools/valgrind/memcheck/messages.properties b/org.eclipse.linuxtools.valgrind.memcheck/src/org/eclipse/linuxtools/valgrind/memcheck/messages.properties
new file mode 100644 (file)
index 0000000..4e17a39
--- /dev/null
@@ -0,0 +1,10 @@
+MemcheckLaunchDelegate.Error_parsing_output=Error parsing output
+MemcheckToolPage.allow_partial=allow partial loads:
+MemcheckToolPage.freelist_size=freelist size (blocks):
+MemcheckToolPage.gcc_296_workarounds=gcc 2.96 workarounds:
+MemcheckToolPage.leak_check=leak check:
+MemcheckToolPage.leak_resolution=leak resolution:
+MemcheckToolPage.Memcheck_Options=Memcheck Options
+MemcheckToolPage.show_reachable=show reachable blocks:
+MemcheckToolPage.undef_value_errors=undef value errors:
+MemcheckToolPage.minimum_heap_block=minimum heap block alignment:
diff --git a/org.eclipse.linuxtools.valgrind.memcheck/src/org/eclipse/linuxtools/valgrind/memcheck/model/AuxErrorTreeElement.java b/org.eclipse.linuxtools.valgrind.memcheck/src/org/eclipse/linuxtools/valgrind/memcheck/model/AuxErrorTreeElement.java
new file mode 100644 (file)
index 0000000..82dbf12
--- /dev/null
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Elliott Baron <ebaron@redhat.com> - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.valgrind.memcheck.model;
+
+import java.util.ArrayList;
+
+import org.eclipse.linuxtools.valgrind.memcheck.ValgrindError;
+import org.eclipse.linuxtools.valgrind.memcheck.ValgrindStackFrame;
+import org.eclipse.swt.graphics.Image;
+
+public class AuxErrorTreeElement extends ValgrindTreeElement {
+       protected ValgrindError error;
+       
+       public AuxErrorTreeElement(ValgrindTreeElement parent, ValgrindError error) {
+               this.parent = parent;
+               this.error = error;
+               children = new ArrayList<ValgrindTreeElement>();
+               
+               ArrayList<ValgrindStackFrame> frames = error.getAuxFrames();
+               if (frames != null) {
+                       createStackElements(frames);
+               }
+       }
+
+       @Override
+       public Image getImage() {
+               return ERROR_IMG;
+//             return null;
+       }
+
+       @Override
+       public String getText() {
+               return error.getAuxWhat();
+       }
+       
+       public String getFunction() {
+               if (error.getAuxFrames() != null)
+                       return error.getAuxFrames().get(0).getFunc();
+               return null;
+       }
+       
+       public String getLocation() {
+               if (error.getAuxFrames() != null) {
+                       ValgrindStackFrame temp = error.getAuxFrames().get(0);
+                       if (temp.getDir() == null || temp.getFile() == null)
+                               //return "???";//temp.getObj();
+                               return temp.getObj();
+                       else
+                               return temp.getFile() + ":" + temp.getLine();
+               }
+               return null;
+       }
+}
diff --git a/org.eclipse.linuxtools.valgrind.memcheck/src/org/eclipse/linuxtools/valgrind/memcheck/model/ErrorTreeElement.java b/org.eclipse.linuxtools.valgrind.memcheck/src/org/eclipse/linuxtools/valgrind/memcheck/model/ErrorTreeElement.java
new file mode 100644 (file)
index 0000000..1ae57e1
--- /dev/null
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Elliott Baron <ebaron@redhat.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.valgrind.memcheck.model;
+
+import java.util.ArrayList;
+
+import org.eclipse.linuxtools.valgrind.memcheck.ValgrindError;
+import org.eclipse.linuxtools.valgrind.memcheck.ValgrindStackFrame;
+import org.eclipse.swt.graphics.Image;
+
+public class ErrorTreeElement extends ValgrindTreeElement {
+       protected ValgrindError error;
+
+       public ErrorTreeElement(ValgrindTreeElement parent, ValgrindError error) {
+               this.parent = parent;
+               this.error = error;
+               children = new ArrayList<ValgrindTreeElement>();
+
+               ArrayList<ValgrindStackFrame> frames = error.getFrames();
+               createStackElements(frames);
+
+               String auxwhat = error.getAuxWhat();
+               if (auxwhat != null) {
+                       children.add(new AuxErrorTreeElement(this, error));
+               }
+       }
+
+       @Override
+       public String getText() {
+               return error.getWhat()
+                               + " [pid: " + error.getPid() + " / tid: " + error.getTid() + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+       }
+
+       @Override
+       public Image getImage() {
+               return ERROR_IMG;
+//             return null;
+       }
+       
+       public String getKind() {
+               return error.getKind();
+       }
+
+       public String getWhat() {
+               return error.getWhat();
+       }
+
+       public String getPid() {
+               return error.getPid();
+       }
+
+       public String getTid() {
+               return error.getTid();
+       }
+
+       public String getFunction() {
+               if (error.getFrames().size() != 0)
+                       return error.getFrames().get(0).getFunc();
+               return null;
+       }
+
+       public String getAddress() {
+               if (error.getFrames().size() != 0)
+                       return error.getFrames().get(0).getPC().toUpperCase().replace("X",
+                                       "x");
+               return null;
+       }
+
+       public String getLocation() {
+               if (error.getFrames().size() != 0) {
+                       ValgrindStackFrame temp = error.getFrames().get(0);
+                       if (temp.getDir() == null || temp.getFile() == null)
+                               //return "???";//temp.getObj();
+                               return temp.getObj();
+                       else
+                               return temp.getFile() + ":" + temp.getLine();
+               }
+               return null;
+       }
+}
diff --git a/org.eclipse.linuxtools.valgrind.memcheck/src/org/eclipse/linuxtools/valgrind/memcheck/model/Messages.java b/org.eclipse.linuxtools.valgrind.memcheck/src/org/eclipse/linuxtools/valgrind/memcheck/model/Messages.java
new file mode 100644 (file)
index 0000000..088c825
--- /dev/null
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Elliott Baron <ebaron@redhat.com> - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.valgrind.memcheck.model;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class Messages {
+       private static final String BUNDLE_NAME = "org.eclipse.linuxtools.valgrind.memcheck.model.messages"; //$NON-NLS-1$
+
+       private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
+                       .getBundle(BUNDLE_NAME);
+
+       private Messages() {
+       }
+
+       public static String getString(String key) {
+               try {
+                       return RESOURCE_BUNDLE.getString(key);
+               } catch (MissingResourceException e) {
+                       return '!' + key + '!';
+               }
+       }
+}
diff --git a/org.eclipse.linuxtools.valgrind.memcheck/src/org/eclipse/linuxtools/valgrind/memcheck/model/RootTreeElement.java b/org.eclipse.linuxtools.valgrind.memcheck/src/org/eclipse/linuxtools/valgrind/memcheck/model/RootTreeElement.java
new file mode 100644 (file)
index 0000000..751ec3f
--- /dev/null
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Elliott Baron <ebaron@redhat.com> - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.valgrind.memcheck.model;
+
+import java.util.ArrayList;
+
+import org.eclipse.linuxtools.valgrind.memcheck.ValgrindError;
+import org.eclipse.swt.graphics.Image;
+
+public class RootTreeElement extends ValgrindTreeElement {
+
+       public RootTreeElement(ValgrindError[] errors) {
+               parent = null;
+               children = new ArrayList<ValgrindTreeElement>(errors.length);
+               for (ValgrindError error : errors) {
+                       children.add(new ErrorTreeElement(this, error));
+               }
+       }
+       
+       @Override
+       public String getText() {
+               return null;
+       }
+
+       @Override
+       public Image getImage() {
+               return null;
+       }
+
+}
diff --git a/org.eclipse.linuxtools.valgrind.memcheck/src/org/eclipse/linuxtools/valgrind/memcheck/model/StackFrameTreeElement.java b/org.eclipse.linuxtools.valgrind.memcheck/src/org/eclipse/linuxtools/valgrind/memcheck/model/StackFrameTreeElement.java
new file mode 100644 (file)
index 0000000..6a422af
--- /dev/null
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Elliott Baron <ebaron@redhat.com> - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.valgrind.memcheck.model;
+
+import java.util.ArrayList;
+
+import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.debug.ui.IDebugUIConstants;
+import org.eclipse.linuxtools.valgrind.memcheck.ValgrindStackFrame;
+import org.eclipse.swt.graphics.Image;
+
+public class StackFrameTreeElement extends ValgrindTreeElement {
+
+       protected ValgrindStackFrame frame;
+       protected boolean top;
+
+       public StackFrameTreeElement(ValgrindTreeElement parent, ValgrindStackFrame frame, boolean top) {
+               this.parent = parent;           
+               this.frame = frame;
+               this.top = top;
+               children = new ArrayList<ValgrindTreeElement>();
+       }
+
+       public StackFrameTreeElement(ValgrindTreeElement parent, ValgrindStackFrame frame) {
+               this(parent, frame, false);
+       }
+
+       @Override
+       public String getText() {
+               StringBuffer line = new StringBuffer();
+               line.append(top ? Messages.getString("StackFrameTreeElement.at") : Messages.getString("StackFrameTreeElement.by")); //$NON-NLS-1$ //$NON-NLS-2$
+               line.append(frame.getPC() + ": "); //$NON-NLS-1$
+               if (frame.getObj() != null) {
+                       if (frame.getFunc() != null) {
+                               line.append(frame.getFunc() + " "); //$NON-NLS-1$
+                       }
+                       line.append("("); //$NON-NLS-1$
+                       if (frame.getFile() != null) {
+                               line.append(frame.getFile() + ":" + String.valueOf(frame.getLine())); //$NON-NLS-1$
+                       }
+                       else {
+                               line.append(Messages.getString("StackFrameTreeElement.within") + frame.getObj()); //$NON-NLS-1$
+                       }
+                       line.append(")"); //$NON-NLS-1$
+               }
+               else {
+                       line.append("***"); //$NON-NLS-1$
+               }
+               return line.toString();
+       }
+
+       @Override
+       public Image getImage() {
+               return DebugUITools.getImage(IDebugUIConstants.IMG_OBJS_STACKFRAME);
+       }
+       
+       public ValgrindStackFrame getFrame() {
+               return frame;
+       }
+
+}
diff --git a/org.eclipse.linuxtools.valgrind.memcheck/src/org/eclipse/linuxtools/valgrind/memcheck/model/TextTreeElement.java b/org.eclipse.linuxtools.valgrind.memcheck/src/org/eclipse/linuxtools/valgrind/memcheck/model/TextTreeElement.java
new file mode 100644 (file)
index 0000000..6821ae9
--- /dev/null
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Elliott Baron <ebaron@redhat.com> - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.valgrind.memcheck.model;
+
+import java.util.ArrayList;
+
+import org.eclipse.swt.graphics.Image;
+
+public class TextTreeElement extends ValgrindTreeElement {
+       
+       protected String text;
+       
+       public TextTreeElement(ValgrindTreeElement parent, String text) {
+               this.parent = parent;
+               this.text = text;
+               children = new ArrayList<ValgrindTreeElement>();
+       }
+
+       @Override
+       public String getText() {
+               return text;
+       }
+
+       @Override
+       public Image getImage() {
+               return null;
+       }
+
+}
diff --git a/org.eclipse.linuxtools.valgrind.memcheck/src/org/eclipse/linuxtools/valgrind/memcheck/model/ValgrindTreeElement.java b/org.eclipse.linuxtools.valgrind.memcheck/src/org/eclipse/linuxtools/valgrind/memcheck/model/ValgrindTreeElement.java
new file mode 100644 (file)
index 0000000..3b6facd
--- /dev/null
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Elliott Baron <ebaron@redhat.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.valgrind.memcheck.model;
+
+import java.util.ArrayList;
+
+import org.eclipse.linuxtools.valgrind.memcheck.MemcheckPlugin;
+import org.eclipse.linuxtools.valgrind.memcheck.ValgrindStackFrame;
+import org.eclipse.swt.graphics.Image;
+
+public abstract class ValgrindTreeElement {
+       protected static final Image ERROR_IMG = MemcheckPlugin
+                       .imageDescriptorFromPlugin(MemcheckPlugin.PLUGIN_ID,
+                                       "icons/warning.gif").createImage();
+
+       protected ValgrindTreeElement parent;
+       protected ArrayList<ValgrindTreeElement> children;
+
+       public ValgrindTreeElement getParent() {
+               return parent;
+       }
+
+       public ValgrindTreeElement[] getChildren() {
+               return children.toArray(new ValgrindTreeElement[children.size()]);
+       }
+
+       public abstract String getText();
+
+       public abstract Image getImage();
+
+       protected void createStackElements(ArrayList<ValgrindStackFrame> frames) {
+               if (frames.size() > 0) {
+                       children.add(new StackFrameTreeElement(this, frames.get(0), true));
+                       for (int i = 1; i < frames.size(); i++) {
+                               children.add(new StackFrameTreeElement(this, frames.get(i)));
+                       }
+               }
+       }
+}
diff --git a/org.eclipse.linuxtools.valgrind.memcheck/src/org/eclipse/linuxtools/valgrind/memcheck/model/messages.properties b/org.eclipse.linuxtools.valgrind.memcheck/src/org/eclipse/linuxtools/valgrind/memcheck/model/messages.properties
new file mode 100644 (file)
index 0000000..22905b4
--- /dev/null
@@ -0,0 +1,3 @@
+StackFrameTreeElement.at=at 
+StackFrameTreeElement.by=by 
+StackFrameTreeElement.within=within 
diff --git a/org.eclipse.linuxtools.valgrind.memcheck/src/org/tizen/valgrind/memcheck/editor/MemcheckEditor.java b/org.eclipse.linuxtools.valgrind.memcheck/src/org/tizen/valgrind/memcheck/editor/MemcheckEditor.java
new file mode 100644 (file)
index 0000000..cd50b8a
--- /dev/null
@@ -0,0 +1,817 @@
+/*
+ *  Memcheck Editor
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Jaewon Lim <jaewon81.lim@samsung.com>
+ * Wonhyoung Park <wonhyoung2.park@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.valgrind.memcheck.editor;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.ArrayList;
+
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.ITreeViewerListener;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TreeExpansionEvent;
+import org.eclipse.jface.viewers.TreeSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.linuxtools.profiling.ui.ProfileUIUtils;
+import org.eclipse.linuxtools.valgrind.memcheck.ValgrindError;
+import org.eclipse.linuxtools.valgrind.memcheck.ValgrindStackFrame;
+import org.eclipse.linuxtools.valgrind.memcheck.ValgrindXMLParser;
+import org.eclipse.linuxtools.valgrind.memcheck.model.AuxErrorTreeElement;
+import org.eclipse.linuxtools.valgrind.memcheck.model.ErrorTreeElement;
+import org.eclipse.linuxtools.valgrind.memcheck.model.RootTreeElement;
+import org.eclipse.linuxtools.valgrind.memcheck.model.StackFrameTreeElement;
+import org.eclipse.linuxtools.valgrind.memcheck.model.ValgrindTreeElement;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.ScrolledComposite;
+import org.eclipse.swt.events.ControlEvent;
+import org.eclipse.swt.events.ControlListener;
+import org.eclipse.swt.graphics.Cursor;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeColumn;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.editors.text.TextEditor;
+import org.eclipse.ui.forms.events.ExpansionEvent;
+import org.eclipse.ui.forms.events.IExpansionListener;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.Section;
+import org.eclipse.ui.part.MultiPageEditorPart;
+import org.xml.sax.SAXException;
+
+
+public class MemcheckEditor extends MultiPageEditorPart {
+       
+       protected TreeViewer memoryErrorTreeViewer;
+       protected Section memoryErrorSection;
+
+       protected TreeViewer memoryLeakTreeViewer;
+       protected Section memoryLeakSection;
+
+       protected ScrolledComposite scrolledComposite;
+       protected Composite mainComposite;
+
+       protected ValgrindError[] errors;
+       private TextEditor sourceEditor;
+
+       private String fileName;
+       private String filePath;
+       Cursor waitCursor;
+       
+       private ArrayList <String> projectfilelist;
+       
+       private void initialize(){
+               waitCursor = Display.getCurrent().getSystemCursor(SWT.CURSOR_WAIT);
+               fileName = getEditorInput().getName();
+               filePath = getEditorInput().getToolTipText();
+               projectfilelist = new ArrayList<String>();              
+       }
+       
+       @Override
+       public void init(IEditorSite site, IEditorInput input)
+                       throws PartInitException {
+               super.init(site, input);
+               initialize();
+       }
+
+       @Override
+       public boolean isDirty() {
+               return false;
+       }
+       
+
+       @Override
+       public void createPages() {
+               createMemcheckPage();
+               createSourcePage();
+               updateTitle();
+               
+               try {
+                       loadMemcheckData();
+               } catch (FileNotFoundException e) {
+                       e.printStackTrace();
+               } catch (ParserConfigurationException e) {
+                       e.printStackTrace();
+               } catch (IOException e) {
+                       e.printStackTrace();
+               } catch (CoreException e) {
+                       e.printStackTrace();
+               } catch (SAXException e) {
+                       e.printStackTrace();
+               }
+       }
+       
+       private void createMemcheckPage(){
+               Composite parent = new Composite(getContainer(), SWT.NULL);
+               parent.setLayout(new FillLayout());
+               
+               scrolledComposite = new ScrolledComposite(parent, SWT.V_SCROLL
+                               | SWT.H_SCROLL);
+               scrolledComposite.setLayout(new GridLayout(1, false));
+               scrolledComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+               FormToolkit toolkit = new FormToolkit(scrolledComposite.getDisplay());
+               mainComposite = toolkit.createComposite(scrolledComposite, SWT.BORDER);
+               mainComposite.setLayout(new GridLayout(1, false));
+               mainComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
+               createTitle(mainComposite, toolkit);
+               
+               createMemoryErrorPart(mainComposite, toolkit);
+               createMemoryLeakPart(mainComposite, toolkit);
+               
+               int index = addPage(parent);
+               setPageText(index, "Memcheck");
+       }
+       
+       protected void createTitle(Composite parent, FormToolkit toolkit) {
+               Section section = toolkit.createSection(parent, Section.TITLE_BAR);
+               section.setText("Memory Error and Leak Information");
+               section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               toolkit.createCompositeSeparator(section);
+       }
+
+       protected Section createSection(String title, Composite parent,
+                       FormToolkit toolkit) {
+               Section section = toolkit.createSection(parent, Section.EXPANDED
+                               | Section.TREE_NODE | Section.TITLE_BAR);
+               section.setText(title);
+               section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               return section;
+       }
+
+       protected void createMemoryErrorPart(Composite parent, FormToolkit toolkit) {
+               memoryErrorSection = createSection("Memory Error", parent, toolkit);
+
+               Composite subComposite = toolkit.createComposite(memoryErrorSection);
+               memoryErrorSection.setClient(subComposite);
+               memoryErrorSection.addExpansionListener(new SectionExpansionListener());
+               subComposite.setLayout(new GridLayout(1, false));
+               subComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+               Label label = new Label(subComposite, SWT.NONE);
+               label
+                               .setText("All reads and writes of memory are checked, and calls to malloc/new/free/delete are intercepted");
+
+               createMemoryErrorTree(subComposite);
+       }
+
+       protected void createMemoryErrorTree(Composite parent) {
+               memoryErrorTreeViewer = new TreeViewer(parent, SWT.H_SCROLL);
+               Tree localTree = memoryErrorTreeViewer.getTree();
+               localTree.setHeaderVisible(true);
+               localTree.setLinesVisible(true);
+               localTree.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+               String[] columnNames = new String[] { "Memory error", "Function name",
+                               "Sizes", "Address", "Location", "pid", "tid" };
+               int[] columnWidths = new int[] { 125, 150, 50, 80, 405, 80, 50 };
+               TreeColumn[] memoryErrorTreeColumn = new TreeColumn[columnNames.length];
+
+               for (int cnt = 0; cnt < columnNames.length; cnt++) {
+                       memoryErrorTreeColumn[cnt] = new TreeColumn(memoryErrorTreeViewer
+                                       .getTree(), SWT.LEFT);
+                       memoryErrorTreeColumn[cnt].setText(columnNames[cnt]);
+                       memoryErrorTreeColumn[cnt].setWidth(columnWidths[cnt]);
+                       memoryErrorTreeColumn[cnt]
+                                       .addControlListener(new ControlListener() {
+                                               public void controlMoved(ControlEvent e) {
+
+                                               }
+
+                                               public void controlResized(ControlEvent e) {
+                                                       memoryErrorSection.layout(true);
+                                                       resizeComposite();
+                                               }
+                                       });
+               }
+               memoryErrorTreeViewer.setContentProvider(new TreeContentProvider());
+               memoryErrorTreeViewer.setLabelProvider(new ErrorTreeLabelProvider());
+               memoryErrorTreeViewer.addDoubleClickListener(new DoubleClickListener(
+                               memoryErrorTreeViewer, memoryErrorSection));
+               memoryErrorTreeViewer.addTreeListener(new TreeViewerListener(
+                               memoryErrorTreeViewer, memoryErrorSection));
+       }
+
+       protected void createMemoryLeakPart(Composite parent, FormToolkit toolkit) {
+               memoryLeakSection = createSection("Memory Leak", parent, toolkit);
+               Composite subComposite = toolkit.createComposite(memoryLeakSection);
+               memoryLeakSection.setClient(subComposite);
+               memoryLeakSection.addExpansionListener(new SectionExpansionListener());
+               subComposite.setLayout(new GridLayout(1, false));
+               subComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+               Label label = new Label(subComposite, SWT.NONE);
+               label
+                               .setText("Definitely Lost: The worst outcome is that no pointer to the block can be found.\n"
+                                               + "Possibly Lost: A pointer to the interior of the block is found.");
+
+               createMemoryLeakTree(subComposite);
+       }
+
+       protected void createMemoryLeakTree(Composite parent) {
+               memoryLeakTreeViewer = new TreeViewer(parent, SWT.H_SCROLL);
+               Tree localTree = memoryLeakTreeViewer.getTree();
+               localTree.setHeaderVisible(true);
+               localTree.setLinesVisible(true);
+               localTree.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+               String[] columnNames = new String[] { "Memory leak", "Function name",
+                               "Blocks", "Sizes", "Address", "Location", "pid", "tid" };
+               int[] columnWidths = new int[] { 135, 100, 80, 80, 80, 325, 80, 50 };
+               TreeColumn[] memoryLeakTreeColumn = new TreeColumn[columnNames.length];
+
+               for (int cnt = 0; cnt < columnNames.length; cnt++) {
+                       memoryLeakTreeColumn[cnt] = new TreeColumn(memoryLeakTreeViewer
+                                       .getTree(), SWT.LEFT);
+                       memoryLeakTreeColumn[cnt].setText(columnNames[cnt]);
+                       memoryLeakTreeColumn[cnt].setWidth(columnWidths[cnt]);
+                       memoryLeakTreeColumn[cnt].addControlListener(new ControlListener() {
+                               public void controlMoved(ControlEvent e) {
+                                       return;
+                               }
+
+                               public void controlResized(ControlEvent e) {
+                                       memoryLeakSection.layout(true);
+                                       resizeComposite();
+                               }
+                       });
+               }
+
+               memoryLeakTreeViewer.setContentProvider(new TreeContentProvider());
+               memoryLeakTreeViewer.setLabelProvider(new LeakTreeLabelProvider());
+               memoryLeakTreeViewer.addDoubleClickListener(new DoubleClickListener(
+                               memoryLeakTreeViewer, memoryLeakSection));
+               memoryLeakTreeViewer.addTreeListener(new TreeViewerListener(
+                               memoryLeakTreeViewer, memoryLeakSection));
+       }
+       
+       protected void resizeComposite() {
+               scrolledComposite.setMinSize(mainComposite.computeSize(SWT.DEFAULT,
+                               SWT.DEFAULT));
+       }
+       
+       public void getFilelistInProjects() {   
+               this.projectfilelist.clear();
+               IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
+               for(IProject prj: projects) {
+                       try {
+                               // Skip closed projects.
+                               if(!prj.isOpen()) continue;
+                               IResource[] members = prj.getFolder("src").members();
+
+                               for (IResource r : members) {
+                                       if (r.getType() == IResource.FILE && (r.getFileExtension().equalsIgnoreCase("cpp") || r.getFileExtension().equalsIgnoreCase("c"))) {
+                                               
+                                               this.projectfilelist.add(r.getName());
+                                       }
+                               }
+               
+                       } catch (CoreException e) {
+                               e.printStackTrace();
+                       }
+               }
+       }
+       
+       public void refreshView() {
+               int cnt_defact = 0;
+       
+               int cnt_def = 0;
+               int cnt_def_byte = 0;
+               int cnt_def_block = 0;
+               int cnt_def_defact = 0;
+                       
+               int cnt_poss = 0;
+               int cnt_poss_byte = 0;
+               int cnt_poss_block = 0;
+               int cnt_poss_defact = 0;
+
+               if (errors != null) {
+                       int max = errors.length;
+                       ArrayList<ValgrindError> memoryErrorArray = new ArrayList<ValgrindError>();
+                       ArrayList<ValgrindError> memoryLeakArray = new ArrayList<ValgrindError>();
+                       for (int cnt = 0; cnt < max; cnt++) {
+                               if (errors[cnt].getKind().startsWith("Invalid")) {
+                                       memoryErrorArray.add(errors[cnt]);
+                               } else {
+                                       memoryLeakArray.add(errors[cnt]);
+                               }
+                       }
+                                       
+                       
+                       for (int cnt = 0; cnt < memoryErrorArray.size(); cnt++) {
+                               ValgrindError val_tmp = memoryErrorArray.get(cnt);
+                               for (int i = 0; i < val_tmp.getFrames().size(); i++){
+                                       ValgrindStackFrame obj_frame = val_tmp.getFrames().get(i);
+                                       if(obj_frame.getFile() != null){
+                                               for (int j = 0; j < projectfilelist.size(); j++){
+                                                       if(obj_frame.getFile().compareToIgnoreCase(projectfilelist.get(j)) == 0){
+                                                               cnt_defact++;
+                                                               i = val_tmp.getFrames().size(); // exit condition 
+                                                               break;
+                                                       }       
+                                               }
+                                       }                                       
+                               }                       
+                       }
+                       
+                       
+                       String str_data = "*** Memory Error Summary ***\n\n";
+                       str_data += "[ " + memoryErrorArray.size() + " ] errors \n";
+                       str_data += "\t from [ " + cnt_defact + " ] defect \n";
+                       str_data += "\t from [ " + (memoryErrorArray.size() - cnt_defact) + " ] system library";
+                       memoryErrorSection.setToolTipText(str_data);
+                       
+                               
+                       for (int cnt = 0; cnt < memoryLeakArray.size(); cnt++) {
+                               ValgrindError tmp = memoryLeakArray.get(cnt);
+                               if(tmp.getKind().startsWith("Leak_DefinitelyLost"))
+                               {
+                                       cnt_def++;
+                                       String what = tmp.getWhat();
+                                       int end = what.indexOf(" byte");
+                                       if (what != null && end >= 0){
+                                               String temp_byte = what.substring(0,end);
+                                               try{
+                                                       cnt_def_byte += Integer.valueOf(temp_byte);
+                                               }
+                                               catch(NumberFormatException e){
+                                                       try{
+                                                               temp_byte = temp_byte.replace(",", "");
+                                                               cnt_def_byte += Integer.valueOf(temp_byte);
+                                                       }
+                                                       catch(NumberFormatException e1){
+                                                               temp_byte = temp_byte.substring(0, temp_byte.indexOf(" ("));
+                                                               cnt_def_byte += Integer.valueOf(temp_byte);
+                                                       }
+                                                       
+                                               }
+                                       }
+                                       // block
+                                       int start = what.indexOf(" in ");
+                                       end = what.indexOf(" block");
+                                       if (what != null && start >= 0 && end >= 0){
+                                               String temp_block = what.substring(start + 3, end).trim();
+                                               try{
+                                                       cnt_def_block += Integer.valueOf(temp_block);
+                                               }
+                                               catch(NumberFormatException e){
+                                                       temp_block = temp_block.replace(",", "");
+                                                       cnt_def_block += Integer.valueOf(temp_block);
+                                               }
+                                       }
+                                       
+                                       // defect                       
+                                       for (int i = 0; i < tmp.getFrames().size(); i++){
+                                               ValgrindStackFrame obj_frame = tmp.getFrames().get(i);
+                                               if(obj_frame.getFile() != null){
+                                                       for (int j = 0; j < projectfilelist.size(); j++){
+                                                               if(obj_frame.getFile().compareToIgnoreCase(projectfilelist.get(j)) == 0){
+                                                                       cnt_def_defact++;
+                                                                       i = tmp.getFrames().size(); // exit condition 
+                                                                       break;
+                                                               }       
+                                                       }
+                                               }                                       
+                                       }                       
+                               
+                                       
+                                       
+                               }if(tmp.getKind().startsWith("Leak_PossiblyLost"))
+                               {
+                                       cnt_poss++;
+                                       String what = tmp.getWhat();
+                                       int end = what.indexOf(" byte");
+                                       if (what != null && end >= 0){
+                                               String temp_byte = what.substring(0,end);
+                                               try{
+                                                       cnt_poss_byte += Integer.valueOf(temp_byte);
+                                               }
+                                               catch(NumberFormatException e){
+                                                       temp_byte = temp_byte.replace(",", "");
+                                                       cnt_poss_byte += Integer.valueOf(temp_byte);
+                                                       
+                                               }
+                                       }
+                                       
+                                       // block
+                                       int start = what.indexOf(" in ");
+                                       end = what.indexOf(" block");
+                                       if (what != null && start >= 0 && end >= 0){
+                                               String temp_block = what.substring(start + 3, end).trim();
+                                               try{
+                                                       cnt_poss_block += Integer.valueOf(temp_block);
+                                               }
+                                               catch(NumberFormatException e){
+                                                       temp_block = temp_block.replace(",", "");
+                                                       cnt_poss_block += Integer.valueOf(temp_block);
+                                               }
+                                       }
+                                       
+                                       // defect                       
+                                       for (int i = 0; i < tmp.getFrames().size(); i++){
+                                               ValgrindStackFrame obj_frame = tmp.getFrames().get(i);
+                                               if(obj_frame.getFile() != null){
+                                                       for (int j = 0; j < projectfilelist.size(); j++){
+                                                               if(obj_frame.getFile().compareToIgnoreCase(projectfilelist.get(j)) == 0){
+                                                                       cnt_poss_defact++;
+                                                                       i = tmp.getFrames().size(); // exit condition 
+                                                                       break;
+                                                               }       
+                                                       }
+                                               }                                       
+                                       }                       
+                               }                               
+                       }
+                       
+                       str_data = "*** Memory Leak Summary ***\n\n";
+                       str_data += "[ " + cnt_def + " ] definitely lost: [ " + String.format("%,d", cnt_def_byte) + " ] bytes in [ " + String.format("%,d", cnt_def_block) +" ] blocks.\n";
+                       str_data += "\t from [ " + cnt_def_defact + " ] defect \n";
+                       str_data += "\t from [ " + (cnt_def - cnt_def_defact) + " ] system library\n\n";
+                       str_data += "[ " + cnt_poss + " ] possibly lost: [ " + String.format("%,d", cnt_poss_byte) + " ] bytes in [ " + String.format("%,d", cnt_poss_block) +" ] blocks. \n";
+                       str_data += "\t from [ " + cnt_poss_defact + " ] defect \n";
+                       str_data += "\t from [ " + (cnt_poss - cnt_poss_defact) + " ] system library \n";
+                                               
+                       memoryLeakSection.setToolTipText(str_data);
+                       
+                       RootTreeElement memoryErrorTree = new RootTreeElement(
+                                       memoryErrorArray.toArray(new ValgrindError[memoryErrorArray
+                                                       .size()]));
+                       RootTreeElement memoryLeakTree = new RootTreeElement(
+                                       memoryLeakArray.toArray(new ValgrindError[memoryLeakArray
+                                                       .size()]));
+                       memoryErrorTreeViewer.setInput(memoryErrorTree);
+                       memoryLeakTreeViewer.setInput(memoryLeakTree);
+                       scrolledComposite.setContent(mainComposite);
+                       scrolledComposite.setMinSize(mainComposite.computeSize(SWT.DEFAULT,
+                                       SWT.DEFAULT));
+                       scrolledComposite.setExpandVertical(true);
+                       scrolledComposite.setExpandHorizontal(true);
+               }
+       }
+       
+       protected class SectionExpansionListener implements IExpansionListener {
+               public void expansionStateChanged(ExpansionEvent e) {
+                       resizeComposite();
+               }
+
+               public void expansionStateChanging(ExpansionEvent e) {
+               }
+       }
+
+       protected class ErrorTreeLabelProvider extends LabelProvider implements
+                       ITableLabelProvider {
+               public Image getColumnImage(Object element, int columnIndex) {
+                       if (columnIndex == 0)
+                               return ((ValgrindTreeElement) element).getImage();
+                       else
+                               return null;
+               }
+
+               public String getColumnText(Object element, int columnIndex) {
+                       if (element instanceof ErrorTreeElement) {
+                               ErrorTreeElement treeElement = (ErrorTreeElement) element;
+                               switch (columnIndex) {
+                               case 0:
+                                       return treeElement.getKind().replaceFirst("Invalid",
+                                                       "Invalid ");
+                               case 1:
+                                       return treeElement.getFunction();
+                               case 2:
+                                       String what = treeElement.getWhat();
+                                       int start = what.indexOf("size ");
+                                       if (what == null || start < 0)
+                                               return "-";
+                                       else
+                                               return what.substring(start + 5);
+                               case 3:
+                                       return treeElement.getAddress();
+                               case 4:
+                                       return treeElement.getLocation();
+                               case 5:
+                                       return treeElement.getPid();
+                               case 6:
+                                       return treeElement.getTid();
+                               default:
+                                       return null;
+                               }
+                       }
+                       if (element instanceof StackFrameTreeElement) {
+                               ValgrindStackFrame stackElement = ((StackFrameTreeElement) element)
+                                               .getFrame();
+                               switch (columnIndex) {
+                               case 1:
+                                       return stackElement.getFunc();
+                               case 3:
+                                       return stackElement.getPC().toUpperCase().replaceFirst("X",
+                                                       "x");
+                               case 4:
+                                       if (stackElement.getDir() == null
+                                                       || stackElement.getFile() == null)
+                                               //return "***";//stackElement.getObj();
+                                               return stackElement.getObj();
+                                       else
+                                               return stackElement.getFile() + ":"
+                                                               + stackElement.getLine();
+                               default:
+                                       return null;
+                               }
+                       }
+                       if (element instanceof AuxErrorTreeElement) {
+                               AuxErrorTreeElement auxError = (AuxErrorTreeElement) element;
+                               String temp;
+                               switch (columnIndex) {
+                               case 0:
+                                       temp = auxError.getText();
+                                       if (temp.indexOf("size") > 0) {
+                                               String last = temp.substring(temp.indexOf("size") + 5);
+                                               return temp.substring(temp.indexOf("bytes ") + 6, temp
+                                                               .indexOf(" a "))
+                                                               + " "
+                                                               + last.substring(last.indexOf(" ") + 1)
+                                                               + " area";
+                                       } else {
+                                               return temp.substring(temp.indexOf("is") + 3);
+                                       }
+                               case 1:
+                                       return auxError.getFunction();
+                               case 2:
+                                       temp = auxError.getText();
+                                       if (temp.indexOf("size") > 0) {
+                                               String last = temp.substring(temp.indexOf("size") + 5);
+                                               return temp.substring(temp.indexOf("is") + 3, temp
+                                                               .indexOf(" byte"))
+                                                               + "/"
+                                                               + last.substring(0, last.indexOf(" ") - 1);
+                                       }
+                                       return null;
+                               case 3:
+                                       temp = auxError.getText();
+                                       return temp.substring(temp.indexOf("Address") + 8,
+                                                       temp.indexOf(" is")).toUpperCase().replaceFirst(
+                                                       "X", "x");
+                               case 4:
+                                       return auxError.getLocation();
+                               default:
+                                       return null;
+                               }
+                       }
+                       return null;
+               }
+       }
+
+       protected class LeakTreeLabelProvider extends LabelProvider implements
+                       ITableLabelProvider {
+               public Image getColumnImage(Object element, int columnIndex) {
+                       if (columnIndex == 0)
+                               return ((ValgrindTreeElement) element).getImage();
+                       else
+                               return null;
+               }
+
+               public String getColumnText(Object element, int columnIndex) {
+                       if (element instanceof ErrorTreeElement) {
+                               ErrorTreeElement treeElement = (ErrorTreeElement) element;
+                               String what;
+                               int start, end;
+                               switch (columnIndex) {
+                               case 0:
+                                       return treeElement.getKind().replaceFirst("Leak_", "")
+                                                       .replaceAll("Lost", " Lost");
+                               case 1:
+                                       return treeElement.getFunction();
+                               case 2:
+                                       what = treeElement.getWhat();
+                                       start = what.indexOf(" in ");
+                                       end = what.indexOf(" block");
+                                       if (what != null && start >= 0 && end >= 0)
+                                               return what.substring(start + 3, end);
+                                       return null;
+                               case 3:
+                                       what = treeElement.getWhat();
+                                       end = what.indexOf(" byte");
+                                       if (what != null && end >= 0)
+                                               return what.substring(0, end);
+                                       return null;
+                               case 4:
+                                       return treeElement.getAddress();
+                               case 5:
+                                       return treeElement.getLocation();
+                               case 6:
+                                       return treeElement.getPid();
+                               case 7:
+                                       return treeElement.getTid();
+                               default:
+                                       return null;
+                               }
+                       }
+                       if (element instanceof StackFrameTreeElement) {
+                               ValgrindStackFrame stackElement = ((StackFrameTreeElement) element)
+                                               .getFrame();
+                               switch (columnIndex) {
+                               case 1:
+                                       return stackElement.getFunc();
+                               case 4:
+                                       return stackElement.getPC().toUpperCase().replaceFirst("X",
+                                                       "x");
+                               case 5:
+                                       if (stackElement.getDir() == null
+                                                       || stackElement.getFile() == null)
+                                               //return "***";//stackElement.getObj();
+                                               return stackElement.getObj();
+                                       else
+                                               return stackElement.getFile() + ":"
+                                                               + stackElement.getLine();
+                               default:
+                                       return null;
+                               }
+                       }
+                       return null;
+               }
+       }
+
+       protected class TreeContentProvider implements ITreeContentProvider {
+               public Object[] getChildren(Object parentElement) {
+                       return ((ValgrindTreeElement) parentElement).getChildren();
+               }
+
+               public Object getParent(Object element) {
+                       return ((ValgrindTreeElement) element).getParent();
+               }
+
+               public boolean hasChildren(Object element) {
+                       return getChildren(element).length > 0;
+               }
+
+               public Object[] getElements(Object inputElement) {
+                       return getChildren(inputElement);
+               }
+
+               public void dispose() {
+               }
+
+               public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+               }
+       }
+
+       protected class TreeViewerListener implements ITreeViewerListener {
+               protected TreeViewer viewer;
+               protected Section section;
+
+               public TreeViewerListener(TreeViewer input, Section sec) {
+                       viewer = input;
+                       section = sec;
+               }
+
+               public void treeCollapsed(TreeExpansionEvent event) {
+                       section.getClient().getDisplay().asyncExec(new ResizingRunnable());
+               }
+
+               public void treeExpanded(TreeExpansionEvent event) {
+                       section.getClient().getDisplay().asyncExec(new ResizingRunnable());
+               }
+
+               protected class ResizingRunnable implements Runnable {
+                       public void run() {
+                               try {
+                                       while (viewer.isBusy()) {
+                                               Thread.sleep(10);
+                                       }
+                               } catch (InterruptedException e) {
+                                       e.printStackTrace();
+                               }
+                               section.layout(true);
+                               resizeComposite();
+                       }
+               }
+       }
+
+       protected class DoubleClickListener implements IDoubleClickListener {
+               private TreeViewer viewer;
+               private Section section;
+
+               public DoubleClickListener(TreeViewer input, Section sec) {
+                       viewer = input;
+                       section = sec;
+               }
+
+               public void doubleClick(DoubleClickEvent event) {
+                       Object element = ((TreeSelection) event.getSelection())
+                                       .getFirstElement();
+                       if (element instanceof StackFrameTreeElement) {
+                               ValgrindStackFrame frame = ((StackFrameTreeElement) element)
+                                               .getFrame();
+                               if (frame.getFile() != null) {
+                                       String sb_strpath = frame.getDir() + Path.SEPARATOR
+                                                       + frame.getFile();
+                                       //fixed for sb2
+                                       //String strpath = ScratchboxTargetControl.getHostpathFromSboxpath(sb_strpath);
+                                       String strpath = sb_strpath; 
+
+                                       int line = frame.getLine();
+                                       try {
+                                               ProfileUIUtils.openEditorAndSelect(strpath, line);
+                                       } catch (PartInitException e) {
+                                               e.printStackTrace();
+                                       } catch (BadLocationException e) {
+                                               e.printStackTrace();
+                                       }
+                               }
+                       } else {
+                               if (!viewer.isExpandable(element))
+                                       return;
+                               if (viewer.getExpandedState(element)) {
+                                       viewer.collapseToLevel(element, TreeViewer.ALL_LEVELS);
+                               } else {
+                                       viewer.expandToLevel(element, 1);
+                               }
+                               section.layout(true);
+                               resizeComposite();
+                       }
+               }
+       }
+       
+       
+       private void createSourcePage(){
+               try{
+                       sourceEditor = new TextEditor();
+                       int index = addPage(sourceEditor, getEditorInput());
+                       setPageText(index, "Source");
+               }catch(PartInitException e){
+                       e.printStackTrace();
+               }
+       }
+       
+       private void updateTitle(){
+               setPartName(fileName);
+               setTitleToolTip(filePath);
+       }
+
+       private void loadMemcheckData() throws FileNotFoundException, ParserConfigurationException, IOException, CoreException, SAXException{
+               loadData();
+               getFilelistInProjects(); 
+               refreshView();
+       }
+       
+       
+       private void loadData() throws FileNotFoundException, ParserConfigurationException, IOException, CoreException, SAXException {
+               ArrayList<ValgrindError> errorList = new ArrayList<ValgrindError>();
+               ValgrindXMLParser parser;
+               parser = new ValgrindXMLParser(new FileInputStream(this.filePath));
+               errorList.addAll(parser.getErrors());
+       
+               errors = errorList.toArray(new ValgrindError[errorList.size()]);
+               
+       }
+
+       @Override
+       public void doSave(IProgressMonitor monitor) {
+       }
+
+       @Override
+       public void doSaveAs() {
+       }
+
+       @Override
+       public boolean isSaveAsAllowed() {
+               return false;
+       }
+}
diff --git a/org.eclipse.linuxtools.valgrind.ui/.classpath b/org.eclipse.linuxtools.valgrind.ui/.classpath
new file mode 100644 (file)
index 0000000..ad32c83
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+       <classpathentry kind="src" path="src"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.eclipse.linuxtools.valgrind.ui/.project b/org.eclipse.linuxtools.valgrind.ui/.project
new file mode 100644 (file)
index 0000000..cae9d42
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.eclipse.linuxtools.valgrind.ui</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.ManifestBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.SchemaBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.pde.PluginNature</nature>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>
diff --git a/org.eclipse.linuxtools.valgrind.ui/.settings/org.eclipse.core.resources.prefs b/org.eclipse.linuxtools.valgrind.ui/.settings/org.eclipse.core.resources.prefs
new file mode 100644 (file)
index 0000000..78fadca
--- /dev/null
@@ -0,0 +1,3 @@
+#Wed Dec 01 09:14:02 CET 2010
+eclipse.preferences.version=1
+encoding/<project>=UTF-8
diff --git a/org.eclipse.linuxtools.valgrind.ui/.settings/org.eclipse.core.runtime.prefs b/org.eclipse.linuxtools.valgrind.ui/.settings/org.eclipse.core.runtime.prefs
new file mode 100644 (file)
index 0000000..5725327
--- /dev/null
@@ -0,0 +1,3 @@
+#Tue Dec 14 16:37:10 CET 2010
+eclipse.preferences.version=1
+line.separator=\n
diff --git a/org.eclipse.linuxtools.valgrind.ui/ChangeLog b/org.eclipse.linuxtools.valgrind.ui/ChangeLog
new file mode 100644 (file)
index 0000000..d935e6b
--- /dev/null
@@ -0,0 +1,4 @@
+2009-01-05  Elliott Baron  <ebaron@redhat.com>
+
+       * META-INF/MANIFEST.MF: Changed version to 0.1.0.
+       * build.properties: Include about.html and icons.
\ No newline at end of file
diff --git a/org.eclipse.linuxtools.valgrind.ui/META-INF/MANIFEST.MF b/org.eclipse.linuxtools.valgrind.ui/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..fc773ed
--- /dev/null
@@ -0,0 +1,14 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Tizen SDK Valgrind UI
+Bundle-SymbolicName: org.eclipse.linuxtools.valgrind.ui;singleton:=true
+Bundle-Version: 1.3.18.qualifier
+Bundle-Activator: org.eclipse.linuxtools.valgrind.ui.ValgrindUIPlugin
+Bundle-Vendor: Eclipse Linux Tools
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.tizen.common
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-ActivationPolicy: lazy
+Export-Package: org.eclipse.linuxtools.valgrind.ui
+Bundle-Localization: plugin
diff --git a/org.eclipse.linuxtools.valgrind.ui/NOTICE b/org.eclipse.linuxtools.valgrind.ui/NOTICE
new file mode 100644 (file)
index 0000000..9e46511
--- /dev/null
@@ -0,0 +1,46 @@
+2010-02-03 SPRC SDK Team <d.kozinski@samsung.com>
+       * plugin.xml : add extension for org.eclipse.ui.perspectiveExtensions
+
+2010-02-10 SPRC SDK Team <d.kozinski@samsung.com>
+       * .classpath : change java runtime environment
+       * org.eclipse.jdt.core.prefs : remove file
+
+2010-03-31 HyungJong, Shin <hj_shin@samsung.com>
+       * valgrind_out.xml : add new file
+       * valgrind_out.xml : remove useless file
+
+2010-04-05 HyungJong, Shin <hj_shin@samsung.com>
+       * MANIFEST.MF : modify some dependency
+       * ValgrindSaveFileHandler.java : bugfix : add the code to check the write permission of folder to save a file adn to set default location to home folder.
+
+2010-04-06 HyungJong, Shin <hj_shin@samsung.com>
+       * ValgrindSaveFileHandler.java : bugfix : for unintentional error message to save a file in syslog, oprofile, valgrind.
+
+2010-11-05 sdk <sdk@sdk-laptop.(none)>
+       * MANIFEST.MF : changed some package name
+       * plugin.xml : changed some package name
+
+2011-07-13 jaewon81.lim <jaewon81.lim@samsung.com>
+       * MANIFEST.MF : modified import package name
+
+2011-08-22 joogwan.kim <joogwan.kim@samsung.com>
+       * MANIFEST.MF : Change plug-in name
+
+2011-08-25 wonhyoung2.park <wonhyoung2.park@samsung.com>
+       * MANIFEST.MF : plugin provider and name modified
+
+2011-09-17 YoonKi Park <yoonki.park@samsung.com>
+       * plugin.xml : change view category name to SLP SDK
+
+2011-11-22 taeyoung2.son <taeyoung2.son@samsung.com>
+       * MANIFEST.MF :  Modify SDK naming from "SLP(or Samsung Linux Platform)" to "Tizen"
+
+2011-11-29 wonhyoung2.park <wonhyoung2.park@samsung.com>
+       * MANIFEST.MF : chagne slp to tizen
+       * plugin.xml : chagne slp to tizen
+
+2011-12-02 taeyoung2.son <taeyoung2.son@samsung.com>
+       * MANIFEST.MF : Delete dependency feature's version value.
+
+2011-12-03 wonhyoung2.park <wonhyoung2.park@samsung.com>
+       * MANIFEST.MF : package instll routine chage
diff --git a/org.eclipse.linuxtools.valgrind.ui/about.html b/org.eclipse.linuxtools.valgrind.ui/about.html
new file mode 100644 (file)
index 0000000..e6a2741
--- /dev/null
@@ -0,0 +1,26 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"><head>
+
+
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>About</title>
+</head><body lang="EN-US">
+<h2>About This Content</h2>
+<p>October 24, 2008</p>        
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in ("Content").  Unless otherwise 
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 ("EPL").  A copy of the EPL is available 
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, "Program" will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is 
+being redistributed by another party ("Redistributor") and different terms and conditions may
+apply to your use of any object code in the Content.  Check the Redistributor's license that was 
+provided with the Content.  If no such license exists, contact the Redistributor.  Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body></html>
\ No newline at end of file
diff --git a/org.eclipse.linuxtools.valgrind.ui/build.properties b/org.eclipse.linuxtools.valgrind.ui/build.properties
new file mode 100644 (file)
index 0000000..6423a8f
--- /dev/null
@@ -0,0 +1,11 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               .,\
+               plugin.xml,\
+               plugin.properties,\
+               about.html,\
+               icons/,\
+               schema/
+javacSource = 1.6
+javacTarget = 1.6
diff --git a/org.eclipse.linuxtools.valgrind.ui/icons/chart.png b/org.eclipse.linuxtools.valgrind.ui/icons/chart.png
new file mode 100644 (file)
index 0000000..d65084d
Binary files /dev/null and b/org.eclipse.linuxtools.valgrind.ui/icons/chart.png differ
diff --git a/org.eclipse.linuxtools.valgrind.ui/icons/dependent.gif b/org.eclipse.linuxtools.valgrind.ui/icons/dependent.gif
new file mode 100644 (file)
index 0000000..122bada
Binary files /dev/null and b/org.eclipse.linuxtools.valgrind.ui/icons/dependent.gif differ
diff --git a/org.eclipse.linuxtools.valgrind.ui/icons/dump.gif b/org.eclipse.linuxtools.valgrind.ui/icons/dump.gif
new file mode 100644 (file)
index 0000000..d5b8001
Binary files /dev/null and b/org.eclipse.linuxtools.valgrind.ui/icons/dump.gif differ
diff --git a/org.eclipse.linuxtools.valgrind.ui/icons/event.gif b/org.eclipse.linuxtools.valgrind.ui/icons/event.gif
new file mode 100644 (file)
index 0000000..c91f254
Binary files /dev/null and b/org.eclipse.linuxtools.valgrind.ui/icons/event.gif differ
diff --git a/org.eclipse.linuxtools.valgrind.ui/icons/image.gif b/org.eclipse.linuxtools.valgrind.ui/icons/image.gif
new file mode 100644 (file)
index 0000000..8aa0162
Binary files /dev/null and b/org.eclipse.linuxtools.valgrind.ui/icons/image.gif differ
diff --git a/org.eclipse.linuxtools.valgrind.ui/icons/open_log.png b/org.eclipse.linuxtools.valgrind.ui/icons/open_log.png
new file mode 100644 (file)
index 0000000..60bf946
Binary files /dev/null and b/org.eclipse.linuxtools.valgrind.ui/icons/open_log.png differ
diff --git a/org.eclipse.linuxtools.valgrind.ui/icons/oprofile_view.png b/org.eclipse.linuxtools.valgrind.ui/icons/oprofile_view.png
new file mode 100644 (file)
index 0000000..4f8488f
Binary files /dev/null and b/org.eclipse.linuxtools.valgrind.ui/icons/oprofile_view.png differ
diff --git a/org.eclipse.linuxtools.valgrind.ui/icons/refresh.gif b/org.eclipse.linuxtools.valgrind.ui/icons/refresh.gif
new file mode 100644 (file)
index 0000000..4f884d7
Binary files /dev/null and b/org.eclipse.linuxtools.valgrind.ui/icons/refresh.gif differ
diff --git a/org.eclipse.linuxtools.valgrind.ui/icons/sample.gif b/org.eclipse.linuxtools.valgrind.ui/icons/sample.gif
new file mode 100644 (file)
index 0000000..061161a
Binary files /dev/null and b/org.eclipse.linuxtools.valgrind.ui/icons/sample.gif differ
diff --git a/org.eclipse.linuxtools.valgrind.ui/icons/save_log.png b/org.eclipse.linuxtools.valgrind.ui/icons/save_log.png
new file mode 100644 (file)
index 0000000..5950473
Binary files /dev/null and b/org.eclipse.linuxtools.valgrind.ui/icons/save_log.png differ
diff --git a/org.eclipse.linuxtools.valgrind.ui/icons/session.gif b/org.eclipse.linuxtools.valgrind.ui/icons/session.gif
new file mode 100644 (file)
index 0000000..c2b41bd
Binary files /dev/null and b/org.eclipse.linuxtools.valgrind.ui/icons/session.gif differ
diff --git a/org.eclipse.linuxtools.valgrind.ui/icons/symbol.gif b/org.eclipse.linuxtools.valgrind.ui/icons/symbol.gif
new file mode 100644 (file)
index 0000000..6ae4604
Binary files /dev/null and b/org.eclipse.linuxtools.valgrind.ui/icons/symbol.gif differ
diff --git a/org.eclipse.linuxtools.valgrind.ui/icons/valgrind-icon.png b/org.eclipse.linuxtools.valgrind.ui/icons/valgrind-icon.png
new file mode 100644 (file)
index 0000000..dc1dede
Binary files /dev/null and b/org.eclipse.linuxtools.valgrind.ui/icons/valgrind-icon.png differ
diff --git a/org.eclipse.linuxtools.valgrind.ui/icons/valgrind-icon.png.1 b/org.eclipse.linuxtools.valgrind.ui/icons/valgrind-icon.png.1
new file mode 100644 (file)
index 0000000..099bbda
Binary files /dev/null and b/org.eclipse.linuxtools.valgrind.ui/icons/valgrind-icon.png.1 differ
diff --git a/org.eclipse.linuxtools.valgrind.ui/plugin.properties b/org.eclipse.linuxtools.valgrind.ui/plugin.properties
new file mode 100644 (file)
index 0000000..c867e80
--- /dev/null
@@ -0,0 +1,5 @@
+#Properties file for org.eclipse.linuxtools.valgrind.ui
+view.name.0 = Valgrind
+Bundle-Vendor.0 = Eclipse.org
+Bundle-Name.0 = Valgrind UI Plug-in (Incubation)
+extension-point.name.0 = valgrindToolViews
\ No newline at end of file
diff --git a/org.eclipse.linuxtools.valgrind.ui/plugin.xml b/org.eclipse.linuxtools.valgrind.ui/plugin.xml
new file mode 100644 (file)
index 0000000..7459a8f
--- /dev/null
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+   <extension-point id="org.eclipse.linuxtools.valgrind.ui.valgrindToolViews" name="%extension-point.name.0" schema="schema/org.eclipse.linuxtools.valgrind.ui.valgrindToolViews.exsd"/>
+   <extension
+         point="org.eclipse.ui.views">
+      <view
+            allowMultiple="false"
+            category="org.tizen.nativeapp.viewCategory"
+            class="org.eclipse.linuxtools.valgrind.ui.ValgrindViewPart"
+            icon="icons/valgrind-icon.png"
+            id="org.eclipse.linuxtools.valgrind.ui.valgrindview"
+            name="%view.name.0"
+            restorable="true">
+      </view>
+   </extension>
+   <extension
+         point="org.eclipse.ui.menus">
+      <menuContribution
+            locationURI="toolbar:org.eclipse.linuxtools.valgrind.ui.valgrindview">
+         <separator
+               name="toolbarLocal"
+               visible="false">
+         </separator>
+      </menuContribution>
+      <menuContribution
+            locationURI="toolbar:org.eclipse.linuxtools.valgrind.ui.valgrindview?after=toolbarLocal">
+         <separator
+               name="toolbarExtensions"
+               visible="false">
+         </separator>
+      </menuContribution>
+      <menuContribution
+            locationURI="toolbar:org.eclipse.linuxtools.valgrind.ui.valgrindview?after=additions">
+         <command
+               commandId="org.tizen.valgrind.command.saveFile"
+               icon="icons/save_log.png"
+               tooltip="Save file">
+            <parameter
+                  name="org.tizen.valgrind.command.saveFile.parameter"
+                  value="memcheck">
+            </parameter>
+         </command>
+         <command
+               commandId="org.tizen.common.command.openFile"
+               icon="icons/open_log.png"
+               tooltip="Open file">
+            <parameter
+                  name="org.tizen.common.command.openFile.parameter"
+                  value="*">
+            </parameter>
+         </command>
+      </menuContribution>
+   </extension>
+   <extension
+         point="org.eclipse.ui.handlers">
+      <handler
+            class="org.tizen.valgrind.ui.handler.ValgrindSaveFileHandler"
+            commandId="org.tizen.valgrind.command.saveFile">
+      </handler>
+   </extension>
+   <extension
+         point="org.eclipse.ui.commands">
+      <category
+            description="Commands related to the Valgrind"
+            id="org.tizen.valgrind.ui.command.category"
+            name="Valgrind">
+      </category>
+      <command
+            categoryId="org.tizen.valgrind.ui.command.category"
+            description="Save"
+            id="org.tizen.valgrind.command.saveFile"
+            name="Save">
+         <commandParameter
+               id="org.tizen.valgrind.command.saveFile.parameter"
+               name="Extension"
+               optional="false">
+         </commandParameter>
+      </command>
+   </extension>
+   <extension
+         point="org.eclipse.ui.perspectiveExtensions">
+      <perspectiveExtension
+            targetID="org.tizen.nativeapp.perspective">
+         <viewShortcut
+               id="org.eclipse.linuxtools.valgrind.ui.valgrindview">
+         </viewShortcut>
+      </perspectiveExtension>
+   </extension>
+</plugin>
diff --git a/org.eclipse.linuxtools.valgrind.ui/schema/org.eclipse.linuxtools.valgrind.ui.valgrindToolViews.exsd b/org.eclipse.linuxtools.valgrind.ui/schema/org.eclipse.linuxtools.valgrind.ui.valgrindToolViews.exsd
new file mode 100644 (file)
index 0000000..78387c4
--- /dev/null
@@ -0,0 +1,112 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.linuxtools.valgrind.ui" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+      <appinfo>
+         <meta.schema plugin="org.eclipse.linuxtools.valgrind.ui" id="org.eclipse.linuxtools.valgrind.ui.valgrindToolViews" name="valgrindToolViews"/>
+      </appinfo>
+      <documentation>
+         This extension point provides an interface for creating the controls within the Valgrind &lt;code&gt;IViewPart&lt;/code&gt;.
+      </documentation>
+   </annotation>
+
+   <element name="extension">
+      <annotation>
+         <appinfo>
+            <meta.element />
+         </appinfo>
+      </annotation>
+      <complexType>
+         <sequence minOccurs="1" maxOccurs="unbounded">
+            <element ref="view"/>
+         </sequence>
+         <attribute name="point" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="id" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appinfo>
+                  <meta.attribute translatable="true"/>
+               </appinfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <element name="view">
+      <complexType>
+         <attribute name="definitionId" type="string" use="required">
+            <annotation>
+               <documentation>
+                  The &lt;code&gt;id&lt;/code&gt; of the extender of &lt;code&gt;org.eclipse.linuxtools.valgrind.launch.valgrindTools&lt;/code&gt; for which this extension provides UI
+               </documentation>
+               <appinfo>
+                  <meta.attribute kind="identifier" basedOn="org.eclipse.linuxtools.valgrind.launch.valgrindTools/tool/@id"/>
+               </appinfo>
+            </annotation>
+         </attribute>
+         <attribute name="class" type="string" use="required">
+            <annotation>
+               <documentation>
+                  The class that creates controls for the Valgrind &lt;code&gt;IViewPart&lt;/code&gt;
+               </documentation>
+               <appinfo>
+                  <meta.attribute kind="java" basedOn=":org.eclipse.linuxtools.valgrind.ui.IValgrindToolView"/>
+               </appinfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="since"/>
+      </appinfo>
+      <documentation>
+         [Enter the first release in which this extension point appears.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="examples"/>
+      </appinfo>
+      <documentation>
+         [Enter extension point usage example here.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="apiinfo"/>
+      </appinfo>
+      <documentation>
+         [Enter API information here.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="implementation"/>
+      </appinfo>
+      <documentation>
+         [Enter information about supplied implementation of this extension point.]
+      </documentation>
+   </annotation>
+
+
+</schema>
diff --git a/org.eclipse.linuxtools.valgrind.ui/src/org/eclipse/linuxtools/valgrind/ui/IValgrindToolView.java b/org.eclipse.linuxtools.valgrind.ui/src/org/eclipse/linuxtools/valgrind/ui/IValgrindToolView.java
new file mode 100644 (file)
index 0000000..bf82163
--- /dev/null
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Elliott Baron <ebaron@redhat.com> - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.valgrind.ui;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.ui.IViewPart;
+
+/**
+ * Provides an interface for including controls in the Valgrind view.
+ */
+public interface IValgrindToolView extends IViewPart {
+       
+       /**
+        * Provides a mechanism to add actions to the Valgrind view's toolbar
+        * @return an array of actions to add to the toolbar
+        */
+       public IAction[] getToolbarActions();
+       
+       /**
+        * Refreshes the controls within this view
+        */
+       public void refreshView();
+
+}
diff --git a/org.eclipse.linuxtools.valgrind.ui/src/org/eclipse/linuxtools/valgrind/ui/Messages.java b/org.eclipse.linuxtools.valgrind.ui/src/org/eclipse/linuxtools/valgrind/ui/Messages.java
new file mode 100644 (file)
index 0000000..2e8c1c1
--- /dev/null
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Elliott Baron <ebaron@redhat.com> - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.valgrind.ui;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class Messages {
+       private static final String BUNDLE_NAME = "org.eclipse.linuxtools.valgrind.ui.messages"; //$NON-NLS-1$
+
+       private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
+                       .getBundle(BUNDLE_NAME);
+
+       private Messages() {
+       }
+
+       public static String getString(String key) {
+               try {
+                       return RESOURCE_BUNDLE.getString(key);
+               } catch (MissingResourceException e) {
+                       return '!' + key + '!';
+               }
+       }
+}
diff --git a/org.eclipse.linuxtools.valgrind.ui/src/org/eclipse/linuxtools/valgrind/ui/ValgrindUIPlugin.java b/org.eclipse.linuxtools.valgrind.ui/src/org/eclipse/linuxtools/valgrind/ui/ValgrindUIPlugin.java
new file mode 100644 (file)
index 0000000..a2328c8
--- /dev/null
@@ -0,0 +1,166 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Elliott Baron <ebaron@redhat.com> - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.valgrind.ui;
+
+import java.util.HashMap;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+public class ValgrindUIPlugin extends AbstractUIPlugin {
+
+       // The plug-in ID
+       public static final String PLUGIN_ID = "org.eclipse.linuxtools.valgrind.ui"; //$NON-NLS-1$
+       public static final String VIEW_ID = PLUGIN_ID + ".valgrindview"; //$NON-NLS-1$
+       public static final String TOOLBAR_LOC_GROUP_ID = "toolbarLocal"; //$NON-NLS-1$
+       public static final String TOOLBAR_EXT_GROUP_ID = "toolbarExtensions"; //$NON-NLS-1$
+       
+       // Extension point constants
+       public static final String TOOL_EXT_ID = "valgrindToolViews"; //$NON-NLS-1$
+
+       protected static final String EXT_ELEMENT = "view"; //$NON-NLS-1$
+       protected static final String EXT_ATTR_ID = "definitionId"; //$NON-NLS-1$
+       protected static final String EXT_ATTR_CLASS = "class"; //$NON-NLS-1$
+
+       protected HashMap<String, IConfigurationElement> toolMap; 
+
+       // The shared instance
+       private static ValgrindUIPlugin plugin;
+
+       protected ValgrindViewPart view;
+
+       /**
+        * The constructor
+        */
+       public ValgrindUIPlugin() {
+       }
+
+       /*
+        * (non-Javadoc)
+        * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+        */
+       public void start(BundleContext context) throws Exception {
+               super.start(context);
+               plugin = this;
+       }
+
+       /*
+        * (non-Javadoc)
+        * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+        */
+       public void stop(BundleContext context) throws Exception {
+               plugin = null;
+               super.stop(context);
+       }
+
+       /**
+        * Returns the shared instance
+        *
+        * @return the shared instance
+        */
+       public static ValgrindUIPlugin getDefault() {
+               return plugin;
+       }
+
+       public void createView(final String contentDescription, final String toolID) {
+               Display.getDefault().syncExec(new Runnable() {
+                       public void run() {
+                               try {
+                                       IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+                                       activePage.showView(ValgrindUIPlugin.VIEW_ID);
+
+                                       // create the view's tool specific controls and populate content description
+                                       view.createDynamicContent(contentDescription, toolID);
+
+                                       view.refreshView();
+                               } catch (PartInitException e) {
+                                       e.printStackTrace();
+                               } catch (CoreException e) {
+                                       e.printStackTrace();
+                               }
+                       }                                       
+               });
+       }
+
+       public void refreshView() {
+               if (view != null) {
+                       Display.getDefault().syncExec(new Runnable() {
+                               public void run() {
+                                       view.refreshView();
+                               }                               
+                       });
+               }
+       }
+
+       protected void setView(ValgrindViewPart view) {
+               this.view = view;
+       }
+
+       public ValgrindViewPart getView() {
+               return view;
+       }
+
+       public static Shell getActiveWorkbenchShell() {
+               IWorkbenchWindow window = getDefault().getWorkbench().getActiveWorkbenchWindow();
+               if (window != null) {
+                       return window.getShell();
+               }
+               return null;
+       }
+
+       protected void initializeToolMap() {
+               toolMap = new HashMap<String, IConfigurationElement>();
+               IExtensionPoint extPoint = Platform.getExtensionRegistry().getExtensionPoint(PLUGIN_ID, TOOL_EXT_ID);
+               IConfigurationElement[] configs = extPoint.getConfigurationElements();
+               for (IConfigurationElement config : configs) {
+                       if (config.getName().equals(EXT_ELEMENT)) {
+                               String id = config.getAttribute(EXT_ATTR_ID);
+                               if (id != null && config.getAttribute(EXT_ATTR_CLASS) != null) {
+                                       toolMap.put(id, config);
+                               }
+                       }
+               }
+       }
+
+       protected HashMap<String, IConfigurationElement> getToolMap() {
+               if (toolMap == null) {
+                       initializeToolMap();
+               }
+               return toolMap;
+       }
+
+       public IValgrindToolView getToolView(String id) throws CoreException {
+               IValgrindToolView view = null;
+               IConfigurationElement config = getToolMap().get(id);
+               if (config != null) {
+                       Object obj = config.createExecutableExtension(EXT_ATTR_CLASS);
+                       if (obj instanceof IValgrindToolView) {
+                               view = (IValgrindToolView) obj;
+                       }
+               }
+               if (view == null) {
+                       throw new CoreException(new Status(IStatus.ERROR, PLUGIN_ID, Messages.getString("ValgrindUIPlugin.Cannot_retrieve_view"))); //$NON-NLS-1$
+               }
+               return view;
+       }
+}
diff --git a/org.eclipse.linuxtools.valgrind.ui/src/org/eclipse/linuxtools/valgrind/ui/ValgrindViewPart.java b/org.eclipse.linuxtools.valgrind.ui/src/org/eclipse/linuxtools/valgrind/ui/ValgrindViewPart.java
new file mode 100644 (file)
index 0000000..09f9c63
--- /dev/null
@@ -0,0 +1,101 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Elliott Baron <ebaron@redhat.com> - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.linuxtools.valgrind.ui;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.action.ActionContributionItem;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.part.ViewPart;
+
+public class ValgrindViewPart extends ViewPart {
+
+       protected Composite dynamicViewHolder;
+       protected IValgrindToolView dynamicView;
+       protected ActionContributionItem[] dynamicActions;
+
+       @Override
+       public void createPartControl(Composite parent) {
+
+               setContentDescription(Messages.getString("ValgrindViewPart.No_Valgrind_output")); //$NON-NLS-1$
+
+               dynamicViewHolder = new Composite(parent, SWT.NONE);
+               dynamicViewHolder.setLayout(new GridLayout());
+               dynamicViewHolder.setLayoutData(new GridData(GridData.FILL_BOTH));
+               ValgrindUIPlugin.getDefault().setView(this);
+       }
+
+       public IValgrindToolView createDynamicContent(String description, String toolID) throws CoreException {
+               setContentDescription(description);
+
+               // remove tool specific toolbar controls
+               IToolBarManager toolbar = getViewSite().getActionBars().getToolBarManager();
+               if (dynamicActions != null) {
+                       for (ActionContributionItem item : dynamicActions) {
+                               toolbar.remove(item);
+                       }
+               }
+
+               // remove old view controls
+               for (Control child : dynamicViewHolder.getChildren()) {
+                       child.dispose();
+               }
+               dynamicView = ValgrindUIPlugin.getDefault().getToolView(toolID);
+               dynamicView.createPartControl(dynamicViewHolder);
+
+               // create toolbar items
+               IAction[] actions = dynamicView.getToolbarActions();
+               if (actions != null) {
+                       dynamicActions = new ActionContributionItem[actions.length];
+                       for (int i = 0; i < actions.length; i++) {
+                               dynamicActions[i] = new ActionContributionItem(actions[i]);
+                               toolbar.appendToGroup(ValgrindUIPlugin.TOOLBAR_LOC_GROUP_ID, dynamicActions[i]);
+//                             toolbar.add(dynamicActions[i]);
+                       }
+               }
+               toolbar.update(true);
+               
+               dynamicViewHolder.layout(true);
+
+               return dynamicView;
+       }
+
+       @Override
+       public void setFocus() {
+               if (dynamicView != null) {
+                       dynamicView.setFocus();
+               }
+       }
+
+       public void refreshView() {
+               if (dynamicView != null) {
+                       dynamicView.refreshView();
+               }
+       }
+
+       @Override
+       public void dispose() {
+               if (dynamicView != null) {
+                       dynamicView.dispose();
+               }
+               super.dispose();
+       }
+
+       public IValgrindToolView getDynamicView() {
+               return dynamicView;
+       }
+
+}
diff --git a/org.eclipse.linuxtools.valgrind.ui/src/org/eclipse/linuxtools/valgrind/ui/messages.properties b/org.eclipse.linuxtools.valgrind.ui/src/org/eclipse/linuxtools/valgrind/ui/messages.properties
new file mode 100644 (file)
index 0000000..6c5b13b
--- /dev/null
@@ -0,0 +1,3 @@
+ValgrindUIPlugin.Cannot_retrieve_view=Cannot retrieve view from extension
+ValgrindViewPart.No_Valgrind_output=No Valgrind output to display at this time.
+ValgrindViewPart.Select_a_recent_launch=Select a recent launch
diff --git a/org.eclipse.linuxtools.valgrind.ui/src/org/tizen/valgrind/ui/handler/ValgrindRefreshViewHandler.java b/org.eclipse.linuxtools.valgrind.ui/src/org/tizen/valgrind/ui/handler/ValgrindRefreshViewHandler.java
new file mode 100644 (file)
index 0000000..611ec71
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ *  Valgrind Refresh View Handler
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Jaewon Lim <jaewon81.lim@samsung.com>
+ * Wonhyoung Park <wonhyoung2.park@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.valgrind.ui.handler;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.linuxtools.valgrind.ui.*;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+public class ValgrindRefreshViewHandler extends AbstractHandler {
+       private IViewPart part;
+//     private Shell shell;
+
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+
+               setPart((IViewPart) HandlerUtil.getActivePart(event));
+               
+               refreshView();
+               return null;
+       }
+
+       private void refreshView() {
+               ValgrindUIPlugin.getDefault().refreshView();
+       }
+
+       public void setPart(IViewPart part) {
+               this.part = part;
+       }
+
+       public IViewPart getPart() {
+               return part;
+       }
+}
diff --git a/org.eclipse.linuxtools.valgrind.ui/src/org/tizen/valgrind/ui/handler/ValgrindSaveFileHandler.java b/org.eclipse.linuxtools.valgrind.ui/src/org/tizen/valgrind/ui/handler/ValgrindSaveFileHandler.java
new file mode 100644 (file)
index 0000000..c6eeb1d
--- /dev/null
@@ -0,0 +1,184 @@
+/*
+ * Valgrind Save File Handler 
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Jaewon Lim <jaewon81.lim@samsung.com>
+ * Wonhyoung Park <wonhyoung2.park@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.valgrind.ui.handler;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.linuxtools.valgrind.ui.ValgrindUIPlugin;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+import org.tizen.common.core.application.StatusLineMessageManager;
+import org.tizen.common.util.DialogUtil;
+
+public class ValgrindSaveFileHandler extends AbstractHandler {
+       private IViewPart part;
+       private TreeViewer viewer;
+       private String fileName;
+       private Shell shell;
+       private StatusLineMessageManager statusLine;
+       
+       private final String title = "Save File";
+
+       
+
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+
+               part = (IViewPart)HandlerUtil.getActivePart(event);
+               shell = part.getSite().getShell();
+               setStatusLine(new StatusLineMessageManager(part));
+               
+               setViewer((TreeViewer)part.getSite().getSelectionProvider());
+               //uiModel = (UiModelRoot)viewer.getInput();
+               
+       //      String extension = event.getParameter(PARAMETER_ID); bery 20090723
+               String extension ="";
+               
+               if(this.part.getTitle().contains("memcheck")){
+                               extension = "memcheck";
+                               }else if(this.part.getTitle().contains("massif")){
+                                       extension = "massif";
+                               }
+               
+               try {
+                       saveFile(extension);
+               } catch (InvocationTargetException e) {
+                       e.printStackTrace();
+               } catch (InterruptedException e) {
+                       e.printStackTrace();
+               }
+
+               return null;
+       }
+
+       private void saveFile(String extension) throws InvocationTargetException, InterruptedException {
+               fileName = getSaveFileName(extension);
+               
+               if(fileName==null)
+                       return;
+               
+               if(!fileName.endsWith("."+extension))
+                       fileName= fileName+"."+extension;
+               
+               if(!(new File(fileName).getParentFile().canWrite())){
+                       DialogUtil.openErrorDialog("You can store a file into the direcotry that has write permission. please select another directory");
+                       return;
+               }
+               
+               part.getSite().getWorkbenchWindow().run(false, false, new IRunnableWithProgress(){
+                       public void run(IProgressMonitor monitor) {
+                               monitor.beginTask("Save File", 100);
+                               writeData();
+                               monitor.done();
+                       }
+               });
+               
+       }
+
+       private String getSaveFileName(String extension) {
+               String[] extFilter = {"*."+extension,"*.*"};
+               
+               FileDialog dialog = new FileDialog(shell, SWT.SAVE);
+               dialog.setFilterExtensions(extFilter);
+               dialog.setText(title);
+               dialog.setOverwrite(true);
+               dialog.setFileName("untitled."+extension);
+               dialog.setFilterPath(System.getProperty("user.home"));
+               return dialog.open();
+       }
+                       
+       private void writeData() {
+               FileWriter writer = null;
+               
+               try {
+                       
+               writer = new FileWriter(fileName);
+               String outputxml=" ";
+
+//             String ValgrindHostdir = ValgrindUIPlugin.getDefault().getStateLocation().append("Valgrind_XML").toOSString();
+               String ValgrindHostdir = ValgrindUIPlugin.getDefault().getStateLocation().toOSString();
+               if(this.part.getTitle().contains("memcheck")) {
+                       outputxml =ValgrindHostdir+File.separator+"valgrind_out.xml";
+               } else if(this.part.getTitle().contains("massif")) {
+                       outputxml =ValgrindHostdir+File.separator+"massif_000.txt";
+               }
+                                               
+           File inputFile = new File(outputxml);
+           File outputFile = new File(fileName);
+
+           FileReader in = new FileReader(inputFile);
+           FileWriter out = new FileWriter(outputFile);
+           int c;
+
+           while ((c = in.read()) != -1)
+             out.write(c);
+
+           in.close();
+           out.close();
+
+               }catch (FileNotFoundException e) {
+                       e.printStackTrace();
+               }catch (IllegalStateException e) {
+                       e.printStackTrace();
+               }catch (IOException e) {
+                       e.printStackTrace();
+               }finally{
+                       try {
+                               if (writer != null)
+                                       writer.close();
+                       } catch (IOException e) {
+                               e.printStackTrace();
+                       }
+               }
+       }
+
+       public void setStatusLine(StatusLineMessageManager statusLine) {
+               this.statusLine = statusLine;
+       }
+
+       public StatusLineMessageManager getStatusLine() {
+               return statusLine;
+       }
+
+       public void setViewer(TreeViewer viewer) {
+               this.viewer = viewer;
+       }
+
+       public TreeViewer getViewer() {
+               return viewer;
+       }
+       
+}
+
diff --git a/org.tizen.profiler.branding/.project b/org.tizen.profiler.branding/.project
new file mode 100644 (file)
index 0000000..a53f985
--- /dev/null
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.tizen.profiler.branding</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.pde.ManifestBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.SchemaBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.pde.PluginNature</nature>
+       </natures>
+</projectDescription>
diff --git a/org.tizen.profiler.branding/32_TIZEN_SDK_icon.png b/org.tizen.profiler.branding/32_TIZEN_SDK_icon.png
new file mode 100644 (file)
index 0000000..e511542
Binary files /dev/null and b/org.tizen.profiler.branding/32_TIZEN_SDK_icon.png differ
diff --git a/org.tizen.profiler.branding/META-INF/MANIFEST.MF b/org.tizen.profiler.branding/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..daabb9d
--- /dev/null
@@ -0,0 +1,6 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Tizen SDK Profiling Tools
+Bundle-SymbolicName: org.tizen.profiler.branding
+Bundle-Version: 1.0.0.qualifier
+Bundle-Vendor: The Linux Foundation
diff --git a/org.tizen.profiler.branding/about.ini b/org.tizen.profiler.branding/about.ini
new file mode 100644 (file)
index 0000000..fc8fa16
--- /dev/null
@@ -0,0 +1,32 @@
+# about.ini
+# contains information about a feature
+# java.io.Properties file (ISO 8859-1 with "\" escapes)
+# "%key" are externalized strings defined in about.properties
+# This file does not need to be translated.
+
+# Property "aboutText" contains blurb for "About" dialog (translated)
+aboutText=%blurb
+
+# Property "windowImage" contains path to window icon (16x16)
+# needed for primary features only
+
+# Property "featureImage" contains path to feature image (32x32)
+featureImage=32_TIZEN_SDK_icon.png
+
+# Property "aboutImage" contains path to product image (500x330 or 115x164)
+# needed for primary features only
+
+# Property "appName" contains name of the application (translated)
+# needed for primary features only
+
+# Property "welcomePage" contains path to welcome page (special XML-based format)
+# welcomePage=$nl$/welcome.xml
+
+# Property "welcomePerspective" contains the id of the perspective in which the
+# welcome page is to be opened.
+# optional
+
+# Property "tipsAndTricksHref" contains the Help topic href to a tips and tricks page 
+# optional
+# tipsAndTricksHref=/org.tizen.doc.user/tips/tizen_tips.htm
+
diff --git a/org.tizen.profiler.branding/about.mappings b/org.tizen.profiler.branding/about.mappings
new file mode 100644 (file)
index 0000000..bd5dc17
--- /dev/null
@@ -0,0 +1,6 @@
+# about.mappings
+# contains fill-ins for about.properties and bundle.properties
+# java.io.Properties file (ISO 8859-1 with "\" escapes)
+# This file does not need to be translated.
+0=Tzen SDK Profiling Tools
+1=date-time
diff --git a/org.tizen.profiler.branding/about.properties b/org.tizen.profiler.branding/about.properties
new file mode 100644 (file)
index 0000000..5c2e80a
--- /dev/null
@@ -0,0 +1,12 @@
+# about.properties
+# contains externalized strings for about.ini
+# java.io.Properties file (ISO 8859-1 with "\" escapes)
+# fill-ins are supplied by about.mappings
+# This file should be translated.
+
+blurb={0}\n\
+\n\
+Version : {featureVersion}\n\
+Build id : {1}\n\
+\n\
+Visit https://developer.tizen.org \n
\ No newline at end of file
diff --git a/org.tizen.profiler.branding/build.properties b/org.tizen.profiler.branding/build.properties
new file mode 100644 (file)
index 0000000..3672726
--- /dev/null
@@ -0,0 +1,5 @@
+bin.includes = META-INF/,\
+               about.ini,\
+               about.mappings,\
+               about.properties,\
+               32_TIZEN_SDK_icon.png
diff --git a/org.tizen.profiler.feature/.project b/org.tizen.profiler.feature/.project
new file mode 100644 (file)
index 0000000..c9afae3
--- /dev/null
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.tizen.profiler.feature</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.pde.FeatureBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.pde.FeatureNature</nature>
+       </natures>
+</projectDescription>
diff --git a/org.tizen.profiler.feature/build.properties b/org.tizen.profiler.feature/build.properties
new file mode 100644 (file)
index 0000000..740a2ac
--- /dev/null
@@ -0,0 +1,2 @@
+bin.includes = feature.properties,\
+               feature.xml
diff --git a/org.tizen.profiler.feature/feature.properties b/org.tizen.profiler.feature/feature.properties
new file mode 100644 (file)
index 0000000..5245f71
--- /dev/null
@@ -0,0 +1,53 @@
+###############################################################################
+# Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd.
+# All rights reserved. This program and the accompanying materials 
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+# 
+# Contributors:
+#      S-Core Co., Ltd
+###############################################################################
+# feature.properties
+# contains externalized strings for feature.xml
+# "%foo" in feature.xml corresponds to the key "foo" in this file
+# java.io.Properties file (ISO 8859-1 with "\" escapes)
+# This file should be translated.
+
+# "featureName" property - name of the feature
+featureName=Tizen Profiler
+
+# "providerName" property - name of the company that provides the feature
+providerName=The Linux Foundation
+
+# "updateSiteName" property - label for the update site
+updateSiteName=Tizen Profiler Updates
+
+# "description" property - description of the feature
+description=Tizen SDK's Profiler.
+
+# "copyright" property
+copyrightURL=https://developer.tizen.org
+copyright=Copyright (C) 2010 - 2011 Samsung Electronics Co., Ltd.\n\
+All rights reserved.\n
+
+# "licenseURL" property - URL of the "Feature License"
+# do not translate value - just change to point to a locale-specific HTML page
+licenseURL=license.html
+
+# "license" property - text of the "Feature Update License"
+# should be plain text version of license agreement pointed to be "licenseURL"
+license=\
+Tizen SDK\n\
+\n\
+Tizen SDK contains software portions licensed under various open source licenses as well as proprietary components.  All open source software portions ("Open Source Software") are licensed under the open source licenses that accompany such Open Source Software.\n\
+\n\
+The licenses governing the Open Source Software are available at: https://developer.tizen.org/tizen-sdk-opensource-license\n\
+ \n\
+Except for the Open Source Software and proprietary components contributed from companies other than Samsung, contained in Tizen SDK, all other software portions contained in Tizen SDK are governed by the terms and conditions of the Samsung Tizen SDK License Agreement, available at: https://developer.tizen.org/tizen-sdk-license\n\
+\n\
+The licenses of all proprietary components contributed from companies other than Samsung will be either displayed as part of their respective installers or accessed inside installation package archive of each component.\n\
+\n\
+You may access and download Tizen SDK Open Source Software at: http://developer.tizen.org/download/tizenopensdk.tar.gz\n\
+BY CLICKING THE "I AGREE" BUTTON OR BY USING ANY PART OF TIZEN SDK, YOU AGREE (ON BEHALF OF YOURSELF AND/OR YOUR COMPANY) TO THE OPEN SOURCE SOFTWARE LICENSE TERMS, THE SAMSUNG TIZEN SDK LICENSE AGREEMENT AND THE LICENSES OF ALL PROPRIETARY COMPONENTS CONTRIBUTED FROM COMPANIES OTHER THAN SAMSUNG. If you do not agree with the Open Source Software license terms or the SAMSUNG TIZEN SDK LICENSE AGREEMENT or THE LICENSES OF ALL PROPRIETARY COMPONENTS CONTRIBUTED FROM COMPANIES OTHER THAN SAMSUNG, you may not download or use Tizen SDK.\n
+########### end of license property ##########################################
diff --git a/org.tizen.profiler.feature/feature.xml b/org.tizen.profiler.feature/feature.xml
new file mode 100644 (file)
index 0000000..487c78b
--- /dev/null
@@ -0,0 +1,169 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<feature
+      id="org.tizen.profiler.feature"
+      label="%featureName"
+      version="1.0.0.qualifier"
+      provider-name="%providerName"
+      plugin="org.tizen.profiler.branding"
+      license-feature="org.tizen.base.feature">
+
+   <description>
+      %description
+   </description>
+
+   <copyright>
+      %copyright
+   </copyright>
+
+   <license url="license.html">
+Tizen SDK
+
+Tizen SDK contains software portions licensed under various open source licenses as well as proprietary components.  All open source software portions ("Open Source Software") are licensed under the open source licenses that accompany such Open Source Software.
+
+The licenses governing the Open Source Software are available at: https://developer.tizen.org/tizen-sdk-opensource-license
+\
+Except for the Open Source Software and proprietary components contributed from companies other than Samsung, contained in Tizen SDK, all other software portions contained in Tizen SDK are governed by the terms and conditions of the Samsung Tizen SDK License Agreement, available at: https://developer.tizen.org/tizen-sdk-license
+
+The licenses of all proprietary components contributed from companies other than Samsung will be either displayed as part of their respective installers or accessed inside installation package archive of each component.
+
+You may access and download Tizen SDK Open Source Software at: http://developer.tizen.org/download/tizenopensdk.tar.gz
+BY CLICKING THE "I AGREE" BUTTON OR BY USING ANY PART OF TIZEN SDK, YOU AGREE (ON BEHALF OF YOURSELF AND/OR YOUR COMPANY) TO THE OPEN SOURCE SOFTWARE LICENSE TERMS, THE SAMSUNG TIZEN SDK LICENSE AGREEMENT AND THE LICENSES OF ALL PROPRIETARY COMPONENTS CONTRIBUTED FROM COMPANIES OTHER THAN SAMSUNG. If you do not agree with the Open Source Software license terms or the SAMSUNG TIZEN SDK LICENSE AGREEMENT or THE LICENSES OF ALL PROPRIETARY COMPONENTS CONTRIBUTED FROM COMPANIES OTHER THAN SAMSUNG, you may not download or use Tizen SDK.
+   </license>
+
+   <includes
+         id="org.eclipse.birt.chart"
+         version="0.0.0"/>
+
+   <plugin
+         id="org.eclipse.linuxtools.oprofile.core"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.linuxtools.oprofile.launch"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.linuxtools.oprofile.launch.exe"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.linuxtools.oprofile.ui"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.linuxtools.profiling.launch"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.linuxtools.profiling.ui"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.linuxtools.valgrind.core"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.linuxtools.valgrind.launch"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.linuxtools.valgrind.launch.exe"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.linuxtools.valgrind.massif"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.linuxtools.valgrind.memcheck"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.linuxtools.valgrind.ui"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.mozilla.javascript"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.birt.chart.engine"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.birt.core"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.emf.ecore"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.emf.ecore.xmi"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.emf.common"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.tizen.profiler.branding"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"/>
+
+</feature>
diff --git a/org.tizen.profiler.feature/license.html b/org.tizen.profiler.feature/license.html
new file mode 100644 (file)
index 0000000..0793aa8
--- /dev/null
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
+<title>Tizen SOFTWARE DEVELOPMENT KIT (&quot;SDK&quot;) LICENSE AGREEMENT</title>
+</head>
+
+<body lang="EN-US">
+               <p align="center">Tizen SDK</p><br /><br />
+
+Tizen SDK contains software portions licensed under various open source licenses as well as proprietary components.  All open source software portions ("Open Source Software") are licensed under the open source
+licenses that accompany such Open Source Software.<br/><br/>
+
+The licenses governing the Open Source Software are available at:<br />
+<a href="https://developer.tizen.org/tizen-sdk-opensource-license">https://developer.tizen.org/tizen-sdk-opensource-license</a><br /><br />
+Except for the Open Source Software and proprietary components contributed from companies other than Samsung, contained in Tizen SDK, all other software portions contained in Tizen SDK are governed by the
+terms and conditions of the Samsung Tizen SDK License Agreement, available at:<br />
+<a href="https://developer.tizen.org/tizen-sdk-license">https://developer.tizen.org/tizen-sdk-license</a><br /><br />
+
+The licenses of all proprietary components contributed from companies other than Samsung will be either displayed as part of their respective installers or accessed inside installation package archive of each
+component.
+
+You may access and download Tizen SDK Open Source Software at:<br />
+<a href="http://developer.tizen.org/download/tizenopensdk.tar.gz">http://developer.tizen.org/download/tizenopensdk.tar.gz</a><br /><br />
+BY CLICKING THE "I AGREE" BUTTON OR BY USING ANY PART OF TIZEN SDK, YOU AGREE (ON BEHALF OF YOURSELF AND/OR YOUR COMPANY) TO THE OPEN SOURCE SOFTWARE LICENSE TERMS, THE SAMSUNG TIZEN SDK LICENSE AGREEMENT AND THE LICENSES OF ALL PROPRIETARY COMPONENTS CONTRIBUTED FROM COMPANIES OTHER THAN SAMSUNG. If you do not agree with the Open Source Software license terms or the SAMSUNG TIZEN SDK LICENSE AGREEMENT or THE LICENSES OF ALL PROPRIETARY COMPONENTS CONTRIBUTED FROM COMPANIES OTHER THAN SAMSUNG, you may not download or use Tizen SDK.
diff --git a/package/build.linux b/package/build.linux
new file mode 100644 (file)
index 0000000..7bca81c
--- /dev/null
@@ -0,0 +1,73 @@
+#!/bin/bash -xe
+
+__copy_necessary_binaries()
+{
+       echo "add necessary files"
+
+#      builder_data_path="${SRCDIR}/builder/metadata/data"
+#      cp -rf ${builder_data_path}/* ${INSTALL_DIR}/
+}
+
+__set_parameter()
+{
+       echo "TARGET OS : ${TARGET_OS}"
+       build_script_path=${ROOTDIR}/pde-build
+}
+
+# clean
+clean()
+{
+       echo "=========================================CLEAN============================================"
+       __set_parameter
+       ${build_script_path}/clean.sh ${package_name}
+}
+
+# build
+build() 
+{
+       echo "=========================================BUILD============================================"
+       pkgname_and_platform_list=`awk 'BEGIN{RS="\n\n"; FS="\n"} /Package:/{for(i=1;i<NF;i++){if($i ~ /^OS:/){print $1,$i}}}' ${SRCDIR}/package/pkginfo.manifest | tr ' ' '@'`
+       for pkgname_and_platform in ${pkgname_and_platform_list}
+       do
+               pkgname_and_platform=`echo $pkgname_and_platform | tr '@' ' '`
+               package_name=`echo ${pkgname_and_platform} | cut -f1 -d " " | cut -f2 -d ":"`
+               platform=`echo ${pkgname_and_platform} | cut -f2 -d " " | cut -f2 -d ":"`
+       
+               if [ "x${TARGET_OS}" = "x${platform}" ]
+               then
+                       __set_parameter
+                       ${build_script_path}/build.sh ${package_name}
+               else
+                       echo ""
+               fi
+       done
+}
+
+# install
+install() 
+{
+       pkgname_and_platform_list=`awk 'BEGIN{RS="\n\n"; FS="\n"} /Package:/{for(i=1;i<NF;i++){if($i ~ /^OS:/){print $1,$i}}}' ${SRCDIR}/package/pkginfo.manifest | tr ' ' '@'`
+       for pkgname_and_platform in ${pkgname_and_platform_list}
+       do
+               echo "=========================================INSTALL============================================"
+               pkgname_and_platform=`echo $pkgname_and_platform | tr '@' ' '`
+               package_name=`echo ${pkgname_and_platform} | cut -f1 -d " " | cut -f2 -d ":"`
+               platform=`echo ${pkgname_and_platform} | cut -f2 -d " " | cut -f2 -d ":"`
+
+               if [ "x${TARGET_OS}" = "x${platform}" ]
+               then
+                       __set_parameter
+                       INSTALL_DIR=${SRCDIR}/package/${package_name}.package.${TARGET_OS}/data
+                       mkdir -p ${INSTALL_DIR}
+                       __copy_necessary_binaries
+                       ${build_script_path}/install.sh ${package_name}
+               else
+                       echo ""
+               fi
+       done    
+}
+
+[ "$1" = "clean" ] && clean
+[ "$1" = "build" ] && build
+[ "$1" = "install" ] && install
+exit 0
diff --git a/package/changelog b/package/changelog
new file mode 100644 (file)
index 0000000..2fdd86a
--- /dev/null
@@ -0,0 +1,18 @@
+* 0.2.26
+- modify for sonar
+== Jaewon Lim <jaewon81.lim@samsung.com> 2013-01-28 17:55
+* 0.2.24
+- modify for sonar
+== j0.kim <j0.kim@samsung.com> 2013-01-03 16:35
+* 0.2.23
+- change account information (developer -> app)
+== j0.kim <j0.kim@samsung.com> 2012-12-28 19:05
+* 0.2.22
+- add org.tizen.sdblib dependency
+== j0.kim <j0.kim@samsung.com> 2012-11-28 15:49
+* 0.2.21
+- bug fix for nullpointer exception when launch oprofile and valgrind
+== j0.kim <j0.kim@samsung.com> 2012-11-13 20:35
+* 0.2.20
+- add branding plugin
+== j0.kim <j0.kim@samsung.com> 2012-11-05 14:33
diff --git a/package/pkginfo.manifest b/package/pkginfo.manifest
new file mode 100644 (file)
index 0000000..ecbab8d
--- /dev/null
@@ -0,0 +1,38 @@
+Source:profiler-eplugin
+Version:0.2.26
+Maintainer:Jaewon Lim <jaewon81.lim@samsung.com>, Juyoung Kim
+
+Package:profiler-eplugin
+OS:ubuntu-32
+Build-host-os:ubuntu-32
+Description:Profiler plugin
+Install-dependency:base-ide-product [ubuntu-32], common-eplugin [ubuntu-32], nativecommon-eplugin [ubuntu-32]
+Build-dependency:pde-build [ubuntu-32], common-eplugin [ubuntu-32], nativecpp-eplugin [ubuntu-32], nativecommon-eplugin [ubuntu-32]
+
+Package:profiler-eplugin
+OS:windows-32
+Build-host-os:ubuntu-32
+Description:Profiler plugin
+Install-dependency:base-ide-product [windows-32], common-eplugin [windows-32], nativecommon-eplugin [windows-32]
+Build-dependency:pde-build [windows-32], common-eplugin [windows-32], nativecpp-eplugin [windows-32], nativecommon-eplugin [windows-32]
+
+Package:profiler-eplugin
+OS:ubuntu-64
+Build-host-os:ubuntu-64
+Description:Profiler plugin
+Install-dependency:base-ide-product [ubuntu-64], common-eplugin [ubuntu-64], nativecommon-eplugin [ubuntu-64]
+Build-dependency:pde-build [ubuntu-64], common-eplugin [ubuntu-64], nativecpp-eplugin [ubuntu-64], nativecommon-eplugin [ubuntu-64]
+
+Package:profiler-eplugin
+OS:windows-64
+Build-host-os:ubuntu-64
+Description:Profiler plugin
+Install-dependency:base-ide-product [windows-64], common-eplugin [windows-64], nativecommon-eplugin [windows-64]
+Build-dependency:pde-build [windows-64], common-eplugin [windows-64], nativecpp-eplugin [windows-64], nativecommon-eplugin [windows-64]
+
+Package:profiler-eplugin
+OS:macos-64
+Build-host-os:ubuntu-64
+Description:Profiler plugin
+Install-dependency:base-ide-product [macos-64], common-eplugin [macos-64], nativecommon-eplugin [macos-64]
+Build-dependency:pde-build [macos-64], common-eplugin [macos-64], nativecpp-eplugin [macos-64], nativecommon-eplugin [macos-64]