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

Add null check for Disassembly view source #295

Merged
merged 1 commit into from
Feb 23, 2023

Conversation

LizzMre
Copy link
Contributor

@LizzMre LizzMre commented Feb 22, 2023

Disassembly view is expected to be populated with lines that are fetched from a given source file. There might be the case where instructions on what lines to append are wrong. This results in a null response that will propagate through the code leading to a NPE.

The current commit is proofing the code from NPE by:

  • removing the source position of the lines that were not found within the given file
  • null checking the source before becoming a key element in the code flow
  • adding logging if expected lines are not found in the given file

Resolves: #287

@github-actions
Copy link

github-actions bot commented Feb 22, 2023

Test Results

     573 files       573 suites   45m 36s ⏱️
10 853 tests 10 719 ✔️ 134 💤 0
10 875 runs  10 741 ✔️ 134 💤 0

Results for commit d62e3fa.

♻️ This comment has been updated with latest results.

Copy link
Member

@jonahgraham jonahgraham left a comment

Choose a reason for hiding this comment

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

This looks good to me. May need some cosmetic and version changes to get it through the build, but the code change itself is done apart from the minor logging issue.

// Log error to indicate what is tha cause of the issue
String warningMessage = "Line(s) " + Integer.toString(first) + "-" + Integer.toString(last) //$NON-NLS-1$
+ " cannot be found in file: " + fFileKey + ".\nSkipping lines!"; //$NON-NLS-1$
DsfUIPlugin.logErrorMessage(warningMessage); //$NON-NLS-1$
Copy link
Member

Choose a reason for hiding this comment

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

This logErrorMessage has two minor problems:

  1. It discards the exception. I think you should log the exception too, it provides the stack trace/context to diagnose the problem
  2. What is logged in this case is Internal message logged from Debug UI as type INTERAL_ERROR, which seems a little to harsh here.
Suggested change
DsfUIPlugin.logErrorMessage(warningMessage); //$NON-NLS-1$
DsfUIPlugin.log(Status.warning(warningMessage, e));

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I updated this and the Bundle-Version. Thank you!

@jonahgraham
Copy link
Member

GitHub doesn't allow me to add a comment to a non-modified file. The build failed with this error:

The following bundles are missing a service segment version bump:
  - org.eclipse.cdt.dsf.ui
Please bump service segment by 100 if on master branch

which means this line

Bundle-Version: 2.7.0.qualifier

needs to be changed to

Bundle-Version: 2.7.100.qualifier

Disassembly view is expected to be populated with lines that are fetched from a given source file. There might be the case where instructions on what lines to append are wrong. This results in a null response that will propagate through the code leading to a NPE.

The current commit is proofing the code from NPE by:
- removing the source position of the lines that were not found within the given file
- null checking the source before becoming a key element in the code flow
- adding logging if expected lines are not found in the given file

Resolves: eclipse-cdt#287
@jonahgraham jonahgraham added the debug The debug components of CDT, anything to do with running or debugging the target. label Feb 23, 2023
@jonahgraham jonahgraham added this to the 11.1.0 milestone Feb 23, 2023
@jonahgraham
Copy link
Member

Thanks @LizzMre - this change looks good now. I am waiting on CI to confirm no issues and then it can be merged.

@LizzMre
Copy link
Contributor Author

LizzMre commented Feb 23, 2023

@jonahgraham Thank you very much for your help!

@jonahgraham jonahgraham merged commit 48b9774 into eclipse-cdt:main Feb 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
debug The debug components of CDT, anything to do with running or debugging the target.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Null check missing for input argument (source) when updating Disassembly view
2 participants