mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-21 04:13:22 +08:00
[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:
parent
00faeae705
commit
b8811c8554
@ -1,6 +1,6 @@
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "dbgexcept.h"
|
#include "dbgexcept.h"
|
||||||
//#include "diawrapper.h"
|
#include "dbgengine.h"
|
||||||
|
|
||||||
namespace pykd {
|
namespace pykd {
|
||||||
|
|
||||||
@ -17,4 +17,35 @@ python::handle<> exceptPyType<AddSyntheticSymbolException>::pyExceptType;
|
|||||||
python::handle<> exceptPyType<ImplementException>::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
|
}; // end namespace pykd
|
||||||
|
@ -226,5 +226,9 @@ private:
|
|||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void printException();
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
}; // namespace pykd
|
}; // namespace pykd
|
||||||
|
|
||||||
|
@ -208,9 +208,6 @@ py( PDEBUG_CLIENT4 client, PCSTR args )
|
|||||||
|
|
||||||
global["globalEventHandler"] = EventHandlerPtr( new EventHandlerImpl() );
|
global["globalEventHandler"] = EventHandlerPtr( new EventHandlerImpl() );
|
||||||
|
|
||||||
// èìïîðòèðóåì ìîäóëü îáðàáîòêè èñêëþ÷åíèé ( íóæåí äëÿ âûâîäà traceback à )
|
|
||||||
python::object tracebackModule = python::import("traceback");
|
|
||||||
|
|
||||||
// ðàçáîð ïàðàìåòðîâ
|
// ðàçáîð ïàðàìåòðîâ
|
||||||
typedef boost::escaped_list_separator<char> char_separator_t;
|
typedef boost::escaped_list_separator<char> char_separator_t;
|
||||||
typedef boost::tokenizer< char_separator_t > char_tokenizer_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 & )
|
catch( boost::python::error_already_set const & )
|
||||||
{
|
{
|
||||||
// îøèáêà â ñêðèïòå
|
printException();
|
||||||
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() );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
|
@ -50,6 +50,7 @@ DEBUG_CALLBACK_RESULT EventHandlerImpl::OnBreakpoint( ULONG bpId )
|
|||||||
return DEBUG_CALLBACK_RESULT(retVal);
|
return DEBUG_CALLBACK_RESULT(retVal);
|
||||||
}
|
}
|
||||||
catch (const python::error_already_set &) {
|
catch (const python::error_already_set &) {
|
||||||
|
printException();
|
||||||
}
|
}
|
||||||
|
|
||||||
return DebugCallbackBreak;
|
return DebugCallbackBreak;
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include "dbgengine.h"
|
#include "dbgengine.h"
|
||||||
#include "bpoint.h"
|
#include "bpoint.h"
|
||||||
|
#include "dbgexcept.h"
|
||||||
|
|
||||||
namespace pykd {
|
namespace pykd {
|
||||||
|
|
||||||
@ -62,7 +63,7 @@ private:
|
|||||||
return pythonHandler(arg1);
|
return pythonHandler(arg1);
|
||||||
}
|
}
|
||||||
catch (const python::error_already_set &) {
|
catch (const python::error_already_set &) {
|
||||||
//onHandlerException();
|
printException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return DebugCallbackNoChange;
|
return DebugCallbackNoChange;
|
||||||
@ -77,7 +78,7 @@ private:
|
|||||||
return pythonHandler(arg1,arg2);
|
return pythonHandler(arg1,arg2);
|
||||||
}
|
}
|
||||||
catch (const python::error_already_set &) {
|
catch (const python::error_already_set &) {
|
||||||
//onHandlerException();
|
printException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return DebugCallbackNoChange;
|
return DebugCallbackNoChange;
|
||||||
@ -91,12 +92,13 @@ private:
|
|||||||
return pythonHandler();
|
return pythonHandler();
|
||||||
}
|
}
|
||||||
catch (const python::error_already_set &) {
|
catch (const python::error_already_set &) {
|
||||||
//onHandlerException();
|
printException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return DebugCallbackNoChange;
|
return DebugCallbackNoChange;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef boost::shared_ptr<EventHandlerWrap> EventHandlerPtr;
|
typedef boost::shared_ptr<EventHandlerWrap> EventHandlerPtr;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#define PYKD_VERSION_MAJOR 0
|
#define PYKD_VERSION_MAJOR 0
|
||||||
#define PYKD_VERSION_MINOR 2
|
#define PYKD_VERSION_MINOR 2
|
||||||
#define PYKD_VERSION_SUBVERSION 0
|
#define PYKD_VERSION_SUBVERSION 0
|
||||||
#define PYKD_VERSION_BUILDNO 4
|
#define PYKD_VERSION_BUILDNO 6
|
||||||
|
|
||||||
|
|
||||||
#define __VER_STR2__(x) #x
|
#define __VER_STR2__(x) #x
|
||||||
|
Loading…
Reference in New Issue
Block a user