[0.3.x] added : pydbgio.h

git-svn-id: https://pykd.svn.codeplex.com/svn@86067 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
SND\kernelnet_cp 2013-10-29 05:49:55 +00:00 committed by Mikhail I. Izmestev
parent 2115053907
commit 529794221e
2 changed files with 72 additions and 0 deletions

45
pykd/pydbgio.h Normal file
View File

@ -0,0 +1,45 @@
#pragma once
#include "kdlib/windbg.h"
#include "pystate.h"
namespace pykd {
///////////////////////////////////////////////////////////////////////////////
class DbgOut : public kdlib::windbg::WindbgOut
{
public:
DbgOut() {
int a = 10;
}
void flush() {
}
std::wstring encoding() {
return L"ascii";
}
};
///////////////////////////////////////////////////////////////////////////////
class DbgIn : public kdlib::windbg::WindbgIn
{
public:
std::wstring readline() {
AutoRestorePyState pystate;
return kdlib::windbg::WindbgIn::readline();
}
std::wstring encoding() {
return L"ascii";
}
};
///////////////////////////////////////////////////////////////////////////////
}

27
pykd/pystate.h Normal file
View File

@ -0,0 +1,27 @@
#pragma once
#include <Python.h>
namespace pykd {
class AutoRestorePyState
{
public:
AutoRestorePyState()
{
m_state = PyEval_SaveThread();
}
~AutoRestorePyState()
{
PyEval_RestoreThread( m_state );
}
private:
PyThreadState* m_state;
};
}