-
Notifications
You must be signed in to change notification settings - Fork 13
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 validation for invalid memory references #131
Conversation
Avoid dispatching of a fetch memory request if there is not enough information available i.e no memory address is set. Add validation for the default values of the memory address widget. => Prompts a validation error if the memory inspector has been openend for an empty/not set address Fixes eclipse-cdt-cloud#126
src/webview/memory-webview-view.tsx
Outdated
@@ -82,7 +82,7 @@ const MEMORY_DISPLAY_CONFIGURATION_DEFAULTS: MemoryDisplayConfiguration = { | |||
showRadixPrefix: true, | |||
}; | |||
|
|||
const DEFAULT_READ_ARGUMENTS: Required<ReadMemoryArguments> = { | |||
export const DEFAULT_READ_ARGUMENTS: Required<ReadMemoryArguments> = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to move this into a more common place? Like ../common/messaging
or ../common/memory
? Looks like ReadMemoryArguments
is defined in ../common/messaging
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO I don't see any benefit in doing that.
The default constants defined in the memory-webview-view
(MEMORY_DISPLAY_CONFIGURATION_DEFAULTS,DEFAULT_SESSION_CONTEXT etc.) only serve the purpose of constructing the initial state for the App
component. They are an implementation detail of ( and scoped to) the webview/react app and should not leak into other components.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, not a too strong opinion about this. The main reason for raising this was to avoid a direct dependency between the memory-webview-view
and the options-widget
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @jreineckearm that it would be better to move this to a constants file (e.g. view-types.ts
) to avoid circular dependencies.
Thanks, @tortmayr ! Two corner cases which might be worth to address if effort is reasonable:
I don't know what's involved to fix item 3. It probably is the one with the least of the three findings. |
It seems like each of the three fields has its own We typically only see the actual field of the I guess the idea is to give the user feedback about the current value if they input an invalid value on accident.
|
Thanks, for looking into my feedback, @tortmayr !
Thanks, I see now. Ideally, the options widget shouldn't know about the window status. Revisiting this part again, I believe the label "Actual" is a bit ambiguous: it could mean both the actual value of the window contents and the last read argument. It is the latter. But let's not alter the label with this PR. Having had a bit more of a play with it, I think what confused me was the "Actual:" label below "Address" without a value. Especially when just adding spaces to the edit field (the trimming part). It could be enough to solve that confusion by trimming the input for comparison (and actually before passing to the memory read, I saw unexpected errors with our backend if passing in something untrimmed, though that may only be our debug adapter), and only show "Actual" below "Address" if the Does this make sense? |
- Move DEFAULT_READ_ARGUMENTS Into view-types.ts - Ensure that value of address option field gets trimmed before requesting a memory update - Dont render option field hints (Actual...) if the memory view is stil in intial state
@jreineckearm
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @tortmayr ! The behavior looks great now! :-)
Also thank you for moving the default arguments to a common file.
Good to go with this change
What it does
Avoid dispatching of a fetch memory request if there is not enough information available i.e no memory address is set.
Add validation for the default values of the memory address widget. => Prompts a validation error if the memory inspector has been openend for an empty/not set address
Fixes #126
How to test
Start a debug session and open the memory inspector via command palette
Observe that
Once the user manually changes the address, the error disappears and memory is fetched normally.
demo_val.mp4
Review checklist
Reminder for reviewers