diff options
author | Christopher Ferris <cferris@google.com> | 2018-08-02 15:21:37 -0700 |
---|---|---|
committer | Christopher Ferris <cferris@google.com> | 2018-08-02 18:01:02 -0700 |
commit | 55f79ae7068d292e5e957d2194b756bbc87e7af4 (patch) | |
tree | 62c31edce3f8f4d09e8535dd6738ca28fd9c6d02 /libunwindstack/RegsInfo.h | |
parent | 3e532dfdfd8987e2a705a00e8dcd20c55da44812 (diff) | |
download | unwinding-55f79ae7068d292e5e957d2194b756bbc87e7af4.tar.gz |
Fix incorrect left shifts.
Bug: 112142060
Test: New unit tests pass.
Change-Id: I0c47b22582f0bf75ab503364a337c7de4de3ec43
Diffstat (limited to 'libunwindstack/RegsInfo.h')
-rw-r--r-- | libunwindstack/RegsInfo.h | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/libunwindstack/RegsInfo.h b/libunwindstack/RegsInfo.h index 47825f5..e6dd33c 100644 --- a/libunwindstack/RegsInfo.h +++ b/libunwindstack/RegsInfo.h @@ -25,11 +25,13 @@ namespace unwindstack { template <typename AddressType> struct RegsInfo { + static constexpr size_t MAX_REGISTERS = 64; + RegsInfo(RegsImpl<AddressType>* regs) : regs(regs) {} RegsImpl<AddressType>* regs = nullptr; uint64_t saved_reg_map = 0; - AddressType saved_regs[64]; + AddressType saved_regs[MAX_REGISTERS]; inline AddressType Get(uint32_t reg) { if (IsSaved(reg)) { @@ -39,23 +41,23 @@ struct RegsInfo { } inline AddressType* Save(uint32_t reg) { - if (reg > sizeof(saved_regs) / sizeof(AddressType)) { - // This should never happen as since all currently supported - // architectures have the total number of registers < 64. + if (reg > MAX_REGISTERS) { + // This should never happen since all currently supported + // architectures have < 64 total registers. abort(); } - saved_reg_map |= 1 << reg; + saved_reg_map |= 1ULL << reg; saved_regs[reg] = (*regs)[reg]; return &(*regs)[reg]; } inline bool IsSaved(uint32_t reg) { - if (reg > sizeof(saved_regs) / sizeof(AddressType)) { - // This should never happen as since all currently supported - // architectures have the total number of registers < 64. + if (reg > MAX_REGISTERS) { + // This should never happen since all currently supported + // architectures have < 64 total registers. abort(); } - return saved_reg_map & (1 << reg); + return saved_reg_map & (1ULL << reg); } inline uint16_t Total() { return regs->total_regs(); } |