toolkit/components/telemetry/ProcessedStack.h

Fri, 16 Jan 2015 18:13:44 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 18:13:44 +0100
branch
TOR_BUG_9701
changeset 14
925c144e1f1f
permissions
-rw-r--r--

Integrate suggestion from review to improve consistency with existing code.

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 #ifndef ProcessedStack_h__
     7 #define ProcessedStack_h__
     9 #include <string>
    10 #include <vector>
    12 namespace mozilla {
    13 namespace Telemetry {
    15 // This class represents a stack trace and the modules referenced in that trace.
    16 // It is designed to be easy to read and write to disk or network and doesn't
    17 // include any logic on how to collect or read the information it stores.
    18 class ProcessedStack
    19 {
    20 public:
    21   ProcessedStack();
    22   size_t GetStackSize() const;
    23   size_t GetNumModules() const;
    25   struct Frame
    26   {
    27     // The offset of this program counter in its module or an absolute pc.
    28     uintptr_t mOffset;
    29     // The index to pass to GetModule to get the module this program counter
    30     // was in.
    31     uint16_t mModIndex;
    32   };
    33   struct Module
    34   {
    35     // The file name, /foo/bar/libxul.so for example.
    36     std::string mName;
    37     std::string mBreakpadId;
    39     bool operator==(const Module& other) const;
    40   };
    42   const Frame &GetFrame(unsigned aIndex) const;
    43   void AddFrame(const Frame& aFrame);
    44   const Module &GetModule(unsigned aIndex) const;
    45   void AddModule(const Module& aFrame);
    47   void Clear();
    49 private:
    50   std::vector<Module> mModules;
    51   std::vector<Frame> mStack;
    52 };
    54 // Get the current list of loaded modules, filter and pair it to the provided
    55 // stack. We let the caller collect the stack since different callers have
    56 // different needs (current thread X main thread, stopping the thread, etc).
    57 ProcessedStack
    58 GetStackAndModules(const std::vector<uintptr_t> &aPCs);
    60 } // namespace Telemetry
    61 } // namespace mozilla
    62 #endif // ProcessedStack_h__

mercurial