Breakpad processor: Give Windows stack data Windows-specific names.

Rename BasicSourceLineResolver::Module::StackInfoTypes to
WindowsFrameInfoTypes. This enum really describes the forms of
Windows-specific stack unwinding data (STACK WIN records), and its
name should reflect that, especially since we'll be adding support for
other kinds of stack walking information.

The 'stack' -> 'frame' shift matches the naming of the
WindowsFrameInfo type.

Similarly, rename BasicSourceLineResolver::Module::stack_info_ to
windows_frame_info_.

Do similar renamings in basic_source_line_resolver_unittest.cc.

a=jimblandy, r=mmentovai


git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@513 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
jimblandy 2010-02-05 18:09:17 +00:00
parent 7f1455601d
commit 2b48a6a89f
2 changed files with 50 additions and 46 deletions

View file

@ -128,18 +128,18 @@ class BasicSourceLineResolver::Module {
friend class BasicSourceLineResolver; friend class BasicSourceLineResolver;
typedef map<int, string> FileMap; typedef map<int, string> 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 // StackFrameTypeEnum. Each identifies a different type of frame
// information, although all are represented in the symbol file in the // information, although all are represented in the symbol file in the
// same format. These are used as indices to the stack_info_ array. // same format. These are used as indices to the windows_frame_info_ array.
enum StackInfoTypes { enum WindowsFrameInfoTypes {
STACK_INFO_FPO = 0, WINDOWS_FRAME_INFO_FPO = 0,
STACK_INFO_TRAP, // not used here WINDOWS_FRAME_INFO_TRAP, // not used here
STACK_INFO_TSS, // not used here WINDOWS_FRAME_INFO_TSS, // not used here
STACK_INFO_STANDARD, WINDOWS_FRAME_INFO_STANDARD,
STACK_INFO_FRAME_DATA, WINDOWS_FRAME_INFO_FRAME_DATA,
STACK_INFO_LAST, // must be the last sequentially-numbered item WINDOWS_FRAME_INFO_LAST, // must be the last sequentially-numbered item
STACK_INFO_UNKNOWN = -1 WINDOWS_FRAME_INFO_UNKNOWN = -1
}; };
// Splits line into at most max_tokens space-separated tokens, placing // Splits line into at most max_tokens space-separated tokens, placing
@ -167,7 +167,7 @@ class BasicSourceLineResolver::Module {
// Returns false if an error occurs. // Returns false if an error occurs.
bool ParsePublicSymbol(char *public_line); 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); bool ParseStackInfo(char *stack_info_line);
string name_; string name_;
@ -175,12 +175,12 @@ class BasicSourceLineResolver::Module {
RangeMap< MemAddr, linked_ptr<Function> > functions_; RangeMap< MemAddr, linked_ptr<Function> > functions_;
AddressMap< MemAddr, linked_ptr<PublicSymbol> > public_symbols_; AddressMap< MemAddr, linked_ptr<PublicSymbol> > public_symbols_;
// Each element in the array is a ContainedRangeMap for a type listed in // Each element in the array is a ContainedRangeMap for a type
// StackInfoTypes. These are split by type because there may be overlaps // listed in WindowsFrameInfoTypes. These are split by type because
// between maps of different types, but some information is only available // there may be overlaps between maps of different types, but some
// as certain types. // information is only available as certain types.
ContainedRangeMap< MemAddr, linked_ptr<WindowsFrameInfo> > ContainedRangeMap< MemAddr, linked_ptr<WindowsFrameInfo> >
stack_info_[STACK_INFO_LAST]; windows_frame_info_[WINDOWS_FRAME_INFO_LAST];
}; };
BasicSourceLineResolver::BasicSourceLineResolver() : modules_(new ModuleMap) { BasicSourceLineResolver::BasicSourceLineResolver() : modules_(new ModuleMap) {
@ -469,13 +469,16 @@ WindowsFrameInfo *BasicSourceLineResolver::Module::FindWindowsFrameInfo(
MemAddr address = frame->instruction - frame->module->base_address(); MemAddr address = frame->instruction - frame->module->base_address();
scoped_ptr<WindowsFrameInfo> result(new WindowsFrameInfo()); scoped_ptr<WindowsFrameInfo> result(new WindowsFrameInfo());
// We only know about STACK_INFO_FRAME_DATA and STACK_INFO_FPO. Prefer // We only know about WINDOWS_FRAME_INFO_FRAME_DATA and
// them in this order. STACK_INFO_FRAME_DATA is the newer type that // WINDOWS_FRAME_INFO_FPO. Prefer them in this order.
// includes its own program string. STACK_INFO_FPO is the older type // 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. // corresponding to the FPO_DATA struct. See stackwalker_x86.cc.
linked_ptr<WindowsFrameInfo> frame_info; linked_ptr<WindowsFrameInfo> frame_info;
if ((stack_info_[STACK_INFO_FRAME_DATA].RetrieveRange(address, &frame_info)) if ((windows_frame_info_[WINDOWS_FRAME_INFO_FRAME_DATA]
|| (stack_info_[STACK_INFO_FPO].RetrieveRange(address, &frame_info))) { .RetrieveRange(address, &frame_info))
|| (windows_frame_info_[WINDOWS_FRAME_INFO_FPO]
.RetrieveRange(address, &frame_info))) {
result->CopyFrom(*frame_info.get()); result->CopyFrom(*frame_info.get());
return result.release(); 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 // Otherwise, the final token tells whether the stack info indicates that
// a base pointer has been allocated. // a base pointer has been allocated.
// //
// Expect has_program_string to be 1 when type is STACK_INFO_FRAME_DATA and // Expect has_program_string to be 1 when type is
// 0 when type is STACK_INFO_FPO, but don't enforce this. // WINDOWS_FRAME_INFO_FRAME_DATA and 0 when type is WINDOWS_FRAME_INFO_FPO,
// but don't enforce this.
// Skip "STACK " prefix. // Skip "STACK " prefix.
stack_info_line += 6; stack_info_line += 6;
@ -652,7 +656,7 @@ bool BasicSourceLineResolver::Module::ParseStackInfo(char *stack_info_line) {
return false; return false;
int type = strtol(tokens[1], NULL, 16); 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; return false;
u_int64_t rva = strtoull(tokens[2], NULL, 16); u_int64_t rva = strtoull(tokens[2], NULL, 16);
@ -702,7 +706,7 @@ bool BasicSourceLineResolver::Module::ParseStackInfo(char *stack_info_line) {
max_stack_size, max_stack_size,
allocates_base_pointer, allocates_base_pointer,
program_string)); 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; return true;
} }

View file

@ -104,7 +104,7 @@ static bool RunTests() {
TestCodeModule module1("module1"); TestCodeModule module1("module1");
StackFrame frame; StackFrame frame;
scoped_ptr<WindowsFrameInfo> frame_info; scoped_ptr<WindowsFrameInfo> windows_frame_info;
frame.instruction = 0x1000; frame.instruction = 0x1000;
frame.module = NULL; frame.module = NULL;
resolver.FillSourceLineInfo(&frame); resolver.FillSourceLineInfo(&frame);
@ -124,10 +124,10 @@ static bool RunTests() {
ASSERT_EQ(frame.source_file_name, "file1_1.cc"); ASSERT_EQ(frame.source_file_name, "file1_1.cc");
ASSERT_EQ(frame.source_line, 44); ASSERT_EQ(frame.source_line, 44);
ASSERT_EQ(frame.source_line_base, 0x1000); ASSERT_EQ(frame.source_line_base, 0x1000);
frame_info.reset(resolver.FindWindowsFrameInfo(&frame)); windows_frame_info.reset(resolver.FindWindowsFrameInfo(&frame));
ASSERT_TRUE(frame_info.get()); ASSERT_TRUE(windows_frame_info.get());
ASSERT_FALSE(frame_info->allocates_base_pointer); ASSERT_FALSE(windows_frame_info->allocates_base_pointer);
ASSERT_EQ(frame_info->program_string, ASSERT_EQ(windows_frame_info->program_string,
"$eip 4 + ^ = $esp $ebp 8 + = $ebp $ebp ^ ="); "$eip 4 + ^ = $esp $ebp 8 + = $ebp $ebp ^ =");
ClearSourceLineInfo(&frame); ClearSourceLineInfo(&frame);
@ -135,32 +135,32 @@ static bool RunTests() {
frame.module = &module1; frame.module = &module1;
resolver.FillSourceLineInfo(&frame); resolver.FillSourceLineInfo(&frame);
ASSERT_TRUE(VerifyEmpty(frame)); ASSERT_TRUE(VerifyEmpty(frame));
frame_info.reset(resolver.FindWindowsFrameInfo(&frame)); windows_frame_info.reset(resolver.FindWindowsFrameInfo(&frame));
ASSERT_FALSE(frame_info.get()); ASSERT_FALSE(windows_frame_info.get());
frame.instruction = 0x1280; frame.instruction = 0x1280;
resolver.FillSourceLineInfo(&frame); resolver.FillSourceLineInfo(&frame);
ASSERT_EQ(frame.function_name, "Function1_3"); ASSERT_EQ(frame.function_name, "Function1_3");
ASSERT_TRUE(frame.source_file_name.empty()); ASSERT_TRUE(frame.source_file_name.empty());
ASSERT_EQ(frame.source_line, 0); ASSERT_EQ(frame.source_line, 0);
frame_info.reset(resolver.FindWindowsFrameInfo(&frame)); windows_frame_info.reset(resolver.FindWindowsFrameInfo(&frame));
ASSERT_TRUE(frame_info.get()); ASSERT_TRUE(windows_frame_info.get());
ASSERT_FALSE(frame_info->allocates_base_pointer); ASSERT_FALSE(windows_frame_info->allocates_base_pointer);
ASSERT_TRUE(frame_info->program_string.empty()); ASSERT_TRUE(windows_frame_info->program_string.empty());
frame.instruction = 0x1380; frame.instruction = 0x1380;
resolver.FillSourceLineInfo(&frame); resolver.FillSourceLineInfo(&frame);
ASSERT_EQ(frame.function_name, "Function1_4"); ASSERT_EQ(frame.function_name, "Function1_4");
ASSERT_TRUE(frame.source_file_name.empty()); ASSERT_TRUE(frame.source_file_name.empty());
ASSERT_EQ(frame.source_line, 0); ASSERT_EQ(frame.source_line, 0);
frame_info.reset(resolver.FindWindowsFrameInfo(&frame)); windows_frame_info.reset(resolver.FindWindowsFrameInfo(&frame));
ASSERT_TRUE(frame_info.get()); ASSERT_TRUE(windows_frame_info.get());
ASSERT_FALSE(frame_info->allocates_base_pointer); ASSERT_FALSE(windows_frame_info->allocates_base_pointer);
ASSERT_FALSE(frame_info->program_string.empty()); ASSERT_FALSE(windows_frame_info->program_string.empty());
frame.instruction = 0x2000; frame.instruction = 0x2000;
frame_info.reset(resolver.FindWindowsFrameInfo(&frame)); windows_frame_info.reset(resolver.FindWindowsFrameInfo(&frame));
ASSERT_FALSE(frame_info.get()); ASSERT_FALSE(windows_frame_info.get());
frame.instruction = 0x2900; frame.instruction = 0x2900;
frame.module = &module1; frame.module = &module1;
@ -184,9 +184,9 @@ static bool RunTests() {
ASSERT_EQ(frame.source_file_name, "file2_2.cc"); ASSERT_EQ(frame.source_file_name, "file2_2.cc");
ASSERT_EQ(frame.source_line, 21); ASSERT_EQ(frame.source_line, 21);
ASSERT_EQ(frame.source_line_base, 0x2180); ASSERT_EQ(frame.source_line_base, 0x2180);
frame_info.reset(resolver.FindWindowsFrameInfo(&frame)); windows_frame_info.reset(resolver.FindWindowsFrameInfo(&frame));
ASSERT_TRUE(frame_info.get()); ASSERT_TRUE(windows_frame_info.get());
ASSERT_EQ(frame_info->prolog_size, 1); ASSERT_EQ(windows_frame_info->prolog_size, 1);
frame.instruction = 0x216f; frame.instruction = 0x216f;
resolver.FillSourceLineInfo(&frame); resolver.FillSourceLineInfo(&frame);