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-1000 Board doesn't match the target after cancel in debug/jtag tab #799

Merged
merged 9 commits into from
Nov 2, 2023

Conversation

sigmaaa
Copy link
Collaborator

@sigmaaa sigmaaa commented Jul 19, 2023

Description

The initial bug can be reproduced this way: select board in the debug/jtag tab -> click cancel -> select the previous target in the launch bar -> open the debug tab again -> board doesn't match the target. This happens because we had to save the target attribute of the configuration not only when we finish the dialog, but in the moment when the target is changed. We had to do this because we want the SVD path to always be according to the selected target. However, it led us to the problem when we couldn't actually add a custom SVD path, because it will be always reinitialized after the configuration is reopened. Moreover, it saves the wrong value for the SVD path, if the SVD path is not opened before the finish dialog.

To address this issue, I made the following changes: I removed the saving configuration in the listeners (which also ensures proper operation cancellation), and I introduced a dynamic variable for the SVD path. This variable will be replaced during the debug phase to resolve the problem

Fixes # (IEP-1000)
Fixes #(IEP-1004)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

How has this been tested?

Test 1:

  • Edit debug configuration -> select different target -> click cancel -> edit the same configuration again -> all pre-filled values should be correct
    Test 2:
  • Edit launch configuration -> select flash over jtag -> select different target -> click finish
  • Edit launch configuration again -> select different target -> click cancel -> edit the same configuration again -> all pre-filled
    values should be correct
    Test 3:
  • Create a new debug configuration
  • in the SVD tab as path should be provided ${esp_svd_path} dynamic variable
  • this variable should be present in the Variables... list
  • debug the project with this configuration -> check peripherals view

Test Configuration:

  • ESP-IDF Version:
  • OS (Windows, Linux, and macOS):

Dependent components impacted by this PR:

  • SVD tab/ SVD path
  • Debug configuration, Launch configuration

Checklist

  • PR Self Reviewed
  • Applied Code formatting
  • Added Documentation
  • Added Unit Test
  • Verified on all platforms - Windows,Linux and macOS

Summary by CodeRabbit

New Features:

  • Introduced a new system for resolving the System View Description (SVD) path, enhancing the software's ability to locate necessary files.
  • Added a feature to revert target changes in the launch bar when the "Cancel" button is pressed, improving user control over target selection.
  • Implemented a new method to handle different cases based on the active launch configuration and target, improving the software's adaptability.

Refactor:

  • Simplified the logic in the CMakeMainTab2 class by removing unnecessary code blocks and introducing more efficient methods.
  • Streamlined the TabDebugger class with updates to UI elements, tooltips, and methods, enhancing the user interface's intuitiveness.

Note: The remaining changes do not have a direct impact on end-users and are categorized as "Refactor" or "Chores."

Copy link
Collaborator Author

@sigmaaa sigmaaa left a comment

Choose a reason for hiding this comment

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

self reviwed

