diff options
| author | Pavel Labath <pavel@labath.sk> | 2019-12-03 11:39:20 +0100 |
|---|---|---|
| committer | Pavel Labath <pavel@labath.sk> | 2019-12-03 11:39:20 +0100 |
| commit | 2b8db387f2a616f39a077ede18c6366f2ea9f203 (patch) | |
| tree | bc031616f89a752df513eeb04662dbf0ab64d992 /lldb/source/Target/ABI.cpp | |
| parent | 09667bc1920463107684a566c3f2c3cef9b156e7 (diff) | |
| download | bcm5719-llvm-2b8db387f2a616f39a077ede18c6366f2ea9f203.tar.gz bcm5719-llvm-2b8db387f2a616f39a077ede18c6366f2ea9f203.zip | |
[lldb] Move register info "augmentation" from gdb-remote into ABI
Summary:
Previously the ABI plugin exposed some "register infos" and the
gdb-remote code used those to fill in the missing bits. Now, the
"filling in" code is in the ABI plugin itself, and the gdb-remote code
just invokes that.
The motivation for this is two-fold:
a) the "augmentation" logic is useful outside of process gdb-remote. For
instance, it would allow us to avoid repeating the register number
definitions in minidump code.
b) It gives more implementation freedom to the ABI classes. Now that
these "register infos" are essentially implementation details, classes
can use other methods to obtain dwarf/eh_frame register numbers -- for
instance they can consult llvm MC layer.
Since the augmentation code was not currently tested anywhere, I took
the opportunity to create a simple test for it.
Reviewers: jasonmolenda, clayborg, tatyana-krasnukha
Subscribers: aprantl, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D70906
Diffstat (limited to 'lldb/source/Target/ABI.cpp')
| -rw-r--r-- | lldb/source/Target/ABI.cpp | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/lldb/source/Target/ABI.cpp b/lldb/source/Target/ABI.cpp index 005261e0dde..6217ee2ed9c 100644 --- a/lldb/source/Target/ABI.cpp +++ b/lldb/source/Target/ABI.cpp @@ -63,24 +63,6 @@ bool ABI::GetRegisterInfoByName(ConstString name, RegisterInfo &info) { return false; } -bool ABI::GetRegisterInfoByKind(RegisterKind reg_kind, uint32_t reg_num, - RegisterInfo &info) { - if (reg_kind < eRegisterKindEHFrame || reg_kind >= kNumRegisterKinds) - return false; - - uint32_t count = 0; - const RegisterInfo *register_info_array = GetRegisterInfoArray(count); - if (register_info_array) { - for (uint32_t i = 0; i < count; ++i) { - if (register_info_array[i].kinds[reg_kind] == reg_num) { - info = register_info_array[i]; - return true; - } - } - } - return false; -} - ValueObjectSP ABI::GetReturnValueObject(Thread &thread, CompilerType &ast_type, bool persistent) const { if (!ast_type.IsValid()) @@ -229,3 +211,20 @@ std::unique_ptr<llvm::MCRegisterInfo> ABI::MakeMCRegisterInfo(const ArchSpec &ar assert(info_up); return info_up; } + +void ABI::AugmentRegisterInfo(RegisterInfo &info) { + if (info.kinds[eRegisterKindEHFrame] != LLDB_INVALID_REGNUM && + info.kinds[eRegisterKindDWARF] != LLDB_INVALID_REGNUM) + return; + + RegisterInfo abi_info; + if (!GetRegisterInfoByName(ConstString(info.name), abi_info)) + return; + + if (info.kinds[eRegisterKindEHFrame] == LLDB_INVALID_REGNUM) + info.kinds[eRegisterKindEHFrame] = abi_info.kinds[eRegisterKindEHFrame]; + if (info.kinds[eRegisterKindDWARF] == LLDB_INVALID_REGNUM) + info.kinds[eRegisterKindDWARF] = abi_info.kinds[eRegisterKindDWARF]; + if (info.kinds[eRegisterKindGeneric] == LLDB_INVALID_REGNUM) + info.kinds[eRegisterKindGeneric] = abi_info.kinds[eRegisterKindGeneric]; +} |

