dolphin/Externals/wxWidgets3/include/wx/stackwalk.h
Soren Jorvang d14efe561b Import r67258 of the wxWidgets trunk, which I expect will before
long become wxWidgets 2.9.2, which in turn is expected to be the
last 2.9 release before the 3.0 stable release.

Since the full wxWidgets distribution is rather large, I have
imported only the parts that we use, on a subdirectory basis:

art
include/wx/*.*
include/wx/aui
include/wx/cocoa
include/wx/generic
include/wx/gtk
include/wx/meta
include/wx/msw
include/wx/osx
include/wx/persist
include/wx/private
include/wx/protocol
include/wx/unix
src/aui
src/common
src/generic
src/gtk
src/msw
src/osx
src/unix


git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7380 8ced0084-cf51-0410-be5f-012b33b47a6e
2011-03-20 18:05:19 +00:00

160 lines
5.1 KiB
C++

///////////////////////////////////////////////////////////////////////////////
// Name: wx/stackwalk.h
// Purpose: wxStackWalker and related classes, common part
// Author: Vadim Zeitlin
// Modified by:
// Created: 2005-01-07
// RCS-ID: $Id: stackwalk.h 64754 2010-06-26 11:43:13Z FM $
// Copyright: (c) 2004 Vadim Zeitlin <vadim@wxwindows.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_STACKWALK_H_
#define _WX_STACKWALK_H_
#include "wx/defs.h"
#if wxUSE_STACKWALKER
class WXDLLIMPEXP_FWD_BASE wxStackFrame;
#define wxSTACKWALKER_MAX_DEPTH (200)
// ----------------------------------------------------------------------------
// wxStackFrame: a single stack level
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_BASE wxStackFrameBase
{
private:
// put this inline function here so that it is defined before use
wxStackFrameBase *ConstCast() const
{ return const_cast<wxStackFrameBase *>(this); }
public:
wxStackFrameBase(size_t level, void *address = NULL)
{
m_level = level;
m_line =
m_offset = 0;
m_address = address;
}
// get the level of this frame (deepest/innermost one is 0)
size_t GetLevel() const { return m_level; }
// return the address of this frame
void *GetAddress() const { return m_address; }
// return the unmangled (if possible) name of the function containing this
// frame
wxString GetName() const { ConstCast()->OnGetName(); return m_name; }
// return the instruction pointer offset from the start of the function
size_t GetOffset() const { ConstCast()->OnGetName(); return m_offset; }
// get the module this function belongs to (not always available)
wxString GetModule() const { ConstCast()->OnGetName(); return m_module; }
// return true if we have the filename and line number for this frame
bool HasSourceLocation() const { return !GetFileName().empty(); }
// return the name of the file containing this frame, empty if
// unavailable (typically because debug info is missing)
wxString GetFileName() const
{ ConstCast()->OnGetLocation(); return m_filename; }
// return the line number of this frame, 0 if unavailable
size_t GetLine() const { ConstCast()->OnGetLocation(); return m_line; }
// return the number of parameters of this function (may return 0 if we
// can't retrieve the parameters info even although the function does have
// parameters)
virtual size_t GetParamCount() const { return 0; }
// get the name, type and value (in text form) of the given parameter
//
// any pointer may be NULL
//
// return true if at least some values could be retrieved
virtual bool GetParam(size_t WXUNUSED(n),
wxString * WXUNUSED(type),
wxString * WXUNUSED(name),
wxString * WXUNUSED(value)) const
{
return false;
}
// although this class is not supposed to be used polymorphically, give it
// a virtual dtor to silence compiler warnings
virtual ~wxStackFrameBase() { }
protected:
// hooks for derived classes to initialize some fields on demand
virtual void OnGetName() { }
virtual void OnGetLocation() { }
// fields are protected, not private, so that OnGetXXX() could modify them
// directly
size_t m_level;
wxString m_name,
m_module,
m_filename;
size_t m_line;
void *m_address;
size_t m_offset;
};
// ----------------------------------------------------------------------------
// wxStackWalker: class for enumerating stack frames
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_BASE wxStackWalkerBase
{
public:
// ctor does nothing, use Walk() to walk the stack
wxStackWalkerBase() { }
// dtor does nothing neither but should be virtual
virtual ~wxStackWalkerBase() { }
// enumerate stack frames from the current location, skipping the initial
// number of them (this can be useful when Walk() is called from some known
// location and you don't want to see the first few frames anyhow; also
// notice that Walk() frame itself is not included if skip >= 1)
virtual void Walk(size_t skip = 1, size_t maxDepth = wxSTACKWALKER_MAX_DEPTH) = 0;
#if wxUSE_ON_FATAL_EXCEPTION
// enumerate stack frames from the location of uncaught exception
//
// this version can only be called from wxApp::OnFatalException()
virtual void WalkFromException(size_t maxDepth = wxSTACKWALKER_MAX_DEPTH) = 0;
#endif // wxUSE_ON_FATAL_EXCEPTION
protected:
// this function must be overrided to process the given frame
virtual void OnStackFrame(const wxStackFrame& frame) = 0;
};
#ifdef __WXMSW__
#include "wx/msw/stackwalk.h"
#elif defined(__UNIX__)
#include "wx/unix/stackwalk.h"
#else
#error "wxStackWalker is not supported, set wxUSE_STACKWALKER to 0"
#endif
#endif // wxUSE_STACKWALKER
#endif // _WX_STACKWALK_H_