public class SvdPathResolver implements IDynamicVariableResolver
{

public String resolveValue(IDynamicVariable variable, String argument) throws CoreException
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

mostly code from the updateSvd method

Copy link
Collaborator

@alirana01 alirana01 left a comment

Choose a reason for hiding this comment

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

Nicely done and good utilization of Dynamic Variable Resolver, I didnt think of that when implementing just some minor comments from me to clean up a bit.

@sigmaaa sigmaaa requested a review from alirana01 July 21, 2023 14:38
@sigmaaa
Copy link
Collaborator Author

sigmaaa commented Jul 21, 2023

Hi, @alirana01, thanks for the review. Fixed mentioned points in the latest commit

@kolipakakondal
Copy link
Collaborator

Hi @AndriiFilippov Could you please verify this?

Copy link
Collaborator

@kolipakakondal kolipakakondal left a comment

Choose a reason for hiding this comment

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

LGTM

@AndriiFilippov
Copy link
Collaborator

Hi @sigmaaa !

Tested under:

OS - Windows 10
ESP-IDF: master

Test 1 👍
Test 2 👍
Test 3 👍
Able to Debug/JTAG.

After pressing the "cancel" button in the debug configuration, there is no confusion between the target(ESP32) and board type. However, in the Launch Target, a switch occurs to a new (canceled target ESP32c3). As a result, if you try to build the project, you will encounter an error. There is nothing to worry about - you just need to manually change the target back to the one that was used before. Nevertheless, I believe this could potentially mislead the user.

I think we should consider how to automatically return to the original target.

image

@kolipakakondal kolipakakondal added the bug Something isn't working label Sep 28, 2023
@kolipakakondal kolipakakondal added this to the v2.12.0 milestone Sep 28, 2023
@coderabbitai
Copy link

coderabbitai bot commented Sep 29, 2023

Walkthrough

The changes primarily focus on improving the handling of System View Description (SVD) paths and launch configuration attributes. The introduction of the SvdPathResolver class and modifications to the TabDebugger and CMakeMainTab2 classes enhance the user interface and streamline the process of target selection and configuration. The changes also include the addition of new string constants and modifications to the LaunchBarListener class.

Changes

File(s) Summary
bundles/com.espressif.idf.debug.gdbjtag.openocd/plugin.properties Added new variable descriptions and string constants.
bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/SvdPathResolver.java Introduced a new class SvdPathResolver for resolving SVD paths.
bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/ui/TabDebugger.java Improved handling of launch configuration attributes and target selection. Added methods for reverting target changes.
bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/ui/TabSvdTarget.java Refactored the initializeFrom method and replaced updateSvd method with a variable expression.
bundles/com.espressif.idf.launch.serial.ui/src/com/espressif/idf/launch/serial/ui/internal/CMakeMainTab2.java Improved handling of launch configuration attributes and target selection. Removed unnecessary code.
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/LaunchBarListener.java Updated methods for handling different cases based on the active launch configuration and target.

"In the land of code, where the shadows lie,
A rabbit hopped, with a twinkle in its eye. 🐇
With each hop, a change was made,
Improving paths where SVDs laid.
Targets selected, configurations set,
A smoother journey, you're sure to get. 🎉
So here's to the code, ever so bright,
Guiding us through the development night." 🌙


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai help to get help.
  • @coderabbitai resolve to resolve all the CodeRabbit review comments.

Note: For conversation with the bot, please use the review comments on code diffs or files.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.json

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 5

Commits Files that changed from the base of the PR and between 05177fd and f516316.
Files ignored due to filter (1)
  • bundles/com.espressif.idf.debug.gdbjtag.openocd/plugin.xml
Files selected for processing (6)
  • bundles/com.espressif.idf.debug.gdbjtag.openocd/plugin.properties (1 hunks)
  • bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/SvdPathResolver.java (1 hunks)
  • bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/ui/TabDebugger.java (4 hunks)
  • bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/ui/TabSvdTarget.java (2 hunks)
  • bundles/com.espressif.idf.launch.serial.ui/src/com/espressif/idf/launch/serial/ui/internal/CMakeMainTab2.java (1 hunks)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/LaunchBarListener.java (4 hunks)
Files skipped from review due to trivial changes (3)
  • bundles/com.espressif.idf.debug.gdbjtag.openocd/plugin.properties
  • bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/ui/TabSvdTarget.java
  • bundles/com.espressif.idf.launch.serial.ui/src/com/espressif/idf/launch/serial/ui/internal/CMakeMainTab2.java
Additional comments (Suppressed): 8
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/LaunchBarListener.java (4)
  • 46-61: The use of lambda expressions instead of anonymous classes is a good practice as it makes the code more readable and concise. The change from new Runnable() to () -> is an improvement.

  • 67-79: No significant changes were made in this hunk. The replacement of "" with StringUtil.EMPTY is a minor change that improves readability by making the purpose of the empty string clearer.

  • 97-125: The logic for checking if the target has changed and prompting the user for action has been modified. The condition for checking if JTAG flashing is enabled or if the launch configuration type is debug has been updated. This change seems to be in line with the PR summary, but ensure that it doesn't introduce any unexpected behavior.

  • 180-183: The return statement in the deleteDirectory method has been simplified. This change improves readability without altering the functionality.

bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/ui/TabDebugger.java (4)
  • 88-89: The import statement for LaunchBarListener has been added. Ensure that this class is available in the project and its methods are accessible from this context.

