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

Support different memory address representations for variables #107

Open
martin-fleck-at opened this issue Mar 13, 2024 · 4 comments
Open

Comments

@martin-fleck-at
Copy link
Contributor

(based on #96 (comment))

When querying the memory address for a variable, we currently only support hexadecimal addresses in our default implementation of the C Tracker. However, the ReadMemoryResponse and DisassembledInstruction also support the decimal format as an argument. We should at least think about supporting those two formats and may consider supporting other formats such as octal or binary as well. In those cases, we need to consider whether we do want to convert them to hex or decimal for further processing as they are the only formats mentioned explicitly by the DAP.

@martin-fleck-at
Copy link
Contributor Author

Furthermore, the current address matching returns the first match but does not require the whole string to be an address. I'd open that up for discussion and we should comment the code accordingly to the decision.

@martin-fleck-at
Copy link
Contributor Author

@colin-grant-work @jreineckearm An initial version of this that also supports decimal addresses was added as part of #96. However, I think we still need to discuss whether we also want to support other data formats (even though the DAP does not mention them explicitly) and whether we expect an address to be returned directly as opposed to extracting the address from the returned textual value as we do now.

@jreineckearm
Copy link
Contributor

I believe we should be good with decimal and hexadecimal for the time being in terms of number formats.
I haven't seen yet the usage of octal, float, binary, etc on such interfaces. Normally, you use hexadecimal address values in embedded (and other) debuggers. Or decimal if integers are passed as a string without bothering to format as hexadecimal.

What might be interesting to explore is if we gain anything from resolving textual memory references as they are (with evaluate requests) rather than using address-of on the variable name. Thinking here of expressions for structs like struct_base_address + member_offset. It may help to cover more use cases rather than assuming size-of and address-of operations are present in the debug adapters expression evaluator. That would be in addition to the current approach to preserve size-/address-of as last resort fallback. I am only worried about debug adapters that log multiple errors for each if those attempts. We may in fact enter territory here that is better covered by debug adapter contributions to the Memory Inspector extension. See discussions #68 and #77 .

@colin-grant-work
Copy link
Contributor

colin-grant-work commented Mar 14, 2024

I think that if we're ok supporting just bases 10 and 16, the work added in #96 should suffice: it saves the address-of request if we think we already know the address. Making other requests or using metadata that is specific to certain debug adapters is best handled by providing an alternative to the base implementation either upstream or downstream.

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

No branches or pull requests

3 participants