Ignore failure in recovering optional registers

Evaluating CFI rules may fail due to e.g. the unavailability of the
memory or some register values. Failures in recovering registers other
than CFA or return address can be ignored because they are optional.

Bug: fuchsia:102034
Change-Id: Ia1d8bdb12766e32b5445b49d353fc71c63ab73e7
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3701260
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
This commit is contained in:
Dangyi Liu 2022-06-10 21:17:53 -07:00 committed by Joshua Peraza
parent c4c43b80ea
commit 467ac5701f
2 changed files with 6 additions and 3 deletions

View file

@ -81,7 +81,7 @@ bool CFIFrameInfo::FindCallerRegs(const RegisterValueMap<V>& registers,
working = registers;
working[".cfa"] = cfa;
if (!evaluator.EvaluateForValue(it->second, &value))
return false;
continue;
(*caller_registers)[it->first] = value;
}

View file

@ -254,8 +254,9 @@ TEST_F(Scope, RegsLackRA) {
cfi.SetCFARule("42740329");
cfi.SetRARule("27045204");
cfi.SetRegisterRule("$r1", ".ra");
ASSERT_FALSE(cfi.FindCallerRegs<uint64_t>(registers, memory,
&caller_registers));
ASSERT_TRUE(cfi.FindCallerRegs<uint64_t>(registers, memory,
&caller_registers));
ASSERT_EQ(caller_registers.end(), caller_registers.find("$r1"));
}
// Register rules can see the current frame's register values.
@ -439,6 +440,7 @@ TEST_F(ParseHandler, RegisterRules) {
handler.RARule("reg-for-ra");
handler.RegisterRule("reg1", "reg-for-reg1");
handler.RegisterRule("reg2", "reg-for-reg2");
handler.RegisterRule("reg3", "reg3");
registers["reg-for-cfa"] = 0x268a9a4a3821a797ULL;
registers["reg-for-ra"] = 0x6301b475b8b91c02ULL;
registers["reg-for-reg1"] = 0x06cde8e2ff062481ULL;
@ -449,6 +451,7 @@ TEST_F(ParseHandler, RegisterRules) {
ASSERT_EQ(0x6301b475b8b91c02ULL, caller_registers[".ra"]);
ASSERT_EQ(0x06cde8e2ff062481ULL, caller_registers["reg1"]);
ASSERT_EQ(0xff0c4f76403173e2ULL, caller_registers["reg2"]);
ASSERT_EQ(caller_registers.end(), caller_registers.find("reg3"));
}
struct SimpleCFIWalkerFixture {