Index: src/processor/cfi_frame_info_unittest.cc |
=================================================================== |
--- a/src/processor/cfi_frame_info_unittest.cc |
+++ b/src/processor/cfi_frame_info_unittest.cc |
@@ -111,19 +111,18 @@ TEST_F(Simple, NoRA) { |
TEST_F(Simple, SetCFAAndRARule) { |
ExpectNoMemoryReferences(); |
cfi.SetCFARule(Module::Expr("330903416631436410")); |
cfi.SetRARule(Module::Expr("5870666104170902211")); |
ASSERT_TRUE(cfi.FindCallerRegs<u_int64_t>(registers, memory, |
&caller_registers)); |
- ASSERT_EQ(2U, caller_registers.size()); |
- ASSERT_EQ(330903416631436410ULL, caller_registers[ustr__ZDcfa()]); |
- ASSERT_EQ(5870666104170902211ULL, caller_registers[ustr__ZDra()]); |
+ ASSERT_EQ(330903416631436410ULL, caller_registers.get(ustr__ZDcfa())); |
+ ASSERT_EQ(5870666104170902211ULL, caller_registers.get(ustr__ZDra())); |
ASSERT_EQ(".cfa: 330903416631436410 .ra: 5870666104170902211", |
cfi.Serialize()); |
} |
TEST_F(Simple, SetManyRules) { |
ExpectNoMemoryReferences(); |
@@ -136,23 +135,22 @@ TEST_F(Simple, SetManyRules) { |
const UniqueString* reg4 = ToUniqueString("uncopyrightables"); |
cfi.SetRegisterRule(reg1, Module::Expr(".cfa 54370437 *")); |
cfi.SetRegisterRule(reg2, Module::Expr("24076308 .cfa +")); |
cfi.SetRegisterRule(reg3, Module::Expr(".cfa 29801007 -")); |
cfi.SetRegisterRule(reg4, Module::Expr("92642917 .cfa /")); |
ASSERT_TRUE(cfi.FindCallerRegs<u_int64_t>(registers, memory, |
&caller_registers)); |
- ASSERT_EQ(6U, caller_registers.size()); |
- ASSERT_EQ(7664691U, caller_registers[ustr__ZDcfa()]); |
- ASSERT_EQ(107469446U, caller_registers[ustr__ZDra()]); |
- ASSERT_EQ(416732599139967ULL, caller_registers[reg1]); |
- ASSERT_EQ(31740999U, caller_registers[reg2]); |
- ASSERT_EQ(-22136316ULL, caller_registers[reg3]); |
- ASSERT_EQ(12U, caller_registers[reg4]); |
+ ASSERT_EQ(7664691U, caller_registers.get(ustr__ZDcfa())); |
+ ASSERT_EQ(107469446U, caller_registers.get(ustr__ZDra())); |
+ ASSERT_EQ(416732599139967ULL, caller_registers.get(reg1)); |
+ ASSERT_EQ(31740999U, caller_registers.get(reg2)); |
+ ASSERT_EQ(-22136316ULL, caller_registers.get(reg3)); |
+ ASSERT_EQ(12U, caller_registers.get(reg4)); |
ASSERT_EQ(".cfa: $temp1 68737028 = $temp2 61072337 = $temp1 $temp2 - " |
".ra: .cfa 99804755 + " |
"pubvexingfjordschmaltzy: .cfa 29801007 - " |
"register1: .cfa 54370437 * " |
"uncopyrightables: 92642917 .cfa / " |
"vodkathumbscrewingly: 24076308 .cfa +", |
cfi.Serialize()); |
} |
@@ -160,19 +158,18 @@ TEST_F(Simple, SetManyRules) { |
TEST_F(Simple, RulesOverride) { |
ExpectNoMemoryReferences(); |
cfi.SetCFARule(Module::Expr("330903416631436410")); |
cfi.SetRARule(Module::Expr("5870666104170902211")); |
cfi.SetCFARule(Module::Expr("2828089117179001")); |
ASSERT_TRUE(cfi.FindCallerRegs<u_int64_t>(registers, memory, |
&caller_registers)); |
- ASSERT_EQ(2U, caller_registers.size()); |
- ASSERT_EQ(2828089117179001ULL, caller_registers[ustr__ZDcfa()]); |
- ASSERT_EQ(5870666104170902211ULL, caller_registers[ustr__ZDra()]); |
+ ASSERT_EQ(2828089117179001ULL, caller_registers.get(ustr__ZDcfa())); |
+ ASSERT_EQ(5870666104170902211ULL, caller_registers.get(ustr__ZDra())); |
ASSERT_EQ(".cfa: 2828089117179001 .ra: 5870666104170902211", |
cfi.Serialize()); |
} |
class Scope: public CFIFixture, public Test { }; |
// There should be no value for .cfa in scope when evaluating the CFA rule. |
TEST_F(Scope, CFALacksCFA) { |
@@ -196,37 +193,35 @@ TEST_F(Scope, CFALacksRA) { |
// The current frame's registers should be in scope when evaluating |
// the CFA rule. |
TEST_F(Scope, CFASeesCurrentRegs) { |
ExpectNoMemoryReferences(); |
const UniqueString* reg1 = ToUniqueString(".baraminology"); |
const UniqueString* reg2 = ToUniqueString(".ornithorhynchus"); |
- registers[reg1] = 0x06a7bc63e4f13893ULL; |
- registers[reg2] = 0x5e0bf850bafce9d2ULL; |
+ registers.set(reg1, 0x06a7bc63e4f13893ULL); |
+ registers.set(reg2, 0x5e0bf850bafce9d2ULL); |
cfi.SetCFARule(Module::Expr(".baraminology .ornithorhynchus +")); |
cfi.SetRARule(Module::Expr("0")); |
ASSERT_TRUE(cfi.FindCallerRegs<u_int64_t>(registers, memory, |
&caller_registers)); |
- ASSERT_EQ(2U, caller_registers.size()); |
ASSERT_EQ(0x06a7bc63e4f13893ULL + 0x5e0bf850bafce9d2ULL, |
- caller_registers[ustr__ZDcfa()]); |
+ caller_registers.get(ustr__ZDcfa())); |
} |
// .cfa should be in scope in the return address expression. |
TEST_F(Scope, RASeesCFA) { |
ExpectNoMemoryReferences(); |
cfi.SetCFARule(Module::Expr("48364076")); |
cfi.SetRARule(Module::Expr(".cfa")); |
ASSERT_TRUE(cfi.FindCallerRegs<u_int64_t>(registers, memory, |
&caller_registers)); |
- ASSERT_EQ(2U, caller_registers.size()); |
- ASSERT_EQ(48364076U, caller_registers[ustr__ZDra()]); |
+ ASSERT_EQ(48364076U, caller_registers.get(ustr__ZDra())); |
} |
// There should be no value for .ra in scope when evaluating the CFA rule. |
TEST_F(Scope, RALacksRA) { |
ExpectNoMemoryReferences(); |
cfi.SetCFARule(Module::Expr("0")); |
cfi.SetRARule(Module::Expr(".ra")); |
@@ -236,36 +231,34 @@ TEST_F(Scope, RALacksRA) { |
// The current frame's registers should be in scope in the return |
// address expression. |
TEST_F(Scope, RASeesCurrentRegs) { |
ExpectNoMemoryReferences(); |
cfi.SetCFARule(Module::Expr("10359370")); |
const UniqueString* reg1 = ToUniqueString("noachian"); |
- registers[reg1] = 0x54dc4a5d8e5eb503ULL; |
+ registers.set(reg1, 0x54dc4a5d8e5eb503ULL); |
cfi.SetRARule(Module::Expr(reg1, 0, false)); |
ASSERT_TRUE(cfi.FindCallerRegs<u_int64_t>(registers, memory, |
&caller_registers)); |
- ASSERT_EQ(2U, caller_registers.size()); |
- ASSERT_EQ(0x54dc4a5d8e5eb503ULL, caller_registers[ustr__ZDra()]); |
+ ASSERT_EQ(0x54dc4a5d8e5eb503ULL, caller_registers.get(ustr__ZDra())); |
} |
// .cfa should be in scope for register rules. |
TEST_F(Scope, RegistersSeeCFA) { |
ExpectNoMemoryReferences(); |
cfi.SetCFARule(Module::Expr("6515179")); |
cfi.SetRARule(Module::Expr(".cfa")); |
const UniqueString* reg1 = ToUniqueString("rogerian"); |
cfi.SetRegisterRule(reg1, Module::Expr(".cfa")); |
ASSERT_TRUE(cfi.FindCallerRegs<u_int64_t>(registers, memory, |
&caller_registers)); |
- ASSERT_EQ(3U, caller_registers.size()); |
- ASSERT_EQ(6515179U, caller_registers[reg1]); |
+ ASSERT_EQ(6515179U, caller_registers.get(reg1)); |
} |
// The return address should not be in scope for register rules. |
TEST_F(Scope, RegsLackRA) { |
ExpectNoMemoryReferences(); |
cfi.SetCFARule(Module::Expr("42740329")); |
cfi.SetRARule(Module::Expr("27045204")); |
@@ -276,27 +269,26 @@ TEST_F(Scope, RegsLackRA) { |
} |
// Register rules can see the current frame's register values. |
TEST_F(Scope, RegsSeeRegs) { |
ExpectNoMemoryReferences(); |
const UniqueString* reg1 = ToUniqueString("$r1"); |
const UniqueString* reg2 = ToUniqueString("$r2"); |
- registers[reg1] = 0x6ed3582c4bedb9adULL; |
- registers[reg2] = 0xd27d9e742b8df6d0ULL; |
+ registers.set(reg1, 0x6ed3582c4bedb9adULL); |
+ registers.set(reg2, 0xd27d9e742b8df6d0ULL); |
cfi.SetCFARule(Module::Expr("88239303")); |
cfi.SetRARule(Module::Expr("30503835")); |
cfi.SetRegisterRule(reg1, Module::Expr("$r1 42175211 = $r2")); |
cfi.SetRegisterRule(reg2, Module::Expr("$r2 21357221 = $r1")); |
ASSERT_TRUE(cfi.FindCallerRegs<u_int64_t>(registers, memory, |
&caller_registers)); |
- ASSERT_EQ(4U, caller_registers.size()); |
- ASSERT_EQ(0xd27d9e742b8df6d0ULL, caller_registers[reg1]); |
- ASSERT_EQ(0x6ed3582c4bedb9adULL, caller_registers[reg2]); |
+ ASSERT_EQ(0xd27d9e742b8df6d0ULL, caller_registers.get(reg1)); |
+ ASSERT_EQ(0x6ed3582c4bedb9adULL, caller_registers.get(reg2)); |
} |
// Each rule's temporaries are separate. |
TEST_F(Scope, SeparateTempsRA) { |
ExpectNoMemoryReferences(); |
cfi.SetCFARule(Module::Expr("$temp1 76569129 = $temp1")); |
cfi.SetRARule(Module::Expr("0")); |
@@ -440,39 +432,39 @@ class ParseHandlerFixture: public CFIFix |
CFIFrameInfoParseHandler handler; |
}; |
class ParseHandler: public ParseHandlerFixture, public Test { }; |
TEST_F(ParseHandler, CFARARule) { |
handler.CFARule("reg-for-cfa"); |
handler.RARule("reg-for-ra"); |
- registers[ToUniqueString("reg-for-cfa")] = 0x268a9a4a3821a797ULL; |
- registers[ToUniqueString("reg-for-ra")] = 0x6301b475b8b91c02ULL; |
+ registers.set(ToUniqueString("reg-for-cfa"), 0x268a9a4a3821a797ULL); |
+ registers.set(ToUniqueString("reg-for-ra"), 0x6301b475b8b91c02ULL); |
ASSERT_TRUE(cfi.FindCallerRegs<u_int64_t>(registers, memory, |
&caller_registers)); |
- ASSERT_EQ(0x268a9a4a3821a797ULL, caller_registers[ustr__ZDcfa()]); |
- ASSERT_EQ(0x6301b475b8b91c02ULL, caller_registers[ustr__ZDra()]); |
+ ASSERT_EQ(0x268a9a4a3821a797ULL, caller_registers.get(ustr__ZDcfa())); |
+ ASSERT_EQ(0x6301b475b8b91c02ULL, caller_registers.get(ustr__ZDra())); |
} |
TEST_F(ParseHandler, RegisterRules) { |
handler.CFARule("reg-for-cfa"); |
handler.RARule("reg-for-ra"); |
handler.RegisterRule(ToUniqueString("reg1"), "reg-for-reg1"); |
handler.RegisterRule(ToUniqueString("reg2"), "reg-for-reg2"); |
- registers[ToUniqueString("reg-for-cfa")] = 0x268a9a4a3821a797ULL; |
- registers[ToUniqueString("reg-for-ra")] = 0x6301b475b8b91c02ULL; |
- registers[ToUniqueString("reg-for-reg1")] = 0x06cde8e2ff062481ULL; |
- registers[ToUniqueString("reg-for-reg2")] = 0xff0c4f76403173e2ULL; |
+ registers.set(ToUniqueString("reg-for-cfa"), 0x268a9a4a3821a797ULL); |
+ registers.set(ToUniqueString("reg-for-ra"), 0x6301b475b8b91c02ULL); |
+ registers.set(ToUniqueString("reg-for-reg1"), 0x06cde8e2ff062481ULL); |
+ registers.set(ToUniqueString("reg-for-reg2"), 0xff0c4f76403173e2ULL); |
ASSERT_TRUE(cfi.FindCallerRegs<u_int64_t>(registers, memory, |
&caller_registers)); |
- ASSERT_EQ(0x268a9a4a3821a797ULL, caller_registers[ustr__ZDcfa()]); |
- ASSERT_EQ(0x6301b475b8b91c02ULL, caller_registers[ustr__ZDra()]); |
- ASSERT_EQ(0x06cde8e2ff062481ULL, caller_registers[ToUniqueString("reg1")]); |
- ASSERT_EQ(0xff0c4f76403173e2ULL, caller_registers[ToUniqueString("reg2")]); |
+ ASSERT_EQ(0x268a9a4a3821a797ULL, caller_registers.get(ustr__ZDcfa())); |
+ ASSERT_EQ(0x6301b475b8b91c02ULL, caller_registers.get(ustr__ZDra())); |
+ ASSERT_EQ(0x06cde8e2ff062481ULL, caller_registers.get(ToUniqueString("reg1"))); |
+ ASSERT_EQ(0xff0c4f76403173e2ULL, caller_registers.get(ToUniqueString("reg2"))); |
} |
struct SimpleCFIWalkerFixture { |
struct RawContext { |
u_int64_t r0, r1, r2, r3, r4, sp, pc; |
}; |
enum Validity { |
R0_VALID = 0x01, |