Introduce a new class for caching register set reads and writes
in the generic NativeRegisterContextRegisterInfo class. Use it
in the NetBSD plugin for initial testing.
The implementation provides a generic caching version of ReadRegister()
and WriteRegister() that call virtual methods implemented in actual
NativeRegisterContext* classes. It supports both caching reads,
and delayed writes. The cache is flushed whenever the thread resumes
execution or a new read follows writes.
The hook API consists of five methods that need to be implemented
in NativeRegisterContext* classes:
- GetRegisterSetForRegNum() to map register number to a register set number (the latter being opaque to NativeRegisterContextRegisterInfo).
- ReadRegisterSet() and WriteRegisterSet() to respectively read regset into cache and write it back. The actual cache storage is provided by final classes (m_gpr, m_fpr...).
- GetRegisterFromCache() and SetRegisterInCache() to respectively get and update individual register values inside the cache. The implementation of both methods can assume that ReadRegisterSet() has been called to fill the cache, and must not call either ReadRegisterSet() or WriteRegisterSet().
The NativeRegisterContextRegisterInfo class maintains state map of cache
for individual regsets, and issues appropriate ReadRegisterSet()
and WriteRegisterSet() calls to maintain it. It includes
a FlushRegisterSets() method that needs to be called whenever the thread
is about to resume execution.
I think using Optional<integral> would be better. Although, I'm not sure what are the cases where a register does not belong to any register set.