unwindstack: RegsArm64: fix harmless off by 1 + iterate GPRs contiguously
The memcpy should be for 31 GPRs, [x0, x30]. Currently it (accidentally) also copies over the SP register (which ends up being harmless, as the layouts match, and the value is reassigned again anyway). Separately, I'm including an optional change for the iteration order, since LR is the x30 GPR, it makes slightly more sense to print it immediately after x29. However, this is a change in behaviour, so I can undo the change if you think it's not worth it. Tested: atest libunwindstack_unit_test Change-Id: Ib6b81f8ee3a9a526bfabe4b09b327f083c855fb8
This commit is contained in:
parent
be27975fff
commit
92237bad6a
2 changed files with 4 additions and 4 deletions
|
@ -100,8 +100,8 @@ void RegsArm64::IterateRegisters(std::function<void(const char*, uint64_t)> fn)
|
|||
fn("x27", regs_[ARM64_REG_R27]);
|
||||
fn("x28", regs_[ARM64_REG_R28]);
|
||||
fn("x29", regs_[ARM64_REG_R29]);
|
||||
fn("sp", regs_[ARM64_REG_SP]);
|
||||
fn("lr", regs_[ARM64_REG_LR]);
|
||||
fn("sp", regs_[ARM64_REG_SP]);
|
||||
fn("pc", regs_[ARM64_REG_PC]);
|
||||
fn("pst", regs_[ARM64_REG_PSTATE]);
|
||||
}
|
||||
|
@ -110,10 +110,10 @@ Regs* RegsArm64::Read(void* remote_data) {
|
|||
arm64_user_regs* user = reinterpret_cast<arm64_user_regs*>(remote_data);
|
||||
|
||||
RegsArm64* regs = new RegsArm64();
|
||||
memcpy(regs->RawData(), &user->regs[0], (ARM64_REG_R31 + 1) * sizeof(uint64_t));
|
||||
memcpy(regs->RawData(), &user->regs[0], (ARM64_REG_R30 + 1) * sizeof(uint64_t));
|
||||
uint64_t* reg_data = reinterpret_cast<uint64_t*>(regs->RawData());
|
||||
reg_data[ARM64_REG_PC] = user->pc;
|
||||
reg_data[ARM64_REG_SP] = user->sp;
|
||||
reg_data[ARM64_REG_PC] = user->pc;
|
||||
reg_data[ARM64_REG_PSTATE] = user->pstate;
|
||||
return regs;
|
||||
}
|
||||
|
|
|
@ -111,8 +111,8 @@ std::vector<Register> ExpectedRegisters<RegsArm64>() {
|
|||
result.push_back({"x27", ARM64_REG_R27});
|
||||
result.push_back({"x28", ARM64_REG_R28});
|
||||
result.push_back({"x29", ARM64_REG_R29});
|
||||
result.push_back({"sp", ARM64_REG_SP});
|
||||
result.push_back({"lr", ARM64_REG_LR});
|
||||
result.push_back({"sp", ARM64_REG_SP});
|
||||
result.push_back({"pc", ARM64_REG_PC});
|
||||
result.push_back({"pst", ARM64_REG_PSTATE});
|
||||
return result;
|
||||
|
|
Loading…
Reference in a new issue