Merge pull request #41160 from mikeash/swift-inspect-concurrency

[RemoteMirror][swift-inspect] Add a command to inspect the state of the concurrency runtime.
This commit is contained in:
Mike Ash
2022-02-04 12:41:20 -05:00
committed by GitHub
15 changed files with 962 additions and 42 deletions

View File

@@ -40,6 +40,10 @@ public:
using ReadBytesResult =
std::unique_ptr<const void, std::function<void(const void *)>>;
template <typename T>
using ReadObjResult =
std::unique_ptr<const T, std::function<void(const void *)>>;
virtual bool queryDataLayout(DataLayoutQueryType type, void *inBuffer,
void *outBuffer) = 0;
@@ -90,6 +94,15 @@ public:
return true;
}
template <typename T>
ReadObjResult<T> readObj(RemoteAddress address) {
auto bytes = readBytes(address, sizeof(T));
auto deleter = bytes.get_deleter();
auto ptr = bytes.get();
bytes.release();
return ReadObjResult<T>(reinterpret_cast<const T *>(ptr), deleter);
}
/// Attempts to read 'size' bytes from the given address in the remote process.
///
/// Returns a pointer to the requested data and a function that must be called to