1 // Copyright (c) 2006, Google Inc. 2 // All rights reserved. 3 // 4 // Redistribution and use in source and binary forms, with or without 5 // modification, are permitted provided that the following conditions are 6 // met: 7 // 8 // * Redistributions of source code must retain the above copyright 9 // notice, this list of conditions and the following disclaimer. 10 // * Redistributions in binary form must reproduce the above 11 // copyright notice, this list of conditions and the following disclaimer 12 // in the documentation and/or other materials provided with the 13 // distribution. 14 // * Neither the name of Google Inc. nor the names of its 15 // contributors may be used to endorse or promote products derived from 16 // this software without specific prior written permission. 17 // 18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 30 // call_stack.h: A call stack comprised of stack frames. 31 // 32 // This class manages a vector of stack frames. It is used instead of 33 // exposing the vector directly to allow the CallStack to own StackFrame 34 // pointers without having to publicly export the linked_ptr class. A 35 // CallStack must be composed of pointers instead of objects to allow for 36 // CPU-specific StackFrame subclasses. 37 // 38 // By convention, the stack frame at index 0 is the innermost callee frame, 39 // and the frame at the highest index in a call stack is the outermost 40 // caller. CallStack only allows stacks to be built by pushing frames, 41 // beginning with the innermost callee frame. 42 // 43 // Author: Mark Mentovai 44 45 #ifndef GOOGLE_BREAKPAD_PROCESSOR_CALL_STACK_H__ 46 #define GOOGLE_BREAKPAD_PROCESSOR_CALL_STACK_H__ 47 48 #include <vector> 49 50 namespace google_breakpad { 51 52 using std::vector; 53 54 struct StackFrame; 55 template<typename T> class linked_ptr; 56 57 class CallStack { 58 public: CallStack()59 CallStack() { Clear(); } 60 ~CallStack(); 61 62 // Resets the CallStack to its initial empty state 63 void Clear(); 64 frames()65 const vector<StackFrame*>* frames() const { return &frames_; } 66 67 private: 68 // Stackwalker is responsible for building the frames_ vector. 69 friend class Stackwalker; 70 71 // Storage for pushed frames. 72 vector<StackFrame*> frames_; 73 }; 74 75 } // namespace google_breakpad 76 77 #endif // GOOGLE_BREAKPAD_PROCSSOR_CALL_STACK_H__ 78