michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef ProcessedStack_h__ michael@0: #define ProcessedStack_h__ michael@0: michael@0: #include michael@0: #include michael@0: michael@0: namespace mozilla { michael@0: namespace Telemetry { michael@0: michael@0: // This class represents a stack trace and the modules referenced in that trace. michael@0: // It is designed to be easy to read and write to disk or network and doesn't michael@0: // include any logic on how to collect or read the information it stores. michael@0: class ProcessedStack michael@0: { michael@0: public: michael@0: ProcessedStack(); michael@0: size_t GetStackSize() const; michael@0: size_t GetNumModules() const; michael@0: michael@0: struct Frame michael@0: { michael@0: // The offset of this program counter in its module or an absolute pc. michael@0: uintptr_t mOffset; michael@0: // The index to pass to GetModule to get the module this program counter michael@0: // was in. michael@0: uint16_t mModIndex; michael@0: }; michael@0: struct Module michael@0: { michael@0: // The file name, /foo/bar/libxul.so for example. michael@0: std::string mName; michael@0: std::string mBreakpadId; michael@0: michael@0: bool operator==(const Module& other) const; michael@0: }; michael@0: michael@0: const Frame &GetFrame(unsigned aIndex) const; michael@0: void AddFrame(const Frame& aFrame); michael@0: const Module &GetModule(unsigned aIndex) const; michael@0: void AddModule(const Module& aFrame); michael@0: michael@0: void Clear(); michael@0: michael@0: private: michael@0: std::vector mModules; michael@0: std::vector mStack; michael@0: }; michael@0: michael@0: // Get the current list of loaded modules, filter and pair it to the provided michael@0: // stack. We let the caller collect the stack since different callers have michael@0: // different needs (current thread X main thread, stopping the thread, etc). michael@0: ProcessedStack michael@0: GetStackAndModules(const std::vector &aPCs); michael@0: michael@0: } // namespace Telemetry michael@0: } // namespace mozilla michael@0: #endif // ProcessedStack_h__