Skip to content

Commit

Permalink
Ignore failure in recovering optional registers
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
liudangyi authored and Joshua Peraza committed Jun 14, 2022
1 parent c4c43b8 commit 467ac57
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/processor/cfi_frame_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
7 changes: 5 additions & 2 deletions src/processor/cfi_frame_info_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
Expand All @@ -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 {
Expand Down

0 comments on commit 467ac57

Please sign in to comment.