Skip to content

[Reflection] Separate MemoryReader::resolvePointer to distinguish related operations #41530

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

Conversation

kastiglione
Copy link
Contributor

@kastiglione kastiglione commented Feb 23, 2022

Until recently, MemoryReader had a single function resovlePointer which did two things, and has a somewhat vague name. The two things were:

  1. Tool-specific mapping between real addresses and tagged addresses (first implemented in swift-reflection-dump and then later in lldb)
  2. Finding a "symbol" for a given address

Recently, resolvePointerAsSymbol was added, which overloaded the term "resolve" and it added another way to deal with symbols for addresses. Symbols themselves were a bit muddled, as swift-reflection-dump was dealing with dynamic symbols aka bindings, while lldb was dealing in regular (static) symbols.

This change separates these two parts of functionality, and also divides symbol lookup into two cases. The API surface will now be:

  1. resolvePointer for mapping/tagging addresses
  2. getSymbol for looking up a symbol for an address
  3. getDynamicSymbol for looking up a dyld binding for an address

Note: each of these names could be improved. Some alternative terms: lookup instead of get, Binding or BindingName instead of DynamicSymbol. Maybe even another term instead of "resolve". Suggestions welcome!

Currently, swift-reflection-dump supports getDynamicSymbol but not getSymbol. For lldb it's the reverse, getSymbol is supported but getDynamicSymbol needs to be implemented.

For everything but lldb, this change is NFC. For lldb it fixes a bug where LLDBMemoryReader returns regular symbols where we should instead be returning dynamic symbols.

@kastiglione
Copy link
Contributor Author

@swift-ci test

@kastiglione
Copy link
Contributor Author

@swift-ci test macOS

@kastiglione kastiglione changed the title [Reflection] Update MemoryReader to distinguish related operations [Reflection] Separate MemoryReader::resolvePointer to distinguish related operations Feb 24, 2022
@kastiglione kastiglione marked this pull request as ready for review February 24, 2022 17:53
Comment on lines 151 to 154
virtual llvm::Optional<RemoteAbsolutePointer>
resolvePointerAsSymbol(RemoteAddress address) {
return llvm::None;
}
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 have kept this in to allow this change to allow this PR to be free of a dependent change in llvm-project. Later, it will be removed.

@kastiglione
Copy link
Contributor Author

@swift-ci test

@kastiglione kastiglione merged commit cfe0b97 into main Mar 12, 2022
@kastiglione kastiglione deleted the Reflection-Update-MemoryReader-to-distinguish-related-operations branch March 12, 2022 06:36
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.

3 participants