mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-21 04:13:22 +08:00
[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:
parent
2115053907
commit
529794221e
45
pykd/pydbgio.h
Normal file
45
pykd/pydbgio.h
Normal 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
27
pykd/pystate.h
Normal 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;
|
||||
};
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user