  • 177-178: A flag ignoreJtagTargetChange is being set/reset in the createControl method using LaunchBarListener.setIgnoreJtagTargetChange(). This change seems to be part of the solution to prevent saving the target attribute of the configuration at the wrong time. However, ensure that this flag is used correctly in other parts of the code where the JTAG target change is handled.

  • 461-466: The code updating launch configuration attributes in the widgetSelected method has been removed. This change is consistent with the PR summary, which mentions removing the saving of configuration in listeners. However, make sure that these attributes are updated elsewhere as necessary, especially the TARGET_FOR_JTAG attribute, which seems important for the debugging process.

  • 1504-1510: The code updating launch configuration attributes in the performApply method has been simplified by directly setting the attributes on the given configuration instead of creating a working copy. This change simplifies the logic and avoids unnecessary object creation, which can improve performance. However, ensure that this change does not introduce any issues related to concurrency or shared state, as multiple threads might access the same configuration object simultaneously.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 5

Commits Files that changed from the base of the PR and between f516316 and c06d09a.
Files selected for processing (6)
  • bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/ui/Messages.java (1 hunks)
  • bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/ui/TabDebugger.java (44 hunks)
  • bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/ui/messages.properties (1 hunks)
  • bundles/com.espressif.idf.launch.serial.ui/src/com/espressif/idf/launch/serial/ui/internal/CMakeMainTab2.java (5 hunks)
  • bundles/com.espressif.idf.launch.serial.ui/src/com/espressif/idf/launch/serial/ui/internal/Messages.java (1 hunks)
  • bundles/com.espressif.idf.launch.serial.ui/src/com/espressif/idf/launch/serial/ui/internal/messages.properties (1 hunks)
Files skipped from review due to trivial changes (4)
  • bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/ui/Messages.java
  • bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/ui/messages.properties
  • bundles/com.espressif.idf.launch.serial.ui/src/com/espressif/idf/launch/serial/ui/internal/Messages.java
  • bundles/com.espressif.idf.launch.serial.ui/src/com/espressif/idf/launch/serial/ui/internal/messages.properties
Additional comments (Suppressed): 20
bundles/com.espressif.idf.launch.serial.ui/src/com/espressif/idf/launch/serial/ui/internal/CMakeMainTab2.java (4)
  • 38-47: The new hunk introduces additional imports from the org.eclipse.core.runtime package. Ensure that these are necessary for the changes made in this PR.

  • 104-110: A new field lastAppliedConfiguration of type ILaunchConfigurationWorkingCopy has been added. This seems to be used to store the last applied launch configuration.

  • 118-146: The createControl method has been updated to include a new job revertTargetJob which is scheduled to run after 100ms when the parent composite is disposed. This job reverts the active launch target to the one stored in lastAppliedConfiguration. This change appears to be part of the fix for the bug where the board selection doesn't match the target after canceling in the debug/JTAG tab.

  • 586-592: The lastAppliedConfiguration field is now being set to the working copy of the launch configuration before it's saved. This allows the last applied configuration to be accessed later, such as in the revertTargetJob in the createControl method.

bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/ui/TabDebugger.java (16)
  • 26-42: The new hunk has added a few more import statements. Ensure that these new imports are used in the code and are necessary.

  • 90-96: A new import statement has been added. Ensure that this new import is used in the code and is necessary.

  • 100-108: No significant changes have been made in this hunk, only the addition of //$NON-NLS-1$ comments which are used for internationalization and localization in Eclipse. These comments indicate that the string does not need to be translated.

  • 145-151: No significant changes have been made in this hunk, only the addition of //$NON-NLS-1$ comments which are used for internationalization and localization in Eclipse. These comments indicate that the string does not need to be translated.

  • 239-253: No significant changes have been made in this hunk, only the addition of //$NON-NLS-1$ comments which are used for internationalization and localization in Eclipse. These comments indicate that the string does not need to be translated.

  • 331-337: No significant changes have been made in this hunk, only the addition of //$NON-NLS-1$ comments which are used for internationalization and localization in Eclipse. These comments indicate that the string does not need to be translated.

