26 import java.net.URL; |
26 import java.net.URL; |
27 import java.nio.channels.FileChannel; |
27 import java.nio.channels.FileChannel; |
28 import java.util.AbstractList; |
28 import java.util.AbstractList; |
29 import java.util.ArrayList; |
29 import java.util.ArrayList; |
30 import java.util.Iterator; |
30 import java.util.Iterator; |
|
31 import java.util.List; |
31 |
32 |
32 import org.eclipse.cdt.core.model.ICModelMarker; |
33 import org.eclipse.cdt.core.model.ICModelMarker; |
33 import org.eclipse.core.resources.IMarker; |
34 import org.eclipse.core.resources.IMarker; |
34 import org.eclipse.core.resources.IProject; |
35 import org.eclipse.core.resources.IProject; |
35 import org.eclipse.core.resources.IResource; |
36 import org.eclipse.core.resources.IResource; |
42 import org.eclipse.core.runtime.IStatus; |
43 import org.eclipse.core.runtime.IStatus; |
43 import org.eclipse.core.runtime.Path; |
44 import org.eclipse.core.runtime.Path; |
44 import org.eclipse.core.runtime.Platform; |
45 import org.eclipse.core.runtime.Platform; |
45 import org.eclipse.core.runtime.Status; |
46 import org.eclipse.core.runtime.Status; |
46 import org.eclipse.core.runtime.jobs.Job; |
47 import org.eclipse.core.runtime.jobs.Job; |
|
48 import org.eclipse.jface.dialogs.Dialog; |
47 import org.eclipse.jface.dialogs.MessageDialog; |
49 import org.eclipse.jface.dialogs.MessageDialog; |
48 import org.eclipse.jface.preference.IPreferenceStore; |
50 import org.eclipse.jface.preference.IPreferenceStore; |
|
51 import org.eclipse.jface.resource.JFaceResources; |
49 import org.eclipse.jface.viewers.ArrayContentProvider; |
52 import org.eclipse.jface.viewers.ArrayContentProvider; |
50 import org.eclipse.jface.viewers.LabelProvider; |
53 import org.eclipse.jface.viewers.LabelProvider; |
51 import org.eclipse.swt.SWT; |
54 import org.eclipse.swt.SWT; |
|
55 import org.eclipse.swt.events.DisposeEvent; |
|
56 import org.eclipse.swt.events.DisposeListener; |
|
57 import org.eclipse.swt.events.SelectionAdapter; |
|
58 import org.eclipse.swt.events.SelectionEvent; |
|
59 import org.eclipse.swt.graphics.Cursor; |
|
60 import org.eclipse.swt.layout.GridData; |
|
61 import org.eclipse.swt.layout.GridLayout; |
|
62 import org.eclipse.swt.widgets.Composite; |
52 import org.eclipse.swt.widgets.FileDialog; |
63 import org.eclipse.swt.widgets.FileDialog; |
53 import org.eclipse.swt.widgets.Shell; |
64 import org.eclipse.swt.widgets.Shell; |
|
65 import org.eclipse.swt.widgets.ToolBar; |
|
66 import org.eclipse.swt.widgets.ToolItem; |
54 import org.eclipse.ui.IWorkbenchPage; |
67 import org.eclipse.ui.IWorkbenchPage; |
55 import org.eclipse.ui.IWorkbenchPart; |
68 import org.eclipse.ui.IWorkbenchPart; |
56 import org.eclipse.ui.PlatformUI; |
69 import org.eclipse.ui.PlatformUI; |
57 import org.eclipse.ui.dialogs.ListDialog; |
70 import org.eclipse.ui.dialogs.ListDialog; |
58 import org.osgi.framework.Bundle; |
71 import org.osgi.framework.Bundle; |
68 import com.nokia.carbide.cpp.epoc.engine.MMPDataRunnableAdapter; |
81 import com.nokia.carbide.cpp.epoc.engine.MMPDataRunnableAdapter; |
69 import com.nokia.carbide.cpp.epoc.engine.model.mmp.EMMPStatement; |
82 import com.nokia.carbide.cpp.epoc.engine.model.mmp.EMMPStatement; |
70 import com.nokia.carbide.cpp.epoc.engine.model.mmp.IMMPData; |
83 import com.nokia.carbide.cpp.epoc.engine.model.mmp.IMMPData; |
71 import com.nokia.carbide.cpp.epoc.engine.preprocessor.AcceptedNodesViewFilter; |
84 import com.nokia.carbide.cpp.epoc.engine.preprocessor.AcceptedNodesViewFilter; |
72 import com.nokia.s60tools.analyzetool.Activator; |
85 import com.nokia.s60tools.analyzetool.Activator; |
|
86 import com.nokia.s60tools.analyzetool.AnalyzeToolHelpContextIDs; |
73 import com.nokia.s60tools.analyzetool.builder.AnalyzeToolBuilder; |
87 import com.nokia.s60tools.analyzetool.builder.AnalyzeToolBuilder; |
74 import com.nokia.s60tools.analyzetool.engine.MMPInfo; |
88 import com.nokia.s60tools.analyzetool.engine.MMPInfo; |
75 import com.nokia.s60tools.analyzetool.engine.UseAtool; |
89 import com.nokia.s60tools.analyzetool.engine.UseAtool; |
76 import com.nokia.s60tools.analyzetool.global.Constants.COMMAND_LINE_ERROR_CODE; |
90 import com.nokia.s60tools.analyzetool.global.Constants.COMMAND_LINE_ERROR_CODE; |
|
91 import com.nokia.s60tools.analyzetool.ui.CustomMessageDialog; |
|
92 import com.nokia.s60tools.analyzetool.ui.OutputModeDialog; |
77 |
93 |
78 /** |
94 /** |
79 * Provides commonly used functions. |
95 * Provides commonly used functions. |
80 * |
96 * |
81 * @author kihe |
97 * @author kihe |
139 } |
157 } |
140 return false; |
158 return false; |
141 } |
159 } |
142 |
160 |
143 /** |
161 /** |
144 * Checks is AnalyzeTool libraries installed from the current SDK. |
162 * Checks AnalyzeTool libraries from the current SDK. |
145 * |
163 * |
146 * @param cpi |
164 * @param cpi |
147 * {@link ICarbideProjectInfo} reference |
165 * {@link ICarbideProjectInfo} reference |
148 * @return True if libraries are installed otherwise false. |
166 * @return error message or Constants.ATOOL_LIBS_OK if libraries are OK |
149 */ |
167 */ |
150 public static boolean checkAtoolLibs(final ICarbideProjectInfo cpi) { |
168 public static String checkAtoolLibs(final ICarbideProjectInfo cpi) { |
151 // get active platform |
169 // get active platform |
152 String platform = cpi.getDefaultConfiguration().getPlatformString(); |
170 String platform = cpi.getDefaultConfiguration().getPlatformString(); |
153 |
171 |
154 // get epoc root |
172 // get epoc root |
155 IPath epocRootPath = EpocEngineHelper.getEpocRootForProject(cpi |
173 IPath epocRootPath = EpocEngineHelper.getEpocRootForProject(cpi |
156 .getProject()); |
174 .getProject()); |
157 |
175 |
158 // check that epocroot path found |
176 // check that epoc root path was found |
159 if (epocRootPath == null) { |
177 if (epocRootPath == null) { |
160 return false; |
178 return "EPOCROOT directory of the SDK for the active build configuration of the project not found."; |
161 } |
179 } |
162 |
180 |
163 String epocroot = epocRootPath.toOSString(); |
181 String epocroot = epocRootPath.toOSString(); |
164 boolean found = true; |
182 |
165 StringBuffer fileBuffer = new StringBuffer(bufferSize); |
183 List<String> missingAtoolLibsList = new ArrayList<String>(); |
166 fileBuffer.append(Constants.CAN_NOT_FIND_LIBRARIES_MARKER); |
184 |
167 fileBuffer.append(": "); |
|
168 if ((Constants.BUILD_TARGET_WINSCW).equalsIgnoreCase(platform)) { |
185 if ((Constants.BUILD_TARGET_WINSCW).equalsIgnoreCase(platform)) { |
169 for (int i = 0; i < Constants.atoolLibsSbs2.length; i++) { |
186 for (int i = 0; i < Constants.atoolLibsWinscw.length; i++) { |
170 java.io.File file = new java.io.File(epocroot |
187 File file = new File(epocroot + Constants.atoolLibsWinscw[i]); |
171 + Constants.atoolLibsWinscw[i]); |
|
172 if (!file.exists()) { |
188 if (!file.exists()) { |
173 found = false; |
189 missingAtoolLibsList.add(epocroot |
174 fileBuffer.append(epocroot); |
190 + Constants.atoolLibsWinscw[i]); |
175 fileBuffer.append(Constants.atoolLibsWinscw[i]); |
|
176 fileBuffer.append(' '); |
|
177 } |
191 } |
178 } |
192 } |
179 } else if ((Constants.BUILD_TARGET_ARMV5).equalsIgnoreCase(platform)) { |
193 } else if ((Constants.BUILD_TARGET_ARMV5).equalsIgnoreCase(platform)) { |
180 if (AnalyzeToolBuilder.isSBSBuildActivated(cpi)) { |
194 if (AnalyzeToolBuilder.isSBSBuildActivated(cpi)) { |
181 for (int i = 0; i < Constants.atoolLibsSbs2.length; i++) { |
195 for (int i = 0; i < Constants.atoolLibsSbs2.length; i++) { |
182 java.io.File file = new java.io.File(epocroot |
196 File file = new File(epocroot + Constants.atoolLibsSbs2[i]); |
183 + Constants.atoolLibsSbs2[i]); |
|
184 if (!file.exists()) { |
197 if (!file.exists()) { |
185 found = false; |
198 missingAtoolLibsList.add(epocroot |
186 fileBuffer.append(epocroot); |
199 + Constants.atoolLibsSbs2[i]); |
187 fileBuffer.append(Constants.atoolLibsSbs2[i]); |
|
188 fileBuffer.append(' '); |
|
189 } |
200 } |
190 } |
201 } |
191 } else { |
202 } else { |
192 for (int i = 0; i < Constants.atoolLibs.length; i++) { |
203 for (int i = 0; i < Constants.atoolLibs.length; i++) { |
193 java.io.File file = new java.io.File(epocroot |
204 File file = new File(epocroot + Constants.atoolLibs[i]); |
194 + Constants.atoolLibs[i]); |
|
195 if (!file.exists()) { |
205 if (!file.exists()) { |
196 found = false; |
206 missingAtoolLibsList.add(epocroot |
197 fileBuffer.append(epocroot); |
207 + Constants.atoolLibs[i]); |
198 fileBuffer.append(Constants.atoolLibs[i]); |
|
199 fileBuffer.append(' '); |
|
200 } |
208 } |
201 } |
209 } |
202 } |
210 } |
203 } |
211 } |
204 if (!found) { |
212 |
205 createErrorMarker(cpi.getProject(), fileBuffer.toString()); |
213 if (missingAtoolLibsList.size() > 0) { |
206 } |
214 StringBuffer fileBuffer = new StringBuffer(bufferSize); |
207 |
215 |
208 return found; |
216 fileBuffer.append(Constants.CAN_NOT_FIND_LIBRARIES_MARKER); |
|
217 fileBuffer.append("\n\n"); |
|
218 |
|
219 for (String string : missingAtoolLibsList) { |
|
220 fileBuffer.append(string); |
|
221 fileBuffer.append("\n"); |
|
222 } |
|
223 |
|
224 fileBuffer.append("\n"); |
|
225 fileBuffer.append(Constants.CAN_NOT_FIND_LIBRARIES_SUPPORT); |
|
226 |
|
227 return fileBuffer.toString(); |
|
228 } |
|
229 |
|
230 return Constants.ATOOL_LIBS_OK; |
209 } |
231 } |
210 |
232 |
211 /** |
233 /** |
212 * Copies stored memory leak analysis file to given folder. |
234 * Copies stored memory leak analysis file to given folder. |
213 * |
235 * |
396 atoolInstallFolder.append(getDefaultAtoolLocation()); |
417 atoolInstallFolder.append(getDefaultAtoolLocation()); |
397 } else if (("").equals(folder)) { |
418 } else if (("").equals(folder)) { |
398 store.setValue(Constants.USE_INTERNAL, true); |
419 store.setValue(Constants.USE_INTERNAL, true); |
399 atoolInstallFolder.append(getDefaultAtoolLocation()); |
420 atoolInstallFolder.append(getDefaultAtoolLocation()); |
400 } else if (folder.equals(Constants.DEFAULT_ATOOL_FOLDER)) { |
421 } else if (folder.equals(Constants.DEFAULT_ATOOL_FOLDER)) { |
401 java.io.File file = new java.io.File(Constants.DEFAULT_ATOOL_FOLDER); |
422 File file = new File(Constants.DEFAULT_ATOOL_FOLDER); |
402 if (file.exists()) { |
423 if (file.exists()) { |
403 atoolInstallFolder.append(Constants.DEFAULT_ATOOL_FOLDER); |
424 atoolInstallFolder.append(Constants.DEFAULT_ATOOL_FOLDER); |
404 } else { |
425 } else { |
405 store.setValue(Constants.USE_INTERNAL, true); |
426 store.setValue(Constants.USE_INTERNAL, true); |
406 atoolInstallFolder.append(getDefaultAtoolLocation()); |
427 atoolInstallFolder.append(getDefaultAtoolLocation()); |
656 } |
677 } |
657 |
678 |
658 return infDir + "\\atool_temp\\"; |
679 return infDir + "\\atool_temp\\"; |
659 } |
680 } |
660 |
681 |
|
682 public static ToolBar createHelpControl(Composite parent) { |
|
683 ToolBar toolBar = new ToolBar(parent, SWT.FLAT | SWT.NO_FOCUS); |
|
684 ((GridLayout) parent.getLayout()).numColumns++; |
|
685 toolBar.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER)); |
|
686 final Cursor cursor = new Cursor(parent.getDisplay(), SWT.CURSOR_HAND); |
|
687 toolBar.setCursor(cursor); |
|
688 toolBar.addDisposeListener(new DisposeListener() { |
|
689 public void widgetDisposed(DisposeEvent e) { |
|
690 cursor.dispose(); |
|
691 } |
|
692 }); |
|
693 ToolItem item = new ToolItem(toolBar, SWT.NONE); |
|
694 item.setImage(JFaceResources.getImage(Dialog.DLG_IMG_HELP)); |
|
695 item.setToolTipText(JFaceResources.getString("helpToolTip")); //$NON-NLS-1$ |
|
696 item.addSelectionListener(new SelectionAdapter() { |
|
697 public void widgetSelected(SelectionEvent e) { |
|
698 PlatformUI.getWorkbench().getHelpSystem().displayHelp( |
|
699 AnalyzeToolHelpContextIDs.ANALYZE_TROUBLESHOOTING); |
|
700 } |
|
701 }); |
|
702 return toolBar; |
|
703 } |
|
704 |
661 /** |
705 /** |
662 * Gets cpp file name and path. |
706 * Gets cpp file name and path. |
663 * |
707 * |
664 * @param resource |
708 * @param resource |
665 * One resource file |
709 * One resource file |
1340 .showErrorMessage("Can not analyze. \n\nSelected data file does not contain AnalyzeTool data."); |
1425 .showErrorMessage("Can not analyze. \n\nSelected data file does not contain AnalyzeTool data."); |
1341 Activator.getDefault().logInfo(IStatus.ERROR, IStatus.ERROR, |
1426 Activator.getDefault().logInfo(IStatus.ERROR, IStatus.ERROR, |
1342 "AnalyzeTool - Invalid data file."); |
1427 "AnalyzeTool - Invalid data file."); |
1343 break; |
1428 break; |
1344 |
1429 |
|
1430 case DATA_FILE_OLD_FORMAT: |
|
1431 Util.showMessageDialog(Constants.UNSUPPORTED_FORMAT_TITLE, |
|
1432 Constants.UNSUPPORTED_FORMAT_MESSAGE, SWT.ICON_ERROR); |
|
1433 Activator.getDefault().logInfo(IStatus.ERROR, IStatus.ERROR, |
|
1434 "AnalyzeTool - Unsupported format."); |
|
1435 break; |
|
1436 |
|
1437 case DATA_FILE_UNSUPPORTED_TRACE_FORMAT: |
|
1438 Util.showMessageDialog(Constants.UNSUPPORTED_FORMAT_TITLE, |
|
1439 Constants.TRACE_FORMAT_VERSION_IS_HIGHER, SWT.ICON_ERROR); |
|
1440 Activator.getDefault().logInfo(IStatus.ERROR, IStatus.ERROR, |
|
1441 "AnalyzeTool - Unsupported trace format."); |
|
1442 break; |
|
1443 |
1345 case RELEASABLES_ERROR: |
1444 case RELEASABLES_ERROR: |
1346 Util |
1445 Util |
1347 .showErrorMessage("AnalyzeTool can not copy needed files, therefore callstack can not be displayed when analyzing data." |
1446 .showErrorMessage("AnalyzeTool can not copy needed files, therefore callstack can not be displayed when analyzing data." |
1348 + "\n\nTry to clean AnalyzeTool made changes and build project again."); |
1447 + "\n\nTry to clean AnalyzeTool made changes and build project again."); |
1349 Activator.getDefault().logInfo(IStatus.ERROR, IStatus.ERROR, |
1448 Activator.getDefault().logInfo(IStatus.ERROR, IStatus.ERROR, |