From 467ac5701f5fc0e77ffa463219cb706c95b0af6a Mon Sep 17 00:00:00 2001 From: Dangyi Liu Date: Fri, 10 Jun 2022 21:17:53 -0700 Subject: [PATCH] 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 --- src/processor/cfi_frame_info.cc | 2 +- src/processor/cfi_frame_info_unittest.cc | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/processor/cfi_frame_info.cc b/src/processor/cfi_frame_info.cc index 280620f2..258a1194 100644 --- a/src/processor/cfi_frame_info.cc +++ b/src/processor/cfi_frame_info.cc @@ -81,7 +81,7 @@ bool CFIFrameInfo::FindCallerRegs(const RegisterValueMap& registers, working = registers; working[".cfa"] = cfa; if (!evaluator.EvaluateForValue(it->second, &value)) - return false; + continue; (*caller_registers)[it->first] = value; } diff --git a/src/processor/cfi_frame_info_unittest.cc b/src/processor/cfi_frame_info_unittest.cc index 8111437a..919aafac 100644 --- a/src/processor/cfi_frame_info_unittest.cc +++ b/src/processor/cfi_frame_info_unittest.cc @@ -254,8 +254,9 @@ TEST_F(Scope, RegsLackRA) { cfi.SetCFARule("42740329"); cfi.SetRARule("27045204"); cfi.SetRegisterRule("$r1", ".ra"); - ASSERT_FALSE(cfi.FindCallerRegs(registers, memory, - &caller_registers)); + ASSERT_TRUE(cfi.FindCallerRegs(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 {