diff options
Diffstat (limited to 'src/processor/windows_frame_info.h')
-rw-r--r-- | src/processor/windows_frame_info.h | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/src/processor/windows_frame_info.h b/src/processor/windows_frame_info.h index 0665dcdf..cca78b88 100644 --- a/src/processor/windows_frame_info.h +++ b/src/processor/windows_frame_info.h @@ -38,9 +38,13 @@ #ifndef PROCESSOR_WINDOWS_FRAME_INFO_H__ #define PROCESSOR_WINDOWS_FRAME_INFO_H__ +#include <cstring> #include <string> +#include <vector> #include "google_breakpad/common/breakpad_types.h" +#include "processor/logging.h" +#include "processor/tokenize.h" namespace google_breakpad { @@ -52,6 +56,20 @@ struct WindowsFrameInfo { VALID_ALL = -1 }; + // The types for stack_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 + }; + WindowsFrameInfo() : valid(VALID_NONE), prolog_size(0), epilog_size(0), @@ -80,6 +98,56 @@ struct WindowsFrameInfo { allocates_base_pointer(set_allocates_base_pointer), program_string(set_program_string) {} + // Parse a textual serialization of a WindowsFrameInfo object from + // a string. Returns NULL if parsing fails, or a new object + // otherwise. type, rva and code_size are present in the STACK line, + // but not the StackFrameInfo structure, so return them as outparams. + static WindowsFrameInfo *ParseFromString(const std::string string, + int &type, + u_int64_t &rva, + u_int64_t &code_size) { + // The format of a STACK WIN record is documented at: + // + // http://code.google.com/p/google-breakpad/wiki/SymbolFiles + + std::vector<char> buffer; + StringToVector(string, buffer); + std::vector<char*> tokens; + if (!Tokenize(&buffer[0], " \r\n", 11, &tokens)) + return NULL; + + type = strtol(tokens[0], NULL, 16); + if (type < 0 || type > STACK_INFO_LAST - 1) + return NULL; + + rva = strtoull(tokens[1], NULL, 16); + 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[10]; + } else { + allocates_base_pointer = strtoul(tokens[10], NULL, 16); + } + + return new WindowsFrameInfo(prolog_size, + epilog_size, + parameter_size, + saved_register_size, + local_size, + max_stack_size, + allocates_base_pointer, + program_string); + } + // CopyFrom makes "this" WindowsFrameInfo object identical to "that". void CopyFrom(const WindowsFrameInfo &that) { valid = that.valid; |