[0.2.x] added : print exception stack from event callback

git-svn-id: https://pykd.svn.codeplex.com/svn@81516 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
SND\kernelnet_cp 2012-11-27 06:49:15 +00:00 committed by Mikhail I. Izmestev
parent 00faeae705
commit b8811c8554
6 changed files with 44 additions and 29 deletions

View File

@ -1,6 +1,6 @@
#include "stdafx.h"
#include "dbgexcept.h"
//#include "diawrapper.h"
#include "dbgengine.h"
namespace pykd {
@ -17,4 +17,35 @@ python::handle<> exceptPyType<AddSyntheticSymbolException>::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 );
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

View File

@ -226,5 +226,9 @@ private:
/////////////////////////////////////////////////////////////////////////////////
void printException();
/////////////////////////////////////////////////////////////////////////////////
}; // namespace pykd

View File

@ -208,9 +208,6 @@ py( PDEBUG_CLIENT4 client, PCSTR args )
global["globalEventHandler"] = EventHandlerPtr( new EventHandlerImpl() );
// èìïîðòèðóåì ìîäóëü îáðàáîòêè èñêëþ÷åíèé ( íóæåí äëÿ âûâîäà traceback à )
python::object tracebackModule = python::import("traceback");
// ðàçáîð ïàðàìåòðîâ
typedef boost::escaped_list_separator<char> char_separator_t;
typedef boost::tokenizer< char_separator_t > char_tokenizer_t;
@ -262,27 +259,7 @@ py( PDEBUG_CLIENT4 client, PCSTR args )
}
catch( boost::python::error_already_set const & )
{
// îøèáêà â ñêðèïòå
PyObject *errtype = NULL, *errvalue = NULL, *traceback = NULL;
PyErr_Fetch( &errtype, &errvalue, &traceback );
PyErr_NormalizeException( &errtype, &errvalue, &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() );
printException();
}
}
catch(...)

View File

@ -50,6 +50,7 @@ DEBUG_CALLBACK_RESULT EventHandlerImpl::OnBreakpoint( ULONG bpId )
return DEBUG_CALLBACK_RESULT(retVal);
}
catch (const python::error_already_set &) {
printException();
}
return DebugCallbackBreak;

View File

@ -6,6 +6,7 @@
#include "dbgengine.h"
#include "bpoint.h"
#include "dbgexcept.h"
namespace pykd {
@ -62,7 +63,7 @@ private:
return pythonHandler(arg1);
}
catch (const python::error_already_set &) {
//onHandlerException();
printException();
}
}
return DebugCallbackNoChange;
@ -77,7 +78,7 @@ private:
return pythonHandler(arg1,arg2);
}
catch (const python::error_already_set &) {
//onHandlerException();
printException();
}
}
return DebugCallbackNoChange;
@ -91,12 +92,13 @@ private:
return pythonHandler();
}
catch (const python::error_already_set &) {
//onHandlerException();
printException();
}
}
return DebugCallbackNoChange;
}
};
typedef boost::shared_ptr<EventHandlerWrap> EventHandlerPtr;

View File

@ -2,7 +2,7 @@
#define PYKD_VERSION_MAJOR 0
#define PYKD_VERSION_MINOR 2
#define PYKD_VERSION_SUBVERSION 0
#define PYKD_VERSION_BUILDNO 4
#define PYKD_VERSION_BUILDNO 6
#define __VER_STR2__(x) #x