/ src / processor / stackwalker_address_list.h
stackwalker_address_list.h
 1  // Copyright 2013 Google LLC
 2  //
 3  // Redistribution and use in source and binary forms, with or without
 4  // modification, are permitted provided that the following conditions are
 5  // met:
 6  //
 7  //     * Redistributions of source code must retain the above copyright
 8  // notice, this list of conditions and the following disclaimer.
 9  //     * Redistributions in binary form must reproduce the above
10  // copyright notice, this list of conditions and the following disclaimer
11  // in the documentation and/or other materials provided with the
12  // distribution.
13  //     * Neither the name of Google LLC nor the names of its
14  // contributors may be used to endorse or promote products derived from
15  // this software without specific prior written permission.
16  //
17  // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18  // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19  // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20  // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21  // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22  // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23  // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24  // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25  // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26  // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27  // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  
29  // stackwalker_address_list.h: a pseudo stackwalker.
30  //
31  // Doesn't actually walk a stack, rather initializes a CallStack given an
32  // explicit list of already walked return addresses.
33  //
34  // Author: Chris Hamilton <chrisha@chromium.org>
35  
36  #ifndef PROCESSOR_STACKWALKER_ADDRESS_LIST_H_
37  #define PROCESSOR_STACKWALKER_ADDRESS_LIST_H_
38  
39  #include "google_breakpad/common/breakpad_types.h"
40  #include "google_breakpad/processor/stackwalker.h"
41  
42  namespace google_breakpad {
43  
44  class CodeModules;
45  
46  class StackwalkerAddressList : public Stackwalker {
47   public:
48    // Initializes this stack walker with an explicit set of frame addresses.
49    // |modules| and |frame_symbolizer| are passed directly through to the base
50    // Stackwalker constructor.
51    StackwalkerAddressList(const uint64_t* frames,
52                           size_t frame_count,
53                           const CodeModules* modules,
54                           StackFrameSymbolizer* frame_symbolizer);
55    StackwalkerAddressList(const StackwalkerAddressList&) = delete;
56    void operator=(const StackwalkerAddressList&) = delete;
57  
58   private:
59    // Implementation of Stackwalker.
60    virtual StackFrame* GetContextFrame();
61    virtual StackFrame* GetCallerFrame(const CallStack* stack,
62                                       bool stack_scan_allowed);
63  
64    const uint64_t* frames_;
65    size_t frame_count_;
66  };
67  
68  }  // namespace google_breakpad
69  
70  #endif  // PROCESSOR_STACKWALKER_ADDRESS_LIST_H_