pykd/pykd/dbgexcept.cpp
SND\EreTIk_cp b0a49c7ed4 [0.2.x] + exception handling
git-svn-id: https://pykd.svn.codeplex.com/svn@81883 9b283d60-5439-405e-af05-b73fd8c4d996
2017-11-08 17:42:50 +04:00

56 lines
1.9 KiB
C++

#include "stdafx.h"
#include "dbgexcept.h"
#include "dbgengine.h"
namespace pykd {
///////////////////////////////////////////////////////////////////////////////////
python::handle<> exceptPyType<python::detail::not_specified>::pyExceptType;
python::handle<> exceptPyType<DbgException>::pyExceptType;
python::handle<> exceptPyType<MemoryException>::pyExceptType;
python::handle<> exceptPyType<WaitEventException>::pyExceptType;
python::handle<> exceptPyType<SymbolException>::pyExceptType;
//python::handle<> exceptPyType<pyDia::Exception>::pyExceptType;
python::handle<> exceptPyType<TypeException>::pyExceptType;
python::handle<> exceptPyType<AddSyntheticSymbolException>::pyExceptType;
python::handle<> exceptPyType<WrongEventTypeException>::pyExceptType;
python::handle<> exceptPyType<ImplementException>::pyExceptType;
///////////////////////////////////////////////////////////////////////////////////
void printException()
{
// îøèáêà â ñêðèïòå
PyObject *errtype = NULL, *errvalue = NULL, *traceback = NULL;
PyErr_Fetch( &errtype, &errvalue, &traceback );
PyErr_NormalizeException( &errtype, &errvalue, &traceback );
if ( errtype == PyExc_SystemExit )
return;
python::object tracebackModule = python::import("traceback");
std::wstringstream sstr;
python::object lst =
python::object( tracebackModule.attr("format_exception" ) )(
python::handle<>( errtype ),
python::handle<>( python::allow_null( errvalue ) ),
python::handle<>( python::allow_null( traceback ) ) );
sstr << std::endl << std::endl;
for ( long i = 0; i < python::len(lst); ++i )
sstr << std::wstring( python::extract<std::wstring>(lst[i]) ) << std::endl;
eprintln( sstr.str() );
}
///////////////////////////////////////////////////////////////////////////////////
}; // end namespace pykd