  • 357-370: No significant changes have been made in this hunk, only the addition of //$NON-NLS-1$ comments which are used for internationalization and localization in Eclipse. These comments indicate that the string does not need to be translated.

  • 382-396: No significant changes have been made in this hunk, only the addition of //$NON-NLS-1$ comments which are used for internationalization and localization in Eclipse. These comments indicate that the string does not need to be translated.

  • 404-422: No significant changes have been made in this hunk, only the addition of //$NON-NLS-1$ comments which are used for internationalization and localization in Eclipse. These comments indicate that the string does not need to be translated.

  • 456-461: No significant changes have been made in this hunk, only the addition of //$NON-NLS-1$ comments which are used for internationalization and localization in Eclipse. These comments indicate that the string does not need to be translated.

  • 477-484: No significant changes have been made in this hunk, only the addition of //$NON-NLS-1$ comments which are used for internationalization and localization in Eclipse. These comments indicate that the string does not need to be translated.

  • 555-562: No significant changes have been made in this hunk, only the addition of //$NON-NLS-1$ comments which are used for internationalization and localization in Eclipse. These comments indicate that the string does not need to be translated.

  • 600-606: No significant changes have been made in this hunk, only the addition of //$NON-NLS-1$ comments which are used for internationalization and localization in Eclipse. These comments indicate that the string does not need to be translated.

  • 625-632: No significant changes have been made in this hunk, only the addition of //$NON-NLS-1$ comments which are used for internationalization and localization in Eclipse. These comments indicate that the string does not need to be translated.

  • 694-700: No significant changes have been made in this hunk, only the addition of //$NON-NLS-1$ comments which are used for internationalization and localization in Eclipse. These comments indicate that the string does not need to be translated.

  • 793-799: No significant changes have been made in this hunk, only the addition of //$NON-NLS-1$ comments which are used for internationalization and localization in Eclipse. These comments indicate that the string does not need to be translated.

808

Comment on lines 732 to 737
}

if (!selectedItem.contentEquals(updatedSelectedTarget) && isFlashOverJtag) {
try {
ILaunchConfigurationWorkingCopy wc = launchBarManager.getActiveLaunchConfiguration()
.getWorkingCopy();
wc.setAttribute(IDFLaunchConstants.TARGET_FOR_JTAG, selectedItem);
wc.doSave();
} catch (CoreException e2) {
Logger.log(e2);
}
updateLaunchBar(selectedItem);
}
boardConfigsMap = parser.getBoardsConfigs(selectedItem);
Copy link

Choose a reason for hiding this comment

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

The code for updating the launch configuration with the selected target has been removed from the if block. Instead, the updateLaunchBar method is called directly. This change simplifies the code and removes the need to handle a CoreException here.

