-
Notifications
You must be signed in to change notification settings - Fork 133
IEP-1000 Board doesn't match the target after cancel in debug/jtag tab #799
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
Merged
Merged
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
2b3d916
fix `board doesn't match the target after cancel`
sigmaaa 6fe9d7a
small cleanup LaunchBarListener
sigmaaa b0fe98b
esp_svd_path_desc clear message
sigmaaa f707e5d
Added SvdPathResolver class comment
sigmaaa f516316
refactoring resolveValue method
sigmaaa c06d09a
fix: added workaround to roll back target after Cancel
sigmaaa 3ea3b41
fix: reducing complexity, extracting revertTargetJob
sigmaaa 9bc6b8b
fix: fixing wrong default target name
sigmaaa fb6f882
fix: optimization in case when target is not yet set to the configura…
sigmaaa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
...df.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/SvdPathResolver.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| /******************************************************************************* | ||
| * Copyright 2023 Espressif Systems (Shanghai) PTE LTD. All rights reserved. | ||
| * Use is subject to license terms. | ||
| *******************************************************************************/ | ||
| package com.espressif.idf.debug.gdbjtag.openocd; | ||
|
|
||
| import java.io.File; | ||
| import java.io.InputStream; | ||
| import java.net.URL; | ||
| import java.util.jar.JarEntry; | ||
| import java.util.jar.JarFile; | ||
|
|
||
| import org.eclipse.core.resources.IFile; | ||
| import org.eclipse.core.resources.IFolder; | ||
| import org.eclipse.core.resources.IProject; | ||
| import org.eclipse.core.runtime.CoreException; | ||
| import org.eclipse.core.runtime.FileLocator; | ||
| import org.eclipse.core.runtime.NullProgressMonitor; | ||
| import org.eclipse.core.runtime.Platform; | ||
| import org.eclipse.core.variables.IDynamicVariable; | ||
| import org.eclipse.core.variables.IDynamicVariableResolver; | ||
| import org.eclipse.embedcdt.core.EclipseUtils; | ||
| import org.eclipse.launchbar.core.ILaunchBarManager; | ||
|
|
||
| import com.espressif.idf.core.IDFConstants; | ||
| import com.espressif.idf.core.build.IDFLaunchConstants; | ||
| import com.espressif.idf.core.logging.Logger; | ||
| import com.espressif.idf.core.util.StringUtil; | ||
| import com.espressif.idf.debug.gdbjtag.openocd.ui.TabSvdTarget; | ||
|
|
||
| /** | ||
| * A resolver class for the esp_svd_path dynamic variable. Resolves SVD path by looking for appropriate files inside the | ||
| * plugin resources | ||
| * | ||
| * @author Denys Almazov <[email protected]> | ||
| */ | ||
| public class SvdPathResolver implements IDynamicVariableResolver | ||
| { | ||
|
|
||
| private static final ILaunchBarManager LAUNCH_BAR_MANAGER = Activator.getService(ILaunchBarManager.class); | ||
|
|
||
sigmaaa marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| public String resolveValue(IDynamicVariable variable, String argument) throws CoreException | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. mostly code from the updateSvd method |
||
| { | ||
| String selectedTarget = StringUtil.EMPTY; | ||
| String selectedTargetPath = StringUtil.EMPTY; | ||
| try | ||
| { | ||
| selectedTarget = LAUNCH_BAR_MANAGER.getActiveLaunchTarget().getAttribute(IDFLaunchConstants.ATTR_IDF_TARGET, | ||
| StringUtil.EMPTY); | ||
| if (StringUtil.isEmpty(selectedTarget)) | ||
| return StringUtil.EMPTY; | ||
| selectedTargetPath = resolveSvdPath(selectedTarget); | ||
| } | ||
| catch (Exception e) | ||
| { | ||
| Logger.log(e); | ||
| } | ||
| return selectedTargetPath; | ||
| } | ||
sigmaaa marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| private String resolveSvdPath(String target) throws Exception | ||
| { | ||
| URL svdUrl = Platform.getBundle(Activator.PLUGIN_ID).getResource("svd/".concat(target.concat(".svd"))); //$NON-NLS-1$ //$NON-NLS-2$ | ||
| String jarPath = new File(TabSvdTarget.class.getProtectionDomain().getCodeSource().getLocation().toURI()) | ||
| .getPath(); | ||
| String selectedTargetPath; | ||
| if (!jarPath.contains(".jar")) //$NON-NLS-1$ | ||
| selectedTargetPath = new File(FileLocator.resolve(svdUrl).toURI()).getPath(); | ||
| else | ||
| selectedTargetPath = resolveSvdPathFromJar(svdUrl, jarPath); | ||
| return selectedTargetPath; | ||
| } | ||
sigmaaa marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| private String resolveSvdPathFromJar(URL svdUrl, String jarPath) throws Exception | ||
| { | ||
| IProject project = EclipseUtils | ||
| .getProjectByLaunchConfiguration(LAUNCH_BAR_MANAGER.getActiveLaunchConfiguration()); | ||
| IFolder svdFolder = project.getFolder(IDFConstants.BUILD_FOLDER).getFolder("svd"); //$NON-NLS-1$ | ||
| if (!svdFolder.exists()) | ||
| { | ||
| svdFolder.create(true, true, new NullProgressMonitor()); | ||
| } | ||
| IFile svdFile = project.getFolder(IDFConstants.BUILD_FOLDER).getFile(svdUrl.getPath()); | ||
| if (!svdFile.exists()) | ||
| { | ||
| try (JarFile jarFile = new JarFile(jarPath)) | ||
| { | ||
| JarEntry file = (JarEntry) jarFile.getEntry(svdUrl.getFile().substring(1)); | ||
| if (file != null) | ||
| { | ||
| InputStream inputStream = jarFile.getInputStream(file); | ||
| svdFile.create(inputStream, true, new NullProgressMonitor()); | ||
| inputStream.close(); | ||
| } | ||
| } | ||
| } | ||
| project.refreshLocal(IProject.DEPTH_INFINITE, new NullProgressMonitor()); | ||
| return svdFile.getRawLocation().toOSString(); | ||
sigmaaa marked this conversation as resolved.
Show resolved
Hide resolved
sigmaaa marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
|
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.