2005-01-16 20:23:20 -05:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: wx/msw/stackwalk.h
|
|
|
|
// Purpose: wxStackWalker for MSW
|
|
|
|
// Author: Vadim Zeitlin
|
|
|
|
// Modified by:
|
|
|
|
// Created: 2005-01-08
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) 2005 Vadim Zeitlin <vadim@wxwindows.org>
|
|
|
|
// Licence: wxWindows licence
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_MSW_STACKWALK_H_
|
|
|
|
#define _WX_MSW_STACKWALK_H_
|
|
|
|
|
2006-09-09 13:29:19 -04:00
|
|
|
#include "wx/arrstr.h"
|
|
|
|
|
2005-01-16 20:23:20 -05:00
|
|
|
// these structs are declared in windows headers
|
|
|
|
struct _CONTEXT;
|
|
|
|
struct _EXCEPTION_POINTERS;
|
|
|
|
|
|
|
|
// and these in dbghelp.h
|
|
|
|
struct _SYMBOL_INFO;
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxStackFrame
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLIMPEXP_BASE wxStackFrame : public wxStackFrameBase
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
wxStackFrame *ConstCast() const
|
2008-11-01 22:39:52 -04:00
|
|
|
{ return const_cast<wxStackFrame *>(this); }
|
2005-01-16 20:23:20 -05:00
|
|
|
|
|
|
|
size_t DoGetParamCount() const { return m_paramTypes.GetCount(); }
|
|
|
|
|
|
|
|
public:
|
|
|
|
wxStackFrame(size_t level, void *address, size_t addrFrame)
|
|
|
|
: wxStackFrameBase(level, address)
|
|
|
|
{
|
|
|
|
m_hasName =
|
|
|
|
m_hasLocation = false;
|
|
|
|
|
|
|
|
m_addrFrame = addrFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual size_t GetParamCount() const
|
|
|
|
{
|
|
|
|
ConstCast()->OnGetParam();
|
|
|
|
return DoGetParamCount();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
GetParam(size_t n, wxString *type, wxString *name, wxString *value) const;
|
|
|
|
|
|
|
|
// callback used by OnGetParam(), don't call directly
|
|
|
|
void OnParam(_SYMBOL_INFO *pSymInfo);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void OnGetName();
|
|
|
|
virtual void OnGetLocation();
|
|
|
|
|
|
|
|
void OnGetParam();
|
|
|
|
|
|
|
|
|
|
|
|
// helper for debug API: it wants to have addresses as DWORDs
|
|
|
|
size_t GetSymAddr() const
|
|
|
|
{
|
2008-11-01 22:39:52 -04:00
|
|
|
return reinterpret_cast<size_t>(m_address);
|
2005-01-16 20:23:20 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool m_hasName,
|
|
|
|
m_hasLocation;
|
|
|
|
|
|
|
|
size_t m_addrFrame;
|
|
|
|
|
|
|
|
wxArrayString m_paramTypes,
|
|
|
|
m_paramNames,
|
|
|
|
m_paramValues;
|
|
|
|
};
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxStackWalker
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLIMPEXP_BASE wxStackWalker : public wxStackWalkerBase
|
|
|
|
{
|
|
|
|
public:
|
2005-01-18 20:15:12 -05:00
|
|
|
// we don't use ctor argument, it is for compatibility with Unix version
|
|
|
|
// only
|
|
|
|
wxStackWalker(const char * WXUNUSED(argv0) = NULL) { }
|
2005-01-16 20:23:20 -05:00
|
|
|
|
2009-01-14 09:38:00 -05:00
|
|
|
virtual void Walk(size_t skip = 1, size_t maxDepth = wxSTACKWALKER_MAX_DEPTH);
|
2008-09-13 20:26:29 -04:00
|
|
|
#if wxUSE_ON_FATAL_EXCEPTION
|
2009-01-14 09:38:00 -05:00
|
|
|
virtual void WalkFromException(size_t maxDepth = wxSTACKWALKER_MAX_DEPTH);
|
2008-09-13 20:26:29 -04:00
|
|
|
#endif // wxUSE_ON_FATAL_EXCEPTION
|
2005-01-16 20:23:20 -05:00
|
|
|
|
|
|
|
|
|
|
|
// enumerate stack frames from the given context
|
2009-01-14 09:38:00 -05:00
|
|
|
void WalkFrom(const _CONTEXT *ctx, size_t skip = 1, size_t maxDepth = wxSTACKWALKER_MAX_DEPTH);
|
|
|
|
void WalkFrom(const _EXCEPTION_POINTERS *ep, size_t skip = 1, size_t maxDepth = wxSTACKWALKER_MAX_DEPTH);
|
2005-01-16 20:23:20 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _WX_MSW_STACKWALK_H_
|
|
|
|
|