diff options
Diffstat (limited to 'src/processor/fast_source_line_resolver_types.h')
-rw-r--r-- | src/processor/fast_source_line_resolver_types.h | 138 |
1 files changed, 101 insertions, 37 deletions
diff --git a/src/processor/fast_source_line_resolver_types.h b/src/processor/fast_source_line_resolver_types.h index 2c010470..75b9004f 100644 --- a/src/processor/fast_source_line_resolver_types.h +++ b/src/processor/fast_source_line_resolver_types.h @@ -1,5 +1,4 @@ -// Copyright (c) 2010 Google Inc. -// All rights reserved. +// Copyright 2010 Google LLC // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -11,7 +10,7 @@ // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. -// * Neither the name of Google Inc. nor the names of its +// * Neither the name of Google LLC nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // @@ -37,14 +36,16 @@ #ifndef PROCESSOR_FAST_SOURCE_LINE_RESOLVER_TYPES_H__ #define PROCESSOR_FAST_SOURCE_LINE_RESOLVER_TYPES_H__ -#include "google_breakpad/processor/fast_source_line_resolver.h" -#include "processor/source_line_resolver_base_types.h" - +#include <cstdint> #include <map> #include <string> +#include "google_breakpad/processor/fast_source_line_resolver.h" #include "google_breakpad/processor/stack_frame.h" #include "processor/cfi_frame_info.h" +#include "processor/contained_range_map.h" +#include "processor/simple_serializer-inl.h" +#include "processor/source_line_resolver_base_types.h" #include "processor/static_address_map-inl.h" #include "processor/static_contained_range_map-inl.h" #include "processor/static_map.h" @@ -53,74 +54,133 @@ namespace google_breakpad { +#define DESERIALIZE(raw_ptr, field) \ + field = *(reinterpret_cast<const decltype(field)*>(raw_ptr)); \ + raw_ptr += sizeof(field); + struct FastSourceLineResolver::Line : public SourceLineResolverBase::Line { - void CopyFrom(const Line *line_ptr) { - const char *raw = reinterpret_cast<const char*>(line_ptr); + void CopyFrom(const Line* line_ptr) { + const char* raw = reinterpret_cast<const char*>(line_ptr); CopyFrom(raw); } // De-serialize the memory data of a Line. - void CopyFrom(const char *raw) { - address = *(reinterpret_cast<const MemAddr*>(raw)); - size = *(reinterpret_cast<const MemAddr*>(raw + sizeof(address))); - source_file_id = *(reinterpret_cast<const int32_t *>( - raw + 2 * sizeof(address))); - line = *(reinterpret_cast<const int32_t*>( - raw + 2 * sizeof(address) + sizeof(source_file_id))); + void CopyFrom(const char* raw) { + DESERIALIZE(raw, address); + DESERIALIZE(raw, size); + DESERIALIZE(raw, source_file_id); + DESERIALIZE(raw, line); } }; struct FastSourceLineResolver::Function : public SourceLineResolverBase::Function { - void CopyFrom(const Function *func_ptr) { - const char *raw = reinterpret_cast<const char*>(func_ptr); + void CopyFrom(const Function* func_ptr) { + const char* raw = reinterpret_cast<const char*>(func_ptr); CopyFrom(raw); } // De-serialize the memory data of a Function. - void CopyFrom(const char *raw) { + void CopyFrom(const char* raw) { size_t name_size = strlen(raw) + 1; name = raw; - address = *(reinterpret_cast<const MemAddr*>(raw + name_size)); - size = *(reinterpret_cast<const MemAddr*>( - raw + name_size + sizeof(MemAddr))); - parameter_size = *(reinterpret_cast<const int32_t*>( - raw + name_size + 2 * sizeof(MemAddr))); - lines = StaticRangeMap<MemAddr, Line>( - raw + name_size + 2 * sizeof(MemAddr) + sizeof(int32_t)); + raw += name_size; + DESERIALIZE(raw, address); + DESERIALIZE(raw, size); + DESERIALIZE(raw, parameter_size); + raw = SimpleSerializer<bool>::Read(raw, &is_multiple); + int32_t inline_size; + DESERIALIZE(raw, inline_size); + inlines = StaticContainedRangeMap<MemAddr, char>(raw); + lines = StaticRangeMap<MemAddr, Line>(raw + inline_size); } + StaticContainedRangeMap<MemAddr, char> inlines; StaticRangeMap<MemAddr, Line> lines; }; +struct FastSourceLineResolver::Inline : public SourceLineResolverBase::Inline { + void CopyFrom(const Inline* inline_ptr) { + const char* raw = reinterpret_cast<const char*>(inline_ptr); + CopyFrom(raw); + } + + // De-serialize the memory data of a Inline. + void CopyFrom(const char* raw) { + DESERIALIZE(raw, has_call_site_file_id); + DESERIALIZE(raw, inline_nest_level); + DESERIALIZE(raw, call_site_line); + DESERIALIZE(raw, call_site_file_id); + DESERIALIZE(raw, origin_id); + uint32_t inline_range_size; + DESERIALIZE(raw, inline_range_size); + for (size_t i = 0; i < inline_range_size; i += 2) { + std::pair<MemAddr, MemAddr> range; + DESERIALIZE(raw, range.first); + DESERIALIZE(raw, range.second); + inline_ranges.push_back(range); + } + } +}; + +struct FastSourceLineResolver::InlineOrigin + : public SourceLineResolverBase::InlineOrigin { + void CopyFrom(const InlineOrigin* origin_ptr) { + const char* raw = reinterpret_cast<const char*>(origin_ptr); + CopyFrom(raw); + } + + // De-serialize the memory data of a Line. + void CopyFrom(const char* raw) { + DESERIALIZE(raw, has_file_id); + DESERIALIZE(raw, source_file_id); + name = raw; + } +}; + struct FastSourceLineResolver::PublicSymbol : public SourceLineResolverBase::PublicSymbol { - void CopyFrom(const PublicSymbol *public_symbol_ptr) { - const char *raw = reinterpret_cast<const char*>(public_symbol_ptr); + void CopyFrom(const PublicSymbol* public_symbol_ptr) { + const char* raw = reinterpret_cast<const char*>(public_symbol_ptr); CopyFrom(raw); } // De-serialize the memory data of a PublicSymbol. - void CopyFrom(const char *raw) { + void CopyFrom(const char* raw) { size_t name_size = strlen(raw) + 1; name = raw; - address = *(reinterpret_cast<const MemAddr*>(raw + name_size)); - parameter_size = *(reinterpret_cast<const int32_t*>( - raw + name_size + sizeof(MemAddr))); + raw += name_size; + DESERIALIZE(raw, address); + DESERIALIZE(raw, parameter_size); + raw = SimpleSerializer<bool>::Read(raw, &is_multiple); } }; +#undef DESERIALIZE + class FastSourceLineResolver::Module: public SourceLineResolverBase::Module { public: - explicit Module(const string &name) : name_(name), is_corrupt_(false) { } + explicit Module(const string& name) : name_(name), is_corrupt_(false) { } virtual ~Module() { } // Looks up the given relative address, and fills the StackFrame struct // with the result. - virtual void LookupAddress(StackFrame *frame) const; + virtual void LookupAddress( + StackFrame* frame, + std::deque<std::unique_ptr<StackFrame>>* inlined_frames) const; + + // Construct inlined frames for |frame| and store them in |inline_frames|. + // |frame|'s source line and source file name may be updated if an inlined + // frame is found inside |frame|. As a result, the innermost inlined frame + // will be the first one in |inline_frames|. + virtual void ConstructInlineFrames( + StackFrame* frame, + MemAddr address, + const StaticContainedRangeMap<MemAddr, char>& inline_map, + std::deque<std::unique_ptr<StackFrame>>* inlined_frames) const; // Loads a map from the given buffer in char* type. - virtual bool LoadMapFromMemory(char *memory_buffer, + virtual bool LoadMapFromMemory(char* memory_buffer, size_t memory_buffer_size); // Tells whether the loaded symbol data is corrupt. Return value is @@ -132,16 +192,16 @@ class FastSourceLineResolver::Module: public SourceLineResolverBase::Module { // is not available, returns NULL. A NULL return value does not indicate // an error. The caller takes ownership of any returned WindowsFrameInfo // object. - virtual WindowsFrameInfo *FindWindowsFrameInfo(const StackFrame *frame) const; + virtual WindowsFrameInfo* FindWindowsFrameInfo(const StackFrame* frame) const; // If CFI stack walking information is available covering ADDRESS, // return a CFIFrameInfo structure describing it. If the information // is not available, return NULL. The caller takes ownership of any // returned CFIFrameInfo object. - virtual CFIFrameInfo *FindCFIFrameInfo(const StackFrame *frame) const; + virtual CFIFrameInfo* FindCFIFrameInfo(const StackFrame* frame) const; // Number of serialized map components of Module. - static const int kNumberMaps_ = 5 + WindowsFrameInfo::STACK_INFO_LAST; + static const int kNumberMaps_ = 6 + WindowsFrameInfo::STACK_INFO_LAST; private: friend class FastSourceLineResolver; @@ -178,6 +238,10 @@ class FastSourceLineResolver::Module: public SourceLineResolverBase::Module { // this map, or the end of the range as given by the cfi_initial_rules_ // entry (which FindCFIFrameInfo looks up first). StaticMap<MemAddr, char> cfi_delta_rules_; + + // INLINE_ORIGIN records: used as a function name string pool for INLINE + // records. + StaticMap<int, char> inline_origins_; }; } // namespace google_breakpad |