diff options
author | jimblandy <jimblandy@4c0a9323-5329-0410-9bdc-e9ce6186880e> | 2010-02-05 18:10:51 +0000 |
---|---|---|
committer | jimblandy <jimblandy@4c0a9323-5329-0410-9bdc-e9ce6186880e> | 2010-02-05 18:10:51 +0000 |
commit | bd76cd035c6306c6acee9257b0df87e75c796053 (patch) | |
tree | 7cf1b61a85d1f472c63268f72e020b665d8ed876 /src/processor | |
parent | Breakpad processor: Give Windows stack data Windows-specific names. (diff) | |
download | breakpad-bd76cd035c6306c6acee9257b0df87e75c796053.tar.xz |
Breakpad processor: Move STACK WIN record parsing into its own function.
This looks a little odd right now, since ParseStackInfo has only one
alternative to handle, but I think breaking this out should make the
subsequent addition of STACK CFI record support easier to review.
a=jimblandy, r=mmentovai
git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@514 4c0a9323-5329-0410-9bdc-e9ce6186880e
Diffstat (limited to 'src/processor')
-rw-r--r-- | src/processor/basic_source_line_resolver.cc | 68 |
1 files changed, 39 insertions, 29 deletions
diff --git a/src/processor/basic_source_line_resolver.cc b/src/processor/basic_source_line_resolver.cc index 2440495e..180abd2c 100644 --- a/src/processor/basic_source_line_resolver.cc +++ b/src/processor/basic_source_line_resolver.cc @@ -170,6 +170,9 @@ class BasicSourceLineResolver::Module { // Parses a stack frame info declaration, storing it in windows_frame_info_. bool ParseStackInfo(char *stack_info_line); + // Parses a STACK WIN record, storing it in windows_frame_info_. + bool ParseWindowsFrameInfo(char *stack_info_line); + string name_; FileMap files_; RangeMap< MemAddr, linked_ptr<Function> > functions_; @@ -631,50 +634,57 @@ bool BasicSourceLineResolver::Module::ParsePublicSymbol(char *public_line) { } bool BasicSourceLineResolver::Module::ParseStackInfo(char *stack_info_line) { - // STACK WIN <type> <rva> <code_size> <prolog_size> <epliog_size> - // <parameter_size> <saved_register_size> <local_size> <max_stack_size> - // <has_program_string> <program_string_OR_allocates_base_pointer> - // - // If has_program_string is 1, the rest of the line is a program string. - // 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 - // 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; - vector<char*> tokens; - if (!Tokenize(stack_info_line, 12, &tokens)) + // Find the token indicating what sort of stack frame walking + // information this is. + while (*stack_info_line == ' ') + stack_info_line++; + const char *platform = stack_info_line; + while (!strchr(" \r\n", *stack_info_line)) + stack_info_line++; + *stack_info_line++ = '\0'; + + // MSVC stack frame info. + if (strcmp(platform, "WIN") == 0) + return ParseWindowsFrameInfo(stack_info_line); + + // Something we don't recognize. + else return false; +} + +bool BasicSourceLineResolver::Module::ParseWindowsFrameInfo( + char *stack_info_line) { + // The format of a STACK WIN record is documented at: + // + // http://code.google.com/p/google-breakpad/wiki/SymbolFiles - // Only MSVC stack frame info is understood for now. - const char *platform = tokens[0]; - if (strcmp(platform, "WIN") != 0) + vector<char*> tokens; + if (!Tokenize(stack_info_line, 11, &tokens)) return false; - int type = strtol(tokens[1], NULL, 16); + int type = strtol(tokens[0], NULL, 16); if (type < 0 || type > WINDOWS_FRAME_INFO_LAST - 1) return false; - u_int64_t rva = strtoull(tokens[2], NULL, 16); - u_int64_t code_size = strtoull(tokens[3], NULL, 16); - u_int32_t prolog_size = strtoul(tokens[4], NULL, 16); - u_int32_t epilog_size = strtoul(tokens[5], NULL, 16); - u_int32_t parameter_size = strtoul(tokens[6], NULL, 16); - u_int32_t saved_register_size = strtoul(tokens[7], NULL, 16); - u_int32_t local_size = strtoul(tokens[8], NULL, 16); - u_int32_t max_stack_size = strtoul(tokens[9], NULL, 16); - int has_program_string = strtoul(tokens[10], NULL, 16); + u_int64_t rva = strtoull(tokens[1], NULL, 16); + u_int64_t code_size = strtoull(tokens[2], NULL, 16); + u_int32_t prolog_size = strtoul(tokens[3], NULL, 16); + u_int32_t epilog_size = strtoul(tokens[4], NULL, 16); + u_int32_t parameter_size = strtoul(tokens[5], NULL, 16); + u_int32_t saved_register_size = strtoul(tokens[6], NULL, 16); + u_int32_t local_size = strtoul(tokens[7], NULL, 16); + u_int32_t max_stack_size = strtoul(tokens[8], NULL, 16); + int has_program_string = strtoul(tokens[9], NULL, 16); const char *program_string = ""; int allocates_base_pointer = 0; if (has_program_string) { - program_string = tokens[11]; + program_string = tokens[10]; } else { - allocates_base_pointer = strtoul(tokens[11], NULL, 16); + allocates_base_pointer = strtoul(tokens[10], NULL, 16); } // TODO(mmentovai): I wanted to use StoreRange's return value as this |