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

Make memory address padding configurable #89

Merged
merged 4 commits into from
Mar 6, 2024

Conversation

planger
Copy link
Contributor

@planger planger commented Mar 1, 2024

What it does

Introduces VS Code setting for memory address padding with the values

  • Unpadded
  • Minimal padding
  • 32 bit padding
  • 64 bit padding

Fixes #76

How to test

  • Open memory a inspector instance and switch address padding in the options
  • Observe whether the memory address is adjusted accordingly
  • Change setting memory-inspector.addressPadding in VS Code settings
  • Open new memory inspector view and ensure the new padding setting is used
  • Change VS Code setting again and reset options in memory view to check if it resets properly
memory-address-padding.mp4

Review checklist

Reminder for reviewers

src/webview/memory-webview-view.tsx Outdated Show resolved Hide resolved
src/plugin/memory-webview-main.ts Show resolved Hide resolved
fetchMemory={this.props.fetchMemory}
isMemoryFetching={this.props.isMemoryFetching}
scrollingBehavior={this.props.scrollingBehavior}
addressPadding={this.props.addressPadding}
Copy link
Contributor

Choose a reason for hiding this comment

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

I have some misgivings about the number of places we're passing around the new memoized padding / length values when they're relevant to only one column, and we should avoid knowing too much about column internals outside of those contributions.

One idea about how to handle it would be to introduce a new lifecycle on the columns so that they can update any relevant state onComponentDidUpdate or whatever seems best. Another (obviously beyond the scope of this PR) would be to use something other than React so that individual columns could have tighter control of their own rendering.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean -- conceptually -- onComponentDidUpdate in App, we invoke an update on each column, passing them a new object state to avoid having to pass column-specific state down to the MemoryWidget/MemoryTable?
That sounds like a good idea to me!
I feel though such a change probably deserves a separate PR, wdyt?

Copy link
Contributor

Choose a reason for hiding this comment

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

Do you mean -- conceptually -- onComponentDidUpdate in App, we invoke an update on each column, passing them a new object state to avoid having to pass column-specific state down to the MemoryWidget/MemoryTable?

Yes, exactly. That way columns are kept up-to-date on changes in props/state and can store the results of any calculations they'd otherwise repeat.

I feel though such a change probably deserves a separate PR, wdyt?

I'd be inclined to do it here because this PR is introducing a new prop that's being passed in a style we might like to avoid, but if you feel strongly, we could put it off.

Copy link
Contributor

Choose a reason for hiding this comment

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

To be frank: I agree with @planger that this should be addressed in a separate refactoring PR.
It is a great idea to have more fine granular control over updates. In the sense of avoiding to flood components with "unsed" or just passed through props. But it sounds like this is something that should be properly analyzed and rolled out across the board. I am sure there is more potential for this beyond the address padding. And a separate PR will give clearer separation of the feature enhancement and refactoring work.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm ok with that approach, though I think it's not generally a good idea to acknowledge that something is not the direction we want to go and then move forward with it anyway. I've approved the PR - @planger, feel free to make whatever changes to the wording of the preference enum descriptions that you prefer and merge at your convenience.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks, @colin-grant-work ! I appreciate that the situation isn't ideal. Let's make sure that we address this as soon as we can.

@planger
Copy link
Contributor Author

planger commented Mar 1, 2024

@colin-grant-work Thank you very much for your review and raising your ideas for improvements! I commented on them above, but would prefer to address those general improvements in separate PRs, unless you feel otherwise.

package.json Outdated
],
"default": "Minimal",
"enumDescriptions": [
"Minimal padding based on the longest address in range.",
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a few suggestions for the wording:

Pads address values with leading zeroes to largest address in loaded range.
Disables padding of address values with leading zeroes.
Pads address values with leading zeroes to 32-bit.
Pads address values with leading zeroes to 64-bit.

zeroes could also be replaced by 0s. Use should be also aligned with below description text.

@colin-grant-work , @gbodeen , @thegecko , any thoughts about this from native English speakers?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the 'with leading zeroes' part could be a bit redundant, since that's also part of the preference description. Personally, I'd go short, maybe something like

[
"Pads to shortest uniform length", // This one is the trickiest one to describe clearly. Open to suggestions.
"Disables padding",
"Pads to 32 bits",
"Pads to 64 bits"
]

Copy link
Contributor

Choose a reason for hiding this comment

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

Probably

[
"Pads to largest address width in loaded range", // This one is the trickiest one to describe clearly. Open to suggestions.
"Disables padding",
"Pads to 32 bits",
"Pads to 64 bits"
]

?

@jreineckearm
Copy link
Contributor

Tested the changes and the functionality works nicely!
Just added some thoughts on the wording for the new setting in the extension manifest.

planger and others added 3 commits March 6, 2024 18:51
Introduces VS Code setting for memory address padding with the values
  * Unpadded
  * Minimal padding
  * 32 bit padding
  * 64 bit padding

Fixes eclipse-cdt-cloud#76
@martin-fleck-at
Copy link
Contributor

martin-fleck-at commented Mar 6, 2024

Since Philip is out this week, I rebased the PR to resolve a merge conflict and improved the wording based on your suggestions. Thank you very much!

@thegecko
Copy link
Contributor

thegecko commented Mar 6, 2024

Good to merge this @martin-fleck-at ?

@planger
Copy link
Contributor Author

planger commented Mar 6, 2024

Thanks @martin-fleck-at for taking over the maintenance on this PR and thanks @colin-grant-work and @jreineckearm for the reviews. I think this is good to go in and I'll open an issue about the refactoring we were discussing above.

Edit: #95

@planger planger merged commit 7416dc9 into eclipse-cdt-cloud:main Mar 6, 2024
5 checks passed
@planger planger deleted the address-padding branch March 6, 2024 19:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pad memory address values with leading zeros
5 participants