Comment on lines 175 to 215
@Override
public void createControl(Composite parent)
{

if (Activator.getInstance().isDebugging())
{
System.out.println("openocd.TabDebugger.createControl() ");
System.out.println("openocd.TabDebugger.createControl() "); //$NON-NLS-1$
}

LaunchBarListener.setIgnoreJtagTargetChange(true);
parent.addDisposeListener(event -> {
String targetNameFromUI = fTargetName.getText();
// TODO: find a better way to roll back target change in the launch bar when Cancel was pressed.
// We have to do like this because we don't have access to the cancel button
Job revertTargetJob = new Job(Messages.TabDebugger_SettingTargetJob)
{
protected IStatus run(IProgressMonitor monitor)
{
try
{
String targetName = lastAppliedConfiguration.getOriginal()
.getAttribute(IDFLaunchConstants.TARGET_FOR_JTAG, targetNameFromUI);
ILaunchTargetManager launchTargetManager = Activator.getService(ILaunchTargetManager.class);
ILaunchTarget selectedTarget = Stream.of(launchTargetManager.getLaunchTargets())
.filter(target -> target.getId().contentEquals((targetName))).findFirst().orElseGet(() -> null);
launchBarManager.setActiveLaunchTarget(selectedTarget);
return Status.OK_STATUS;
}
catch (CoreException e)
{
Logger.log(e);
return Status.CANCEL_STATUS;
}
}
};
revertTargetJob.schedule(100);
LaunchBarListener.setIgnoreJtagTargetChange(false);
});

if (!(parent instanceof ScrolledComposite))
{
ScrolledComposite sc = new ScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL);
Copy link

Choose a reason for hiding this comment

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

This hunk introduces a new logic to handle the cancellation of target change in the launch bar. It creates a job to revert the target change if the Cancel button was pressed. This seems like a workaround due to lack of access to the cancel button. While this might work, it's worth considering if there's a more direct way to handle this scenario.

Comment on lines 427 to 434

{
Label label = new Label(comp, SWT.NONE);
label.setText(Messages.getString("DebuggerTab.gdbServerTelnetPort_Label"));
label.setToolTipText(Messages.getString("DebuggerTab.gdbServerTelnetPort_ToolTipText"));
label.setText(Messages.getString("DebuggerTab.gdbServerTelnetPort_Label")); //$NON-NLS-1$
label.setToolTipText(Messages.getString("DebuggerTab.gdbServerTelnetPort_ToolTipText")); //$NON-NLS-1$

fGdbServerTelnetPort = new Text(comp, SWT.SINGLE | SWT.BORDER);
GridData gd = new GridData();
Copy link

Choose a reason for hiding this comment

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

Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [427-437]

The new hunk has removed some code related to updating the launch configuration when the selected item is not equal to the updated selected target. Ensure that this removal doesn't affect the functionality of the application.

Comment on lines 494 to 499
String selectedItem = fTarget.getText();
if (!selectedItem.contentEquals(updatedSelectedTarget))
{
try
{
ILaunchConfigurationWorkingCopy wc = launchBarManager.getActiveLaunchConfiguration()
.getWorkingCopy();
wc.setAttribute(IDFLaunchConstants.TARGET_FOR_JTAG, selectedItem);
TabSvdTarget.updateSvd(selectedItem, wc);
wc.doSave();
}
catch (CoreException e1)
{
Logger.log(e1);
}
updateLaunchBar(selectedItem);
}
fGdbClientExecutable.setText(IDFUtil.getXtensaToolchainExecutablePathByTarget(selectedItem));
Copy link

Choose a reason for hiding this comment

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

The new hunk has removed some code related to updating the launch configuration when the selected item is not equal to the updated selected target. Ensure that this removal doesn't affect the functionality of the application.

Comment on lines 721 to 737
}

int ret = -1;
if ("global".equals(text))
if ("global".equals(text)) //$NON-NLS-1$
{
ret = PreferencesUtil.createPreferenceDialogOn(parent.getShell(), GlobalMcuPage.ID, null, null)
.open();
}
else if ("workspace".equals(text))
else if ("workspace".equals(text)) //$NON-NLS-1$
{
ret = PreferencesUtil.createPreferenceDialogOn(parent.getShell(), WorkspaceMcuPage.ID, null, null)
.open();
}
else if ("project".equals(text))
else if ("project".equals(text)) //$NON-NLS-1$
{
assert (fConfiguration != null);
IProject project = EclipseUtils.getProjectByLaunchConfiguration(fConfiguration);
Copy link

Choose a reason for hiding this comment

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

The new hunk has removed some code related to updating the launch configuration when the selected item is not equal to the updated selected target. Ensure that this removal doesn't affect the functionality of the application.

@sigmaaa
Copy link
Collaborator Author

sigmaaa commented Sep 29, 2023

Hi @sigmaaa !

Tested under:

OS - Windows 10 ESP-IDF: master

Test 1 👍 Test 2 👍 Test 3 👍 Able to Debug/JTAG.

After pressing the "cancel" button in the debug configuration, there is no confusion between the target(ESP32) and board type. However, in the Launch Target, a switch occurs to a new (canceled target ESP32c3). As a result, if you try to build the project, you will encounter an error. There is nothing to worry about - you just need to manually change the target back to the one that was used before. Nevertheless, I believe this could potentially mislead the user.

I think we should consider how to automatically return to the original target.

image

Hi @AndriiFilippov, @kolipakakondal , @alirana01
added a workaround fix: added workaround to roll back target after Cancel for this issue with a TODO comment. Unfortunately, we don't have access to the Cancel button, which is part of LaunchConfigurationDialog and we don't have an extension point to this.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0
Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between c06d09a and 3ea3b41.
Files selected for processing (2)
  • bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/ui/TabDebugger.java (45 hunks)
  • bundles/com.espressif.idf.launch.serial.ui/src/com/espressif/idf/launch/serial/ui/internal/CMakeMainTab2.java (6 hunks)
Files skipped from review due to trivial changes (1)
  • bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/ui/TabDebugger.java
Additional comments (Suppressed): 6
bundles/com.espressif.idf.launch.serial.ui/src/com/espressif/idf/launch/serial/ui/internal/CMakeMainTab2.java (6)
  • 41-44: New import statements have been added for IProgressMonitor, IStatus, Status, and Job. These classes are used for creating and managing background jobs in Eclipse. The addition of these imports suggests that new functionality related to background jobs has been added to the CMakeMainTab2 class.

  • 88-88: A new constant JOB_DELAY_MS has been introduced. This constant is used to specify the delay before a job is scheduled to run. The value is set to 100 milliseconds. This change suggests that a new job is being scheduled somewhere in the class.

  • 121-125: The addDisposeListener method has been updated to include a call to scheduleRevertTargetJob(targetNameFromUI) before setting IgnoreJtagTargetChange to false. This change ensures that the target is reverted to its original value when the parent composite is disposed. This is a good practice as it ensures that the state of the application is consistent even when UI elements are disposed.

  • 568-573: The doSave method is now called inside a try block, and any CoreException that occurs is logged. This is a good practice as it ensures that any exceptions that occur during the save operation are caught and logged, preventing the application from crashing unexpectedly.

  • 715-718: The code for updating the launch configuration with the selected target has been removed from the if block. Instead, the updateLaunchBar method is called directly. This change simplifies the code and removes the need to handle a CoreException here.

  • 860-884: A new method scheduleRevertTargetJob has been added. This method creates and schedules a new job that reverts the target to its original value. The job is scheduled to run after a delay specified by JOB_DELAY_MS. This is a good practice as it ensures that the target is reverted to its original value in a non-blocking manner, allowing the UI to remain responsive.

@AndriiFilippov
Copy link
Collaborator

@sigmaaa hi !

Tested under:
OS - Windows 10
ESP-IDF: v5.1.1

In general, everything is good, except for one scenario:

create new project -> go to Edit Launch Config -> click "Cancel" -> the Launch Mode and Launch Target disappear.

image

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 3ea3b41 and 9bc6b8b.
Files selected for processing (2)
  • bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/ui/TabDebugger.java (45} hunks)
  • bundles/com.espressif.idf.launch.serial.ui/src/com/espressif/idf/launch/serial/ui/internal/CMakeMainTab2.java (6} hunks)
