2006-09-20 23:16:16 +02:00
|
|
|
// Copyright (c) 2006, Google Inc.
|
|
|
|
|
// All rights reserved.
|
2006-09-06 21:28:46 +02:00
|
|
|
//
|
2006-09-20 23:16:16 +02:00
|
|
|
// Redistribution and use in source and binary forms, with or without
|
|
|
|
|
// modification, are permitted provided that the following conditions are
|
|
|
|
|
// met:
|
2006-09-06 21:28:46 +02:00
|
|
|
//
|
2006-09-20 23:16:16 +02:00
|
|
|
// * Redistributions of source code must retain the above copyright
|
|
|
|
|
// notice, this list of conditions and the following disclaimer.
|
|
|
|
|
// * Redistributions in binary form must reproduce the above
|
|
|
|
|
// 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
|
|
|
|
|
// contributors may be used to endorse or promote products derived from
|
|
|
|
|
// this software without specific prior written permission.
|
2006-09-06 21:28:46 +02:00
|
|
|
//
|
2006-09-20 23:16:16 +02:00
|
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
2006-09-06 21:28:46 +02:00
|
|
|
|
2006-09-07 17:56:38 +02:00
|
|
|
// stackwalker.h: Generic stackwalker.
|
2006-09-06 21:28:46 +02:00
|
|
|
//
|
|
|
|
|
// The Stackwalker class is an abstract base class providing common generic
|
|
|
|
|
// methods that apply to stacks from all systems. Specific implementations
|
|
|
|
|
// will extend this class by providing GetContextFrame and GetCallerFrame
|
|
|
|
|
// methods to fill in system-specific data in a StackFrame structure.
|
|
|
|
|
// Stackwalker assembles these StackFrame strucutres into a vector of
|
|
|
|
|
// StackFrames.
|
|
|
|
|
//
|
|
|
|
|
// Author: Mark Mentovai
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef PROCESSOR_STACKWALKER_H__
|
|
|
|
|
#define PROCESSOR_STACKWALKER_H__
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "google/stack_frame.h"
|
|
|
|
|
#include "processor/memory_region.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace google_airbag {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class MinidumpModuleList;
|
2006-09-08 04:35:53 +02:00
|
|
|
class SymbolSupplier;
|
2006-09-06 21:28:46 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class Stackwalker {
|
2006-09-07 17:56:38 +02:00
|
|
|
public:
|
|
|
|
|
virtual ~Stackwalker() {}
|
|
|
|
|
|
2006-09-08 04:35:53 +02:00
|
|
|
// Fills the given vector of StackFrames by calling GetContextFrame and
|
2006-09-08 06:05:46 +02:00
|
|
|
// GetCallerFrame, and populating the returned frames with all available
|
|
|
|
|
// data.
|
2006-09-08 04:35:53 +02:00
|
|
|
void Walk(StackFrames *frames);
|
2006-09-07 17:56:38 +02:00
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
// memory identifies a MemoryRegion that provides the stack memory
|
|
|
|
|
// for the stack to walk. modules, if non-NULL, is a MinidumpModuleList
|
|
|
|
|
// that is used to look up which code module each stack frame is
|
2006-09-08 04:35:53 +02:00
|
|
|
// associated with. supplier is an optional caller-supplied SymbolSupplier
|
|
|
|
|
// implementation. If supplier is NULL, source line info will not be
|
2006-09-20 02:00:12 +02:00
|
|
|
// resolved.
|
2006-09-08 04:35:53 +02:00
|
|
|
Stackwalker(MemoryRegion* memory,
|
|
|
|
|
MinidumpModuleList* modules,
|
2006-09-20 02:00:12 +02:00
|
|
|
SymbolSupplier* supplier);
|
2006-09-07 17:56:38 +02:00
|
|
|
|
|
|
|
|
// The stack memory to walk. Subclasses will require this region to
|
|
|
|
|
// get information from the stack.
|
|
|
|
|
MemoryRegion* memory_;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
// Obtains the context frame, the innermost called procedure in a stack
|
|
|
|
|
// trace. Returns false on failure.
|
|
|
|
|
virtual bool GetContextFrame(StackFrame* frame) = 0;
|
|
|
|
|
|
|
|
|
|
// Obtains a caller frame. Each call to GetCallerFrame should return the
|
|
|
|
|
// frame that called the last frame returned by GetContextFrame or
|
|
|
|
|
// GetCallerFrame. GetCallerFrame should return false on failure or
|
|
|
|
|
// when there are no more caller frames (when the end of the stack has
|
|
|
|
|
// been reached).
|
|
|
|
|
virtual bool GetCallerFrame(StackFrame* frame) = 0;
|
|
|
|
|
|
|
|
|
|
// A list of modules, for populating each StackFrame's module information.
|
|
|
|
|
// This field is optional and may be NULL.
|
|
|
|
|
MinidumpModuleList* modules_;
|
2006-09-08 04:35:53 +02:00
|
|
|
|
|
|
|
|
// The optional SymbolSupplier for resolving source line info.
|
|
|
|
|
SymbolSupplier* supplier_;
|
2006-09-06 21:28:46 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace google_airbag
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif // PROCESSOR_STACKWALKER_H__
|