Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Raynaud2013-06-13 11:18:29 +0000
committerXavier Raynaud2013-06-14 07:17:56 +0000
commit0ff3cd546076ba2050fe9233a3eeb32b842c1d7e (patch)
tree23949be86baf45eebb8fd5db1e7e278c7865a824
parentc0baa6628beb9e2e0b76ae5fb800540a97c6b286 (diff)
downloadorg.eclipse.linuxtools-0ff3cd546076ba2050fe9233a3eeb32b842c1d7e.tar.gz
org.eclipse.linuxtools-0ff3cd546076ba2050fe9233a3eeb32b842c1d7e.tar.xz
org.eclipse.linuxtools-0ff3cd546076ba2050fe9233a3eeb32b842c1d7e.zip
Gcov: Fix various warnings
* Externalize strings * Remove unused method. * Remove trailing white space. * Enforce a 'no tabs' policy. Change-Id: I79b3d3556349a8295fcfe4ac0af9d97c66ae9b1f Reviewed-on: https://git.eclipse.org/r/13417 Tested-by: Hudson CI Reviewed-by: Xavier Raynaud <xavier.raynaud@kalray.eu> IP-Clean: Xavier Raynaud <xavier.raynaud@kalray.eu>
-rw-r--r--gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/action/Messages.java28
-rw-r--r--gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/action/OpenGCAction.java89
-rw-r--r--gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/action/messages.properties13
-rw-r--r--gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/dialog/Messages.java39
-rw-r--r--gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/dialog/OpenGCDialog.java197
-rw-r--r--gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/dialog/messages.properties25
-rw-r--r--gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/parser/CovManager.java743
-rw-r--r--gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/parser/GcdaRecordsParser.java529
-rw-r--r--gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/parser/GcnoFunction.java462
-rw-r--r--gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/parser/GcnoRecordsParser.java434
-rw-r--r--gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/parser/Messages.java40
-rw-r--r--gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/parser/messages.properties24
-rw-r--r--gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/utils/GcovStringReader.java37
-rw-r--r--gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/utils/LEDataInputStream.java367
-rw-r--r--gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/utils/Messages.java25
-rw-r--r--gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/utils/STGcovProgramChecker.java111
-rw-r--r--gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/utils/messages.properties11
-rw-r--r--gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/CovView.java424
-rw-r--r--gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/FieldCoveragePercentage.java160
-rw-r--r--gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/FieldExecutedLines.java100
-rw-r--r--gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/FieldInstrumentedLines.java105
-rw-r--r--gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/FieldName.java96
-rw-r--r--gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/FieldTotalLines.java115
-rw-r--r--gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/Messages.java14
-rw-r--r--gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/annotatedsource/CoverageAnnotationColumn.java79
-rw-r--r--gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/annotatedsource/Messages.java29
-rw-r--r--gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/annotatedsource/OpenSourceFileAction.java168
-rw-r--r--gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/annotatedsource/STAnnotatedSourceNotFoundEditor.java50
-rw-r--r--gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/annotatedsource/messages.properties15
-rw-r--r--gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/messages.properties13
30 files changed, 2331 insertions, 2211 deletions
diff --git a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/action/Messages.java b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/action/Messages.java
new file mode 100644
index 0000000000..6c3c50effc
--- /dev/null
+++ b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/action/Messages.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.internal.gcov.action;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.linuxtools.internal.gcov.action.messages"; //$NON-NLS-1$
+ public static String OpenGCAction_gcov_error;
+ public static String OpenGCAction_file_dne_run;
+ public static String OpenGCAction_file_dne_compile;
+
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/action/OpenGCAction.java b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/action/OpenGCAction.java
index 750b2bc258..dbb5db6795 100644
--- a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/action/OpenGCAction.java
+++ b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/action/OpenGCAction.java
@@ -25,64 +25,59 @@ import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.window.Window;
import org.eclipse.linuxtools.internal.gcov.dialog.OpenGCDialog;
import org.eclipse.linuxtools.internal.gcov.view.CovView;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorLauncher;
import org.eclipse.ui.PlatformUI;
-
/**
* Action performed when user clicks on a gcda/gcno file
- *
* @author Xavier Raynaud <xavier.raynaud@st.com>
*/
public class OpenGCAction implements IEditorLauncher {
- @Override
- public void open(IPath file) {
- Shell shell = PlatformUI.getWorkbench().getDisplay().getActiveShell();
- String extension = file.getFileExtension();
- File gcno;
- File gcda;
- if ("gcno".equals(extension)) { //$NON-NLS-1$
- IPath file2 = file.removeFileExtension().addFileExtension("gcda"); //$NON-NLS-1$
- gcno = file.toFile();
- gcda = file2.toFile();
- } else if ("gcda".equals(extension)) { //$NON-NLS-1$
- IPath file2 = file.removeFileExtension().addFileExtension("gcno"); //$NON-NLS-1$
- gcda = file.toFile();
- gcno = file2.toFile();
-
- } else {
- // should never occurs
- return;
- }
+ @Override
+ public void open(IPath file) {
+ Shell shell = PlatformUI.getWorkbench().getDisplay().getActiveShell();
+ String extension = file.getFileExtension();
+ File gcno;
+ File gcda;
+ if ("gcno".equals(extension)) { //$NON-NLS-1$
+ IPath file2 = file.removeFileExtension().addFileExtension("gcda"); //$NON-NLS-1$
+ gcno = file.toFile();
+ gcda = file2.toFile();
+ } else if ("gcda".equals(extension)) { //$NON-NLS-1$
+ IPath file2 = file.removeFileExtension().addFileExtension("gcno"); //$NON-NLS-1$
+ gcda = file.toFile();
+ gcno = file2.toFile();
+ } else {
+ // should never occurs
+ return;
+ }
- if (gcda == null || !gcda.isFile()) {
- String msg = "File " + gcda + " does not exist.";
- msg += "\nPlease run your application at least once.";
- MessageDialog.openError(shell, "gcov Error", msg);
- return;
- }
- if (gcno == null || !gcno.isFile()) {
- String msg = "File " + gcno + " does not exist.";
- msg += "\nPlease recompile your application.";
- MessageDialog.openError(shell, "gcov Error", msg);
- return;
- }
-
+ if (gcda == null || !gcda.isFile()) {
+ String msg = NLS.bind(Messages.OpenGCAction_file_dne_run, gcda);
+ MessageDialog.openError(shell, Messages.OpenGCAction_gcov_error, msg);
+ return;
+ }
+ if (gcno == null || !gcno.isFile()) {
+ String msg = NLS.bind(Messages.OpenGCAction_file_dne_compile, gcno);
+ MessageDialog.openError(shell, Messages.OpenGCAction_gcov_error, msg);
+ return;
+ }
- String s = getDefaultBinary(file);
- OpenGCDialog d = new OpenGCDialog(shell, s, file);
- if (d.open() != Window.OK) {
- return;
- }
- String binaryPath = d.getBinaryFile();
- if (d.isCompleteCoverageResultWanted()) {
- CovView.displayCovResults(binaryPath, gcda.getAbsolutePath());
- } else {
- CovView.displayCovDetailedResult(binaryPath, gcda.getAbsolutePath());
- }
- }
+ String s = getDefaultBinary(file);
+ OpenGCDialog d = new OpenGCDialog(shell, s, file);
+ if (d.open() != Window.OK) {
+ return;
+ }
+ String binaryPath = d.getBinaryFile();
+ if (d.isCompleteCoverageResultWanted()) {
+ CovView.displayCovResults(binaryPath, gcda.getAbsolutePath());
+ } else {
+ CovView.displayCovDetailedResult(binaryPath, gcda.getAbsolutePath());
+ }
+ }
private String getDefaultBinary(IPath file) {
IProject project = null;
@@ -104,5 +99,5 @@ public class OpenGCAction implements IEditorLauncher {
}
}
return ""; //$NON-NLS-1$
- }
+ }
}
diff --git a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/action/messages.properties b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/action/messages.properties
new file mode 100644
index 0000000000..7d55456fda
--- /dev/null
+++ b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/action/messages.properties
@@ -0,0 +1,13 @@
+###############################################################################
+# Copyright (c) 2013 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
+###############################################################################
+OpenGCAction_gcov_error=gcov Error
+OpenGCAction_file_dne_run=File {0} does not exist.\nPlease run your application at least once.
+OpenGCAction_file_dne_compile=File {0} does not exist.\nPlease recompile your application.
diff --git a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/dialog/Messages.java b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/dialog/Messages.java
new file mode 100644
index 0000000000..8b8961aebd
--- /dev/null
+++ b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/dialog/Messages.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.internal.gcov.dialog;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.linuxtools.internal.gcov.dialog.messages"; //$NON-NLS-1$
+ public static String OpenGCDialog_bin_browser_button_text;
+ public static String OpenGCDialog_bin_browser_fs_button_text;
+ public static String OpenGCDialog_bin_browser_handler_text;
+ public static String OpenGCDialog_no_bin_error_label;
+ public static String OpenGCDialog_bin_dne_error_label;
+ public static String OpenGCDialog_bin_group_header;
+ public static String OpenGCDialog_bin_group_label;
+ public static String OpenGCDialog_bin_group_tooltip;
+ public static String OpenGCDialog_coverage_mode_header;
+ public static String OpenGCDialog_coverage_mode_tooltip;
+ public static String OpenGCDialog_invalid_bin_error_title;
+ public static String OpenGCDialog_invalid_bin_error_message;
+ public static String OpenGCDialog_open_results;
+ public static String OpenGCDialog_summ_button_text;
+ public static String OpenGCDialog_open_file_button_text;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/dialog/OpenGCDialog.java b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/dialog/OpenGCDialog.java
index 9b876c6e45..4e4546df68 100644
--- a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/dialog/OpenGCDialog.java
+++ b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/dialog/OpenGCDialog.java
@@ -29,6 +29,7 @@ import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.linuxtools.binutils.utils.STSymbolManager;
import org.eclipse.linuxtools.internal.gcov.Activator;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
@@ -51,133 +52,123 @@ import org.eclipse.ui.model.WorkbenchContentProvider;
import org.eclipse.ui.model.WorkbenchLabelProvider;
import org.eclipse.ui.views.navigator.ResourceComparator;
-
/**
- * This dialog box is opened when user clicks on a gcno/gcda file.
- * it allows the user to choose the binary file who produced the gcno/gcda file.
+ * This dialog box is opened when user clicks on a gcno/gcda file. it allows the user to choose the binary file who
+ * produced the gcno/gcda file.
* @author Xavier Raynaud <xavier.raynaud@st.com>
- *
*/
public class OpenGCDialog extends Dialog {
-
- /* Inputs */
- private Text binText;
+
+ /* Inputs */
+ private Text binText;
private String binValue;
private Button openThisFileOnlyButton;
private Button openCoverageSummaryButton;
private boolean openCoverageSummary = true;
-
+
/* buttons */
private Button binBrowseWorkspaceButton;
private Button binBrowseFileSystemButton;
-
+
/* error label */
private Label errorLabel;
-
+
/* validation boolean */
private boolean binaryValid;
/* internal listener */
private final BinaryModifyListener binModifyListener = new BinaryModifyListener();
-
+
private final String defaultValue;
private final IPath gcFile;
/**
* Constructor
* @param parentShell
- * @param binPath the path to a binary file.
+ * @param binPath
+ * the path to a binary file.
*/
- public OpenGCDialog(Shell parentShell, String binPath, IPath gcFile) {
- super(parentShell);
- this.gcFile = gcFile;
+ public OpenGCDialog(Shell parentShell, String binPath, IPath gcFile) {
+ super(parentShell);
+ this.gcFile = gcFile;
setShellStyle(getShellStyle() | SWT.RESIZE);
this.defaultValue = binPath;
- }
+ }
- /**
+ /**
* Gets the Binary file selected by the user
* @return a path to a binary file
*/
public String getBinaryFile() {
- return binValue;
+ return binValue;
}
-
- /**
+
+ /**
* Gets whether the user wants a complete coverage result, or a result specific file to the given gcFile.
*/
public boolean isCompleteCoverageResultWanted() {
- return openCoverageSummary;
+ return openCoverageSummary;
}
-
@Override
- protected Control createContents(Composite parent) {
+ protected Control createContents(Composite parent) {
Control composite = super.createContents(parent);
validateBinary();
return composite;
}
@Override
- protected Control createDialogArea(Composite parent) {
- this.getShell().setText("Gcov - Open coverage results...");
+ protected Control createDialogArea(Composite parent) {
+ this.getShell().setText(Messages.OpenGCDialog_open_results);
Composite composite = (Composite) super.createDialogArea(parent);
- /* first line */
+ /* first line */
Group c = new Group(composite, SWT.NONE);
- c.setText("Binary File");
- c.setToolTipText("Please enter here the binary file which produced the coverage data.");
- GridLayout layout = new GridLayout(2,false);
+ c.setText(Messages.OpenGCDialog_bin_group_header);
+ c.setToolTipText(Messages.OpenGCDialog_bin_group_tooltip);
+ GridLayout layout = new GridLayout(2, false);
c.setLayout(layout);
GridData data = new GridData(GridData.FILL_BOTH);
c.setLayoutData(data);
-
- Label binLabel = new Label(c,SWT.NONE);
- binLabel.setText("Please enter here the binary file which produced the coverage data.");
+
+ Label binLabel = new Label(c, SWT.NONE);
+ binLabel.setText(Messages.OpenGCDialog_bin_group_label);
data = new GridData();
data.horizontalSpan = 2;
binLabel.setLayoutData(data);
- binText = new Text(c,SWT.BORDER);
+ binText = new Text(c, SWT.BORDER);
binText.setText(this.defaultValue);
data = new GridData(GridData.FILL_HORIZONTAL);
data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
binText.setLayoutData(data);
binText.addModifyListener(binModifyListener);
- Composite cbBin = new Composite(c,SWT.NONE);
+ Composite cbBin = new Composite(c, SWT.NONE);
data = new GridData(GridData.HORIZONTAL_ALIGN_END);
cbBin.setLayoutData(data);
cbBin.setLayout(new GridLayout(2, true));
binBrowseWorkspaceButton = new Button(cbBin, SWT.PUSH);
- binBrowseWorkspaceButton.setText("&Workspace...");
- binBrowseWorkspaceButton.addSelectionListener(
- new SelectionAdapter()
- {
- @Override
- public void widgetSelected(SelectionEvent sev)
- {
- handleBrowseWorkspace("Open Binary file...", binText);
- }
- }
- );
+ binBrowseWorkspaceButton.setText(Messages.OpenGCDialog_bin_browser_button_text);
+ binBrowseWorkspaceButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent sev) {
+ handleBrowseWorkspace(Messages.OpenGCDialog_bin_browser_handler_text, binText);
+ }
+ });
binBrowseFileSystemButton = new Button(cbBin, SWT.PUSH);
- binBrowseFileSystemButton.setText("&File System...");
- binBrowseFileSystemButton.addSelectionListener(
- new SelectionAdapter()
- {
- @Override
- public void widgetSelected(SelectionEvent sev)
- {
- handleBrowse("Open Binary file...", binText);
- }
- }
- );
-
+ binBrowseFileSystemButton.setText(Messages.OpenGCDialog_bin_browser_fs_button_text);
+ binBrowseFileSystemButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent sev) {
+ handleBrowse(Messages.OpenGCDialog_bin_browser_handler_text, binText);
+ }
+ });
+
Group covMode = new Group(composite, SWT.NONE);
- covMode.setText("Coverage result");
- covMode.setToolTipText("Please choose the result scope.");
+ covMode.setText(Messages.OpenGCDialog_coverage_mode_header);
+ covMode.setToolTipText(Messages.OpenGCDialog_coverage_mode_tooltip);
GridData covModeData = new GridData(GridData.FILL_BOTH);
covMode.setLayoutData(covModeData);
covMode.setLayout(new GridLayout());
@@ -185,26 +176,24 @@ public class OpenGCDialog extends Dialog {
openThisFileOnlyButton.setLayoutData(new GridData());
openCoverageSummaryButton = new Button(covMode, SWT.RADIO);
openCoverageSummaryButton.setLayoutData(new GridData());
- String cFile = gcFile.removeFileExtension().lastSegment() + ".c";
-
- openThisFileOnlyButton.setText("Show coverage details for \"" + cFile + "\" only.");
- openCoverageSummaryButton.setText("Show coverage for the whole selected binary file");
-
+ String cFile = gcFile.removeFileExtension().lastSegment() + ".c"; //$NON-NLS-1$
+
+ openThisFileOnlyButton.setText(NLS.bind(Messages.OpenGCDialog_open_file_button_text, cFile));
+ openCoverageSummaryButton.setText(Messages.OpenGCDialog_summ_button_text);
+
openCoverageSummaryButton.setSelection(true);
-
+
SelectionAdapter sa = new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent sev)
- {
- openCoverageSummary = openCoverageSummaryButton.getSelection();
+ @Override
+ public void widgetSelected(SelectionEvent sev) {
+ openCoverageSummary = openCoverageSummaryButton.getSelection();
}
};
openCoverageSummaryButton.addSelectionListener(sa);
openThisFileOnlyButton.addSelectionListener(sa);
-
/* 2sd line */
- errorLabel = new Label(composite,SWT.NONE);
+ errorLabel = new Label(composite, SWT.NONE);
data = new GridData(GridData.FILL_HORIZONTAL);
data.horizontalSpan = 3;
errorLabel.setLayoutData(data);
@@ -219,60 +208,59 @@ public class OpenGCDialog extends Dialog {
binValue = binText.getText();
IStringVariableManager mgr = VariablesPlugin.getDefault().getStringVariableManager();
try {
- binValue = mgr.performStringSubstitution(binValue, false);
+ binValue = mgr.performStringSubstitution(binValue, false);
} catch (CoreException _) {
- // do nothing: never occurs
+ // do nothing: never occurs
}
-
+
File f = new File(binValue);
if (f.exists()) {
- IBinaryObject binary = STSymbolManager.sharedInstance.getBinaryObject(new Path(binValue));
- if (binary == null) {
- MessageDialog.openError(
- PlatformUI.getWorkbench().getDisplay().getActiveShell(),
- "Invalid binary file",
- binText.getText() + " is not a valid binary file.");
- return;
- }
- binaryValid = true;
+ IBinaryObject binary = STSymbolManager.sharedInstance.getBinaryObject(new Path(binValue));
+ if (binary == null) {
+ MessageDialog.openError(PlatformUI.getWorkbench().getDisplay().getActiveShell(),
+ Messages.OpenGCDialog_invalid_bin_error_title,
+ NLS.bind(Messages.OpenGCDialog_invalid_bin_error_message, binText.getText()));
+ return;
+ }
+ binaryValid = true;
getButton(IDialogConstants.OK_ID).setEnabled(binaryValid);
errorLabel.setText(""); //$NON-NLS-1$
} else {
- binaryValid = false;
+ binaryValid = false;
getButton(IDialogConstants.OK_ID).setEnabled(false);
if (!binValue.equals("")) { //$NON-NLS-1$
- errorLabel.setText("\"" + binText.getText() + "\" doesn't exist");
+ errorLabel.setText(NLS.bind(Messages.OpenGCDialog_bin_dne_error_label, binText.getText()));
} else {
- errorLabel.setText("Please enter a binary file");
+ errorLabel.setText(Messages.OpenGCDialog_no_bin_error_label);
}
return;
}
}
- private class BinaryModifyListener implements ModifyListener
- {
+ private class BinaryModifyListener implements ModifyListener {
@Override
- public void modifyText(ModifyEvent e) {
+ public void modifyText(ModifyEvent e) {
validateBinary();
}
}
protected void handleBrowseWorkspace(String msg, Text text) {
- ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(), new WorkbenchContentProvider());
- dialog.setTitle(msg);
- dialog.setMessage(msg);
- dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
+ ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(),
+ new WorkbenchContentProvider());
+ dialog.setTitle(msg);
+ dialog.setMessage(msg);
+ dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
dialog.setAllowMultiple(false);
IContainer c = ResourcesPlugin.getWorkspace().getRoot().getContainerForLocation(this.gcFile);
- if (c != null) dialog.setInitialSelection(c.getProject());
+ if (c != null)
+ dialog.setInitialSelection(c.getProject());
dialog.setValidator(new ISelectionStatusValidator() {
@Override
- public IStatus validate(Object[] selection)
- {
+ public IStatus validate(Object[] selection) {
if (selection.length != 1) {
- return new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, "", null); //$NON-NLS-1$
+ return new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, "", null); //$NON-NLS-1$
}
if (!(selection[0] instanceof IFile)) {
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, "", null); //$NON-NLS-1$
@@ -286,25 +274,24 @@ public class OpenGCDialog extends Dialog {
}
}
-
- protected void handleBrowse(String msg, Text text)
- {
- FileDialog dialog = new FileDialog(this.getShell(),SWT.OPEN);
+ protected void handleBrowse(String msg, Text text) {
+ FileDialog dialog = new FileDialog(this.getShell(), SWT.OPEN);
dialog.setText(msg);
String t = text.getText();
IStringVariableManager mgr = VariablesPlugin.getDefault().getStringVariableManager();
try {
- t = mgr.performStringSubstitution(t, false);
+ t = mgr.performStringSubstitution(t, false);
} catch (CoreException _) {
- // do nothing: never occurs
+ // do nothing: never occurs
}
File f = new File(t);
t = f.getParent();
if (t == null || t.length() == 0) {
- t = this.gcFile.removeLastSegments(1).toOSString();
+ t = this.gcFile.removeLastSegments(1).toOSString();
}
dialog.setFilterPath(t);
String s = dialog.open();
- if (s != null) text.setText(s);
+ if (s != null)
+ text.setText(s);
}
}
diff --git a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/dialog/messages.properties b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/dialog/messages.properties
new file mode 100644
index 0000000000..27aa33fd1b
--- /dev/null
+++ b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/dialog/messages.properties
@@ -0,0 +1,25 @@
+###############################################################################
+# Copyright (c) 2013 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
+###############################################################################
+OpenGCDialog_bin_browser_button_text=&Workspace...
+OpenGCDialog_bin_browser_fs_button_text=&File System...
+OpenGCDialog_bin_browser_handler_text=Open Binary file...
+OpenGCDialog_no_bin_error_label=Please enter a binary file
+OpenGCDialog_bin_dne_error_label={0} does not exist
+OpenGCDialog_bin_group_header=Binary File
+OpenGCDialog_bin_group_label=Please enter here the binary file which produced the coverage data.
+OpenGCDialog_bin_group_tooltip=Please enter here the binary file which produced the coverage data.
+OpenGCDialog_coverage_mode_header=Coverage result
+OpenGCDialog_coverage_mode_tooltip=Please choose the result scope.
+OpenGCDialog_invalid_bin_error_title=Invalid binary file
+OpenGCDialog_invalid_bin_error_message={0} is not a valid binary file.
+OpenGCDialog_open_results=Gcov - Open coverage results...
+OpenGCDialog_summ_button_text=Show coverage for the whole selected binary file
+OpenGCDialog_open_file_button_text=Show coverage details for {0} only.
diff --git a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/parser/CovManager.java b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/parser/CovManager.java
index 760cd293ae..c980f031ff 100644
--- a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/parser/CovManager.java
+++ b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/parser/CovManager.java
@@ -20,7 +20,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
-import java.io.PrintStream;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
@@ -41,6 +40,7 @@ import org.eclipse.linuxtools.internal.gcov.model.CovFileTreeElement;
import org.eclipse.linuxtools.internal.gcov.model.CovFolderTreeElement;
import org.eclipse.linuxtools.internal.gcov.model.CovFunctionTreeElement;
import org.eclipse.linuxtools.internal.gcov.model.CovRootTreeElement;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Shell;
@@ -48,395 +48,366 @@ import org.eclipse.ui.PlatformUI;
/**
* @author Xavier Raynaud <xavier.raynaud@st.com>
- *
*/
public class CovManager implements Serializable {
- /**
+ /**
*
*/
- private static final long serialVersionUID = 5582066617970911413L;
- // input
- private final String binaryPath;
- // results
- private final ArrayList<Folder> allFolders = new ArrayList<Folder>();
- private final ArrayList<SourceFile> allSrcs = new ArrayList<SourceFile>();
- private final ArrayList<GcnoFunction> allFnctns = new ArrayList<GcnoFunction>();
- private final HashMap<String, SourceFile> sourceMap = new HashMap<String, SourceFile>();
- private long nbrPgmRuns = 0;
- // for view
- private CovRootTreeElement rootNode;
- private IProject project;
-
- /**
- * Constructor
- * @param binaryPath
- * @param project the project that will be used to get the path to run commands
- */
- public CovManager(String binaryPath, IProject project) {
- this.binaryPath = binaryPath;
- this.project = project;
- }
-
- /**
- * Constructor
- * @param binaryPath
- */
- public CovManager(String binaryPath) {
- this(binaryPath, null);
- }
-
- /**
- * parse coverage files, execute resolve graph algorithm, process counts for functions,
- * lines and folders.
- * @param List of coverage files paths
- * @throws CoreException, IOException, InterruptedException
- */
+ private static final long serialVersionUID = 5582066617970911413L;
+ // input
+ private final String binaryPath;
+ // results
+ private final ArrayList<Folder> allFolders = new ArrayList<Folder>();
+ private final ArrayList<SourceFile> allSrcs = new ArrayList<SourceFile>();
+ private final ArrayList<GcnoFunction> allFnctns = new ArrayList<GcnoFunction>();
+ private final HashMap<String, SourceFile> sourceMap = new HashMap<String, SourceFile>();
+ private long nbrPgmRuns = 0;
+ // for view
+ private CovRootTreeElement rootNode;
+ private final IProject project;
+
+ /**
+ * Constructor
+ * @param binaryPath
+ * @param project
+ * the project that will be used to get the path to run commands
+ */
+ public CovManager(String binaryPath, IProject project) {
+ this.binaryPath = binaryPath;
+ this.project = project;
+ }
+
+ /**
+ * Constructor
+ * @param binaryPath
+ */
+ public CovManager(String binaryPath) {
+ this(binaryPath, null);
+ }
+
+ /**
+ * parse coverage files, execute resolve graph algorithm, process counts for functions, lines and folders.
+ * @param List
+ * of coverage files paths
+ * @throws CoreException
+ * , IOException, InterruptedException
+ */
+
+ public void processCovFiles(List<String> covFilesPaths, String initialGcda) throws CoreException, IOException {
+ GcdaRecordsParser daRcrd = null;
+ DataInput traceFile;
+
+ Map<File, File> sourcePath = new HashMap<File, File>();
+
+ if (initialGcda != null) {
+ File initialGcdaFile = new File(initialGcda).getAbsoluteFile();
+ for (String s : covFilesPaths) {
+ File gcda = new File(s).getAbsoluteFile();
+ if (gcda.getName().equals(initialGcdaFile.getName()) && !gcda.equals(initialGcdaFile)) {
+ if (!sourcePath.isEmpty()) {
+ // hum... another file has the same name...
+ // sorry, we have to clean sourcePath
+ sourcePath.clear();
+ break;
+ } else {
+ addSourceLookup(sourcePath, initialGcdaFile, gcda);
+ }
+ }
+ }
+ }
+
+ for (String gcdaPath : covFilesPaths) {
+ String gcnoPath = gcdaPath.replace(".gcda", ".gcno"); //$NON-NLS-1$ //$NON-NLS-2$
+ // parse GCNO file
+ traceFile = OpenTraceFileStream(gcnoPath, ".gcno", sourcePath); //$NON-NLS-1$
+ if (traceFile == null)
+ return;
+ GcnoRecordsParser noRcrd = new GcnoRecordsParser(sourceMap, allSrcs);
+ noRcrd.parseData(traceFile);
+
+ // add new functions parsed to AllSrcs array
+ for (GcnoFunction f : noRcrd.getFnctns()) {
+ allFnctns.add(f);
+ }
+
+ // close the input stream
+ if (traceFile.getClass() == DataInputStream.class)
+ ((DataInputStream) traceFile).close();
+
+ // parse GCDA file
+ traceFile = OpenTraceFileStream(gcdaPath, ".gcda", sourcePath); //$NON-NLS-1$
+ if (traceFile == null)
+ return;
+ if (noRcrd.getFnctns().isEmpty()) {
+ String message = NLS.bind(Messages.CovManager_No_Funcs_Error, gcnoPath);
+ Status status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, message);
+ throw new CoreException(status);
+ }
+ daRcrd = new GcdaRecordsParser(noRcrd.getFnctns());
+ daRcrd.parseGcdaRecord(traceFile);
+
+ // close the input stream
+ if (traceFile.getClass() == DataInputStream.class)
+ ((DataInputStream) traceFile).close();
+ }
+
+ // to fill the view title
+ if (daRcrd != null)
+ nbrPgmRuns = daRcrd.getObjSmryNbrPgmRuns();
+ /* process counts from data parsed */
+
+ // solve graph for each function
+ for (GcnoFunction gf : allFnctns) {
+ gf.solveGraphFnctn();
+ }
+
+ // allocate lines
+ for (SourceFile sourceFile : allSrcs) {
+ sourceFile.createLines();
+ }
+
+ // add line counts
+ for (GcnoFunction gf : allFnctns) {
+ gf.addLineCounts(allSrcs);
+ }
+
+ // accumulate lines
+ for (SourceFile sf : allSrcs) {
+ sf.accumulateLineCounts();
+ }
+
+ /* compute counts by folder */
+
+ // make the folders list
+ for (SourceFile sf : allSrcs) {
+ File srcFile = new File(sf.getName());
+ String folderName = srcFile.getParent();
+ if (folderName == null)
+ folderName = "?"; //$NON-NLS-1$
+ Folder folder = null;
+ for (Folder f : allFolders) {
+ if (f.getPath().equals(folderName))
+ folder = f;
+ }
+ if (folder == null) {
+ folder = new Folder(folderName);
+ allFolders.add(folder);
+ }
+ folder.addSrcFiles(sf);
+ }
+
+ // assign sourcesList for each folder
+ for (Folder f : allFolders) {
+ f.accumulateSourcesCounts();
+ }
+ }
+
+ /**
+ * fill the model by count results
+ * @throws CoreException
+ * , IOException, InterruptedException
+ */
+
+ public void fillGcovView() {
+ // process counts for summary level
+ int summaryTotal = 0, summaryInstrumented = 0, summaryExecuted = 0;
+ for (Folder f : allFolders) {
+ summaryTotal += f.getNumLines();
+ summaryInstrumented += f.getLinesInstrumented();
+ summaryExecuted += f.getLinesExecuted();
+ }
+
+ // fill rootNode model: the entry of the contentProvider
+ rootNode = new CovRootTreeElement(Messages.CovManager_Summary, summaryTotal, summaryExecuted,
+ summaryInstrumented);
+ IBinaryObject binaryObject = STSymbolManager.sharedInstance.getBinaryObject(new Path(binaryPath));
+
+ for (Folder fldr : allFolders) {
+ String folderLocation = fldr.getPath();
+ CovFolderTreeElement fldrTreeElem = new CovFolderTreeElement(rootNode, folderLocation, fldr.getNumLines(),
+ fldr.getLinesExecuted(), fldr.getLinesInstrumented());
+ rootNode.addChild(fldrTreeElem);
+
+ for (SourceFile src : fldr.getSrcFiles()) {
+ CovFileTreeElement srcTreeElem = new CovFileTreeElement(fldrTreeElem, src.getName(), src.getNumLines(),
+ src.getLinesExecuted(), src.getLinesInstrumented());
+ fldrTreeElem.addChild(srcTreeElem);
+
+ for (GcnoFunction fnctn : src.getFnctns()) {
+ String name = fnctn.getName();
+ name = STSymbolManager.sharedInstance.demangle(binaryObject, name, project);
+ srcTreeElem.addChild(new CovFunctionTreeElement(srcTreeElem, name, fnctn.getSrcFile(), fnctn
+ .getFirstLineNmbr(), fnctn.getCvrge().getLinesExecuted(), fnctn.getCvrge()
+ .getLinesInstrumented()));
+ }
+ }
+ }
+ }
+
+ // transform String path to stream
+ private DataInput OpenTraceFileStream(String filePath, String extension, Map<File, File> sourcePath)
+ throws FileNotFoundException {
+ File f = new File(filePath).getAbsoluteFile();
+ String filename = f.getName();
+ if (f.isFile() && f.canRead()) {
+ FileInputStream fis = new FileInputStream(f);
+ InputStream inputStream = new BufferedInputStream(fis);
+ return new DataInputStream(inputStream);
+ } else {
+ String postfix = ""; //$NON-NLS-1$
+ File dir = null;
+ do {
+ if ("".equals(postfix))postfix = f.getName(); //$NON-NLS-1$
+ else
+ postfix = f.getName() + File.separator + postfix;
+ f = f.getParentFile();
+ if (f != null) {
+ dir = sourcePath.get(f);
+ } else
+ break;
+ } while (dir == null);
+
+ if (dir != null) {
+ f = new File(dir, postfix);
+ if (f.isFile() && f.canRead()) {
+ return OpenTraceFileStream(f.getAbsolutePath(), extension, sourcePath);
+ }
+ }
+
+ Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
+ FileDialog fg = new FileDialog(shell, SWT.OPEN);
+ fg.setFilterExtensions(new String[] { "*" + extension, "*.*", "*" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ fg.setFileName(filename);
+ fg.setText(NLS.bind(Messages.CovManager_No_FilePath_Error, new Object[] { filePath, filename }));
+ String s = fg.open();
+ if (s == null)
+ return null;
+ else {
+ f = new File(s).getAbsoluteFile();
+ addSourceLookup(sourcePath, f, new File(filePath).getAbsoluteFile());
+ if (f.isFile() && f.canRead()) {
+ FileInputStream fis = new FileInputStream(f);
+ InputStream inputStream = new BufferedInputStream(fis);
+ return new DataInputStream(inputStream);
+ }
+ }
+ }
+ return null;
+ }
+
+ public ArrayList<SourceFile> getAllSrcs() {
+ return allSrcs;
+ }
+
+ public ArrayList<GcnoFunction> getAllFnctns() {
+ return allFnctns;
+ }
+
+ public CovRootTreeElement getRootNode() {
+ return rootNode;
+ }
+
+ public String getBinaryPath() {
+ return binaryPath;
+ }
+
+ public SourceFile getSourceFile(String sourcePath) {
+ return sourceMap.get(sourcePath);
+ }
+
+ public long getNbrPgmRuns() {
+ return nbrPgmRuns;
+ }
+
+ /**
+ * Retrieve a list containing gcda paths from a binary file
+ * @return
+ * @throws InterruptedException
+ */
+ public List<String> getGCDALocations() throws InterruptedException {
+ IBinaryObject binaryObject = STSymbolManager.sharedInstance.getBinaryObject(new Path(binaryPath));
+ String binaryPath = binaryObject.getPath().toOSString();
+ List<String> l = new LinkedList<String>();
+ Process p;
+ p = getStringsProcess(Messages.CovManager_Strings, binaryPath);
+ if (p == null) {
+ Status status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR,
+ Messages.CovManager_Retrieval_Error, new IOException());
+ Activator.getDefault().getLog().log(status);
+ return l;
+ }
+ ThreadConsumer t = new ThreadConsumer(p, l);
+ t.start();
+ p.waitFor();
+ t.join();
+ return l;
+ }
+
+ private Process getStringsProcess(String stringsTool, String binaryPath) {
+ try {
+ Process p = Runtime.getRuntime().exec(new String[] { stringsTool, binaryPath });
+ return p;
+ } catch (Exception _) {
+ return null;
+ }
+ }
+
+ private static final class ThreadConsumer extends Thread {
+ private final Process p;
+ private final List<String> list;
+
+ ThreadConsumer(Process p, List<String> files) {
+ super();
+ this.p = p;
+ this.list = files;
+ }
+
+ @Override
+ public void run() {
+ try {
+ populateGCDAFiles(p.getInputStream());
+ } catch (Exception _) {
+ }
+ }
+
+ private void populateGCDAFiles(InputStream s) throws IOException {
+ InputStreamReader isr = new InputStreamReader(s);
+ LineNumberReader lnr = new LineNumberReader(isr);
+ String line = null;
+ while ((line = lnr.readLine()) != null) {
+ if (line.endsWith(".gcda")) //$NON-NLS-1$
+ {
+ // absolute .gcda filepaths retrieved using the "strings" tool may
+ // be prefixed by random printable characters so strip leading
+ // characters until the filepath starts with "X:/", "X:\", "/" or "\"
+ // FIXME: need a more robust mechanism to locate .gcda files [Bugzilla 329710]
+ while ((line.length() > 6) && !line.matches("^([A-Za-z]:)?[/\\\\].*")) { //$NON-NLS-1$
+ line = line.substring(1);
+ }
+ IPath p = new Path(line);
+ String filename = p.toString();
+
+ if (!list.contains(filename))
+ list.add(filename);
+ }
+ }
+ }
+ }
+
+ /**
+ * @return the sourceMap
+ */
+ public HashMap<String, SourceFile> getSourceMap() {
+ return sourceMap;
+ }
+
+ private void addSourceLookup(Map<File, File> map, File hostPath, File compilerPath) {
+ while (hostPath.getName().equals(compilerPath.getName())) {
+ hostPath = hostPath.getParentFile();
+ compilerPath = compilerPath.getParentFile();
+ }
+ map.put(compilerPath, hostPath);
+ }
- public void processCovFiles(List<String> covFilesPaths, String initialGcda) throws CoreException, IOException {
- GcdaRecordsParser daRcrd = null;
- DataInput traceFile;
-
- Map<File, File> sourcePath = new HashMap<File, File>();
-
- if (initialGcda != null) {
- File initialGcdaFile = new File(initialGcda).getAbsoluteFile();
- for (String s : covFilesPaths) {
- File gcda = new File(s).getAbsoluteFile();
- if (gcda.getName().equals(initialGcdaFile.getName()) && !gcda.equals(initialGcdaFile)) {
- if (!sourcePath.isEmpty()) {
- // hum... another file has the same name...
- // sorry, we have to clean sourcePath
- sourcePath.clear();
- break;
- } else {
- addSourceLookup(sourcePath, initialGcdaFile, gcda);
- }
- }
- }
- }
-
-
-
- for (String gcdaPath: covFilesPaths) {
- String gcnoPath = gcdaPath.replace(".gcda", ".gcno"); //$NON-NLS-1$ //$NON-NLS-2$
- // parse GCNO file
- traceFile = OpenTraceFileStream(gcnoPath, ".gcno", sourcePath); //$NON-NLS-1$
- if (traceFile == null) return;
- GcnoRecordsParser noRcrd = new GcnoRecordsParser(sourceMap, allSrcs);
- noRcrd.parseData(traceFile);
-
- // add new functions parsed to AllSrcs array
- for (GcnoFunction f: noRcrd.getFnctns()) {
- allFnctns.add(f);
- }
-
- //close the input stream
- if(traceFile.getClass() == DataInputStream.class)
- ((DataInputStream)traceFile).close();
-
- // parse GCDA file
- traceFile = OpenTraceFileStream(gcdaPath, ".gcda", sourcePath); //$NON-NLS-1$
- if (traceFile == null) return;
- if (noRcrd.getFnctns().isEmpty()){
- String message = gcnoPath + " doesn't contain any function:\n";
- Status status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, message);
- throw new CoreException(status);
- }
- daRcrd = new GcdaRecordsParser(noRcrd.getFnctns());
- daRcrd.parseGcdaRecord(traceFile);
-
- //close the input stream
- if(traceFile.getClass() == DataInputStream.class)
- ((DataInputStream)traceFile).close();
- }
-
- // to fill the view title
- if (daRcrd != null)
- nbrPgmRuns = daRcrd.getObjSmryNbrPgmRuns();
- /* process counts from data parsed */
-
- // solve graph for each function
- for (GcnoFunction gf : allFnctns) {
- gf.solveGraphFnctn();
- }
-
- // allocate lines
- for (SourceFile sourceFile: allSrcs) {
- sourceFile.createLines();
- }
-
- // add line counts
- for (GcnoFunction gf : allFnctns) {
- gf.addLineCounts(allSrcs);
- }
-
- // accumulate lines
- for (SourceFile sf: allSrcs) {
- sf.accumulateLineCounts();
- }
-
- /* compute counts by folder*/
-
- // make the folders list
- for (SourceFile sf : allSrcs) {
- File srcFile = new File (sf.getName());
- String folderName = srcFile.getParent();
- if (folderName == null) folderName = "?"; //$NON-NLS-1$
- Folder folder = null;
- for (Folder f: allFolders) {
- if (f.getPath().equals(folderName))
- folder = f;
- }
- if (folder == null){
- folder = new Folder(folderName);
- allFolders.add(folder);
- }
- folder.addSrcFiles(sf);
- }
-
- // assign sourcesList for each folder
- for (Folder f : allFolders) {
- f.accumulateSourcesCounts();
- }
- }
-
-
- /**
- * fill the model by count results
- * @throws CoreException, IOException, InterruptedException
- */
-
- public void fillGcovView() {
- // process counts for summary level
- int summaryTotal = 0, summaryInstrumented = 0, summaryExecuted = 0;
- for (Folder f : allFolders) {
- summaryTotal+=f.getNumLines();
- summaryInstrumented+=f.getLinesInstrumented();
- summaryExecuted+=f.getLinesExecuted();
- }
-
- // fill rootNode model: the entry of the contentProvider
- rootNode = new CovRootTreeElement("Summary", summaryTotal,summaryExecuted,
- summaryInstrumented);
- IBinaryObject binaryObject = STSymbolManager.sharedInstance.getBinaryObject(new Path(binaryPath));
-
- for (Folder fldr : allFolders) {
- String folderLocation = fldr.getPath();
- CovFolderTreeElement fldrTreeElem = new CovFolderTreeElement(
- rootNode, folderLocation, fldr.getNumLines(), fldr.getLinesExecuted(),
- fldr.getLinesInstrumented());
- rootNode.addChild(fldrTreeElem);
-
- for (SourceFile src : fldr.getSrcFiles()) {
- CovFileTreeElement srcTreeElem = new CovFileTreeElement(
- fldrTreeElem, src.getName(), src.getNumLines(), src
- .getLinesExecuted(), src.getLinesInstrumented());
- fldrTreeElem.addChild(srcTreeElem);
-
- for (GcnoFunction fnctn : src.getFnctns()) {
- String name = fnctn.getName();
- name = STSymbolManager.sharedInstance.demangle(binaryObject, name, project);
- srcTreeElem.addChild(new CovFunctionTreeElement(
- srcTreeElem, name, fnctn.getSrcFile(), fnctn
- .getFirstLineNmbr(), fnctn.getCvrge()
- .getLinesExecuted(), fnctn.getCvrge()
- .getLinesInstrumented()));
- }
- }
- }
- }
-
- // transform String path to stream
- private DataInput OpenTraceFileStream(String filePath, String extension, Map<File, File> sourcePath) throws FileNotFoundException{
- File f = new File(filePath).getAbsoluteFile();
- String filename = f.getName();
- if (f.isFile() && f.canRead()) {
- FileInputStream fis = new FileInputStream(f);
- InputStream inputStream = new BufferedInputStream(fis);
- return new DataInputStream(inputStream);
- } else {
- String postfix = ""; //$NON-NLS-1$
- File dir = null;
- do {
- if ("".equals(postfix)) postfix = f.getName(); //$NON-NLS-1$
- else postfix = f.getName() + File.separator + postfix;
- f = f.getParentFile();
- if (f != null) {
- dir = sourcePath.get(f);
- } else break;
- } while (dir == null);
-
- if (dir != null) {
- f = new File(dir, postfix);
- if (f.isFile() && f.canRead()) {
- return OpenTraceFileStream(f.getAbsolutePath(), extension, sourcePath);
- }
- }
-
-
- Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
- FileDialog fg = new FileDialog(shell, SWT.OPEN);
- fg.setFilterExtensions(new String[] {"*" + extension, "*.*", "*"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- fg.setFileName(filename);
- fg.setText(filePath + " not found. Please enter location of " + filename);
- String s = fg.open();
- if (s == null) return null;
- else {
- f = new File(s).getAbsoluteFile();
- addSourceLookup(sourcePath, f, new File(filePath).getAbsoluteFile());
- if (f.isFile() && f.canRead()) {
- FileInputStream fis = new FileInputStream(f);
- InputStream inputStream = new BufferedInputStream(fis);
- return new DataInputStream(inputStream);
- }
- }
- }
- return null;
- }
-
-
- public ArrayList<SourceFile> getAllSrcs() {
- return allSrcs;
- }
-
- public ArrayList<GcnoFunction> getAllFnctns() {
- return allFnctns;
- }
-
- public CovRootTreeElement getRootNode() {
- return rootNode;
- }
-
- public String getBinaryPath() {
- return binaryPath;
- }
-
- public SourceFile getSourceFile(String sourcePath){
- return sourceMap.get(sourcePath);
- }
-
- public long getNbrPgmRuns() {
- return nbrPgmRuns;
- }
-
- /**
- * Retrieve a list containing gcda paths from a binary file
- * @return
- * @throws InterruptedException
- */
- public List<String> getGCDALocations() throws InterruptedException
- {
- IBinaryObject binaryObject = STSymbolManager.sharedInstance.getBinaryObject(new Path(binaryPath));
- String binaryPath = binaryObject.getPath().toOSString();
- List<String> l = new LinkedList<String>();
- Process p;
- String stringsTool = "strings";
- p = getStringsProcess(stringsTool, binaryPath);
- if (p == null) {
- Status status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR,
- "An error occured during analysis: unable to retrieve gcov data", new IOException());
- Activator.getDefault().getLog().log(status);
- return l;
- }
- ThreadConsumer t = new ThreadConsumer(p, l);
- t.start();
- p.waitFor();
- t.join();
- return l;
- }
-
-
- private Process getStringsProcess(String stringsTool, String binaryPath) {
- try {
- Process p = Runtime.getRuntime().exec(new String[] {stringsTool, binaryPath });
- return p;
- } catch (Exception _) {
- return null;
- }
- }
-
-
-
- private static final class ThreadConsumer extends Thread
- {
- private final Process p;
- private final List<String> list;
- ThreadConsumer(Process p, List<String> files)
- {
- super();
- this.p = p;
- this.list = files;
- }
-
- @Override
- public void run()
- {
- try {
- populateGCDAFiles(p.getInputStream());
- } catch (Exception _) {
- }
- }
-
- private void populateGCDAFiles(InputStream s) throws IOException
- {
- InputStreamReader isr = new InputStreamReader(s);
- LineNumberReader lnr = new LineNumberReader(isr);
- String line = null;
- while ((line =lnr.readLine()) != null) {
- if (line.endsWith(".gcda")) //$NON-NLS-1$
- {
- // absolute .gcda filepaths retrieved using the "strings" tool may
- // be prefixed by random printable characters so strip leading
- // characters until the filepath starts with "X:/", "X:\", "/" or "\"
- // FIXME: need a more robust mechanism to locate .gcda files [Bugzilla 329710]
- while ((line.length() > 6) && !line.matches("^([A-Za-z]:)?[/\\\\].*")) { //$NON-NLS-1$
- line = line.substring(1);
- }
- IPath p = new Path(line);
- String filename = p.toString();
-
-
- if (!list.contains(filename)) list.add(filename);
- }
- }
- }
- }
-
- public void dumpProcessCovFilesResult(PrintStream ps) {
- ps.println("Parse gcda and gcno files done, resolve graph algorithm executed, now display results");
- ps.println("- PRINT FUNCTIONS ARRAY : ");
- for (int i = 0; i < allFnctns.size(); i++) {
- ps.println("-- FUNCTION " +i);
- ps.println(" name = " + allFnctns.get(i).getName());
- ps.println(" instrumentd lines = " + allFnctns.get(i).getCvrge().getLinesInstrumented());
- ps.println(" executed lines = "+ allFnctns.get(i).getCvrge().getLinesExecuted());
- }
- ps.println("- PRINT SRCS ARRAY : ");
- for (int i = 0; i < allSrcs.size(); i++) {
- ps.println("-- FILE " + i);
- ps.println(" name = " + allSrcs.get(i).getName());
- ps.println(" total lines = " + allSrcs.get(i).getNumLines());
- ps.println(" instrumentd lines = "+ allSrcs.get(i).getLinesInstrumented());
- ps.println(" executed lines = "+ allSrcs.get(i).getLinesExecuted());
- }
- }
-
-
- /**
- * @return the sourceMap
- */
- public HashMap<String, SourceFile> getSourceMap() {
- return sourceMap;
- }
-
-
- private void addSourceLookup(Map<File, File> map, File hostPath, File compilerPath) {
- while (hostPath.getName().equals(compilerPath.getName())) {
- hostPath = hostPath.getParentFile();
- compilerPath = compilerPath.getParentFile();
- }
- map.put(compilerPath, hostPath);
- }
-
}
diff --git a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/parser/GcdaRecordsParser.java b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/parser/GcdaRecordsParser.java
index aef541f8d5..a4c901a97f 100644
--- a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/parser/GcdaRecordsParser.java
+++ b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/parser/GcdaRecordsParser.java
@@ -23,285 +23,260 @@ import org.eclipse.linuxtools.internal.gcov.Activator;
import org.eclipse.linuxtools.internal.gcov.utils.BEDataInputStream;
import org.eclipse.linuxtools.internal.gcov.utils.LEDataInputStream;
import org.eclipse.linuxtools.internal.gcov.utils.MasksGenerator;
-
-
+import org.eclipse.osgi.util.NLS;
public class GcdaRecordsParser {
-
- private static final int GCOV_DATA_MAGIC = 0x67636461; // en ASCII: 67=g 63=c 64=d 61=a
- private static final int GCOV_TAG_FUNCTION = 0x01000000;
- private static final int GCOV_COUNTER_ARCS = 0x01a10000;
- private static final int GCOV_TAG_OBJECT_SYMMARY = 0xa1000000;
- private static final int GCOV_TAG_PROGRAM_SUMMARY = 0xa3000000;
-
- private final ArrayList<GcnoFunction> fnctns;
- private long objSmryNbrPgmRuns = 0;
- private long pgmSmryChksm = 0;
- private long objSmryChksm = 0;
- private long objSmryArcCnts = 0;
- private long objSmrytotalCnts = 0;
- private long objSmryRunMax = 0;
- private long objSmrySumMax = 0;
-
-
- public GcdaRecordsParser(ArrayList<GcnoFunction> fnctns) {
- this.fnctns = fnctns;
- }
-
- public void parseGcdaRecord(DataInput stream) throws IOException, CoreException {
- // header data
- int magic = 0;
-
- // data & flags to process tests
- GcnoFunction currentFnctn = null;
-
- //read magic
- magic = stream.readInt();
-
- if (magic == GCOV_DATA_MAGIC){
- stream = new BEDataInputStream((DataInputStream) stream);
- }else{
- magic = (magic >> 16) | (magic << 16);
- magic = ((magic & 0xff00ff) << 8) | ((magic >> 8) & 0xff00ff);
- if (magic == GCOV_DATA_MAGIC){
- stream = new LEDataInputStream((DataInputStream) stream);
- }else{
- String message = magic + " :desn't correspond to a correct data file header\n";
- Status status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, message);
- throw new CoreException(status);
- }
- }
-
- //read version
- int version = stream.readInt();
- //read stamp
- //stamp = stream.readInt();
- stream.readInt();
-
- while (true) {
- try {
- // parse header
- int tag = stream.readInt();
-
- /*
- * Move on to the next tag if an unused level (tag == O) is encountered,
- * these do no have corresponding data lengths.
- */
- if(tag == 0){
- continue;
- }
-
- long length = (stream.readInt() & MasksGenerator.UNSIGNED_INT_MASK);
- // parse gcda data
- switch (tag) {
- case GCOV_TAG_FUNCTION: {
- long fnctnId = stream.readInt() & MasksGenerator.UNSIGNED_INT_MASK;
- if (!fnctns.isEmpty()) {
- boolean fnctnFound = false;
- for (GcnoFunction f: fnctns) {
- if (f.getIdent() == fnctnId) {
- fnctnFound = true;
- currentFnctn = f;
- long fnctnChksm = stream.readInt()& MasksGenerator.UNSIGNED_INT_MASK;
- if (f.getCheksum() != fnctnChksm){
- String message = "Checksums don't correspond for " +
- currentFnctn.getName() + " (Id: " + fnctnId + ")\n";
- Status status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, message);
- throw new CoreException(status);
- }
-
- /*
- * danielhb, 2012-08-06: Gcov versions 4.7.0 or
- * later (long value = 875575082) has different format for
- * the data file:
- *
- * prior format:
- *
- * announce_function: header int32:ident int32:checksum
- *
- * new format:
- *
- * announce_function: header int32:ident
- * int32:lineno_checksum int32:cfg_checksum
- *
- *
- * TL;DR Need to consume the extra long value.
- *
- */
- if (version >= 875575082)
- {
- // long cfgChksm = (stream.readInt()&MasksGenerator.UNSIGNED_INT_MASK);
- stream.readInt();
- }
-
- break;
- }
- }
-
- if (fnctnFound == false){
- currentFnctn = null;
- String message = "Function with Id: " + fnctnId +
- " not found in function list\n";
- Status status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, message);
- throw new CoreException(status);
- }
-
- }
- break;
- }
-
- case GCOV_COUNTER_ARCS: {
- if (currentFnctn == null){
- String message = "Missing function or duplicate counter tag\n";
- Status status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, message);
- throw new CoreException(status);
- }
-
- if (length != 2 * (currentFnctn.getNumCounts())){
- String message = "GCDA content is inconsistent\n";
- Status status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, message);
- throw new CoreException(status);
- }
-
- ArrayList<Block> fnctnBlcks = currentFnctn.getFunctionBlocks();
- if (fnctnBlcks.isEmpty()){
- String message = "Function block list is empty\n";
- Status status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, message);
- throw new CoreException(status);
- }
-
- for (int i = 0; i < fnctnBlcks.size(); i++) {
- Block b = fnctnBlcks.get(i);
- int nonFakeExit = 0;
-
- ArrayList<Arc> arcsExit = b.getExitArcs();
- for (Arc extArc: arcsExit) {
- if (extArc.isFake() == false)
- nonFakeExit++;
- if (extArc.isOnTree() == false) {
- long arcsCnts = stream.readLong();
- extArc.setCount(arcsCnts);
- extArc.setCountValid(true);
- b.decNumSuccs();
- extArc.getDstnatnBlock().decNumPreds();
- }
- }
-
- // If there is only one non-fake exit, it is an
- // unconditional branch.
- if (nonFakeExit == 1) {
- for (Arc extArc: arcsExit) {
- if (extArc.isFake() == false) {
- extArc.setUnconditionnal(true);
-
- // If this block is instrumenting a call, it might be
- // an artificial block. It is not artificial if it has
- // a non-fallthrough exit, or the destination of this
- // arc has more than one entry. Mark the destination
- // block as a return site, if none of those conditions hold.
-
- if (b.isCallSite() == true
- && extArc.isFallthrough() == true
- && extArc.getDstnatnBlock()
- .getEntryArcs().get(0)
- .equals(extArc)
- && extArc.getDstnatnBlock()
- .getEntryArcs().size() == 1)
- extArc.getDstnatnBlock()
- .setCallReturn(true);
- }
- }
- }
- }
-
- // counters arcs process data reset
- currentFnctn = null;
- break;
- }
-
- case GCOV_TAG_OBJECT_SYMMARY: {
- objSmryChksm = (stream.readInt() & MasksGenerator.UNSIGNED_INT_MASK);
- objSmryArcCnts = (stream.readInt() & MasksGenerator.UNSIGNED_INT_MASK);
- objSmryNbrPgmRuns = (stream.readInt() & MasksGenerator.UNSIGNED_INT_MASK);
- objSmrytotalCnts = stream.readLong();
- objSmryRunMax = stream.readLong();
- objSmrySumMax = stream.readLong();
- break;
- }
-
- // program summary tag
- case GCOV_TAG_PROGRAM_SUMMARY: {
- //long[] pgmSmryskips = new long[(int) length];
- pgmSmryChksm = (stream.readInt() & MasksGenerator.UNSIGNED_INT_MASK);
- for (int i = 0; i < length - 1; i++) {
- //pgmSmryskips[i] = (stream.readInt() & MasksGenerator.UNSIGNED_INT_MASK);
- stream.readInt();
- }
- break;
- }
-
- default: {
- //System.out.println("wrong gcda tag");
- break;
- }
- }
- }
- catch (EOFException _) {
- break;
- }
- }
- }
-
- /**
- * @return the objSmryNbrPgmRuns
- */
- public long getObjSmryNbrPgmRuns() {
- return objSmryNbrPgmRuns;
- }
-
- /**
- * @return the objSmryChksm
- */
- public long getObjSmryChksm() {
- return objSmryChksm;
- }
-
- /**
- * @return the objSmryArcCnts
- */
- public long getObjSmryArcCnts() {
- return objSmryArcCnts;
- }
-
- /**
- * @return the objSmrytotalCnts
- */
- public long getObjSmrytotalCnts() {
- return objSmrytotalCnts;
- }
-
- /**
- * @return the objSmryRunMax
- */
- public long getObjSmryRunMax() {
- return objSmryRunMax;
- }
-
- /**
- * @return the objSmrySumMax
- */
- public long getObjSmrySumMax() {
- return objSmrySumMax;
- }
-
- /**
- * @return the pgmSmryChksm
- */
- public long getPgmSmryChksm() {
- return pgmSmryChksm;
- }
-
-
+ private static final int GCOV_DATA_MAGIC = 0x67636461; // en ASCII: 67=g 63=c 64=d 61=a
+ private static final int GCOV_TAG_FUNCTION = 0x01000000;
+ private static final int GCOV_COUNTER_ARCS = 0x01a10000;
+ private static final int GCOV_TAG_OBJECT_SYMMARY = 0xa1000000;
+ private static final int GCOV_TAG_PROGRAM_SUMMARY = 0xa3000000;
+
+ private final ArrayList<GcnoFunction> fnctns;
+ private long objSmryNbrPgmRuns = 0;
+ private long pgmSmryChksm = 0;
+ private long objSmryChksm = 0;
+ private long objSmryArcCnts = 0;
+ private long objSmrytotalCnts = 0;
+ private long objSmryRunMax = 0;
+ private long objSmrySumMax = 0;
+
+ public GcdaRecordsParser(ArrayList<GcnoFunction> fnctns) {
+ this.fnctns = fnctns;
+ }
+
+ public void parseGcdaRecord(DataInput stream) throws IOException, CoreException {
+ // header data
+ int magic = 0;
+
+ // data & flags to process tests
+ GcnoFunction currentFnctn = null;
+
+ // read magic
+ magic = stream.readInt();
+
+ if (magic == GCOV_DATA_MAGIC) {
+ stream = new BEDataInputStream((DataInputStream) stream);
+ } else {
+ magic = (magic >> 16) | (magic << 16);
+ magic = ((magic & 0xff00ff) << 8) | ((magic >> 8) & 0xff00ff);
+ if (magic == GCOV_DATA_MAGIC) {
+ stream = new LEDataInputStream((DataInputStream) stream);
+ } else {
+ String message = NLS.bind(Messages.GcdaRecordsParser_magic_num_error, magic);
+ Status status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, message);
+ throw new CoreException(status);
+ }
+ }
+
+ // read version
+ int version = stream.readInt();
+ // read stamp
+ // stamp = stream.readInt();
+ stream.readInt();
+
+ while (true) {
+ try {
+ // parse header
+ int tag = stream.readInt();
+
+ /*
+ * Move on to the next tag if an unused level (tag == O) is encountered, these do no have corresponding
+ * data lengths.
+ */
+ if (tag == 0) {
+ continue;
+ }
+
+ long length = (stream.readInt() & MasksGenerator.UNSIGNED_INT_MASK);
+ // parse gcda data
+ switch (tag) {
+ case GCOV_TAG_FUNCTION: {
+ long fnctnId = stream.readInt() & MasksGenerator.UNSIGNED_INT_MASK;
+ if (!fnctns.isEmpty()) {
+ boolean fnctnFound = false;
+ for (GcnoFunction f : fnctns) {
+ if (f.getIdent() == fnctnId) {
+ fnctnFound = true;
+ currentFnctn = f;
+ long fnctnChksm = stream.readInt() & MasksGenerator.UNSIGNED_INT_MASK;
+ if (f.getCheksum() != fnctnChksm) {
+ String message = NLS.bind(Messages.GcdaRecordsParser_checksum_error, new Object[] {
+ currentFnctn.getName(), fnctnId });
+ Status status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, message);
+ throw new CoreException(status);
+ }
+
+ /*
+ * danielhb, 2012-08-06: Gcov versions 4.7.0 or later (long value = 875575082) has
+ * different format for the data file: prior format: announce_function: header
+ * int32:ident int32:checksum new format: announce_function: header int32:ident
+ * int32:lineno_checksum int32:cfg_checksum TL;DR Need to consume the extra long value.
+ */
+ if (version >= 875575082) {
+ // long cfgChksm = (stream.readInt()&MasksGenerator.UNSIGNED_INT_MASK);
+ stream.readInt();
+ }
+
+ break;
+ }
+ }
+
+ if (fnctnFound == false) {
+ currentFnctn = null;
+ String message = NLS.bind(Messages.GcdaRecordsParser_func_not_found, fnctnId);
+ Status status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, message);
+ throw new CoreException(status);
+ }
+
+ }
+ break;
+ }
+
+ case GCOV_COUNTER_ARCS: {
+ if (currentFnctn == null) {
+ String message = Messages.GcdaRecordsParser_func_counter_error;
+ Status status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, message);
+ throw new CoreException(status);
+ }
+
+ if (length != 2 * (currentFnctn.getNumCounts())) {
+ String message = Messages.GcdaRecordsParser_content_inconsistent;
+ Status status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, message);
+ throw new CoreException(status);
+ }
+
+ ArrayList<Block> fnctnBlcks = currentFnctn.getFunctionBlocks();
+ if (fnctnBlcks.isEmpty()) {
+ String message = Messages.GcdaRecordsParser_func_block_empty;
+ Status status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, message);
+ throw new CoreException(status);
+ }
+
+ for (int i = 0; i < fnctnBlcks.size(); i++) {
+ Block b = fnctnBlcks.get(i);
+ int nonFakeExit = 0;
+
+ ArrayList<Arc> arcsExit = b.getExitArcs();
+ for (Arc extArc : arcsExit) {
+ if (extArc.isFake() == false)
+ nonFakeExit++;
+ if (extArc.isOnTree() == false) {
+ long arcsCnts = stream.readLong();
+ extArc.setCount(arcsCnts);
+ extArc.setCountValid(true);
+ b.decNumSuccs();
+ extArc.getDstnatnBlock().decNumPreds();
+ }
+ }
+
+ // If there is only one non-fake exit, it is an
+ // unconditional branch.
+ if (nonFakeExit == 1) {
+ for (Arc extArc : arcsExit) {
+ if (extArc.isFake() == false) {
+ extArc.setUnconditionnal(true);
+
+ // If this block is instrumenting a call, it might be
+ // an artificial block. It is not artificial if it has
+ // a non-fallthrough exit, or the destination of this
+ // arc has more than one entry. Mark the destination
+ // block as a return site, if none of those conditions hold.
+
+ if (b.isCallSite() == true && extArc.isFallthrough() == true
+ && extArc.getDstnatnBlock().getEntryArcs().get(0).equals(extArc)
+ && extArc.getDstnatnBlock().getEntryArcs().size() == 1)
+ extArc.getDstnatnBlock().setCallReturn(true);
+ }
+ }
+ }
+ }
+
+ // counters arcs process data reset
+ currentFnctn = null;
+ break;
+ }
+
+ case GCOV_TAG_OBJECT_SYMMARY: {
+ objSmryChksm = (stream.readInt() & MasksGenerator.UNSIGNED_INT_MASK);
+ objSmryArcCnts = (stream.readInt() & MasksGenerator.UNSIGNED_INT_MASK);
+ objSmryNbrPgmRuns = (stream.readInt() & MasksGenerator.UNSIGNED_INT_MASK);
+ objSmrytotalCnts = stream.readLong();
+ objSmryRunMax = stream.readLong();
+ objSmrySumMax = stream.readLong();
+ break;
+ }
+
+ // program summary tag
+ case GCOV_TAG_PROGRAM_SUMMARY: {
+ // long[] pgmSmryskips = new long[(int) length];
+ pgmSmryChksm = (stream.readInt() & MasksGenerator.UNSIGNED_INT_MASK);
+ for (int i = 0; i < length - 1; i++) {
+ // pgmSmryskips[i] = (stream.readInt() & MasksGenerator.UNSIGNED_INT_MASK);
+ stream.readInt();
+ }
+ break;
+ }
+
+ default: {
+ // System.out.println("wrong gcda tag");
+ break;
+ }
+ }
+ } catch (EOFException _) {
+ break;
+ }
+ }
+ }
+
+ /**
+ * @return the objSmryNbrPgmRuns
+ */
+ public long getObjSmryNbrPgmRuns() {
+ return objSmryNbrPgmRuns;
+ }
+
+ /**
+ * @return the objSmryChksm
+ */
+ public long getObjSmryChksm() {
+ return objSmryChksm;
+ }
+
+ /**
+ * @return the objSmryArcCnts
+ */
+ public long getObjSmryArcCnts() {
+ return objSmryArcCnts;
+ }
+
+ /**
+ * @return the objSmrytotalCnts
+ */
+ public long getObjSmrytotalCnts() {
+ return objSmrytotalCnts;
+ }
+
+ /**
+ * @return the objSmryRunMax
+ */
+ public long getObjSmryRunMax() {
+ return objSmryRunMax;
+ }
+
+ /**
+ * @return the objSmrySumMax
+ */
+ public long getObjSmrySumMax() {
+ return objSmrySumMax;
+ }
+
+ /**
+ * @return the pgmSmryChksm
+ */
+ public long getPgmSmryChksm() {
+ return pgmSmryChksm;
+ }
}
diff --git a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/parser/GcnoFunction.java b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/parser/GcnoFunction.java
index 30f0817054..4f85fb1a3c 100644
--- a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/parser/GcnoFunction.java
+++ b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/parser/GcnoFunction.java
@@ -15,241 +15,233 @@ import java.util.ArrayList;
public class GcnoFunction implements Serializable, Comparable<GcnoFunction> {
- /**
+ /**
*
*/
- private static final long serialVersionUID = -4159055012321132651L;
-
- private final long ident;
- private final long cheksum;
- private final long firstLineNmbr;
- private final String name;
- private final String srcFile;
- private ArrayList<Block> functionBlocks = new ArrayList<Block>();
- private int numCounts = 0, blocksExecuted = 0, numBlocks = 0;
- private final CoverageInfo cvrge = new CoverageInfo();
-
- public GcnoFunction(long fnctnIdent, long fnctnChksm, String fnctnName, String fnctnSrcFle, long fnctnFrstLnNmbr) {
- this.ident = fnctnIdent;
- this.cheksum = fnctnChksm;
- this.name = fnctnName;
- this.srcFile = fnctnSrcFle;
- this.firstLineNmbr = fnctnFrstLnNmbr;
- }
-
- @Override
- public int compareTo(GcnoFunction o) {
- if (getFirstLineNmbr()>o.getFirstLineNmbr()) return 1;
- else if (getFirstLineNmbr()<o.getFirstLineNmbr()) return -1;
- return 0;
- }
-
-
- public void addLineCounts(ArrayList<SourceFile> srcs) {
- for (int i = 0; i != numBlocks; i++) {
- Block blk = functionBlocks.get(i);
- SourceFile fileSrc = null;
- if ((blk.getCount() != 0) && (i != 0) && (i + 1 != numBlocks))
- blocksExecuted++;
-
- long[] enc = blk.getEncoding();
- for (int j = 0, k = 0; j != blk.getLineNum(); j++, k++) {
- if (enc[k] == 0) {
- int srcn = (int) enc[++k];
- for (SourceFile sf : srcs) {
- if (sf.getIndex() == srcn) {
- fileSrc = sf;
- break;
- }
- }
- j++;
- } else if ((fileSrc != null) && enc[k] < fileSrc.getLines().size()) {
- Line line = fileSrc.getLines().get((int) enc[k]);
- if (line.exists() == false)
- cvrge.incLinesInstrumented();
- if ((line.getCount() == 0) && (blk.getCount() != 0))
- cvrge.incLinesExecuted();
- line.setExists(true);
- line.setCount(line.getCount()+ blk.getCount());
- }
- }
- }
- }
-
- public void solveGraphFnctn() {
- ArrayList<Block> fnctnBlcks = this.functionBlocks;
- ArrayList<Block> validBlocks = new ArrayList<Block>();
- ArrayList<Block> invalidBlocks = new ArrayList<Block>();
-
-
- // Function should contain at least one block
- if (fnctnBlcks.size() >= 2){
- if (fnctnBlcks.get(0).getNumPreds() == 0)
- fnctnBlcks.get(0).setNumPreds(50000);
- if (fnctnBlcks.get(fnctnBlcks.size() - 1).getNumSuccs() == 0)
- fnctnBlcks.get(fnctnBlcks.size() - 1).setNumSuccs(50000);
- }
-
-
- for (int i = 0; i < fnctnBlcks.size(); i++) {
- Block b = fnctnBlcks.get(i);
- b.setInvalidChain(true);
- invalidBlocks.add(b);
- }
-
- while (validBlocks.isEmpty() == false
- || invalidBlocks.isEmpty() == false) {
-
- if (invalidBlocks.isEmpty() == false) {
- for (int i = invalidBlocks.size() - 1; i >= 0; i--) {
- Block invb = invalidBlocks.get(i);
- long total = 0;
- invalidBlocks.remove(i);
- invb.setInvalidChain(false);
-
- if (invb.getNumSuccs() == 0) {
- ArrayList<Arc> extArcs = invb.getExitArcs();
- for (Arc arc : extArcs)
- total += arc.getCount();
- } else if (invb.getNumPreds() == 0) {
- ArrayList<Arc> entrArcs = invb.getEntryArcs();
- for (Arc arc : entrArcs)
- total += arc.getCount();
- } else
- continue;
-
- invb.setCount(total);
- invb.setCountValid(true);
- invb.setValidChain(true);
- validBlocks.add(invb);
- }
- }/*else
- System.out.println("NO, invalid blocks = 0");
- */
- while (validBlocks.isEmpty() == false) {
- int last = validBlocks.size() - 1;
- Block vb = validBlocks.get(last);
- Arc invarc = null;
- int total = 0;
- validBlocks.remove(last);
-
- vb.setValidChain(false);
-
- if (vb.getNumSuccs() == 1) {
- Block blcksdst;
- total = (int) vb.getCount();
-
- for (Arc extAr : vb.getExitArcs()) {
- total -= extAr.getCount();
- if (extAr.isCountValid() == false)
- invarc = extAr;
- }
- blcksdst = invarc.getDstnatnBlock();
- invarc.setCountValid(true);
- invarc.setCount(total);
- vb.decNumSuccs();
- blcksdst.decNumPreds();
-
- if (blcksdst.isCountValid() == true) {
- if (blcksdst.getNumPreds() == 1
- && blcksdst.isValidChain() == false) {
- blcksdst.setValidChain(true);
- validBlocks.add(blcksdst);
- }
- } else {
- if (blcksdst.getNumPreds() == 0
- && blcksdst.isInvalidChain() == false) {
- blcksdst.setInvalidChain(true);
- invalidBlocks.add(blcksdst);
- }
- }
- }
-
- if (vb.getNumPreds() == 1) {
- Block blcksrc;
- total = (int) vb.getCount();
- invarc = null;
-
- for (Arc entrAr: vb.getEntryArcs()) {
- total -= entrAr.getCount();
- if (entrAr.isCountValid() == false)
- invarc = entrAr;
- }
-
- blcksrc = invarc.getSrcBlock();
- invarc.setCountValid(true);
- invarc.setCount(total);
- vb.decNumPreds();
- blcksrc.decNumSuccs();
-
- if (blcksrc.isCountValid() == true) {
- if (blcksrc.getNumSuccs() == 1
- && blcksrc.isInvalidChain() == false) {
- blcksrc.setValidChain(true);
- validBlocks.add(blcksrc);
- }
- } else if (blcksrc.getNumSuccs() == 0
- && blcksrc.isInvalidChain() == false) {
- blcksrc.setInvalidChain(true);
- invalidBlocks.add(blcksrc);
- }
- }
- }
- }
- }
-
- /* getters & setters */
-
- public long getIdent() {
- return ident;
- }
-
- public long getCheksum() {
- return cheksum;
- }
-
- public String getName() {
- return name;
- }
-
- public String getSrcFile() {
- return srcFile;
- }
-
- public long getFirstLineNmbr() {
- return firstLineNmbr;
- }
-
- public ArrayList<Block> getFunctionBlocks() {
- return functionBlocks;
- }
-
- public Block getFunctionBlock(int i) {
- return functionBlocks.get(i);
- }
-
- public void setFunctionBlocks(ArrayList<Block> functionBlocks) {
- this.functionBlocks = functionBlocks;
- }
-
- public void incNumCounts() {
- this.numCounts++;
- }
-
- public int getNumCounts() {
- return numCounts;
- }
-
- public int getNumBlocks() {
- return numBlocks;
- }
-
- public void setNumBlocks(int numBlocks) {
- this.numBlocks = numBlocks;
- }
-
- public CoverageInfo getCvrge() {
- return cvrge;
- }
-
+ private static final long serialVersionUID = -4159055012321132651L;
+
+ private final long ident;
+ private final long cheksum;
+ private final long firstLineNmbr;
+ private final String name;
+ private final String srcFile;
+ private ArrayList<Block> functionBlocks = new ArrayList<Block>();
+ private int numCounts = 0, numBlocks = 0;
+ private final CoverageInfo cvrge = new CoverageInfo();
+
+ public GcnoFunction(long fnctnIdent, long fnctnChksm, String fnctnName, String fnctnSrcFle, long fnctnFrstLnNmbr) {
+ this.ident = fnctnIdent;
+ this.cheksum = fnctnChksm;
+ this.name = fnctnName;
+ this.srcFile = fnctnSrcFle;
+ this.firstLineNmbr = fnctnFrstLnNmbr;
+ }
+
+ @Override
+ public int compareTo(GcnoFunction o) {
+ if (getFirstLineNmbr() > o.getFirstLineNmbr())
+ return 1;
+ else if (getFirstLineNmbr() < o.getFirstLineNmbr())
+ return -1;
+ return 0;
+ }
+
+ public void addLineCounts(ArrayList<SourceFile> srcs) {
+ for (int i = 0; i != numBlocks; i++) {
+ Block blk = functionBlocks.get(i);
+ SourceFile fileSrc = null;
+
+ long[] enc = blk.getEncoding();
+ for (int j = 0, k = 0; j != blk.getLineNum(); j++, k++) {
+ if (enc[k] == 0) {
+ int srcn = (int) enc[++k];
+ for (SourceFile sf : srcs) {
+ if (sf.getIndex() == srcn) {
+ fileSrc = sf;
+ break;
+ }
+ }
+ j++;
+ } else if ((fileSrc != null) && enc[k] < fileSrc.getLines().size()) {
+ Line line = fileSrc.getLines().get((int) enc[k]);
+ if (line.exists() == false)
+ cvrge.incLinesInstrumented();
+ if ((line.getCount() == 0) && (blk.getCount() != 0))
+ cvrge.incLinesExecuted();
+ line.setExists(true);
+ line.setCount(line.getCount() + blk.getCount());
+ }
+ }
+ }
+ }
+
+ public void solveGraphFnctn() {
+ ArrayList<Block> fnctnBlcks = this.functionBlocks;
+ ArrayList<Block> validBlocks = new ArrayList<Block>();
+ ArrayList<Block> invalidBlocks = new ArrayList<Block>();
+
+ // Function should contain at least one block
+ if (fnctnBlcks.size() >= 2) {
+ if (fnctnBlcks.get(0).getNumPreds() == 0)
+ fnctnBlcks.get(0).setNumPreds(50000);
+ if (fnctnBlcks.get(fnctnBlcks.size() - 1).getNumSuccs() == 0)
+ fnctnBlcks.get(fnctnBlcks.size() - 1).setNumSuccs(50000);
+ }
+
+ for (int i = 0; i < fnctnBlcks.size(); i++) {
+ Block b = fnctnBlcks.get(i);
+ b.setInvalidChain(true);
+ invalidBlocks.add(b);
+ }
+
+ while (validBlocks.isEmpty() == false || invalidBlocks.isEmpty() == false) {
+
+ if (invalidBlocks.isEmpty() == false) {
+ for (int i = invalidBlocks.size() - 1; i >= 0; i--) {
+ Block invb = invalidBlocks.get(i);
+ long total = 0;
+ invalidBlocks.remove(i);
+ invb.setInvalidChain(false);
+
+ if (invb.getNumSuccs() == 0) {
+ ArrayList<Arc> extArcs = invb.getExitArcs();
+ for (Arc arc : extArcs)
+ total += arc.getCount();
+ } else if (invb.getNumPreds() == 0) {
+ ArrayList<Arc> entrArcs = invb.getEntryArcs();
+ for (Arc arc : entrArcs)
+ total += arc.getCount();
+ } else
+ continue;
+
+ invb.setCount(total);
+ invb.setCountValid(true);
+ invb.setValidChain(true);
+ validBlocks.add(invb);
+ }
+ }/*
+ * else System.out.println("NO, invalid blocks = 0");
+ */
+ while (validBlocks.isEmpty() == false) {
+ int last = validBlocks.size() - 1;
+ Block vb = validBlocks.get(last);
+ Arc invarc = null;
+ int total = 0;
+ validBlocks.remove(last);
+
+ vb.setValidChain(false);
+
+ if (vb.getNumSuccs() == 1) {
+ Block blcksdst;
+ total = (int) vb.getCount();
+
+ for (Arc extAr : vb.getExitArcs()) {
+ total -= extAr.getCount();
+ if (extAr.isCountValid() == false)
+ invarc = extAr;
+ }
+ blcksdst = invarc.getDstnatnBlock();
+ invarc.setCountValid(true);
+ invarc.setCount(total);
+ vb.decNumSuccs();
+ blcksdst.decNumPreds();
+
+ if (blcksdst.isCountValid() == true) {
+ if (blcksdst.getNumPreds() == 1 && blcksdst.isValidChain() == false) {
+ blcksdst.setValidChain(true);
+ validBlocks.add(blcksdst);
+ }
+ } else {
+ if (blcksdst.getNumPreds() == 0 && blcksdst.isInvalidChain() == false) {
+ blcksdst.setInvalidChain(true);
+ invalidBlocks.add(blcksdst);
+ }
+ }
+ }
+
+ if (vb.getNumPreds() == 1) {
+ Block blcksrc;
+ total = (int) vb.getCount();
+ invarc = null;
+
+ for (Arc entrAr : vb.getEntryArcs()) {
+ total -= entrAr.getCount();
+ if (entrAr.isCountValid() == false)
+ invarc = entrAr;
+ }
+
+ blcksrc = invarc.getSrcBlock();
+ invarc.setCountValid(true);
+ invarc.setCount(total);
+ vb.decNumPreds();
+ blcksrc.decNumSuccs();
+
+ if (blcksrc.isCountValid() == true) {
+ if (blcksrc.getNumSuccs() == 1 && blcksrc.isInvalidChain() == false) {
+ blcksrc.setValidChain(true);
+ validBlocks.add(blcksrc);
+ }
+ } else if (blcksrc.getNumSuccs() == 0 && blcksrc.isInvalidChain() == false) {
+ blcksrc.setInvalidChain(true);
+ invalidBlocks.add(blcksrc);
+ }
+ }
+ }
+ }
+ }
+
+ /* getters & setters */
+
+ public long getIdent() {
+ return ident;
+ }
+
+ public long getCheksum() {
+ return cheksum;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getSrcFile() {
+ return srcFile;
+ }
+
+ public long getFirstLineNmbr() {
+ return firstLineNmbr;
+ }
+
+ public ArrayList<Block> getFunctionBlocks() {
+ return functionBlocks;
+ }
+
+ public Block getFunctionBlock(int i) {
+ return functionBlocks.get(i);
+ }
+
+ public void setFunctionBlocks(ArrayList<Block> functionBlocks) {
+ this.functionBlocks = functionBlocks;
+ }
+
+ public void incNumCounts() {
+ this.numCounts++;
+ }
+
+ public int getNumCounts() {
+ return numCounts;
+ }
+
+ public int getNumBlocks() {
+ return numBlocks;
+ }
+
+ public void setNumBlocks(int numBlocks) {
+ this.numBlocks = numBlocks;
+ }
+
+ public CoverageInfo getCvrge() {
+ return cvrge;
+ }
+
}
diff --git a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/parser/GcnoRecordsParser.java b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/parser/GcnoRecordsParser.java
index 4e398aa4bb..65acfbbc00 100644
--- a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/parser/GcnoRecordsParser.java
+++ b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/parser/GcnoRecordsParser.java
@@ -25,240 +25,216 @@ import org.eclipse.linuxtools.internal.gcov.utils.BEDataInputStream;
import org.eclipse.linuxtools.internal.gcov.utils.GcovStringReader;
import org.eclipse.linuxtools.internal.gcov.utils.LEDataInputStream;
import org.eclipse.linuxtools.internal.gcov.utils.MasksGenerator;
-
+import org.eclipse.osgi.util.NLS;
public class GcnoRecordsParser {
-
- private static final int GCOV_NOTE_MAGIC = 0x67636e6f; // en ASCII: 67=g 63=c 6e=n 6f=o
- private static final int GCOV_TAG_FUNCTION = 0x01000000;
- private static final int GCOV_TAG_BLOCKS = 0x01410000;
- private static final int GCOV_TAG_ARCS = 0x01430000;
- private static final int GCOV_TAG_LINES = 0x01450000;
-
- private GcnoFunction fnctn = null;
- private final ArrayList<GcnoFunction> fnctns = new ArrayList<GcnoFunction>();
- private final ArrayList<SourceFile> currentAllSrcs;
- private final HashMap<String, SourceFile> sourceMap;
-
- public GcnoRecordsParser(HashMap<String, SourceFile> sourceMap, ArrayList<SourceFile> AllSrcs){
- this.sourceMap = sourceMap;
- this.currentAllSrcs = AllSrcs;
- }
-
- private SourceFile findOrAdd (String fileName, ArrayList<SourceFile> srcs)
- {
- SourceFile newsrc = sourceMap.get(fileName);
- if (newsrc == null) {
- newsrc = new SourceFile(fileName, srcs.size()+1);
- srcs.add(newsrc);
- sourceMap.put(fileName, newsrc);
- }
- return newsrc; //return the new added element
- }
-
-
- public void parseData(DataInput stream) throws IOException, CoreException{
- // header data
- int magic = 0;
- // blocks data
- ArrayList<Block> blocks = null;
- // source file data
- SourceFile source = null;
- // flag
- boolean parseFirstFnctn = false;
-
- magic = stream.readInt();
- if (magic == GCOV_NOTE_MAGIC){
- stream = new BEDataInputStream((DataInputStream) stream);
- }else{
- magic = (magic >> 16) | (magic << 16);
- magic = ((magic & 0xff00ff) << 8) | ((magic >> 8) & 0xff00ff);
- if (magic == GCOV_NOTE_MAGIC){
- stream = new LEDataInputStream((DataInputStream) stream);
- }else{
- String message = magic + " :desn't correspond to a correct note file header\n";
- Status status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, message);
- throw new CoreException(status);
- }
- }
-
- int version = stream.readInt();
- //stamp = stream.readInt();
- stream.readInt();
- /*------------------------------------------------------------------------------
- System.out.println("Gcno LE, Magic "+magic+" version "+version+" stamp "+stamp);
- */
-
- while (true){
- try{
- int tag;
- // parse header
- while (true){
- tag=stream.readInt();
- if (tag == GCOV_TAG_FUNCTION || tag == GCOV_TAG_BLOCKS ||
- tag == GCOV_TAG_ARCS || tag == GCOV_TAG_LINES)
- break;
- }
- int length=stream.readInt();
+ private static final int GCOV_NOTE_MAGIC = 0x67636e6f; // en ASCII: 67=g 63=c 6e=n 6f=o
+ private static final int GCOV_TAG_FUNCTION = 0x01000000;
+ private static final int GCOV_TAG_BLOCKS = 0x01410000;
+ private static final int GCOV_TAG_ARCS = 0x01430000;
+ private static final int GCOV_TAG_LINES = 0x01450000;
+
+ private GcnoFunction fnctn = null;
+ private final ArrayList<GcnoFunction> fnctns = new ArrayList<GcnoFunction>();
+ private final ArrayList<SourceFile> currentAllSrcs;
+ private final HashMap<String, SourceFile> sourceMap;
+
+ public GcnoRecordsParser(HashMap<String, SourceFile> sourceMap, ArrayList<SourceFile> AllSrcs) {
+ this.sourceMap = sourceMap;
+ this.currentAllSrcs = AllSrcs;
+ }
+
+ private SourceFile findOrAdd(String fileName, ArrayList<SourceFile> srcs) {
+ SourceFile newsrc = sourceMap.get(fileName);
+ if (newsrc == null) {
+ newsrc = new SourceFile(fileName, srcs.size() + 1);
+ srcs.add(newsrc);
+ sourceMap.put(fileName, newsrc);
+ }
+ return newsrc; // return the new added element
+ }
+
+ public void parseData(DataInput stream) throws IOException, CoreException {
+ // header data
+ int magic = 0;
+ // blocks data
+ ArrayList<Block> blocks = null;
+ // source file data
+ SourceFile source = null;
+ // flag
+ boolean parseFirstFnctn = false;
+
+ magic = stream.readInt();
+ if (magic == GCOV_NOTE_MAGIC) {
+ stream = new BEDataInputStream((DataInputStream) stream);
+ } else {
+ magic = (magic >> 16) | (magic << 16);
+ magic = ((magic & 0xff00ff) << 8) | ((magic >> 8) & 0xff00ff);
+ if (magic == GCOV_NOTE_MAGIC) {
+ stream = new LEDataInputStream((DataInputStream) stream);
+ } else {
+ String message = NLS.bind(Messages.GcnoRecordsParser_magic_num_error, magic);
+ Status status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, message);
+ throw new CoreException(status);
+ }
+ }
+
+ int version = stream.readInt();
+ // stamp = stream.readInt();
+ stream.readInt();
+
+ /*------------------------------------------------------------------------------
+ System.out.println("Gcno LE, Magic "+magic+" version "+version+" stamp "+stamp);
+ */
+
+ while (true) {
+ try {
+ int tag;
+ // parse header
+ while (true) {
+ tag = stream.readInt();
+ if (tag == GCOV_TAG_FUNCTION || tag == GCOV_TAG_BLOCKS || tag == GCOV_TAG_ARCS
+ || tag == GCOV_TAG_LINES)
+ break;
+ }
+ int length = stream.readInt();
+
+ // parse gcno data
+ if (tag == GCOV_TAG_FUNCTION) {
+ // before parse new function, add current function to functions list
+ if (parseFirstFnctn == true)
+ fnctns.add(fnctn);
+
+ long fnctnIdent = (stream.readInt() & MasksGenerator.UNSIGNED_INT_MASK);
+ long fnctnChksm = (stream.readInt() & MasksGenerator.UNSIGNED_INT_MASK);
+ /*
+ * danielhb, 2012-08-06: Gcov versions 4.7.0 or later (long value = 875575082) has different format
+ * for the data file: prior format: announce_function: header int32:ident int32:checksum new format:
+ * announce_function: header int32:ident int32:lineno_checksum int32:cfg_checksum TL;DR Need to
+ * consume the extra long value.
+ */
+ if (version >= 875575082) {
+ // long cfgChksm = (stream.readInt()&MasksGenerator.UNSIGNED_INT_MASK);
+ stream.readInt();
+ }
+ String fnctnName = GcovStringReader.readString(stream);
+ String fnctnSrcFle = GcovStringReader.readString(stream);
+ long fnctnFrstLnNmbr = (stream.readInt() & MasksGenerator.UNSIGNED_INT_MASK);
+
+ fnctn = new GcnoFunction(fnctnIdent, fnctnChksm, fnctnName, fnctnSrcFle, fnctnFrstLnNmbr);
+ SourceFile srcFle2 = findOrAdd(fnctn.getSrcFile(), currentAllSrcs);
+ if (fnctn.getFirstLineNmbr() >= srcFle2.getNumLines()) {
+ srcFle2.setNumLines((int) fnctn.getFirstLineNmbr() + 1);
+ }
+ srcFle2.addFnctn(fnctn);
+ parseFirstFnctn = true;
+ continue;
+ }
+
+ else if (tag == GCOV_TAG_BLOCKS) {
+ blocks = new ArrayList<Block>();
+ for (int i = 0; i < length; i++) {
+ long BlckFlag = stream.readInt() & MasksGenerator.UNSIGNED_INT_MASK;
+ Block blck = new Block(BlckFlag);
+ blocks.add(blck);
+ }
+ fnctn.setNumBlocks(length);
+ continue;
+ } else if (tag == GCOV_TAG_ARCS) {
+ int srcBlockIndice = stream.readInt();
+ int nmbrArcs = (length - 1) / 2;
+ ArrayList<Arc> arcs = new ArrayList<Arc>(nmbrArcs);
+
+ for (int i = 0; i < nmbrArcs; i++) {
+ int dstnatnBlockIndice = stream.readInt();
+ long flag = (stream.readInt() & MasksGenerator.UNSIGNED_INT_MASK);
+ Arc arc = new Arc(srcBlockIndice, dstnatnBlockIndice, flag, blocks);
+ arcs.add(arc);
+ }
+
+ // each arc, register it as exit of the src block
+ Block srcBlk = blocks.get(srcBlockIndice);
+ for (Arc a : arcs) {
+ srcBlk.addExitArcs(a);
+ srcBlk.incNumSuccs();
+ }
+
+ // each arc, register it as entry of its dstntn block
+ for (Arc a : arcs) {
+ Block dstntnBlk = a.getDstnatnBlock();
+ dstntnBlk.addEntryArcs(a);
+ dstntnBlk.incNumPreds();
+ }
+
+ for (Arc a : arcs) {
+ if (a.isFake() == true) {
+ if (a.getSrcBlock() != null) {
+ // Exceptional exit from this function, the
+ // source block must be a call.
+ srcBlk = blocks.get(srcBlockIndice);
+ srcBlk.setCallSite(true);
+ a.setCallNonReturn(true);
+ } else {
+ a.setNonLoclaReturn(true);
+ Block dstntnBlk = a.getDstnatnBlock();
+ dstntnBlk.setNonLocalReturn(true);
+ }
+ }
+
+ if (a.isOnTree() == false)
+ fnctn.incNumCounts();
+ // nbrCounts++;
+ }
+
+ fnctn.setFunctionBlocks(blocks);
+ continue;
+ }
+
+ else if (tag == GCOV_TAG_LINES) {
+ int numBlock = stream.readInt();
+ long[] lineNos = new long[length - 1];
+ int ix = 0;
+ do {
+ long lineNumber = stream.readInt() & MasksGenerator.UNSIGNED_INT_MASK;
+ if (lineNumber != 0) {
+ if (ix == 0) {
+ lineNos[ix++] = 0;
+ lineNos[ix++] = source.getIndex();
+ }
+ lineNos[ix++] = lineNumber;
+ if (lineNumber >= source.getNumLines()) {
+ source.setNumLines((int) lineNumber + 1);
+ }
+ } else {
+ String fileName = GcovStringReader.readString(stream);
+ if (fileName == Messages.GcnoRecordsParser_null_string)
+ break;
- // parse gcno data
- if (tag == GCOV_TAG_FUNCTION){
- // before parse new function, add current function to functions list
- if (parseFirstFnctn == true) fnctns.add(fnctn);
-
- long fnctnIdent = (stream.readInt()&MasksGenerator.UNSIGNED_INT_MASK);
- long fnctnChksm = (stream.readInt()&MasksGenerator.UNSIGNED_INT_MASK);
- /*
- * danielhb, 2012-08-06: Gcov versions 4.7.0 or
- * later (long value = 875575082) has different format for
- * the data file:
- *
- * prior format:
- *
- * announce_function: header int32:ident int32:checksum
- *
- * new format:
- *
- * announce_function: header int32:ident
- * int32:lineno_checksum int32:cfg_checksum
- *
- *
- * TL;DR Need to consume the extra long value.
- *
- */
- if (version >= 875575082)
- {
- // long cfgChksm = (stream.readInt()&MasksGenerator.UNSIGNED_INT_MASK);
- stream.readInt();
- }
- String fnctnName = GcovStringReader.readString(stream);
- String fnctnSrcFle = GcovStringReader.readString(stream);
- long fnctnFrstLnNmbr= (stream.readInt()&MasksGenerator.UNSIGNED_INT_MASK);
-
- fnctn = new GcnoFunction(fnctnIdent, fnctnChksm, fnctnName, fnctnSrcFle, fnctnFrstLnNmbr);
- SourceFile srcFle2 = findOrAdd (fnctn.getSrcFile(),currentAllSrcs);
- if (fnctn.getFirstLineNmbr() >= srcFle2.getNumLines()){
- srcFle2.setNumLines((int)fnctn.getFirstLineNmbr()+1);
- }
- srcFle2.addFnctn(fnctn);
- parseFirstFnctn = true;
- continue;
- }
-
- else if (tag == GCOV_TAG_BLOCKS){
- blocks = new ArrayList<Block>();
- for (int i = 0; i < length; i++) {
- long BlckFlag = stream.readInt()& MasksGenerator.UNSIGNED_INT_MASK;
- Block blck = new Block(BlckFlag);
- blocks.add(blck);
- }
- fnctn.setNumBlocks(length);
- continue;
- }
- else if (tag == GCOV_TAG_ARCS){
- int srcBlockIndice = stream.readInt();
- int nmbrArcs = (length-1)/2;
- ArrayList<Arc> arcs = new ArrayList<Arc>(nmbrArcs);
+ source = findOrAdd(fileName, currentAllSrcs);
+ lineNos[ix++] = 0;
+ lineNos[ix++] = source.getIndex();
+ }
+ } while (true);
- for (int i = 0; i < nmbrArcs; i++) {
- int dstnatnBlockIndice = stream.readInt();
- long flag = (stream.readInt()&MasksGenerator.UNSIGNED_INT_MASK);
- Arc arc = new Arc(srcBlockIndice, dstnatnBlockIndice, flag, blocks);
- arcs.add(arc);
- }
-
- // each arc, register it as exit of the src block
- Block srcBlk = blocks.get(srcBlockIndice);
- for (Arc a : arcs) {
- srcBlk.addExitArcs(a);
- srcBlk.incNumSuccs();
- }
-
- // each arc, register it as entry of its dstntn block
- for (Arc a : arcs) {
- Block dstntnBlk = a.getDstnatnBlock();
- dstntnBlk.addEntryArcs(a);
- dstntnBlk.incNumPreds();
- }
-
- for (Arc a : arcs) {
- if (a.isFake() == true) {
- if (a.getSrcBlock() != null ) {
- // Exceptional exit from this function, the
- // source block must be a call.
- srcBlk = blocks.get(srcBlockIndice);
- srcBlk.setCallSite(true);
- a.setCallNonReturn(true);
- } else {
- a.setNonLoclaReturn(true);
- Block dstntnBlk = a.getDstnatnBlock();
- dstntnBlk.setNonLocalReturn(true);
- }
- }
-
- if (a.isOnTree() == false)
- fnctn.incNumCounts();
- //nbrCounts++;
- }
-
- fnctn.setFunctionBlocks(blocks);
- continue;
- }
-
-
- else if (tag == GCOV_TAG_LINES) {
- int numBlock = stream.readInt();
- long[] lineNos = new long[length-1];
- int ix = 0;
- do {
- long lineNumber = stream.readInt()&MasksGenerator.UNSIGNED_INT_MASK;
- if (lineNumber != 0){
- if (ix == 0){
- lineNos[ix++] = 0;
- lineNos[ix++] = source.getIndex();
- }
- lineNos[ix++]=lineNumber;
- if (lineNumber >= source.getNumLines()){
- source.setNumLines((int)lineNumber+1);
- }
- } else {
- String fileName = GcovStringReader.readString(stream);
- if (fileName == "NULL string")
- break;
+ fnctn.getFunctionBlocks().get((numBlock)).setEncoding(lineNos);
+ fnctn.getFunctionBlocks().get((numBlock)).setNumLine(ix);
+ continue;
+ }
+ } catch (EOFException e) {
+ fnctn.setFunctionBlocks(blocks);
+ fnctns.add(fnctn);
+ break;
+ }
+ }// while
+ }
- source = findOrAdd (fileName, currentAllSrcs);
- lineNos[ix++]=0;
- lineNos[ix++]=source.getIndex();
- }
- } while (true);
-
- fnctn.getFunctionBlocks().get((numBlock))
- .setEncoding(lineNos);
-
- fnctn.getFunctionBlocks().get((numBlock))
- .setNumLine(ix);
-
- continue;
- }
- }
- catch (EOFException e) {
-
- fnctn.setFunctionBlocks(blocks);
- fnctns.add(fnctn);
-
- break;
+ /* Getters */
+ public ArrayList<GcnoFunction> getFnctns() {
+ return fnctns;
+ }
- }
- }//while
- }
-
- /* Getters */
- public ArrayList<GcnoFunction> getFnctns() {
- return fnctns;
- }
-
- public ArrayList<SourceFile> getcurrentAllSrcs() {
- return currentAllSrcs;
- }
+ public ArrayList<SourceFile> getcurrentAllSrcs() {
+ return currentAllSrcs;
+ }
}
diff --git a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/parser/Messages.java b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/parser/Messages.java
new file mode 100644
index 0000000000..b89ebec9af
--- /dev/null
+++ b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/parser/Messages.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.internal.gcov.parser;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.linuxtools.internal.gcov.parser.messages"; //$NON-NLS-1$
+ public static String CovManager_Parsing_Done;
+ public static String CovManager_Retrieval_Error;
+ public static String CovManager_Strings;
+ public static String CovManager_Summary;
+ public static String CovManager_No_Funcs_Error;
+ public static String CovManager_No_FilePath_Error;
+
+ public static String GcdaRecordsParser_content_inconsistent;
+ public static String GcdaRecordsParser_func_block_empty;
+ public static String GcdaRecordsParser_func_counter_error;
+ public static String GcdaRecordsParser_magic_num_error;
+ public static String GcdaRecordsParser_checksum_error;
+ public static String GcdaRecordsParser_func_not_found;
+ public static String GcnoRecordsParser_null_string;
+ public static String GcnoRecordsParser_magic_num_error;
+
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/parser/messages.properties b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/parser/messages.properties
new file mode 100644
index 0000000000..615bd9c782
--- /dev/null
+++ b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/parser/messages.properties
@@ -0,0 +1,24 @@
+###############################################################################
+# Copyright (c) 2013 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
+###############################################################################
+CovManager_Parsing_Done=Parse gcda and gcno files done, resolve graph algorithm executed, now display results
+CovManager_Retrieval_Error=An error occured during analysis: unable to retrieve gcov data
+CovManager_Strings=strings
+CovManager_Summary=Summary
+CovManager_No_Funcs_Error={0} doesn't contain any function:\n
+CovManager_No_FilePath_Error={0} not found. Please enter location of {1}
+GcdaRecordsParser_content_inconsistent=GCDA content is inconsistent\n
+GcdaRecordsParser_func_block_empty=Function block list is empty\n
+GcdaRecordsParser_func_counter_error=Missing function or duplicate counter tag\n
+GcdaRecordsParser_magic_num_error={0} :doesn't correspond to a correct data file header\n
+GcdaRecordsParser_checksum_error=Checksums don't correspond for {0} (Id: {1})\n
+GcdaRecordsParser_func_not_found=Function with Id: {0} not found in function list\n;
+GcnoRecordsParser_null_string=NULL string
+GcnoRecordsParser_magic_num_error={0} :doesn't correspond to a correct note file header\n
diff --git a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/utils/GcovStringReader.java b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/utils/GcovStringReader.java
index 1c1158507e..3fa963a8f9 100644
--- a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/utils/GcovStringReader.java
+++ b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/utils/GcovStringReader.java
@@ -15,24 +15,23 @@ import java.io.IOException;
public class GcovStringReader {
-
- public static String readString(DataInput stream) throws IOException {
- String res = "NULL string";
- long length = stream.readInt()&MasksGenerator.UNSIGNED_INT_MASK;
- if (length != 0) {
- int ln = ((int) length) << 2;
- byte[] name = new byte[ln];
- stream.readFully(name);
- StringBuffer sb = new StringBuffer();
- for(int j=0; j < ln; j++){
- if(name[j]!=0){
- char c = (char) name[j];
- sb.append(c);
- }
- }
- res = sb.toString();
- }
- return res;
- }
+ public static String readString(DataInput stream) throws IOException {
+ String res = Messages.GcovStringReader_null_string;
+ long length = stream.readInt() & MasksGenerator.UNSIGNED_INT_MASK;
+ if (length != 0) {
+ int ln = ((int) length) << 2;
+ byte[] name = new byte[ln];
+ stream.readFully(name);
+ StringBuffer sb = new StringBuffer();
+ for (int j = 0; j < ln; j++) {
+ if (name[j] != 0) {
+ char c = (char) name[j];
+ sb.append(c);
+ }
+ }
+ res = sb.toString();
+ }
+ return res;
+ }
}
diff --git a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/utils/LEDataInputStream.java b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/utils/LEDataInputStream.java
index b3f90b754a..a4dff1ee15 100644
--- a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/utils/LEDataInputStream.java
+++ b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/utils/LEDataInputStream.java
@@ -13,211 +13,178 @@ package org.eclipse.linuxtools.internal.gcov.utils;
import java.io.DataInput;
import java.io.DataInputStream;
import java.io.IOException;
+
/**
* Little-endian implementation of DataInputStream
* @author Xavier Raynaud <xavier.raynaud@st.com>
- *
*/
public class LEDataInputStream implements DataInput {
- private final DataInputStream in;
- private final byte[] buffer = new byte[8];
-
- /**
- * Constructor
- * @param in
- */
- public LEDataInputStream(DataInputStream in) {
- this.in = in;
- }
-
-
- /*
- * (non-Javadoc)
- * @see java.io.DataInput#readShort()
- */
- @Override
- public final short readShort() throws IOException
- {
- in.readFully(buffer, 0, 2);
- return (short)(
- (buffer[1]&0xff) << 8 |
- (buffer[0]&0xff));
- }
-
- /*
- * (non-Javadoc)
- * @see java.io.DataInput#readUnsignedShort()
- */
- @Override
- public final int readUnsignedShort() throws IOException
- {
- in.readFully(buffer, 0, 2);
- return (
- (buffer[1]&0xff) << 8 |
- (buffer[0]&0xff));
- }
-
- /*
- * (non-Javadoc)
- * @see java.io.DataInput#readChar()
- */
- @Override
- public final char readChar() throws IOException
- {
- in.readFully(buffer, 0, 2);
- return (char) (
- (buffer[1]&0xff) << 8 |
- (buffer[0]&0xff));
- }
-
- /*
- * (non-Javadoc)
- * @see java.io.DataInput#readInt()
- */
- @Override
- public final int readInt() throws IOException
- {
- in.readFully(buffer, 0, 4);
- return
- (buffer[3]) << 24 |
- (buffer[2]&0xff) << 16 |
- (buffer[1]&0xff) << 8 |
- (buffer[0]&0xff);
- }
-
- /*
- * (non-Javadoc)
- * @see java.io.DataInput#readLong()
- */
- @Override
- public final long readLong() throws IOException
- {
- in.readFully(buffer, 0, 8);
- return
- (long)(buffer[7]) << 56 | /* long cast needed or shift done modulo 32 */
- (long)(buffer[6]&0xff) << 48 |
- (long)(buffer[5]&0xff) << 40 |
- (long)(buffer[4]&0xff) << 32 |
- (long)(buffer[3]&0xff) << 24 |
- (long)(buffer[2]&0xff) << 16 |
- (long)(buffer[1]&0xff) << 8 |
- (long)(buffer[0]&0xff);
- }
-
- /*
- * (non-Javadoc)
- * @see java.io.DataInput#readFloat()
- */
- @Override
- public final float readFloat() throws IOException
- {
- return Float.intBitsToFloat(readInt());
- }
-
- /*
- * (non-Javadoc)
- * @see java.io.DataInput#readDouble()
- */
- @Override
- public final double readDouble() throws IOException
- {
- return Double.longBitsToDouble(readLong());
- }
-
- /*
- * (non-Javadoc)
- * @see java.io.DataInput#readBoolean()
- */
- @Override
- public boolean readBoolean() throws IOException {
- return in.readBoolean();
- }
-
- /*
- * (non-Javadoc)
- * @see java.io.DataInput#readByte()
- */
- @Override
- public byte readByte() throws IOException {
- return in.readByte();
- }
-
- /*
- * (non-Javadoc)
- * @see java.io.DataInput#readFully(byte[])
- */
- @Override
- public void readFully(byte[] b) throws IOException {
- in.readFully(b);
- }
-
- /*
- * (non-Javadoc)
- * @see java.io.DataInput#readFully(byte[], int, int)
- */
- @Override
- public void readFully(byte[] b, int off, int len) throws IOException {
- in.readFully(b,off,len);
- }
-
- /*
- * (non-Javadoc)
- * @see java.io.DataInput#readLine()
- */
- @Override
- @Deprecated
- public String readLine() throws IOException {
- return in.readLine();
- }
-
- /*
- * (non-Javadoc)
- * @see java.io.DataInput#readUTF()
- */
- @Override
- public String readUTF() throws IOException {
- return in.readUTF();
- }
-
- /*
- * (non-Javadoc)
- * @see java.io.DataInput#readUnsignedByte()
- */
- @Override
- public int readUnsignedByte() throws IOException {
- return in.readUnsignedByte();
- }
-
- /*
- * (non-Javadoc)
- * @see java.io.DataInput#skipBytes(int)
- */
- @Override
- public int skipBytes(int n) throws IOException {
- return in.skipBytes(n);
- }
-
- /**
- * Close this stream.
- */
- public void close() throws IOException {
- in.close();
- }
-
- public final long readUnsignedInt() throws IOException
- {
- in.readFully(buffer, 0, 4);
- return
- ((
- (buffer[3]) << 24 |
- (buffer[2]&0xff) << 16 |
- (buffer[1]&0xff) << 8 |
- (buffer[0]&0xff)
- )
- & MasksGenerator.UNSIGNED_INT_MASK );
- }
-
-
+ private final DataInputStream in;
+ private final byte[] buffer = new byte[8];
+
+ /**
+ * Constructor
+ * @param in
+ */
+ public LEDataInputStream(DataInputStream in) {
+ this.in = in;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.io.DataInput#readShort()
+ */
+ @Override
+ public final short readShort() throws IOException {
+ in.readFully(buffer, 0, 2);
+ return (short) ((buffer[1] & 0xff) << 8 | (buffer[0] & 0xff));
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.io.DataInput#readUnsignedShort()
+ */
+ @Override
+ public final int readUnsignedShort() throws IOException {
+ in.readFully(buffer, 0, 2);
+ return ((buffer[1] & 0xff) << 8 | (buffer[0] & 0xff));
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.io.DataInput#readChar()
+ */
+ @Override
+ public final char readChar() throws IOException {
+ in.readFully(buffer, 0, 2);
+ return (char) ((buffer[1] & 0xff) << 8 | (buffer[0] & 0xff));
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.io.DataInput#readInt()
+ */
+ @Override
+ public final int readInt() throws IOException {
+ in.readFully(buffer, 0, 4);
+ return (buffer[3]) << 24 | (buffer[2] & 0xff) << 16 | (buffer[1] & 0xff) << 8 | (buffer[0] & 0xff);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.io.DataInput#readLong()
+ */
+ @Override
+ public final long readLong() throws IOException {
+ in.readFully(buffer, 0, 8);
+ return (long) (buffer[7]) << 56 | /* long cast needed or shift done modulo 32 */
+ (long) (buffer[6] & 0xff) << 48 | (long) (buffer[5] & 0xff) << 40 | (long) (buffer[4] & 0xff) << 32
+ | (long) (buffer[3] & 0xff) << 24 | (long) (buffer[2] & 0xff) << 16 | (long) (buffer[1] & 0xff) << 8
+ | (buffer[0] & 0xff);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.io.DataInput#readFloat()
+ */
+ @Override
+ public final float readFloat() throws IOException {
+ return Float.intBitsToFloat(readInt());
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.io.DataInput#readDouble()
+ */
+ @Override
+ public final double readDouble() throws IOException {
+ return Double.longBitsToDouble(readLong());
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.io.DataInput#readBoolean()
+ */
+ @Override
+ public boolean readBoolean() throws IOException {
+ return in.readBoolean();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.io.DataInput#readByte()
+ */
+ @Override
+ public byte readByte() throws IOException {
+ return in.readByte();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.io.DataInput#readFully(byte[])
+ */
+ @Override
+ public void readFully(byte[] b) throws IOException {
+ in.readFully(b);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.io.DataInput#readFully(byte[], int, int)
+ */
+ @Override
+ public void readFully(byte[] b, int off, int len) throws IOException {
+ in.readFully(b, off, len);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.io.DataInput#readLine()
+ */
+ @Override
+ @Deprecated
+ public String readLine() throws IOException {
+ return in.readLine();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.io.DataInput#readUTF()
+ */
+ @Override
+ public String readUTF() throws IOException {
+ return in.readUTF();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.io.DataInput#readUnsignedByte()
+ */
+ @Override
+ public int readUnsignedByte() throws IOException {
+ return in.readUnsignedByte();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.io.DataInput#skipBytes(int)
+ */
+ @Override
+ public int skipBytes(int n) throws IOException {
+ return in.skipBytes(n);
+ }
+
+ /**
+ * Close this stream.
+ */
+ public void close() throws IOException {
+ in.close();
+ }
+
+ public final long readUnsignedInt() throws IOException {
+ in.readFully(buffer, 0, 4);
+ return (((buffer[3]) << 24 | (buffer[2] & 0xff) << 16 | (buffer[1] & 0xff) << 8 | (buffer[0] & 0xff)) & MasksGenerator.UNSIGNED_INT_MASK);
+ }
}
diff --git a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/utils/Messages.java b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/utils/Messages.java
new file mode 100644
index 0000000000..e3d07ed4c3
--- /dev/null
+++ b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/utils/Messages.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.internal.gcov.utils;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.linuxtools.internal.gcov.utils.messages"; //$NON-NLS-1$
+ public static String GcovStringReader_null_string;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/utils/STGcovProgramChecker.java b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/utils/STGcovProgramChecker.java
index 9e8ab64bc5..fde1aabfef 100644
--- a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/utils/STGcovProgramChecker.java
+++ b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/utils/STGcovProgramChecker.java
@@ -15,7 +15,6 @@ import java.io.IOException;
import java.util.WeakHashMap;
import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
-
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.Path;
import org.eclipse.linuxtools.binutils.utils.STNMFactory;
@@ -24,64 +23,62 @@ import org.eclipse.linuxtools.binutils.utils.STSymbolManager;
public class STGcovProgramChecker implements STNMSymbolsHandler {
- private boolean gcovFound = false;
- private long timestamp;
- private final static WeakHashMap<File, STGcovProgramChecker> map = new WeakHashMap<File, STGcovProgramChecker>();
-
- /** Private Constructor */
- private STGcovProgramChecker(long timestamp) {
- this.timestamp = timestamp;
- }
-
- private static STGcovProgramChecker getProgramChecker(IBinaryObject object, IProject project) throws IOException {
- File program = object.getPath().toFile();
- STGcovProgramChecker pg = map.get(program);
- if (pg == null) {
- pg = new STGcovProgramChecker(program.lastModified());
- STNMFactory.getNM(object.getCPU(), object.getPath().toOSString(), pg, project);
- map.put(program, pg);
- } else {
- long fileTime = program.lastModified();
- if (fileTime > pg.timestamp) {
- pg.timestamp = fileTime;
- pg.gcovFound = false;
- STNMFactory.getNM(object.getCPU(), object.getPath().toOSString(), pg, project);
- }
- }
- return pg;
- }
-
- public static boolean isGCovCompatible(String s, IProject project) throws IOException {
- IBinaryObject object = STSymbolManager.sharedInstance.getBinaryObject(new Path(s));
- if (object == null) return false;
- return isGCovCompatible(object, project);
- }
-
- public static boolean isGCovCompatible(IBinaryObject object, IProject project) throws IOException {
- STGcovProgramChecker pg = getProgramChecker(object, project);
- return pg.gcovFound;
- }
+ private boolean gcovFound = false;
+ private long timestamp;
+ private final static WeakHashMap<File, STGcovProgramChecker> map = new WeakHashMap<File, STGcovProgramChecker>();
+
+ /** Private Constructor */
+ private STGcovProgramChecker(long timestamp) {
+ this.timestamp = timestamp;
+ }
+
+ private static STGcovProgramChecker getProgramChecker(IBinaryObject object, IProject project) throws IOException {
+ File program = object.getPath().toFile();
+ STGcovProgramChecker pg = map.get(program);
+ if (pg == null) {
+ pg = new STGcovProgramChecker(program.lastModified());
+ STNMFactory.getNM(object.getCPU(), object.getPath().toOSString(), pg, project);
+ map.put(program, pg);
+ } else {
+ long fileTime = program.lastModified();
+ if (fileTime > pg.timestamp) {
+ pg.timestamp = fileTime;
+ pg.gcovFound = false;
+ STNMFactory.getNM(object.getCPU(), object.getPath().toOSString(), pg, project);
+ }
+ }
+ return pg;
+ }
+
+ public static boolean isGCovCompatible(String s, IProject project) throws IOException {
+ IBinaryObject object = STSymbolManager.sharedInstance.getBinaryObject(new Path(s));
+ if (object == null)
+ return false;
+ return isGCovCompatible(object, project);
+ }
+
+ public static boolean isGCovCompatible(IBinaryObject object, IProject project) throws IOException {
+ STGcovProgramChecker pg = getProgramChecker(object, project);
+ return pg.gcovFound;
+ }
+
+ @Override
+ public void foundBssSymbol(String symbol, String address) {
+ }
- @Override
- public void foundBssSymbol(String symbol, String address) {
- }
+ @Override
+ public void foundDataSymbol(String symbol, String address) {
+ }
- @Override
- public void foundDataSymbol(String symbol, String address) {
- }
+ @Override
+ public void foundTextSymbol(String symbol, String address) {
+ if ("gcov_read_words".equals(symbol) || "_gcov_read_words".equals(symbol)) { //$NON-NLS-1$//$NON-NLS-2$
+ gcovFound = true;
+ }
+ }
- @Override
- public void foundTextSymbol(String symbol, String address) {
- if ("gcov_read_words".equals(symbol) || "_gcov_read_words".equals(symbol))
- {
- gcovFound = true;
- }
- }
+ @Override
+ public void foundUndefSymbol(String symbol) {
+ }
- @Override
- public void foundUndefSymbol(String symbol) {
- }
-
-
-
}
diff --git a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/utils/messages.properties b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/utils/messages.properties
new file mode 100644
index 0000000000..9e4e7bdd05
--- /dev/null
+++ b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/utils/messages.properties
@@ -0,0 +1,11 @@
+###############################################################################
+# Copyright (c) 2013 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
+###############################################################################
+GcovStringReader_null_string=NULL string
diff --git a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/CovView.java b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/CovView.java
index 5faa8b835f..a5ae877cdf 100644
--- a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/CovView.java
+++ b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/CovView.java
@@ -38,6 +38,7 @@ import org.eclipse.linuxtools.internal.gcov.action.SwitchContentProviderAction;
import org.eclipse.linuxtools.internal.gcov.parser.CovManager;
import org.eclipse.linuxtools.internal.gcov.parser.SourceFile;
import org.eclipse.linuxtools.internal.gcov.view.annotatedsource.OpenSourceFileAction;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
@@ -52,97 +53,92 @@ import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
-
/**
* @author Xavier Raynaud <xavier.raynaud@st.com>
- *
*/
public class CovView extends AbstractSTDataView {
- private String defaultCSVPath = "gcov.csv"; //$NON-NLS-1$
+ private String defaultCSVPath = "gcov.csv"; //$NON-NLS-1$
- private Label label;
+ private Label label;
private Text fFilterText;
private TreeColumnViewerFilter fViewerFilter;
- private Action folderAction;
- private Action fileAction;
- private Action functionAction;
-
- /* (non-Javadoc)
- * @see org.eclipse.linuxtools.dataviewers.abstractview.AbstractSTDataView#createAbstractSTViewer
- * (org.eclipse.swt.widgets.Composite)
- */
- @Override
- protected AbstractSTViewer createAbstractSTViewer(Composite parent) {
- return new CovViewer(parent);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.linuxtools.dataviewers.abstractview.AbstractSTDataViewer#contributeToToolbar(org.eclipse.jface.action.IToolBarManager)
- */
- @Override
- protected void contributeToToolbar(IToolBarManager manager) {
- manager.add(new Separator());
- manager.add(new Separator());
- manager.add(folderAction);
- manager.add(fileAction);
- manager.add(functionAction);
- manager.add(new Separator());
- manager.add(new ChartAction(getViewSite().getShell(), getSTViewer()));
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.linuxtools.dataviewers.abstractview.AbstractSTDataViewer#createActions()
- */
- @Override
- protected void createActions() {
- super.createActions();
- folderAction = new SwitchContentProviderAction(
- Messages.CovView_sort_coverage_per_folder,
- "icons/directory_obj.gif", //$NON-NLS-1$
- getSTViewer().getViewer(),
- CovFolderContentProvider.sharedInstance);
-
- fileAction = new SwitchContentProviderAction(
- Messages.CovView_sort_coverage_per_file,
- "icons/c_file_obj.gif", //$NON-NLS-1$
- getSTViewer().getViewer(),
- CovFileContentProvider.sharedInstance);
- fileAction.setChecked(true);
-
- functionAction = new SwitchContentProviderAction(
- Messages.CovView_sort_coverage_per_function,
- "icons/function_obj.gif", //$NON-NLS-1$
- getSTViewer().getViewer(),
- CovFunctionContentProvider.sharedInstance);
- }
-
- /**
- * This is a callback that will allow us
- * to create the viewer and initialize it.
- */
- @Override
- public void createPartControl(Composite parent) {
- super.createPartControl(parent);
- GridLayout l = (GridLayout) parent.getLayout();
- l.horizontalSpacing = 0;
- l.verticalSpacing = 0;
- l.marginHeight = 0;
- l.marginWidth = 0;
- fViewerFilter = new TreeColumnViewerFilter((TreeViewer) getSTViewer().getViewer(), getSTViewer().getAllFields()[0], true);
- getSTViewer().getViewer().addFilter(fViewerFilter);
- }
-
- @Override
- protected void createTitle(Composite parent) {
- label = new Label(parent, SWT.WRAP);
- GridData data = new GridData(SWT.FILL, SWT.BEGINNING, true, false, 1, 1);
- label.setLayoutData(data);
-
- fFilterText = new Text(parent, SWT.BORDER | SWT.SINGLE | SWT.SEARCH | SWT.ICON_SEARCH
- | SWT.ICON_CANCEL);
- fFilterText.setMessage(Messages.CovView_type_filter_text);
+ private Action folderAction;
+ private Action fileAction;
+ private Action functionAction;
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractview.AbstractSTDataView#createAbstractSTViewer
+ * (org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected AbstractSTViewer createAbstractSTViewer(Composite parent) {
+ return new CovViewer(parent);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * org.eclipse.linuxtools.dataviewers.abstractview.AbstractSTDataViewer#contributeToToolbar(org.eclipse.jface.action
+ * .IToolBarManager)
+ */
+ @Override
+ protected void contributeToToolbar(IToolBarManager manager) {
+ manager.add(new Separator());
+ manager.add(new Separator());
+ manager.add(folderAction);
+ manager.add(fileAction);
+ manager.add(functionAction);
+ manager.add(new Separator());
+ manager.add(new ChartAction(getViewSite().getShell(), getSTViewer()));
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractview.AbstractSTDataViewer#createActions()
+ */
+ @Override
+ protected void createActions() {
+ super.createActions();
+ folderAction = new SwitchContentProviderAction(Messages.CovView_sort_coverage_per_folder,
+ "icons/directory_obj.gif", //$NON-NLS-1$
+ getSTViewer().getViewer(), CovFolderContentProvider.sharedInstance);
+
+ fileAction = new SwitchContentProviderAction(Messages.CovView_sort_coverage_per_file, "icons/c_file_obj.gif", //$NON-NLS-1$
+ getSTViewer().getViewer(), CovFileContentProvider.sharedInstance);
+ fileAction.setChecked(true);
+
+ functionAction = new SwitchContentProviderAction(Messages.CovView_sort_coverage_per_function,
+ "icons/function_obj.gif", //$NON-NLS-1$
+ getSTViewer().getViewer(), CovFunctionContentProvider.sharedInstance);
+ }
+
+ /**
+ * This is a callback that will allow us to create the viewer and initialize it.
+ */
+ @Override
+ public void createPartControl(Composite parent) {
+ super.createPartControl(parent);
+ GridLayout l = (GridLayout) parent.getLayout();
+ l.horizontalSpacing = 0;
+ l.verticalSpacing = 0;
+ l.marginHeight = 0;
+ l.marginWidth = 0;
+ fViewerFilter = new TreeColumnViewerFilter((TreeViewer) getSTViewer().getViewer(),
+ getSTViewer().getAllFields()[0], true);
+ getSTViewer().getViewer().addFilter(fViewerFilter);
+ }
+
+ @Override
+ protected void createTitle(Composite parent) {
+ label = new Label(parent, SWT.WRAP);
+ GridData data = new GridData(SWT.FILL, SWT.BEGINNING, true, false, 1, 1);
+ label.setLayoutData(data);
+
+ fFilterText = new Text(parent, SWT.BORDER | SWT.SINGLE | SWT.SEARCH | SWT.ICON_SEARCH | SWT.ICON_CANCEL);
+ fFilterText.setMessage(Messages.CovView_type_filter_text);
fFilterText.setToolTipText(Messages.CovView_filter_by_name);
fFilterText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
fFilterText.addModifyListener(new ModifyListener() {
@@ -152,140 +148,134 @@ public class CovView extends AbstractSTDataView {
fViewerFilter.setMatchingText(text);
}
});
- }
-
- public static void setCovViewTitle(CovView view, String title,
- String binaryPath) {
- view.label.setText(" \n program runs = " + title
- + " \n program file : " + binaryPath + "\n ");
- view.label.getParent().layout(true);
- }
-
-
- public static void displayCovDetailedResult(String binaryPath, String gcdaFile) {
- try {
- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- IFile binary = root.getFileForLocation(new Path(binaryPath));
- IProject project = null;
- if (binary != null) project = binary.getProject();
-
- // parse and process coverage data
- CovManager cvrgeMnger = new CovManager(binaryPath, project);
- List<String> gcdaPaths = new LinkedList<String>();
- gcdaPaths.add(gcdaFile);
- cvrgeMnger.processCovFiles(gcdaPaths, gcdaFile);
- // generate model for view
- cvrgeMnger.fillGcovView();
-
- for (SourceFile sf : cvrgeMnger.getSourceMap().values()) {
- OpenSourceFileAction.sharedInstance.openAnnotatedSourceFile(project,
- binary, sf, 0);
- }
- } catch (CoreException e) {
- reportError(e);
- } catch (IOException e) {
- reportError(e);
- }
- }
-
- public static CovView displayCovResults(String binaryPath, String gcda) {
- try {
-
- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- IFile binary = root.getFileForLocation(new Path(binaryPath));
- IProject project = null;
- if (binary != null) project = binary.getProject();
-
- // parse and process coverage data
- CovManager cvrgeMnger = new CovManager(binaryPath, project);
- List<String> gcdaPaths = cvrgeMnger.getGCDALocations();
- cvrgeMnger.processCovFiles(gcdaPaths, gcda);
- // generate model for view
- cvrgeMnger.fillGcovView();
- //load an Eclipse view
- CovView cvrgeView = displayCovResults(cvrgeMnger);
- return cvrgeView;
- } catch (InterruptedException e) {
- reportError(e);
- } catch (IOException e) {
- reportError(e);
- } catch (CoreException e) {
- reportError(e);
- }
- return null;
- }
-
- private static void reportError(Exception _) {
- final String message = "An error has occured when parsing "
- + "the coverage data files :\n" + _.getMessage();
- Status status = new Status(IStatus.ERROR, Activator.PLUGIN_ID,
- IStatus.ERROR, message, _);
-
- Activator.getDefault().getLog().log(status);
- PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- Shell s = PlatformUI.getWorkbench().getDisplay().getActiveShell();
- MessageDialog.openError(s, "Gcov Parsing Error", message);
- }
- });
- }
-
- /**
- * Used by Test engine and OpenSerAction
- * @param cvrgeMnger
- */
- public static CovView displayCovResults(CovManager cvrgeMnger) throws PartInitException {
- //load an Eclipse view
- IWorkbenchWindow window = PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow();
- IWorkbenchPage page = window.getActivePage();
- CovView cvrgeView = (CovView) page.showView("org.eclipse.linuxtools.gcov.view"); //$NON-NLS-1$
-
- //view title
- CovView.setCovViewTitle(cvrgeView, Integer
- .toString((int) cvrgeMnger.getNbrPgmRuns()), cvrgeMnger
- .getBinaryPath());
-
- // load the controller
- cvrgeView.setInput(cvrgeMnger);
- CovViewer stviewer = (CovViewer) cvrgeView.getSTViewer();
- stviewer.getViewer().expandToLevel(2);
- return cvrgeView;
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.linuxtools.dataviewers.abstractview.AbstractSTDataView#createExportToCSVAction()
- */
- @Override
- protected IAction createExportToCSVAction() {
- IAction action = new STExportToCSVAction(this.getSTViewer()) {
- @Override
- public void run() {
- Object o = getSTViewer().getInput();
- if (o instanceof CovManager) {
- getExporter().setFilePath(getDefaultCSVPath());
- }
- super.run();
- }
-
- };
- return action;
- }
-
- /**
- * @return the defaultCSVPath
- */
- public String getDefaultCSVPath() {
- return defaultCSVPath;
- }
-
- /**
- * @param defaultCSVPath the defaultCSVPath to set
- */
- public void setDefaultCSVPath(String defaultCSVPath) {
- this.defaultCSVPath = defaultCSVPath;
- }
+ }
+
+ public static void setCovViewTitle(CovView view, String title, String binaryPath) {
+ String viewText = NLS.bind(Messages.CovView_view_title, new Object[] { title, binaryPath });
+ view.label.setText(viewText);
+ view.label.getParent().layout(true);
+ }
+
+ public static void displayCovDetailedResult(String binaryPath, String gcdaFile) {
+ try {
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ IFile binary = root.getFileForLocation(new Path(binaryPath));
+ IProject project = null;
+ if (binary != null)
+ project = binary.getProject();
+
+ // parse and process coverage data
+ CovManager cvrgeMnger = new CovManager(binaryPath, project);
+ List<String> gcdaPaths = new LinkedList<String>();
+ gcdaPaths.add(gcdaFile);
+ cvrgeMnger.processCovFiles(gcdaPaths, gcdaFile);
+ // generate model for view
+ cvrgeMnger.fillGcovView();
+
+ for (SourceFile sf : cvrgeMnger.getSourceMap().values()) {
+ OpenSourceFileAction.sharedInstance.openAnnotatedSourceFile(project, binary, sf, 0);
+ }
+ } catch (CoreException e) {
+ reportError(e);
+ } catch (IOException e) {
+ reportError(e);
+ }
+ }
+
+ public static CovView displayCovResults(String binaryPath, String gcda) {
+ try {
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ IFile binary = root.getFileForLocation(new Path(binaryPath));
+ IProject project = null;
+ if (binary != null)
+ project = binary.getProject();
+
+ // parse and process coverage data
+ CovManager cvrgeMnger = new CovManager(binaryPath, project);
+ List<String> gcdaPaths = cvrgeMnger.getGCDALocations();
+ cvrgeMnger.processCovFiles(gcdaPaths, gcda);
+ // generate model for view
+ cvrgeMnger.fillGcovView();
+ // load an Eclipse view
+ CovView cvrgeView = displayCovResults(cvrgeMnger);
+ return cvrgeView;
+ } catch (InterruptedException e) {
+ reportError(e);
+ } catch (IOException e) {
+ reportError(e);
+ } catch (CoreException e) {
+ reportError(e);
+ }
+ return null;
+ }
+
+ private static void reportError(Exception ex) {
+ final String message = NLS.bind(Messages.CovView_error_message, ex.getMessage());
+ Status status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, message, ex);
+
+ Activator.getDefault().getLog().log(status);
+ PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ Shell s = PlatformUI.getWorkbench().getDisplay().getActiveShell();
+ MessageDialog.openError(s, Messages.CovView_parsing_error, message);
+ }
+ });
+ }
+
+ /**
+ * Used by Test engine and OpenSerAction
+ * @param cvrgeMnger
+ */
+ public static CovView displayCovResults(CovManager cvrgeMnger) throws PartInitException {
+ // load an Eclipse view
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ IWorkbenchPage page = window.getActivePage();
+ CovView cvrgeView = (CovView) page.showView("org.eclipse.linuxtools.gcov.view"); //$NON-NLS-1$
+
+ // view title
+ CovView.setCovViewTitle(cvrgeView, Integer.toString((int) cvrgeMnger.getNbrPgmRuns()),
+ cvrgeMnger.getBinaryPath());
+
+ // load the controller
+ cvrgeView.setInput(cvrgeMnger);
+ CovViewer stviewer = (CovViewer) cvrgeView.getSTViewer();
+ stviewer.getViewer().expandToLevel(2);
+ return cvrgeView;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractview.AbstractSTDataView#createExportToCSVAction()
+ */
+ @Override
+ protected IAction createExportToCSVAction() {
+ IAction action = new STExportToCSVAction(this.getSTViewer()) {
+ @Override
+ public void run() {
+ Object o = getSTViewer().getInput();
+ if (o instanceof CovManager) {
+ getExporter().setFilePath(getDefaultCSVPath());
+ }
+ super.run();
+ }
+ };
+ return action;
+ }
+
+ /**
+ * @return the defaultCSVPath
+ */
+ public String getDefaultCSVPath() {
+ return defaultCSVPath;
+ }
+
+ /**
+ * @param defaultCSVPath
+ * the defaultCSVPath to set
+ */
+ public void setDefaultCSVPath(String defaultCSVPath) {
+ this.defaultCSVPath = defaultCSVPath;
+ }
}
diff --git a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/FieldCoveragePercentage.java b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/FieldCoveragePercentage.java
index 007ef1a634..8977bfc9ff 100644
--- a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/FieldCoveragePercentage.java
+++ b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/FieldCoveragePercentage.java
@@ -17,88 +17,86 @@ import org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractPercentageDraw
import org.eclipse.linuxtools.dataviewers.charts.provider.IChartField;
import org.eclipse.linuxtools.internal.gcov.model.CovRootTreeElement;
import org.eclipse.linuxtools.internal.gcov.model.TreeElement;
-
-
+import org.eclipse.osgi.util.NLS;
public class FieldCoveragePercentage extends AbstractPercentageDrawerField implements IChartField {
- public final static NumberFormat nf = new DecimalFormat("##0.0#"); //$NON-NLS-1$
-
-
- @Override
- public String getColumnHeaderText() {
- return "Coverage %";
- }
-
- @Override
- public String getValue(Object obj) {
- float f = getPercentage(obj);
- if (f < 0)
- f = 0.0f;
- return nf.format(f);
- }
-
-
- /**
- * Gets the percentage value to display
- * @param obj
- * @return the percentage value to display, as a float
- */
- @Override
- public float getPercentage(Object obj) {
- TreeElement e = (TreeElement) obj;
- return e.getCoveragePercentage();
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractPercentageDrawerField#getNumberFormat()
- */
- @Override
- public NumberFormat getNumberFormat() {
- return nf;
- }
-
- @Override
- public boolean isSettedNumberFormat() {
- return true;
- }
-
- @Override
- public String getToolTipText(Object element) {
- TreeElement e = (TreeElement) element;
- String s =" Coverage % = "+Integer.toString((int)e.getCoveragePercentage());
- return s ;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField#compare(java.lang.Object, java.lang.Object)
- */
- @Override
- public int compare(Object obj1, Object obj2) {
- TreeElement e1 = (TreeElement) obj1;
- TreeElement e2 = (TreeElement) obj2;
- float f1 = e1.getCoveragePercentage();
- float f2 = e2.getCoveragePercentage();
- return Float.compare(f1, f2);
- }
-
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.dataviewers.charts.provider.IChartField#getNumber(java.lang.Object)
- */
- @Override
- public Number getNumber(Object obj) {
- TreeElement e = (TreeElement) obj;
- float f = getPercentage(obj);
- if (e.getClass() == CovRootTreeElement.class)
- return 0;
- else {
- if (f < 0)
- f = 0.0f;
- return f;
- }
- }
+ public final static NumberFormat nf = new DecimalFormat("##0.0#"); //$NON-NLS-1$
+
+ @Override
+ public String getColumnHeaderText() {
+ return Messages.FieldCoveragePercentage_column_header;
+ }
+
+ @Override
+ public String getValue(Object obj) {
+ float f = getPercentage(obj);
+ if (f < 0)
+ f = 0.0f;
+ return nf.format(f);
+ }
+
+ /**
+ * Gets the percentage value to display
+ * @param obj
+ * @return the percentage value to display, as a float
+ */
+ @Override
+ public float getPercentage(Object obj) {
+ TreeElement e = (TreeElement) obj;
+ return e.getCoveragePercentage();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractPercentageDrawerField#getNumberFormat()
+ */
+ @Override
+ public NumberFormat getNumberFormat() {
+ return nf;
+ }
+
+ @Override
+ public boolean isSettedNumberFormat() {
+ return true;
+ }
+
+ @Override
+ public String getToolTipText(Object element) {
+ TreeElement e = (TreeElement) element;
+ String s = NLS.bind(Messages.FieldCoveragePercentage_column_tooltip,
+ Integer.toString((int) e.getCoveragePercentage()));
+ return s;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField#compare(java.lang.Object,
+ * java.lang.Object)
+ */
+ @Override
+ public int compare(Object obj1, Object obj2) {
+ TreeElement e1 = (TreeElement) obj1;
+ TreeElement e2 = (TreeElement) obj2;
+ float f1 = e1.getCoveragePercentage();
+ float f2 = e2.getCoveragePercentage();
+ return Float.compare(f1, f2);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.charts.provider.IChartField#getNumber(java.lang.Object)
+ */
+ @Override
+ public Number getNumber(Object obj) {
+ TreeElement e = (TreeElement) obj;
+ float f = getPercentage(obj);
+ if (e.getClass() == CovRootTreeElement.class)
+ return 0;
+ else {
+ if (f < 0)
+ f = 0.0f;
+ return f;
+ }
+ }
}
diff --git a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/FieldExecutedLines.java b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/FieldExecutedLines.java
index 070e6d8b69..ba1267261f 100644
--- a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/FieldExecutedLines.java
+++ b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/FieldExecutedLines.java
@@ -16,59 +16,61 @@ import org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTDataViewersF
import org.eclipse.linuxtools.dataviewers.charts.provider.IChartField;
import org.eclipse.linuxtools.internal.gcov.model.TreeElement;
+public class FieldExecutedLines extends AbstractSTDataViewersField implements IChartField {
-public class FieldExecutedLines extends AbstractSTDataViewersField implements IChartField{
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField#getColumnHeaderText()
+ */
+ @Override
+ public String getColumnHeaderText() {
+ return Messages.FieldExecutedLines_column_header;
+ }
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField#getColumnHeaderText()
- */
- @Override
- public String getColumnHeaderText() {
- return "Executed Lines";
- }
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField#getValue(java.lang.Object)
+ */
+ @Override
+ public String getValue(Object obj) {
+ int v = getExecutedLines(obj);
+ return NumberFormat.getInstance().format(v);
+ }
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField#getValue(java.lang.Object)
- */
- @Override
- public String getValue(Object obj) {
- int v = getExecutedLines(obj);
- return NumberFormat.getInstance().format(v);
- }
+ @Override
+ public String getToolTipText(Object element) {
+ int v = getExecutedLines(element);
+ String s = NumberFormat.getInstance().format(v);
+ s += Messages.FieldExecutedLines_column_tooltip;
+ if (v > 1)
+ s += "s"; //$NON-NLS-1$
+ return s;
+ }
- @Override
- public String getToolTipText(Object element) {
- int v = getExecutedLines(element);
- String s = NumberFormat.getInstance().format(v);
- s += " executed line";
- if (v > 1) s += "s";
- return s;
- }
+ @Override
+ public int compare(Object obj1, Object obj2) {
+ int i1 = getExecutedLines(obj1);
+ int i2 = getExecutedLines(obj2);
+ if (i1 > i2)
+ return 1;
+ if (i1 < i2)
+ return -1;
+ return 0;
+ }
- @Override
- public int compare(Object obj1, Object obj2) {
- int i1 = getExecutedLines(obj1);
- int i2 = getExecutedLines(obj2);
- if (i1>i2) return 1;
- if (i1<i2) return -1;
- return 0;
- }
-
- private int getExecutedLines(Object o) {
- if (o instanceof TreeElement) {
- return ((TreeElement) o).getExecutedLines();
- }
- return 0;
- }
+ private int getExecutedLines(Object o) {
+ if (o instanceof TreeElement) {
+ return ((TreeElement) o).getExecutedLines();
+ }
+ return 0;
+ }
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.dataviewers.charts.provider.IChartField#getNumber(java.lang.Object)
- */
- @Override
- public Integer getNumber(Object obj) {
- return getExecutedLines(obj);
- }
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.charts.provider.IChartField#getNumber(java.lang.Object)
+ */
+ @Override
+ public Integer getNumber(Object obj) {
+ return getExecutedLines(obj);
+ }
}
diff --git a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/FieldInstrumentedLines.java b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/FieldInstrumentedLines.java
index e456f871c2..20dd172781 100644
--- a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/FieldInstrumentedLines.java
+++ b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/FieldInstrumentedLines.java
@@ -16,57 +16,58 @@ import org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTDataViewersF
import org.eclipse.linuxtools.dataviewers.charts.provider.IChartField;
import org.eclipse.linuxtools.internal.gcov.model.TreeElement;
+public class FieldInstrumentedLines extends AbstractSTDataViewersField implements IChartField {
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField#getColumnHeaderText()
+ */
+ @Override
+ public String getColumnHeaderText() {
+ return Messages.FieldInstrumentedLines_column_header;
+ }
-public class FieldInstrumentedLines extends AbstractSTDataViewersField implements IChartField{
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField#getColumnHeaderText()
- */
- @Override
- public String getColumnHeaderText() {
- return "Instrumented Lines";
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField#getValue(java.lang.Object)
- */
- @Override
- public String getValue(Object obj) {
- int v = getInstrumentedLines(obj);
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField#getValue(java.lang.Object)
+ */
+ @Override
+ public String getValue(Object obj) {
+ int v = getInstrumentedLines(obj);
return NumberFormat.getInstance().format(v);
- }
-
+ }
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTDataViewersField#getToolTipText(java.lang.Object)
- */
- @Override
- public String getToolTipText(Object element) {
- int v = getInstrumentedLines(element);
+ /*
+ * (non-Javadoc)
+ * @see
+ * org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTDataViewersField#getToolTipText(java.lang.Object)
+ */
+ @Override
+ public String getToolTipText(Object element) {
+ int v = getInstrumentedLines(element);
String s = NumberFormat.getInstance().format(v);
- s += " instrumented line";
- if (v > 1) s += "s";
- return s;
- }
-
+ s += Messages.FieldInstrumentedLines_column_tooltip;
+ if (v > 1)
+ s += "s"; //$NON-NLS-1$
+ return s;
+ }
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField#compare(java.lang.Object, java.lang.Object)
- */
- @Override
- public int compare(Object obj1, Object obj2) {
- int i1 = getInstrumentedLines(obj1);
- int i2 = getInstrumentedLines(obj2);
- if (i1>i2) return 1;
- if (i1<i2) return -1;
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField#compare(java.lang.Object,
+ * java.lang.Object)
+ */
+ @Override
+ public int compare(Object obj1, Object obj2) {
+ int i1 = getInstrumentedLines(obj1);
+ int i2 = getInstrumentedLines(obj2);
+ if (i1 > i2)
+ return 1;
+ if (i1 < i2)
+ return -1;
return 0;
- }
-
+ }
+
private int getInstrumentedLines(Object o) {
if (o instanceof TreeElement) {
return ((TreeElement) o).getInstrumentedLines();
@@ -74,13 +75,13 @@ public class FieldInstrumentedLines extends AbstractSTDataViewersField implement
return 0;
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.dataviewers.charts.provider.IChartField#getNumber(java.lang.Object)
- */
- @Override
- public Integer getNumber(Object obj) {
- return getInstrumentedLines(obj);
- }
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.charts.provider.IChartField#getNumber(java.lang.Object)
+ */
+ @Override
+ public Integer getNumber(Object obj) {
+ return getInstrumentedLines(obj);
+ }
}
diff --git a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/FieldName.java b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/FieldName.java
index 2810420a36..6744fde1bb 100644
--- a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/FieldName.java
+++ b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/FieldName.java
@@ -15,60 +15,62 @@ import org.eclipse.linuxtools.internal.gcov.model.TreeElement;
public class FieldName extends AbstractSTDataViewersField {
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField#getColumnHeaderText()
- */
- @Override
- public String getColumnHeaderText() {
- return "Name";
- }
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField#getColumnHeaderText()
+ */
+ @Override
+ public String getColumnHeaderText() {
+ return Messages.FieldName_column_header;
+ }
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField#getValue(java.lang.Object)
- */
- @Override
- public String getValue(Object obj) {
- if (obj instanceof TreeElement) {
- TreeElement e = (TreeElement) obj;
- String nm = e.getName();
- nm = nm.substring(nm.lastIndexOf('/')+1);
- nm = nm.substring(nm.lastIndexOf('\\')+1);
- return nm;
- }
- return ""; //$NON-NLS-1$
- }
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField#getValue(java.lang.Object)
+ */
+ @Override
+ public String getValue(Object obj) {
+ if (obj instanceof TreeElement) {
+ TreeElement e = (TreeElement) obj;
+ String nm = e.getName();
+ nm = nm.substring(nm.lastIndexOf('/') + 1);
+ nm = nm.substring(nm.lastIndexOf('\\') + 1);
+ return nm;
+ }
+ return ""; //$NON-NLS-1$
+ }
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTDataViewersField#getToolTipText(java.lang.Object)
- */
- @Override
- public String getToolTipText(Object element) {
+ /*
+ * (non-Javadoc)
+ * @see
+ * org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTDataViewersField#getToolTipText(java.lang.Object)
+ */
+ @Override
+ public String getToolTipText(Object element) {
if (element instanceof TreeElement) {
TreeElement elem = (TreeElement) element;
String s = elem.getName();
return s;
}
return ""; //$NON-NLS-1$
- }
+ }
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField#compare(java.lang.Object, java.lang.Object)
- */
- @Override
- public int compare(Object obj1, Object obj2) {
- String s1 = getValue(obj1);
- String s2 = getValue(obj2);
- if (s1 == null) {
- if (s2 == null)
- return 0;
- return -1;
- }
- if (s2 == null)
- return 1;
- return s1.compareTo(s2);
- }
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField#compare(java.lang.Object,
+ * java.lang.Object)
+ */
+ @Override
+ public int compare(Object obj1, Object obj2) {
+ String s1 = getValue(obj1);
+ String s2 = getValue(obj2);
+ if (s1 == null) {
+ if (s2 == null)
+ return 0;
+ return -1;
+ }
+ if (s2 == null)
+ return 1;
+ return s1.compareTo(s2);
+ }
}
diff --git a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/FieldTotalLines.java b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/FieldTotalLines.java
index 4bd3f36c5c..b589a3923a 100644
--- a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/FieldTotalLines.java
+++ b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/FieldTotalLines.java
@@ -10,69 +10,74 @@
*******************************************************************************/
package org.eclipse.linuxtools.internal.gcov.view;
-
import java.text.NumberFormat;
import org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTDataViewersField;
import org.eclipse.linuxtools.internal.gcov.model.TreeElement;
-
-
+import org.eclipse.osgi.util.NLS;
public class FieldTotalLines extends AbstractSTDataViewersField {
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField#getColumnHeaderText()
- */
- @Override
- public String getColumnHeaderText() {
- return "Total Lines";
- }
-
- private int getTotalLines(Object element) {
- if (element instanceof TreeElement) {
- return ((TreeElement) element).getTotalLines();
- }
- return -1;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField#getValue(java.lang.Object)
- */
- @Override
- public String getValue(Object obj) {
- int v = getTotalLines(obj);
- if (v < 0) return ""; //$NON-NLS-1$
- return NumberFormat.getInstance().format(v);
- }
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField#getColumnHeaderText()
+ */
+ @Override
+ public String getColumnHeaderText() {
+ return Messages.FieldTotalLines_column_header;
+ }
+ private int getTotalLines(Object element) {
+ if (element instanceof TreeElement) {
+ return ((TreeElement) element).getTotalLines();
+ }
+ return -1;
+ }
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTDataViewersField#getToolTipText(java.lang.Object)
- */
- @Override
- public String getToolTipText(Object element) {
- int v = getTotalLines(element);
- if (v < 0) return null;
- String s = NumberFormat.getInstance().format(v);
- s += " line";
- if (v>1) s+= "s";
- s += " in total";
- return s;
- }
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField#getValue(java.lang.Object)
+ */
+ @Override
+ public String getValue(Object obj) {
+ int v = getTotalLines(obj);
+ if (v < 0)
+ return ""; //$NON-NLS-1$
+ return NumberFormat.getInstance().format(v);
+ }
+ /*
+ * (non-Javadoc)
+ * @see
+ * org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTDataViewersField#getToolTipText(java.lang.Object)
+ */
+ @Override
+ public String getToolTipText(Object element) {
+ int v = getTotalLines(element);
+ if (v < 0)
+ return null;
+ String s = NumberFormat.getInstance().format(v);
+ String message;
+ if (v > 1) {
+ message = NLS.bind(Messages.FieldTotalLines_column_tooltip_1, s);
+ } else {
+ message = NLS.bind(Messages.FieldTotalLines_column_tooltip_0, s);
+ }
+ return message;
+ }
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField#compare(java.lang.Object, java.lang.Object)
- */
- @Override
- public int compare(Object obj1, Object obj2) {
- int i1 = getTotalLines(obj1);
- int i2 = getTotalLines(obj2);
- if (i1>i2) return 1;
- if (i1<i2) return -1;
- return 0;
- }
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField#compare(java.lang.Object,
+ * java.lang.Object)
+ */
+ @Override
+ public int compare(Object obj1, Object obj2) {
+ int i1 = getTotalLines(obj1);
+ int i2 = getTotalLines(obj2);
+ if (i1 > i2)
+ return 1;
+ if (i1 < i2)
+ return -1;
+ return 0;
+ }
}
diff --git a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/Messages.java b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/Messages.java
index 8a8acb2544..d166ae088a 100644
--- a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/Messages.java
+++ b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/Messages.java
@@ -15,10 +15,24 @@ import org.eclipse.osgi.util.NLS;
public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.linuxtools.internal.gcov.view.messages"; //$NON-NLS-1$
public static String CovView_filter_by_name;
+ public static String CovView_parsing_error;
public static String CovView_sort_coverage_per_file;
public static String CovView_sort_coverage_per_folder;
public static String CovView_sort_coverage_per_function;
public static String CovView_type_filter_text;
+ public static String CovView_view_title;
+ public static String CovView_error_message;
+ public static String FieldCoveragePercentage_column_header;
+ public static String FieldCoveragePercentage_column_tooltip;
+ public static String FieldExecutedLines_column_header;
+ public static String FieldExecutedLines_column_tooltip;
+ public static String FieldInstrumentedLines_column_header;
+ public static String FieldInstrumentedLines_column_tooltip;
+ public static String FieldName_column_header;
+ public static String FieldTotalLines_column_header;
+ public static String FieldTotalLines_column_tooltip_0;
+ public static String FieldTotalLines_column_tooltip_1;
+
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
diff --git a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/annotatedsource/CoverageAnnotationColumn.java b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/annotatedsource/CoverageAnnotationColumn.java
index 6176b26601..8e159e69b1 100644
--- a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/annotatedsource/CoverageAnnotationColumn.java
+++ b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/annotatedsource/CoverageAnnotationColumn.java
@@ -10,53 +10,52 @@
*******************************************************************************/
package org.eclipse.linuxtools.internal.gcov.view.annotatedsource;
-
import java.util.ArrayList;
import org.eclipse.linuxtools.dataviewers.annotatedsourceeditor.ISTAnnotationColumn;
import org.eclipse.linuxtools.internal.gcov.parser.Line;
import org.eclipse.linuxtools.internal.gcov.parser.SourceFile;
-
+import org.eclipse.osgi.util.NLS;
public class CoverageAnnotationColumn implements ISTAnnotationColumn {
-
- private final ArrayList<Line> lines;
-
- public CoverageAnnotationColumn(SourceFile sourceFile) {
- lines = sourceFile.getLines();
- }
-
- @Override
- public String getAnnotation(int index) {
- try {
- Line l = lines.get(index+1);
- if (l.exists()) {
- return Long.toString(l.getCount());
- }
- } catch (IndexOutOfBoundsException _) {
- //ignore as empty string will be returned anyway
- }
- return ""; //$NON-NLS-1$
- }
-
- @Override
- public String getTooltip(int index) {
- try {
- Line l = lines.get(index+1);
- if (!l.exists()) {
- return "non executable line";
- } else {
- long count = l.getCount();
- if (count == 0) return "line never executed";
- if (count == 1) return "line executed 1 time";
- return "line executed "
- + Long.toString(count)
- + " times";
- }
- } catch (IndexOutOfBoundsException _) {
- return "non executable line";
- }
- }
+ private final ArrayList<Line> lines;
+
+ public CoverageAnnotationColumn(SourceFile sourceFile) {
+ lines = sourceFile.getLines();
+ }
+
+ @Override
+ public String getAnnotation(int index) {
+ try {
+ Line l = lines.get(index + 1);
+ if (l.exists()) {
+ return Long.toString(l.getCount());
+ }
+ } catch (IndexOutOfBoundsException _) {
+ // ignore as empty string will be returned anyway
+ }
+ return ""; //$NON-NLS-1$
+ }
+
+ @Override
+ public String getTooltip(int index) {
+ try {
+ Line l = lines.get(index + 1);
+ if (!l.exists()) {
+ return Messages.CoverageAnnotationColumn_non_exec_line;
+ } else {
+ long count = l.getCount();
+ if (count == 0) {
+ return Messages.CoverageAnnotationColumn_line_never_exec;
+ } else if (count == 1) {
+ return Messages.CoverageAnnotationColumn_line_exec_once;
+ }
+ return NLS.bind(Messages.CoverageAnnotationColumn_line_mulitiple_exec, Long.toString(count));
+ }
+ } catch (IndexOutOfBoundsException _) {
+ return Messages.CoverageAnnotationColumn_non_exec_line;
+ }
+ }
}
diff --git a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/annotatedsource/Messages.java b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/annotatedsource/Messages.java
new file mode 100644
index 0000000000..cdb351f257
--- /dev/null
+++ b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/annotatedsource/Messages.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.internal.gcov.view.annotatedsource;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.linuxtools.internal.gcov.view.annotatedsource.messages"; //$NON-NLS-1$
+ public static String CoverageAnnotationColumn_line_mulitiple_exec;
+ public static String CoverageAnnotationColumn_line_exec_once;
+ public static String CoverageAnnotationColumn_line_never_exec;
+ public static String CoverageAnnotationColumn_non_exec_line;
+ public static String OpenSourceFileAction_open_error;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/annotatedsource/OpenSourceFileAction.java b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/annotatedsource/OpenSourceFileAction.java
index 544e86f5fc..fb9524fbcc 100644
--- a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/annotatedsource/OpenSourceFileAction.java
+++ b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/annotatedsource/OpenSourceFileAction.java
@@ -36,100 +36,92 @@ import org.eclipse.ui.PartInitException;
import org.eclipse.ui.texteditor.IDocumentProvider;
import org.eclipse.ui.texteditor.ITextEditor;
-
public class OpenSourceFileAction {
- /**
- * Shared instance of this class
- */
- public static final OpenSourceFileAction sharedInstance = new OpenSourceFileAction();
-
- private OpenSourceFileAction() {
- }
-
-
- // FIXME: move this method in binutils plugin.
- private IFileStore getFileStore(IProject project, IPath path) {
- IEditorInput input = STLink2SourceSupport.sharedInstance.getEditorInput(path, project);
- if (input instanceof IURIEditorInput) {
- IURIEditorInput editorInput = (IURIEditorInput) input;
- URI uri = editorInput.getURI();
- try {
- IFileStore fs = EFS.getStore(uri);
- return fs;
- } catch (CoreException _) {
- return null;
- }
- }
- return null;
- }
-
+ /**
+ * Shared instance of this class
+ */
+ public static final OpenSourceFileAction sharedInstance = new OpenSourceFileAction();
- private GcovSourceEditorInput getInput(SourceFile sourceFile,
- IFileStore fs) {
- GcovSourceEditorInput input = new GcovSourceEditorInput(
- fs, sourceFile);
- IWorkbenchPage p = CUIPlugin.getActivePage();
- IEditorPart editorPart = p.findEditor(input);
- if (editorPart != null)
- p.closeEditor(editorPart, false);
- return input;
- }
+ private OpenSourceFileAction() {
+ }
- public void openAnnotatedSourceFile(IProject project, IFile binary, SourceFile sourceFile, int lineNumber) {
- if (sourceFile == null) return;
- String pathName = sourceFile.getName();
- if (pathName == null) return;
- IPath path = new Path(pathName);
- openAnnotatedSourceFile(project, binary, sourceFile, path, lineNumber);
- }
+ // FIXME: move this method in binutils plugin.
+ private IFileStore getFileStore(IProject project, IPath path) {
+ IEditorInput input = STLink2SourceSupport.sharedInstance.getEditorInput(path, project);
+ if (input instanceof IURIEditorInput) {
+ IURIEditorInput editorInput = (IURIEditorInput) input;
+ URI uri = editorInput.getURI();
+ try {
+ IFileStore fs = EFS.getStore(uri);
+ return fs;
+ } catch (CoreException _) {
+ return null;
+ }
+ }
+ return null;
+ }
- public void openAnnotatedSourceFile(IProject project, IFile binary, SourceFile sourceFile, IPath realLocation, int lineNumber) {
- IWorkbenchPage page = CUIPlugin.getActivePage();
- if (page != null) {
- IFileStore fs = getFileStore(project, realLocation);
- if (fs == null && !realLocation.isAbsolute() && binary != null) {
- IPath p = binary.getProjectRelativePath().removeLastSegments(1);
- fs = getFileStore(project, p.append(realLocation));
- }
- if (fs == null) {
- try {
- page.openEditor(new STAnnotatedSourceNotFoundEditorInput(project,sourceFile,
- realLocation, lineNumber),
- STAnnotatedSourceNotFoundEditor.ID, true);
- } catch (PartInitException e) {
- Status s = new Status(IStatus.ERROR, Activator.PLUGIN_ID,
- IStatus.ERROR, "Error when opening annotated source view",
- e);
- Activator.getDefault().getLog().log(s);
- }
- } else {
- IEditorInput input = getInput(sourceFile, fs);
- try {
- IEditorPart editor = page.openEditor(input,
- AbstractOpenSourceFileAction.EDITOR_ID, true);
- if (lineNumber > 0 && editor instanceof ITextEditor) {
- IDocumentProvider provider = ((ITextEditor) editor).getDocumentProvider();
- IDocument document = provider.getDocument(editor.getEditorInput());
- try {
- int start = document.getLineOffset(lineNumber - 1);
- ((ITextEditor) editor).selectAndReveal(start, 0);
- } catch (BadLocationException _) {
- // ignore
- }
- IWorkbenchPage p = editor.getSite().getPage();
- p.activate(editor);
- }
- } catch (PartInitException e) {
- Status s = new Status(IStatus.ERROR, Activator.PLUGIN_ID,
- IStatus.ERROR, "Error when opening annotated source view",
- e);
- Activator.getDefault().getLog().log(s);
- }
- }
- }
- }
+ private GcovSourceEditorInput getInput(SourceFile sourceFile, IFileStore fs) {
+ GcovSourceEditorInput input = new GcovSourceEditorInput(fs, sourceFile);
+ IWorkbenchPage p = CUIPlugin.getActivePage();
+ IEditorPart editorPart = p.findEditor(input);
+ if (editorPart != null)
+ p.closeEditor(editorPart, false);
+ return input;
+ }
+ public void openAnnotatedSourceFile(IProject project, IFile binary, SourceFile sourceFile, int lineNumber) {
+ if (sourceFile == null)
+ return;
+ String pathName = sourceFile.getName();
+ if (pathName == null)
+ return;
+ IPath path = new Path(pathName);
+ openAnnotatedSourceFile(project, binary, sourceFile, path, lineNumber);
+ }
+ public void openAnnotatedSourceFile(IProject project, IFile binary, SourceFile sourceFile, IPath realLocation,
+ int lineNumber) {
+ IWorkbenchPage page = CUIPlugin.getActivePage();
+ if (page != null) {
+ IFileStore fs = getFileStore(project, realLocation);
+ if (fs == null && !realLocation.isAbsolute() && binary != null) {
+ IPath p = binary.getProjectRelativePath().removeLastSegments(1);
+ fs = getFileStore(project, p.append(realLocation));
+ }
+ if (fs == null) {
+ try {
+ page.openEditor(new STAnnotatedSourceNotFoundEditorInput(project, sourceFile, realLocation,
+ lineNumber), STAnnotatedSourceNotFoundEditor.ID, true);
+ } catch (PartInitException e) {
+ Status s = new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR,
+ Messages.OpenSourceFileAction_open_error, e);
+ Activator.getDefault().getLog().log(s);
+ }
+ } else {
+ IEditorInput input = getInput(sourceFile, fs);
+ try {
+ IEditorPart editor = page.openEditor(input, AbstractOpenSourceFileAction.EDITOR_ID, true);
+ if (lineNumber > 0 && editor instanceof ITextEditor) {
+ IDocumentProvider provider = ((ITextEditor) editor).getDocumentProvider();
+ IDocument document = provider.getDocument(editor.getEditorInput());
+ try {
+ int start = document.getLineOffset(lineNumber - 1);
+ ((ITextEditor) editor).selectAndReveal(start, 0);
+ } catch (BadLocationException _) {
+ // ignore
+ }
+ IWorkbenchPage p = editor.getSite().getPage();
+ p.activate(editor);
+ }
+ } catch (PartInitException e) {
+ Status s = new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR,
+ Messages.OpenSourceFileAction_open_error, e);
+ Activator.getDefault().getLog().log(s);
+ }
+ }
+ }
+ }
}
diff --git a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/annotatedsource/STAnnotatedSourceNotFoundEditor.java b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/annotatedsource/STAnnotatedSourceNotFoundEditor.java
index da1d1318e1..178aa9a7d2 100644
--- a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/annotatedsource/STAnnotatedSourceNotFoundEditor.java
+++ b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/annotatedsource/STAnnotatedSourceNotFoundEditor.java
@@ -17,35 +17,31 @@ import org.eclipse.linuxtools.binutils.link2source.STCSourceNotFoundEditor;
import org.eclipse.linuxtools.internal.gcov.parser.SourceFile;
import org.eclipse.ui.IEditorInput;
-
/**
* @author Xavier Raynaud <xavier.raynaud@st.com>
- *
*/
-public class STAnnotatedSourceNotFoundEditor extends
- STCSourceNotFoundEditor {
-
- public static final String ID = "org.eclipse.linuxtools.gcov.view.annotatedsource.STAnnotatedSourceNotFoundEditor";
+public class STAnnotatedSourceNotFoundEditor extends STCSourceNotFoundEditor {
+
+ public static final String ID = "org.eclipse.linuxtools.gcov.view.annotatedsource.STAnnotatedSourceNotFoundEditor"; //$NON-NLS-1$
+
+ public STAnnotatedSourceNotFoundEditor() {
+ }
- public STAnnotatedSourceNotFoundEditor() {
-
- }
-
-
-
- /* (non-Javadoc)
- * @see org.eclipse.linuxtools.binutils.link2source.STCSourceNotFoundEditor#openSourceFileAtLocation(org.eclipse.core.resources.IProject, org.eclipse.core.runtime.IPath, int)
- */
- @Override
- protected void openSourceFileAtLocation(IProject project, IPath sourceLoc,
- int lineNumber) {
- IEditorInput input = this.getEditorInput();
- if (input instanceof STAnnotatedSourceNotFoundEditorInput) {
- STAnnotatedSourceNotFoundEditorInput editorInput = (STAnnotatedSourceNotFoundEditorInput) input;
- SourceFile sf = editorInput.getSourceFile();
- OpenSourceFileAction.sharedInstance.openAnnotatedSourceFile(project, null, sf, sourceLoc, lineNumber);
- } else {
- super.openSourceFileAtLocation(project, sourceLoc, lineNumber);
- }
- }
+ /*
+ * (non-Javadoc)
+ * @see
+ * org.eclipse.linuxtools.binutils.link2source.STCSourceNotFoundEditor#openSourceFileAtLocation(org.eclipse.core
+ * .resources.IProject, org.eclipse.core.runtime.IPath, int)
+ */
+ @Override
+ protected void openSourceFileAtLocation(IProject project, IPath sourceLoc, int lineNumber) {
+ IEditorInput input = this.getEditorInput();
+ if (input instanceof STAnnotatedSourceNotFoundEditorInput) {
+ STAnnotatedSourceNotFoundEditorInput editorInput = (STAnnotatedSourceNotFoundEditorInput) input;
+ SourceFile sf = editorInput.getSourceFile();
+ OpenSourceFileAction.sharedInstance.openAnnotatedSourceFile(project, null, sf, sourceLoc, lineNumber);
+ } else {
+ super.openSourceFileAtLocation(project, sourceLoc, lineNumber);
+ }
+ }
}
diff --git a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/annotatedsource/messages.properties b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/annotatedsource/messages.properties
new file mode 100644
index 0000000000..ef9ab3f72f
--- /dev/null
+++ b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/annotatedsource/messages.properties
@@ -0,0 +1,15 @@
+###############################################################################
+# Copyright (c) 2013 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
+###############################################################################
+CoverageAnnotationColumn_line_mulitiple_exec=line executed {0} times
+CoverageAnnotationColumn_line_exec_once=line executed 1 time
+CoverageAnnotationColumn_line_never_exec=line never executed
+CoverageAnnotationColumn_non_exec_line=non executable line
+OpenSourceFileAction_open_error=Error when opening annotated source view
diff --git a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/messages.properties b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/messages.properties
index f3adae5f00..ab41bbbf1a 100644
--- a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/messages.properties
+++ b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/messages.properties
@@ -9,7 +9,20 @@
# Xavier Raynaud <xavier.raynaud@kalray.eu> - initial API and implementation
#################################################################################
CovView_filter_by_name=Filter by name
+CovView_parsing_error=Gcov Parsing Error
CovView_sort_coverage_per_file=Sort coverage per file
CovView_sort_coverage_per_folder=Sort coverage per folder
CovView_sort_coverage_per_function=Sort coverage per function
CovView_type_filter_text=type filter text
+CovView_view_title= \n program runs = {0} \n program file : {1} \n
+CovView_error_message=An error has occured when parsing the coverage data files :\n {0}
+FieldCoveragePercentage_column_header=Coverage %
+FieldCoveragePercentage_column_tooltip=\ Coverage % = {0}
+FieldExecutedLines_column_header=Executed Lines
+FieldExecutedLines_column_tooltip=\ executed line
+FieldInstrumentedLines_column_header=Instrumented Lines
+FieldInstrumentedLines_column_tooltip=\ instrumented line
+FieldName_column_header=Name
+FieldTotalLines_column_header=Total Lines
+FieldTotalLines_column_tooltip_0={0} line in total
+FieldTotalLines_column_tooltip_1={0} lines in total

Back to the top