Files skipped from review due to trivial changes (1)
  • bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/ui/TabDebugger.java
Additional comments: 6
bundles/com.espressif.idf.launch.serial.ui/src/com/espressif/idf/launch/serial/ui/internal/CMakeMainTab2.java (6)
  • 41-44: The new imports IProgressMonitor, IStatus, Status, and Job are introduced to handle the scheduling of a job that reverts the target selection when the "Cancel" button is pressed. This is a part of the new functionality added to handle the target selection in the launch bar.

  • 88-88: The constant JOB_DELAY_MS is introduced to specify the delay before the job that reverts the target selection is scheduled. This delay allows other operations to complete before the job is run.

  • 121-125: The addDisposeListener method is modified to schedule a job that reverts the target selection when the parent composite is disposed. This is done to ensure that the target selection is reverted when the "Cancel" button is pressed. The scheduleRevertTargetJob method is called with the current target name as an argument.

  • 568-573: The doSave method is now called within the try block, which means that any CoreException thrown by this method will be caught and logged. This is a good practice as it ensures that exceptions are properly handled and do not cause the program to crash.

  • 713-718: The code for updating the launch configuration with the selected target has been removed from the if block. Instead, the updateLaunchBar method is called directly. This change simplifies the code and removes the need to handle a CoreException here.

  • 860-884: The scheduleRevertTargetJob method is introduced to schedule a job that reverts the target selection. The job checks if there is an active launch configuration and if so, it retrieves the target name from it. It then gets the launch target manager service and finds the launch target with the retrieved target name. Finally, it sets the active launch target to the found target. If any CoreException is thrown during this process, it is caught and logged, and the job is cancelled.

