diff --git a/src/processor/basic_source_line_resolver.cc b/src/processor/basic_source_line_resolver.cc index 0bd17124..2440495e 100644 --- a/src/processor/basic_source_line_resolver.cc +++ b/src/processor/basic_source_line_resolver.cc @@ -128,18 +128,18 @@ class BasicSourceLineResolver::Module { friend class BasicSourceLineResolver; typedef map FileMap; - // The types for stack_info_. This is equivalent to MS DIA's + // The types for windows_frame_info_. This is equivalent to MS DIA's // StackFrameTypeEnum. Each identifies a different type of frame // information, although all are represented in the symbol file in the - // same format. These are used as indices to the stack_info_ array. - enum StackInfoTypes { - STACK_INFO_FPO = 0, - STACK_INFO_TRAP, // not used here - STACK_INFO_TSS, // not used here - STACK_INFO_STANDARD, - STACK_INFO_FRAME_DATA, - STACK_INFO_LAST, // must be the last sequentially-numbered item - STACK_INFO_UNKNOWN = -1 + // same format. These are used as indices to the windows_frame_info_ array. + enum WindowsFrameInfoTypes { + WINDOWS_FRAME_INFO_FPO = 0, + WINDOWS_FRAME_INFO_TRAP, // not used here + WINDOWS_FRAME_INFO_TSS, // not used here + WINDOWS_FRAME_INFO_STANDARD, + WINDOWS_FRAME_INFO_FRAME_DATA, + WINDOWS_FRAME_INFO_LAST, // must be the last sequentially-numbered item + WINDOWS_FRAME_INFO_UNKNOWN = -1 }; // Splits line into at most max_tokens space-separated tokens, placing @@ -167,7 +167,7 @@ class BasicSourceLineResolver::Module { // Returns false if an error occurs. bool ParsePublicSymbol(char *public_line); - // Parses a stack frame info declaration, storing it in stack_info_. + // Parses a stack frame info declaration, storing it in windows_frame_info_. bool ParseStackInfo(char *stack_info_line); string name_; @@ -175,12 +175,12 @@ class BasicSourceLineResolver::Module { RangeMap< MemAddr, linked_ptr > functions_; AddressMap< MemAddr, linked_ptr > public_symbols_; - // Each element in the array is a ContainedRangeMap for a type listed in - // StackInfoTypes. These are split by type because there may be overlaps - // between maps of different types, but some information is only available - // as certain types. + // Each element in the array is a ContainedRangeMap for a type + // listed in WindowsFrameInfoTypes. These are split by type because + // there may be overlaps between maps of different types, but some + // information is only available as certain types. ContainedRangeMap< MemAddr, linked_ptr > - stack_info_[STACK_INFO_LAST]; + windows_frame_info_[WINDOWS_FRAME_INFO_LAST]; }; BasicSourceLineResolver::BasicSourceLineResolver() : modules_(new ModuleMap) { @@ -469,13 +469,16 @@ WindowsFrameInfo *BasicSourceLineResolver::Module::FindWindowsFrameInfo( MemAddr address = frame->instruction - frame->module->base_address(); scoped_ptr result(new WindowsFrameInfo()); - // We only know about STACK_INFO_FRAME_DATA and STACK_INFO_FPO. Prefer - // them in this order. STACK_INFO_FRAME_DATA is the newer type that - // includes its own program string. STACK_INFO_FPO is the older type - // corresponding to the FPO_DATA struct. See stackwalker_x86.cc. + // We only know about WINDOWS_FRAME_INFO_FRAME_DATA and + // WINDOWS_FRAME_INFO_FPO. Prefer them in this order. + // WINDOWS_FRAME_INFO_FRAME_DATA is the newer type that includes its + // own program string. WINDOWS_FRAME_INFO_FPO is the older type + // corresponding to the FPO_DATA struct. See stackwalker_x86.cc. linked_ptr frame_info; - if ((stack_info_[STACK_INFO_FRAME_DATA].RetrieveRange(address, &frame_info)) - || (stack_info_[STACK_INFO_FPO].RetrieveRange(address, &frame_info))) { + if ((windows_frame_info_[WINDOWS_FRAME_INFO_FRAME_DATA] + .RetrieveRange(address, &frame_info)) + || (windows_frame_info_[WINDOWS_FRAME_INFO_FPO] + .RetrieveRange(address, &frame_info))) { result->CopyFrom(*frame_info.get()); return result.release(); } @@ -636,8 +639,9 @@ bool BasicSourceLineResolver::Module::ParseStackInfo(char *stack_info_line) { // Otherwise, the final token tells whether the stack info indicates that // a base pointer has been allocated. // - // Expect has_program_string to be 1 when type is STACK_INFO_FRAME_DATA and - // 0 when type is STACK_INFO_FPO, but don't enforce this. + // Expect has_program_string to be 1 when type is + // WINDOWS_FRAME_INFO_FRAME_DATA and 0 when type is WINDOWS_FRAME_INFO_FPO, + // but don't enforce this. // Skip "STACK " prefix. stack_info_line += 6; @@ -652,7 +656,7 @@ bool BasicSourceLineResolver::Module::ParseStackInfo(char *stack_info_line) { return false; int type = strtol(tokens[1], NULL, 16); - if (type < 0 || type > STACK_INFO_LAST - 1) + if (type < 0 || type > WINDOWS_FRAME_INFO_LAST - 1) return false; u_int64_t rva = strtoull(tokens[2], NULL, 16); @@ -702,7 +706,7 @@ bool BasicSourceLineResolver::Module::ParseStackInfo(char *stack_info_line) { max_stack_size, allocates_base_pointer, program_string)); - stack_info_[type].StoreRange(rva, code_size, stack_frame_info); + windows_frame_info_[type].StoreRange(rva, code_size, stack_frame_info); return true; } diff --git a/src/processor/basic_source_line_resolver_unittest.cc b/src/processor/basic_source_line_resolver_unittest.cc index 45dfe979..fc9028f2 100644 --- a/src/processor/basic_source_line_resolver_unittest.cc +++ b/src/processor/basic_source_line_resolver_unittest.cc @@ -104,7 +104,7 @@ static bool RunTests() { TestCodeModule module1("module1"); StackFrame frame; - scoped_ptr frame_info; + scoped_ptr windows_frame_info; frame.instruction = 0x1000; frame.module = NULL; resolver.FillSourceLineInfo(&frame); @@ -124,10 +124,10 @@ static bool RunTests() { ASSERT_EQ(frame.source_file_name, "file1_1.cc"); ASSERT_EQ(frame.source_line, 44); ASSERT_EQ(frame.source_line_base, 0x1000); - frame_info.reset(resolver.FindWindowsFrameInfo(&frame)); - ASSERT_TRUE(frame_info.get()); - ASSERT_FALSE(frame_info->allocates_base_pointer); - ASSERT_EQ(frame_info->program_string, + windows_frame_info.reset(resolver.FindWindowsFrameInfo(&frame)); + ASSERT_TRUE(windows_frame_info.get()); + ASSERT_FALSE(windows_frame_info->allocates_base_pointer); + ASSERT_EQ(windows_frame_info->program_string, "$eip 4 + ^ = $esp $ebp 8 + = $ebp $ebp ^ ="); ClearSourceLineInfo(&frame); @@ -135,32 +135,32 @@ static bool RunTests() { frame.module = &module1; resolver.FillSourceLineInfo(&frame); ASSERT_TRUE(VerifyEmpty(frame)); - frame_info.reset(resolver.FindWindowsFrameInfo(&frame)); - ASSERT_FALSE(frame_info.get()); + windows_frame_info.reset(resolver.FindWindowsFrameInfo(&frame)); + ASSERT_FALSE(windows_frame_info.get()); frame.instruction = 0x1280; resolver.FillSourceLineInfo(&frame); ASSERT_EQ(frame.function_name, "Function1_3"); ASSERT_TRUE(frame.source_file_name.empty()); ASSERT_EQ(frame.source_line, 0); - frame_info.reset(resolver.FindWindowsFrameInfo(&frame)); - ASSERT_TRUE(frame_info.get()); - ASSERT_FALSE(frame_info->allocates_base_pointer); - ASSERT_TRUE(frame_info->program_string.empty()); + windows_frame_info.reset(resolver.FindWindowsFrameInfo(&frame)); + ASSERT_TRUE(windows_frame_info.get()); + ASSERT_FALSE(windows_frame_info->allocates_base_pointer); + ASSERT_TRUE(windows_frame_info->program_string.empty()); frame.instruction = 0x1380; resolver.FillSourceLineInfo(&frame); ASSERT_EQ(frame.function_name, "Function1_4"); ASSERT_TRUE(frame.source_file_name.empty()); ASSERT_EQ(frame.source_line, 0); - frame_info.reset(resolver.FindWindowsFrameInfo(&frame)); - ASSERT_TRUE(frame_info.get()); - ASSERT_FALSE(frame_info->allocates_base_pointer); - ASSERT_FALSE(frame_info->program_string.empty()); + windows_frame_info.reset(resolver.FindWindowsFrameInfo(&frame)); + ASSERT_TRUE(windows_frame_info.get()); + ASSERT_FALSE(windows_frame_info->allocates_base_pointer); + ASSERT_FALSE(windows_frame_info->program_string.empty()); frame.instruction = 0x2000; - frame_info.reset(resolver.FindWindowsFrameInfo(&frame)); - ASSERT_FALSE(frame_info.get()); + windows_frame_info.reset(resolver.FindWindowsFrameInfo(&frame)); + ASSERT_FALSE(windows_frame_info.get()); frame.instruction = 0x2900; frame.module = &module1; @@ -184,9 +184,9 @@ static bool RunTests() { ASSERT_EQ(frame.source_file_name, "file2_2.cc"); ASSERT_EQ(frame.source_line, 21); ASSERT_EQ(frame.source_line_base, 0x2180); - frame_info.reset(resolver.FindWindowsFrameInfo(&frame)); - ASSERT_TRUE(frame_info.get()); - ASSERT_EQ(frame_info->prolog_size, 1); + windows_frame_info.reset(resolver.FindWindowsFrameInfo(&frame)); + ASSERT_TRUE(windows_frame_info.get()); + ASSERT_EQ(windows_frame_info->prolog_size, 1); frame.instruction = 0x216f; resolver.FillSourceLineInfo(&frame);