Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IEP-374: GCOV Reports view and creation #817

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
b60cbf3
initial boilerplate
alirana01 Nov 4, 2022
228164f
IEP-374: openocd started and dumps file now generated
alirana01 Aug 1, 2023
b46d51d
move towards active debug session for gcov
alirana01 Aug 7, 2023
66772dc
added buttons to the debug perspective for generating dumps
alirana01 Aug 29, 2023
a65fa9f
added required gcov dialog dependency and fixed button addition
alirana01 Aug 31, 2023
26da993
Using reflections to add the required inputs to internal gcov dialog
alirana01 Sep 6, 2023
4fafdd1
clean up and javadocs
alirana01 Sep 6, 2023
506305f
cleanup unused class
alirana01 Sep 6, 2023
81c1472
missed dependency added again, was removed during conflict resolution
alirana01 Sep 7, 2023
6b290bf
fixed file format
alirana01 Sep 7, 2023
aed14f2
coderabitai: comment resolution
alirana01 Sep 7, 2023
5c286e8
coderabbitai: enhancement to logging
alirana01 Sep 7, 2023
05ea147
Exported strings to the messages file for dynamic language
alirana01 Sep 7, 2023
7ed186c
added required dependencies for ui tests
alirana01 Sep 7, 2023
0ab584f
Revert "added required dependencies for ui tests"
alirana01 Sep 7, 2023
b5c2381
coderabbitai: enhancement to throw exception for null
alirana01 Sep 7, 2023
cdc120a
added update sites to the target group
alirana01 Sep 13, 2023
83b4581
added gcov feature group
alirana01 Sep 13, 2023
c3a6e21
removing unwanted deps
alirana01 Sep 13, 2023
5af363b
review comments
alirana01 Sep 13, 2023
a5b71a6
coderabbitai suggestions and code cleanup
alirana01 Sep 13, 2023
e9289a8
string externalization and added action to view
alirana01 Sep 13, 2023
1076037
docs: Updated documentation file and added images
alirana01 Sep 19, 2023
4bac3ff
refactor: incorporate CodeRabbitAI review to improve readability and …
alirana01 Sep 19, 2023
0f1d826
remove: delete unwanted file DS_Store
alirana01 Sep 19, 2023
2519d20
docs: add Chinese translation
Lindazhxy Feb 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ To get a quick understanding about ESP-IDF and Eclipse plugin features check our
* [ Device Firmware Upgrade (DFU) through USB ](#deviceFirmwareUpgrade)<br>
* [ GDBStub Debugging ](#gdbStubDebugging)<br>
* [ Core Dump Debugging ](#coreDumpDebugging)<br>
* [ GCOV Code Coverage and Dump Generation ](#gcovCodeCoverage)<br>
* [ Application Level Tracing ](#appLvlTracing)<br>
* [ ESP-IDF master update](#updateEspIdfMaster)<br>
* [ Partition Table Editor UI for ESP-IDF](#partitionTableEditor)<br>
Expand Down Expand Up @@ -581,6 +582,38 @@ This will enable the core dump debugging and whenever you connect a serial monit

You can view the registers stack trace and even view the value of variables in stack frame. To exit the debug session simply press stop button.

<a name="gcovCodeCoverage"></a>

# GCOV Code Coverage and Dump Generation

The idf eclipse plugin allows you to generate and view the gcov code coverage reports.

For the purpose of the this documentation please use the example project [gcov](https://github.com/espressif/esp-idf/blob/master/examples/system/gcov/).
You can read about the project more in the project [README.MD](https://github.com/espressif/esp-idf/blob/master/examples/system/gcov/README.md) to learn more about the flags required to enable this.

After building and flashing the project you can start a normal debug session using the OpenOCD Launch Configuration. Once the debug session starts and the eclipse switches to the debug prespective you will notice two buttons on the IDF Process Console.
![](docs/images/GcovCodeCoverage/gcov-1.png)

The first button is to generate the instant runtime dump and the second button is to generate the hard coded dump. Based on where your program is you can create a dump. As per the example project the program halts twice for you to generate the hard-coded dump which you can do by pressing the second button.
The instant runtime dump can be generated by pressing the first button after the hard-coded dump is complete.

After your dumps are generated you can right click on the project and select the following option.
`ESP-IDF: View GCOV Files`

![](docs/images/GcovCodeCoverage/gcov-2.png)

This will open a view for you that will show you the dumps that are available for the eclipse to be analyzed.
![](docs/images/GcovCodeCoverage/gcov-3.png)

You can press the refresh button to update the view to show the latest files and use the select project button to select a different project.
Only one name is shown for both gcno and gcda files and only files that have a matching partner file with gcno or gcda are shown here.

You can double click on any shown file and you will receive the following dialog. ![](docs/images/GcovCodeCoverage/gcov-4.png).
You can either select to view the coverage for the selected file only or view the whole coverage
Depending upon what you selected you will either be shown the file and also a view that will contain the whole summary for the coverage.
![Summary View](docs/images/GcovCodeCoverage/gcov-5.png)
![File View](docs/images/GcovCodeCoverage/gcov-6.png)

<a name="deviceFirmwareUpgrade"></a>

# Device Firmware Upgrade (DFU) through USB
Expand Down
5 changes: 3 additions & 2 deletions bundles/com.espressif.idf.core/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.core.commands,
org.eclipse.jface,
org.apache.commons.logging;bundle-version="1.2.0",
org.eclipse.core.variables,
org.eclipse.embedcdt.core;visibility:=reexport
org.eclipse.embedcdt.core;visibility:=reexport,
org.eclipse.linuxtools.gcov.core,
org.eclipse.core.variables
alirana01 marked this conversation as resolved.
Show resolved Hide resolved
Bundle-RequiredExecutionEnvironment: JavaSE-11
Automatic-Module-Name: com.espressif.idf.core
Bundle-ActivationPolicy: lazy
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*******************************************************************************
* Copyright 2023 Espressif Systems (Shanghai) PTE LTD. All rights reserved.
* Use is subject to license terms.
*******************************************************************************/
package com.espressif.idf.core.util;

import org.eclipse.core.internal.registry.osgi.OSGIUtils;
import org.eclipse.core.resources.IFile;
alirana01 marked this conversation as resolved.
Show resolved Hide resolved
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.ui.PlatformUI;
import org.osgi.framework.Bundle;
import org.osgi.framework.FrameworkUtil;

import com.espressif.idf.core.logging.Logger;

/**
* Gcov utility to handle and manage the selected project for view and also used to setup the dialog settings
*
* @author Ali Azam Rana
*
*/
@SuppressWarnings("restriction")
public class GcovUtility
{
private static IProject selectedProject;

public static void setSelectedProject(IProject project)
{
selectedProject = project;

Check warning on line 30 in bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/GcovUtility.java

View workflow job for this annotation

GitHub Actions / spotbugs

EI_EXPOSE_STATIC_REP2

com.espressif.idf.core.util.GcovUtility.setSelectedProject(IProject) may expose internal static state by storing a mutable object into a static field com.espressif.idf.core.util.GcovUtility.selectedProject
Raw output
This code stores a reference to an externally mutable object into a static field. If unchecked changes to the mutable object would compromise security or other important properties, you will need to do something different. Storing a copy of the object is better approach in many situations.
}

public static IProject getSelectedProject()
{
return selectedProject;

Check warning on line 35 in bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/GcovUtility.java

View workflow job for this annotation

GitHub Actions / spotbugs

MS_EXPOSE_REP

Public static com.espressif.idf.core.util.GcovUtility.getSelectedProject() may expose internal representation by returning GcovUtility.selectedProject
Raw output
A public static method returns a reference to an array that is part of the static state of the class. Any code that calls this method can freely modify the underlying array. One fix is to return a copy of the array.
}

public static void clearSelectedProject()
{
selectedProject = null;
}
alirana01 marked this conversation as resolved.
Show resolved Hide resolved

public static void setUpDialog(IFile gcFile, String elfFile)
{
try
{
Bundle bundle = OSGIUtils.getDefault().getBundle("org.eclipse.linuxtools.gcov.core"); //$NON-NLS-1$
Class<?> openGcAction = bundle.loadClass("org.eclipse.linuxtools.internal.gcov.action.OpenGCAction"); //$NON-NLS-1$
Class<?> openGcDialog = bundle.loadClass("org.eclipse.linuxtools.internal.gcov.dialog.OpenGCDialog"); //$NON-NLS-1$
IDialogSettings ds = PlatformUI.getDialogSettingsProvider(FrameworkUtil.getBundle(openGcAction))
.getDialogSettings();
IDialogSettings defaultMapping = ds.getSection(openGcDialog.getName());
if (defaultMapping == null)
{
defaultMapping = ds.addNewSection(openGcDialog.getName());

Check warning on line 55 in bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/GcovUtility.java

View workflow job for this annotation

GitHub Actions / spotbugs

DLS_DEAD_LOCAL_STORE

Dead store to defaultMapping in com.espressif.idf.core.util.GcovUtility.setUpDialog(IFile, String)
Raw output
This instruction assigns a value to a local variable, but the value is not read or used in any subsequent instruction. Often, this indicates an error, because the value computed is never used.

Note that Sun's javac compiler often generates dead stores for final local variables. Because SpotBugs is a bytecode-based tool, there is no easy way to eliminate these false positives.
}

ds.put(gcFile.getRawLocation().toOSString(), elfFile);
}
catch (Exception e)
{
Logger.log(e);
}
alirana01 marked this conversation as resolved.
Show resolved Hide resolved
}
alirana01 marked this conversation as resolved.
Show resolved Hide resolved
}
11 changes: 11 additions & 0 deletions bundles/com.espressif.idf.debug.gdbjtag.openocd/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,17 @@
id="com.espressif.idf.ui.appLvlTracing"
name="%command.name">
</command>
<command
defaultHandler="com.espressif.idf.debug.gdbjtag.openocd.gcov.GcovDumpHandler"
id="com.espressif.idf.gcov.instant"
name="GCOV Instant">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

</command>
<command
defaultHandler="com.espressif.idf.debug.gdbjtag.openocd.gcov.GcovDumpHandler"
id="com.espressif.idf.gcov.hardcoded"
name="GCOV Hard-coded">
</command>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


</extension>
<extension
point="org.eclipse.ui.startup">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*******************************************************************************

Check warning on line 1 in bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/dsf/Launch.java

View workflow job for this annotation

GitHub Actions / spotbugs

THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION

Method lists Exception in its throws clause.
Raw output
Method lists Exception in its throws clause.
When declaring a method, the types of exceptions in the throws clause should be the most specific. Therefore, using Exception in the throws clause would force the caller to either use it in its own throws clause, or use it in a try-catch block (when it does not necessarily contain any meaningful information about the thrown exception).

For more information, see the SEI CERT ERR07-J rule [https://wiki.sei.cmu.edu/confluence/display/java/ERR07-J.+Do+not+throw+RuntimeException%2C+Exception%2C+or+Throwable].
* Copyright (c) 2013 Liviu Ionescu.
*
* This program and the accompanying materials
Expand All @@ -22,6 +22,7 @@

import org.eclipse.cdt.debug.gdbjtag.core.IGDBJtagConstants;
import org.eclipse.cdt.dsf.concurrent.DefaultDsfExecutor;
import org.eclipse.cdt.dsf.concurrent.DsfExecutor;
import org.eclipse.cdt.dsf.concurrent.DsfRunnable;
import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants;
import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants;
alirana01 marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -37,7 +38,6 @@
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.model.IProcess;
import org.eclipse.debug.core.model.ISourceLocator;
import org.eclipse.debug.internal.core.LaunchConfigurationWorkingCopy;
import org.eclipse.embedcdt.debug.gdbjtag.core.dsf.GnuMcuLaunch;

import com.espressif.idf.core.util.PortChecker;
Expand Down Expand Up @@ -70,11 +70,25 @@
System.out.println("openocd.Launch.launch(" + launchConfiguration.getName() + "," + mode + ") " + this);
}

fConfig = launchConfiguration;

Check warning on line 73 in bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/dsf/Launch.java

View workflow job for this annotation

GitHub Actions / spotbugs

EI_EXPOSE_REP2

new com.espressif.idf.debug.gdbjtag.openocd.dsf.Launch(ILaunchConfiguration, String, ISourceLocator) may expose internal representation by storing an externally mutable object into Launch.fConfig
Raw output
This code stores a reference to an externally mutable object into the internal representation of the object.  If instances are accessed by untrusted code, and unchecked changes to the mutable object would compromise security or other important properties, you will need to do something different. Storing a copy of the object is better approach in many situations.
fExecutor = (DefaultDsfExecutor) getDsfExecutor();
fSession = getSession();
}


public DsfSession getSession()
{
return super.getSession();
}

public DsfServicesTracker getDsfServicesTracker()
{
return fTracker;
}

public DsfExecutor getDsfExecutor()
{
return super.getDsfExecutor();
}
alirana01 marked this conversation as resolved.
Show resolved Hide resolved
alirana01 marked this conversation as resolved.
Show resolved Hide resolved
// ------------------------------------------------------------------------

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
/*******************************************************************************
* Copyright 2023 Espressif Systems (Shanghai) PTE LTD. All rights reserved.
* Use is subject to license terms.
*******************************************************************************/
package com.espressif.idf.debug.gdbjtag.openocd.gcov;

import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
import org.eclipse.cdt.dsf.concurrent.DsfExecutor;
import org.eclipse.cdt.dsf.concurrent.ImmediateDataRequestMonitor;
import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
import org.eclipse.cdt.dsf.datamodel.DMContexts;
import org.eclipse.cdt.dsf.datamodel.IDMContext;
import org.eclipse.cdt.dsf.debug.service.IProcesses;
import org.eclipse.cdt.dsf.debug.service.IRunControl;
import org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMContext;
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService;
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext;
import org.eclipse.cdt.dsf.mi.service.command.commands.CLICommand;
import org.eclipse.cdt.dsf.service.DsfServicesTracker;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;

import com.espressif.idf.core.logging.Logger;
import com.espressif.idf.core.util.GcovUtility;
import com.espressif.idf.core.util.StringUtil;
import com.espressif.idf.debug.gdbjtag.openocd.dsf.Launch;
import com.espressif.idf.ui.gcov.GcovFileView;

/**
* The gcov dump handler simply runs and suspends the debug session momentarily to send the dump commands based on which
* button was pressed
*
* @author Ali Azam Rana
*
*/
public class GcovDumpHandler extends AbstractHandler
{
private static final String INSTANT_ID = "com.espressif.idf.gcov.instant";
private static final String HARD_CODED_ID = "com.espressif.idf.gcov.hardcoded";

private IExecutionDMContext executionDMContext;
private boolean isInstant = false;

@Override
public Object execute(ExecutionEvent event) throws ExecutionException
{
isInstant = event.getCommand().getId().equals(INSTANT_ID);
ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
ILaunch[] launches = launchManager.getLaunches();
ILaunch launchActive = null;
for (ILaunch launch : launches)
{
if (!launch.isTerminated())
{
launchActive = launch;
break;
}
}
alirana01 marked this conversation as resolved.
Show resolved Hide resolved

DsfServicesTracker dsfServicesTracker = ((Launch) launchActive).getDsfServicesTracker();

Check warning on line 74 in bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/gcov/GcovDumpHandler.java

View workflow job for this annotation

GitHub Actions / spotbugs

NP_NULL_ON_SOME_PATH

Possible null pointer dereference of launchActive in com.espressif.idf.debug.gdbjtag.openocd.gcov.GcovDumpHandler.execute(ExecutionEvent)
Raw output
There is a branch of statement that, if executed, guarantees that a null value will be dereferenced, which would generate a NullPointerException when the code is executed. Of course, the problem might be that the branch or statement is infeasible and that the null pointer exception cannot ever be executed; deciding that is beyond the ability of SpotBugs.
ICommandControlService commandControlService = dsfServicesTracker.getService(ICommandControlService.class);
DsfExecutor dsfExecutor = ((Launch) launchActive).getDsfExecutor();
IRunControl runControl = dsfServicesTracker.getService(IRunControl.class);
ICommandControlDMContext controlDmc = DMContexts.getAncestorOfType(commandControlService.getContext(),
ICommandControlDMContext.class);
IProcesses processControl = dsfServicesTracker.getService(IProcesses.class);
processControl.getProcessesBeingDebugged(controlDmc, new DataRequestMonitor<IDMContext[]>(dsfExecutor, null)
{
@Override
protected void handleSuccess()
{
executionDMContext = (IExecutionDMContext) (getData()[0]);
}
});
alirana01 marked this conversation as resolved.
Show resolved Hide resolved
final ILaunch finalActiveLaunch = launchActive;
runControl.suspend(executionDMContext, new RequestMonitor(dsfExecutor, null)
{
@Override
protected void handleSuccess()
{
commandControlService.queueCommand(new CLICommand<>(commandControlService.getContext(),
isInstant ? "mon esp gcov dump" : "mon esp gcov"), new ImmediateDataRequestMonitor<>()
{
@Override
protected void handleSuccess()
{
runControl.resume(executionDMContext, new RequestMonitor(dsfExecutor, null));
ILaunchConfiguration launchConfig = finalActiveLaunch.getLaunchConfiguration();
Display.getDefault().asyncExec(() -> {
String projectName;
try
{
projectName = launchConfig.getAttribute(
ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, StringUtil.EMPTY);

if (!projectName.isEmpty())
{
IProject project = ResourcesPlugin.getWorkspace().getRoot()
.getProject(projectName);
Comment on lines +102 to +113
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can get the project directly from the launch configuration's mapped resources. Something like this: configuration.getMappedResources()[0].getProject(); or something like this if you want to avoid null checks:

		IResource[] resources = null;
		try
		{
			resources = config.getMappedResources();
		}
		catch (CoreException e)
		{
			Logger.log(e);
		}
		Optional<IProject> projectOptional = resources == null ? Optional.empty()
				: Stream.of(resources).filter(Objects::nonNull)
						.filter(resource -> resource.getType() == IResource.PROJECT).map(IResource::getProject)
						.findFirst();
	}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not clear on this we can use that approach but this should be fine too I think since the attribute ID comes from internal static constant

if (project != null && project.exists())
{
GcovUtility.setSelectedProject(project);
IWorkbenchWindow window = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow();
if (window != null)
{
IWorkbenchPage page = window.getActivePage();
if (page != null)
{
try
{
GcovFileView gcovFileView = (GcovFileView) page
.showView(GcovFileView.ID);
Comment on lines +126 to +127
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if that's okay to use the class from the UI package here, since it can cause cyclic dependency later. Isn't it better to move this handler to the com.espressif.idf.ui.handlers package?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some launch class dependencies there that are required and I am not sure if that can be good to add this package as a dependency to ui project

page.activate(gcovFileView);

}
catch (PartInitException e)
{
Logger.log(e);
}
}
}
}
}
}
catch (CoreException e)
{
Logger.log(e);
}
});
alirana01 marked this conversation as resolved.
Show resolved Hide resolved
}

@Override
protected void handleError()
{
runControl.resume(executionDMContext, new RequestMonitor(dsfExecutor, null));
}
});
}
});
alirana01 marked this conversation as resolved.
Show resolved Hide resolved
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

public IDFMonitor(IProject project, String port, String filterOptions, String pythonBinPath, int serverPort)
{
this.project = project;

Check warning on line 46 in bundles/com.espressif.idf.serial.monitor/src/com/espressif/idf/serial/monitor/core/IDFMonitor.java

View workflow job for this annotation

GitHub Actions / spotbugs

EI_EXPOSE_REP2

new com.espressif.idf.serial.monitor.core.IDFMonitor(IProject, String, String, String, int) may expose internal representation by storing an externally mutable object into IDFMonitor.project
Raw output
This code stores a reference to an externally mutable object into the internal representation of the object.  If instances are accessed by untrusted code, and unchecked changes to the mutable object would compromise security or other important properties, you will need to do something different. Storing a copy of the object is better approach in many situations.
this.port = port;
this.pythonBinPath = pythonBinPath;
this.filterOptions = filterOptions;
Expand Down Expand Up @@ -143,54 +143,54 @@

public Process start() throws Exception
{
if (!dependenciesAreInstalled())
{
throw new Exception("The WebSocket dependency is missing and cannot be installed automatically"); //$NON-NLS-1$
}
List<String> arguments = commandArgsWithSocketServer();

// command to execute
Logger.log(arguments.toString());

// CDT Build environment variables
Map<String, String> idfEnvMap = new IDFEnvironmentVariables().getSystemEnvMap();

// Disable buffering of output
idfEnvMap.put("PYTHONUNBUFFERED", "1"); //$NON-NLS-1$ //$NON-NLS-2$

// Update with the CDT build environment variables
Map<String, String> environment = new HashMap<>(System.getenv());
environment.putAll(idfEnvMap);

Logger.log(environment.toString());

// Update PATH and Path
String idfPath = environment.get("PATH"); //$NON-NLS-1$
String processPath = environment.get("Path"); //$NON-NLS-1$
if (!StringUtil.isEmpty(idfPath) && !StringUtil.isEmpty(processPath)) // if both exist!
{
idfPath = idfPath.concat(";").concat(processPath); //$NON-NLS-1$
environment.put("PATH", idfPath); //$NON-NLS-1$
environment.remove("Path");//$NON-NLS-1$
}

// Add ptyprocess terminal argument
environment.remove("TERM_PROGRAM"); // for OS X //$NON-NLS-1$
environment.put("TERM", "vt102"); //$NON-NLS-1$ //$NON-NLS-2$

Logger.log(environment.toString());

// working dir
IPath workingDir = project.getLocation();

LocalTerminal localTerminal = new LocalTerminal(arguments, workingDir.toFile(), environment);
return localTerminal.connect();

Check warning on line 187 in bundles/com.espressif.idf.serial.monitor/src/com/espressif/idf/serial/monitor/core/IDFMonitor.java

View workflow job for this annotation

GitHub Actions / spotbugs

THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION

Method lists Exception in its throws clause.
Raw output
Method lists Exception in its throws clause.
When declaring a method, the types of exceptions in the throws clause should be the most specific. Therefore, using Exception in the throws clause would force the caller to either use it in its own throws clause, or use it in a try-catch block (when it does not necessarily contain any meaningful information about the thrown exception).

For more information, see the SEI CERT ERR07-J rule [https://wiki.sei.cmu.edu/confluence/display/java/ERR07-J.+Do+not+throw+RuntimeException%2C+Exception%2C+or+Throwable].
}

public boolean dependenciesAreInstalled()
{
InstallToolsHandler installToolsHandler = new InstallToolsHandler();
IStatus status = installToolsHandler.handleWebSocketClientInstall();
IStatus status = installToolsHandler.handlePythonDependenciesInstall();
if (status == null || status.getSeverity() == IStatus.ERROR)
{
Logger.log(IDFCorePlugin.getPlugin(), IDFCorePlugin.errorStatus("Unable to get the process status.", null)); //$NON-NLS-1$
alirana01 marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
4 changes: 3 additions & 1 deletion bundles/com.espressif.idf.ui/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,14 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.embedcdt.ui,
org.eclipse.ltk.ui.refactoring,
org.eclipse.ltk.core.refactoring,
org.eclipse.epp.mpc.ui
org.eclipse.epp.mpc.ui,
org.eclipse.core.variables;bundle-version="3.5.100"
Automatic-Module-Name: com.espressif.idf.ui
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-11
Export-Package: com.espressif.idf.ui,
com.espressif.idf.ui.dialogs,
com.espressif.idf.ui.gcov,
com.espressif.idf.ui.handlers,
com.espressif.idf.ui.preferences,
com.espressif.idf.ui.tracing,
Expand Down
Loading
Loading