@sigmaaa
Copy link
Collaborator Author

sigmaaa commented Oct 30, 2023

Hi @AndriiFilippov, thanks for noticing. Fixed

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 9bc6b8b and fb6f882.
Files selected for processing (2)
  • bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/ui/TabDebugger.java (45 hunks)
  • bundles/com.espressif.idf.launch.serial.ui/src/com/espressif/idf/launch/serial/ui/internal/CMakeMainTab2.java (6 hunks)
Additional comments: 15
bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/ui/TabDebugger.java (9)
  • 29-39: New imports have been added. Ensure that these new dependencies are properly managed and do not conflict with existing ones.

  • 103-106: New constants have been defined. Ensure that these constants are used appropriately throughout the code.

  • 178-189: The createControl() method has been modified to set LaunchBarListener to ignore JTAG target changes and schedule the revert target job on dispose. Ensure that this change does not affect the functionality of the application.

  • 259-291: A new method scheduleRevertTargetJob() has been added. This method schedules a job for reverting the target change in the launch bar when the Cancel button is pressed. Ensure that this method is called appropriately and that it functions as expected.

  • 506-511: The new hunk has removed some code related to updating the launch configuration when the selected item is not equal to the updated selected target. Ensure that this removal doesn't affect the functionality of the application.

  • 1025-1027: The updateGdbServerActualPath() method has been added. This method updates the GDB server actual path. Ensure that this method is called appropriately and that it functions as expected.

  • 1092-1094: The initializeFrom() method has been modified to set the fConfiguration field and print debug statements. Ensure that this change does not affect the functionality of the application.

  • 1340-1358: The isValid() method has been modified to check for empty fields and set error messages. This is a good practice as it helps in validating the input and providing feedback to the user.

  • 1552-1554: The performApply() method has been modified to save the JTAG flash voltage, target, and board attributes. Ensure that these attributes are used appropriately throughout the code.

bundles/com.espressif.idf.launch.serial.ui/src/com/espressif/idf/launch/serial/ui/internal/CMakeMainTab2.java (6)
  • 41-44: New imports have been added to handle asynchronous jobs and monitor their progress. This is likely related to the new scheduleRevertTargetJob() method.

  • 88-88: A new constant JOB_DELAY_MS has been added. This constant is used to schedule the delay for the revertTargetJob.

  • 121-124: The createControl() method now schedules a job to revert the active launch target when the parent composite is disposed. This ensures that the target is reverted back to its original state when the user exits the tab.

  • 567-572: The saving of flash arguments has been removed from the performApply() method. This change simplifies the code and removes the need to handle a CoreException here.

  • 714-717: The widgetSelected() method has been updated to call updateLaunchBar() and update the board configurations when the selected target changes. This ensures that the launch bar and board configurations are always in sync with the selected target.

  • 859-886: A new method scheduleRevertTargetJob() has been added. This method schedules a job to revert the active launch target. The job is scheduled with a delay specified by JOB_DELAY_MS. If the active launch configuration is null or an exception occurs, the job is cancelled. Otherwise, the active launch target is set to the selected target and the job completes successfully.

@AndriiFilippov
Copy link
Collaborator

Hi @sigmaaa !

please, check this scenario:

create project -> go to "New Launch Configuration" -> select new config: (Run + ESP-IDF Application) -> click "Next" -> click "Cancel" -> the Launch Mode and Launch Target disappear.

@AndriiFilippov
Copy link
Collaborator

@sigmaaa hi !

this issue is not related to your PR, my bad.

LGTM 👍

Hi @sigmaaa !

please, check this scenario:

create project -> go to "New Launch Configuration" -> select new config: (Run + ESP-IDF Application) -> click "Next" -> click "Cancel" -> the Launch Mode and Launch Target disappear.

@kolipakakondal kolipakakondal merged commit 05ea8a4 into master Nov 2, 2023
7 checks passed
@kolipakakondal kolipakakondal deleted the IEP-1000 branch May 10, 2024 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants